3 /* ammotype */ ATTRIB(HLAC, ammo_field, .int, ammo_cells)
4 /* impulse */ ATTRIB(HLAC, impulse, int, 6)
5 /* flags */ ATTRIB(HLAC, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH);
6 /* rating */ ATTRIB(HLAC, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
7 /* color */ ATTRIB(HLAC, wpcolor, vector, '0 1 0');
8 /* modelname */ ATTRIB(HLAC, mdl, string, "hlac");
10 /* model */ ATTRIB(HLAC, m_model, Model, MDL_HLAC_ITEM);
12 /* crosshair */ ATTRIB(HLAC, w_crosshair, string, "gfx/crosshairhlac");
13 /* crosshair */ ATTRIB(HLAC, w_crosshair_size, float, 0.6);
14 /* wepimg */ ATTRIB(HLAC, model2, string, "weaponhlac");
15 /* refname */ ATTRIB(HLAC, netname, string, "hlac");
16 /* wepname */ ATTRIB(HLAC, message, string, _("Heavy Laser Assault Cannon"));
18 REGISTER_WEAPON(HLAC, NEW(HLAC));
20 #define HLAC_SETTINGS(w_cvar,w_prop) HLAC_SETTINGS_LIST(w_cvar, w_prop, HLAC, hlac)
21 #define HLAC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
22 w_cvar(id, sn, BOTH, ammo) \
23 w_cvar(id, sn, BOTH, animtime) \
24 w_cvar(id, sn, BOTH, damage) \
25 w_cvar(id, sn, BOTH, edgedamage) \
26 w_cvar(id, sn, BOTH, force) \
27 w_cvar(id, sn, BOTH, lifetime) \
28 w_cvar(id, sn, BOTH, radius) \
29 w_cvar(id, sn, BOTH, refire) \
30 w_cvar(id, sn, BOTH, speed) \
31 w_cvar(id, sn, BOTH, spread_crouchmod) \
32 w_cvar(id, sn, PRI, spread_add) \
33 w_cvar(id, sn, PRI, spread_max) \
34 w_cvar(id, sn, PRI, spread_min) \
35 w_cvar(id, sn, NONE, secondary) \
36 w_cvar(id, sn, SEC, shots) \
37 w_cvar(id, sn, SEC, spread) \
38 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
39 w_prop(id, sn, float, reloading_time, reload_time) \
40 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
41 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
42 w_prop(id, sn, string, weaponreplace, weaponreplace) \
43 w_prop(id, sn, float, weaponstart, weaponstart) \
44 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
45 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
48 HLAC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
53 void spawnfunc_weapon_hlac(void) { weapon_defaultspawnfunc(WEP_HLAC.m_id); }
55 void W_HLAC_Touch(void)
61 self.event_damage = func_null;
63 isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY);
65 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);
70 void W_HLAC_Attack(void)
75 W_DecreaseAmmo(WEP_CVAR_PRI(hlac, ammo));
77 spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * self.misc_bulletcounter);
78 spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
80 spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
82 W_SetupShot(self, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage));
83 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
84 if(!autocvar_g_norecoil)
86 self.punchangle_x = random() - 0.5;
87 self.punchangle_y = random() - 0.5;
91 missile.owner = missile.realowner = self;
92 missile.classname = "hlacbolt";
93 missile.bot_dodge = true;
95 missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage);
97 missile.movetype = MOVETYPE_FLY;
98 PROJECTILE_MAKETRIGGER(missile);
100 setorigin(missile, w_shotorg);
101 setsize(missile, '0 0 0', '0 0 0');
103 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
104 //missile.angles = vectoangles(missile.velocity); // csqc
106 missile.touch = W_HLAC_Touch;
107 missile.think = SUB_Remove;
109 missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
111 missile.flags = FL_PROJECTILE;
112 missile.projectiledeathtype = WEP_HLAC.m_id;
114 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
116 MUTATOR_CALLHOOK(EditProjectile, self, missile);
119 void W_HLAC_Attack2(void)
124 spread = WEP_CVAR_SEC(hlac, spread);
128 spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
130 W_SetupShot(self, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage));
131 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
134 missile.owner = missile.realowner = self;
135 missile.classname = "hlacbolt";
136 missile.bot_dodge = true;
138 missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage);
140 missile.movetype = MOVETYPE_FLY;
141 PROJECTILE_MAKETRIGGER(missile);
143 setorigin(missile, w_shotorg);
144 setsize(missile, '0 0 0', '0 0 0');
146 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
147 //missile.angles = vectoangles(missile.velocity); // csqc
149 missile.touch = W_HLAC_Touch;
150 missile.think = SUB_Remove;
152 missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
154 missile.flags = FL_PROJECTILE;
155 missile.missile_flags = MIF_SPLASH;
156 missile.projectiledeathtype = WEP_HLAC.m_id | HITTYPE_SECONDARY;
158 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
160 MUTATOR_CALLHOOK(EditProjectile, self, missile);
164 void W_HLAC_Attack_Frame(void)
166 if(self.weapon != self.switchweapon) // abort immediately if switching
174 if(!_WEP_ACTION(self.weapon, WR_CHECKAMMO1))
175 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
177 W_SwitchWeapon_Force(self, w_getbestweapon(self));
182 ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor();
184 self.misc_bulletcounter = self.misc_bulletcounter + 1;
185 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
189 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
193 void W_HLAC_Attack2_Frame(void)
197 W_DecreaseAmmo(WEP_CVAR_SEC(hlac, ammo));
199 for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
202 if(!autocvar_g_norecoil)
204 self.punchangle_x = random() - 0.5;
205 self.punchangle_y = random() - 0.5;
209 METHOD(HLAC, wr_aim, bool(entity thiswep))
211 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
214 METHOD(HLAC, wr_think, bool(entity thiswep, bool fire1, bool fire2))
216 if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) // forced reload
217 _WEP_ACTION(self.weapon, WR_RELOAD);
220 if(weapon_prepareattack(0, WEP_CVAR_PRI(hlac, refire)))
222 self.misc_bulletcounter = 0;
224 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
228 else if(fire2 && WEP_CVAR(hlac, secondary))
230 if(weapon_prepareattack(1, WEP_CVAR_SEC(hlac, refire)))
232 W_HLAC_Attack2_Frame();
233 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
239 METHOD(HLAC, wr_init, bool(entity thiswep))
241 HLAC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
244 METHOD(HLAC, wr_checkammo1, bool(entity thiswep))
246 float ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_PRI(hlac, ammo);
247 ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
250 METHOD(HLAC, wr_checkammo2, bool(entity thiswep))
252 float ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_SEC(hlac, ammo);
253 ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
256 METHOD(HLAC, wr_config, bool(entity thiswep))
258 HLAC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
261 METHOD(HLAC, wr_reload, bool(entity thiswep))
263 W_Reload(min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND(RELOAD));
266 METHOD(HLAC, wr_suicidemessage, bool(entity thiswep))
268 return WEAPON_HLAC_SUICIDE;
270 METHOD(HLAC, wr_killmessage, bool(entity thiswep))
272 return WEAPON_HLAC_MURDER;
278 METHOD(HLAC, wr_impacteffect, bool(entity thiswep))
281 org2 = w_org + w_backoff * 6;
282 pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
284 sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM);
288 METHOD(HLAC, wr_init, bool(entity thiswep))
292 METHOD(HLAC, wr_zoomreticle, bool(entity thiswep))
294 // no weapon specific image for this weapon