2 REGISTER_WEAPON(HLAC, w_hlac, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hlac", "hlac", _("Heavy Laser Assault Cannon"))
8 void W_HLAC_SetAmmoCounter()
10 // set clip_load to the weapon we have switched to, if the gun uses reloading
11 if(!autocvar_g_balance_hlac_reload_ammo)
12 self.clip_load = 0; // also keeps crosshair ammo from displaying
15 self.clip_load = self.hlac_load;
16 self.clip_size = autocvar_g_balance_hlac_reload_ammo; // for the crosshair ammo display
20 void W_HLAC_ReloadedAndReady()
24 // now do the ammo transfer
25 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
26 while(self.clip_load < autocvar_g_balance_hlac_reload_ammo && self.ammo_cells) // make sure we don't add more ammo than we have
31 self.hlac_load = self.clip_load;
33 t = ATTACK_FINISHED(self) - autocvar_g_balance_hlac_reload_time - 1;
34 ATTACK_FINISHED(self) = t;
40 // return if reloading is disabled for this weapon
41 if(!autocvar_g_balance_hlac_reload_ammo)
44 if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_secondary_ammo)))
49 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
51 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_hlac_reload_time + 1;
52 ATTACK_FINISHED(self) = t;
54 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_hlac_reload_time, W_HLAC_ReloadedAndReady);
56 self.old_clip_load = self.clip_load;
60 void W_HLAC_Touch (void)
64 self.event_damage = SUB_Null;
66 if(self.projectiledeathtype & HITTYPE_SECONDARY)
67 RadiusDamage (self, self.owner, autocvar_g_balance_hlac_secondary_damage, autocvar_g_balance_hlac_secondary_edgedamage, autocvar_g_balance_hlac_secondary_radius, world, autocvar_g_balance_hlac_secondary_force, self.projectiledeathtype, other);
69 RadiusDamage (self, self.owner, autocvar_g_balance_hlac_primary_damage, autocvar_g_balance_hlac_primary_edgedamage, autocvar_g_balance_hlac_primary_radius, world, autocvar_g_balance_hlac_primary_force, self.projectiledeathtype, other);
74 void W_HLAC_Attack (void)
79 // if there's not enough ammo for this attack (but we still have the weapon), reload
80 if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < autocvar_g_balance_hlac_primary_ammo)
86 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
87 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
89 if(autocvar_g_balance_hlac_reload_ammo)
91 self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
92 self.hlac_load = self.clip_load;
95 self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
98 spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter);
99 spread = min(spread,autocvar_g_balance_hlac_primary_spread_max);
101 spread = spread * autocvar_g_balance_hlac_primary_spread_crouchmod;
103 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_primary_damage);
104 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
107 self.punchangle_x = random () - 0.5;
108 self.punchangle_y = random () - 0.5;
112 missile.owner = self;
113 missile.classname = "hlacbolt";
114 missile.bot_dodge = TRUE;
116 missile.bot_dodgerating = autocvar_g_balance_hlac_primary_damage;
118 missile.movetype = MOVETYPE_FLY;
119 PROJECTILE_MAKETRIGGER(missile);
121 setorigin (missile, w_shotorg);
122 setsize(missile, '0 0 0', '0 0 0');
124 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_primary_speed, spread);
125 //missile.angles = vectoangles (missile.velocity); // csqc
127 missile.touch = W_HLAC_Touch;
128 missile.think = SUB_Remove;
130 missile.nextthink = time + autocvar_g_balance_hlac_primary_lifetime;
132 missile.flags = FL_PROJECTILE;
133 missile.projectiledeathtype = WEP_HLAC;
135 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
137 other = missile; MUTATOR_CALLHOOK(EditProjectile);
140 void W_HLAC_Attack2f (void)
142 local entity missile;
145 spread = autocvar_g_balance_hlac_secondary_spread;
149 spread = spread * autocvar_g_balance_hlac_secondary_spread_crouchmod;
151 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_secondary_damage);
152 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
155 missile.owner = self;
156 missile.classname = "hlacbolt";
157 missile.bot_dodge = TRUE;
159 missile.bot_dodgerating = autocvar_g_balance_hlac_secondary_damage;
161 missile.movetype = MOVETYPE_FLY;
162 PROJECTILE_MAKETRIGGER(missile);
164 setorigin (missile, w_shotorg);
165 setsize(missile, '0 0 0', '0 0 0');
167 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_secondary_speed, spread);
168 //missile.angles = vectoangles (missile.velocity); // csqc
170 missile.touch = W_HLAC_Touch;
171 missile.think = SUB_Remove;
173 missile.nextthink = time + autocvar_g_balance_hlac_secondary_lifetime;
175 missile.flags = FL_PROJECTILE;
176 missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
178 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
180 other = missile; MUTATOR_CALLHOOK(EditProjectile);
183 void W_HLAC_Attack2 (void)
187 // if there's not enough ammo for this attack (but we still have the weapon), reload
188 if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < autocvar_g_balance_hlac_secondary_ammo)
194 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
195 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
197 if(autocvar_g_balance_hlac_reload_ammo)
199 self.clip_load -= autocvar_g_balance_hlac_secondary_ammo;
200 self.hlac_load = self.clip_load;
203 self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo;
206 for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
211 self.punchangle_x = random () - 0.5;
212 self.punchangle_y = random () - 0.5;
219 if(self.weapon != self.switchweapon) // abort immediately if switching
225 if (self.BUTTON_ATCK)
227 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
229 W_SwitchWeapon_Force(self, w_getbestweapon(self));
234 ATTACK_FINISHED(self) = time + autocvar_g_balance_hlac_primary_refire * W_WeaponRateFactor();
236 self.misc_bulletcounter = self.misc_bulletcounter + 1;
237 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
241 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_animtime, w_ready);
245 void spawnfunc_weapon_hlac (void)
247 weapon_defaultspawnfunc(WEP_HLAC);
250 float w_hlac(float req)
253 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hlac_primary_speed, 0, autocvar_g_balance_hlac_primary_lifetime, FALSE);
254 else if (req == WR_THINK)
256 if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < min(autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_secondary_ammo)) // forced reload
258 else if (self.BUTTON_ATCK)
260 if (weapon_prepareattack(0, autocvar_g_balance_hlac_primary_refire))
262 self.misc_bulletcounter = 0;
264 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
268 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hlac_secondary)
270 if (weapon_prepareattack(1, autocvar_g_balance_hlac_secondary_refire))
273 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hlac_secondary_animtime, w_ready);
278 if(self.switchweapon == self.weapon)
280 if(self.weaponentity.state == WS_READY)
282 self.wish_reload = 0;
288 else if (req == WR_PRECACHE)
290 precache_model ("models/weapons/g_hlac.md3");
291 precache_model ("models/weapons/v_hlac.md3");
292 precache_model ("models/weapons/h_hlac.iqm");
293 precache_sound ("weapons/lasergun_fire.wav");
296 else if (req == WR_SETUP)
298 weapon_setup(WEP_HLAC);
299 W_HLAC_SetAmmoCounter();
301 else if (req == WR_CHECKAMMO1)
303 if(autocvar_g_balance_hlac_reload_ammo)
304 return self.hlac_load >= autocvar_g_balance_hlac_primary_ammo;
306 return self.ammo_cells >= autocvar_g_balance_hlac_primary_ammo;
308 else if (req == WR_CHECKAMMO2)
310 if(autocvar_g_balance_hlac_reload_ammo)
311 return self.hlac_load >= autocvar_g_balance_hlac_secondary_ammo;
313 return self.ammo_cells >= autocvar_g_balance_hlac_secondary_ammo;
315 else if (req == WR_RELOAD)
323 float w_hlac(float req)
325 if(req == WR_IMPACTEFFECT)
328 org2 = w_org + w_backoff * 6;
329 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
331 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
333 else if(req == WR_PRECACHE)
335 precache_sound("weapons/laserimpact.wav");
337 else if (req == WR_SUICIDEMESSAGE)
338 w_deathtypestring = "%s should have used a smaller gun";
339 else if (req == WR_KILLMESSAGE)
340 w_deathtypestring = "%s was cut down by %s";