ripvanwinkle111 Posted March 5, 2012 Author Share Posted March 5, 2012 convoluted workaround for scripts that receive actor events: Instead of using IsDead(), try making a new bool variable and setting it in an OnDying() event. I've had issues with OnDeath() events but OnDying() always fires in my experience. example: bool ActorDead = False Even OnDying(Actor akKiller) ActorDead = True ;you can now use <if ActorDead> instead of <if IsDead()> EndEvent Yeah, I'm using this workaround at the moment. I still need to add another event so if the player resurrects them, then the flag is set back to false the next time the player talks to them. Link to comment Share on other sites More sharing options...
gsmanners Posted March 5, 2012 Share Posted March 5, 2012 Here's an example of how you would use IsDead: Scriptname DA06GiantScript extends ReferenceAlias Quest Property DA06 Auto Event OnDeath (Actor Killer) DA06QuestScript QuestScript = DA06 as DA06QuestScript if Killer == Game.GetPlayer() if DA06.GetStage() == 100 if Yamarz.GetActorReference().IsDead() HammerGroveScene.Start() endif endif endif QuestScript.GiantDead100 = 1 Yamarz.GetActorReference().EvaluatePackage() DA06.SetObjectiveCompleted(100,1) DA06.SetObjectiveDisplayed(110,1) EndEvent ReferenceAlias Property Yamarz Auto Scene Property HammerGroveScene Auto Link to comment Share on other sites More sharing options...
ripvanwinkle111 Posted March 6, 2012 Author Share Posted March 6, 2012 Here's an example of how you would use IsDead: Scriptname DA06GiantScript extends ReferenceAlias Quest Property DA06 Auto Event OnDeath (Actor Killer) DA06QuestScript QuestScript = DA06 as DA06QuestScript if Killer == Game.GetPlayer() if DA06.GetStage() == 100 if Yamarz.GetActorReference().IsDead() HammerGroveScene.Start() endif endif endif QuestScript.GiantDead100 = 1 Yamarz.GetActorReference().EvaluatePackage() DA06.SetObjectiveCompleted(100,1) DA06.SetObjectiveDisplayed(110,1) EndEvent ReferenceAlias Property Yamarz Auto Scene Property HammerGroveScene Auto Thanks, I'll give that a try later. EDIT: Well, that didn't work either..Yamarz is an alias and GetActorReference() is suppsed to return an actor,but when I tried it, it said it is not a funtion. debug.messagebox("NPC isdead? = "+self.GetActorReference().isdead() ) I also tried this, same effect. debug.messagebox("NPC isdead? = "+(self.getbaseobject() as Actor).GetActorReference().isdead() ) EDIT: Well, I found part of the problem. self.getbaseobject() returns the NPC's baseid but (self.getbaseobject() as Actor) returns none. Sadly (self.getbaseobject() as Actor) is the only one that doesn't throw an error when I add .isdead() Link to comment Share on other sites More sharing options...
fg109 Posted March 6, 2012 Share Posted March 6, 2012 (edited) Just a question, are you attaching the script to the actor, or are you attaching it to a magic effect on the actor? Because if it's the latter, then "Self" would not return the actor the magic effect is on. Otherwise I have no idea what's going on. I just tested the IsDead() function and it seems to work fine. I made a spell to test it (I usually do) and cast it on some NPCs before and after I killed them, and it worked just fine. Scriptname fg109TestMEScript extends ActiveMagicEffect Event OnEffectStart(Actor akTarget, Actor akCaster) if (akTarget.IsDead()) Debug.Notification("I'm dead!") else Debug.Notification("I'm not dead!") endif utility.wait(2) float hp = akTarget.GetAV("health") if (hp > 0) Debug.Notification("I should be alive! Current health is " + hp + ".") else Debug.Notification("I should be dead! Current health is " + hp + ".") endif EndEvent If you are putting the script on an actor and IsDead() doesn't work, you could try using GetAV("health") as a workaround. Edited March 6, 2012 by fg109 Link to comment Share on other sites More sharing options...
ctzto Posted March 6, 2012 Share Posted March 6, 2012 (edited) bool function IsDead(Actor John) native bool JohnIsDead = John.IsDead() Since IsDead() will check for you as it is a predetermined function of papyrus then all you have to check if the created variable JohnIsDead as 1 or true or 0 or false. I'm not 100% with this as IsDead was used only for self and not an npc on the wiki. Edited March 6, 2012 by ctzto Link to comment Share on other sites More sharing options...
ripvanwinkle111 Posted March 7, 2012 Author Share Posted March 7, 2012 Well, the script is attached directly to the npc so I have no clue why it won't work. Both of these lines don't compile. debug.messagebox("NPC isdead? = "+(self as Actor).isdead() )debug.messagebox("NPC isdead? = "+self.isdead() ) I tried it your way, but once I have that bool, I can't get it to make a function call back to let the NPC know that it's dead (or store the variable).The first script compiles fine, but the second part says : cannot cast a actor to a MyNPCscript, types are incompatibleI left out the part about ondeath cast spell on self. --------------Script on the NPC-------------compiles fine---------function amidead(Actor akTarget, Actor akCaster)debug.messagebox("Am I dead? = "+akTarget.isdead())endfunction----------------------------------------------------- ----------------Script on the magiceffect---------------doesn't compile----------Event OnEffectStart(Actor akTarget, Actor akCaster)if (akTarget.IsDead()) npcdead = true (akCaster as MyNPCscript).amidead(akTarget,akCaster)endif EndEvent--------------------------------------------------- EDIT: Ok, I figured it out, my problem is that I took the default setting when adding a script. The default when adding a script to an NPC is ObjectReference Scriptname MyNPCscript extends ObjectReference Instead, it should be Actor Scriptname MyNPCscript extends Actor Now everything works fine. Link to comment Share on other sites More sharing options...
Recommended Posts