‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_placeables.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\_oob;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\killstreaks_shared;
6 #using scripts\shared\util_shared;
7 
8 #using scripts\mp\_util;
9 #using scripts\mp\killstreaks\_killstreaks;
10 #using scripts\mp\killstreaks\_killstreak_detect;
11 
12 #insert scripts\mp\_hacker_tool.gsh;
13 #insert scripts\shared\shared.gsh;
14 
15 #namespace placeables;
16 
17 #define PLACEABLE_OFFSET 40
18 #define PLACEABLE_MOVEABLE_TIMEOUT_EXTENSION 5000
19 
20 function ‪SpawnPlaceable( killstreakRef, killstreakId,
21  onPlaceCallback, onCancelCallback, onMoveCallback, onShutdownCallback, onDeathCallback, onEmpCallback,
22  model, validModel, invalidModel, spawnsVehicle,
23  pickupString,
24  ‪timeout,
25  health,
26  empDamage,
27  placeHintString,
28  invalidLocationHintString )
29 {
30  player = self;
31 
33 
34  placeable = ‪spawn( "script_model", player.origin );
35  placeable.cancelable = true;
36  placeable.held = false;
37  placeable.validModel = validModel;
38  placeable.invalidModel = invalidModel;
39  placeable.killstreakId = killstreakId;
40  placeable.killstreakRef = killstreakRef;
41  placeable.onCancel = onCancelCallback;
42  placeable.onEmp = onEmpCallback;
43  placeable.onMove = onMoveCallback;
44  placeable.onPlace = onPlaceCallback;
45  placeable.onShutdown = onShutdownCallback;
46  placeable.onDeath = onDeathCallback;
47  placeable.owner = player;
48  placeable.originalOwner = player;
49  placeable.ownerEntNum = player.entNum;
50  placeable.originalOwnerEntNum = player.entNum;
51  placeable.pickupString = pickupString;
52  placeable.placedModel = model;
53  placeable.spawnsVehicle = spawnsVehicle;
54 
55  placeable.originalTeam = player.team;
56  placeable.timedOut = false;
57  placeable.timeout = ‪timeout;
58  placeable.timeoutStarted = false;
59  placeable.angles = ( 0, player.angles[1], 0 );
60  placeable.placeHintString = placeHintString;
61  placeable.invalidLocationHintString = invalidLocationHintString;
62 
63  ‪DEFAULT( placeable.placeHintString, "" );
64  ‪DEFAULT( placeable.invalidLocationHintString, "" );
65 
66  placeable NotSolid();
67  if ( isdefined( placeable.vehicle ) )
68  placeable.vehicle NotSolid();
69 
70  placeable.otherModel = ‪spawn( "script_model", player.origin );
71  placeable.otherModel SetModel( placeable.placedModel );
72  placeable.otherModel SetInvisibleToPlayer( player );
73  placeable.otherModel NotSolid();
74  placeable.otherModel ‪clientfield::set( "enemyvehicle", ‪ENEMY_VEHICLE_ACTIVE );
75 
76  placeable ‪killstreaks::configure_team( killstreakRef, killstreakId, player );
77 
78  if( isdefined( health ) && health > 0 )
79  {
80  placeable.health = health;
81  placeable SetCanDamage( false );
82  placeable thread ‪killstreaks::MonitorDamage( killstreakRef, health, &‪OnDeath, 0, undefined, empDamage, &‪OnEMP, true );
83  }
84 
85  player thread ‪CarryPlaceable( placeable );
86  level thread ‪CancelOnGameEnd( placeable );
87 
88  player thread ‪ShutdownOnCancelEvent( placeable );
89  player thread ‪CancelOnPlayerDisconnect( placeable );
90 
91  placeable thread ‪WatchOwnerGameEvents();
92 
93  return placeable;
94 }
95 
96 function ‪UpdatePlacementModels( model, validModel, invalidModel )
97 {
98  placeable = self;
99  placeable.placedModel = model;
100  placeable.validModel = validModel;
101  placeable.invalidModel = invalidModel;
102 }
103 
104 function ‪CarryPlaceable( placeable )
105 {
106  player = self;
107 
108  placeable Show();
109  placeable NotSolid();
110  if ( isdefined( placeable.vehicle ) )
111  placeable.vehicle NotSolid();
112 
113  if ( isdefined( placeable.otherModel ) )
114  {
115  placeable thread ‪util::ghost_wait_show_to_player( player, 0.05, "abort_ghost_wait_show" );
116  placeable.otherModel thread ‪util::ghost_wait_show_to_others( player, 0.05, "abort_ghost_wait_show" );
117  placeable.otherModel NotSolid();
118  }
119 
120  placeable.held = true;
121  player.holding_placeable = placeable;
122 
123  player CarryTurret( placeable, ( ‪PLACEABLE_OFFSET, 0, 0 ), ( 0, 0, 0 ) );
124  player ‪util::_disableWeapon();
125  player thread ‪WatchPlacement( placeable );
126 }
127 
129 {
130  placeable = self;
131 
132  if( isdefined( level.noTurretPlacementTriggers ) )
133  {
134  for( i = 0; i < level.noTurretPlacementTriggers.size; i++ )
135  {
136  if( placeable IsTouching( level.noTurretPlacementTriggers[i] ) )
137  {
138  return true;
139  }
140  }
141  }
142 
143  if( isdefined( level.fatal_triggers ) )
144  {
145  for( i = 0; i < level.fatal_triggers.size; i++ )
146  {
147  if( placeable IsTouching( level.fatal_triggers[i] ) )
148  {
149  return true;
150  }
151  }
152  }
153 
154  if( placeable ‪oob::IsTouchingAnyOOBTrigger() )
155  {
156  return true;
157  }
158 
159  return false;
160 }
161 
162 function ‪WatchPlacement( placeable )
163 {
164  player = self;
165 
166  player endon( "disconnect" );
167  player endon( "death" );
168  placeable endon( "placed" );
169  placeable endon( "cancelled" );
170 
171  player thread ‪WatchCarryCancelEvents( placeable );
172 
173  lastAttempt = -1;
174  placeable.canBePlaced = false;
175  waitingForAttackButtonRelease = true;
176 
177  while( true )
178  {
179  placement = player CanPlayerPlaceTurret();
180 
181  placeable.origin = placement["origin"];
182  placeable.angles = placement["angles"];
183  placeable.canBePlaced = placement["result"] && !( placeable ‪InNoPlacementTrigger() );
184 
185  if ( player.laststand === true )
186  {
187  placeable.canBePlaced = false;
188  }
189 
190  if ( isdefined( placeable.otherModel ) )
191  {
192  placeable.otherModel.origin = placement["origin"];
193  placeable.otherModel.angles = placement["angles"];
194  }
195 
196  if( placeable.canBePlaced != lastAttempt )
197  {
198  if( placeable.canBePlaced )
199  {
200  placeable SetModel( placeable.validModel );
201  player SetHintString( IString( placeable.placeHintString ) );
202  }
203  else
204  {
205  placeable SetModel( placeable.invalidModel );
206  player SetHintString( IString( placeable.invalidLocationHintString ) );
207  }
208 
209  lastAttempt = placeable.canBePlaced;
210  }
211 
212  while( waitingForAttackButtonRelease && !player AttackButtonPressed() )
213  {
214  waitingForAttackButtonRelease = false;
215  }
216 
217  if( !waitingForAttackButtonRelease && placeable.canBePlaced && player AttackButtonPressed() )
218  {
219  if( placement["result"] )
220  {
221  placeable.origin = placement["origin"];
222  placeable.angles = placement["angles"];
223 
224  player SetHintString( "" );
225  player StopCarryTurret( placeable );
226 
227  if( !player ‪util::isWeaponEnabled() )
228  {
229  player ‪util::_enableWeapon();
230  }
231 
232  placeable.held = false;
233  player.holding_placeable = undefined;
234  placeable.cancelable = false;
235 
236  if( ‪IS_TRUE( placeable.health ) )
237  {
238  placeable SetCanDamage( true );
239  placeable Solid();
240  }
241 
242  if ( isdefined( placeable.vehicle ) )
243  {
244  placeable.vehicle SetCanDamage( true );
245  placeable.vehicle Solid();
246  }
247 
248  if( isdefined( placeable.placedModel ) && !placeable.spawnsVehicle )
249  {
250  placeable SetModel( placeable.placedModel );
251  }
252  else
253  {
254  placeable notify( "abort_ghost_wait_show" );
255  placeable.abort_ghost_wait_show_to_player = true;
256  placeable.abort_ghost_wait_show_to_others = true;
257  placeable Ghost(); // need to ghost instead of hide because of resulting issue with client side animations
258 
259  if ( isdefined( placeable.otherModel ) )
260  {
261  placeable.otherModel notify( "abort_ghost_wait_show" );
262  placeable.otherModel.abort_ghost_wait_show_to_player = true;
263  placeable.otherModel.abort_ghost_wait_show_to_others = true;
264  placeable.otherModel Ghost(); // need to ghost instead of hide because of resulting issue with client side animations
265  }
266  }
267 
268  if( isdefined( placeable.timeout ) )
269  {
270  if( !placeable.timeoutStarted )
271  {
272  placeable.timeoutStarted = true;
273  placeable thread ‪killstreaks::WaitForTimeout( placeable.killstreakRef, placeable.timeout, &‪OnTimeout, "death", "cancelled" );
274  }
275  else if( placeable.timedOut )
276  {
277  placeable thread ‪killstreaks::WaitForTimeout( placeable.killstreakRef, ‪PLACEABLE_MOVEABLE_TIMEOUT_EXTENSION, &‪OnTimeout, "cancelled" );
278  }
279  }
280 
281  if( isdefined( placeable.onPlace ) )
282  {
283  player [[ placeable.onPlace ]]( placeable );
284  if( isdefined( placeable.onMove ) && !placeable.timedOut )
285  {
286  ‪SpawnMoveTrigger( placeable, player );
287  }
288  }
289 
290  placeable notify( "placed" );
291  }
292  }
293 
294  if( placeable.cancelable && player ActionSlotFourButtonPressed() )
295  {
296  placeable notify( "cancelled" );
297  }
298 
300  }
301 }
302 
303 function ‪WatchCarryCancelEvents( placeable )
304 {
305  player = self;
306  assert( IsPlayer( player ) );
307 
308  placeable endon( "cancelled" );
309  placeable endon( "placed" );
310 
311  player ‪util::waittill_any( "death", "emp_jammed", "emp_grenaded", "disconnect", "joined_team" );
312  placeable notify( "cancelled" );
313 }
314 
315 function ‪OnTimeout()
316 {
317  placeable = self;
318  if( ‪IS_TRUE( placeable.held ) )
319  {
320  placeable.timedOut = true;
321  return;
322  }
323 
324  placeable notify( "delete_placeable_trigger" );
325  placeable thread ‪killstreaks::WaitForTimeout( placeable.killstreakRef, ‪PLACEABLE_MOVEABLE_TIMEOUT_EXTENSION, &‪ForceShutdown, "cancelled" );
326 }
327 
328 function ‪OnDeath( attacker, weapon )
329 {
330  placeable = self;
331 
332  if( isdefined( placeable.onDeath ) )
333  {
334  [[ placeable.onDeath ]]( attacker, weapon );
335  }
336 
337  placeable notify( "cancelled" );
338 }
339 
340 function ‪OnEMP( attacker )
341 {
342  placeable = self;
343 
344  if( isdefined( placeable.onEmp ) )
345  {
346  placeable [[ placeable.onEmp ]]( attacker );
347  }
348 }
349 
350 function ‪CancelOnPlayerDisconnect( placeable )
351 {
352  placeable endon( "hacked" );
353 
354  player = self;
355  assert( IsPlayer( player ) );
356 
357  placeable endon( "cancelled" );
358  placeable endon( "death" );
359 
360  player ‪util::waittill_any( "disconnect", "joined_team" );
361  placeable notify( "cancelled" );
362 }
363 
364 function ‪CancelOnGameEnd( placeable )
365 {
366  placeable endon( "cancelled" );
367  placeable endon( "death" );
368 
369  level waittill( "game_ended" );
370  placeable notify( "cancelled" );
371 }
372 
373 function ‪SpawnMoveTrigger( placeable, player )
374 {
375  pos = placeable.origin + ( 0, 0, 15 );
376  placeable.pickupTrigger = ‪spawn( "trigger_radius_use", pos );
377  placeable.pickupTrigger SetCursorHint( "HINT_NOICON", placeable );
378  placeable.pickupTrigger SetHintString( placeable.pickupString );
379  placeable.pickupTrigger SetTeamForTrigger( player.team );
380 
381  player ClientClaimTrigger( placeable.pickupTrigger );
382  placeable thread ‪WatchPickup( player);
383  placeable.pickupTrigger thread ‪WatchMoveTriggerShutdown( placeable );
384 }
385 
386 function ‪WatchMoveTriggerShutdown( placeable )
387 {
388  trigger = self;
389  placeable ‪util::waittill_any( "cancelled", "picked_up", "death", "delete_placeable_trigger", "hacker_delete_placeable_trigger" );
390  placeable.pickupTrigger delete();
391 }
392 
393 function ‪WatchPickup( player )
394 {
395  placeable = self;
396  placeable endon( "death" );
397  placeable endon( "cancelled" );
398 
399  assert( isdefined( placeable.pickupTrigger ) );
400  trigger = placeable.pickupTrigger;
401 
402  while ( true )
403  {
404  trigger waittill( "trigger", player );
405 
406  if( !isAlive( player ) )
407  {
408  continue;
409  }
410 
411  if( player isUsingOffhand() )
412  {
413  continue;
414  }
415 
416  if( !player isOnGround() )
417  {
418  continue;
419  }
420 
421  if ( isdefined( placeable.vehicle ) && ( placeable.vehicle.control_initiated === true ) )
422  {
423  continue;
424  }
425 
426  if ( isdefined( player.carryObject ) && player.carryObject.disallowPlaceablePickup === true )
427  {
428  continue;
429  }
430 
431  if( isdefined( trigger.triggerTeam ) && ( player.team != trigger.triggerTeam ) )
432  {
433  continue;
434  }
435 
436  if( isdefined( trigger.claimedBy ) && ( player != trigger.claimedBy ) )
437  {
438  continue;
439  }
440 
441  if( player useButtonPressed() && !player.throwingGrenade && !player meleeButtonPressed() && !player attackButtonPressed() &&
442  !‪IS_TRUE( player.isPlanting ) && !‪IS_TRUE( player.isDefusing ) && !player IsRemoteControlling() && !isdefined( player.holding_placeable ) )
443  {
444  placeable notify( "picked_up" );
445  placeable.held = true;
446  placeable SetCanDamage( false );
447  assert( isdefined( placeable.onMove ) );
448  player [[ placeable.onMove ]]( placeable );
449  player thread ‪CarryPlaceable( placeable );
450  return;
451  }
452  }
453 }
454 
456 {
457  placeable = self;
458  placeable.cancelable = false;
459  placeable notify( "cancelled" );
460 }
461 
463 {
464  self notify("WatchOwnerGameEvents_singleton");
465  self endon ("WatchOwnerGameEvents_singleton");
466 
467  placeable = self;
468  placeable endon( "cancelled" );
469 
470  placeable.owner ‪util::waittill_any( "joined_team", "disconnect", "joined_spectators" );
471 
472  if ( isdefined( placeable ) )
473  {
474  placeable.abandoned = true;
475  placeable ‪ForceShutdown();
476  }
477 }
478 
479 function ‪ShutdownOnCancelEvent( placeable )
480 {
481  placeable endon( "hacked" );
482 
483  player = self;
484  assert( IsPlayer( player ) );
485 
486  placeable ‪util::waittill_any( "cancelled", "death" );
487 
488  if( isdefined( player ) && isdefined( placeable ) && ( placeable.held === true ) )
489  {
490  player SetHintString( "" );
491  player StopCarryTurret( placeable );
492 
493  if( !player ‪util::isWeaponEnabled() )
494  {
495  player ‪util::_enableWeapon();
496  }
497  }
498 
499  if( isdefined( placeable ) )
500  {
501  if( placeable.cancelable )
502  {
503  if( isdefined( placeable.onCancel ) )
504  {
505  [[ placeable.onCancel ]]( placeable );
506  }
507  }
508  else
509  {
510  if( isdefined( placeable.onShutdown ) )
511  {
512  [[ placeable.onShutdown ]]( placeable );
513  }
514  }
515 
516  if ( isdefined( placeable ) )
517  {
518  if ( isdefined( placeable.vehicle ) )
519  {
520  vehicle_to_kill = placeable.vehicle;
521  vehicle_to_kill.selfDestruct = true;
522  vehicle_to_kill Kill(); // need to kill the vehicle before placeable is deleted
523  placeable.vehicle = undefined;
524  placeable.otherModel delete();
525  placeable delete();
526  }
527  else
528  {
529  placeable.otherModel delete();
530  placeable delete();
531  }
532  }
533  }
534 }
‪timeout
‪function timeout(n_time, func, arg1, arg2, arg3, arg4, arg5, arg6)
Definition: util_shared.csc:762
‪isWeaponEnabled
‪function isWeaponEnabled()
Definition: util_shared.gsc:1158
‪IsTouchingAnyOOBTrigger
‪function IsTouchingAnyOOBTrigger()
Definition: _oob.gsc:84
‪WaitForTimeout
‪function WaitForTimeout(killstreak, duration, callback, endCondition1, endCondition2, endCondition3)
Definition: _killstreaks.gsc:2913
‪WatchCarryCancelEvents
‪function WatchCarryCancelEvents(placeable)
Definition: _placeables.gsc:303
‪ForceShutdown
‪function ForceShutdown()
Definition: _placeables.gsc:455
‪CancelOnGameEnd
‪function CancelOnGameEnd(placeable)
Definition: _placeables.gsc:364
‪SpawnMoveTrigger
‪function SpawnMoveTrigger(placeable, player)
Definition: _placeables.gsc:373
‪WatchPlacement
‪function WatchPlacement(placeable)
Definition: _placeables.gsc:162
‪ENEMY_VEHICLE_ACTIVE
‪#define ENEMY_VEHICLE_ACTIVE
Definition: _hacker_tool.gsh:2
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪OnTimeout
‪function OnTimeout()
Definition: _placeables.gsc:315
‪_enableWeapon
‪function _enableWeapon()
Definition: util_shared.gsc:1145
‪CancelOnPlayerDisconnect
‪function CancelOnPlayerDisconnect(placeable)
Definition: _placeables.gsc:350
‪MonitorDamage
‪function MonitorDamage(killstreak_ref, max_health, destroyed_callback, low_health, low_health_callback, emp_damage, emp_callback, allow_bullet_damage)
Definition: _killstreaks.gsc:2499
‪SpawnPlaceable
‪function SpawnPlaceable(killstreakRef, killstreakId, onPlaceCallback, onCancelCallback, onMoveCallback, onShutdownCallback, onDeathCallback, onEmpCallback, model, validModel, invalidModel, spawnsVehicle, pickupString, timeout, health, empDamage, placeHintString, invalidLocationHintString)
Definition: _placeables.gsc:20
‪ShutdownOnCancelEvent
‪function ShutdownOnCancelEvent(placeable)
Definition: _placeables.gsc:479
‪switch_to_last_non_killstreak_weapon
‪function switch_to_last_non_killstreak_weapon(immediate, awayfromBall)
Definition: killstreaks_shared.gsc:36
‪DEFAULT
‪#define DEFAULT(__var, __default)
Definition: shared.gsh:270
‪UpdatePlacementModels
‪function UpdatePlacementModels(model, validModel, invalidModel)
Definition: _placeables.gsc:96
‪_disableWeapon
‪function _disableWeapon()
Definition: util_shared.gsc:1137
‪WatchPickup
‪function WatchPickup(player)
Definition: _placeables.gsc:393
‪InNoPlacementTrigger
‪function InNoPlacementTrigger()
Definition: _placeables.gsc:128
‪WatchOwnerGameEvents
‪function WatchOwnerGameEvents()
Definition: _placeables.gsc:462
‪PLACEABLE_OFFSET
‪#define PLACEABLE_OFFSET
Definition: _placeables.gsc:17
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪ghost_wait_show_to_player
‪function ghost_wait_show_to_player(player, wait_time=0.1, self_endon_string1)
Definition: _util.gsc:937
‪CarryPlaceable
‪function CarryPlaceable(placeable)
Definition: _placeables.gsc:104
‪set
‪function set(str_field_name, n_value)
Definition: clientfield_shared.gsc:34
‪configure_team
‪function configure_team(killstreakType, killstreakId, owner, influencerType, configureTeamPreFunction, configureTeamPostFunction, isHacked=false)
Definition: _killstreaks.gsc:2806
‪PLACEABLE_MOVEABLE_TIMEOUT_EXTENSION
‪#define PLACEABLE_MOVEABLE_TIMEOUT_EXTENSION
Definition: _placeables.gsc:18
‪WatchMoveTriggerShutdown
‪function WatchMoveTriggerShutdown(placeable)
Definition: _placeables.gsc:386
‪OnEMP
‪function OnEMP(attacker)
Definition: _placeables.gsc:340
‪OnDeath
‪function OnDeath(attacker, weapon)
Definition: _placeables.gsc:328
‪ghost_wait_show_to_others
‪function ghost_wait_show_to_others(player, wait_time=0.1, self_endon_string1)
Definition: _util.gsc:977
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265