‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_laststand.gsc
Go to the documentation of this file.
1 // tagTMR<NOTE>: this is a stripped down last stand implementation for the purposes of hooking into
2 // the resurrect gadget. Removed suicide and revive triggers, all hud elements, anything cp/zm specific
3 
4 #using scripts\codescripts\struct;
5 
6 #using scripts\shared\callbacks_shared;
7 #using scripts\shared\demo_shared;
8 #using scripts\shared\flag_shared;
9 #using scripts\shared\hud_util_shared;
10 #using scripts\shared\killcam_shared;
11 #using scripts\shared\laststand_shared;
12 #using scripts\shared\scoreevents_shared;
13 #using scripts\shared\system_shared;
14 #using scripts\shared\util_shared;
15 #using scripts\shared\clientfield_shared;
16 
17 #using scripts\shared\abilities\gadgets\_gadget_resurrect;
18 #using scripts\shared\abilities\_ability_util;
19 
20 #insert scripts\shared\shared.gsh;
21 #insert scripts\shared\abilities\_ability_util.gsh;
22 
23 #using scripts\mp\gametypes\_globallogic_player;
24 #using scripts\mp\gametypes\_globallogic_spawn;
25 #using scripts\mp\gametypes\_killcam;
26 
27 #namespace laststand;
28 
29 ‪REGISTER_SYSTEM( "laststand", &‪__init__, undefined )
30 
31 function ‪__init__()
32 {
33  if (level.script=="frontend")
34  {
35  return ;
36  }
37 }
38 
39 function ‪player_last_stand_stats( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration )
40 {
41  //stat tracking
42  if ( IsDefined( attacker ) && IsPlayer( attacker ) && attacker != self )
43  {
44  attacker.kills++;
45 
46  if (isdefined(weapon))
47  {
48  dmgweapon = weapon;
49 
50  weaponPickedUp = false;
51  if( isdefined( attacker.pickedUpWeapons ) && isdefined( attacker.pickedUpWeapons[weapon] ) )
52  {
53  weaponPickedUp = true;
54  }
55 
56  attacker AddWeaponStat(dmgweapon, "kills", 1, attacker.class_num, weaponPickedUp );
57  }
58  }
59 
60  self.downs++;
61 }
62 
63 function ‪PlayerLastStand( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, delayOverride )
64 {
65  if( self ‪player_is_in_laststand() )
66  {
67  return;
68  }
69 
70  if ( isdefined( self.resurrect_not_allowed_by ) )
71  {
72  return;
73  }
74 
75  self ‪globallogic_player::Callback_PlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, 0, true );
76 
77  self notify("entering_last_stand");
78 
79  // check to see if we are in a game module that wants to do something with PvP damage
80  if( isDefined( level._game_module_player_laststand_callback ) )
81  {
82  self [[ level._game_module_player_laststand_callback ]]( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, delayOverride );
83  }
84 
85  self.lastStandParams = spawnstruct();
86  self.lastStandParams.eInflictor = eInflictor;
87  self.lastStandParams.attacker = attacker;
88  self.lastStandParams.iDamage = iDamage;
89  self.lastStandParams.sMeansOfDeath = sMeansOfDeath;
90  self.lastStandParams.sWeapon = weapon;
91  self.lastStandParams.vDir = vDir;
92  self.lastStandParams.sHitLoc = sHitLoc;
93  self.lastStandParams.lastStandStartTime = gettime();
94  self.lastStandParams.killcam_entity_info_cached = ‪killcam::get_killcam_entity_info( attacker, eInflictor, weapon );
95 
96  self thread ‪player_last_stand_stats( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, delayOverride );
97 
98  self.health = 1;
99  self.laststand = true;
100  self.ignoreme = true;
101  self EnableInvulnerability();
102  self.meleeAttackers = undefined;
103  self.no_revive_trigger = true;
104 
105  ‪callback::callback( #"on_player_laststand" );
106 
107  assert( IsDefined( self.resurrect_weapon ) ); // defined in gadget_resurrect.gsc
108  assert( self.resurrect_weapon != level.weaponNone );
109 
111  self GadgetStateChange( slot, self.resurrect_weapon, ‪GADGET_ACTION_PRIMED );
113  self thread ‪MakeSureSwitchToWeapon();
114  self thread ‪resurrect::enter_rejack_standby(); // UI and input watchers
115  self thread ‪watch_player_input();
116 
117  ‪demo::bookmark( "player_downed", gettime(), self );
118 }
119 
121 {
122  self endon( "death" );
123  self endon( "disconnect" );
124  self endon( "bleed_out" );
125  self endon( "player_input_revive" );
126  self endon( "player_input_suicide" );
127  level endon("game_ended");
128 
129  while( 1 )
130  {
131  if( self getcurrentweapon() != self.resurrect_weapon )
132  {
133  self SwitchToWeapon( self.resurrect_weapon );
134  }
136  }
137 }
138 
139 // self = a player
141 {
142  weaponInventory = self GetWeaponsList( true );
143  self.lastActiveWeapon = self GetCurrentWeapon();
144  if ( self IsThrowingGrenade() )
145  {
146  primaryWeapons = self GetWeaponsListPrimaries();
147  if( IsDefined( primaryWeapons ) && primaryWeapons.size > 0 )
148  {
149  self.lastActiveWeapon = primaryWeapons[0];
150  self SwitchToWeaponImmediate( self.lastActiveWeapon );
151  }
152  }
153 }
154 
155 function ‪laststand_enable_player_weapons( b_allow_grenades = true ) // self == player
156 {
157  self EnableWeaponCycling();
158 
159  if ( b_allow_grenades )
160  {
161  self EnableOffhandWeapons();
162  }
163 
164  if( IsDefined(self.lastActiveWeapon) && (self.lastActiveWeapon != level.weaponNone) && self HasWeapon( self.lastActiveWeapon ) )
165  {
166  self SwitchToWeapon( self.lastActiveWeapon );
167  }
168  else
169  {
170  primaryWeapons = self GetWeaponsListPrimaries();
171  if( IsDefined( primaryWeapons ) && primaryWeapons.size > 0 )
172  {
173  self SwitchToWeapon( primaryWeapons[0] );
174  }
175  }
176 }
177 
178 function ‪laststand_clean_up_on_interrupt( playerBeingRevived, reviverGun )
179 {
180  self endon( "do_revive_ended_normally" );
181 
182  reviveTrigger = playerBeingRevived.revivetrigger;
183 
184  playerBeingRevived ‪util::waittill_any( "disconnect", "game_ended", "death" );
185 
186  if( isdefined( reviveTrigger ) )
187  {
188  reviveTrigger delete();
189  }
190  self ‪cleanup_suicide_hud();
191 
192  if( isdefined( self.reviveProgressBar ) )
193  {
194  self.reviveProgressBar ‪hud::destroyElem();
195  }
196 
197  if( isdefined( self.reviveTextHud ) )
198  {
199  self.reviveTextHud ‪destroy();
200  }
201 }
202 
203 function ‪laststand_clean_up_reviving_any( playerBeingRevived )
204 {
205  self endon( "do_revive_ended_normally" );
206 
207  playerBeingRevived ‪util::waittill_any( "disconnect", "zombified", "stop_revive_trigger" );
208 
209  self.is_reviving_any--;
210  if ( 0 > self.‪is_reviving_any )
211  {
212  self.is_reviving_any = 0;
213  }
214 }
215 
216 function ‪bleed_out()
217 {
218  ‪demo::bookmark( "player_bledout", gettime(), self, undefined, 1 );
219 
220  level notify("bleed_out", self.characterindex);
221 
222  self UndoLastStand();
223  self.ignoreme = false;
224  self.laststand = undefined;
225 
226  self.useLastStandParams = true;
227 
228  // attacker may have become undefined if the player that killed me has disconnected
229  if ( !isDefined( self.lastStandParams.attacker ) )
230  {
231  self.lastStandParams.attacker = self;
232  }
233 
234  self ‪suicide();
235 }
236 
237 function ‪watch_player_input() // self == player
238 {
239  self thread ‪watch_player_input_revive();
240  self thread ‪watch_player_input_suicide();
241 }
242 
243 function ‪watch_player_input_revive() // self == player
244 {
245  level endon("game_ended");
246 
247  self endon( "player_input_bleed_out" );
248  self endon( "disconnect" );
249  self endon( "death" );
250 
251  self waittill("player_input_revive");
252 
253  ‪demo::bookmark( "player_revived", gettime(), self, self );
254 
255  self Rejack(); // TODO: split this out into gadget-specific territory and keep this file last stand only
256 
258 
259  self.ignoreme = false;
260  self DisableInvulnerability();
261  self.laststand = undefined;
262 }
263 
264 function ‪watch_player_input_suicide() // self == player
265 {
266  level endon("game_ended");
267 
268  self endon( "player_input_revive" );
269  self endon( "disconnect" );
270  self endon( "death" );
271 
272  self waittill("player_input_suicide");
273 
274  self ‪bleed_out();
275 }
‪callback
‪function callback(event, localclientnum, params)
Definition: callbacks_shared.csc:13
‪watch_player_input_suicide
‪function watch_player_input_suicide()
Definition: _laststand.gsc:264
‪MakeSureSwitchToWeapon
‪function MakeSureSwitchToWeapon()
Definition: _laststand.gsc:120
‪watch_player_input_revive
‪function watch_player_input_revive()
Definition: _laststand.gsc:243
‪Callback_PlayerKilled
‪function Callback_PlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration, enteredResurrect=false)
Definition: _globallogic_player.gsc:3020
‪laststand_disable_player_weapons
‪function laststand_disable_player_weapons()
Definition: _laststand.gsc:140
‪destroyElem
‪function destroyElem()
Definition: hud_util_shared.gsc:755
‪enter_rejack_standby
‪function enter_rejack_standby()
Definition: _gadget_resurrect.gsc:500
‪__init__
‪function __init__()
Definition: _laststand.gsc:31
‪laststand_enable_player_weapons
‪function laststand_enable_player_weapons(b_allow_grenades=true)
Definition: _laststand.gsc:155
‪GADGET_ACTION_PRIMED
‪#define GADGET_ACTION_PRIMED
Definition: _ability_util.gsh:87
‪laststand_clean_up_on_interrupt
‪function laststand_clean_up_on_interrupt(playerBeingRevived, reviverGun)
Definition: _laststand.gsc:178
‪GADGET_TYPE_RESURRECT
‪#define GADGET_TYPE_RESURRECT
Definition: _ability_util.gsh:46
‪suicide
‪function suicide()
Definition: _vehicle.gsc:1309
‪watch_player_input
‪function watch_player_input()
Definition: _laststand.gsc:237
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪cleanup_suicide_hud
‪function cleanup_suicide_hud()
Definition: laststand_shared.gsc:67
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪bookmark
‪function bookmark(type, time, mainClientEnt, otherClientEnt, eventPriority, inflictorEnt, overrideEntityCamera, actorEnt)
Definition: demo_shared.gsc:25
‪get_killcam_entity_info
‪function get_killcam_entity_info(attacker, eInflictor, weapon)
Definition: _killcam.gsc:1067
‪bleed_out
‪function bleed_out()
Definition: _laststand.gsc:216
‪player_last_stand_stats
‪function player_last_stand_stats(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
Definition: _laststand.gsc:39
‪PlayerLastStand
‪function PlayerLastStand(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, delayOverride)
Definition: _laststand.gsc:63
‪player_is_in_laststand
‪function player_is_in_laststand()
Definition: laststand_shared.gsc:18
‪laststand_clean_up_reviving_any
‪function laststand_clean_up_reviving_any(playerBeingRevived)
Definition: _laststand.gsc:203
‪destroy
‪function destroy(watcher, owner)
Definition: _decoy.gsc:108
‪gadget_slot_for_type
‪function gadget_slot_for_type(type)
Definition: _ability_util.gsc:23
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265
‪is_reviving_any
‪function is_reviving_any()
Definition: _zm_laststand.gsc:1144