2 REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", _("Laser"))
5 void(float imp) W_SwitchWeapon;
7 void W_Laser_Touch (void)
11 self.event_damage = SUB_Null;
13 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);
15 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);
22 self.movetype = MOVETYPE_FLY;
23 self.think = SUB_Remove;
25 self.nextthink = time + autocvar_g_balance_laser_secondary_lifetime;
27 self.nextthink = time + autocvar_g_balance_laser_primary_lifetime;
28 CSQCProjectile(self, TRUE, PROJECTILE_LASER, TRUE);
31 void W_Laser_Attack (float issecondary)
38 if(issecondary == 2) // minstanex shot
39 nodamage = g_minstagib;
43 a = autocvar_g_balance_laser_primary_shotangle;
44 s_forward = v_forward * cos(a * DEG2RAD) + v_up * sin(a * DEG2RAD);
47 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, 0);
48 else if(issecondary == 1)
49 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, autocvar_g_balance_laser_secondary_damage);
51 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON2, autocvar_g_balance_laser_primary_damage);
52 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
56 missile.classname = "laserbolt";
60 missile.bot_dodge = TRUE;
61 missile.bot_dodgerating = autocvar_g_balance_laser_primary_damage;
64 PROJECTILE_MAKETRIGGER(missile);
65 missile.projectiledeathtype = WEP_LASER;
67 setorigin (missile, w_shotorg);
68 setsize(missile, '0 0 0', '0 0 0');
70 W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary);
71 missile.angles = vectoangles (missile.velocity);
72 //missile.glow_color = 250; // 244, 250
73 //missile.glow_size = 120;
74 missile.touch = W_Laser_Touch;
76 missile.flags = FL_PROJECTILE;
78 missile.think = W_Laser_Think;
79 missile.nextthink = time + autocvar_g_balance_laser_primary_delay;
81 other = missile; MUTATOR_CALLHOOK(EditProjectile);
83 if(time >= missile.nextthink)
93 .vector hook_start, hook_end;
94 float gauntletbeam_send(entity to, float sf)
96 WriteByte(MSG_ENTITY, ENT_CLIENT_GAUNTLET);
98 if(sound_allowed(MSG_BROADCAST, self.owner))
100 WriteByte(MSG_ENTITY, sf);
103 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
107 WriteCoord(MSG_ENTITY, self.hook_start_x);
108 WriteCoord(MSG_ENTITY, self.hook_start_y);
109 WriteCoord(MSG_ENTITY, self.hook_start_z);
113 WriteCoord(MSG_ENTITY, self.hook_end_x);
114 WriteCoord(MSG_ENTITY, self.hook_end_y);
115 WriteCoord(MSG_ENTITY, self.hook_end_z);
119 .entity gauntletbeam;
120 .float prevgauntletfire;
121 void gauntletbeam_think()
123 float damage, myforce, myradius;
124 damage = autocvar_g_balance_laser_secondary_damage;
125 myforce = autocvar_g_balance_laser_secondary_force;
126 myradius = autocvar_g_balance_laser_secondary_radius;
128 self.owner.prevgauntletfire = time;
129 if (self.owner.weaponentity.state != WS_INUSE || self != self.owner.gauntletbeam || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK2)
135 self.nextthink = time;
137 makevectors(self.owner.v_angle);
142 W_SetupShot_Range(self.owner, TRUE, 0, "", 0, damage * dt, myradius);
143 WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
149 force = w_shotdir * myforce;
150 if(accuracy_isgooddamage(self.owner, trace_ent))
151 accuracy_add(self.owner, WEP_LASER, 0, damage * dt);
152 Damage (trace_ent, self.owner, self.owner, damage * dt, WEP_LASER | HITTYPE_SECONDARY, trace_endpos, force * dt);
156 if(w_shotorg != self.hook_start)
159 self.hook_start = w_shotorg;
161 if(w_shotend != self.hook_end)
164 self.hook_end = w_shotend;
168 // experimental gauntlet
169 void W_Laser_Attack2 ()
171 // only play fire sound if 0.5 sec has passed since player let go the fire button
172 if(time - self.prevgauntletfire > 0.5)
174 sound (self, CHAN_WEAPON, "weapons/gauntlet_fire.wav", VOL_BASE, ATTN_NORM);
177 entity beam, oldself;
179 self.gauntletbeam = beam = spawn();
180 beam.solid = SOLID_NOT;
181 beam.think = gauntletbeam_think;
183 beam.movetype = MOVETYPE_NONE;
184 beam.shot_spread = 0;
185 beam.bot_dodge = TRUE;
186 beam.bot_dodgerating = autocvar_g_balance_laser_primary_damage;
187 Net_LinkEntity(beam, FALSE, 0, gauntletbeam_send);
197 weapon_action(WEP_LASER, WR_PRECACHE);
198 gauntlet_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 1);
199 gauntlet_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 2);
200 gauntlet_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 3);
201 gauntlet_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 4);
204 void spawnfunc_weapon_laser (void)
206 weapon_defaultspawnfunc(WEP_LASER);
209 float w_laser(float req)
215 if(autocvar_g_balance_laser_secondary)
217 r1 = autocvar_g_balance_laser_primary_damage;
218 r2 = autocvar_g_balance_laser_secondary_damage;
219 if (random() * (r2 + r1) > r1)
220 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_secondary_speed, 0, autocvar_g_balance_laser_secondary_lifetime, FALSE);
222 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
225 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
227 else if (req == WR_THINK)
229 if(autocvar_g_balance_laser_reload_ammo && self.clip_load < 1) // forced reload
230 weapon_action(self.weapon, WR_RELOAD);
231 else if (self.BUTTON_ATCK)
233 if (weapon_prepareattack(0, autocvar_g_balance_laser_primary_refire))
235 W_DecreaseAmmo(zero_ammo, 1, TRUE);
238 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_laser_primary_animtime, w_ready);
241 else if (self.BUTTON_ATCK2)
243 if(autocvar_g_balance_laser_secondary)
245 W_DecreaseAmmo(zero_ammo, 1, TRUE);
247 if (weapon_prepareattack(0, 0))
250 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_secondary_animtime, w_ready);
255 if(self.switchweapon == WEP_LASER) // don't do this if already switching
256 W_SwitchWeapon (self.cnt);
260 else if (req == WR_PRECACHE)
262 precache_model ("models/weapons/g_laser.md3");
263 precache_model ("models/weapons/v_laser.md3");
264 precache_model ("models/weapons/h_laser.iqm");
265 precache_sound ("weapons/lasergun_fire.wav");
266 precache_sound ("weapons/gauntlet_fire.wav");
267 precache_sound ("weapons/reload.wav");
269 else if (req == WR_SETUP)
271 weapon_setup(WEP_LASER);
272 self.current_ammo = zero_ammo;
274 else if (req == WR_CHECKAMMO1)
278 else if (req == WR_CHECKAMMO2)
282 else if (req == WR_RELOAD)
284 W_Reload(0, autocvar_g_balance_laser_reload_ammo, autocvar_g_balance_laser_reload_time, "weapons/reload.wav");
290 float w_laser(float req)
292 if(req == WR_IMPACTEFFECT)
295 org2 = w_org + w_backoff * 6;
296 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
298 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
300 else if(req == WR_PRECACHE)
302 precache_sound("weapons/laserimpact.wav");
304 else if (req == WR_SUICIDEMESSAGE)
305 w_deathtypestring = _("%s lasered themself to hell");
306 else if (req == WR_KILLMESSAGE)
308 if(w_deathtype & HITTYPE_SECONDARY)
309 w_deathtypestring = _("%s was cut in half by %s's gauntlet"); // unchecked: SPLASH
311 w_deathtypestring = _("%s was lasered to death by %s"); // unchecked: SPLASH