‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
zm_usermap_ai.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\array_shared;
4 #using scripts\shared\callbacks_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\compass;
7 #using scripts\shared\exploder_shared;
8 #using scripts\shared\flag_shared;
9 #using scripts\shared\laststand_shared;
10 #using scripts\shared\math_shared;
11 #using scripts\shared\scene_shared;
12 #using scripts\shared\util_shared;
13 
14 #insert scripts\shared\shared.gsh;
15 #insert scripts\shared\version.gsh;
16 
17 #insert scripts\zm\_zm_utility.gsh;
18 
19 #using scripts\zm\_load;
20 #using scripts\zm\_zm;
21 #using scripts\zm\_zm_audio;
22 #using scripts\zm\_zm_powerups;
23 #using scripts\zm\_zm_utility;
24 #using scripts\zm\_zm_weapons;
25 #using scripts\zm\_zm_zonemgr;
26 
27 
28 //Perks
29 #using scripts\zm\_zm_pack_a_punch;
30 #using scripts\zm\_zm_pack_a_punch_util;
31 #using scripts\zm\_zm_perk_additionalprimaryweapon;
32 #using scripts\zm\_zm_perk_doubletap2;
33 #using scripts\zm\_zm_perk_deadshot;
34 #using scripts\zm\_zm_perk_juggernaut;
35 #using scripts\zm\_zm_perk_quick_revive;
36 #using scripts\zm\_zm_perk_sleight_of_hand;
37 #using scripts\zm\_zm_perk_staminup;
38 
39 //Powerups
40 #using scripts\zm\_zm_powerup_double_points;
41 #using scripts\zm\_zm_powerup_carpenter;
42 #using scripts\zm\_zm_powerup_fire_sale;
43 #using scripts\zm\_zm_powerup_free_perk;
44 #using scripts\zm\_zm_powerup_full_ammo;
45 #using scripts\zm\_zm_powerup_insta_kill;
46 #using scripts\zm\_zm_powerup_nuke;
47 #using scripts\zm\_zm_powerup_weapon_minigun;
48 
49 // Weapons
50 #using scripts\zm\_zm_weap_bowie;
51 #using scripts\zm\_zm_weap_bouncingbetty;
52 #using scripts\zm\_zm_weap_cymbal_monkey;
53 #using scripts\zm\_zm_weap_tesla;
54 
55 //Traps
56 #using scripts\zm\_zm_trap_electric;
57 
58 // AI
59 #using scripts\shared\ai\zombie;
60 #using scripts\shared\ai\behavior_zombie_dog;
61 #using scripts\shared\ai\zombie_utility;
62 
63 #using scripts\zm\_zm_ai_dogs;
64 
65 #using scripts\shared\ai\systems\animation_state_machine_utility;
66 #using scripts\shared\ai\systems\animation_state_machine_notetracks;
67 #using scripts\shared\ai\systems\animation_state_machine_mocomp;
68 #using scripts\shared\ai\systems\behavior_tree_utility;
69 #insert scripts\shared\ai\systems\animation_state_machine.gsh;
70 #insert scripts\shared\ai\systems\behavior.gsh;
71 
72 #namespace zm_usermap_ai;
73 
74 //*****************************************************************************
75 //*****************************************************************************
76 
77 function autoexec ‪init()
78 {
79  ‪DEFAULT(level.pathdist_type,‪PATHDIST_ORIGINAL);
80 
81  // INIT BEHAVIORS
83 
84  SetDvar( "scr_zm_use_code_enemy_selection", 0 );
85  level.closest_player_override = &‪factory_closest_player;
86 
87  level thread ‪update_closest_player();
88 
89  level.move_valid_poi_to_navmesh = true;
90 }
91 
93 {
94  // ------- SERVICES -----------//
95  ‪BT_REGISTER_API( "ZmFactoryTraversalService", &‪ZmFactoryTraversalService);
96 
97  ‪BT_REGISTER_API( "shouldMoveLowg", &‪shouldMoveLowg );
98 
100 }
101 
102 //*****************************************************************************
103 //*****************************************************************************
104 
106 {
107  if ( isdefined( entity.traverseStartNode ) )
108  {
109  entity PushActors( false );
110  return true;
111  }
112 
113  return false;
114 }
115 
116 function private ‪mocompIdleSpecialFactoryStart( entity, mocompAnim, mocompAnimBlendOutTime, mocompAnimFlag, mocompDuration )
117 {
118  if( IsDefined( entity.enemyoverride ) && IsDefined( entity.enemyoverride[1] ) )
119  {
120  entity OrientMode( "face direction", entity.enemyoverride[1].origin - entity.origin );
121  entity AnimMode( ‪AI_ANIM_USE_BOTH_DELTAS_ZONLY_PHYSICS, false );
122  }
123  else
124  {
125  entity OrientMode( "face current" );
126  entity AnimMode( ‪AI_ANIM_USE_BOTH_DELTAS_ZONLY_PHYSICS, false );
127  }
128 }
129 
130 function private ‪mocompIdleSpecialFactoryTerminate( entity, mocompAnim, mocompAnimBlendOutTime, mocompAnimFlag, mocompDuration )
131 {
132 
133 }
134 
135 function ‪shouldMoveLowg( entity )
136 {
137  return ‪IS_TRUE( entity.low_gravity );
138 }
139 
140 //*****************************************************************************
141 //*****************************************************************************
142 
143 function private ‪factory_validate_last_closest_player( players )
144 {
145  if ( isdefined( self.last_closest_player ) && ‪IS_TRUE( self.last_closest_player.am_i_valid ) )
146  {
147  return;
148  }
149 
150  self.need_closest_player = true;
151 
152  foreach( player in players )
153  {
154  if ( ‪IS_TRUE( player.am_i_valid ) )
155  {
156  self.last_closest_player = player;
157  return;
158  }
159  }
160 
161  self.last_closest_player = undefined;
162 }
163 
164 function private ‪factory_closest_player( origin, players )
165 {
166  if ( players.size == 0 )
167  {
168  return undefined;
169  }
170 
171  if ( IsDefined( self.zombie_poi ) )
172  {
173  return undefined;
174  }
175 
176  if ( players.size == 1 )
177  {
178  self.last_closest_player = players[0];
179  return self.last_closest_player;
180  }
181 
182  if ( !isdefined( self.last_closest_player ) )
183  {
184  self.last_closest_player = players[0];
185  }
186 
187  if ( !isdefined( self.need_closest_player ) )
188  {
189  self.need_closest_player = true;
190  }
191 
192  if ( isdefined( level.last_closest_time ) && level.last_closest_time >= level.time )
193  {
195  return self.last_closest_player;
196  }
197 
198  if ( ‪IS_TRUE( self.need_closest_player ) )
199  {
200  level.last_closest_time = level.time;
201 
202  self.need_closest_player = false;
203 
204  closest = players[0];
205  closest_dist = self ‪zm_utility::approximate_path_dist( closest );
206 
207  if ( !isdefined( closest_dist ) )
208  {
209  closest = undefined;
210  }
211 
212  for ( index = 1; index < players.size; index++ )
213  {
214  dist = self ‪zm_utility::approximate_path_dist( players[ index ] );
215  if ( isdefined( dist ) )
216  {
217  if ( isdefined( closest_dist ) )
218  {
219  if ( dist < closest_dist )
220  {
221  closest = players[ index ];
222  closest_dist = dist;
223  }
224  }
225  else
226  {
227  closest = players[ index ];
228  closest_dist = dist;
229  }
230  }
231  }
232 
233  self.last_closest_player = closest;
234  }
235 
236  if ( players.size > 1 && isdefined( closest ) )
237  {
238  self ‪zm_utility::approximate_path_dist( closest );
239  }
240 
242  return self.last_closest_player;
243 }
244 
245 function private ‪update_closest_player()
246 {
247  level waittill( "start_of_round" );
248 
249  while ( 1 )
250  {
251  reset_closest_player = true;
253  foreach( zombie in zombies )
254  {
255  if ( ‪IS_TRUE( zombie.need_closest_player ) )
256  {
257  reset_closest_player = false;
258  break;
259  }
260  }
261 
262  if ( reset_closest_player )
263  {
264  foreach( zombie in zombies )
265  {
266  if ( isdefined( zombie.need_closest_player ) )
267  {
268  zombie.need_closest_player = true;
269  }
270  }
271  }
272 
274  }
275 }
276 
277 
278 
279 
280 
281 
282 
283 
284 
285 
286 
287 
288 
289 
290 
‪BT_REGISTER_API
‪#define BT_REGISTER_API(name, function)
Definition: behavior.gsh:1
‪mocompIdleSpecialFactoryStart
‪function private mocompIdleSpecialFactoryStart(entity, mocompAnim, mocompAnimBlendOutTime, mocompAnimFlag, mocompDuration)
Definition: zm_usermap_ai.gsc:116
‪ZmFactoryTraversalService
‪function ZmFactoryTraversalService(entity)
Definition: zm_usermap_ai.gsc:105
‪approximate_path_dist
‪function approximate_path_dist(player)
Definition: _zm_utility.gsc:6092
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪get_round_enemy_array
‪function get_round_enemy_array()
Definition: zombie_utility.gsc:2024
‪factory_closest_player
‪function private factory_closest_player(origin, players)
Definition: zm_usermap_ai.gsc:164
‪update_closest_player
‪function private update_closest_player()
Definition: zm_usermap_ai.gsc:245
‪DEFAULT
‪#define DEFAULT(__var, __default)
Definition: shared.gsh:270
‪ASM_REGISTER_MOCOMP
‪#define ASM_REGISTER_MOCOMP(name, initFunction, updateFunction, terminateFunction)
Definition: animation_state_machine.gsh:1
‪factory_validate_last_closest_player
‪function private factory_validate_last_closest_player(players)
Definition: zm_usermap_ai.gsc:143
‪mocompIdleSpecialFactoryTerminate
‪function private mocompIdleSpecialFactoryTerminate(entity, mocompAnim, mocompAnimBlendOutTime, mocompAnimFlag, mocompDuration)
Definition: zm_usermap_ai.gsc:130
‪init
‪function autoexec init()
Definition: zm_usermap_ai.gsc:77
‪InitZmFactoryBehaviorsAndASM
‪function private InitZmFactoryBehaviorsAndASM()
Definition: zm_usermap_ai.gsc:92
‪PATHDIST_ORIGINAL
‪#define PATHDIST_ORIGINAL
Definition: _zm_utility.gsh:22
‪AI_ANIM_USE_BOTH_DELTAS_ZONLY_PHYSICS
‪#define AI_ANIM_USE_BOTH_DELTAS_ZONLY_PHYSICS
Definition: animation_state_machine.gsh:85
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265
‪shouldMoveLowg
‪function shouldMoveLowg(entity)
Definition: zm_usermap_ai.gsc:135