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))
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 spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter);
80 spread = min(spread,autocvar_g_balance_hlac_primary_spread_max);
82 spread = spread * autocvar_g_balance_hlac_primary_spread_crouchmod;
84 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_primary_damage);
85 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
88 self.punchangle_x = random () - 0.5;
89 self.punchangle_y = random () - 0.5;
94 missile.classname = "hlacbolt";
95 missile.bot_dodge = TRUE;
97 missile.bot_dodgerating = autocvar_g_balance_hlac_primary_damage;
99 missile.movetype = MOVETYPE_FLY;
100 PROJECTILE_MAKETRIGGER(missile);
102 setorigin (missile, w_shotorg);
103 setsize(missile, '0 0 0', '0 0 0');
105 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_primary_speed, spread);
106 //missile.angles = vectoangles (missile.velocity); // csqc
108 missile.touch = W_HLAC_Touch;
109 missile.think = SUB_Remove;
111 missile.nextthink = time + autocvar_g_balance_hlac_primary_lifetime;
113 missile.flags = FL_PROJECTILE;
114 missile.projectiledeathtype = WEP_HLAC;
116 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
118 other = missile; MUTATOR_CALLHOOK(EditProjectile);
120 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
121 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
123 if(autocvar_g_balance_hlac_reload_ammo)
125 self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
126 self.hlac_load = self.clip_load;
129 self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
133 void W_HLAC_Attack2f (void)
135 local entity missile;
138 spread = autocvar_g_balance_hlac_secondary_spread;
142 spread = spread * autocvar_g_balance_hlac_secondary_spread_crouchmod;
144 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_secondary_damage);
145 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
148 missile.owner = self;
149 missile.classname = "hlacbolt";
150 missile.bot_dodge = TRUE;
152 missile.bot_dodgerating = autocvar_g_balance_hlac_secondary_damage;
154 missile.movetype = MOVETYPE_FLY;
155 PROJECTILE_MAKETRIGGER(missile);
157 setorigin (missile, w_shotorg);
158 setsize(missile, '0 0 0', '0 0 0');
160 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_secondary_speed, spread);
161 //missile.angles = vectoangles (missile.velocity); // csqc
163 missile.touch = W_HLAC_Touch;
164 missile.think = SUB_Remove;
166 missile.nextthink = time + autocvar_g_balance_hlac_secondary_lifetime;
168 missile.flags = FL_PROJECTILE;
169 missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
171 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
173 other = missile; MUTATOR_CALLHOOK(EditProjectile);
176 void W_HLAC_Attack2 (void)
180 for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
185 self.punchangle_x = random () - 0.5;
186 self.punchangle_y = random () - 0.5;
189 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
190 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
192 if(autocvar_g_balance_hlac_reload_ammo)
194 self.clip_load -= autocvar_g_balance_hlac_secondary_ammo;
195 self.hlac_load = self.clip_load;
198 self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo;
205 if(self.weapon != self.switchweapon) // abort immediately if switching
211 if (self.BUTTON_ATCK)
213 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
215 W_SwitchWeapon_Force(self, w_getbestweapon(self));
220 ATTACK_FINISHED(self) = time + autocvar_g_balance_hlac_primary_refire * W_WeaponRateFactor();
222 self.misc_bulletcounter = self.misc_bulletcounter + 1;
223 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
227 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_animtime, w_ready);
231 void spawnfunc_weapon_hlac (void)
233 weapon_defaultspawnfunc(WEP_HLAC);
236 float w_hlac(float req)
239 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hlac_primary_speed, 0, autocvar_g_balance_hlac_primary_lifetime, FALSE);
240 else if (req == WR_THINK)
242 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
244 else if (self.BUTTON_ATCK)
246 if (weapon_prepareattack(0, autocvar_g_balance_hlac_primary_refire))
248 self.misc_bulletcounter = 0;
250 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
254 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hlac_secondary)
256 if (weapon_prepareattack(1, autocvar_g_balance_hlac_secondary_refire))
259 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hlac_secondary_animtime, w_ready);
264 if(self.switchweapon == self.weapon)
266 if(self.weaponentity.state == WS_READY)
268 self.wish_reload = 0;
274 else if (req == WR_PRECACHE)
276 precache_model ("models/weapons/g_hlac.md3");
277 precache_model ("models/weapons/v_hlac.md3");
278 precache_model ("models/weapons/h_hlac.iqm");
279 precache_sound ("weapons/lasergun_fire.wav");
282 else if (req == WR_SETUP)
284 weapon_setup(WEP_HLAC);
285 W_Hlac_SetAmmoCounter();
287 else if (req == WR_CHECKAMMO1)
289 if(autocvar_g_balance_hlac_reload_ammo)
290 return self.hlac_load >= autocvar_g_balance_hlac_primary_ammo;
292 return self.ammo_cells >= autocvar_g_balance_hlac_primary_ammo;
294 else if (req == WR_CHECKAMMO2)
296 if(autocvar_g_balance_hlac_reload_ammo)
297 return self.hlac_load >= autocvar_g_balance_hlac_secondary_ammo;
299 return self.ammo_cells >= autocvar_g_balance_hlac_secondary_ammo;
301 else if (req == WR_RELOAD)
309 float w_hlac(float req)
311 if(req == WR_IMPACTEFFECT)
314 org2 = w_org + w_backoff * 6;
315 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
317 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
319 else if(req == WR_PRECACHE)
321 precache_sound("weapons/laserimpact.wav");
323 else if (req == WR_SUICIDEMESSAGE)
324 w_deathtypestring = "%s should have used a smaller gun";
325 else if (req == WR_KILLMESSAGE)
326 w_deathtypestring = "%s was cut down by %s";