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 // weapon load persistence, for weapons that support reloading
9 void W_HLAC_SetAmmoCounter()
11 // set clip_load to the weapon we have switched to, if the gun uses reloading
12 if(!autocvar_g_balance_hlac_reload_ammo)
13 self.clip_load = 0; // also keeps crosshair ammo from displaying
16 self.clip_load = self.hlac_load;
17 self.clip_size = autocvar_g_balance_hlac_reload_ammo; // for the crosshair ammo display
21 void W_HLAC_ReloadedAndReady()
25 // now do the ammo transfer
26 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
27 while(self.clip_load < autocvar_g_balance_hlac_reload_ammo && self.ammo_cells) // make sure we don't add more ammo than we have
32 self.hlac_load = self.clip_load;
34 t = ATTACK_FINISHED(self) - autocvar_g_balance_hlac_reload_time - 1;
35 ATTACK_FINISHED(self) = t;
41 // return if reloading is disabled for this weapon
42 if(!autocvar_g_balance_hlac_reload_ammo)
45 if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_secondary_ammo)))
50 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
52 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_hlac_reload_time + 1;
53 ATTACK_FINISHED(self) = t;
55 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_hlac_reload_time, W_HLAC_ReloadedAndReady);
57 self.old_clip_load = self.clip_load;
61 void W_HLAC_Touch (void)
65 self.event_damage = SUB_Null;
67 if(self.projectiledeathtype & HITTYPE_SECONDARY)
68 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);
70 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);
75 void W_HLAC_Attack (void)
80 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
81 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
83 if(autocvar_g_balance_hlac_reload_ammo)
85 self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
86 self.hlac_load = self.clip_load;
89 self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
92 spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter);
93 spread = min(spread,autocvar_g_balance_hlac_primary_spread_max);
95 spread = spread * autocvar_g_balance_hlac_primary_spread_crouchmod;
97 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_primary_damage);
98 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
101 self.punchangle_x = random () - 0.5;
102 self.punchangle_y = random () - 0.5;
106 missile.owner = self;
107 missile.classname = "hlacbolt";
108 missile.bot_dodge = TRUE;
110 missile.bot_dodgerating = autocvar_g_balance_hlac_primary_damage;
112 missile.movetype = MOVETYPE_FLY;
113 PROJECTILE_MAKETRIGGER(missile);
115 setorigin (missile, w_shotorg);
116 setsize(missile, '0 0 0', '0 0 0');
118 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_primary_speed, spread);
119 //missile.angles = vectoangles (missile.velocity); // csqc
121 missile.touch = W_HLAC_Touch;
122 missile.think = SUB_Remove;
124 missile.nextthink = time + autocvar_g_balance_hlac_primary_lifetime;
126 missile.flags = FL_PROJECTILE;
127 missile.projectiledeathtype = WEP_HLAC;
129 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
131 other = missile; MUTATOR_CALLHOOK(EditProjectile);
134 void W_HLAC_Attack2f (void)
136 local entity missile;
139 spread = autocvar_g_balance_hlac_secondary_spread;
143 spread = spread * autocvar_g_balance_hlac_secondary_spread_crouchmod;
145 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_secondary_damage);
146 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
149 missile.owner = self;
150 missile.classname = "hlacbolt";
151 missile.bot_dodge = TRUE;
153 missile.bot_dodgerating = autocvar_g_balance_hlac_secondary_damage;
155 missile.movetype = MOVETYPE_FLY;
156 PROJECTILE_MAKETRIGGER(missile);
158 setorigin (missile, w_shotorg);
159 setsize(missile, '0 0 0', '0 0 0');
161 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_secondary_speed, spread);
162 //missile.angles = vectoangles (missile.velocity); // csqc
164 missile.touch = W_HLAC_Touch;
165 missile.think = SUB_Remove;
167 missile.nextthink = time + autocvar_g_balance_hlac_secondary_lifetime;
169 missile.flags = FL_PROJECTILE;
170 missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
172 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
174 other = missile; MUTATOR_CALLHOOK(EditProjectile);
177 void W_HLAC_Attack2 (void)
181 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
182 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
184 if(autocvar_g_balance_hlac_reload_ammo)
186 self.clip_load -= autocvar_g_balance_hlac_secondary_ammo;
187 self.hlac_load = self.clip_load;
190 self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo;
193 for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
198 self.punchangle_x = random () - 0.5;
199 self.punchangle_y = random () - 0.5;
206 if(self.weapon != self.switchweapon) // abort immediately if switching
212 if (self.BUTTON_ATCK)
214 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
216 W_SwitchWeapon_Force(self, w_getbestweapon(self));
221 ATTACK_FINISHED(self) = time + autocvar_g_balance_hlac_primary_refire * W_WeaponRateFactor();
223 self.misc_bulletcounter = self.misc_bulletcounter + 1;
224 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
228 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_animtime, w_ready);
232 void spawnfunc_weapon_hlac (void)
234 weapon_defaultspawnfunc(WEP_HLAC);
237 float w_hlac(float req)
241 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hlac_primary_speed, 0, autocvar_g_balance_hlac_primary_lifetime, FALSE);
242 else if (req == WR_THINK)
244 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
246 else if (self.BUTTON_ATCK)
248 if (weapon_prepareattack(0, autocvar_g_balance_hlac_primary_refire))
250 self.misc_bulletcounter = 0;
252 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
256 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hlac_secondary)
258 if (weapon_prepareattack(1, autocvar_g_balance_hlac_secondary_refire))
261 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hlac_secondary_animtime, w_ready);
265 else if (req == WR_PRECACHE)
267 precache_model ("models/weapons/g_hlac.md3");
268 precache_model ("models/weapons/v_hlac.md3");
269 precache_model ("models/weapons/h_hlac.iqm");
270 precache_sound ("weapons/lasergun_fire.wav");
271 precache_sound ("weapons/reload.wav");
274 else if (req == WR_SETUP)
276 weapon_setup(WEP_HLAC);
277 W_HLAC_SetAmmoCounter();
279 else if (req == WR_CHECKAMMO1)
281 ammo_amount = self.ammo_cells >= autocvar_g_balance_hlac_primary_ammo;
282 ammo_amount += self.hlac_load >= autocvar_g_balance_hlac_primary_ammo;
285 else if (req == WR_CHECKAMMO2)
287 ammo_amount = self.ammo_cells >= autocvar_g_balance_hlac_secondary_ammo;
288 ammo_amount += self.hlac_load >= autocvar_g_balance_hlac_secondary_ammo;
291 else if (req == WR_RESETPLAYER)
293 // all weapons must be fully loaded when we spawn
294 self.hlac_load = autocvar_g_balance_hlac_reload_ammo;
296 else if (req == WR_RELOAD)
304 float w_hlac(float req)
306 if(req == WR_IMPACTEFFECT)
309 org2 = w_org + w_backoff * 6;
310 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
312 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
314 else if(req == WR_PRECACHE)
316 precache_sound("weapons/laserimpact.wav");
318 else if (req == WR_SUICIDEMESSAGE)
319 w_deathtypestring = _("%s should have used a smaller gun");
320 else if (req == WR_KILLMESSAGE)
321 w_deathtypestring = _("%s was cut down by %s");