‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_nuketown_mannequin.gsc
Go to the documentation of this file.
1 #using scripts\shared\ai_shared;
2 #using scripts\shared\ai\archetype_mannequin;
3 #using scripts\shared\music_shared;
4 #using scripts\shared\util_shared;
5 
6 #insert scripts\shared\shared.gsh;
7 
8 #define NUKETOWN_SPAWN_MANNEQUIN_FX "dlc0/nuketown/fx_de_rez_man_spawn"
9 
10 #precache( "fx", NUKETOWN_SPAWN_MANNEQUIN_FX );
11 
12 #namespace NuketownMannequin;
13 
14 function ‪SpawnMannequin( origin, angles, gender = "male", speed = undefined, weepingAngel )
15 {
16  if(!IsDefined ( level.mannequinspawn_music))
17  {
18  level.mannequinspawn_music = 1;
19  music::setmusicstate( "mann" );
20  }
21 
22  if ( gender == "male" )
23  {
24  mannequin = SpawnActor( "spawner_bo3_mannequin_male", origin, angles, "", true, true );
25  }
26  else
27  {
28  mannequin = SpawnActor( "spawner_bo3_mannequin_female", origin, angles, "", true, true );
29  }
30 
31  // Select an initial speed.
32  rand = RandomInt( 100 );
33 
34  if( rand <= 35 )
35  {
36  mannequin.zombie_move_speed = "walk";
37  }
38  else if( rand <= 70 )
39  {
40  mannequin.zombie_move_speed = "run";
41  }
42  else
43  {
44  mannequin.zombie_move_speed = "sprint";
45  }
46 
47  if ( IsDefined( speed ) )
48  {
49  mannequin.zombie_move_speed = speed;
50  }
51 
52  if( IsDefined( level.zm_variant_type_max ) )
53  {
54  // Don't select variant 0 since those animations don't have proper footstep notetracks.
55  mannequin.variant_type = RandomIntRange( 1, level.zm_variant_type_max[ mannequin.zombie_move_speed ][ mannequin.zombie_arms_position ] );
56  }
57 
58  mannequin ‪ai::set_behavior_attribute( "can_juke", true );
59  mannequin ASMSetAnimationRate( RandomFloatRange( 0.98, 1.02 ) ); // Slightly vary animation playback.
60  mannequin.holdFire = true; // No firing, performance gain
61 
62  // sjakatdar (10/24/2015) - Disabling the optimization for updating the sight. It will prevent ais from picking up
63  // new enemy. To be able to use this optimization, the script has to explicitly set favorite enemy, which is not being done
64  // for mannequins. Fixes DT#139243.
65  //mannequin.updateSight = false; // No sight update
66 
67  mannequin.canStumble = true;
68  mannequin.should_turn = true;
69  mannequin thread ‪watch_game_ended();
70  mannequin.team = "free";
71  mannequin.overrideActorDamage = &‪mannequinDamage; // prevent mannequins from deal accidental melee damage to each other.
72 
73  mannequins = GetAIArchetypeArray( "mannequin" );
74 
75  foreach ( otherMannequin in mannequins )
76  {
77  if ( otherMannequin.archetype == "mannequin" )
78  {
79  otherMannequin SetIgnoreEnt( mannequin, true );
80  mannequin SetIgnoreEnt( otherMannequin, true );
81  }
82  }
83 
84  if( weepingAngel )
85  {
86  mannequin thread ‪_mannequin_unfreeze_ragdoll();
87  mannequin.is_looking_at_me = true;
88  mannequin.was_looking_at_me = false;
89  mannequin ‪_mannequin_update_freeze( mannequin.is_looking_at_me );
90  }
91 
92  ‪PlayFx( ‪NUKETOWN_SPAWN_MANNEQUIN_FX, mannequin.origin, AnglesToForward( mannequin.angles ) );
93 
94  return mannequin;
95 }
96 
97 function ‪mannequinDamage( inflictor, attacker, ‪damage, dFlags, mod, weapon, point, dir, hitLoc, offsetTime, boneIndex, modelIndex )
98 {
99  if ( IsDefined( inflictor ) && IsActor( inflictor ) && inflictor.archetype == "mannequin" )
100  {
101  return 0;
102  }
103 
104  return ‪damage;
105 }
106 
107 function private ‪watch_game_ended()
108 {
109  self endon ( "death" );
110 
111  level waittill ( "game_ended" );
112 
113  self SetEntityPaused( true );
114 
115  level waittill ( "endgame_sequence" );
116 
117  self Hide();
118 }
119 
121 {
122  self waittill( "death" );
123 
124  if ( IsDefined( self ) )
125  {
126  self SetEntityPaused( false );
127 
128  if ( !self IsRagdoll() )
129  {
130  self StartRagdoll();
131  }
132  }
133 }
134 
135 function private ‪_mannequin_update_freeze( frozen )
136 {
137  self.is_looking_at_me = frozen;
138 
139  if( self.is_looking_at_me && !self.was_looking_at_me )
140  {
141  self SetEntityPaused( true );
142  }
143  else if( !self.is_looking_at_me && self.was_looking_at_me )
144  {
145  self SetEntityPaused( false );
146  }
147 
148  self.was_looking_at_me = self.is_looking_at_me;
149 }
150 
152 {
153  level endon ( "game_ended" );
154  level endon ( "mannequin_force_cleanup" );
155 
156  while( 1 )
157  {
158  mannequins = GetAIArchetypeArray( "mannequin" );
159  foreach( mannequin in mannequins )
160  {
161  mannequin.can_player_see_me = true;
162  }
163 
164  players = GetPlayers();
165 
166  unseenMannequins = mannequins;
167  foreach( player in players )
168  {
169  unseenMannequins = player CantSeeEntities( unseenMannequins, .67, false );
170  }
171 
172  foreach( mannequin in unseenMannequins )
173  {
174  mannequin.can_player_see_me = false;
175  }
176 
177  foreach( mannequin in mannequins )
178  {
179  mannequin ‪_mannequin_update_freeze( mannequin.can_player_see_me );
180  }
181 
183  }
184 }
185 
‪damage
‪function damage(trap)
Definition: _zm_trap_electric.gsc:116
‪NUKETOWN_SPAWN_MANNEQUIN_FX
‪#define NUKETOWN_SPAWN_MANNEQUIN_FX
Definition: _nuketown_mannequin.gsc:8
‪mannequinDamage
‪function mannequinDamage(inflictor, attacker, damage, dFlags, mod, weapon, point, dir, hitLoc, offsetTime, boneIndex, modelIndex)
Definition: _nuketown_mannequin.gsc:97
‪watch_player_looking
‪function watch_player_looking()
Definition: _nuketown_mannequin.gsc:151
‪SpawnMannequin
‪function SpawnMannequin(origin, angles, gender="male", speed=undefined, weepingAngel)
Definition: _nuketown_mannequin.gsc:14
‪_mannequin_unfreeze_ragdoll
‪function private _mannequin_unfreeze_ragdoll()
Definition: _nuketown_mannequin.gsc:120
‪_mannequin_update_freeze
‪function private _mannequin_update_freeze(frozen)
Definition: _nuketown_mannequin.gsc:135
‪set_behavior_attribute
‪function set_behavior_attribute(attribute, value)
Definition: ai_shared.gsc:159
‪watch_game_ended
‪function private watch_game_ended()
Definition: _nuketown_mannequin.gsc:107
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265
‪PlayFx
‪function PlayFx(name)
Definition: _counteruav.gsc:390