How to separate creatures from other actors in a script?

Post » Tue Jun 19, 2012 4:30 am

There is no IsCreature command for the actor script.

Is there some trick to say test for six (creatures I assume have no six) for a script to detect if an actor is a creature or not?
User avatar
Tom
 
Posts: 3463
Joined: Sun Aug 05, 2007 7:39 pm

Post » Tue Jun 19, 2012 4:46 am

I think the best bet would be to check factions. I believe most creatures belong to one of like 2 or 3 creature factions.
User avatar
Kim Kay
 
Posts: 3427
Joined: Fri Oct 13, 2006 10:45 am

Post » Tue Jun 19, 2012 6:25 am

There is no IsCreature command for the actor script.

Is there some trick to say test for six (creatures I assume have no six) for a script to detect if an actor is a creature or not?

Yes there is, but I won't tell :P ...... (yet)
User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Tue Jun 19, 2012 5:35 am

Thanks, I was worried about doing it that way because of the number of factions it may be, but if it is only like there that is ok then.

I think the best bet would be to check factions. I believe most creatures belong to one of like 2 or 3 creature factions.
User avatar
Ben sutton
 
Posts: 3427
Joined: Sun Jun 10, 2007 4:01 am

Post » Tue Jun 19, 2012 7:31 am

Ok,

You can try to use HasKeyWord function to check.
Some keyword to test: ActorTypeDragon, ActorTypeAnimal, ActorTypeCow, ActorTypeNPC, Horse, Giant, .....

I was hesitant earlier because this might not work if other mods actually add new creatures or NPC types and I was doing some ingame testing. The above function always return correct type check. But if the mod owner forgot to set keyword to new creature type or NPC type when he/she creates a new race/creature, then he/she could potentially mess your mod up :)
User avatar
Kelly John
 
Posts: 3413
Joined: Tue Jun 13, 2006 6:40 am

Post » Tue Jun 19, 2012 3:11 pm

I am going to try the faction method as it should only be about 3 factions. But the following is not working and I suspect it is my use of "!" or it is that I am using faction CreatureFaction and "faction" should be something else?

When I say it does not work I mean ALL the actors even the creatures are getting the spells.


Scriptname aadpMainCombatQuest extends Questspell Property ActorCombatAbility Autofaction CreatureFactionfaction PreyFactionfaction DwarvenAutomationFactionspell Property TestIt AutoEVENT onInit()				 registerForUpdate(0.2)endEVENTEVENT onUpdate()								  Actor randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 2000)if !randomActor.IsDead() && !randomActor.IsInFaction(CreatureFaction) && !randomActor.IsInFaction(DwarvenAutomationFaction) && !randomActor.IsInFaction(PreyFaction)  if (randomActor.Hasspell(ActorCombatAbility) == 0)	 randomActor.Addspell(ActorCombatAbility)	 randomActor.Addspell(TestIt)  ;Debug.messagebox("spell now on " + randomactor)  endifendif			endEVENT
User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Tue Jun 19, 2012 12:22 am

If ActorCombatAbility is an ability then HasSpell will never return true as it only returns true for Spells or Shouts.

What you need is HasMagicEffect() or HasEffectKeyword().
User avatar
N3T4
 
Posts: 3428
Joined: Wed Aug 08, 2007 8:36 pm

Post » Tue Jun 19, 2012 6:17 am

um? wow really, I thought I had tested that. Ok, thanks!

But what about my OP on why this part is not working? (see below)


if !randomActor.IsDead() && !randomActor.IsInFaction(CreatureFaction) && !randomActor.IsInFaction(DwarvenAutomationFaction) && !randomActor.IsInFaction(PreyFaction)



If ActorCombatAbility is an ability then HasSpell will never return true as it only returns true for Spells or Shouts.

What you need is HasMagicEffect() or HasEffectKeyword().
User avatar
Céline Rémy
 
Posts: 3443
Joined: Sat Apr 07, 2007 12:45 am

Post » Tue Jun 19, 2012 3:59 am

I am going to try the faction method as it should only be about 3 factions. But the following is not working and I suspect it is my use of "!" or it is that I am using faction CreatureFaction and "faction" should be something else?

When I say it does not work I mean ALL the actors even the creatures are getting the spells.


Scriptname aadpMainCombatQuest extends Questspell Property ActorCombatAbility Autofaction CreatureFactionfaction PreyFactionfaction DwarvenAutomationFactionspell Property TestIt AutoEVENT onInit()				 registerForUpdate(0.2)endEVENTEVENT onUpdate()								  Actor randomActor = Game.FindRandomActorFromRef(Game.GetPlayer(), 2000)if !randomActor.IsDead() && !randomActor.IsInFaction(CreatureFaction) && !randomActor.IsInFaction(DwarvenAutomationFaction) && !randomActor.IsInFaction(PreyFaction)  if (randomActor.Hasspell(ActorCombatAbility) == 0)	 randomActor.Addspell(ActorCombatAbility)	 randomActor.Addspell(TestIt)  ;Debug.messagebox("spell now on " + randomactor)  endifendif			endEVENT

