‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
killstreaks_shared.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\abilities\_ability_player;
4 #using scripts\shared\hostmigration_shared;
5 #using scripts\shared\util_shared;
6 #using scripts\shared\weapons\_weaponobjects;
7 #using scripts\shared\weapons\_tacticalinsertion;
8 #using scripts\shared\vehicles\_raps;
9 #using scripts\shared\table_shared;
10 #using scripts\shared\scoreevents_shared;
11 
12 #insert scripts\shared\shared.gsh;
13 
14 #namespace killstreaks;
15 
16 function ‪is_killstreak_weapon( weapon )
17 {
18  if ( weapon == level.weaponNone || weapon.notKillstreak )
19  {
20  return false;
21  }
22 
23  if ( weapon.isSpecificUse || ‪is_weapon_associated_with_killstreak( weapon ) )
24  {
25  return true;
26  }
27 
28  return false;
29 }
30 
32 {
33  return ( isdefined( level.killstreakWeapons ) && isdefined( level.killstreakWeapons[ weapon ] ) );
34 }
35 
36 function ‪switch_to_last_non_killstreak_weapon( immediate, awayfromBall )
37 {
38  //Check if we were going into last stand
39  ball = GetWeapon( "ball" );
40  if( isdefined( ball ) && self HasWeapon( ball ) && !‪IS_TRUE( awayfromBall ) )
41  {
42  self switchToWeaponImmediate( ball );
43  self DisableWeaponCycling();
44  self DisableOffhandWeapons();
45  }
46  else if ( ‪IS_TRUE( self.lastStand ) )
47  {
48  if ( isdefined( self.laststandpistol ) && self hasWeapon( self.laststandpistol ) )
49  {
50  self switchToWeapon( self.laststandpistol );
51  }
52  }
53  else if( isdefined( self.lastNonKillstreakWeapon ) && self hasWeapon(self.lastNonKillstreakWeapon) )
54  {
55  if ( self.lastNonKillstreakWeapon.isHeroWeapon )
56  {
57  if ( self.lastNonKillstreakWeapon.gadget_heroversion_2_0 )
58  {
59  if ( self.lastNonKillstreakWeapon.isGadget && self GetAmmoCount( self.lastNonKillstreakWeapon ) > 0 )
60  {
61  slot = self GadgetGetSlot( self.lastNonKillstreakWeapon );
62  if ( self ‪ability_player::gadget_is_in_use( slot ) )
63  {
64  return self switchToWeapon( self.lastNonKillstreakWeapon );
65  }
66  else
67  return true;
68  }
69  }
70  else
71  {
72  if ( self GetAmmoCount( self.lastNonKillstreakWeapon ) > 0 )
73  {
74  return self switchToWeapon( self.lastNonKillstreakWeapon );
75  }
76  }
77 
78  // cycle
79  if( ‪IS_TRUE( awayfromBall ) && isdefined( self.lastDroppableWeapon ) && self hasWeapon( self.lastDroppableWeapon ) )
80  self switchToWeapon( self.lastDroppableWeapon );
81  else
82  self switchToWeapon();
83 
84  return true;
85  }
86  else
87  {
88  if( ‪IS_TRUE( immediate ) )
89  self switchToWeaponImmediate( self.lastNonKillstreakWeapon );
90  else
91  self switchToWeapon( self.lastNonKillstreakWeapon );
92  }
93  }
94  else if( isdefined( self.lastDroppableWeapon ) && self hasWeapon(self.lastDroppableWeapon) )
95  {
96  self switchToWeapon( self.lastDroppableWeapon );
97  }
98  else
99  {
100  return false;
101  }
102 
103  return true;
104 }
105 
106 function ‪get_killstreak_weapon( killstreak )
107 {
108  if( !isdefined( killstreak ) )
109  {
110  return level.weaponNone;
111  }
112 
113  Assert( isdefined(level.killstreaks[killstreak]) );
114 
115  return level.killstreaks[killstreak].weapon;
116 }
117 
118 function ‪isHeldInventoryKillstreakWeapon( killstreakWeapon )
119 {
120  switch( killstreakWeapon.name )
121  {
122  case "inventory_minigun":
123  case "inventory_m32":
124  return true;
125  }
126 
127  return false;
128 }
129 
130 function ‪WaitForTimecheck( duration, ‪callback, endCondition1, endCondition2, endCondition3 )
131 {
132  self endon( "hacked" );
133 
134  if( isdefined( endCondition1 ) )
135  self endon( endCondition1 );
136  if( isdefined( endCondition2 ) )
137  self endon( endCondition2 );
138  if( isdefined( endCondition3 ) )
139  self endon( endCondition3 );
140 
142 
143  self notify( "time_check" );
144  self [[ ‪callback ]]();
145 }
146 
147 function ‪EMP_IsEMPd()
148 {
149  if( isdefined( level.enemyEMPActiveFunc ) )
150  {
151  return self [[ level.enemyEMPActiveFunc ]]();
152  }
153 
154  return false;
155 }
156 
157 function ‪WaitTillEMP( onEmpdCallback, arg )
158 {
159  self endon ( "death" );
160  self endon ( "delete" );
161 
162  self waittill( "emp_deployed", attacker );
163 
164  if( isdefined( onEmpdCallback ) )
165  {
166  [[ onEmpdCallback ]]( attacker, arg );
167  }
168 }
169 
170 function ‪HasUav( team_or_entnum )
171 {
172  return level.activeUAVs[ team_or_entnum ] > 0;
173 }
174 
175 function ‪HasSatellite( team_or_entnum )
176 {
177  return level.activeSatellites[ team_or_entnum ] > 0;
178 }
179 
180 function ‪DestroyOtherTeamsEquipment( attacker, weapon )
181 {
182  foreach( team in level.teams )
183  {
184  if( team == attacker.team )
185  {
186  continue;
187  }
188 
189  ‪DestroyEquipment( attacker, team, weapon );
190  ‪DestroyTacticalInsertions( attacker, team );
191  }
192 
193  ‪DestroyEquipment( attacker, "free", weapon );
194  ‪DestroyTacticalInsertions( attacker, "free" );
195 }
196 
197 function ‪DestroyEquipment( attacker, team, weapon )
198 {
199  for( i = 0; i < level.missileEntities.size; i++ )
200  {
201  item = level.missileEntities[i];
202 
203  if ( !isdefined( item.weapon ) )
204  {
205  continue;
206  }
207 
208  if ( !isdefined( item.owner ) )
209  {
210  continue;
211  }
212 
213  if ( isdefined( team ) && item.owner.team != team )
214  {
215  continue;
216  }
217  else if ( item.owner == attacker )
218  {
219  continue;
220  }
221 
222  if ( !item.weapon.isEquipment && !‪IS_TRUE(item.destroyedByEmp) )
223  {
224  continue;
225  }
226 
227  watcher = item.owner weaponobjects::getWatcherForWeapon( item.weapon );
228 
229  if ( !isdefined( watcher ) )
230  {
231  continue;
232  }
233 
234  watcher thread ‪weaponobjects::waitAndDetonate( item, 0.0, attacker, weapon );
235  }
236 }
237 
238 function ‪DestroyTacticalInsertions( attacker, victimTeam )
239 {
240  for ( i = 0; i < level.players.size; i++ )
241  {
242  player = level.players[ i ];
243 
244  if ( !isdefined( player.tacticalInsertion ))
245  {
246  continue;
247  }
248 
249  if ( level.teamBased && player.team != victimTeam )
250  {
251  continue;
252  }
253 
254  if ( attacker == player )
255  {
256  continue;
257  }
258 
259  player.tacticalInsertion thread ‪tacticalinsertion::fizzle();
260  }
261 }
262 
263 function ‪DestroyOtherTeamsActiveVehicles( attacker, weapon )
264 {
265  foreach( team in level.teams )
266  {
267  if( team == attacker.team )
268  {
269  continue;
270  }
271 
272  ‪DestroyActiveVehicles( attacker, team, weapon );
273  }
274 
275  //DestroyActiveVehicles( attacker, undefined, weapon );
276 
277  ‪DestroyNeutralGameplayVehicles( attacker, weapon );
278 }
279 
280 function ‪DestroyNeutralGameplayVehicles( attacker, weapon )
281 {
282  script_vehicles = GetEntArray( "script_vehicle", "classname" );
283  foreach( vehicle in script_vehicles )
284  {
285  if( IsVehicle( vehicle ) && ( !isdefined( vehicle.team ) || vehicle.team == "neutral" ) )
286  {
287  if( isdefined( vehicle.DetonateViaEMP ) && ‪IS_TRUE( weapon.isEmpKillstreak ) )
288  {
289  vehicle [[vehicle.DetonateViaEMP]]( attacker, weapon );
290  }
291 
292  if( isdefined( vehicle.archetype ) )
293  {
294  if ( vehicle.archetype == "siegebot" )
295  {
296  vehicle DoDamage( vehicle.health + 1, vehicle.origin, attacker, attacker, "", "MOD_EXPLOSIVE", 0, weapon );
297  }
298  }
299  }
300  }
301 }
302 
303 function ‪DestroyActiveVehicles( attacker, team, weapon )
304 {
305  targets = Target_GetArray();
306  ‪DestroyEntities( targets, attacker, team, weapon );
307 
308  ai_tanks = GetEntArray( "talon", "targetname" );
309  ‪DestroyEntities( ai_tanks, attacker, team, weapon );
310 
311  remoteMissiles = GetEntArray( "remote_missile", "targetname" );
312  ‪DestroyEntities( remoteMissiles, attacker, team, weapon );
313 
314  remoteDrone = GetEntArray( "remote_drone", "targetname" );
315  ‪DestroyEntities( remoteDrone, attacker, team, weapon );
316 
317  script_vehicles = GetEntArray( "script_vehicle", "classname" );
318  foreach( vehicle in script_vehicles )
319  {
320  if( isdefined( team ) && ( vehicle.team == team ) && IsVehicle( vehicle ) )
321  {
322  if( isdefined( vehicle.DetonateViaEMP ) && ‪IS_TRUE( weapon.isEmpKillstreak ) )
323  {
324  vehicle [[vehicle.DetonateViaEMP]]( attacker, weapon );
325  }
326 
327  if( isdefined( vehicle.archetype ) )
328  {
329  if( vehicle.archetype == "raps" )
330  {
331  vehicle ‪raps::detonate( attacker );
332  }
333  else if( vehicle.archetype == "turret" || vehicle.archetype == "rcbomb" || vehicle.archetype == "wasp" || vehicle.archetype == "siegebot" )
334  {
335  vehicle DoDamage( vehicle.health + 1, vehicle.origin, attacker, attacker, "", "MOD_EXPLOSIVE", 0, weapon );
336  }
337  }
338  }
339  }
340 
341  planeMortars = GetEntArray( "plane_mortar", "targetname" );
342  foreach( planeMortar in planeMortars )
343  {
344  if ( isdefined( team ) && isdefined( planeMortar.team ) )
345  {
346  if ( planeMortar.team != team )
347  {
348  continue;
349  }
350  }
351  else if ( planeMortar.owner == attacker )
352  {
353  continue;
354  }
355 
356  planeMortar notify( "emp_deployed", attacker );
357  }
358 
359  droneStrikes = GetEntArray( "drone_strike", "targetname" );
360  foreach( droneStrike in droneStrikes )
361  {
362  if ( isdefined( team ) && isdefined( droneStrike.team ) )
363  {
364  if ( droneStrike.team != team )
365  {
366  continue;
367  }
368  }
369  else if ( droneStrike.owner == attacker )
370  {
371  continue;
372  }
373 
374  droneStrike notify( "emp_deployed", attacker );
375  }
376 
377  counteruavs = GetEntArray( "counteruav", "targetname" );
378  foreach( counteruav in counteruavs )
379  {
380  if ( isdefined( team ) && isdefined( counteruav.team ) )
381  {
382  if ( counteruav.team != team )
383  {
384  continue;
385  }
386  }
387  else if ( counteruav.owner == attacker )
388  {
389  continue;
390  }
391 
392  counteruav notify( "emp_deployed", attacker );
393  }
394 
395  satellites = GetEntArray( "satellite", "targetname" );
396  foreach( satellite in satellites )
397  {
398  if ( isdefined( team ) && isdefined( satellite.team ) )
399  {
400  if ( satellite.team != team )
401  {
402  continue;
403  }
404  }
405  else if ( satellite.owner == attacker )
406  {
407  continue;
408  }
409 
410  satellite notify( "emp_deployed", attacker );
411  }
412 
413  robots = GetAIArchetypeArray( "robot" );
414  foreach( robot in robots )
415  {
416  if( robot.allowdeath !== false &&
417  robot.magic_bullet_shield !== true &&
418  isdefined( team ) &&
419  robot.team == team )
420  {
421  if ( isdefined( attacker ) && ( !isdefined( robot.owner ) || robot.owner ‪util::IsEnemyPlayer( attacker ) ) )
422  {
423  ‪scoreevents::processScoreEvent( "destroyed_combat_robot", attacker, robot.owner, weapon );
424  LUINotifyEvent( &"player_callout", 2, &"KILLSTREAK_DESTROYED_COMBAT_ROBOT", attacker.entnum );
425  }
426  robot Kill();
427  }
428  }
429 
430  if ( isdefined ( level.missile_swarm_owner ) )
431  {
432  if ( level.missile_swarm_owner ‪util::IsEnemyPlayer( attacker ) )
433  {
434  level.missile_swarm_owner notify( "emp_destroyed_missile_swarm", attacker );
435  }
436  }
437 }
438 
439 function ‪DestroyEntities( entities, attacker, team, weapon )
440 {
441  meansOfDeath = "MOD_EXPLOSIVE";
442 
443  ‪damage = 5000;
444  direction_vec = ( 0, 0, 0 );
445  point = ( 0, 0, 0 );
446  modelName = "";
447  tagName = "";
448  partName = "";
449 
450  foreach( entity in entities )
451  {
452  if ( isdefined( team ) && isdefined( entity.team ) )
453  {
454  if ( entity.team != team )
455  {
456  continue;
457  }
458  }
459  else if ( isdefined( entity.owner ) && ( entity.owner == attacker ) )
460  {
461  continue;
462  }
463 
464  entity notify( "damage", ‪damage, attacker, direction_vec, point, meansOfDeath, tagName, modelName, partName, weapon );
465  }
466 }
‪processScoreEvent
‪function processScoreEvent(event, player, victim, weapon)
Definition: scoreevents_shared.gsc:19
‪callback
‪function callback(event, localclientnum, params)
Definition: callbacks_shared.csc:13
‪DestroyEntities
‪function DestroyEntities(entities, attacker, team, weapon)
Definition: killstreaks_shared.gsc:439
‪isHeldInventoryKillstreakWeapon
‪function isHeldInventoryKillstreakWeapon(killstreakWeapon)
Definition: killstreaks_shared.gsc:118
‪detonate
‪function detonate(attacker)
Definition: vehicle_ai_shared.gsc:1650
‪DestroyOtherTeamsEquipment
‪function DestroyOtherTeamsEquipment(attacker, weapon)
Definition: killstreaks_shared.gsc:180
‪DestroyNeutralGameplayVehicles
‪function DestroyNeutralGameplayVehicles(attacker, weapon)
Definition: killstreaks_shared.gsc:280
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪fizzle
‪function fizzle(attacker)
Definition: _tacticalinsertion.gsc:187
‪DestroyActiveVehicles
‪function DestroyActiveVehicles(attacker, team, weapon)
Definition: killstreaks_shared.gsc:303
‪waitAndDetonate
‪function waitAndDetonate(object, delay, attacker, weapon)
Definition: _weaponobjects.gsc:615
‪IsEnemyPlayer
‪function IsEnemyPlayer(player)
Definition: util_shared.csc:1220
‪HasUav
‪function HasUav(team_or_entnum)
Definition: killstreaks_shared.gsc:170
‪gadget_is_in_use
‪function gadget_is_in_use(slot)
Definition: _ability_player.gsc:321
‪damage
‪function damage(trap)
Definition: _zm_trap_electric.gsc:116
‪get_killstreak_weapon
‪function get_killstreak_weapon(killstreak)
Definition: killstreaks_shared.gsc:106
‪switch_to_last_non_killstreak_weapon
‪function switch_to_last_non_killstreak_weapon(immediate, awayfromBall)
Definition: killstreaks_shared.gsc:36
‪is_killstreak_weapon
‪function is_killstreak_weapon(weapon)
Definition: killstreaks_shared.gsc:16
‪DestroyTacticalInsertions
‪function DestroyTacticalInsertions(attacker, victimTeam)
Definition: killstreaks_shared.gsc:238
‪is_weapon_associated_with_killstreak
‪function is_weapon_associated_with_killstreak(weapon)
Definition: killstreaks_shared.gsc:31
‪EMP_IsEMPd
‪function EMP_IsEMPd()
Definition: killstreaks_shared.gsc:147
‪DestroyEquipment
‪function DestroyEquipment(attacker, team, weapon)
Definition: killstreaks_shared.gsc:197
‪WaitForTimecheck
‪function WaitForTimecheck(duration, callback, endCondition1, endCondition2, endCondition3)
Definition: killstreaks_shared.gsc:130
‪HasSatellite
‪function HasSatellite(team_or_entnum)
Definition: killstreaks_shared.gsc:175
‪DestroyOtherTeamsActiveVehicles
‪function DestroyOtherTeamsActiveVehicles(attacker, weapon)
Definition: killstreaks_shared.gsc:263
‪WaitTillEMP
‪function WaitTillEMP(onEmpdCallback, arg)
Definition: killstreaks_shared.gsc:157
‪MigrationAwareWait
‪function MigrationAwareWait(durationMs)
Definition: hostmigration_shared.gsc:333