How can I make an NPC appear asleep?

Moderator: Event DM

Post Reply
Furin
Scholar of Fools
Posts: 431
Joined: Thu Oct 31, 2002 1:41 am
Location: San Francisco Bay Area, USA (GMT - 7 in summer)

How can I make an NPC appear asleep?

Post by Furin » Tue Oct 14, 2003 5:40 am

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
User avatar
marauder
Scholar
Posts: 1317
Joined: Sun Feb 23, 2003 3:36 am
Location: College Station, TX (GMT -6)
Contact:

Post by marauder » Tue Oct 14, 2003 5:47 am

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*
It is the mark of an educated mind to be able to entertain a thought without accepting it.

-Aristotle
User avatar
Aloro
Team Member; Retired with Honors
Posts: 12805
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End
Contact:

Post by Aloro » Tue Oct 14, 2003 6:09 am

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
Aleksandr Solzhenitsyn wrote:The meaning of earthly existence lies, not as we have grown used to thinking, in prosperity, but in the development of the soul.
User avatar
marauder
Scholar
Posts: 1317
Joined: Sun Feb 23, 2003 3:36 am
Location: College Station, TX (GMT -6)
Contact:

Post by marauder » Tue Oct 14, 2003 6:21 am

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 ;-)
It is the mark of an educated mind to be able to entertain a thought without accepting it.

-Aristotle
Post Reply