Page 1 of 1

How can I make an NPC appear asleep?

Posted: Tue Oct 14, 2003 5:40 am
by Furin
I have an NPC little boy, and I want him to be asleep always and forever.
I put an onSpawn effect to kill him (so he'd lie down), but he now the instant he appears he falls face-down (good), fades out (bad) and leaves behind 4 gold (sad, really).

How can I get him to stay in place, face-down (or face up--I don't care)?

And ideally, I'd love to get him sawing wood like our PCs do when they sleep (you know, "ZZZZZ...."). Is that possible? I mean, hell, of course it's possible. Can anyone tell me how to do it?

And as a bonus, is it possible to get him to be sleeping on a bed?

Also, I just started using the toolset (yesterday). So don't be bashful about talking to me like I'm an idjit.

Thanks very much,
Furin

Posted: Tue Oct 14, 2003 5:47 am
by marauder
Put this in the onSpawn

Code: Select all

   object oPlayer = OBJECT_SELF;
   AssignCommand (oPlayer, ActionPlayAnimation (iSleepAnimation, 1.0, 5.0)); 
   DelayCommand (7.0f, ApplyEffectToObject (DURATION_TYPE_PERMANENT, eNap, oPlayer, 0.0)); 
   AssignCommand (oPlayer, ActionPlayAnimation (iSleepAnimation, 1.0, 300.0)); 
oPlayer should be the object that you want to sleep. You can rename it accordingly, but this was taken from a script that made a PC sleep, and I did not change the names.

*edited to add duration to be permanent*

Posted: Tue Oct 14, 2003 6:09 am
by Aloro
Why would you DelayCommand something in the OnSpawn?

Also... neither iSleepAnimation nor eNap are defined in the above code. ;)

Generally, if I want the NPC's status to change, I'd add a trigger or an OnEnter script or something like that. Since this is supposed to be an always-on effect (as I understand it), you can simply put something like this in the creature's OnSpawn:

Code: Select all

void main()
{
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSleep(), OBJECT_SELF);
}
- Aloro

Posted: Tue Oct 14, 2003 6:21 am
by marauder
I cut it from some other code. The reason for the delay was because of another animation that was playing if I remember correctly. It is not needed. Also yes I did not notice the iSleepAnimation missing. Yours is a lot better Aloro ;-)