Aller au contenu

Photo

script for sleeping NPC or dead npc?


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Who said that I

Who said that I
  • Members
  • 492 messages

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



#2
Krevett

Krevett
  • Members
  • 104 messages

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!



#3
Proleric

Proleric
  • Members
  • 2 352 messages

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);


#4
Li'l Rose

Li'l Rose
  • Members
  • 30 messages
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.
  • Who said that I aime ceci

#5
meaglyn

meaglyn
  • Members
  • 808 messages

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... :)


  • Proleric et Verilazic aiment ceci