1 #using scripts\codescripts\struct;
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\challenges_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\flagsys_shared;
7 #using scripts\shared\killcam_shared;
8 #using scripts\shared\player_shared;
9 #using scripts\shared\scoreevents_shared;
10 #using scripts\shared\system_shared;
11 #using scripts\shared\util_shared;
12 #using scripts\shared\visionset_mgr_shared;
14 #using scripts\shared\weapons\_weaponobjects;
16 #insert scripts\shared\shared.gsh;
17 #insert scripts\shared\version.gsh;
19 #insert scripts\shared\weapons\_lightninggun.gsh;
21 #precache( "fx", "weapon/fx_lightninggun_arc" );
23 #define LIGHTNINGGUN_VICTIM_RUMBLE "lightninggun_victim"
25 #namespace lightninggun;
29 level.weaponLightningGun = GetWeapon(
"hero_lightninggun" );
30 level.weaponLightningGunArc = GetWeapon(
"hero_lightninggun_arc" );
31 level.weaponLightningGunKillcamTime = GetDvarFloat(
"scr_lightningGunKillcamTime", 0.35 );
32 level.weaponLightningGunKillcamDecelPercent = GetDvarFloat(
"scr_lightningGunKillcamDecelPercent", 0.25 );
33 level.weaponLightningGunKillcamOffset = GetDvarFloat(
"scr_lightningGunKillcamOffset", 150.0 );
36 level.lightninggun_arc_range_sq = level.lightninggun_arc_range * level.lightninggun_arc_range;
38 level.lightninggun_arc_speed_sq = level.lightninggun_arc_speed * level.lightninggun_arc_speed;
40 level.lightninggun_arc_fx_min_range_sq = level.lightninggun_arc_fx_min_range * level.lightninggun_arc_fx_min_range;
42 level._effect[
"lightninggun_arc"] =
"weapon/fx_lightninggun_arc";
57 level.weaponLightningGunKillcamTime = GetDvarFloat(
"scr_lightningGunKillcamTime", 0.35 );
58 level.weaponLightningGunKillcamDecelPercent = GetDvarFloat(
"scr_lightningGunKillcamDecelPercent", 0.25 );
59 level.weaponLightningGunKillcamOffset = GetDvarFloat(
"scr_lightningGunKillcamOffset", 150.0 );
66 self endon(
"disconnect" );
69 If ( IsGodMode(
self ) )
75 self SetElectrifiedState(
true );
76 self.electrifiedBy = eAttacker;
81 self.electrifiedBy = undefined;
82 self SetElectrifiedState(
false );
87 arc_target.killcamKilledByEnt =
create_killcam_entity( original_killcam_ent.origin, original_killcam_ent.angles, level.weaponLightningGunArc );
90 arc_target.killcamKilledByEnt
killcam_move( arc_source_pos, arc_target_pos, waitTime );
93 function lightninggun_arc_fx( arc_source_pos, arc_target, arc_target_pos, distanceSq, original_killcam_ent )
95 if ( !isdefined( arc_target ) || !isdefined( original_killcam_ent ) )
99 if ( level.lightninggun_arc_speed_sq > 100 && distanceSq > 1 )
101 waitTime = distanceSq / level.lightninggun_arc_speed_sq;
105 killcamEntity = arc_target.killcamKilledByEnt;
107 if ( !isdefined( arc_target ) || !isdefined( original_killcam_ent ) )
110 if ( distanceSq < level.lightninggun_arc_fx_min_range_sq )
114 killcamEntity
delete();
116 if ( isdefined( arc_target ) )
118 arc_target.killcamKilledByEnt = undefined;
125 fxOrg =
spawn(
"script_model", arc_source_pos );
126 fxOrg SetModel(
"tag_origin" );
128 fx = PlayFxOnTag( level._effect[
"lightninggun_arc"], fxOrg,
"tag_origin" );
129 playsoundatposition(
"wpn_lightning_gun_bounce", fxOrg.origin );
131 fxOrg MoveTo( arc_target_pos, waitTime );
132 fxOrg waittill(
"movedone" );
138 killcamEntity
delete();
140 if ( isdefined( arc_target ) )
142 arc_target.killcamKilledByEnt = undefined;
146 function lightninggun_arc(
delay, eAttacker, arc_source, arc_source_origin, arc_source_pos, arc_target, arc_target_pos, distanceSq )
152 if ( !IsDefined( arc_target ) || !IsAlive( arc_target ) )
158 distanceSq = DistanceSquared( arc_target.origin, arc_source_origin );
159 if ( distanceSq > level.lightninggun_arc_range_sq )
165 if ( !isdefined( arc_source ) )
170 if ( !isdefined( arc_source.killcamKilledByEnt ) )
175 level thread
lightninggun_arc_fx( arc_source_pos, arc_target, arc_target_pos, distanceSq, arc_source.killcamKilledByEnt );
177 arc_target DoDamage( arc_target.health, arc_source_pos, eAttacker, arc_source,
"none",
"MOD_PISTOL_BULLET", 0, level.weaponLightningGunArc );
187 closestPlayers = ArraySort( allEnemyAlivePlayers.a, arc_source_origin,
true );
189 foreach( player
in closestPlayers )
191 if ( IsDefined( arc_source ) && player == arc_source )
201 distanceSq = DistanceSquared( player.origin, arc_source_origin );
202 if ( distanceSq > level.lightninggun_arc_range_sq )
209 if ( isdefined(
self ) && !player DamageConeTrace( arc_source_pos,
self ) )
222 killcamKilledByEnt =
spawn(
"script_model", origin );
223 killcamKilledByEnt SetModel(
"tag_origin" );
224 killcamKilledByEnt.angles = angles;
225 killcamKilledByEnt SetWeapon( weapon );
226 return killcamKilledByEnt;
231 delta = end_origin - start_origin;
232 dist = Length( delta );
233 delta = VectorNormalize( delta );
234 move_to_dist = dist - level.weaponLightningGunKillcamOffset;
236 end_angles = (0,0,0);
238 if ( move_to_dist > 0 )
240 move_to_pos = start_origin + (delta * move_to_dist);
241 self MoveTo( move_to_pos, time, 0, time * level.weaponLightningGunKillcamDecelPercent );
242 end_angles = VectorToAngles( delta );
246 delta = end_origin -
self.origin;
247 end_angles = VectorToAngles( delta );
255 source_pos = eAttacker.origin;
256 bolt_source_pos = eAttacker GetTagOrigin(
"tag_flash" );
259 arc_source_origin =
self.origin;
262 delta = arc_source_pos - bolt_source_pos;
266 arc_source.killcamKilledByEnt
killcam_move( bolt_source_pos, arc_source_pos, level.weaponLightningGunKillcamTime );
267 killcamEntity = arc_source.killcamKilledByEnt;
274 if ( !IsDefined(
self ) )
281 if ( IsDefined(
self.body ) )
283 arc_source_origin =
self.body.origin;
292 killcamEntity
delete();
294 if ( IsDefined( arc_source ) )
296 arc_source.killcamKilledByEnt = undefined;
302 if (
"MOD_PISTOL_BULLET" != meansOfDeath &&
"MOD_HEAD_SHOT" != meansOfDeath )