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 spread_accum - (timediff *
WEP_CVAR(WEP_MACHINEGUN, spread_decay)),
20 spreadSpectrumDistance);
25 (
WEP_CVAR(WEP_MACHINEGUN, spread_add) * actor.(weaponentity).misc_bulletcounter),
26 WEP_CVAR(WEP_MACHINEGUN, spread_max));
38 float heatMultiplierApplicationPercent = 0.5;
39 float coldMultiplierApplicationPercent = 0.5;
41 float spreadSpectrumDistance =
fabs(
WEP_CVAR(WEP_MACHINEGUN, spread_max) -
WEP_CVAR(WEP_MACHINEGUN, spread_min));
43 if (spreadSpectrumDistance > 0)
45 heatMultiplierApplicationPercent = spread_accum / spreadSpectrumDistance;
46 coldMultiplierApplicationPercent = 1 - heatMultiplierApplicationPercent;
53 float cold_multiplier =
WEP_CVAR(WEP_MACHINEGUN, spread_cold_damagemultiplier);
54 float heat_multiplier =
WEP_CVAR(WEP_MACHINEGUN, spread_heat_damagemultiplier);
55 return (cold_multiplier ? coldMultiplierApplicationPercent * cold_multiplier : coldMultiplierApplicationPercent)
56 + (heat_multiplier ? heatMultiplierApplicationPercent * heat_multiplier : heatMultiplierApplicationPercent);
61 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);
65 actor.punchangle_x =
random() - 0.5;
66 actor.punchangle_y =
random() - 0.5;
73 ?
WEP_CVAR(WEP_MACHINEGUN, spread_crouchmod)
76 if(actor.(weaponentity).misc_bulletcounter == 1)
78 WEP_CVAR(WEP_MACHINEGUN, first_spread) * spread_accuracy,
79 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
80 WEP_CVAR(WEP_MACHINEGUN, first_damage),
81 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
82 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
83 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
85 WEP_CVAR(WEP_MACHINEGUN, first_force),
86 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
87 deathtype, EFFECT_BULLET,
true);
90 WEP_CVAR(WEP_MACHINEGUN, sustained_spread) * spread_accuracy,
91 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
92 WEP_CVAR(WEP_MACHINEGUN, sustained_damage),
93 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
94 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
95 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
97 WEP_CVAR(WEP_MACHINEGUN, sustained_force),
98 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
99 deathtype, EFFECT_BULLET,
true);
110 if(actor.(weaponentity).misc_bulletcounter == 1)
119 if(actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon || !
weapon_prepareattack_check(thiswep, actor, weaponentity, (fire & 2), -1))
121 w_ready(thiswep, actor, weaponentity, fire);
130 w_ready(thiswep, actor, weaponentity, fire);
146 w_ready(thiswep, actor, weaponentity, fire);
154 w_ready(thiswep, actor, weaponentity, fire);
163 actor.punchangle_x =
random() - 0.5;
164 actor.punchangle_y =
random() - 0.5;
173 float spread_accuracy;
174 if (
WEP_CVAR(WEP_MACHINEGUN, spread_min) <
WEP_CVAR(WEP_MACHINEGUN, spread_max))
175 spread_accuracy =
WEP_CVAR(WEP_MACHINEGUN, spread_min) + spread_accum;
177 spread_accuracy =
WEP_CVAR(WEP_MACHINEGUN, spread_min) - spread_accum;
180 spread_accuracy *=
WEP_CVAR(WEP_MACHINEGUN, spread_crouchmod);
184 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
185 WEP_CVAR(WEP_MACHINEGUN, sustained_damage) * heat,
186 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
187 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
188 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
190 WEP_CVAR(WEP_MACHINEGUN, sustained_force),
191 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
192 thiswep.
m_id, EFFECT_BULLET,
true);
196 spread_accum +=
WEP_CVAR(WEP_MACHINEGUN, spread_add);
217 actor.punchangle_x =
random() - 0.5;
218 actor.punchangle_y =
random() - 0.5;
227 float spread_accuracy =
WEP_CVAR(WEP_MACHINEGUN, burst_spread);
229 spread_accuracy *=
WEP_CVAR(WEP_MACHINEGUN, spread_crouchmod);
233 WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
234 WEP_CVAR(WEP_MACHINEGUN, sustained_damage) * heat,
235 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
236 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
237 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
239 WEP_CVAR(WEP_MACHINEGUN, sustained_force),
240 WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife),
241 thiswep.
m_id, EFFECT_BULLET,
true);
251 spread_accum +=
WEP_CVAR(WEP_MACHINEGUN, spread_add);
256 if(actor.(weaponentity).misc_bulletcounter == 0)
270 if(
vdist(actor.origin - actor.enemy.origin, <, 3000 -
bound(0,
skill, 10) * 200))
279 if (
WEP_CVAR(WEP_MACHINEGUN, reload_ammo)
280 && actor.(weaponentity).clip_load <
min(
max(
WEP_CVAR(WEP_MACHINEGUN, sustained_ammo),
WEP_CVAR(WEP_MACHINEGUN, first_ammo)),
WEP_CVAR(WEP_MACHINEGUN, burst_ammo))
281 && actor.(weaponentity).misc_bulletcounter >= 0)
283 thiswep.wr_reload(thiswep, actor, weaponentity);
285 else if(
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
298 if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
302 w_ready(thiswep, actor, weaponentity, fire);
306 float ammo_available;
307 if (
WEP_CVAR(WEP_MACHINEGUN, reload_ammo) > 0)
309 ammo_available = actor.(weaponentity).
clip_load;
313 ammo_available =
GetResource(actor, thiswep.ammo_type);
316 int to_shoot =
WEP_CVAR(WEP_MACHINEGUN, burst);
321 float burst_fraction =
min(1, ammo_available /
WEP_CVAR(WEP_MACHINEGUN, burst_ammo));
322 to_shoot =
floor(to_shoot * burst_fraction);
325 int to_use =
min(
WEP_CVAR(WEP_MACHINEGUN, burst_ammo), ammo_available);
345 if((fire & 2) &&
WEP_CVAR(WEP_MACHINEGUN, first))
358 if(
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
359 ammo_amount =
GetResource(actor, thiswep.ammo_type) >=
WEP_CVAR(WEP_MACHINEGUN, sustained_ammo);
361 ammo_amount =
GetResource(actor, thiswep.ammo_type) >=
WEP_CVAR(WEP_MACHINEGUN, first_ammo);
363 if(
WEP_CVAR(WEP_MACHINEGUN, reload_ammo))
365 if(
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
366 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(WEP_MACHINEGUN, sustained_ammo);
368 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(WEP_MACHINEGUN, first_ammo);
377 float burst_ammo_per_shot =
WEP_CVAR(WEP_MACHINEGUN, burst_ammo) /
WEP_CVAR(WEP_MACHINEGUN, burst);
379 if(
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
380 ammo_amount =
GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot;
382 ammo_amount =
GetResource(actor, thiswep.ammo_type) >=
WEP_CVAR(WEP_MACHINEGUN, first_ammo);
384 if(
WEP_CVAR(WEP_MACHINEGUN, reload_ammo))
386 if(
WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
387 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >= burst_ammo_per_shot;
389 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(WEP_MACHINEGUN, first_ammo);
397 if(actor.(weaponentity).misc_bulletcounter < 0)
404 return WEAPON_THINKING_WITH_PORTALS;
410 return WEAPON_MACHINEGUN_MURDER_SNIPE;
412 return WEAPON_MACHINEGUN_MURDER_SPRAY;
434 PAR(_(
"The %s quickly fires bullets with a small degree of spread."),
COLORED_NAME(
this));
435 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."));
436 PAR(_(
"It consumes %s ammo for each bullet shot, until the whole magazine is emptied."),
COLORED_NAME(ITEM_Bullets));
437 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. "
438 "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)]