1 #using scripts\codescripts\struct;
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\util_shared;
6 #using scripts\shared\system_shared;
8 #insert scripts\shared\shared.gsh;
9 #insert scripts\shared\version.gsh;
11 #namespace flashgrenades;
15 level.sound_flash_start =
"";
16 level.sound_flash_loop =
"";
17 level.sound_flash_stop =
"";
24 self endon(
"stop_monitoring_flash");
26 self endon(
"flash_rumble_loop");
27 self notify(
"flash_rumble_loop");
29 goalTime = getTime() + duration * 1000;
31 while ( getTime() < goalTime )
33 self PlayRumbleOnEntity(
"damage_heavy" );
57 duration = amount_distance * 3.5;
61 max_self_duration = 2.5;
63 if ( duration < min_duration )
65 duration = min_duration;
68 if ( isdefined( attacker ) && (attacker ==
self) )
70 duration = duration/3;
73 if ( duration < 0.25 )
78 rumbleduration = undefined;
82 rumbleduration = 0.75;
86 rumbleduration = 0.25;
89 assert(isdefined(
self.team));
91 if (level.teamBased && isdefined(attacker) && isdefined(attacker.team) && attacker.team ==
self.team && attacker !=
self)
93 friendlyfire = [[ level.figure_out_friendly_fire]]( self );
95 if ( friendlyfire == 0 )
99 else if ( friendlyfire == 1 )
102 else if ( friendlyfire == 2)
104 duration = duration * .5;
105 rumbleduration = rumbleduration * .5;
109 else if ( friendlyfire == 3 )
111 duration = duration * .5;
112 rumbleduration = rumbleduration * .5;
117 if (
self hasPerk (
"specialty_flashprotection") )
121 rumbleduration *= 0.1;
129 if( isDefined(attacker) &&
self != attacker &&isPlayer(attacker) )
131 attacker AddWeaponStat( GetWeapon(
"flash_grenade" ),
"hits", 1 );
132 attacker AddWeaponStat( GetWeapon(
"flash_grenade" ),
"used", 1 );
134 self thread
applyFlash(duration, rumbleduration, attacker);
142 attacker thread
applyFlash(duration, rumbleduration, attacker);
148 self endon(
"disconnect");
149 self endon (
"killFlashMonitor");
151 self.flashEndTime = 0;
154 self waittill(
"flashbang", amount_distance, amount_angle, attacker );
156 if ( !isalive(
self ) )
168 self.flashEndTime = 0;
171 self waittill(
"flashbang", amount_distance, amount_angle, attacker );
173 driver =
self getseatoccupant(0);
175 if ( !isdefined(driver) || !isalive( driver ) )
189 if (!isdefined(
self.flashDuration) || duration >
self.flashDuration)
191 self.flashDuration = duration;
194 if (!isdefined(
self.flashRumbleDuration) || rumbleduration >
self.flashRumbleDuration)
196 self.flashRumbleDuration = rumbleduration;
203 if (isdefined(
self.flashDuration))
205 if (
self hasPerk (
"specialty_flashprotection") ==
false )
207 self shellshock(
"flashbang",
self.flashDuration,
false );
209 self.flashEndTime = getTime() + (
self.flashDuration * 1000);
210 self.lastFlashedBy = attacker;
213 if (isdefined(
self.flashRumbleDuration)) {
217 self.flashDuration = undefined;
218 self.flashRumbleDuration = undefined;
223 self endon(
"death" );
224 self endon(
"disconnect" );
226 flashSound =
spawn (
"script_origin",(0,0,1));
227 flashSound.origin =
self.origin;
228 flashSound linkTo(
self );
231 flashSound playsound( level.sound_flash_start );
232 flashSound playLoopSound ( level.sound_flash_loop );
233 if ( duration > 0.5 )
234 wait( duration - 0.5 );
235 flashSound playsound( level.sound_flash_start );
236 flashSound StopLoopSound( .5);
239 flashSound notify (
"delete" );
245 self endon(
"delete" );
246 owner waittill(
"death" );