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
How can I make an NPC appear asleep?
Moderator: Event DM
- marauder
- Scholar
- Posts: 1317
- Joined: Sun Feb 23, 2003 3:36 am
- Location: College Station, TX (GMT -6)
- Contact:
Put this in the onSpawn
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*
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));
*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
-Aristotle
- Aloro
- Team Member; Retired with Honors
- Posts: 12805
- Joined: Sat Dec 28, 2002 5:11 am
- Location: Rainbow's End
- Contact:
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:
- Aloro
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);
}
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.
- marauder
- Scholar
- Posts: 1317
- Joined: Sun Feb 23, 2003 3:36 am
- Location: College Station, TX (GMT -6)
- Contact:
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
-Aristotle