NPC spawn's laying down and kneeling

NPC spawn's laying down and kneeling
Spawning in Praying or just about anyother action is simple. In fact I can't believe I haven't coverd it already. To spawn them in Praying, Simply add this to the bottom of the NPCs OnSpawn Script. This one is set to 90000 Sec. which should be long enough for the NPC to stay there Until interupted.

ActionPlayAnimation(ANIMATION_LOOPING_WORSHIP,1.0,90000.0);

A PC clicking on them will make them get up, or you can use anouther script to send a ClearAllActions to the NPC. To make them go back to kneeling, issue that same line in a script. NOTE: You may need to use AssignCommand with it.

To Spawn them sleeping, is just as easy, getting them to wake up is another story. Add this script to the bottom of the NPCs OnSpawn script.

effect eSleep = EffectSleep; ApplyEffectToObject(DURATION_TYPE_INSTANT,eSleep,OBJECT_SELF);

Now, to get them to Wake up, you need to loop through the effects, look for the Sleep effect, then remove it. You can wake them up anyway you want and the scripting is simmulare, but Iwill do this in a Trigger neer the NPC. When the PC enter the Trigger, the NPC will wake up. This is just basic, you could add it to the OnPerception and make a Skill check to see if the NPC "hears" the PC.

Put this script in a Trigger neer the NPC and Replace "NPC_TAG" with that of the actual NPC. Make sure the TAG is Unique.

void main {   if(!GetIsPC(GetEnteringObject))return; object oNPC = GetObjectByTag("NPC_TAG"); effect eSleep = GetFirstEffect(oNPC); while(GetIsEffectValid(eSleep)) {       if(GetEffectType(eSleep) == EFFECT_TYPE_SLEEP) {           RemoveEffect(oNPC,eSleep); }       eSleep = GetNextEffect(oNPC); } }

Thats also the Basics on how to remove any effect. RemoveEffect alone won't do it.

Unless you use some kind of a hak-pack. you won't be able to get the NPC to Sleep on the Bed. You can, however, get them to sleep on top of a Bedroll.