‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_weap_tesla.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\array_shared;
4 #using scripts\shared\callbacks_shared;
5 #using scripts\shared\demo_shared;
6 #using scripts\shared\laststand_shared;
7 #using scripts\shared\util_shared;
8 
9 #using scripts\shared\ai\zombie_utility;
10 
11 #insert scripts\shared\shared.gsh;
12 
13 #using scripts\zm\_util;
14 #using scripts\zm\_zm;
15 #using scripts\zm\_zm_audio;
16 #using scripts\zm\_zm_laststand;
17 #using scripts\zm\_zm_lightning_chain;
18 #using scripts\zm\_zm_net;
19 #using scripts\zm\_zm_score;
20 #using scripts\zm\_zm_spawner;
21 #using scripts\zm\_zm_utility;
22 #using scripts\zm\_zm_weap_tesla;
23 #using scripts\zm\_zm_weapons;
24 
25 #precache( "fx", "zombie/fx_tesla_rail_view_zmb" );
26 #precache( "fx", "zombie/fx_tesla_tube_view_zmb" );
27 #precache( "fx", "zombie/fx_tesla_tube_view2_zmb" );
28 #precache( "fx", "zombie/fx_tesla_tube_view3_zmb" );
29 #precache( "fx", "zombie/fx_tesla_rail_view_ug_zmb" );
30 #precache( "fx", "zombie/fx_tesla_tube_view_ug_zmb" );
31 #precache( "fx", "zombie/fx_tesla_tube_view2_ug_zmb" );
32 #precache( "fx", "zombie/fx_tesla_tube_view3_ug_zmb" );
33 
34 // T7 TODO
35 // Restore Removed GDT Entries
36 // Trail Effect: fx\_t6\maps\zombie\fx_zombie_tesla_electric_bolt.efx
37 // Trail Effect (upgraded tesla gun): fx\_t6\maps\zombie\fx_zombie_tesla_ug_elec_bolt.efx
38 
39 function ‪init()
40 {
41  level.weaponZMTeslaGun = GetWeapon( "tesla_gun" );
42  level.weaponZMTeslaGunUpgraded = GetWeapon( "tesla_gun_upgraded" );
43  if ( !‪zm_weapons::is_weapon_included( level.weaponZMTeslaGun ) && !‪IS_TRUE( level.uses_tesla_powerup ) )
44  {
45  return;
46  }
47 
48  level._effect["tesla_viewmodel_rail"] = "zombie/fx_tesla_rail_view_zmb";
49  level._effect["tesla_viewmodel_tube"] = "zombie/fx_tesla_tube_view_zmb";
50  level._effect["tesla_viewmodel_tube2"] = "zombie/fx_tesla_tube_view2_zmb";
51  level._effect["tesla_viewmodel_tube3"] = "zombie/fx_tesla_tube_view3_zmb";
52  level._effect["tesla_viewmodel_rail_upgraded"] = "zombie/fx_tesla_rail_view_ug_zmb";
53  level._effect["tesla_viewmodel_tube_upgraded"] = "zombie/fx_tesla_tube_view_ug_zmb";
54  level._effect["tesla_viewmodel_tube2_upgraded"] = "zombie/fx_tesla_tube_view2_ug_zmb";
55  level._effect["tesla_viewmodel_tube3_upgraded"] = "zombie/fx_tesla_tube_view3_ug_zmb";
56 
57  level._effect["tesla_shock_eyes"] = "zombie/fx_tesla_shock_eyes_zmb";
58 
61 
62  ‪zombie_utility::set_zombie_var( "tesla_max_arcs", 5 );
63  ‪zombie_utility::set_zombie_var( "tesla_max_enemies_killed", 10 );
64  ‪zombie_utility::set_zombie_var( "tesla_radius_start", 300 );
65  ‪zombie_utility::set_zombie_var( "tesla_radius_decay", 20 );
66  ‪zombie_utility::set_zombie_var( "tesla_head_gib_chance", 75 );
67  ‪zombie_utility::set_zombie_var( "tesla_arc_travel_time", 0.11, true );
68  ‪zombie_utility::set_zombie_var( "tesla_kills_for_powerup", 10 );
69  ‪zombie_utility::set_zombie_var( "tesla_min_fx_distance", 128 );
70  ‪zombie_utility::set_zombie_var( "tesla_network_death_choke",4 );
71 
72  level.tesla_lightning_params = ‪lightning_chain::create_lightning_chain_params( level.zombie_vars["tesla_max_arcs"],
73  level.zombie_vars["tesla_max_enemies_killed"],
74  level.zombie_vars["tesla_radius_start"],
75  level.zombie_vars["tesla_radius_decay"],
76  level.zombie_vars["tesla_head_gib_chance"],
77  level.zombie_vars["tesla_arc_travel_time"],
78  level.zombie_vars["tesla_kills_for_powerup"],
79  level.zombie_vars["tesla_min_fx_distance"],
80  level.zombie_vars["tesla_network_death_choke"],
81  undefined,
82  undefined,
83  "wpn_tesla_bounce" );
84 
85 
87 }
88 
89 
90 function ‪tesla_damage_init( hit_location, hit_origin, player )
91 {
92  player endon( "disconnect" );
93 
94  if ( ‪IS_TRUE( player.tesla_firing ) )
95  {
96  ‪zm_utility::debug_print( "TESLA: Player: '" + player.name + "' currently processing tesla damage" );
97  return;
98  }
99 
100  if( IsDefined( self.zombie_tesla_hit ) && self.zombie_tesla_hit )
101  {
102  // can happen if an enemy is marked for tesla death and player hits again with the tesla gun
103  return;
104  }
105 
106  ‪zm_utility::debug_print( "TESLA: Player: '" + player.name + "' hit with the tesla gun" );
107 
108  //TO DO Add Tesla Kill Dialog thread....
109 
110  player.tesla_enemies = undefined;
111  player.tesla_enemies_hit = 1;
112  player.tesla_powerup_dropped = false;
113  player.tesla_arc_count = 0;
114  player.tesla_firing = 1;
115 
116  self ‪lightning_chain::arc_damage( self, player, 1, level.tesla_lightning_params );
117 
118  if( player.tesla_enemies_hit >= 4)
119  {
120  player thread ‪tesla_killstreak_sound();
121  }
122 
123  player.tesla_enemies_hit = 0;
124  player.tesla_firing = 0;
125 }
126 
127 function ‪is_tesla_damage( mod, weapon )
128 {
129  return ( (weapon == level.weaponZMTeslaGun || weapon == level.weaponZMTeslaGunUpgraded ) && (mod == "MOD_PROJECTILE" || mod == "MOD_PROJECTILE_SPLASH" ));
130 }
131 
133 {
134  return ‪IS_TRUE( self.tesla_death );
135 }
136 
137 
139 {
140  self thread ‪tesla_sound_thread();
141  self thread ‪tesla_pvp_thread();
142  self thread ‪tesla_network_choke();
143 }
144 
145 
147 {
148  self endon( "disconnect" );
149 
150  for( ;; )
151  {
152  ‪result = self ‪util::waittill_any_return( "grenade_fire", "death", "player_downed", "weapon_change", "grenade_pullback", "disconnect" );
153 
154  if ( !IsDefined( ‪result ) )
155  {
156  continue;
157  }
158 
159  if( ( ‪result == "weapon_change" || ‪result == "grenade_fire" ) && (self GetCurrentWeapon() == level.weaponZMTeslaGun || self GetCurrentWeapon() == level.weaponZMTeslaGunUpgraded) )
160  {
161  if(!IsDefined (self.tesla_loop_sound))
162  {
163  self.tesla_loop_sound = ‪spawn("script_origin", self.origin);
164  self.tesla_loop_sound linkto(self);
165  self thread ‪cleanup_loop_sound( self.tesla_loop_sound );
166  }
167  self.tesla_loop_sound PlayLoopSound( "wpn_tesla_idle", 0.25 );
168  self thread ‪tesla_engine_sweets();
169 
170  }
171  else
172  {
173  self notify ("weap_away");
174  if(IsDefined (self.tesla_loop_sound))
175  {
176  self.tesla_loop_sound StopLoopSound(0.25);
177  }
178  }
179  }
180 }
181 
183 {
184  self waittill( "disconnect" );
185  if ( IsDefined(‪loop_sound) )
186  ‪loop_sound delete();
187 }
188 
189 
191 {
192 
193  self endon( "disconnect" );
194  self endon ("weap_away");
195  while(1)
196  {
197  wait(randomintrange(7,15));
198  self ‪play_tesla_sound ("wpn_tesla_sweeps_idle");
199  }
200 }
201 
203 {
204  self endon( "disconnect" );
205  self endon( "death" );
206 
207  for( ;; )
208  {
209  self waittill( "weapon_pvp_attack", attacker, weapon, ‪damage, mod );
210 
212  {
213  continue;
214  }
215 
216  if ( weapon != level.weaponZMTeslaGun && weapon != level.weaponZMTeslaGunUpgraded )
217  {
218  continue;
219  }
220 
221  if ( mod != "MOD_PROJECTILE" && mod != "MOD_PROJECTILE_SPLASH" )
222  {
223  continue;
224  }
225 
226  if ( self == attacker )
227  {
228  ‪damage = int( self.maxhealth * .25 );
229  if ( ‪damage < 25 )
230  {
231  ‪damage = 25;
232  }
233 
234  if ( self.health - ‪damage < 1 )
235  {
236  self.health = 1;
237  }
238  else
239  {
240  self.health -= ‪damage;
241  }
242  }
243 
244  self setelectrified( 1.0 );
245  self shellshock( "electrocution", 1.0 );
246  self playsound( "wpn_tesla_bounce" );
247  }
248 }
249 function ‪play_tesla_sound(emotion)
250 {
251  self endon( "disconnect" );
252 
253  if(!IsDefined (level.one_emo_at_a_time))
254  {
255  level.one_emo_at_a_time = 0;
256  level.var_counter = 0;
257  }
258  if(level.one_emo_at_a_time == 0)
259  {
260  level.var_counter ++;
261  level.one_emo_at_a_time = 1;
262  org = ‪spawn("script_origin", self.origin);
263  org LinkTo(self);
264  org PlaySoundWithNotify (emotion, "sound_complete"+ "_"+level.var_counter);
265  org waittill("sound_complete"+ "_"+level.var_counter);
266  org delete();
267  level.one_emo_at_a_time = 0;
268  }
269 }
270 
272 {
273  self endon( "disconnect" );
274 
275  //TUEY Play some dialog if you kick ass with the Tesla gun
276 
277  self ‪zm_audio::create_and_play_dialog( "kill", "tesla" );
278  wait(3.5);
279  level ‪util::clientNotify("TGH");
280 }
281 
282 
284 {
285  self endon( "disconnect" );
286  self endon( "death" );
287 
288  self.tesla_network_death_choke = 0;
289 
290  for ( ;; )
291  {
294  self.tesla_network_death_choke = 0;
295  }
296 }
297 
299 {
300  if( self ‪enemy_killed_by_tesla() )
301  {
302  return true;
303  }
304 
305  return false;
306 }
307 
308 //mod, hit_location, hit_origin, player, amount, weapon
309 function ‪tesla_zombie_damage_response( willBeKilled, inflictor, attacker, ‪damage, flags, meansofdeath, weapon, vpoint, vdir, sHitLoc, psOffsetTime, boneIndex, surfaceType )
310 {
311  if( self ‪is_tesla_damage( meansofdeath, weapon ) )
312  {
313  self thread ‪tesla_damage_init( sHitLoc, vpoint, attacker );
314  return true;
315  }
316  return false;
317 }
‪tesla_killstreak_sound
‪function tesla_killstreak_sound()
Definition: _zm_weap_tesla.gsc:271
‪enemy_killed_by_tesla
‪function enemy_killed_by_tesla()
Definition: _zm_weap_tesla.gsc:132
‪register_zombie_damage_override_callback
‪function register_zombie_damage_override_callback(func)
Definition: _zm.gsc:5865
‪arc_damage
‪function arc_damage(source_enemy, player, arc_num, params=level.default_lightning_chain_params)
Definition: _zm_lightning_chain.gsc:120
‪tesla_sound_thread
‪function tesla_sound_thread()
Definition: _zm_weap_tesla.gsc:146
‪waittill_any_return
‪function waittill_any_return(string1, string2, string3, string4, string5, string6, string7)
Definition: util_shared.csc:212
‪set_zombie_var
‪function set_zombie_var(zvar, value, is_float=false, column=1, is_team_based=false)
Definition: zombie_utility.gsc:1434
‪play_tesla_sound
‪function play_tesla_sound(emotion)
Definition: _zm_weap_tesla.gsc:249
‪debug_print
‪function debug_print(str_line)
Definition: _zm_daily_challenges.gsc:402
‪on_player_spawned
‪function on_player_spawned()
Definition: _zm_weap_tesla.gsc:138
‪register_zombie_death_animscript_callback
‪function register_zombie_death_animscript_callback(func)
Definition: _zm_spawner.gsc:1841
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪is_weapon_included
‪function is_weapon_included(weapon)
Definition: _zm_weapons.csc:51
‪damage
‪function damage(trap)
Definition: _zm_trap_electric.gsc:116
‪loop_sound
‪function loop_sound(alias, interval)
Definition: _supplydrop.gsc:2040
‪on_spawned
‪function on_spawned(func, obj)
Definition: callbacks_shared.csc:245
‪wait_network_frame
‪function wait_network_frame(n_count=1)
Definition: util_shared.gsc:64
‪tesla_engine_sweets
‪function tesla_engine_sweets()
Definition: _zm_weap_tesla.gsc:190
‪init
‪function init()
Definition: _zm_weap_tesla.gsc:39
‪tesla_network_choke
‪function tesla_network_choke()
Definition: _zm_weap_tesla.gsc:283
‪create_lightning_chain_params
‪function create_lightning_chain_params(max_arcs=5, max_enemies_killed=10, radius_start=300, radius_decay=20, head_gib_chance=75, arc_travel_time=0.11, kills_for_powerup=10, min_fx_distance=128, network_death_choke=4, should_kill_enemies=true, clientside_fx=true, arc_fx_sound=undefined, no_fx=false, prevent_weapon_kill_credit=false)
Definition: _zm_lightning_chain.gsc:68
‪tesla_zombie_damage_response
‪function tesla_zombie_damage_response(willBeKilled, inflictor, attacker, damage, flags, meansofdeath, weapon, vpoint, vdir, sHitLoc, psOffsetTime, boneIndex, surfaceType)
Definition: _zm_weap_tesla.gsc:309
‪clientNotify
‪function clientNotify(event)
Definition: util_shared.gsc:1416
‪tesla_damage_init
‪function tesla_damage_init(hit_location, hit_origin, player)
Definition: _zm_weap_tesla.gsc:90
‪player_is_in_laststand
‪function player_is_in_laststand()
Definition: laststand_shared.gsc:18
‪create_and_play_dialog
‪function create_and_play_dialog(category, subcategory, force_variant)
Definition: _zm_audio.gsc:603
‪result
‪function result(death, attacker, mod, weapon)
Definition: _zm_aat_blast_furnace.gsc:46
‪cleanup_loop_sound
‪function cleanup_loop_sound(loop_sound)
Definition: _zm_weap_tesla.gsc:182
‪tesla_pvp_thread
‪function tesla_pvp_thread()
Definition: _zm_weap_tesla.gsc:202
‪tesla_zombie_death_response
‪function tesla_zombie_death_response()
Definition: _zm_weap_tesla.gsc:298
‪is_tesla_damage
‪function is_tesla_damage(mod, weapon)
Definition: _zm_weap_tesla.gsc:127