Sys ambient h
The Ambient System include file, sys_ambient_h, is the implementation of the ambient behaviour system.
By default, ambient behaviour begins when a creature sees the player and ceases a short time after the party leaves the creature's sight. Ambient behaviour alternates between a movement phase and an animation phase. In a movement phase, the creature (optionally) moves to a new destination object. In an animation phase, the creature (optionally) performs one or more animations either in sequence or at random. Exact behaviour is controlled by local variables on the creature template (see below).
The actions comprising the animation pattern used in an animation phase are listed in ambient_ai.xls. Each row defines an animation pattern consisting of up to nine actions. Each action is composed of an animation (left of the decimal) and loop count (right of decimal). For example, 619.05 will play a sleeping animation for 5 loops and 619.99 will loop infinitely. Non-looping animations require no loop count (e.g. 808.00 = point right).
The only functions safe to call outside sys_ambient_h or creature_core are:
Local variables stored on the creature used by this script:
AMBIENT_SYSTEM_STATE= State bitmask of AMBIENT_SYSTEM_* values
AMBIENT_MOVE_PATTERN= Ambient movement pattern constant AMBIENT_MOVE_*
AMBIENT_MOVE_PREFIX= Prefix of ambient movement destination (waypoint or creature)
AMBIENT_ANIM_PATTERN= Ambient animation pattern - index into ambient_ai.xls
AMBIENT_ANIM_FREQ= Animation frequency:
- 0.0 = no animations
- -1.0 = play all in order
- x.y = play random number (between x and y) animations in random order
AMBIENT_ANIM_PATTERN_OVERRIDE= (Internal use) If non-zero, takes precedence over AMBIENT_ANIM_PATTERN
AMBIENT_ANIM_FREQ_OVERRIDE= (Internal use) If non-zero, takes precedence over AMBIENT_ANIM_FRE
AMBIENT_ANIM_OVERRIDE_COUNT= (Internal use) If non-zero, the number of times to play the override animation pattern before resuming the default animation pattern
AMBIENT_ANIM_STATE= (Internal use) Animation state
- 0 = start move phase
- -1 = start anim phase
- +ve = # anims left to play
AMBIENT_MOVE_STATE= (Internal use) loword = # of the waypoint moved to last, hiword = direction of travel
AMBIENT_MOVE_COUNT= (Internal use) Number of NPC/WPs available to move to