‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_gravity_spikes.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\audio_shared;
4 #using scripts\shared\callbacks_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\system_shared;
7 #using scripts\shared\util_shared;
8 #using scripts\shared\_explode;
9 
10 #insert scripts\shared\shared.gsh;
11 #insert scripts\shared\version.gsh;
12 
13 #define GRAVITY_SPIKES_DIRT_DURATION 1000
14 #define GRAVITY_SPIKES_DIRT_FADE_TIME 500
15 
16 #precache( "client_fx", "weapon/fx_hero_grvity_spk_grnd_hit_dust" );
17 
18 #namespace gravity_spikes;
19 
20 ‪REGISTER_SYSTEM( "gravity_spikes", &‪__init__, undefined )
21 
22 function ‪__init__()
23 {
24  level._effect["gravity_spike_dust"] = "weapon/fx_hero_grvity_spk_grnd_hit_dust";
25  level.gravity_spike_table = "surface_explosion_gravityspikes";
26 
27  level thread ‪watchForGravitySpikeExplosion();
28 
29  level.dirt_enable_gravity_spikes = GetDvarInt( "scr_dirt_enable_gravity_spikes", 0 );
30 }
31 
33 {
34  if ( GetActiveLocalClients() > 1 )
35  return;
36 
37  weapon_proximity = GetWeapon( "hero_gravityspikes" );
38 
39  while ( true )
40  {
41  level waittill( "explode", localClientNum, position, mod, weapon, owner_cent );
42 
43  if ( weapon.rootWeapon != weapon_proximity )
44  {
45  continue;
46  }
47 
48  if( isdefined(owner_cent) && ( GetLocalPlayer( localClientNum ) == owner_cent ) && level.dirt_enable_gravity_spikes )
49  {
50  owner_cent thread explode::dothedirty( localClientNum, 0, 1.0, 0, ‪GRAVITY_SPIKES_DIRT_DURATION, ‪GRAVITY_SPIKES_DIRT_FADE_TIME );
51  }
52 
53  thread ‪do_gravity_spike_fx( localClientNum, owner_cent, weapon, position );
54  thread ‪audio::doRattle(position,200,700);
55  }
56 }
57 
58 function ‪do_gravity_spike_fx( localClientNum, owner, weapon, position )
59 {
60  // this value will bring in the outermost circle so the effects don't spawn
61  // right on the outer edge of the explosion
62  radius_of_effect = 40;
63 
64  number_of_circles = 3;
65  base_number_of_effects = 3;
66  additional_number_of_effects_per_circle = 7;
67 
68  explosion_radius = weapon.explosionRadius;
69  radius_per_circle = ( explosion_radius - radius_of_effect ) / number_of_circles;
70 
71  for ( circle = 0; circle < number_of_circles; circle++ )
72  {
73  wait( 0.1 );
74  radius_for_this_circle = radius_per_circle * (circle + 1);
75  number_for_this_circle = base_number_of_effects + (additional_number_of_effects_per_circle * circle);
76  thread ‪do_gravity_spike_fx_circle( localClientNum, owner, position, radius_for_this_circle, number_for_this_circle );
77  }
78 }
79 
80 function ‪getIdealLocationForFX( startPos, fxIndex, fxCount, defaultDistance, rotation )
81 {
82  currentAngle = ( ( 360 / fxCount ) * fxIndex );
83  cosCurrent = cos( currentAngle + rotation );
84  sinCurrent = sin( currentAngle + rotation );
85 
86  return startPos + ( defaultDistance * cosCurrent, defaultDistance * sinCurrent, 0 );
87 }
88 
89 function ‪randomizeLocation( startPos, max_x_offset, max_y_offset )
90 {
91  half_x = int(max_x_offset / 2);
92  half_y = int(max_y_offset / 2);
93  rand_x = RandomIntRange( -half_x, half_x );
94  rand_y = RandomIntRange( -half_y, half_y );
95 
96  return startPos + ( rand_x, rand_y, 0 );
97 }
98 
99 function ‪ground_trace( startPos, owner )
100 {
101  trace_height = 50;
102  trace_depth = 100;
103 
104  return bullettrace( startPos + ( 0,0,trace_height ), startPos - ( 0,0,trace_depth ), false, owner );
105 }
106 
107 
108 function ‪do_gravity_spike_fx_circle( localClientNum, owner, center, radius, count )
109 {
110  segment = 360 / count;
111  up = ( 0,0,1 );
112 
113  randomization = 40;
114  sphere_size = 5;
115 
116  for ( i = 0; i < count; i++ )
117  {
118  fx_position = ‪getIdealLocationForFX( center, i, count, radius, 0 );
119  fx_position = ‪randomizeLocation( fx_position, randomization, randomization );
120 
121  ‪trace = ‪ground_trace( fx_position, owner );
122 
123  if ( ‪trace["fraction"] < 1.0 )
124  {
125  fx = GetFXFromSurfaceTable( level.gravity_spike_table, ‪trace["surfacetype"] );
126 
127  if ( isdefined( fx ) )
128  {
129  angles = ( 0, RandomIntRange(0,359), 0 );
130  forward = AnglesToForward( angles );
131 
132  normal = ‪trace["normal"];
133  if ( LengthSquared( normal ) == 0 )
134  {
135  normal = ( 1, 0, 0);
136  }
137  ‪PlayFx( localClientNum, fx, ‪trace["position"], normal, forward );
138  }
139  }
140 
142  }
143 }
144 
‪watchForGravitySpikeExplosion
‪function watchForGravitySpikeExplosion()
Definition: _gravity_spikes.csc:32
‪ground_trace
‪function ground_trace(startPos, owner)
Definition: _gravity_spikes.csc:99
‪doRattle
‪function doRattle(origin, min, max)
Definition: audio_shared.csc:1237
‪__init__
‪function __init__()
Definition: _gravity_spikes.csc:22
‪trace
‪function trace(from, to, target)
Definition: grapple.gsc:369
‪do_gravity_spike_fx
‪function do_gravity_spike_fx(localClientNum, owner, weapon, position)
Definition: _gravity_spikes.csc:58
‪GRAVITY_SPIKES_DIRT_FADE_TIME
‪#define GRAVITY_SPIKES_DIRT_FADE_TIME
Definition: _gravity_spikes.csc:14
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪GRAVITY_SPIKES_DIRT_DURATION
‪#define GRAVITY_SPIKES_DIRT_DURATION
Definition: _gravity_spikes.csc:13
‪do_gravity_spike_fx_circle
‪function do_gravity_spike_fx_circle(localClientNum, owner, center, radius, count)
Definition: _gravity_spikes.csc:108
‪getIdealLocationForFX
‪function getIdealLocationForFX(startPos, fxIndex, fxCount, defaultDistance, rotation)
Definition: _gravity_spikes.csc:80
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪randomizeLocation
‪function randomizeLocation(startPos, max_x_offset, max_y_offset)
Definition: _gravity_spikes.csc:89
‪PlayFx
‪function PlayFx(name)
Definition: _counteruav.gsc:390