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.weapon_load[WEP_LASER];
15 self.clip_size = autocvar_g_balance_laser_reload_ammo; // for the crosshair ammo display
21 self.(self.reload_ammo_player) = 1;
22 self.reload_ammo_min = 0;
23 self.reload_ammo_amount = autocvar_g_balance_laser_reload_ammo;
24 self.reload_time = autocvar_g_balance_laser_reload_time;
25 self.reload_sound = "weapons/reload.wav";
30 void W_Laser_Touch (void)
34 self.event_damage = SUB_Null;
36 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);
38 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);
45 self.movetype = MOVETYPE_FLY;
46 self.think = SUB_Remove;
48 self.nextthink = time + autocvar_g_balance_laser_secondary_lifetime;
50 self.nextthink = time + autocvar_g_balance_laser_primary_lifetime;
51 CSQCProjectile(self, TRUE, PROJECTILE_LASER, TRUE);
54 void W_Laser_Attack (float issecondary)
61 if(issecondary == 2) // minstanex shot
62 nodamage = g_minstagib;
66 a = autocvar_g_balance_laser_primary_shotangle;
67 s_forward = v_forward * cos(a * DEG2RAD) + v_up * sin(a * DEG2RAD);
70 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, 0);
71 else if(issecondary == 1)
72 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, autocvar_g_balance_laser_secondary_damage);
74 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, autocvar_g_balance_laser_primary_damage);
75 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
79 missile.classname = "laserbolt";
83 missile.bot_dodge = TRUE;
84 missile.bot_dodgerating = autocvar_g_balance_laser_primary_damage;
87 PROJECTILE_MAKETRIGGER(missile);
88 missile.projectiledeathtype = WEP_LASER;
90 setorigin (missile, w_shotorg);
91 setsize(missile, '0 0 0', '0 0 0');
93 W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary);
94 missile.angles = vectoangles (missile.velocity);
95 //missile.glow_color = 250; // 244, 250
96 //missile.glow_size = 120;
97 missile.touch = W_Laser_Touch;
99 missile.flags = FL_PROJECTILE;
101 missile.think = W_Laser_Think;
102 missile.nextthink = time + autocvar_g_balance_laser_primary_delay;
104 other = missile; MUTATOR_CALLHOOK(EditProjectile);
106 if(time >= missile.nextthink)
116 .vector hook_start, hook_end;
117 float gauntletbeam_send(entity to, float sf)
119 WriteByte(MSG_ENTITY, ENT_CLIENT_GAUNTLET);
121 if(sound_allowed(MSG_BROADCAST, self.owner))
123 WriteByte(MSG_ENTITY, sf);
126 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
130 WriteCoord(MSG_ENTITY, self.hook_start_x);
131 WriteCoord(MSG_ENTITY, self.hook_start_y);
132 WriteCoord(MSG_ENTITY, self.hook_start_z);
136 WriteCoord(MSG_ENTITY, self.hook_end_x);
137 WriteCoord(MSG_ENTITY, self.hook_end_y);
138 WriteCoord(MSG_ENTITY, self.hook_end_z);
142 .entity gauntletbeam;
143 .float prevgauntletfire;
144 void gauntletbeam_think()
146 float damage, myforce, myradius;
147 damage = autocvar_g_balance_laser_secondary_damage;
148 myforce = autocvar_g_balance_laser_secondary_force;
149 myradius = autocvar_g_balance_laser_secondary_radius;
151 self.owner.prevgauntletfire = time;
152 if (self.owner.weaponentity.state != WS_INUSE || self != self.owner.gauntletbeam || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK2)
158 self.nextthink = time;
160 makevectors(self.owner.v_angle);
165 W_SetupShot_Range(self.owner, TRUE, 0, "", 0, damage * dt, myradius);
166 WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
172 force = w_shotdir * myforce;
173 if(accuracy_isgooddamage(self.owner, trace_ent))
174 accuracy_add(self.owner, WEP_LASER, 0, damage * dt);
175 Damage (trace_ent, self.owner, self.owner, damage * dt, WEP_LASER | HITTYPE_SECONDARY, trace_endpos, force * dt);
179 if(w_shotorg != self.hook_start)
182 self.hook_start = w_shotorg;
184 if(w_shotend != self.hook_end)
187 self.hook_end = w_shotend;
191 // experimental gauntlet
192 void W_Laser_Attack2 ()
194 // only play fire sound if 0.5 sec has passed since player let go the fire button
195 if(time - self.prevgauntletfire > 0.5)
197 sound (self, CHAN_WEAPON, "weapons/gauntlet_fire.wav", VOL_BASE, ATTN_NORM);
200 entity beam, oldself;
202 self.gauntletbeam = beam = spawn();
203 beam.solid = SOLID_NOT;
204 beam.think = gauntletbeam_think;
206 beam.movetype = MOVETYPE_NONE;
207 beam.shot_spread = 0;
208 beam.bot_dodge = TRUE;
209 beam.bot_dodgerating = autocvar_g_balance_laser_primary_damage;
210 Net_LinkEntity(beam, FALSE, 0, gauntletbeam_send);
220 weapon_action(WEP_LASER, WR_PRECACHE);
221 gauntlet_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 1);
222 gauntlet_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 2);
223 gauntlet_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 3);
224 gauntlet_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 4);
227 void spawnfunc_weapon_laser (void)
229 weapon_defaultspawnfunc(WEP_LASER);
232 float w_laser(float req)
238 if(autocvar_g_balance_laser_secondary)
240 r1 = autocvar_g_balance_laser_primary_damage;
241 r2 = autocvar_g_balance_laser_secondary_damage;
242 if (random() * (r2 + r1) > r1)
243 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_secondary_speed, 0, autocvar_g_balance_laser_secondary_lifetime, FALSE);
245 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
248 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
250 else if (req == WR_THINK)
252 if(autocvar_g_balance_laser_reload_ammo && self.clip_load < 1) // forced reload
254 else if (self.BUTTON_ATCK)
256 if (weapon_prepareattack(0, autocvar_g_balance_laser_primary_refire))
258 // if this weapon is reloadable, decrease its load
259 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
261 if(autocvar_g_balance_laser_reload_ammo)
264 self.weapon_load[WEP_LASER] = self.clip_load;
269 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_laser_primary_animtime, w_ready);
272 else if (self.BUTTON_ATCK2)
274 if(autocvar_g_balance_laser_secondary)
276 // if this weapon is reloadable, decrease its load
277 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
279 if(autocvar_g_balance_laser_reload_ammo)
282 self.weapon_load[WEP_LASER] = self.clip_load;
286 if (weapon_prepareattack(0, 0))
289 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_secondary_animtime, w_ready);
294 if(self.switchweapon == WEP_LASER) // don't do this if already switching
295 W_SwitchWeapon (self.cnt);
299 else if (req == WR_PRECACHE)
301 precache_model ("models/weapons/g_laser.md3");
302 precache_model ("models/weapons/v_laser.md3");
303 precache_model ("models/weapons/h_laser.iqm");
304 precache_sound ("weapons/lasergun_fire.wav");
305 precache_sound ("weapons/gauntlet_fire.wav");
306 precache_sound ("weapons/reload.wav");
308 else if (req == WR_SETUP)
310 weapon_setup(WEP_LASER);
311 W_Laser_SetAmmoCounter();
313 else if (req == WR_CHECKAMMO1)
317 else if (req == WR_CHECKAMMO2)
321 else if (req == WR_RELOAD)
329 float w_laser(float req)
331 if(req == WR_IMPACTEFFECT)
334 org2 = w_org + w_backoff * 6;
335 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
337 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
339 else if(req == WR_PRECACHE)
341 precache_sound("weapons/laserimpact.wav");
343 else if (req == WR_SUICIDEMESSAGE)
344 w_deathtypestring = _("%s lasered themself to hell");
345 else if (req == WR_KILLMESSAGE)
347 if(w_deathtype & HITTYPE_SECONDARY)
348 w_deathtypestring = _("%s was cut in half by %s's gauntlet"); // unchecked: SPLASH
350 w_deathtypestring = _("%s was lasered to death by %s"); // unchecked: SPLASH