‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_quadtank.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\system_shared;
7 #using scripts\shared\util_shared;
8 #using scripts\shared\vehicle_shared;
9 
10 #insert scripts\shared\shared.gsh;
11 #insert scripts\shared\version.gsh;
12 
13 #namespace quadtank;
14 
15 ‪REGISTER_SYSTEM( "quadtank", &‪__init__, undefined )
16 
17 function ‪__init__()
18 {
20 
23 }
24 
25 function ‪_setup_( localClientNum )
26 {
27  player = GetLocalPlayer( localClientNum );
28  if( isdefined( player ) )
29  {
31  }
32  //set code field to get notifies to play impact effects
33  self.notifyOnBulletImpact = true;
34  self thread ‪wait_for_bullet_impact( localClientNum );
35 
36  //trophy state
37  self.trophy_on = false;
38 }
39 
40 
41 function ‪player_shock_fx_handler( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
42 {
43  if ( isdefined( self ) )
44  {
45  self thread ‪player_shock_fx_fade_off( localClientNum, 1.0, 1.0 );
46  }
47 }
48 
49 function ‪player_shock_fx_fade_off( localClientNum, amount, fadeoutTime )
50 {
51  // not ending on death or shutdown, cause we have to clean ourselves up
52  self endon( "disconnect" );
53  self notify( "player_shock_fx_fade_off_end" ); // kill previous threads
54  self endon( "player_shock_fx_fade_off_end" );
55 
56  if ( !isAlive( self ) )
57  {
58  return;
59  }
60 
61  ‪startTime = GetTime();
62 
65 
66  while ( GetTime() <= ‪startTime + fadeoutTime * 1000 && isAlive( self ) )
67  {
68  ratio = ( GetTime() - ‪startTime ) / ( fadeoutTime * 1000 );
69  currentValue = LerpFloat( amount, 0, ratio );
70  setfilterpassconstant( localClientNum, ‪FILTER_INDEX_PLAYER_SHOCK, 0, 0, currentValue ); // use code function instead of script wrapper cause player can be undefined
71 
72  wait ‪CLIENT_FRAME;
73  }
74 
75  setfilterpassenabled( localClientNum, ‪FILTER_INDEX_PLAYER_SHOCK, 0, false );
76 }
77 
78 function ‪update_trophy_system_state( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
79 {
80  self thread ‪set_trophy_state( localClientNum, newval === 1 );
81 }
82 
83 function ‪set_trophy_state( localClientNum, isOn )
84 {
85  self endon( "entityshutdown" );
86  self notify( "stop_set_trophy_state" );
87  self endon( "stop_set_trophy_state" );
88 
89  if ( isdefined( self.trophydestroy_fx_handle ) )
90  {
91  StopFX( localClientNum, self.trophydestroy_fx_handle );
92  }
93 
94  if ( isdefined( self.trophylight_fx_handle ) )
95  {
96  StopFX( localClientNum, self.trophylight_fx_handle );
97  }
98 
99  ‪vehicle::wait_for_DObj( localClientNum );
100 
101  if( isdefined( self.scriptbundlesettings ) )
102  {
103  settings = ‪struct::get_script_bundle( "vehiclecustomsettings", self.scriptbundlesettings );
104  }
105 
106  if ( !isdefined( settings ) )
107  {
108  return;
109  }
110 
111  if ( isOn === 1 )
112  {
113  warmuptime = ‪VAL( settings.trophywarmup, 0.1 );
114 
115  start = GetTime();
116  interval = 0.3;
117  while ( GetTime() <= start + warmuptime * 1000 )
118  {
119  if ( isdefined( settings.trophylight_fx_1 ) && isdefined( settings.trophylight_tag_1 ) )
120  {
121  self.trophylight_fx_handle = PlayFXOnTag( localClientNum, settings.trophylight_fx_1, self, settings.trophylight_tag_1 );
122  }
123 
124  wait 0.05;
125 
126  if ( isdefined( self.trophylight_fx_handle ) )
127  {
128  StopFX( localClientNum, self.trophylight_fx_handle );
129  }
130 
131  wait max( interval, 0.05 );
132  interval *= 0.8;
133  }
134 
135  if ( isdefined( settings.trophylight_fx_1 ) && isdefined( settings.trophylight_tag_1 ) )
136  {
137  self.trophylight_fx_handle = PlayFXOnTag( localClientNum, settings.trophylight_fx_1, self, settings.trophylight_tag_1 );
138  }
139 
140  self.trophy_on = true;
141 
142  self PlayLoopSound ( "wpn_trophy_spin_loop");
143 
144  rate = 0.0;
145  while ( isdefined( settings.trophyanim ) && rate < 1 )
146  {
147  rate += 0.02;
148  self SetAnim( settings.trophyanim, 1.0, 0.1, rate );
150  }
151  self SetAnim( settings.trophyanim, 1.0, 0.1, 1.0 );
152  }
153  else
154  {
155  self.trophy_on = false;
156 
157  self StopAllLoopSounds();
158 
159  if ( isdefined( settings.trophyanim ) )
160  {
161  self SetAnim( settings.trophyanim, 0.0, 0.2, 1.0 );
162  }
163 
164  if ( isdefined( settings.trophydestroyfx ) )
165  {
166  self.trophydestroy_fx_handle = PlayFXOnTag( localClientNum, settings.trophydestroyfx, self, "tag_target_lower" );
167  }
168  }
169 }
170 
171 function ‪wait_for_bullet_impact( localClientNum )
172 {
173  self endon( "entityshutdown" );
174 
175  if( isdefined( self.scriptbundlesettings ) )
176  {
177  settings = ‪struct::get_script_bundle( "vehiclecustomsettings", self.scriptbundlesettings );
178  }
179  else
180  {
181  return;
182  }
183 
184  while( 1 )
185  {
186  self waittill( "damage", attacker, impactPos, effectDir, partname );
187  if( partName == "tag_target_lower" || partName == "tag_target_upper" || partName == "tag_defense_active" || partName == "tag_body_animate" )
188  {
189  if( self.trophy_on )
190  {
191  if( IsDefined( attacker ) && attacker IsPlayer() && attacker.team != self.team )
192  {
193  ‪PlayFx( localClientNum, settings.weakspotfx, impactPos, effectDir );
194  self playsound( 0, "veh_quadtank_panel_hit" );
195  }
196  }
197  }
198  }
199 }
‪startTime
‪class AnimationAdjustmentInfoZ startTime
‪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
‪VAL
‪#define VAL(__var, __default)
Definition: shared.gsh:272
‪wait_for_DObj
‪function wait_for_DObj(localClientNum)
Definition: vehicle_shared.csc:387
‪update_trophy_system_state
‪function update_trophy_system_state(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _quadtank.csc:77
‪player_shock_fx_handler
‪function player_shock_fx_handler(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _quadtank.csc:81
‪enable_filter_ev_interference
‪function enable_filter_ev_interference(player, filterid)
Definition: filter_shared.csc:645
‪_setup_
‪function _setup_(localClientNum)
Definition: _quadtank.csc:24
‪CLIENT_FRAME
‪#define CLIENT_FRAME
Definition: shared.gsh:263
‪set_filter_ev_interference_amount
‪function set_filter_ev_interference_amount(player, filterid, amount)
Definition: filter_shared.csc:652
‪FILTER_INDEX_PLAYER_SHOCK
‪#define FILTER_INDEX_PLAYER_SHOCK
Definition: shared.gsh:487
‪__init__
‪function __init__()
Definition: _quadtank.csc:17
‪wait_for_bullet_impact
‪function wait_for_bullet_impact(localClientNum)
Definition: _quadtank.csc:118
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪set_trophy_state
‪function set_trophy_state(localClientNum, isOn)
Definition: _quadtank.csc:83
‪add_vehicletype_callback
‪function add_vehicletype_callback(vehicletype, callback)
Definition: vehicle_shared.csc:77
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪get_script_bundle
‪function get_script_bundle(str_type, str_name)
Definition: struct.csc:45
‪player_shock_fx_fade_off
‪function player_shock_fx_fade_off(localClientNum, amount, fadeoutTime)
Definition: _quadtank.csc:89
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪init_filter_ev_interference
‪function init_filter_ev_interference(player)
Definition: filter_shared.csc:639
‪PlayFx
‪function PlayFx(name)
Definition: _counteruav.gsc:390