‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_aat_fire_works.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\aat_shared;
4 #using scripts\shared\array_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\flag_shared;
7 #using scripts\shared\math_shared;
8 #using scripts\shared\system_shared;
9 #using scripts\shared\util_shared;
10 #using scripts\shared\ai\systems\gib;
11 #using scripts\zm\_zm_spawner;
12 
13 #insert scripts\shared\aat_zm.gsh;
14 #insert scripts\shared\shared.gsh;
15 #insert scripts\shared\version.gsh;
16 
17 #using scripts\zm\_zm_stats;
18 #using scripts\zm\_zm_utility;
19 
20 #insert scripts\zm\aats\_zm_aat_fire_works.gsh;
21 
22 #insert scripts\zm\_zm_utility.gsh;
23 
24 #precache( "material", ZM_AAT_FIRE_WORKS_DAMAGE_FEEDBACK_ICON );
25 
26 #namespace zm_aat_fire_works;
27 
29 
30 function ‪__init__()
31 {
32  if ( !‪IS_TRUE( level.aat_in_use ) )
33  {
34  return;
35  }
36 
39 
41 
44 }
45 
46 function ‪result( ‪death, attacker, mod, weapon )
47 {
48  self ‪fire_works_summon( attacker, weapon );
49 }
50 
51 // Checks to see if fire works is running
52 // self == zombie
54 {
55  if( ‪IS_TRUE( self.barricade_enter ) )
56  {
57  return false;
58  }
59 
60  if ( ‪IS_TRUE( self.is_traversing ) )
61  {
62  return false;
63  }
64 
65  if( !‪IS_TRUE( self.completed_emerging_into_playable_area ) && !IsDefined( self.first_node ) )
66  {
67  return false;
68  }
69 
70  if ( ‪IS_TRUE( self.is_leaping ) )
71  {
72  return false;
73  }
74 
75  return true;
76 }
77 
78 // Summons the player's current gun to pop up and fire in a circle for a period of time
79 // immune_result_direct == target is immune to death gib
80 // immune_result_indirect == target is immune to death gib on hit from the magic bullet
81 // self == target zombie
82 function ‪fire_works_summon( e_player, w_weapon )
83 {
84  w_summoned_weapon = e_player GetCurrentWeapon();
85  v_target_zombie_origin = self.origin;
86 
87  // Checks if self is immune_result_direct == true. If so, do not kill self
88  if ( !‪IS_TRUE( level.aat[ ‪ZM_AAT_FIRE_WORKS_NAME ].immune_result_direct[ self.archetype ] ) )
89  {
90  self thread ‪zombie_death_gib( e_player, w_weapon, e_player );
91  }
92 
93  // Spawns base model
94  v_firing_pos = v_target_zombie_origin + ‪ZM_AAT_FIRE_WORKS_ZOMBIE_GUN_HEIGHT;
95  v_start_yaw = VectorToAngles( v_firing_pos - v_target_zombie_origin );
96  v_start_yaw = (0, v_start_yaw[1], 0);
97  mdl_weapon = ‪zm_utility::spawn_weapon_model( w_summoned_weapon, undefined, v_target_zombie_origin, v_start_yaw );
98 
99  // Stat tracking definitions
100  mdl_weapon.owner = e_player;
101  mdl_weapon.b_aat_fire_works_weapon = true;
102  mdl_weapon.allow_zombie_to_target_ai = true; // lets the zombie damage callbacks pass through damage from this
103 
104  // Fires FX
105  mdl_weapon thread ‪clientfield::set( ‪ZM_AAT_FIRE_WORKS_NAME, 1 );
106 
107  // Moves weapon upwards to firing position
108  mdl_weapon MoveTo( v_firing_pos, ‪ZM_AAT_FIRE_WORKS_SUMMON_TIME );
109  mdl_weapon waittill( "movedone" );
110 
111  // Starts firing
112  for ( i = 0; i < ‪ZM_AAT_FIRE_WORKS_FIRING_NUM_FRAMES; i++ )
113  {
114  zombie = mdl_weapon ‪zm_aat_fire_works_get_target();
115  if ( !IsDefined( zombie ) )
116  {
117  //if no target available, just pick a random yaw
118  v_curr_yaw = (0, RandomIntRange( 0, 360 ), 0);
119  v_target_pos = mdl_weapon.origin + VectorScale( AnglesToForward( v_curr_yaw ), 40 );
120  }
121  else
122  {
123  v_target_pos = zombie GetCentroid();
124  }
125 
126  mdl_weapon.angles = VectorToAngles( v_target_pos - mdl_weapon.origin );
127  v_flash_pos = mdl_weapon GetTagOrigin( "tag_flash" );
128  mdl_weapon DontInterpolate();
129 
130  // MagicBullet shots are credited to the model rather than player, as MagicBullet causes recoil on player
131  MagicBullet( w_summoned_weapon, v_flash_pos, v_target_pos, mdl_weapon );
132 
134  }
135 
136  mdl_weapon MoveTo( v_target_zombie_origin, ‪ZM_AAT_FIRE_WORKS_SUMMON_TIME );
137  mdl_weapon waittill( "movedone" );
138 
140 
141  ‪util::wait_network_frame(); // Waits for FX to complete
142  ‪util::wait_network_frame(); // extra waits for theater playback
143  ‪util::wait_network_frame(); // extra waits for theater playback
144 
145  mdl_weapon Delete();
146  wait .25; // Delay for final projectile-based gun shots to finish firing
147 }
148 
149 // Death callback for zombies killed by summoned Fire Works weapon
151 {
152  a_ai_zombies = array::randomize( GetAiTeamArray( "axis" ) );
153 
154  los_checks = 0;
155  for ( i = 0; i < a_ai_zombies.size; i++ )
156  {
157  zombie = a_ai_zombies[i];
158  test_origin = zombie getcentroid();
159  if ( DistanceSquared( self.origin, test_origin ) > ‪ZM_AAT_FIRE_WORKS_RANGE_SQ )
160  {
161  continue;
162  }
163 
164  if ( los_checks < ‪ZM_AAT_FIRE_WORKS_MAX_LOS_CHECKS && !zombie DamageConeTrace( self.origin ) )
165  {
166  los_checks++;
167  continue;
168  }
169 
170  return zombie;
171  }
172 
173  if ( a_ai_zombies.size )
174  {
175  // just return the first one, so that we at least change direction
176  return a_ai_zombies[0];
177  }
178 
179  return undefined;
180 }
181 
182 // self is a zombie
183 function ‪zm_aat_fire_works_zombie_damage_response( str_mod, str_hit_location, v_hit_origin, e_attacker, n_amount, w_weapon, direction_vec, tagName, modelName, partName, dFlags, inflictor, chargeLevel )
184 {
185  if ( ‪IS_TRUE( level.aat[ ‪ZM_AAT_FIRE_WORKS_NAME ].immune_result_indirect[ self.archetype ] ) )
186  {
187  return false;
188  }
189 
190  if ( ‪IS_TRUE( e_attacker.b_aat_fire_works_weapon ) )
191  {
192  self thread ‪zombie_death_gib( e_attacker, w_weapon, e_attacker.owner );
193  return true;
194  }
195 
196  return false;
197 }
198 
199 // Death callback for zombies killed by summoned Fire Works weapon
201 {
202  if ( isdefined( attacker ) )
203  {
204  if ( ‪IS_TRUE( attacker.b_aat_fire_works_weapon ) )
205  {
206  // Checks if player has disconnected
207  if ( isdefined( attacker.owner ) )
208  {
209  e_attacking_player = attacker.owner;
210  // TODO set up stat tracking
211  }
212  }
213  }
214 }
215 
216 // Gibs and Kills zombie
217 // self == affected zombie
218 // e_attacker == the script_model of the gun (needs to do the damage, so the player doesn't receive kickback)
219 // w_weapon == the weapon to apply damage using
220 // e_owner == the owner of the gun (for awarding challenge stat progress)
221 function ‪zombie_death_gib( e_attacker, w_weapon, e_owner )
222 {
223  gibserverutils::gibhead( self );
224 
225  if ( ‪math::cointoss() )
226  {
227  gibserverutils::gibleftarm( self );
228  }
229  else
230  {
231  gibserverutils::gibrightarm( self );
232  }
233 
234  gibserverutils::giblegs( self );
235 
236  self DoDamage( self.health, self.origin, e_attacker, w_weapon, "torso_upper" );
237 
238  if ( IsDefined( e_owner ) && IsPlayer( e_owner ) )
239  {
240  e_owner ‪zm_stats::increment_challenge_stat( "ZOMBIE_HUNTER_FIRE_WORKS" );
241  }
242 }
‪zombie_death_gib
‪function zombie_death_gib(e_attacker, w_weapon, e_owner)
Definition: _zm_aat_fire_works.gsc:221
‪death
‪function death(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _ai_tank.csc:134
‪__init__
‪function __init__()
Definition: _zm_aat_fire_works.gsc:30
‪ZM_AAT_FIRE_WORKS_MAX_LOS_CHECKS
‪#define ZM_AAT_FIRE_WORKS_MAX_LOS_CHECKS
Definition: _zm_aat_fire_works.gsh:18
‪zm_aat_fire_works_death_callback
‪function zm_aat_fire_works_death_callback(attacker)
Definition: _zm_aat_fire_works.gsc:200
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪cointoss
‪function cointoss()
Definition: math_shared.csc:171
‪zm_aat_fire_works_zombie_damage_response
‪function zm_aat_fire_works_zombie_damage_response(str_mod, str_hit_location, v_hit_origin, e_attacker, n_amount, w_weapon, direction_vec, tagName, modelName, partName, dFlags, inflictor, chargeLevel)
Definition: _zm_aat_fire_works.gsc:183
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪register_zombie_death_event_callback
‪function register_zombie_death_event_callback(func)
Definition: _zm_spawner.gsc:2463
‪increment_challenge_stat
‪function increment_challenge_stat(stat_name, amount=1)
Definition: _zm_stats.gsc:478
‪ZM_AAT_FIRE_WORKS_SUMMON_TIME
‪#define ZM_AAT_FIRE_WORKS_SUMMON_TIME
Definition: _zm_aat_fire_works.gsh:15
‪wait_network_frame
‪function wait_network_frame(n_count=1)
Definition: util_shared.gsc:64
‪ZM_AAT_FIRE_WORKS_COOLDOWN_ENTITY
‪#define ZM_AAT_FIRE_WORKS_COOLDOWN_ENTITY
Definition: _zm_aat_fire_works.gsh:6
‪ZM_AAT_FIRE_WORKS_RANGE_SQ
‪#define ZM_AAT_FIRE_WORKS_RANGE_SQ
Definition: _zm_aat_fire_works.gsh:17
‪ZM_AAT_FIRE_WORKS_FIRING_NUM_FRAMES
‪#define ZM_AAT_FIRE_WORKS_FIRING_NUM_FRAMES
Definition: _zm_aat_fire_works.gsh:19
‪ZM_AAT_FIRE_WORKS_DAMAGE_FEEDBACK_SOUND
‪#define ZM_AAT_FIRE_WORKS_DAMAGE_FEEDBACK_SOUND
Definition: _zm_aat_fire_works.gsh:11
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪register_zombie_damage_callback
‪function register_zombie_damage_callback(func)
Definition: _zm_spawner.gsc:2114
‪ZM_AAT_FIRE_WORKS_COOLDOWN_GLOBAL
‪#define ZM_AAT_FIRE_WORKS_COOLDOWN_GLOBAL
Definition: _zm_aat_fire_works.gsh:8
‪zm_aat_fire_works_get_target
‪function zm_aat_fire_works_get_target()
Definition: _zm_aat_fire_works.gsc:150
‪ZM_AAT_FIRE_WORKS_COOLDOWN_ATTACKER
‪#define ZM_AAT_FIRE_WORKS_COOLDOWN_ATTACKER
Definition: _zm_aat_fire_works.gsh:7
‪set
‪function set(str_field_name, n_value)
Definition: clientfield_shared.gsc:34
‪fire_works_zombie_validation
‪function fire_works_zombie_validation()
Definition: _zm_aat_fire_works.gsc:53
‪ZM_AAT_FIRE_WORKS_ZOMBIE_GUN_HEIGHT
‪#define ZM_AAT_FIRE_WORKS_ZOMBIE_GUN_HEIGHT
Definition: _zm_aat_fire_works.gsh:20
‪ZM_AAT_FIRE_WORKS_DAMAGE_FEEDBACK_ICON
‪#define ZM_AAT_FIRE_WORKS_DAMAGE_FEEDBACK_ICON
Definition: _zm_aat_fire_works.gsh:10
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪fire_works_summon
‪function fire_works_summon(e_player, w_weapon)
Definition: _zm_aat_fire_works.gsc:82
‪result
‪function result(death, attacker, mod, weapon)
Definition: _zm_aat_fire_works.gsc:46
‪ZM_AAT_FIRE_WORKS_PERCENTAGE
‪#define ZM_AAT_FIRE_WORKS_PERCENTAGE
Definition: _zm_aat_fire_works.gsh:5
‪ZM_AAT_FIRE_WORKS_NAME
‪#define ZM_AAT_FIRE_WORKS_NAME
Definition: aat_zm.gsh:6
‪spawn_weapon_model
‪function spawn_weapon_model(localClientNum, origin, angles)
Definition: _weapon_customization_icon.csc:141
‪ZM_AAT_FIRE_WORKS_OCCURS_ON_DEATH
‪#define ZM_AAT_FIRE_WORKS_OCCURS_ON_DEATH
Definition: _zm_aat_fire_works.gsh:9