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 /* model */ MDL_HLAC_ITEM,
12 /* simplemdl */ "foobar",
13 /* crosshair */ "gfx/crosshairhlac 0.6",
14 /* wepimg */ "weaponhlac",
16 /* wepname */ _("Heavy Laser Assault Cannon")
19 #define HLAC_SETTINGS(w_cvar,w_prop) HLAC_SETTINGS_LIST(w_cvar, w_prop, HLAC, hlac)
20 #define HLAC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
21 w_cvar(id, sn, BOTH, ammo) \
22 w_cvar(id, sn, BOTH, animtime) \
23 w_cvar(id, sn, BOTH, damage) \
24 w_cvar(id, sn, BOTH, edgedamage) \
25 w_cvar(id, sn, BOTH, force) \
26 w_cvar(id, sn, BOTH, lifetime) \
27 w_cvar(id, sn, BOTH, radius) \
28 w_cvar(id, sn, BOTH, refire) \
29 w_cvar(id, sn, BOTH, speed) \
30 w_cvar(id, sn, BOTH, spread_crouchmod) \
31 w_cvar(id, sn, PRI, spread_add) \
32 w_cvar(id, sn, PRI, spread_max) \
33 w_cvar(id, sn, PRI, spread_min) \
34 w_cvar(id, sn, NONE, secondary) \
35 w_cvar(id, sn, SEC, shots) \
36 w_cvar(id, sn, SEC, spread) \
37 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
38 w_prop(id, sn, float, reloading_time, reload_time) \
39 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
40 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
41 w_prop(id, sn, string, weaponreplace, weaponreplace) \
42 w_prop(id, sn, float, weaponstart, weaponstart) \
43 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
44 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
47 HLAC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
52 void spawnfunc_weapon_hlac(void) { weapon_defaultspawnfunc(WEP_HLAC.m_id); }
54 void W_HLAC_Touch(void)
60 self.event_damage = func_null;
62 isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY);
64 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);
69 void W_HLAC_Attack(void)
74 W_DecreaseAmmo(WEP_CVAR_PRI(hlac, ammo));
76 spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * self.misc_bulletcounter);
77 spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
79 spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
81 W_SetupShot(self, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage));
82 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
83 if(!autocvar_g_norecoil)
85 self.punchangle_x = random() - 0.5;
86 self.punchangle_y = random() - 0.5;
90 missile.owner = missile.realowner = self;
91 missile.classname = "hlacbolt";
92 missile.bot_dodge = true;
94 missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage);
96 missile.movetype = MOVETYPE_FLY;
97 PROJECTILE_MAKETRIGGER(missile);
99 setorigin(missile, w_shotorg);
100 setsize(missile, '0 0 0', '0 0 0');
102 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
103 //missile.angles = vectoangles(missile.velocity); // csqc
105 missile.touch = W_HLAC_Touch;
106 missile.think = SUB_Remove;
108 missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
110 missile.flags = FL_PROJECTILE;
111 missile.projectiledeathtype = WEP_HLAC.m_id;
113 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
115 MUTATOR_CALLHOOK(EditProjectile, self, missile);
118 void W_HLAC_Attack2(void)
123 spread = WEP_CVAR_SEC(hlac, spread);
127 spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
129 W_SetupShot(self, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage));
130 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
133 missile.owner = missile.realowner = self;
134 missile.classname = "hlacbolt";
135 missile.bot_dodge = true;
137 missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage);
139 missile.movetype = MOVETYPE_FLY;
140 PROJECTILE_MAKETRIGGER(missile);
142 setorigin(missile, w_shotorg);
143 setsize(missile, '0 0 0', '0 0 0');
145 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
146 //missile.angles = vectoangles(missile.velocity); // csqc
148 missile.touch = W_HLAC_Touch;
149 missile.think = SUB_Remove;
151 missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
153 missile.flags = FL_PROJECTILE;
154 missile.missile_flags = MIF_SPLASH;
155 missile.projectiledeathtype = WEP_HLAC.m_id | HITTYPE_SECONDARY;
157 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
159 MUTATOR_CALLHOOK(EditProjectile, self, missile);
163 void W_HLAC_Attack_Frame(void)
165 if(self.weapon != self.switchweapon) // abort immediately if switching
173 if(!_WEP_ACTION(self.weapon, WR_CHECKAMMO1))
174 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
176 W_SwitchWeapon_Force(self, w_getbestweapon(self));
181 ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor();
183 self.misc_bulletcounter = self.misc_bulletcounter + 1;
184 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
188 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
192 void W_HLAC_Attack2_Frame(void)
196 W_DecreaseAmmo(WEP_CVAR_SEC(hlac, ammo));
198 for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
201 if(!autocvar_g_norecoil)
203 self.punchangle_x = random() - 0.5;
204 self.punchangle_y = random() - 0.5;
208 bool W_HLAC(entity thiswep, int req)
215 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
220 if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) // forced reload
221 _WEP_ACTION(self.weapon, WR_RELOAD);
222 else if(self.BUTTON_ATCK)
224 if(weapon_prepareattack(0, WEP_CVAR_PRI(hlac, refire)))
226 self.misc_bulletcounter = 0;
228 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
232 else if(self.BUTTON_ATCK2 && WEP_CVAR(hlac, secondary))
234 if(weapon_prepareattack(1, WEP_CVAR_SEC(hlac, refire)))
236 W_HLAC_Attack2_Frame();
237 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
245 HLAC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
250 ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_PRI(hlac, ammo);
251 ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
256 ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_SEC(hlac, ammo);
257 ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
262 HLAC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
267 W_Reload(min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND(RELOAD));
270 case WR_SUICIDEMESSAGE:
272 return WEAPON_HLAC_SUICIDE;
276 return WEAPON_HLAC_MURDER;
283 bool W_HLAC(entity thiswep, int req)
287 case WR_IMPACTEFFECT:
290 org2 = w_org + w_backoff * 6;
291 pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
293 sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM);
303 // no weapon specific image for this weapon