Author Topic: script for sleeping NPC or dead npc?  (Read 388 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
script for sleeping NPC or dead npc?
« on: October 24, 2015, 07:12:08 am »


               

Is there a script that can make an NPC look dead?



               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
script for sleeping NPC or dead npc?
« Reply #1 on: October 24, 2015, 09:20:03 am »


               

You can try to assign him an animation with ActionPlayAnimation(ANIMATION_LOOPING_DEAD_BACK, float Speed, float Duration);


 


Edit: You can add SetCommandable(FALSE); to avoid a PC changing his animation by trying to speak with the NPC, but don't forget to set it to TRUE again if you want to do something else with your NPC!


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
script for sleeping NPC or dead npc?
« Reply #2 on: October 24, 2015, 10:38:34 am »


               

That's a good method.


 


Another one is to set the corpse options you want, then kill the NPC. I often use



SetIsDestroyable(FALSE, TRUE, FALSE);

which makes the NPC corpse unselectable, like a static placeable. This has the advantage that players aren't explicitly told that the NPC is dead; they can't interfere with inventory or converse. You can play around with the parameters to get the effect you need, though.


 


You can kill the NPC with EffectDeath or EffectDamage (the difference being that only the latter fires the OnDeath event, which you might not want in this case).


 


To bring the corpse to life,



    RemoveEffects(oNPC);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectResurrection(), oNPC);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectHeal(GetMaxHitPoints(oNPC)), oNPC);
    SetCommandable(TRUE, oNPC);


               
               

               
            

Legacy_Li'l Rose

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
script for sleeping NPC or dead npc?
« Reply #3 on: October 24, 2015, 01:02:29 pm »


               You could try adding this to the npcs on spawn script. Put the npc in an encounter trigger, and the npc will spawn dead.

{
AssignCommand(OBJECT_SELF, ClearAllActions());
AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_LOOPING_DEAD_BACK, 1.0, 1800.0));

// Apply an effect.
effect eEffect;
eEffect = SupernaturalEffect(EffectParalyze());
DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, OBJECT_SELF));
DelayCommand(1800.0, DestroyObject(OBJECT_SELF));
}

The npc will spawn dead, then lay there for a half hour, or whatever time you want. Then can spawn again later from the encounter trigger. Just be sure that the npc is not immune to a paralyze effect.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
script for sleeping NPC or dead npc?
« Reply #4 on: October 24, 2015, 01:23:03 pm »


               

EffectDeath does fire the onDeath handler. It just does it BEFORE setting the NPC's HitPoints to 0 so things like GetIsDead() return FALSE. So if your onDeath handler starts with "if(!GetIsDead()) return;" or similar it won't do much. But it does fire... '<img'>