5 METHOD(HLAC, m_spawnfunc_hookreplace, Weapon(HLAC this, entity e))
7 if (autocvar_g_weapon_noncore_allow && !Item_IsLoot(e) && (this.spawnflags & WEP_FLAG_MUTATORBLOCKED))
14 void W_HLAC_Touch(entity this, entity toucher)
18 PROJECTILE_TOUCH(this, toucher);
20 this.event_damage = func_null;
22 isprimary = !(this.projectiledeathtype & HITTYPE_SECONDARY);
24 RadiusDamage(this, this.realowner, WEP_CVAR_BOTH(hlac, isprimary, damage), WEP_CVAR_BOTH(hlac, isprimary, edgedamage), WEP_CVAR_BOTH(hlac, isprimary, radius),
25 NULL, NULL, WEP_CVAR_BOTH(hlac, isprimary, force), this.projectiledeathtype, this.weaponentity_fld, toucher);
30 void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity)
35 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hlac, ammo), weaponentity);
37 spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * actor.(weaponentity).misc_bulletcounter);
38 spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
40 spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
42 W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage), thiswep.m_id);
43 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
44 if(!autocvar_g_norecoil)
46 actor.punchangle_x = random() - 0.5;
47 actor.punchangle_y = random() - 0.5;
50 missile = new(hlacbolt);
51 missile.owner = missile.realowner = actor;
52 missile.bot_dodge = true;
54 missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage);
56 set_movetype(missile, MOVETYPE_FLY);
57 PROJECTILE_MAKETRIGGER(missile);
59 setorigin(missile, w_shotorg);
60 setsize(missile, '0 0 0', '0 0 0');
62 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
63 //missile.angles = vectoangles(missile.velocity); // csqc
65 settouch(missile, W_HLAC_Touch);
66 setthink(missile, SUB_Remove);
68 missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
70 missile.flags = FL_PROJECTILE;
71 IL_PUSH(g_projectiles, missile);
72 IL_PUSH(g_bot_dodge, missile);
73 missile.projectiledeathtype = thiswep.m_id;
74 missile.weaponentity_fld = weaponentity;
76 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
78 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
81 void W_HLAC_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
86 spread = WEP_CVAR_SEC(hlac, spread);
90 spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
92 W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage), thiswep.m_id | HITTYPE_SECONDARY);
93 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
95 missile = new(hlacbolt);
96 missile.owner = missile.realowner = actor;
97 missile.bot_dodge = true;
99 missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage);
101 set_movetype(missile, MOVETYPE_FLY);
102 PROJECTILE_MAKETRIGGER(missile);
104 setorigin(missile, w_shotorg);
105 setsize(missile, '0 0 0', '0 0 0');
107 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
108 //missile.angles = vectoangles(missile.velocity); // csqc
110 settouch(missile, W_HLAC_Touch);
111 setthink(missile, SUB_Remove);
113 missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
115 missile.flags = FL_PROJECTILE;
116 IL_PUSH(g_projectiles, missile);
117 IL_PUSH(g_bot_dodge, missile);
118 missile.missile_flags = MIF_SPLASH;
119 missile.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
120 missile.weaponentity_fld = weaponentity;
122 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
124 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
128 void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int fire)
130 if(actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon) // abort immediately if switching
132 w_ready(thiswep, actor, weaponentity, fire);
136 if(PHYS_INPUT_BUTTON_ATCK(actor))
138 if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
139 if(!(actor.items & IT_UNLIMITED_AMMO))
141 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
142 w_ready(thiswep, actor, weaponentity, fire);
146 ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
147 W_HLAC_Attack(thiswep, actor, weaponentity);
148 actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
149 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
153 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
157 void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity)
161 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hlac, ammo), weaponentity);
163 for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
164 W_HLAC_Attack2(thiswep, actor, weaponentity);
166 if(!autocvar_g_norecoil)
168 actor.punchangle_x = random() - 0.5;
169 actor.punchangle_y = random() - 0.5;
173 METHOD(HLAC, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
175 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
177 METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
179 if(autocvar_g_balance_hlac_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
180 thiswep.wr_reload(thiswep, actor, weaponentity);
183 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
185 actor.(weaponentity).misc_bulletcounter = 0;
186 W_HLAC_Attack(thiswep, actor, weaponentity);
187 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
191 else if((fire & 2) && WEP_CVAR(hlac, secondary))
193 if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire)))
195 W_HLAC_Attack2_Frame(thiswep, actor, weaponentity);
196 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
200 METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
202 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hlac, ammo);
203 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
206 METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
208 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hlac, ammo);
209 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
212 METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
214 W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
216 METHOD(HLAC, wr_suicidemessage, Notification(entity thiswep))
218 return WEAPON_HLAC_SUICIDE;
220 METHOD(HLAC, wr_killmessage, Notification(entity thiswep))
222 return WEAPON_HLAC_MURDER;
228 METHOD(HLAC, wr_impacteffect, void(entity thiswep, entity actor))
231 org2 = w_org + w_backoff * 6;
232 pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
234 sound(actor, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM);