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), NULL, NULL, WEP_CVAR_BOTH(hlac, isprimary, force), this.projectiledeathtype, toucher);
20 void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity)
25 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hlac, ammo), weaponentity);
27 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));
33 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
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 = WEP_HLAC.m_id;
65 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
67 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
70 void W_HLAC_Attack2(entity actor, .entity weaponentity)
75 spread = WEP_CVAR_SEC(hlac, spread);
79 spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
81 W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage));
82 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
84 missile = new(hlacbolt);
85 missile.owner = missile.realowner = actor;
86 missile.bot_dodge = true;
88 missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage);
90 set_movetype(missile, MOVETYPE_FLY);
91 PROJECTILE_MAKETRIGGER(missile);
93 setorigin(missile, w_shotorg);
94 setsize(missile, '0 0 0', '0 0 0');
96 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
97 //missile.angles = vectoangles(missile.velocity); // csqc
99 settouch(missile, W_HLAC_Touch);
100 setthink(missile, SUB_Remove);
102 missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
104 missile.flags = FL_PROJECTILE;
105 IL_PUSH(g_projectiles, missile);
106 IL_PUSH(g_bot_dodge, missile);
107 missile.missile_flags = MIF_SPLASH;
108 missile.projectiledeathtype = WEP_HLAC.m_id | HITTYPE_SECONDARY;
110 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
112 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
116 void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int fire)
118 if(actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon) // abort immediately if switching
120 w_ready(thiswep, actor, weaponentity, fire);
124 if(PHYS_INPUT_BUTTON_ATCK(actor))
126 if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
127 if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
129 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
130 w_ready(thiswep, actor, weaponentity, fire);
134 int slot = weaponslot(weaponentity);
135 ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
136 W_HLAC_Attack(WEP_HLAC, actor, weaponentity);
137 actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
138 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
142 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
146 void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity)
150 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hlac, ammo), weaponentity);
152 for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
153 W_HLAC_Attack2(actor, weaponentity);
155 if(!autocvar_g_norecoil)
157 actor.punchangle_x = random() - 0.5;
158 actor.punchangle_y = random() - 0.5;
162 METHOD(HLAC, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
164 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
166 METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
168 if(autocvar_g_balance_hlac_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
169 thiswep.wr_reload(thiswep, actor, weaponentity);
172 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
174 actor.(weaponentity).misc_bulletcounter = 0;
175 W_HLAC_Attack(thiswep, actor, weaponentity);
176 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
180 else if((fire & 2) && WEP_CVAR(hlac, secondary))
182 if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire)))
184 W_HLAC_Attack2_Frame(thiswep, actor, weaponentity);
185 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
189 METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
191 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hlac, ammo);
192 ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
195 METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
197 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hlac, ammo);
198 ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
201 METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
203 W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
205 METHOD(HLAC, wr_suicidemessage, Notification(entity thiswep))
207 return WEAPON_HLAC_SUICIDE;
209 METHOD(HLAC, wr_killmessage, Notification(entity thiswep))
211 return WEAPON_HLAC_MURDER;
217 METHOD(HLAC, wr_impacteffect, void(entity thiswep, entity actor))
220 org2 = w_org + w_backoff * 6;
221 pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
223 sound(actor, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM);