‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_smokegrenade.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\challenges_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\damagefeedback_shared;
7 #using scripts\shared\math_shared;
8 #using scripts\shared\scoreevents_shared;
9 #using scripts\shared\sound_shared;
10 #using scripts\shared\system_shared;
11 #using scripts\shared\util_shared;
12 #using scripts\shared\weapons\_tacticalinsertion;
13 #using scripts\shared\weapons\_weaponobjects;
14 
15 #insert scripts\shared\shared.gsh;
16 #insert scripts\shared\version.gsh;
17 
18 #namespace smokegrenade;
19 
20 #define SMOKE_GRENADE_RADIUS 128
21 
22 function ‪init_shared()
23 {
24  level.willyPeteDamageRadius = 300;
25  level.willyPeteDamageHeight = 128;
26  level.smokeGrenadeDuration = 8;
27  level.smokeGrenadeDissipation = 4;
28  level.smokeGrenadeTotalTime = level.smokeGrenadeDuration + level.smokeGrenadeDissipation;
29  level.fx_smokegrenade_single = "smoke_center";
30  level.smoke_grenade_triggers = [];
31 
33 }
34 
35 function ‪watchSmokeGrenadeDetonation( owner, statWeapon, grenadeWeaponName, duration, totalTime )
36 {
37  self endon( "trophy_destroyed" );
38 
39  owner AddWeaponStat( statWeapon, "used", 1 );
40 
41  self waittill( "explode", position, surface );
42 
43  oneFoot = ( 0, 0, 12 );
44  startPos = position + oneFoot;
45 
46  smokeWeapon = GetWeapon( grenadeWeaponName );
47  ‪smokeDetonate( owner, statWeapon, smokeWeapon, position, ‪SMOKE_GRENADE_RADIUS, totalTime, duration );
48 
49  // do a little damage because it's white phosphorous, we want to control it here instead of the gdt entry
50  ‪damageEffectArea ( owner, startPos, smokeWeapon.explosionRadius, level.willyPeteDamageHeight, undefined );
51 }
52 
53 // Spawn FX and sight blocking volumes
54 function ‪smokeDetonate( owner, statWeapon, smokeWeapon, position, radius, effectLifetime, smokeBlockDuration )
55 {
56  dir_up = (0.0, 0.0, 1.0);
57  ent = SpawnTimedFX( smokeWeapon, position, dir_up, effectLifetime );
58 
59  ent SetTeam( owner.team );
60  ent SetOwner( owner );
61 
62  ent thread ‪smokeBlockSight( radius );
63  ent thread ‪spawnSmokeGrenadeTrigger( smokeBlockDuration );
64 
65  if ( isdefined ( owner ) )
66  {
67  owner.smokeGrenadeTime = getTime();
68  owner.smokeGrenadePosition = position;
69  }
70 
71  thread ‪playSmokeSound( position, smokeBlockDuration, statWeapon.projSmokeStartSound, statWeapon.projSmokeEndSound, statWeapon.projSmokeLoopSound );
72 
73  return ent;
74 }
75 
76 function ‪damageEffectArea ( owner, position, radius, height, killCamEnt )
77 {
78  // spawn trigger radius for the effect areas
79  effectArea = ‪spawn( "trigger_radius", position, 0, radius, height );
80 
81  // dog stuff
82  if ( isdefined( level.dogsOnFlashDogs ) )
83  {
84  owner thread [[level.dogsOnFlashDogs]]( effectArea );
85  }
86 
87  // clean up
88  effectArea delete();
89 }
90 
91 function ‪smokeBlockSight( radius )
92 {
93  self endon( "death" );
94 
95  while( true )
96  {
97  FxBlockSight( self, radius );
98 
99  /#
100  if( GetDvarInt( "scr_smokegrenade_debug", 0 ) )
101  {
102  Sphere( self.origin, ‪SMOKE_GRENADE_RADIUS, (1,0,0), 0.25, false, 10, 15 );
103  }
104  #/
105 
106  wait( 0.75 );
107  }
108 }
109 
110 function ‪spawnSmokeGrenadeTrigger( duration )
111 {
112  team = self.team;
113 
114  trigger = ‪spawn( "trigger_radius", self.origin, 0, ‪SMOKE_GRENADE_RADIUS, ‪SMOKE_GRENADE_RADIUS );
115 
116  ‪ARRAY_ADD( level.smoke_grenade_triggers, trigger );
117  self ‪util::waittill_any_timeout( duration, "death" );
118  ArrayRemoveValue( level.smoke_grenade_triggers, trigger );
119 
120  trigger delete();
121 }
122 
124 {
125  foreach( trigger in level.smoke_grenade_triggers )
126  {
127  if( self IsTouching( trigger ) )
128  {
129  return true;
130  }
131  }
132 
133  return false;
134 }
135 
137 {
138  self endon("disconnect");
139 
140  self thread ‪begin_other_grenade_tracking();
141 }
142 
144 {
145  self endon( "death" );
146  self endon( "disconnect" );
147 
148  self notify( "smokeTrackingStart" );
149  self endon( "smokeTrackingStart" );
150 
151  weapon_smoke = GetWeapon( "willy_pete" );
152 
153  for (;;)
154  {
155  self waittill ( "grenade_fire", grenade, weapon, cookTime );
156 
157  if ( grenade ‪util::isHacked() )
158  {
159  continue;
160  }
161 
162  if ( weapon.rootWeapon == weapon_smoke )
163  {
164  grenade thread ‪watchSmokeGrenadeDetonation( self, weapon_smoke, level.fx_smokegrenade_single, level.smokeGrenadeDuration, level.smokeGrenadeTotalTime );
165  }
166  }
167 }
168 
169 function ‪playSmokeSound( position, duration, startSound, stopSound, loopSound )
170 {
171  smokeSound = ‪spawn ("script_origin",(0,0,1));
172  smokeSound.origin = position;
173  if( isDefined( startSound ) )
174  {
175  smokeSound playsound( startSound );
176  }
177 
178  if( isDefined( loopSound ) )
179  {
180  smokeSound playLoopSound ( loopSound );
181  }
182 
183  if ( duration > 0.5 )
184  wait( duration - 0.5 );
185 
186  if( isDefined( stopSound ) )
187  {
188  thread ‪sound::play_in_space( stopSound, position );
189  }
190  smokeSound StopLoopSound( .5);
191  wait(.5);
192  smokeSound delete();
193 }
‪smokeDetonate
‪function smokeDetonate(owner, statWeapon, smokeWeapon, position, radius, effectLifetime, smokeBlockDuration)
Definition: _smokegrenade.gsc:54
‪SMOKE_GRENADE_RADIUS
‪#define SMOKE_GRENADE_RADIUS
Definition: _smokegrenade.gsc:20
‪play_in_space
‪function play_in_space(localClientNum, alias, origin)
Definition: sound_shared.csc:30
‪on_player_spawned
‪function on_player_spawned()
Definition: _smokegrenade.gsc:136
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪waittill_any_timeout
‪function waittill_any_timeout(n_timeout, string1, string2, string3, string4, string5)
Definition: util_shared.csc:423
‪playSmokeSound
‪function playSmokeSound(position, duration, startSound, stopSound, loopSound)
Definition: _smokegrenade.gsc:169
‪smokeBlockSight
‪function smokeBlockSight(radius)
Definition: _smokegrenade.gsc:91
‪on_spawned
‪function on_spawned(func, obj)
Definition: callbacks_shared.csc:245
‪ARRAY_ADD
‪#define ARRAY_ADD(__array, __item)
Definition: shared.gsh:304
‪damageEffectArea
‪function damageEffectArea(owner, position, radius, height, killCamEnt)
Definition: _smokegrenade.gsc:76
‪watchSmokeGrenadeDetonation
‪function watchSmokeGrenadeDetonation(owner, statWeapon, grenadeWeaponName, duration, totalTime)
Definition: _smokegrenade.gsc:35
‪isHacked
‪function isHacked()
Definition: util_shared.gsc:2493
‪spawnSmokeGrenadeTrigger
‪function spawnSmokeGrenadeTrigger(duration)
Definition: _smokegrenade.gsc:110
‪IsInSmokeGrenade
‪function IsInSmokeGrenade()
Definition: _smokegrenade.gsc:123
‪init_shared
‪function init_shared()
Definition: _smokegrenade.gsc:22
‪begin_other_grenade_tracking
‪function begin_other_grenade_tracking()
Definition: _smokegrenade.gsc:143