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_Touch (void)
11 self.event_damage = SUB_Null;
13 RadiusDamage (self, self.owner, cvar("g_balance_laser_secondary_damage"), cvar("g_balance_laser_secondary_edgedamage"), cvar("g_balance_laser_secondary_radius"), world, cvar("g_balance_laser_secondary_force"), self.projectiledeathtype, other);
15 RadiusDamage (self, self.owner, cvar("g_balance_laser_primary_damage"), cvar("g_balance_laser_primary_edgedamage"), cvar("g_balance_laser_primary_radius"), world, cvar("g_balance_laser_primary_force"), self.projectiledeathtype, other);
22 self.movetype = MOVETYPE_FLY;
23 self.think = SUB_Remove;
25 self.nextthink = time + cvar("g_balance_laser_secondary_lifetime");
27 self.nextthink = time + cvar("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;
44 a = cvar("g_balance_laser_secondary_shotangle");
46 a = cvar("g_balance_laser_primary_shotangle");
47 s_forward = v_forward * cos(a * DEG2RAD) + v_up * sin(a * DEG2RAD);
50 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", 0);
51 else if(issecondary == 1)
52 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_laser_secondary_damage"));
54 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_laser_primary_damage"));
55 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
59 missile.classname = "laserbolt";
60 missile.dmg = (issecondary == 1);
63 missile.bot_dodge = TRUE;
65 missile.bot_dodgerating = cvar("g_balance_laser_secondary_damage");
67 missile.bot_dodgerating = cvar("g_balance_laser_primary_damage");
70 PROJECTILE_MAKETRIGGER(missile);
71 missile.projectiledeathtype = WEP_LASER;
73 missile.projectiledeathtype |= HITTYPE_SECONDARY;
75 setorigin (missile, w_shotorg);
76 setsize(missile, '0 0 0', '0 0 0');
79 W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_secondary);
81 W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary);
82 missile.angles = vectoangles (missile.velocity);
83 //missile.glow_color = 250; // 244, 250
84 //missile.glow_size = 120;
85 missile.touch = W_Laser_Touch;
87 missile.flags = FL_PROJECTILE;
89 missile.think = W_Laser_Think;
91 missile.nextthink = time + cvar("g_balance_laser_secondary_delay");
93 missile.nextthink = time + cvar("g_balance_laser_primary_delay");
94 if(time >= missile.nextthink)
104 .vector hook_start, hook_end;
105 float gauntletbeam_send(entity to, float sf)
107 WriteByte(MSG_ENTITY, ENT_CLIENT_GAUNTLET);
109 if(sound_allowed(MSG_BROADCAST, self.owner))
111 WriteByte(MSG_ENTITY, sf);
114 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
118 WriteCoord(MSG_ENTITY, self.hook_start_x);
119 WriteCoord(MSG_ENTITY, self.hook_start_y);
120 WriteCoord(MSG_ENTITY, self.hook_start_z);
124 WriteCoord(MSG_ENTITY, self.hook_end_x);
125 WriteCoord(MSG_ENTITY, self.hook_end_y);
126 WriteCoord(MSG_ENTITY, self.hook_end_z);
130 .entity gauntletbeam;
131 .float prevgauntletfire;
132 void gauntletbeam_think()
134 float damage, myforce, myradius;
137 damage = cvar("g_balance_laser_secondary_damage");
138 myforce = cvar("g_balance_laser_secondary_force");
139 myradius = cvar("g_balance_laser_secondary_radius");
143 damage = cvar("g_balance_laser_primary_damage");
144 myforce = cvar("g_balance_laser_primary_force");
145 myradius = cvar("g_balance_laser_primary_radius");
148 self.owner.prevgauntletfire = time;
149 if (self.owner.weaponentity.state != WS_INUSE || self != self.owner.gauntletbeam || self.owner.deadflag != DEAD_NO || (!self.owner.BUTTON_ATCK2 && self.cnt) || (!self.owner.BUTTON_ATCK && !self.cnt))
155 self.nextthink = time;
157 makevectors(self.owner.v_angle);
161 WarpZone_traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * myradius, FALSE, self.owner, ANTILAG_LATENCY(self.owner));
164 if(trace_fraction < 1)
167 force = angle * myforce;
168 Damage (trace_ent, self.owner, self.owner, damage * frametime, WEP_ELECTRO, trace_endpos, force * frametime);
173 if(self.owner.weaponentity.movedir_x > 0)
175 vecs = self.owner.weaponentity.movedir;
180 org = self.owner.origin + self.owner.view_ofs + v_forward * vecs_x + v_right * vecs_y + v_up * vecs_z;
182 if(org != self.hook_start)
185 self.hook_start = org;
187 if(trace_endpos != self.hook_end)
190 self.hook_end = trace_endpos;
194 // experimental gauntlet
195 void W_Laser_Attack2 (float issecondary)
197 // only play fire sound if 0.5 sec has passed since player let go the fire button
198 if(time - self.prevgauntletfire > 0.5)
200 sound (self, CHAN_WEAPON, "weapons/gauntlet_fire.wav", VOL_BASE, ATTN_NORM);
203 entity beam, oldself;
205 self.gauntletbeam = beam = spawn();
206 beam.solid = SOLID_NOT;
207 beam.think = gauntletbeam_think;
209 beam.movetype = MOVETYPE_NONE;
210 beam.shot_spread = 0;
211 beam.bot_dodge = TRUE;
212 beam.bot_dodgerating = cvar("g_balance_laser_primary_damage");
213 beam.cnt = issecondary;
214 Net_LinkEntity(beam, FALSE, 0, gauntletbeam_send);
224 weapon_action(WEP_LASER, WR_PRECACHE);
225 gauntlet_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 1);
226 gauntlet_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 2);
227 gauntlet_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 3);
228 gauntlet_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LASER), FALSE, FALSE, 4);
231 void spawnfunc_weapon_laser (void)
233 weapon_defaultspawnfunc(WEP_LASER);
236 float w_laser(float req)
242 if(cvar("g_balance_laser_secondary"))
244 r1 = cvar("g_balance_laser_primary_damage");
245 r2 = cvar("g_balance_laser_secondary_damage");
246 if (random() * (r2 + r1) > r1)
247 self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_laser_secondary_speed"), 0, cvar("g_balance_laser_secondary_lifetime"), FALSE);
249 self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
252 self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
254 else if (req == WR_THINK)
256 if (self.BUTTON_ATCK)
257 if (weapon_prepareattack(0, cvar("g_balance_laser_primary_refire")))
259 if(cvar("g_balance_laser_primary_gauntlet"))
263 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_primary_animtime"), w_ready);
265 if (self.BUTTON_ATCK2)
267 if(cvar("g_balance_laser_secondary"))
269 if (weapon_prepareattack(0, cvar("g_balance_laser_secondary_refire")))
271 if(cvar("g_balance_laser_secondary_gauntlet"))
275 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_laser_secondary_animtime"), w_ready);
280 if(self.switchweapon == WEP_LASER) // don't do this if already switching
281 W_SwitchWeapon (self.cnt);
285 else if (req == WR_PRECACHE)
287 precache_model ("models/weapons/g_laser.md3");
288 precache_model ("models/weapons/v_laser.md3");
289 precache_model ("models/weapons/h_laser.iqm");
290 precache_sound ("weapons/lasergun_fire.wav");
291 precache_sound ("weapons/gauntlet_fire.wav");
293 else if (req == WR_SETUP)
294 weapon_setup(WEP_LASER);
295 else if (req == WR_CHECKAMMO1)
297 else if (req == WR_CHECKAMMO2)
303 float w_laser(float req)
305 if(req == WR_IMPACTEFFECT)
308 org2 = w_org + w_backoff * 6;
309 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
311 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
313 else if(req == WR_PRECACHE)
315 precache_sound("weapons/laserimpact.wav");
317 else if (req == WR_SUICIDEMESSAGE)
318 w_deathtypestring = "lasered themself to hell";
319 else if (req == WR_KILLMESSAGE)
321 w_deathtypestring = "was lasered to death by"; // unchecked: SPLASH