2 REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", "Laser");
4 void(float imp) W_SwitchWeapon;
6 void W_Laser_Touch (void)
10 self.event_damage = SUB_Null;
12 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);
14 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);
21 self.movetype = MOVETYPE_FLY;
22 self.think = SUB_Remove;
24 self.nextthink = time + cvar("g_balance_laser_secondary_lifetime");
26 self.nextthink = time + cvar("g_balance_laser_primary_lifetime");
27 CSQCProjectile(self, TRUE, PROJECTILE_LASER, TRUE);
30 void W_Laser_Attack (float issecondary)
37 if(issecondary == 2) // minstanex shot
38 nodamage = g_minstagib;
43 a = cvar("g_balance_laser_secondary_shotangle");
45 a = cvar("g_balance_laser_primary_shotangle");
46 s_forward = v_forward * cos(a * DEG2RAD) + v_up * sin(a * DEG2RAD);
49 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", 0);
50 else if(issecondary == 1)
51 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_laser_secondary_damage"));
53 W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_laser_primary_damage"));
54 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
58 missile.classname = "laserbolt";
59 missile.dmg = (issecondary == 1);
62 missile.bot_dodge = TRUE;
64 missile.bot_dodgerating = cvar("g_balance_laser_secondary_damage");
66 missile.bot_dodgerating = cvar("g_balance_laser_primary_damage");
69 PROJECTILE_MAKETRIGGER(missile);
70 missile.projectiledeathtype = WEP_LASER;
72 missile.projectiledeathtype |= HITTYPE_SECONDARY;
74 setorigin (missile, w_shotorg);
75 setsize(missile, '0 0 0', '0 0 0');
78 W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_secondary);
80 W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary);
81 missile.angles = vectoangles (missile.velocity);
82 //missile.glow_color = 250; // 244, 250
83 //missile.glow_size = 120;
84 missile.touch = W_Laser_Touch;
86 missile.flags = FL_PROJECTILE;
88 missile.think = W_Laser_Think;
90 missile.nextthink = time + cvar("g_balance_laser_secondary_delay");
92 missile.nextthink = time + cvar("g_balance_laser_primary_delay");
93 if(time >= missile.nextthink)
103 void W_Laser_Attack2 (void) // gauntlet
105 W_SetupShot (self, TRUE, 0, "weapons/gauntlet_fire.wav", cvar("g_balance_laser_primary_damage"));
107 WarpZone_traceline_antilag(self, w_shotorg, w_shotorg + w_shotdir * cvar("g_balance_laser_primary_radius"), FALSE, self, ANTILAG_LATENCY(self));
109 pointparticles(particleeffectnum("laser_gauntlet"), w_shotorg + w_shotdir * cvar("g_balance_laser_primary_radius"), '0 0 0', 1);
111 if (trace_fraction < 1)
112 Damage(trace_ent, self, self, cvar("g_balance_laser_primary_damage"), WEP_LASER | HITTYPE_SECONDARY, trace_endpos, cvar("g_balance_laser_primary_force") * w_shotdir);
115 void spawnfunc_weapon_laser (void)
117 weapon_defaultspawnfunc(WEP_LASER);
120 float w_laser(float req)
126 if(cvar("g_balance_laser_secondary"))
128 r1 = cvar("g_balance_laser_primary_damage");
129 r2 = cvar("g_balance_laser_secondary_damage");
130 if (random() * (r2 + r1) > r1)
131 self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_laser_secondary_speed"), 0, cvar("g_balance_laser_secondary_lifetime"), FALSE);
133 self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
136 self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
138 else if (req == WR_THINK)
140 if (self.BUTTON_ATCK)
141 if (weapon_prepareattack(0, cvar("g_balance_laser_primary_refire")))
143 if(cvar("g_balance_laser_gauntlet"))
147 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_primary_animtime"), w_ready);
149 if (self.BUTTON_ATCK2)
151 if(cvar("g_balance_laser_secondary"))
153 if (weapon_prepareattack(0, cvar("g_balance_laser_secondary_refire")))
156 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_laser_secondary_animtime"), w_ready);
161 if(self.switchweapon == WEP_LASER) // don't do this if already switching
162 W_SwitchWeapon (self.cnt);
166 else if (req == WR_PRECACHE)
168 precache_model ("models/weapons/g_laser.md3");
169 precache_model ("models/weapons/v_laser.md3");
170 precache_model ("models/weapons/h_laser.iqm");
171 precache_sound ("weapons/lasergun_fire.wav");
172 precache_sound ("weapons/gauntlet_fire.wav");
174 else if (req == WR_SETUP)
175 weapon_setup(WEP_LASER);
176 else if (req == WR_CHECKAMMO1)
178 else if (req == WR_CHECKAMMO2)
180 else if (req == WR_SUICIDEMESSAGE)
181 w_deathtypestring = "lasered themself to hell";
182 else if (req == WR_KILLMESSAGE)
184 w_deathtypestring = "was lasered to death by"; // unchecked: SPLASH