1 #using scripts\codescripts\struct;
3 #using scripts\shared\_oob;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\killstreaks_shared;
6 #using scripts\shared\util_shared;
8 #using scripts\mp\_util;
9 #using scripts\mp\killstreaks\_killstreaks;
10 #using scripts\mp\killstreaks\_killstreak_detect;
12 #insert scripts\mp\_hacker_tool.gsh;
13 #insert scripts\shared\shared.gsh;
15 #namespace placeables;
17 #define PLACEABLE_OFFSET 40
18 #define PLACEABLE_MOVEABLE_TIMEOUT_EXTENSION 5000
21 onPlaceCallback, onCancelCallback, onMoveCallback, onShutdownCallback, onDeathCallback, onEmpCallback,
22 model, validModel, invalidModel, spawnsVehicle,
28 invalidLocationHintString )
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;
55 placeable.originalTeam = player.team;
56 placeable.timedOut =
false;
58 placeable.timeoutStarted =
false;
59 placeable.angles = ( 0, player.angles[1], 0 );
60 placeable.placeHintString = placeHintString;
61 placeable.invalidLocationHintString = invalidLocationHintString;
63 DEFAULT( placeable.placeHintString,
"" );
64 DEFAULT( placeable.invalidLocationHintString,
"" );
67 if ( isdefined( placeable.vehicle ) )
68 placeable.vehicle NotSolid();
70 placeable.otherModel =
spawn(
"script_model", player.origin );
71 placeable.otherModel SetModel( placeable.placedModel );
72 placeable.otherModel SetInvisibleToPlayer( player );
73 placeable.otherModel NotSolid();
78 if( isdefined( health ) && health > 0 )
80 placeable.health = health;
81 placeable SetCanDamage(
false );
99 placeable.placedModel = model;
100 placeable.validModel = validModel;
101 placeable.invalidModel = invalidModel;
109 placeable NotSolid();
110 if ( isdefined( placeable.vehicle ) )
111 placeable.vehicle NotSolid();
113 if ( isdefined( placeable.otherModel ) )
117 placeable.otherModel NotSolid();
120 placeable.held =
true;
121 player.holding_placeable = placeable;
132 if( isdefined( level.noTurretPlacementTriggers ) )
134 for( i = 0; i < level.noTurretPlacementTriggers.size; i++ )
136 if( placeable IsTouching( level.noTurretPlacementTriggers[i] ) )
143 if( isdefined( level.fatal_triggers ) )
145 for( i = 0; i < level.fatal_triggers.size; i++ )
147 if( placeable IsTouching( level.fatal_triggers[i] ) )
166 player endon(
"disconnect" );
167 player endon(
"death" );
168 placeable endon(
"placed" );
169 placeable endon(
"cancelled" );
174 placeable.canBePlaced =
false;
175 waitingForAttackButtonRelease =
true;
179 placement = player CanPlayerPlaceTurret();
181 placeable.origin = placement[
"origin"];
182 placeable.angles = placement[
"angles"];
185 if ( player.laststand ===
true )
187 placeable.canBePlaced =
false;
190 if ( isdefined( placeable.otherModel ) )
192 placeable.otherModel.origin = placement[
"origin"];
193 placeable.otherModel.angles = placement[
"angles"];
196 if( placeable.canBePlaced != lastAttempt )
198 if( placeable.canBePlaced )
200 placeable SetModel( placeable.validModel );
201 player SetHintString( IString( placeable.placeHintString ) );
205 placeable SetModel( placeable.invalidModel );
206 player SetHintString( IString( placeable.invalidLocationHintString ) );
209 lastAttempt = placeable.canBePlaced;
212 while( waitingForAttackButtonRelease && !player AttackButtonPressed() )
214 waitingForAttackButtonRelease =
false;
217 if( !waitingForAttackButtonRelease && placeable.canBePlaced && player AttackButtonPressed() )
219 if( placement[
"result"] )
221 placeable.origin = placement[
"origin"];
222 placeable.angles = placement[
"angles"];
224 player SetHintString(
"" );
225 player StopCarryTurret( placeable );
232 placeable.held =
false;
233 player.holding_placeable = undefined;
234 placeable.cancelable =
false;
238 placeable SetCanDamage(
true );
242 if ( isdefined( placeable.vehicle ) )
244 placeable.vehicle SetCanDamage(
true );
245 placeable.vehicle Solid();
248 if( isdefined( placeable.placedModel ) && !placeable.spawnsVehicle )
250 placeable SetModel( placeable.placedModel );
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;
259 if ( isdefined( placeable.otherModel ) )
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();
268 if( isdefined( placeable.timeout ) )
270 if( !placeable.timeoutStarted )
272 placeable.timeoutStarted =
true;
275 else if( placeable.timedOut )
281 if( isdefined( placeable.onPlace ) )
283 player [[ placeable.onPlace ]]( placeable );
284 if( isdefined( placeable.onMove ) && !placeable.timedOut )
290 placeable notify(
"placed" );
294 if( placeable.cancelable && player ActionSlotFourButtonPressed() )
296 placeable notify(
"cancelled" );
306 assert( IsPlayer( player ) );
308 placeable endon(
"cancelled" );
309 placeable endon(
"placed" );
311 player
util::waittill_any(
"death",
"emp_jammed",
"emp_grenaded",
"disconnect",
"joined_team" );
312 placeable notify(
"cancelled" );
320 placeable.timedOut =
true;
324 placeable notify(
"delete_placeable_trigger" );
332 if( isdefined( placeable.onDeath ) )
334 [[ placeable.onDeath ]]( attacker, weapon );
337 placeable notify(
"cancelled" );
344 if( isdefined( placeable.onEmp ) )
346 placeable [[ placeable.onEmp ]]( attacker );
352 placeable endon(
"hacked" );
355 assert( IsPlayer( player ) );
357 placeable endon(
"cancelled" );
358 placeable endon(
"death" );
361 placeable notify(
"cancelled" );
366 placeable endon(
"cancelled" );
367 placeable endon(
"death" );
369 level waittill(
"game_ended" );
370 placeable notify(
"cancelled" );
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 );
381 player ClientClaimTrigger( placeable.pickupTrigger );
389 placeable
util::waittill_any(
"cancelled",
"picked_up",
"death",
"delete_placeable_trigger",
"hacker_delete_placeable_trigger" );
390 placeable.pickupTrigger
delete();
396 placeable endon(
"death" );
397 placeable endon(
"cancelled" );
399 assert( isdefined( placeable.pickupTrigger ) );
400 trigger = placeable.pickupTrigger;
404 trigger waittill(
"trigger", player );
406 if( !isAlive( player ) )
411 if( player isUsingOffhand() )
416 if( !player isOnGround() )
421 if ( isdefined( placeable.vehicle ) && ( placeable.vehicle.control_initiated ===
true ) )
426 if ( isdefined( player.carryObject ) && player.carryObject.disallowPlaceablePickup ===
true )
431 if( isdefined( trigger.triggerTeam ) && ( player.team != trigger.triggerTeam ) )
436 if( isdefined( trigger.claimedBy ) && ( player != trigger.claimedBy ) )
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 ) )
444 placeable notify(
"picked_up" );
445 placeable.held =
true;
446 placeable SetCanDamage(
false );
447 assert( isdefined( placeable.onMove ) );
448 player [[ placeable.onMove ]]( placeable );
458 placeable.cancelable =
false;
459 placeable notify(
"cancelled" );
464 self notify(
"WatchOwnerGameEvents_singleton");
465 self endon (
"WatchOwnerGameEvents_singleton");
468 placeable endon(
"cancelled" );
472 if ( isdefined( placeable ) )
474 placeable.abandoned =
true;
481 placeable endon(
"hacked" );
484 assert( IsPlayer( player ) );
488 if( isdefined( player ) && isdefined( placeable ) && ( placeable.held ===
true ) )
490 player SetHintString(
"" );
491 player StopCarryTurret( placeable );
499 if( isdefined( placeable ) )
501 if( placeable.cancelable )
503 if( isdefined( placeable.onCancel ) )
505 [[ placeable.onCancel ]]( placeable );
510 if( isdefined( placeable.onShutdown ) )
512 [[ placeable.onShutdown ]]( placeable );
516 if ( isdefined( placeable ) )
518 if ( isdefined( placeable.vehicle ) )
520 vehicle_to_kill = placeable.vehicle;
521 vehicle_to_kill.selfDestruct =
true;
522 vehicle_to_kill Kill();
523 placeable.vehicle = undefined;
524 placeable.otherModel
delete();
529 placeable.otherModel
delete();