2 REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", _("Laser"))
5 void(float imp) W_SwitchWeapon;
7 void W_Laser_SetAmmoCounter()
9 // set clip_load to the weapon we have switched to, if the gun uses reloading
10 if(!autocvar_g_balance_laser_reload_ammo)
11 self.clip_load = 0; // also keeps crosshair ammo from displaying
14 self.clip_load = self.laser_load;
15 self.clip_size = autocvar_g_balance_laser_reload_ammo; // for the crosshair ammo display
19 void W_Laser_ReloadedAndReady()
23 self.clip_load = autocvar_g_balance_laser_reload_ammo; // maximum load since this weapon uses no ammo
24 self.laser_load = self.clip_load;
26 t = ATTACK_FINISHED(self) - autocvar_g_balance_laser_reload_time - 1;
27 ATTACK_FINISHED(self) = t;
33 // return if reloading is disabled for this weapon
34 if(!autocvar_g_balance_laser_reload_ammo)
37 if(!W_ReloadCheck(1, 0))
42 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
44 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_laser_reload_time + 1;
45 ATTACK_FINISHED(self) = t;
47 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_laser_reload_time, W_Laser_ReloadedAndReady);
52 void W_Laser_Touch (void)
56 self.event_damage = SUB_Null;
58 RadiusDamage (self, self.owner, autocvar_g_balance_laser_secondary_damage, autocvar_g_balance_laser_secondary_edgedamage, autocvar_g_balance_laser_secondary_radius, world, autocvar_g_balance_laser_secondary_force, self.projectiledeathtype, other);
60 RadiusDamage (self, self.owner, autocvar_g_balance_laser_primary_damage, autocvar_g_balance_laser_primary_edgedamage, autocvar_g_balance_laser_primary_radius, world, autocvar_g_balance_laser_primary_force, self.projectiledeathtype, other);
67 self.movetype = MOVETYPE_FLY;
68 self.think = SUB_Remove;
70 self.nextthink = time + autocvar_g_balance_laser_secondary_lifetime;
72 self.nextthink = time + autocvar_g_balance_laser_primary_lifetime;
73 CSQCProjectile(self, TRUE, PROJECTILE_LASER, TRUE);
76 void W_Laser_Attack (float issecondary)
83 if(issecondary == 2) // minstanex shot
84 nodamage = g_minstagib;
88 a = autocvar_g_balance_laser_primary_shotangle;
89 s_forward = v_forward * cos(a * DEG2RAD) + v_up * sin(a * DEG2RAD);
92 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, 0);
93 else if(issecondary == 1)
94 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, autocvar_g_balance_laser_secondary_damage);
96 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, autocvar_g_balance_laser_primary_damage);
97 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
100 missile.owner = self;
101 missile.classname = "laserbolt";
105 missile.bot_dodge = TRUE;
106 missile.bot_dodgerating = autocvar_g_balance_laser_primary_damage;
109 PROJECTILE_MAKETRIGGER(missile);
110 missile.projectiledeathtype = WEP_LASER;
112 setorigin (missile, w_shotorg);
113 setsize(missile, '0 0 0', '0 0 0');
115 W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary);
116 missile.angles = vectoangles (missile.velocity);
117 //missile.glow_color = 250; // 244, 250
118 //missile.glow_size = 120;
119 missile.touch = W_Laser_Touch;
121 missile.flags = FL_PROJECTILE;
123 missile.think = W_Laser_Think;
124 missile.nextthink = time + autocvar_g_balance_laser_primary_delay;
126 other = missile; MUTATOR_CALLHOOK(EditProjectile);
128 if(time >= missile.nextthink)
138 .vector hook_start, hook_end;
139 float gauntletbeam_send(entity to, float sf)
141 WriteByte(MSG_ENTITY, ENT_CLIENT_GAUNTLET);
143 if(sound_allowed(MSG_BROADCAST, self.owner))
145 WriteByte(MSG_ENTITY, sf);
148 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
152 WriteCoord(MSG_ENTITY, self.hook_start_x);
153 WriteCoord(MSG_ENTITY, self.hook_start_y);
154 WriteCoord(MSG_ENTITY, self.hook_start_z);
158 WriteCoord(MSG_ENTITY, self.hook_end_x);
159 WriteCoord(MSG_ENTITY, self.hook_end_y);
160 WriteCoord(MSG_ENTITY, self.hook_end_z);
164 .entity gauntletbeam;
165 .float prevgauntletfire;
166 void gauntletbeam_think()
168 float damage, myforce, myradius;
169 damage = autocvar_g_balance_laser_secondary_damage;
170 myforce = autocvar_g_balance_laser_secondary_force;
171 myradius = autocvar_g_balance_laser_secondary_radius;
173 self.owner.prevgauntletfire = time;
174 if (self.owner.weaponentity.state != WS_INUSE || self != self.owner.gauntletbeam || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK2)
180 self.nextthink = time;
182 makevectors(self.owner.v_angle);
187 W_SetupShot_Range(self.owner, TRUE, 0, "", 0, damage * dt, myradius);
188 WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
194 force = w_shotdir * myforce;
195 if(accuracy_isgooddamage(self.owner, trace_ent))
196 accuracy_add(self.owner, WEP_LASER, 0, damage * dt);
197 Damage (trace_ent, self.owner, self.owner, damage * dt, WEP_LASER | HITTYPE_SECONDARY, trace_endpos, force * dt);
201 if(w_shotorg != self.hook_start)
204 self.hook_start = w_shotorg;
206 if(w_shotend != self.hook_end)
209 self.hook_end = w_shotend;
213 // experimental gauntlet
214 void W_Laser_Attack2 ()
216 // only play fire sound if 0.5 sec has passed since player let go the fire button
217 if(time - self.prevgauntletfire > 0.5)
219 sound (self, CHAN_WEAPON, "weapons/gauntlet_fire.wav", VOL_BASE, ATTN_NORM);
222 entity beam, oldself;
224 self.gauntletbeam = beam = spawn();
225 beam.solid = SOLID_NOT;
226 beam.think = gauntletbeam_think;
228 beam.movetype = MOVETYPE_NONE;
229 beam.shot_spread = 0;
230 beam.bot_dodge = TRUE;
231 beam.bot_dodgerating = autocvar_g_balance_laser_primary_damage;
232 Net_LinkEntity(beam, FALSE, 0, gauntletbeam_send);
242 weapon_action(WEP_LASER, WR_PRECACHE);
243 gauntlet_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 1);
244 gauntlet_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 2);
245 gauntlet_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 3);
246 gauntlet_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 4);
249 void spawnfunc_weapon_laser (void)
251 weapon_defaultspawnfunc(WEP_LASER);
254 float w_laser(float req)
260 if(autocvar_g_balance_laser_secondary)
262 r1 = autocvar_g_balance_laser_primary_damage;
263 r2 = autocvar_g_balance_laser_secondary_damage;
264 if (random() * (r2 + r1) > r1)
265 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_secondary_speed, 0, autocvar_g_balance_laser_secondary_lifetime, FALSE);
267 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
270 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
272 else if (req == WR_THINK)
274 if(autocvar_g_balance_laser_reload_ammo && self.clip_load < 1) // forced reload
276 else if (self.BUTTON_ATCK)
278 if (weapon_prepareattack(0, autocvar_g_balance_laser_primary_refire))
280 // if this weapon is reloadable, decrease its load
281 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
283 if(autocvar_g_balance_laser_reload_ammo)
286 self.laser_load = self.clip_load;
291 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_laser_primary_animtime, w_ready);
294 else if (self.BUTTON_ATCK2)
296 if(autocvar_g_balance_laser_secondary)
298 // if this weapon is reloadable, decrease its load
299 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
301 if(autocvar_g_balance_laser_reload_ammo)
304 self.laser_load = self.clip_load;
308 if (weapon_prepareattack(0, 0))
311 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_secondary_animtime, w_ready);
316 if(self.switchweapon == WEP_LASER) // don't do this if already switching
317 W_SwitchWeapon (self.cnt);
321 else if (req == WR_PRECACHE)
323 precache_model ("models/weapons/g_laser.md3");
324 precache_model ("models/weapons/v_laser.md3");
325 precache_model ("models/weapons/h_laser.iqm");
326 precache_sound ("weapons/lasergun_fire.wav");
327 precache_sound ("weapons/gauntlet_fire.wav");
328 precache_sound ("weapons/reload.wav");
330 else if (req == WR_SETUP)
332 weapon_setup(WEP_LASER);
333 W_Laser_SetAmmoCounter();
335 else if (req == WR_CHECKAMMO1)
337 else if (req == WR_CHECKAMMO2)
339 else if (req == WR_RELOAD)
345 float w_laser(float req)
347 if(req == WR_IMPACTEFFECT)
350 org2 = w_org + w_backoff * 6;
351 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
353 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
355 else if(req == WR_PRECACHE)
357 precache_sound("weapons/laserimpact.wav");
359 else if (req == WR_SUICIDEMESSAGE)
360 w_deathtypestring = "%s lasered themself to hell";
361 else if (req == WR_KILLMESSAGE)
363 if(w_deathtype & HITTYPE_SECONDARY)
364 w_deathtypestring = "%s was cut in half by %s's gauntlet"; // unchecked: SPLASH
366 w_deathtypestring = "%s was lasered to death by %s"; // unchecked: SPLASH