Sleeping AI

From The DarkMod Wiki
Jump to navigationJump to search

Introduction

Sleeping AI are (mostly) working now. They can either put themselves to bed at map start and remain there (unless alerted) or else patrol there, sleep for a while, then patrol again.


Non-patrolling sleepers

These are defined as sleepers at the start and immediately lay down. They only will get up if alerted.


Set on the AI the spawn arg:

sleeping 1


Patrol sleepers

This is done by targetting a path_sleep entity which then targets a path_wait to define how long they will sleep before getting up again.


Setting up

By default, place the AI on the right side of the bed (as you look towards the head of the bed) and facing away from the bed.


Direction

If you want the AI to start from the left side of the bed (as you look towards the head of the bed) then add:

lay_down_left 0 (note this goes on the AI if the AI is using sleeping 1 BUT on the path_sleep if you are using a path_sleep)

Sleeping position in the bed

Stand the AI close to the bed about half way between the head and the foot; adjust as needed.

The distance the AI slides across onto the bed can be controlled by

lay_down_slide_dist 16 (default)

(note this goes on the AI if the AI is using sleeping 1 BUT on the path_sleep if you are using a path_sleep)

Monster clip the bed or not?

Yes, monster clip should not directly effect the sleep animation and the bed should normally be monsterclipped anyway. The only way it might affect it is if the clip sticks out too far and stops the AI getting near enough. In that case reduce narrow the clip close to the bed edge and/or adjust the slide value (see #Sleeping position in the bed

Problems, Troubleshooting

There are a few known problems:

AI is sinking into the bed or floating high

AI animate to the same height so if they are slightly high the first thing to check is the bed surface height. Most Dark Mod beds are a standard height which is correct for sleepers. One known bed (at time of writing) is a little high so AI will animate into it so be sunk a little low. This bed can be sunk a little into the floor to compensate. If they are floating slightly high then the bed can be lifted a little and perhaps some wood brushes under the legs make it right.

If the AI are floating very high then this is most likely caused by the AI clipping into the bed at the start so they are lifted up to stand on its edge before they animate. They then animate up even higher. Solution: move them further out at the start. Note: this problem probably only affects AI that start off sleeping rather than patrol to a bed.


AI lays down too far to one side of the bed

To move an AI across the bed see #Sleeping position in the bed


AI lays wrong way head to foot

If the AI is laying the wrong way with his head at the foot of the bed and his feet at the head then see #Direction

Known bugs

AI have their eyes closed now while sleeping. This is using the pain anim as a place holder at the moment, since we don't have a suitable anim yet (sleeping looks like a quite painful experience now...)

Another problem is that the bounding box stays behind and is solid when the AI goes to bed.

When you KO a sleeping AI, they may drop down through the bed, pop back to standing, like they did in Thief,

Also this is probably unrelated but might be contributing to this problem: I'm noticing that KO'd AI are sometimes(?) flashing into the AF pose for just a frame, then back to the pose they were in before KO'ing. You can see it if you watch really closely.

There is also a problem when they see the player while laying down - they jump up for a moment, then finsih putting themselves to bed and then finally get up to chase the player.