1 #using scripts\shared\ai_shared;
2 #using scripts\shared\array_shared;
3 #using scripts\shared\clientfield_shared;
4 #using scripts\shared\callbacks_shared;
6 #insert scripts\shared\archetype_shared\archetype_shared.gsh;
7 #insert scripts\shared\ai\systems\animation_state_machine.gsh;
8 #insert scripts\shared\shared.gsh;
16 #define FACIAL_STATE_COMBAT "combat"
17 #define FACIAL_STATE_COMBAT_AIM "combat_aim"
18 #define FACIAL_STATE_COMBAT_SHOOT "combat_shoot"
19 #define FACIAL_STATE_DEATH "death"
20 #define FACIAL_STATE_MELEE "melee"
21 #define FACIAL_STATE_PAIN "pain"
22 #define FACIAL_STATE_ANIMSCRIPTED "animscripted"
24 #define FACIAL_STATE_INACTIVE "inactive"
26 #define FACIAL_SYSTEM_FADE_DIST GetDvarInt( "ai_clientFacialCullDist", 2000 )
28 #using_animtree( "generic" );
32 if ( SessionModeIsZombiesGame() && GetDvarInt(
"splitscreen_playerCount" ) > 2 )
43 if( !IsDefined( level.__facialAnimationsList ) )
56 if (
self HasDObj( localClientNum ) )
58 self ClearAnim( %faces, 0 );
65 if( isdefined(
self ) )
67 self notify(
"stopFacialThread");
69 if (
IS_TRUE(
self.facialDeathAnimStarted ) )
73 self.facialDeathAnimStarted =
true;
79 assert( !IsDefined( level.__facialAnimationsList ) );
81 level.__facialAnimationsList = [];
117 foreach( deathAnim
in deathAnims )
119 assert( !IsAnimLooping( localClientNum, deathAnim ),
"FACIAL ANIM - Death facial animation " + deathAnim +
" is set to looping in the GDT. It needs to be non-looping." );
125 if ( SessionModeIsCampaignGame() )
128 primaryDeltaAnim =
self GetPrimaryDeltaAnim();
129 if ( isdefined( primaryDeltaAnim ) )
131 primaryDeltaAnimLength = GetAnimLength( primaryDeltaAnim );
132 notetracks = GetNotetracksInDelta( primaryDeltaAnim, 0, 1 );
133 foreach( notetrack
in notetracks )
135 if ( notetrack[1] ==
"facial_anim" )
137 facialAnim = notetrack[2];
138 facialAnimLength = GetAnimLength( facialAnim );
141 if ( facialAnimLength < primaryDeltaAnimLength && !IsAnimLooping( localClientNum, facialAnim ) )
160 self endon (
"entityshutdown");
161 self endon (
"stopFacialThread");
178 asmStatus =
self ASMGetStatus( localClientNum );
179 forceNewAnim =
false;
189 if ( isdefined( animOverride ) )
192 scriptedAnim =
self GetPrimaryDeltaAnim();
193 if ( isdefined( scriptedAnim ) && ( !isdefined(
self._scriptedAnim ) ||
self._scriptedAnim != scriptedAnim ) )
195 self._scriptedAnim = scriptedAnim;
198 if ( isdefined( animOverride ) && animOverride !==
self._currentFaceAnim )
218 if( !IsDefined( closestPlayer ) )
224 if( !
self HasDObj(localClientNum) || !
self HasAnimTree() )
230 currFaceState =
self._currentFaceState;
231 currentASMState =
self ASMGetCurrentState( localClientNum );
232 if( isdefined( currentASMState ) )
234 currentASMState = ToLower( currentASMState );
237 if(
self ASMIsTerminating( localClientNum ) )
245 else if( IsDefined( currentASMState ) && IsSubStr( currentASMState,
"pain" ) )
249 else if( IsDefined( currentASMState ) && IsSubStr( currentASMState,
"melee" ) )
253 else if(
self ASMIsShootLayerActive( localClientNum ) )
257 else if(
self ASMIsAimLayerActive( localClientNum ) )
268 Assert( IsDefined( level.__facialAnimationsList[
self.archetype][nextFaceState] ) );
270 clearOnCompletion =
false;
277 animToPlay = array::random( level.__facialAnimationsList[
self.archetype][nextFaceState] );
278 if ( isdefined( animOverride ) )
280 animToPlay = animOverride;
281 assert( nextFaceState !=
FACIAL_STATE_DEATH || !IsAnimLooping( localClientNum, animToPlay ),
"FACIAL ANIM - Death facial animation " + animToPlay +
" is set to looping in the GDT. It needs to be non-looping." );
285 self._currentFaceState = nextFaceState;
299 if( IsDefined( animation ) )
301 self._currentFaceAnim = animation;
303 if(
self HasDObj(localClientNum) &&
self HasAnimTree() )
305 self SetFlaggedAnimKnob(
"ai_secondary_facial_anim", animation, 1.0, 0.1, 1.0 );
307 if( clearOnCompletion )
309 wait( GetAnimLength( animation ) );
321 if ( GetMigrationStatus(localClientNum) )
324 if( IsDefined(
self ) &&
325 IsDefined( level.__facialAnimationsList ) &&
326 IsDefined( level.__facialAnimationsList[
self.archetype] ) &&
329 animToPlay = array::random( level.__facialAnimationsList[
self.archetype][
FACIAL_STATE_DEATH] );
331 if ( isdefined( animOverride ) )
333 animToPlay = animOverride;
343 if( IsDefined(
self._currentFaceAnim ) &&
self HasDObj(localClientNum) &&
self HasAnimTree() )
345 self ClearAnim(
self._currentFaceAnim, 0.2 );
348 self._currentFaceAnim = undefined;