5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
10 /* modelname */ "hlac",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairhlac 0.6",
13 /* wepimg */ "weaponhlac",
15 /* wepname */ _("Heavy Laser Assault Cannon")
18 #define HLAC_SETTINGS(w_cvar,w_prop) HLAC_SETTINGS_LIST(w_cvar, w_prop, HLAC, hlac)
19 #define HLAC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20 w_cvar(id, sn, BOTH, ammo) \
21 w_cvar(id, sn, BOTH, animtime) \
22 w_cvar(id, sn, BOTH, damage) \
23 w_cvar(id, sn, BOTH, edgedamage) \
24 w_cvar(id, sn, BOTH, force) \
25 w_cvar(id, sn, BOTH, lifetime) \
26 w_cvar(id, sn, BOTH, radius) \
27 w_cvar(id, sn, BOTH, refire) \
28 w_cvar(id, sn, BOTH, speed) \
29 w_cvar(id, sn, BOTH, spread_crouchmod) \
30 w_cvar(id, sn, PRI, spread_add) \
31 w_cvar(id, sn, PRI, spread_max) \
32 w_cvar(id, sn, PRI, spread_min) \
33 w_cvar(id, sn, NONE, secondary) \
34 w_cvar(id, sn, SEC, shots) \
35 w_cvar(id, sn, SEC, spread) \
36 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
37 w_prop(id, sn, float, reloading_time, reload_time) \
38 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
39 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
40 w_prop(id, sn, string, weaponreplace, weaponreplace) \
41 w_prop(id, sn, float, weaponstart, weaponstart) \
42 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
45 HLAC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
49 void spawnfunc_weapon_hlac() { weapon_defaultspawnfunc(WEP_HLAC); }
51 void W_HLAC_Touch (void)
57 self.event_damage = func_null;
59 isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY);
61 RadiusDamage(self, self.realowner, WEP_CVAR_BOTH(hlac, isprimary, damage), WEP_CVAR_BOTH(hlac, isprimary, edgedamage), WEP_CVAR_BOTH(hlac, isprimary, radius), world, world, WEP_CVAR_BOTH(hlac, isprimary, force), self.projectiledeathtype, other);
66 void W_HLAC_Attack (void)
71 W_DecreaseAmmo(WEP_CVAR_PRI(hlac, ammo));
73 spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * self.misc_bulletcounter);
74 spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
76 spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
78 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage));
79 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
80 if (!autocvar_g_norecoil)
82 self.punchangle_x = random () - 0.5;
83 self.punchangle_y = random () - 0.5;
87 missile.owner = missile.realowner = self;
88 missile.classname = "hlacbolt";
89 missile.bot_dodge = TRUE;
91 missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage);
93 missile.movetype = MOVETYPE_FLY;
94 PROJECTILE_MAKETRIGGER(missile);
96 setorigin (missile, w_shotorg);
97 setsize(missile, '0 0 0', '0 0 0');
99 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
100 //missile.angles = vectoangles (missile.velocity); // csqc
102 missile.touch = W_HLAC_Touch;
103 missile.think = SUB_Remove;
105 missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
107 missile.flags = FL_PROJECTILE;
108 missile.projectiledeathtype = WEP_HLAC;
110 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
112 other = missile; MUTATOR_CALLHOOK(EditProjectile);
115 void W_HLAC_Attack2()
120 spread = WEP_CVAR_SEC(hlac, spread);
124 spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
126 W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage));
127 pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
130 missile.owner = missile.realowner = self;
131 missile.classname = "hlacbolt";
132 missile.bot_dodge = TRUE;
134 missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage);
136 missile.movetype = MOVETYPE_FLY;
137 PROJECTILE_MAKETRIGGER(missile);
139 setorigin (missile, w_shotorg);
140 setsize(missile, '0 0 0', '0 0 0');
142 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
143 //missile.angles = vectoangles (missile.velocity); // csqc
145 missile.touch = W_HLAC_Touch;
146 missile.think = SUB_Remove;
148 missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
150 missile.flags = FL_PROJECTILE;
151 missile.missile_flags = MIF_SPLASH;
152 missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
154 CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
156 other = missile; MUTATOR_CALLHOOK(EditProjectile);
160 void W_HLAC_Attack_Frame()
162 if(self.weapon != self.switchweapon) // abort immediately if switching
168 if (self.BUTTON_ATCK)
170 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1))
171 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
173 W_SwitchWeapon_Force(self, w_getbestweapon(self));
178 ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor();
180 self.misc_bulletcounter = self.misc_bulletcounter + 1;
181 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
185 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
189 void W_HLAC_Attack2_Frame()
193 W_DecreaseAmmo(WEP_CVAR_SEC(hlac, ammo));
195 for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
198 if (!autocvar_g_norecoil)
200 self.punchangle_x = random () - 0.5;
201 self.punchangle_y = random () - 0.5;
205 float W_HLAC(float req)
212 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), FALSE);
217 if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) // forced reload
218 WEP_ACTION(self.weapon, WR_RELOAD);
219 else if (self.BUTTON_ATCK)
221 if (weapon_prepareattack(0, WEP_CVAR_PRI(hlac, refire)))
223 self.misc_bulletcounter = 0;
225 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
229 else if (self.BUTTON_ATCK2 && WEP_CVAR(hlac, secondary))
231 if (weapon_prepareattack(1, WEP_CVAR_SEC(hlac, refire)))
233 W_HLAC_Attack2_Frame();
234 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
242 precache_model ("models/weapons/g_hlac.md3");
243 precache_model ("models/weapons/v_hlac.md3");
244 precache_model ("models/weapons/h_hlac.iqm");
245 precache_sound ("weapons/lasergun_fire.wav");
246 HLAC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
251 ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_PRI(hlac, ammo);
252 ammo_amount += self.(weapon_load[WEP_HLAC]) >= WEP_CVAR_PRI(hlac, ammo);
257 ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_SEC(hlac, ammo);
258 ammo_amount += self.(weapon_load[WEP_HLAC]) >= WEP_CVAR_SEC(hlac, ammo);
263 HLAC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
268 W_Reload(min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), "weapons/reload.wav");
271 case WR_SUICIDEMESSAGE:
273 return WEAPON_HLAC_SUICIDE;
277 return WEAPON_HLAC_MURDER;
284 float W_HLAC(float req)
288 case WR_IMPACTEFFECT:
291 org2 = w_org + w_backoff * 6;
292 pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
294 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
300 precache_sound("weapons/laserimpact.wav");
305 // no weapon specific image for this weapon