‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_gadget_unstoppable_force.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\lui_shared;
16 
17 #using scripts\shared\system_shared;
18 
19 #define MAX_FLASH_ALPHA GetDvarFloat("scr_unstoppableforce_flash_alpha", 0.6)
20 #define FLASH_FADE_IN_TIME GetDvarFloat("scr_unstoppableforce_flash_fade_in_time", 0.075)
21 #define FLASH_FADE_OUT_TIME GetDvarFloat("scr_unstoppableforce_flash_fade_out_time", 0.9)
22 #define UNSTOPPABLEFORCE_BLUR_AMOUNT GetDvarFloat( "scr_unstoppableforce_amount", 0.15 )
23 #define UNSTOPPABLEFORCE_BLUR_INNER_RADIUS GetDvarFloat( "scr_unstoppableforce_inner_radius", 0.6 )
24 #define UNSTOPPABLEFORCE_BLUR_OUTER_RADIUS GetDvarFloat( "scr_unstoppableforce_outer_radius", 1 )
25 #define UNSTOPPABLEFORCE_BLUR_VELOCITY_SHOULDSCALE GetDvarInt( "scr_unstoppableforce_velShouldScale", 1 )
26 #define UNSTOPPABLEFORCE_BLUR_VELOCITY_SCALE GetDvarInt( "scr_unstoppableforce_velScale", 220 )
27 
28 #define UNSTOPPABLEFORCE_SHOW_BOOST_SPEED_TOLERANCE GetDvarInt( "scr_unstoppableforce_boost_speed_tol", 320 )
29 
30 #define UNSTOPPABLEFORCE_ACTIVATION_DELAY GetDvarFloat( "scr_unstoppableforce_activation_delay", 0.35 )
31 
32 #precache( "client_fx", "player/fx_plyr_ability_screen_blur_overdrive" );
33 
34 ‪REGISTER_SYSTEM( "gadget_unstoppable_force", &‪__init__, undefined )
35 
36 function ‪__init__()
37 {
39 
41 }
42 
43 function ‪on_localplayer_shutdown(localClientNum)
44 {
45  ‪stop_boost_camera_fx( localClientNum );
46 }
47 
48 
49 function ‪player_unstoppableforce_handler(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
50 {
51  if ( !self IsLocalPlayer() || IsSpectating( localClientNum, false ) || ( (isdefined(level.localPlayers[localClientNum])) && (self GetEntityNumber() != level.localPlayers[localClientNum] GetEntityNumber())) )
52  {
53  return;
54  }
55 
56  if( (newVal != oldval) && newVal)
57  {
59  self thread ‪activation_flash(localClientNum);
60  self ‪boost_fx_on_velocity(localClientNum);
61  }
62  else if ( (newVal != oldval) && !newval )
63  {
64  self ‪stop_boost_camera_fx(localClientNum);
65  DisableSpeedBlur( localClientNum );
66 
67  // Notify child threads to end.
68  self notify( "end_unstoppableforce_boost_fx");
69  }
70 }
71 
72 
73 // Flashes the screen white on activation.
74 function ‪activation_flash(localClientNum)
75 {
76  self ‪util::waittill_any_timeout(‪UNSTOPPABLEFORCE_ACTIVATION_DELAY, "unstoppableforce_arm_cross_end");
77 
81 }
82 
83 // Turn on the "hyperdrive" boost effects on camera
84 function ‪enable_boost_camera_fx(localClientNum)
85 {
86  self.firstperson_fx_unstoppableforce = PlayFXOnCamera( localClientNum, "player/fx_plyr_ability_screen_blur_overdrive", (0,0,0), (1,0,0), (0,0,1) );
87 }
88 
89 // Turn off the "hyperdrive" boost effects on camera
90 function ‪stop_boost_camera_fx(localClientNum)
91 {
92  if (isdefined(self.firstperson_fx_unstoppableforce))
93  {
94  StopFX(localClientNum, self.firstperson_fx_unstoppableforce);
95  self.firstperson_fx_unstoppableforce = undefined;
96  }
97 }
98 
99 // Stop FX when we die or hit a cybercom turnoff event.
100 function ‪boost_fx_interrupt_handler(localClientNum)
101 {
102  self endon("end_unstoppableforce_boost_fx");
103 
104  self ‪util::waittill_any("disable_cybercom", "death");
105  ‪stop_boost_camera_fx( localClientNum );
106 
107  self notify( "end_unstoppableforce_boost_fx");
108 }
109 
110 // Turn on boost FX (hyperdrive!) when we're moving forward fast enough.
111 // This effectively translates to sprinting forward with its current tuning.
112 function ‪boost_fx_on_velocity(localClientNum) //self == player
113 {
114  self endon("disable_cybercom");
115  self endon("death");
116  self endon("end_unstoppableforce_boost_fx");
117  self endon("disconnect");
118 
119  //Keep track of when we might need to turn force off the boost FX
120  self thread ‪boost_fx_interrupt_handler(localclientnum);
121 
122  while (isDefined(self))
123  {
124  // Get forward direction and speed information.
125  v_player_velocity = self GetVelocity();
126  v_player_forward = Anglestoforward(self.angles);
127  n_dot = VectorDot(VectorNormalize(v_player_velocity), v_player_forward);
128  n_speed = Length(v_player_velocity);
129 
130  // If we're moving forward fast enough:
131  if (n_speed >= ‪UNSTOPPABLEFORCE_SHOW_BOOST_SPEED_TOLERANCE && n_dot > 0.8)
132  {
133  if (!isdefined(self.firstperson_fx_unstoppableforce))
134  {
135  self ‪enable_boost_camera_fx(localClientNum);
136  }
137  }
138  else
139  {
140  if (isdefined(self.firstperson_fx_unstoppableforce))
141  {
142  self ‪stop_boost_camera_fx(localClientNum);
143  }
144  }
146  }
147 }
‪UNSTOPPABLEFORCE_BLUR_AMOUNT
‪#define UNSTOPPABLEFORCE_BLUR_AMOUNT
Definition: _gadget_unstoppable_force.csc:22
‪enable_boost_camera_fx
‪function enable_boost_camera_fx(localClientNum)
Definition: _gadget_unstoppable_force.csc:84
‪UNSTOPPABLEFORCE_BLUR_VELOCITY_SHOULDSCALE
‪#define UNSTOPPABLEFORCE_BLUR_VELOCITY_SHOULDSCALE
Definition: _gadget_unstoppable_force.csc:25
‪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
‪boost_fx_on_velocity
‪function boost_fx_on_velocity(localClientNum)
Definition: _gadget_unstoppable_force.csc:112
‪on_localplayer_shutdown
‪function on_localplayer_shutdown(localClientNum)
Definition: _gadget_unstoppable_force.csc:43
‪UNSTOPPABLEFORCE_BLUR_INNER_RADIUS
‪#define UNSTOPPABLEFORCE_BLUR_INNER_RADIUS
Definition: _gadget_unstoppable_force.csc:23
‪waittill_any_timeout
‪function waittill_any_timeout(n_timeout, string1, string2, string3, string4, string5)
Definition: util_shared.csc:423
‪UNSTOPPABLEFORCE_BLUR_VELOCITY_SCALE
‪#define UNSTOPPABLEFORCE_BLUR_VELOCITY_SCALE
Definition: _gadget_unstoppable_force.csc:26
‪FLASH_FADE_OUT_TIME
‪#define FLASH_FADE_OUT_TIME
Definition: _gadget_unstoppable_force.csc:21
‪MAX_FLASH_ALPHA
‪#define MAX_FLASH_ALPHA
Definition: _gadget_unstoppable_force.csc:19
‪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
‪UNSTOPPABLEFORCE_BLUR_OUTER_RADIUS
‪#define UNSTOPPABLEFORCE_BLUR_OUTER_RADIUS
Definition: _gadget_unstoppable_force.csc:24
‪FLASH_FADE_IN_TIME
‪#define FLASH_FADE_IN_TIME
Definition: _gadget_unstoppable_force.csc:20
‪UNSTOPPABLEFORCE_ACTIVATION_DELAY
‪#define UNSTOPPABLEFORCE_ACTIVATION_DELAY
Definition: _gadget_unstoppable_force.csc:30
‪stop_boost_camera_fx
‪function stop_boost_camera_fx(localClientNum)
Definition: _gadget_unstoppable_force.csc:90
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪player_unstoppableforce_handler
‪function player_unstoppableforce_handler(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _gadget_unstoppable_force.csc:49
‪boost_fx_interrupt_handler
‪function boost_fx_interrupt_handler(localClientNum)
Definition: _gadget_unstoppable_force.csc:100
‪UNSTOPPABLEFORCE_SHOW_BOOST_SPEED_TOLERANCE
‪#define UNSTOPPABLEFORCE_SHOW_BOOST_SPEED_TOLERANCE
Definition: _gadget_unstoppable_force.csc:28
‪__init__
‪function __init__()
Definition: _gadget_unstoppable_force.csc:36
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪activation_flash
‪function activation_flash(localClientNum)
Definition: _gadget_unstoppable_force.csc:74