‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_gadget_overdrive.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\filter_shared;
6 #using scripts\shared\util_shared;
7 
8 #using scripts\shared\abilities\_ability_player;
9 #using scripts\shared\abilities\_ability_power;
10 #using scripts\shared\abilities\_ability_util;
11 
12 #insert scripts\shared\shared.gsh;
13 #insert scripts\shared\version.gsh;
14 
15 #using scripts\shared\system_shared;
16 #using scripts\shared\visionset_mgr_shared;
17 #using scripts\shared\postfx_shared;
18 #using scripts\shared\lui_shared;
19 
20 #insert scripts\shared\abilities\gadgets\_gadget_overdrive.gsh;
21 
22 #define MAX_FLASH_ALPHA GetDvarFloat("scr_overdrive_flash_alpha", 0.7)
23 #define FLASH_FADE_IN_TIME GetDvarFloat("scr_overdrive_flash_fade_in_time", 0.075)
24 #define FLASH_FADE_OUT_TIME GetDvarFloat("scr_overdrive_flash_fade_out_time", 0.45)
25 #define OVERDRIVE_BOOST_FX_DURATION GetDvarFloat("scr_overdrive_boost_fx_time", 0.75)
26 #define OVERDRIVE_BLUR_AMOUNT GetDvarFloat( "scr_overdrive_amount", 0.15 )
27 #define OVERDRIVE_BLUR_INNER_RADIUS GetDvarFloat( "scr_overdrive_inner_radius", 0.6 )
28 #define OVERDRIVE_BLUR_OUTER_RADIUS GetDvarFloat( "scr_overdrive_outer_radius", 1 )
29 #define OVERDRIVE_BLUR_VELOCITY_SHOULDSCALE GetDvarInt( "scr_overdrive_velShouldScale", 1 )
30 #define OVERDRIVE_BLUR_VELOCITY_SCALE GetDvarInt( "scr_overdrive_velScale", 220 )
31 
32 #define OVERDRIVE_SHOW_BOOST_SPEED_TOLERANCE GetDvarInt( "scr_overdrive_boost_speed_tol", 280 )
33 
34 
35 #precache( "client_fx", "player/fx_plyr_ability_screen_blur_overdrive" );
36 
37 
38 
39 ‪REGISTER_SYSTEM( "gadget_overdrive", &‪__init__, undefined )
40 
41 function ‪__init__()
42 {
46 
48 
50 }
51 
52 function ‪on_localplayer_shutdown(localClientNum)
53 {
54  self ‪overdrive_shutdown( localClientNum );
55 }
56 
57 
58 function ‪on_localplayer_spawned( localClientNum )
59 {
60  if( self != GetLocalPlayer( localClientNum ) )
61  return;
62 
65  DisableSpeedBlur( localClientNum );
66 }
67 
68 function ‪on_player_connect( local_client_num )
69 {
70 
71 }
72 
73 function ‪player_overdrive_handler(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
74 {
75  if ( !self IsLocalPlayer() || IsSpectating( localClientNum, false ) || ( (isdefined(level.localPlayers[localClientNum])) && (self GetEntityNumber() != level.localPlayers[localClientNum] GetEntityNumber())) )
76  {
77  return;
78  }
79 
80  if( (newVal != oldval) && newval )
81  {
84  self UseAlternateAimParams();
85  self thread ‪activation_flash(localClientNum);
86  self ‪boost_fx_on_velocity(localClientNum);
87  }
88  else if ( (newVal != oldval) && !newval )
89  {
90  self ‪overdrive_shutdown( localClientNum );
91  }
92 }
93 
94 
95 // Flashes the screen white on activation.
96 function ‪activation_flash(localClientNum)
97 {
98  self notify("activation_flash");
99  self endon("activation_flash");
100  self endon("death");
101  self endon("entityshutdown");
102  self endon("stop_player_fx");
103  self endon("disable_cybercom");
104 
105  self.whiteFlashFade = 1;
109  self.whiteFlashFade = undefined;
110 }
111 
112 // Turn on the "hyperdrive" boost effects on camera
113 function ‪enable_boost_camera_fx(localClientNum)
114 {
115  if (isDefined(self.firstperson_fx_overdrive))
116  {
117  StopFX(localClientNum, self.firstperson_fx_overdrive);
118  self.firstperson_fx_overdrive = undefined;
119  }
120  self.firstperson_fx_overdrive = PlayFXOnCamera( localClientNum, "player/fx_plyr_ability_screen_blur_overdrive", (0,0,0), (1,0,0), (0,0,1) );
121  self thread ‪watch_stop_player_fx( localClientNum, self.firstperson_fx_overdrive );
122 }
123 
124 function ‪watch_stop_player_fx( localClientNum, fx )
125 {
126  self notify("watch_stop_player_fx");
127  self endon("watch_stop_player_fx");
128  self endon("entityshutdown");
129 
130  self ‪util::waittill_any( "stop_player_fx","death","disable_cybercom" );
131 
132  if ( IsDefined( fx ) )
133  {
134  StopFx( localClientNum, fx );
135  self.firstperson_fx_overdrive = undefined;
136  }
137 }
138 
139 // Turn off the "hyperdrive" boost effects on camera
140 function ‪stop_boost_camera_fx(localClientNum)
141 {
142  self notify( "stop_player_fx" );
143 
144  if(‪IS_TRUE(self.whiteFlashFade))
145  {
147  }
148 }
149 
150 // Stop FX when we die or hit a cybercom turnoff event.
152 {
153  self endon("overdrive_boost_fx_interrupt_handler");
154  self endon("end_overdrive_boost_fx");
155  self endon("entityshutdown");
156 
157  self ‪util::waittill_any( "death", "disable_cybercom" );
158 
159  self ‪overdrive_shutdown( localClientNum );
160 }
161 
162 // Turns off all effects and ability buffs given by overdrive.
163 // self == player
164 function ‪overdrive_shutdown( localClientNum )
165 {
166  if (isdefined(localClientNum))
167  {
168  self ‪stop_boost_camera_fx( localClientNum );
169  self ClearAlternateAimParams();
171  DisableSpeedBlur( localClientNum );
172  self notify( "end_overdrive_boost_fx");
173  }
174 }
175 
176 // Turn on boost FX (hyperdrive!) when we're moving forward fast enough.
177 // This effectively translates to sprinting forward with its current tuning.
178 function ‪boost_fx_on_velocity(localClientNum) //self == player
179 {
180  self endon("disable_cybercom");
181  self endon("death");
182  self endon("end_overdrive_boost_fx");
183  self endon("disconnect");
184 
185  // Ensure the boost plays for at least a short time on activation.
186  self ‪enable_boost_camera_fx(localClientNum);
187 
188  //Keep track of when we might need to turn force off the boost FX
189  self thread ‪overdrive_boost_fx_interrupt_handler(localclientnum);
190 
192 
193  while (isDefined(self))
194  {
195  // Get forward direction and speed information.
196  v_player_velocity = self GetVelocity();
197  v_player_forward = Anglestoforward(self.angles);
198  n_dot = VectorDot(VectorNormalize(v_player_velocity), v_player_forward);
199  n_speed = Length(v_player_velocity);
200 
201  // If we're moving forward fast enough:
202  if (n_speed >= ‪OVERDRIVE_SHOW_BOOST_SPEED_TOLERANCE && n_dot > 0.8)
203  {
204  if (!isdefined(self.firstperson_fx_overdrive))
205  {
206  self ‪enable_boost_camera_fx(localClientNum);
207  }
208  }
209  else
210  {
211  if (isdefined(self.firstperson_fx_overdrive))
212  {
213  self ‪stop_boost_camera_fx(localClientNum);
214  }
215  }
217  }
218 }
219 
‪init_filter_overdrive
‪function init_filter_overdrive(player)
Definition: filter_shared.csc:763
‪FILTER_INDEX_OVERDRIVE
‪#define FILTER_INDEX_OVERDRIVE
Definition: shared.gsh:494
‪OVERDRIVE_SHOW_BOOST_SPEED_TOLERANCE
‪#define OVERDRIVE_SHOW_BOOST_SPEED_TOLERANCE
Definition: _gadget_overdrive.csc:32
‪player_overdrive_handler
‪function player_overdrive_handler(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _gadget_overdrive.csc:73
‪MAX_FLASH_ALPHA
‪#define MAX_FLASH_ALPHA
Definition: _gadget_overdrive.csc:22
‪on_localclient_shutdown
‪function on_localclient_shutdown(func, obj)
Definition: callbacks_shared.csc:190
‪CF_CALLBACK_ZERO_ON_NEW_ENT
‪#define CF_CALLBACK_ZERO_ON_NEW_ENT
Definition: version.gsh:103
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪screen_fade
‪function screen_fade(n_time, n_target_alpha=1, n_start_alpha=0, str_color="black", b_force_close_menu=false)
Definition: lui_shared.csc:372
‪on_localplayer_spawned
‪function on_localplayer_spawned(localClientNum)
Definition: _gadget_overdrive.csc:58
‪OVERDRIVE_VISIONSET
‪#define OVERDRIVE_VISIONSET
Definition: _gadget_overdrive.gsh:2
‪FLASH_FADE_IN_TIME
‪#define FLASH_FADE_IN_TIME
Definition: _gadget_overdrive.csc:23
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪on_player_connect
‪function on_player_connect(local_client_num)
Definition: _gadget_overdrive.csc:68
‪on_localplayer_shutdown
‪function on_localplayer_shutdown(localClientNum)
Definition: _gadget_overdrive.csc:52
‪watch_stop_player_fx
‪function watch_stop_player_fx(localClientNum, fx)
Definition: _gadget_overdrive.csc:124
‪register_visionset_info
‪function register_visionset_info(name, version, lerp_step_count, visionset_from, visionset_to, visionset_type=VSMGR_VISIONSET_TYPE_NAKED)
Definition: visionset_mgr_shared.csc:50
‪overdrive_boost_fx_interrupt_handler
‪function overdrive_boost_fx_interrupt_handler(localClientNum)
Definition: _gadget_overdrive.csc:151
‪OVERDRIVE_VISIONSET_ALIAS
‪#define OVERDRIVE_VISIONSET_ALIAS
Definition: _gadget_overdrive.gsh:3
‪overdrive_shutdown
‪function overdrive_shutdown(localClientNum)
Definition: _gadget_overdrive.csc:164
‪stop_boost_camera_fx
‪function stop_boost_camera_fx(localClientNum)
Definition: _gadget_overdrive.csc:140
‪OVERDRIVE_BLUR_OUTER_RADIUS
‪#define OVERDRIVE_BLUR_OUTER_RADIUS
Definition: _gadget_overdrive.csc:28
‪OVERDRIVE_BLUR_VELOCITY_SHOULDSCALE
‪#define OVERDRIVE_BLUR_VELOCITY_SHOULDSCALE
Definition: _gadget_overdrive.csc:29
‪on_localclient_connect
‪function on_localclient_connect(localClientNum)
Definition: ctf.csc:20
‪OVERDRIVE_BOOST_FX_DURATION
‪#define OVERDRIVE_BOOST_FX_DURATION
Definition: _gadget_overdrive.csc:25
‪FLASH_FADE_OUT_TIME
‪#define FLASH_FADE_OUT_TIME
Definition: _gadget_overdrive.csc:24
‪OVERDRIVE_BLUR_INNER_RADIUS
‪#define OVERDRIVE_BLUR_INNER_RADIUS
Definition: _gadget_overdrive.csc:27
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪activation_flash
‪function activation_flash(localClientNum)
Definition: _gadget_overdrive.csc:96
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪OVERDRIVE_BLUR_AMOUNT
‪#define OVERDRIVE_BLUR_AMOUNT
Definition: _gadget_overdrive.csc:26
‪__init__
‪function __init__()
Definition: _gadget_overdrive.csc:41
‪OVERDRIVE_BLUR_VELOCITY_SCALE
‪#define OVERDRIVE_BLUR_VELOCITY_SCALE
Definition: _gadget_overdrive.csc:30
‪enable_filter_overdrive
‪function enable_filter_overdrive(player, filterid)
Definition: filter_shared.csc:772
‪enable_boost_camera_fx
‪function enable_boost_camera_fx(localClientNum)
Definition: _gadget_overdrive.csc:113
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪disable_filter_overdrive
‪function disable_filter_overdrive(player, filterid)
Definition: filter_shared.csc:783
‪boost_fx_on_velocity
‪function boost_fx_on_velocity(localClientNum)
Definition: _gadget_overdrive.csc:178
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪OVERDRIVE_VISIONSET_STEPS
‪#define OVERDRIVE_VISIONSET_STEPS
Definition: _gadget_overdrive.gsh:5