5 void W_HLAC_Touch(entity this, entity toucher)
9 PROJECTILE_TOUCH(this, toucher);
11 this.event_damage = func_null;
13 isprimary = !(this.projectiledeathtype & HITTYPE_SECONDARY);
15 RadiusDamage(this, this.realowner, WEP_CVAR_BOTH(hlac, isprimary, damage), WEP_CVAR_BOTH(hlac, isprimary, edgedamage), WEP_CVAR_BOTH(hlac, isprimary, radius),
16 NULL, NULL, WEP_CVAR_BOTH(hlac, isprimary, force), this.projectiledeathtype, this.weaponentity_fld, toucher);
21 void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity)
25 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hlac, ammo), weaponentity);
27 float spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * actor.(weaponentity).misc_bulletcounter);
28 spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
30 spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
32 W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage), thiswep.m_id);
33 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
34 if(!autocvar_g_norecoil)
36 actor.punchangle_x = random() - 0.5;
37 actor.punchangle_y = random() - 0.5;
40 missile = new(hlacbolt);
41 missile.owner = missile.realowner = actor;
42 missile.bot_dodge = true;
44 missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage);
46 set_movetype(missile, MOVETYPE_FLY);
47 PROJECTILE_MAKETRIGGER(missile);
49 setorigin(missile, w_shotorg);
50 setsize(missile, '0 0 0', '0 0 0');
52 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
53 //missile.angles = vectoangles(missile.velocity); // csqc
55 settouch(missile, W_HLAC_Touch);
56 setthink(missile, SUB_Remove);
58 missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
60 missile.flags = FL_PROJECTILE;
61 IL_PUSH(g_projectiles, missile);
62 IL_PUSH(g_bot_dodge, missile);
63 missile.projectiledeathtype = thiswep.m_id;
64 missile.weaponentity_fld = weaponentity;
66 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
68 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
71 void W_HLAC_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
74 float spread = WEP_CVAR_SEC(hlac, spread);
77 spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
79 W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage), thiswep.m_id | HITTYPE_SECONDARY);
80 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
82 missile = new(hlacbolt);
83 missile.owner = missile.realowner = actor;
84 missile.bot_dodge = true;
86 missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage);
88 set_movetype(missile, MOVETYPE_FLY);
89 PROJECTILE_MAKETRIGGER(missile);
91 setorigin(missile, w_shotorg);
92 setsize(missile, '0 0 0', '0 0 0');
94 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
95 //missile.angles = vectoangles(missile.velocity); // csqc
97 settouch(missile, W_HLAC_Touch);
98 setthink(missile, SUB_Remove);
100 missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
102 missile.flags = FL_PROJECTILE;
103 IL_PUSH(g_projectiles, missile);
104 IL_PUSH(g_bot_dodge, missile);
105 missile.missile_flags = MIF_SPLASH;
106 missile.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
107 missile.weaponentity_fld = weaponentity;
109 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
111 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
115 void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int fire)
117 if(actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon) // abort immediately if switching
119 w_ready(thiswep, actor, weaponentity, fire);
123 if(PHYS_INPUT_BUTTON_ATCK(actor))
125 if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
126 if(!(actor.items & IT_UNLIMITED_AMMO))
128 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
129 w_ready(thiswep, actor, weaponentity, fire);
133 ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
134 W_HLAC_Attack(thiswep, actor, weaponentity);
135 actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
136 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
140 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
144 void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity)
146 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hlac, ammo), weaponentity);
148 for(float i = WEP_CVAR_SEC(hlac, shots); i > 0; --i)
149 W_HLAC_Attack2(thiswep, actor, weaponentity);
151 if(!autocvar_g_norecoil)
153 actor.punchangle_x = random() - 0.5;
154 actor.punchangle_y = random() - 0.5;
158 METHOD(HLAC, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
160 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
162 METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
164 if(autocvar_g_balance_hlac_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
165 thiswep.wr_reload(thiswep, actor, weaponentity);
168 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
170 actor.(weaponentity).misc_bulletcounter = 0;
171 W_HLAC_Attack(thiswep, actor, weaponentity);
172 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
176 else if((fire & 2) && WEP_CVAR(hlac, secondary))
178 if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire)))
180 W_HLAC_Attack2_Frame(thiswep, actor, weaponentity);
181 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
185 METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
187 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hlac, ammo);
188 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
191 METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
193 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hlac, ammo);
194 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
197 METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
199 W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
201 METHOD(HLAC, wr_suicidemessage, Notification(entity thiswep))
203 return WEAPON_HLAC_SUICIDE;
205 METHOD(HLAC, wr_killmessage, Notification(entity thiswep))
207 return WEAPON_HLAC_MURDER;
213 METHOD(HLAC, wr_impacteffect, void(entity thiswep, entity actor))
216 org2 = w_org + w_backoff * 6;
217 pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
219 sound(actor, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM);