Jump to content

[LE] How to check if an NPC is summoned?


Recommended Posts

 

'IsCommandedActor()' is the Papyrus function to recognize an actor that has been summon/conjure or reanimated using the default vanilla system (hard coded).
To distinguish an actor if he is undead, vampire, etc... you combine the function with retrieving the keywords that the actor has in his 'Race', for example:
KeyWord Property KeyWordVampire Auto
Actor TargetActor
 
EVENT OnEffectStart(Actor akTarget, Actor akCaster)
     TargetActor = akTarget
If ( TargetActor.IsCommandedActor() == True ) && ( TargetActor.HasKeyWord(KeyWordVampire) )
 
          ; Do My Stuff
 
 EndIf
ENDEVENT
* I don't remember the exact name of the keywords, I just added the first thing it came to my head, I'm too tired...

 

 

Oh, I know that part.

 

I just don't know if an NPC gains the undead keyword when they're reanimated or not.

 

Would

If (TargetActor.IsCommandedActor()==True) && (TargetActor.haskeyword(actortypeundead))

work for reanimated NPCs as well? When I was planning on doing it before, I planned to just check if the NPC had ANY of the reanimation magic effects running, but if they're already flagged as undead when they become reanimated, then that would just be redundant for me to do.

 

 

If it does NOT flag reanimated npc's as undead, I think I would have to do something like:

 

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
If (TargetActor.IsCommandedActor()==True) && (TargetActor.haskeyword(actortypeundead))

;do stuff here

elseif targetactor.hasmagiceffect(vanillareanimatespell01)
;do same stuff
elseif targetactor.hasmagiceffect(vanillareanimatespell02)
;do same stuff
elseif targetactor.hasmagiceffect(vanillareanimatespell03)
;do same stuff
elseif targetactor.hasmagiceffect(vanillareanimatespell04)
;do same stuff
elseif targetactor.hasmagiceffect(vanillareanimatespell05)
;do same stuff
Edited by saintgrimm92
Link to comment
Share on other sites

You can't flag via script an actor as undead, dynamically adding a keyword to a reference is not supported. So, an npc when dies and then it's reanimated still uses its default race and setup.


If you need to check if an npc was an undead before reanimated, you can only do it by checking the keyword associated with it.


By checking the running magic effect will include ALL actors.


Now, if you need to check if the actor is 'commanded' + is undead + is under the influence of the reanimate spell, you need to check them all via script, example:


If (TargetActor.IsCommandedActor()==True) && (TargetActor.haskeyword(actortypeundead)) && (TargetActor.HasMagicEffect(ReanimateFX))

Link to comment
Share on other sites

Well technically, aliases have the capability to add keywords. If you force ref someone, they will now have any keywords the alias was built with until unaliased

 

I have never seen a need to go this route, since whatever goal can usually be attained another way, but it is a solid avenue to add a keyword at runtime

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...