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
23 self.reload_ammo_player = ammo_fuel;
24 self.reload_ammo_min = min(autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_secondary_ammo);
25 self.reload_ammo_amount = autocvar_g_balance_hlac_reload_ammo;
26 self.reload_time = autocvar_g_balance_hlac_reload_time;
27 self.reload_sound = "weapons/reload.wav";
32 void W_HLAC_Touch (void)
36 self.event_damage = SUB_Null;
38 if(self.projectiledeathtype & HITTYPE_SECONDARY)
39 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);
41 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);
46 void W_HLAC_Attack (void)
51 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
52 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
54 if(autocvar_g_balance_hlac_reload_ammo)
56 self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
57 self.hlac_load = self.clip_load;
60 self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
63 spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter);
64 spread = min(spread,autocvar_g_balance_hlac_primary_spread_max);
66 spread = spread * autocvar_g_balance_hlac_primary_spread_crouchmod;
68 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_primary_damage);
69 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
72 self.punchangle_x = random () - 0.5;
73 self.punchangle_y = random () - 0.5;
78 missile.classname = "hlacbolt";
79 missile.bot_dodge = TRUE;
81 missile.bot_dodgerating = autocvar_g_balance_hlac_primary_damage;
83 missile.movetype = MOVETYPE_FLY;
84 PROJECTILE_MAKETRIGGER(missile);
86 setorigin (missile, w_shotorg);
87 setsize(missile, '0 0 0', '0 0 0');
89 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_primary_speed, spread);
90 //missile.angles = vectoangles (missile.velocity); // csqc
92 missile.touch = W_HLAC_Touch;
93 missile.think = SUB_Remove;
95 missile.nextthink = time + autocvar_g_balance_hlac_primary_lifetime;
97 missile.flags = FL_PROJECTILE;
98 missile.projectiledeathtype = WEP_HLAC;
100 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
102 other = missile; MUTATOR_CALLHOOK(EditProjectile);
105 void W_HLAC_Attack2f (void)
107 local entity missile;
110 spread = autocvar_g_balance_hlac_secondary_spread;
114 spread = spread * autocvar_g_balance_hlac_secondary_spread_crouchmod;
116 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CHAN_WEAPON, autocvar_g_balance_hlac_secondary_damage);
117 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
120 missile.owner = self;
121 missile.classname = "hlacbolt";
122 missile.bot_dodge = TRUE;
124 missile.bot_dodgerating = autocvar_g_balance_hlac_secondary_damage;
126 missile.movetype = MOVETYPE_FLY;
127 PROJECTILE_MAKETRIGGER(missile);
129 setorigin (missile, w_shotorg);
130 setsize(missile, '0 0 0', '0 0 0');
132 W_SetupProjectileVelocity(missile, autocvar_g_balance_hlac_secondary_speed, spread);
133 //missile.angles = vectoangles (missile.velocity); // csqc
135 missile.touch = W_HLAC_Touch;
136 missile.think = SUB_Remove;
138 missile.nextthink = time + autocvar_g_balance_hlac_secondary_lifetime;
140 missile.flags = FL_PROJECTILE;
141 missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
143 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
145 other = missile; MUTATOR_CALLHOOK(EditProjectile);
148 void W_HLAC_Attack2 (void)
152 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
153 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
155 if(autocvar_g_balance_hlac_reload_ammo)
157 self.clip_load -= autocvar_g_balance_hlac_secondary_ammo;
158 self.hlac_load = self.clip_load;
161 self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo;
164 for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
169 self.punchangle_x = random () - 0.5;
170 self.punchangle_y = random () - 0.5;
177 if(self.weapon != self.switchweapon) // abort immediately if switching
183 if (self.BUTTON_ATCK)
185 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
187 W_SwitchWeapon_Force(self, w_getbestweapon(self));
192 ATTACK_FINISHED(self) = time + autocvar_g_balance_hlac_primary_refire * W_WeaponRateFactor();
194 self.misc_bulletcounter = self.misc_bulletcounter + 1;
195 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
199 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_animtime, w_ready);
203 void spawnfunc_weapon_hlac (void)
205 weapon_defaultspawnfunc(WEP_HLAC);
208 float w_hlac(float req)
212 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hlac_primary_speed, 0, autocvar_g_balance_hlac_primary_lifetime, FALSE);
213 else if (req == WR_THINK)
215 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
217 else if (self.BUTTON_ATCK)
219 if (weapon_prepareattack(0, autocvar_g_balance_hlac_primary_refire))
221 self.misc_bulletcounter = 0;
223 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hlac_primary_refire, HLAC_fire1_02);
227 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hlac_secondary)
229 if (weapon_prepareattack(1, autocvar_g_balance_hlac_secondary_refire))
232 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hlac_secondary_animtime, w_ready);
236 else if (req == WR_PRECACHE)
238 precache_model ("models/weapons/g_hlac.md3");
239 precache_model ("models/weapons/v_hlac.md3");
240 precache_model ("models/weapons/h_hlac.iqm");
241 precache_sound ("weapons/lasergun_fire.wav");
242 precache_sound ("weapons/reload.wav");
245 else if (req == WR_SETUP)
247 weapon_setup(WEP_HLAC);
248 W_HLAC_SetAmmoCounter();
250 else if (req == WR_CHECKAMMO1)
252 ammo_amount = self.ammo_cells >= autocvar_g_balance_hlac_primary_ammo;
253 ammo_amount += self.hlac_load >= autocvar_g_balance_hlac_primary_ammo;
256 else if (req == WR_CHECKAMMO2)
258 ammo_amount = self.ammo_cells >= autocvar_g_balance_hlac_secondary_ammo;
259 ammo_amount += self.hlac_load >= autocvar_g_balance_hlac_secondary_ammo;
262 else if (req == WR_RESETPLAYER)
264 // all weapons must be fully loaded when we spawn
265 self.hlac_load = autocvar_g_balance_hlac_reload_ammo;
267 else if (req == WR_RELOAD)
275 float w_hlac(float req)
277 if(req == WR_IMPACTEFFECT)
280 org2 = w_org + w_backoff * 6;
281 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
283 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
285 else if(req == WR_PRECACHE)
287 precache_sound("weapons/laserimpact.wav");
289 else if (req == WR_SUICIDEMESSAGE)
290 w_deathtypestring = _("%s should have used a smaller gun");
291 else if (req == WR_KILLMESSAGE)
292 w_deathtypestring = _("%s was cut down by %s");