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"))
6 void W_HLAC_SetAmmoCounter()
8 // set clip_load to the weapon we have switched to, if the gun uses reloading
9 if(!autocvar_g_balance_hlac_reload_ammo)
10 self.clip_load = 0; // also keeps crosshair ammo from displaying
13 self.clip_load = self.hlac_load;
14 self.clip_size = autocvar_g_balance_hlac_reload_ammo; // for the crosshair ammo display
18 void W_HLAC_ReloadedAndReady()
22 // now do the ammo transfer
23 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
24 while(self.clip_load < autocvar_g_balance_hlac_reload_ammo && self.ammo_cells) // make sure we don't add more ammo than we have
29 self.hlac_load = self.clip_load;
31 t = ATTACK_FINISHED(self) - autocvar_g_balance_hlac_reload_time - 1;
32 ATTACK_FINISHED(self) = t;
38 // return if reloading is disabled for this weapon
39 if(!autocvar_g_balance_hlac_reload_ammo)
42 if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_secondary_ammo)))
47 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
49 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_hlac_reload_time + 1;
50 ATTACK_FINISHED(self) = t;
52 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_hlac_reload_time, W_HLAC_ReloadedAndReady);
54 self.old_clip_load = self.clip_load;
58 void W_HLAC_Touch (void)
62 self.event_damage = SUB_Null;
64 if(self.projectiledeathtype & HITTYPE_SECONDARY)
65 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);
67 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);
72 void W_HLAC_Attack (void)
77 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
78 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
80 if(autocvar_g_balance_hlac_reload_ammo)
82 self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
83 self.hlac_load = self.clip_load;
86 self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
89 spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter);
90 spread = min(spread,autocvar_g_balance_hlac_primary_spread_max);
92 spread = spread * autocvar_g_balance_hlac_primary_spread_crouchmod;
94 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_primary_damage);
95 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
98 self.punchangle_x = random () - 0.5;
99 self.punchangle_y = random () - 0.5;
103 missile.owner = self;
104 missile.classname = "hlacbolt";
105 missile.bot_dodge = TRUE;
107 missile.bot_dodgerating = autocvar_g_balance_hlac_primary_damage;
109 missile.movetype = MOVETYPE_FLY;
110 PROJECTILE_MAKETRIGGER(missile);
112 setorigin (missile, w_shotorg);
113 setsize(missile, '0 0 0', '0 0 0');
115 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_primary_speed, spread);
116 //missile.angles = vectoangles (missile.velocity); // csqc
118 missile.touch = W_HLAC_Touch;
119 missile.think = SUB_Remove;
121 missile.nextthink = time + autocvar_g_balance_hlac_primary_lifetime;
123 missile.flags = FL_PROJECTILE;
124 missile.projectiledeathtype = WEP_HLAC;
126 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
128 other = missile; MUTATOR_CALLHOOK(EditProjectile);
131 void W_HLAC_Attack2f (void)
133 local entity missile;
136 spread = autocvar_g_balance_hlac_secondary_spread;
140 spread = spread * autocvar_g_balance_hlac_secondary_spread_crouchmod;
142 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_secondary_damage);
143 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
146 missile.owner = self;
147 missile.classname = "hlacbolt";
148 missile.bot_dodge = TRUE;
150 missile.bot_dodgerating = autocvar_g_balance_hlac_secondary_damage;
152 missile.movetype = MOVETYPE_FLY;
153 PROJECTILE_MAKETRIGGER(missile);
155 setorigin (missile, w_shotorg);
156 setsize(missile, '0 0 0', '0 0 0');
158 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_secondary_speed, spread);
159 //missile.angles = vectoangles (missile.velocity); // csqc
161 missile.touch = W_HLAC_Touch;
162 missile.think = SUB_Remove;
164 missile.nextthink = time + autocvar_g_balance_hlac_secondary_lifetime;
166 missile.flags = FL_PROJECTILE;
167 missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
169 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
171 other = missile; MUTATOR_CALLHOOK(EditProjectile);
174 void W_HLAC_Attack2 (void)
178 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
179 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
181 if(autocvar_g_balance_hlac_reload_ammo)
183 self.clip_load -= autocvar_g_balance_hlac_secondary_ammo;
184 self.hlac_load = self.clip_load;
187 self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo;
190 for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
195 self.punchangle_x = random () - 0.5;
196 self.punchangle_y = random () - 0.5;
203 if(self.weapon != self.switchweapon) // abort immediately if switching
209 if (self.BUTTON_ATCK)
211 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
213 W_SwitchWeapon_Force(self, w_getbestweapon(self));
218 ATTACK_FINISHED(self) = time + autocvar_g_balance_hlac_primary_refire * W_WeaponRateFactor();
220 self.misc_bulletcounter = self.misc_bulletcounter + 1;
221 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
225 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_animtime, w_ready);
229 void spawnfunc_weapon_hlac (void)
231 weapon_defaultspawnfunc(WEP_HLAC);
234 float w_hlac(float req)
237 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hlac_primary_speed, 0, autocvar_g_balance_hlac_primary_lifetime, FALSE);
238 else if (req == WR_THINK)
240 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
242 else if (self.BUTTON_ATCK)
244 if (weapon_prepareattack(0, autocvar_g_balance_hlac_primary_refire))
246 self.misc_bulletcounter = 0;
248 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
252 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hlac_secondary)
254 if (weapon_prepareattack(1, autocvar_g_balance_hlac_secondary_refire))
257 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hlac_secondary_animtime, w_ready);
261 else if (req == WR_PRECACHE)
263 precache_model ("models/weapons/g_hlac.md3");
264 precache_model ("models/weapons/v_hlac.md3");
265 precache_model ("models/weapons/h_hlac.iqm");
266 precache_sound ("weapons/lasergun_fire.wav");
267 precache_sound ("weapons/reload.wav");
270 else if (req == WR_SETUP)
272 weapon_setup(WEP_HLAC);
273 W_HLAC_SetAmmoCounter();
275 else if (req == WR_CHECKAMMO1)
277 if(autocvar_g_balance_hlac_reload_ammo)
278 return self.hlac_load >= autocvar_g_balance_hlac_primary_ammo;
280 return self.ammo_cells >= autocvar_g_balance_hlac_primary_ammo;
282 else if (req == WR_CHECKAMMO2)
284 if(autocvar_g_balance_hlac_reload_ammo)
285 return self.hlac_load >= autocvar_g_balance_hlac_secondary_ammo;
287 return self.ammo_cells >= autocvar_g_balance_hlac_secondary_ammo;
289 else if (req == WR_RELOAD)
293 else if (req == WR_SWITCHABLE)
295 // checks if this weapon can be switched to, when reloading is enabled
296 // returns true if there's either enough load in the weapon to use it,
297 // or we have enough ammo to reload the weapon to a usable point
299 ammo_amount = min(autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_secondary_ammo);
300 return (autocvar_g_balance_hlac_reload_ammo && self.hlac_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
306 float w_hlac(float req)
308 if(req == WR_IMPACTEFFECT)
311 org2 = w_org + w_backoff * 6;
312 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
314 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
316 else if(req == WR_PRECACHE)
318 precache_sound("weapons/laserimpact.wav");
320 else if (req == WR_SUICIDEMESSAGE)
321 w_deathtypestring = "%s should have used a smaller gun";
322 else if (req == WR_KILLMESSAGE)
323 w_deathtypestring = "%s was cut down by %s";