14 if (
WEP_CVAR(WEP_MACHINEGUN, spread_decay))
16 float spreadSpectrumDistance =
fabs(
WEP_CVAR(WEP_MACHINEGUN, spread_max) -
WEP_CVAR(WEP_MACHINEGUN, spread_min));
18 spread_accum =
bound(0,
19 actor.(weaponentity).machinegun_spread_accumulation - (timediff *
WEP_CVAR(WEP_MACHINEGUN, spread_decay)),
20 spreadSpectrumDistance);
24 (
WEP_CVAR(WEP_MACHINEGUN, spread_add) * actor.(weaponentity).misc_bulletcounter),
25 WEP_CVAR(WEP_MACHINEGUN, spread_max));
36 float heatMultiplierApplicationPercent = 0.5;
37 float coldMultiplierApplicationPercent = 0.5;
39 float spreadSpectrumDistance =
fabs(
WEP_CVAR(WEP_MACHINEGUN, spread_max) -
WEP_CVAR(WEP_MACHINEGUN, spread_min));
41 if (spreadSpectrumDistance > 0)
43 heatMultiplierApplicationPercent = spread_accum / spreadSpectrumDistance;
44 coldMultiplierApplicationPercent = 1 - heatMultiplierApplicationPercent;
51 float cold_multiplier =
WEP_CVAR(WEP_MACHINEGUN, spread_cold_damagemultiplier);
52 float heat_multiplier =
WEP_CVAR(WEP_MACHINEGUN, spread_heat_damagemultiplier);
53 return (cold_multiplier ? coldMultiplierApplicationPercent * cold_multiplier : coldMultiplierApplicationPercent)
54 + (heat_multiplier ? heatMultiplierApplicationPercent * heat_multiplier : heatMultiplierApplicationPercent);
59 W_SetupShot(actor, weaponentity,
true, 0, SND_MACHINEGUN_FIRE,
CH_WEAPON_A, ((actor.(weaponentity).misc_bulletcounter == 1) ?
WEP_CVAR(WEP_MACHINEGUN, first_damage) :
WEP_CVAR(WEP_MACHINEGUN, sustained_damage)), deathtype);
63 actor.punchangle.x =
random() - 0.5;
64 actor.punchangle.y =
random() - 0.5;
71 ?
WEP_CVAR(WEP_MACHINEGUN, spread_crouchmod)
74 if (actor.(weaponentity).misc_bulletcounter == 1)
76 WEP_CVAR(WEP_MACHINEGUN, first_spread) * spread_accuracy,
77 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
78 WEP_CVAR(WEP_MACHINEGUN, first_damage),
79 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
80 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
81 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
83 WEP_CVAR(WEP_MACHINEGUN, first_force),
84 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
91 WEP_CVAR(WEP_MACHINEGUN, sustained_spread) * spread_accuracy,
92 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
93 WEP_CVAR(WEP_MACHINEGUN, sustained_damage),
94 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
95 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
96 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
98 WEP_CVAR(WEP_MACHINEGUN, sustained_force),
99 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
114 if (actor.(weaponentity).misc_bulletcounter == 1)
123 if (actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon || !
weapon_prepareattack_check(thiswep, actor, weaponentity, (fire & 2), -1))
125 w_ready(thiswep, actor, weaponentity, fire);
134 w_ready(thiswep, actor, weaponentity, fire);
150 w_ready(thiswep, actor, weaponentity, fire);
158 w_ready(thiswep, actor, weaponentity, fire);
167 actor.punchangle.x =
random() - 0.5;
168 actor.punchangle.y =
random() - 0.5;
176 float spread_accuracy = (
WEP_CVAR(WEP_MACHINEGUN, spread_min) <
WEP_CVAR(WEP_MACHINEGUN, spread_max))
177 ?
WEP_CVAR(WEP_MACHINEGUN, spread_min) + spread_accum
178 :
WEP_CVAR(WEP_MACHINEGUN, spread_min) - spread_accum;
181 spread_accuracy *=
WEP_CVAR(WEP_MACHINEGUN, spread_crouchmod);
185 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
186 WEP_CVAR(WEP_MACHINEGUN, sustained_damage) * heat,
187 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
188 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
189 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
191 WEP_CVAR(WEP_MACHINEGUN, sustained_force),
192 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
200 spread_accum +=
WEP_CVAR(WEP_MACHINEGUN, spread_add);
220 actor.punchangle.x =
random() - 0.5;
221 actor.punchangle.y =
random() - 0.5;
229 float spread_accuracy =
WEP_CVAR(WEP_MACHINEGUN, burst_spread);
231 spread_accuracy *=
WEP_CVAR(WEP_MACHINEGUN, spread_crouchmod);
235 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
236 WEP_CVAR(WEP_MACHINEGUN, sustained_damage) * heat,
237 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
238 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
239 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
241 WEP_CVAR(WEP_MACHINEGUN, sustained_force),
242 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
256 spread_accum +=
WEP_CVAR(WEP_MACHINEGUN, spread_add);
260 if (actor.(weaponentity).misc_bulletcounter == 0)
271 if (
vdist(actor.origin - actor.enemy.origin, <, 3000 -
bound(0,
skill, 10) * 200))
280 if (
WEP_CVAR(WEP_MACHINEGUN, reload_ammo)
281 && actor.(weaponentity).clip_load <
min(
max(
WEP_CVAR(WEP_MACHINEGUN, sustained_ammo),
WEP_CVAR(WEP_MACHINEGUN, first_ammo)),
WEP_CVAR(WEP_MACHINEGUN, burst_ammo))
282 && actor.(weaponentity).misc_bulletcounter >= 0)
284 thiswep.wr_reload(thiswep, actor, weaponentity);
288 if (
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
301 if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity)
305 w_ready(thiswep, actor, weaponentity, fire);
309 float ammo_available = (
WEP_CVAR(WEP_MACHINEGUN, reload_ammo) > 0)
310 ? actor.(weaponentity).clip_load
313 int to_shoot =
WEP_CVAR(WEP_MACHINEGUN, burst);
318 float burst_fraction =
min(1, ammo_available /
WEP_CVAR(WEP_MACHINEGUN, burst_ammo));
319 to_shoot =
floor(to_shoot * burst_fraction);
322 int to_use =
min(
WEP_CVAR(WEP_MACHINEGUN, burst_ammo), ammo_available);
341 if ((fire & 2) &&
WEP_CVAR(WEP_MACHINEGUN, first))
353 float ammo_amount = (
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
356 if (
WEP_CVAR(WEP_MACHINEGUN, reload_ammo))
358 if (
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
359 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(WEP_MACHINEGUN, sustained_ammo);
361 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(WEP_MACHINEGUN, first_ammo);
368 float burst_ammo_per_shot =
WEP_CVAR(WEP_MACHINEGUN, burst_ammo) /
WEP_CVAR(WEP_MACHINEGUN, burst);
369 float ammo_amount = (
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
370 ? (
GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot)
372 if (
WEP_CVAR(WEP_MACHINEGUN, reload_ammo))
374 if (
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
375 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >= burst_ammo_per_shot;
377 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(WEP_MACHINEGUN, first_ammo);
384 if (actor.(weaponentity).misc_bulletcounter < 0)
391 return WEAPON_THINKING_WITH_PORTALS;
397 return WEAPON_MACHINEGUN_MURDER_SNIPE;
399 return WEAPON_MACHINEGUN_MURDER_SPRAY;
421 PAR(_(
"The %s quickly fires bullets with a small degree of spread."),
COLORED_NAME(
this));
422 PAR(_(
"The secondary fire fires a quick burst of bullets faster than the primary fire and with no spread, but there's a short delay until it can be used again."));
423 PAR(_(
"It consumes %s ammo for each bullet shot, until the whole magazine is emptied."),
COLORED_NAME(ITEM_Bullets));
424 PAR(_(
"The %s can be used in a lot of situations, and it works particularly well at long ranges since the bullets pierce the sky instantaneously. "
425 "Since the secondary fire has no spread, it's the better option when firing over a long range."),
COLORED_NAME(
this));
bool bot_aim(entity this,.entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity, bool shot_accurate)
void SpawnCasing(vector vel, vector ang, int casingtype, entity casingowner,.entity weaponentity)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
virtual void wr_checkammo2()
(SERVER) checks ammo for weapon second
virtual void wr_checkammo1()
(SERVER) checks ammo for weapon primary
#define COLORED_NAME(this)
const int IT_UNLIMITED_AMMO
#define PHYS_INPUT_BUTTON_ATCK(s)
#define PHYS_INPUT_BUTTON_ATCK2(s)
float W_WeaponRateFactor(entity this)
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
const int HITTYPE_SECONDARY
#define pointparticles(effect, org, vel, howmany)
entity Notification
always last
#define METHOD(cname, name, prototype)
#define w_getbestweapon(ent, wepent)
#define sound(e, c, s, v, a)
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
void fireBullet_falloff(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float falloff_halflife, float falloff_mindist, float falloff_maxdist, float headshot_multiplier, float force, float falloff_forcehalflife, float dtype, entity tracer_effect, bool do_antilag)
#define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
string W_Guide_Keybinds(Weapon wep)
string W_Guide_DPS_secondaryMultishot(string name, string pri, string sec, string shots, string refire2, bool sec_variable)
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
#define WEP_CVAR(wep, name)
void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor,.entity weaponentity)
ERASEABLE float MachineGun_Heat(float spread_accum)
void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor,.entity weaponentity, int fire)
void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor,.entity weaponentity, int fire)
ERASEABLE void MachineGun_Update_Spread(entity actor,.entity weaponentity)
void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor,.entity weaponentity, int fire)
float machinegun_spread_accumulation
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)
void W_Reload(entity actor,.entity weaponentity, float sent_ammo_min, Sound sent_sound)
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
bool weapon_prepareattack_check(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
#define ATTACK_FINISHED(ent, w)
float weapon_load[REGISTRY_MAX(Weapons)]