It's not working because "faction CreatureFaction" is just creating an empty variable. What you need is to set up faction properties on your script.
User avatar
Angela
 
Posts: 3492
Joined: Mon Mar 05, 2007 8:33 am

Post » Mon Jun 18, 2012 11:11 pm

Right, but how? The wiki page that describes these functions (such as GetInFaction) does not include that info. I know it is likely cross referenced to some other page in the wiki but where?

see here: http://www.creationkit.com/GetInFaction

Up till now I have been GUESSING at the properties set up for all the functions I use.

It's not working because "faction CreatureFaction" is just creating an empty variable. What you need is to set up faction properties on your script.
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Post » Tue Jun 19, 2012 5:15 am

Right, but how? The wiki page that describes these functions (such as GetInFaction) does not include that info. I know it is likely cross referenced to some other page in the wiki but where?

see here: http://www.creationkit.com/GetInFaction

Up till now I have been GUESSING at the properties set up for all the functions I use.
just double click the script instead of going to edit source, and it will bring up the properties window. right click on the left and add new property, select type faction, give it a name, save it, then after it loads click on edit value and change the value to the faction you want to check for. then in your script you can just use !randomactor.isinfaction(factionpropertynamehere).

You should check out the Papyrus tutorials here: http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Variables_and_Conditionals and here: http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties_and_Functions
User avatar
Lovingly
 
Posts: 3414
Joined: Fri Sep 15, 2006 6:36 am

Post » Tue Jun 19, 2012 10:07 am

Good info, thanks, but not directly what I was referring to. I found what my issue was, I forgot to add AUTO at the end:

faction Property CreatureFaction auto

But my complaint about the page is that this part in red

faction Property CreatureFaction auto

is the part I always have to guess at because the page that lists the function does not include this info. So I am wondering how you guys are getting this part? Say for example I want to use a function like this:

http://www.creationkit.com/HasSpell_-_Actor

No where on the page does it say to use the word SPELL to do this:

Spell Properties Myspell Auto

Now it is easy to guess that the needed word is SPELL and I have been guessing most of them, but I do not want to guess anymore.

Thank you for your patience with me. I am a warrior not a programmer. :unsure:


just double click the script instead of going to edit source, and it will bring up the properties window. right click on the left and add new property, select type faction, give it a name, save it, then after it loads click on edit value and change the value to the faction you want to check for. then in your script you can just use !randomactor.isinfaction(factionpropertynamehere).

You should check out the Papyrus tutorials here: http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Variables_and_Conditionals and here: http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties_and_Functions
User avatar
Cayal
 
Posts: 3398
Joined: Tue Jan 30, 2007 6:24 pm

Post » Tue Jun 19, 2012 9:27 am

Here is a complete list of native object types on the wiki - http://www.creationkit.com/Category:Script_Objects

Cipscis
User avatar
le GraiN
 
Posts: 3436
Joined: Thu Mar 22, 2007 6:48 pm

Post » Tue Jun 19, 2012 4:04 am

For your example there: It says the parameters is a SPELL or SHOUT. So that means you have to pass it a SPELL or SHOUT property. Just like IsInFaction says the parameters is a FACTION. If you use the properties menu to create the property rather than typing it out, it gives you a list of types to choose from and also puts in the AUTO by itself.
User avatar
Oyuki Manson Lavey
 
Posts: 3438
Joined: Mon Aug 28, 2006 2:47 am

Post » Tue Jun 19, 2012 4:10 am

I found a horse that is not in the Creature faction (the wagon horse) ...bummer. I thought all the creatures would fall into the Creature Faction because even the dragons did.

I cannot believe Bethesda did not include some way to detect creatures like they did in Oblivion. :dry:

Even if I do get all the factions some mod may make their own faction for their mod creatures.
User avatar
His Bella
 
Posts: 3428
Joined: Wed Apr 25, 2007 5:57 am

Post » Tue Jun 19, 2012 12:21 pm

It's more that everything is an actor now, instead of having creatures as a separate type. While this might be inconvenient at times, it's more often going to be the opposite.

I'm sure there must be some keyword or set of keywords that specifies that an Actor either is or isn't a creature or NPC. This seems like exactly the type of thing that keywords are for.

Cipscis
User avatar
Rudy Paint fingers
 
Posts: 3416
Joined: Sun Nov 11, 2007 1:52 am

Post » Tue Jun 19, 2012 8:50 am

