‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_sticky_grenade.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\math_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\util_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 
10 #precache( "client_fx", "weapon/fx_equip_light_os" );
11 
12 #namespace sticky_grenade;
13 
14 ‪REGISTER_SYSTEM( "sticky_grenade", &‪__init__, undefined )
15 
16 function ‪__init__()
17 {
18  level._effect["grenade_light"] = "weapon/fx_equip_light_os";
19 
20  ‪callback::add_weapon_type( "sticky_grenade", &‪spawned );
21 }
22 
23 function ‪spawned( localClientNum )
24 {
25  if ( self isGrenadeDud() )
26  return;
27 
28  self thread ‪fx_think( localClientNum );
29 }
30 
32 {
33  self waittill( "entityshutdown" );
34 
35  StopSound(handle);
36 }
37 
38 function ‪fx_think( localClientNum )
39 {
40  self notify( "light_disable" );
41  self endon( "light_disable" );
42 
43  self endon( "entityshutdown" );
44 
45  self ‪util::waittill_dobj( localClientNum );
46 
47  handle = self PlaySound( localClientNum, "wpn_semtex_countdown" );
48  self thread ‪stop_sound_on_ent_shutdown( handle );
49 
50 
51  interval = 0.3;
52 
53  for( ;; )
54  {
55  self ‪stop_light_fx( localClientNum );
56  localPlayer = GetLocalPlayer( localClientNum );
57 
58  if ( !( localPlayer isEntityLinkedToTag( self, "j_head" ) )
59  && !( localPlayer isEntityLinkedToTag( self, "j_elbow_le" ) )
60  && !( localPlayer isEntityLinkedToTag( self, "j_spineupper" ) ) )
61  {
62  self ‪start_light_fx( localClientNum );
63  }
64 
65  self ‪fullscreen_fx( localClientNum );
66 
67  ‪util::server_wait( localClientNum, interval, 0.01, "player_switch" );
68 
69  self ‪util::waittill_dobj( localClientNum );
70 
71  interval = ‪math::clamp( ( interval / 1.2 ), 0.08, 0.3 );
72  }
73 }
74 
75 function ‪start_light_fx( localClientNum )
76 {
77  player = GetLocalPlayer( localClientNum );
78 
79  self.fx = PlayFxOnTag( localClientNum, level._effect["grenade_light"], self, "tag_fx" );
80 }
81 
82 function ‪stop_light_fx( localClientNum )
83 {
84  if ( isdefined( self.fx ) && self.fx != 0 )
85  {
86  StopFx( localClientNum, self.fx );
87  self.fx = undefined;
88  }
89 }
90 
91 function ‪sticky_indicator( player, localClientNum )
92 {
93  controllerModel = GetUIModelForController( localClientNum );
94  stickyImageModel = CreateUIModel( controllerModel, "hudItems.stickyImage" );
95 
96  SetUIModelValue( stickyImageModel, "hud_icon_stuck_semtex" );
97 
98  player thread ‪stick_indicator_watch_early_shutdown( stickyImageModel );
99  // this is probably good enough, but the while loop is safer
100  // self util::waittill_any( "death", "detonated" );
101 
102  while( IsDefined(self ) )
103  {
105  }
106 
107  SetUIModelValue( stickyImageModel, "blacktransparent" );
108  player notify ( "sticky_shutdown");
109 }
110 
111 function ‪stick_indicator_watch_early_shutdown( stickyImageModel )
112 {
113  self endon ( "sticky_shutdown" );
114  self endon ( "entityshutdown" );
115 
116  self waittill ( "player_flashback" );
117 
118  SetUIModelValue( stickyImageModel, "blacktransparent" );
119 }
120 
121 function ‪fullscreen_fx( localClientNum )
122 {
123  player = GetLocalPlayer( localClientNum );
124 
125  if ( isdefined( player ) )
126  {
127  if ( player GetInKillcam( localClientNum ) )
128  {
129  return;
130  }
131  else if ( player ‪util::is_player_view_linked_to_entity( localClientNum ) )
132  {
133  return;
134  }
135  }
136 
137  if ( self isfriendly( localClientNum ) )
138  {
139  return;
140  }
141 
142  parent = self GetParentEntity();
143 
144  if ( isdefined( parent ) && parent == player )
145  {
146  parent PlayRumbleOnEntity( localClientNum, "buzz_high" );
147 
148  if ( GetDvarint( "ui_hud_hardcore" ) == 0 )
149  {
150  self thread ‪sticky_indicator( player, localClientNum );
151  }
152  }
153 }
‪is_player_view_linked_to_entity
‪function is_player_view_linked_to_entity(localClientNum)
Definition: util_shared.csc:1244
‪sticky_indicator
‪function sticky_indicator(player, localClientNum)
Definition: _sticky_grenade.csc:91
‪fx_think
‪function fx_think(localClientNum)
Definition: _sticky_grenade.csc:38
‪stop_sound_on_ent_shutdown
‪function stop_sound_on_ent_shutdown(handle)
Definition: _sticky_grenade.csc:31
‪stick_indicator_watch_early_shutdown
‪function stick_indicator_watch_early_shutdown(stickyImageModel)
Definition: _sticky_grenade.csc:111
‪spawned
‪function spawned(localClientNum)
Definition: _sticky_grenade.csc:23
‪add_weapon_type
‪function add_weapon_type(weapontype, callback)
Definition: callbacks_shared.csc:780
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪waittill_dobj
‪function waittill_dobj(localClientNum)
Definition: util_shared.csc:1117
‪start_light_fx
‪function start_light_fx(localClientNum)
Definition: _sticky_grenade.csc:75
‪clamp
‪function clamp(val, val_min, val_max)
Definition: math_shared.csc:16
‪stop_light_fx
‪function stop_light_fx(localClientNum)
Definition: _sticky_grenade.csc:82
‪server_wait
‪function server_wait(localClientNum, seconds, waitBetweenChecks, level_endon)
Definition: util_shared.csc:1125
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪__init__
‪function __init__()
Definition: _sticky_grenade.csc:16
‪fullscreen_fx
‪function fullscreen_fx(localClientNum)
Definition: _sticky_grenade.csc:121