5 void W_MachineGun_Attack(
Weapon thiswep,
int deathtype,
entity actor, .
entity weaponentity)
7 W_SetupShot(actor, weaponentity,
true, 0, SND_UZI_FIRE,
CH_WEAPON_A, ((actor.(weaponentity).misc_bulletcounter == 1) ?
WEP_CVAR(machinegun, first_damage) :
WEP_CVAR(machinegun, sustained_damage)), deathtype);
10 actor.punchangle_x =
random() - 0.5;
11 actor.punchangle_y =
random() - 0.5;
16 if(actor.(weaponentity).misc_bulletcounter == 1)
17 fireBullet(actor, weaponentity,
w_shotorg,
w_shotdir,
WEP_CVAR(machinegun, first_spread),
WEP_CVAR(machinegun, solidpenetration),
WEP_CVAR(machinegun, first_damage), 0,
WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET);
19 fireBullet(actor, weaponentity,
w_shotorg,
w_shotdir,
WEP_CVAR(machinegun, sustained_spread),
WEP_CVAR(machinegun, solidpenetration),
WEP_CVAR(machinegun, sustained_damage), 0,
WEP_CVAR(machinegun, sustained_force), deathtype, EFFECT_BULLET);
24 if(autocvar_g_casings >= 2)
30 if(actor.(weaponentity).misc_bulletcounter == 1)
37 void W_MachineGun_Attack_Frame(
Weapon thiswep,
entity actor, .
entity weaponentity,
int fire)
39 if(actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon || !
weapon_prepareattack_check(thiswep, actor, weaponentity, (fire & 2), -1))
41 w_ready(thiswep, actor, weaponentity, fire);
46 if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
47 if(!(actor.items & IT_UNLIMITED_AMMO))
50 w_ready(thiswep, actor, weaponentity, fire);
54 W_MachineGun_Attack(thiswep, thiswep.
m_id, actor, weaponentity);
55 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1,
WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
62 void W_MachineGun_Attack_Auto(
Weapon thiswep,
entity actor, .
entity weaponentity,
int fire)
64 float machinegun_spread;
68 w_ready(thiswep, actor, weaponentity, fire);
72 if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
73 if(!(actor.items & IT_UNLIMITED_AMMO))
76 w_ready(thiswep, actor, weaponentity, fire);
85 actor.punchangle_x =
random() - 0.5;
86 actor.punchangle_y =
random() - 0.5;
89 machinegun_spread =
bound(
WEP_CVAR(machinegun, spread_min),
WEP_CVAR(machinegun, spread_min) + (
WEP_CVAR(machinegun, spread_add) * actor.(weaponentity).misc_bulletcounter),
WEP_CVAR(machinegun, spread_max));
90 fireBullet(actor, weaponentity,
w_shotorg,
w_shotdir, machinegun_spread,
WEP_CVAR(machinegun, solidpenetration),
WEP_CVAR(machinegun, sustained_damage), 0,
WEP_CVAR(machinegun, sustained_force), thiswep.
m_id, EFFECT_BULLET);
96 if(autocvar_g_casings >= 2)
103 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1,
WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
106 void W_MachineGun_Attack_Burst(
Weapon thiswep,
entity actor, .
entity weaponentity,
int fire)
111 actor.punchangle_x =
random() - 0.5;
112 actor.punchangle_y =
random() - 0.5;
115 fireBullet(actor, weaponentity,
w_shotorg,
w_shotdir,
WEP_CVAR(machinegun, burst_spread),
WEP_CVAR(machinegun, solidpenetration),
WEP_CVAR(machinegun, sustained_damage), 0,
WEP_CVAR(machinegun, sustained_force), thiswep.
m_id, EFFECT_BULLET);
119 if(autocvar_g_casings >= 2)
125 actor.(weaponentity).
misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
126 if(actor.(weaponentity).misc_bulletcounter == 0)
133 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2,
WEP_CVAR(machinegun, burst_refire), W_MachineGun_Attack_Burst);
140 if(
vdist(actor.origin - actor.enemy.origin, <, 3000 -
bound(0,
skill, 10) * 200))
148 if(
WEP_CVAR(machinegun, reload_ammo)
149 && actor.(weaponentity).clip_load <
min(
max(
WEP_CVAR(machinegun, sustained_ammo),
WEP_CVAR(machinegun, first_ammo)),
WEP_CVAR(machinegun, burst_ammo))
152 thiswep.wr_reload(thiswep, actor, weaponentity);
154 else if(
WEP_CVAR(machinegun, mode) == 1)
160 W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
167 if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
168 if(!(actor.items & IT_UNLIMITED_AMMO))
171 w_ready(thiswep, actor, weaponentity, fire);
175 float ammo_available;
176 if (
WEP_CVAR(machinegun, reload_ammo) > 0)
178 ammo_available = actor.(weaponentity).
clip_load;
182 ammo_available =
GetResource(actor, thiswep.ammo_type);
187 float burst_fraction =
min(1, ammo_available /
WEP_CVAR(machinegun, burst_ammo));
188 int to_shoot =
floor(
WEP_CVAR(machinegun, burst) * burst_fraction);
191 int to_use =
min(
WEP_CVAR(machinegun, burst_ammo), ammo_available);
196 W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire);
206 W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity);
207 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1,
WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
210 if((fire & 2) &&
WEP_CVAR(machinegun, first))
214 W_MachineGun_Attack(thiswep, thiswep.m_id |
HITTYPE_SECONDARY, actor, weaponentity);
223 ammo_amount =
GetResource(actor, thiswep.ammo_type) >=
WEP_CVAR(machinegun, sustained_ammo);
227 if(
WEP_CVAR(machinegun, reload_ammo))
230 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(machinegun, sustained_ammo);
232 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(machinegun, first_ammo);
239 float burst_ammo_per_shot =
WEP_CVAR(machinegun, burst_ammo) /
WEP_CVAR(machinegun, burst);
241 ammo_amount =
GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot;
245 if(
WEP_CVAR(machinegun, reload_ammo))
248 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >= burst_ammo_per_shot;
250 ammo_amount += actor.(weaponentity).(
weapon_load[thiswep.m_id]) >=
WEP_CVAR(machinegun, first_ammo);
256 if(actor.(weaponentity).misc_bulletcounter < 0)
262 return WEAPON_THINKING_WITH_PORTALS;
267 return WEAPON_MACHINEGUN_MURDER_SNIPE;
269 return WEAPON_MACHINEGUN_MURDER_SPRAY;
278 org2 = w_org + w_backoff * 2;
279 pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1);
#define PHYS_INPUT_BUTTON_ATCK2(s)
bool bot_aim(entity this,.entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity)
float weapon_load[REGISTRY_MAX(Weapons)]
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
#define w_getbestweapon(ent, wepent)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define WEP_CVAR(wepname, name)
bool weapon_prepareattack_check(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
#define METHOD(cname, name, prototype)
void fireBullet(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect)
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
#define PHYS_INPUT_BUTTON_ATCK(s)
const int HITTYPE_SECONDARY
#define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
entity Notification
always last
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
#define ATTACK_FINISHED(ent, w)
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)
#define sound(e, c, s, v, a)
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
float W_WeaponRateFactor(entity this)
void W_Reload(entity actor,.entity weaponentity, float sent_ammo_min, Sound sent_sound)