Except that when a moder makes a creature in Oblivion it is automatically detectable.

In skyrim I have to prey that all the moders that make NPC or creatures ALSO take the time to add the keyword attribute AND add it with the EXACT right key word. I know that assumption will bite me in the butt sooner or latter.

Maybe there is a way to detect the skeleton of the modle used? Or something else that is only used for Humanoids?

Rats....This would not be an issue if we still had PLAYGROUP command that automatically picked the proper animation for the "race" (creature type) it is called on.


Maybe a actor value check? Will a check for say SpeechCraft only give above ZERO for NPC actors?




It's more that everything is an actor now, instead of having creatures as a separate type. While this might be inconvenient at times, it's more often going to be the opposite.

I'm sure there must be some keyword or set of keywords that specifies that an Actor either is or isn't a creature or NPC. This seems like exactly the type of thing that keywords are for.

Cipscis
User avatar
jessica breen
 
Posts: 3524
Joined: Thu Aug 03, 2006 1:04 am

Post » Tue Jun 19, 2012 1:49 am

nope... Horse and other animals have 15 speech as do some NPC. :wallbash:
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Tue Jun 19, 2012 10:34 am

I found a horse that is not in the Creature faction (the wagon horse) ...bummer. I thought all the creatures would fall into the Creature Faction because even the dragons did.

I cannot believe Bethesda did not include some way to detect creatures like they did in Oblivion. :dry:

Even if I do get all the factions some mod may make their own faction for their mod creatures.
the cart horse (HorseForCarriageNew) is in the CreatureFriendFaction. Theres that faction, the CreatureFaction, the PreyFaction, and the PredatorFaction. those 4 should cover pretty much every creature. Other mods could of course add creatures that aren't of the right factions, but unfortunately that's something you're going to run into no matter what method you use.

One other thing to look into is soul trapping. Soulgems have a variable that let you choose whether it should be able to take NPC souls or not. I'm not sure if that NPC flag on Actors is hard-coded or not, or if there is any way to get that data. I haven't found it anywhere, unfortunately.

You could also use Actor.GetRace(), but again it's going to have the same problem where mod-added races won't be counted. Actually I imagine that's how the soultrap check works internally...
User avatar
Mark Churchman
 
Posts: 3363
Joined: Sun Aug 05, 2007 5:58 am

Post » Tue Jun 19, 2012 6:38 am

Aha I found what you're looking for I think.

randomActor.GetRace().HasKeyword(akKeyword)

for akKeyword you'd use either ActorTypeNPC for humanoids, or ActorTypeCreature for creatures, either one in a KEYWORD property, of course.

It still has the issue of modders not adding the right keywords to their races, but it's about as simple and as effective as you're going to get I think. Also with this method if they add new NPCs or creatures of an existing race, they'll be covered.

edit: There's also ActorTypeDwarven for dwarven constructs
User avatar
Eilidh Brian
 
Posts: 3504
Joined: Mon Jun 19, 2006 10:45 am

Post » Tue Jun 19, 2012 10:47 am

Aha I found what you're looking for I think.

randomActor.GetRace().HasKeyword(akKeyword)

for akKeyword you'd use either ActorTypeNPC for humanoids, or ActorTypeCreature for creatures, either one in a KEYWORD property, of course.

It still has the issue of modders not adding the right keywords to their races, but it's about as simple and as effective as you're going to get I think. Also with this method if they add new NPCs or creatures of an existing race, they'll be covered.

edit: There's also ActorTypeDwarven for dwarven constructs
In my mod I separate targets by normal NPCs and pretty much everything else. This is what I use. If the "target" of whatever I'm doing "HasKeyword(ActorTypeNPC)" that means they are an NPC. If they don't they are a creature. You can further separate the check by dragons and other stuff. Just look at the races for the actors you are thinking of using inside the editor, and check their keyword list. Check and see who has what keyword, and adjust your code accordingly.

There are 3 keywords that I know are used.

ActorTypeNPC
ActorTypeDragon
ActorTypeCreature

If the target has any of those 3 keywords, they are that "type" of target.
User avatar
marie breen
 
Posts: 3388
Joined: Thu Aug 03, 2006 4:50 am

Post » Tue Jun 19, 2012 2:02 am

Can you not exclude creatures via a 'do they have a weapon equipped' counter?
User avatar
Fam Mughal
 
Posts: 3468
Joined: Sat May 26, 2007 3:18 am

Post » Tue Jun 19, 2012 11:14 am

Can you not exclude creatures via a 'do they have a weapon equipped' counter?
Not all NPCs have weapons equipped... Some, especially mages, don't bother with hunks of steel.
User avatar
teeny
 
Posts: 3423
Joined: Sun Feb 25, 2007 1:51 am


Return to V - Skyrim