X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fmachinegun.qc;h=684ae22bc740858542996ce53647b45491b23ab8;hb=HEAD;hp=e16ffe66bd451b1a7a4927aaa047417cd3d645db;hpb=8079e573522588959013a67cd2acd7d65944538b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index e16ffe66b..b0517597f 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -2,75 +2,57 @@ #ifdef SVQC -void W_MachineGun_MuzzleFlash_Think(entity this) -{ - this.frame += 2; - this.scale *= 0.5; - this.alpha -= 0.25; - this.nextthink = time + 0.05; - - if(this.alpha <= 0) - { - setthink(this, SUB_Remove); - this.nextthink = time; - this.realowner.muzzle_flash = NULL; - return; - } - -} - -void W_MachineGun_MuzzleFlash(entity actor, .entity weaponentity) -{ - entity wepent = actor.(weaponentity); - - if(wepent.muzzle_flash == NULL) - wepent.muzzle_flash = spawn(); - - // muzzle flash for 1st person view - setmodel(wepent.muzzle_flash, MDL_MACHINEGUN_MUZZLEFLASH); // precision set below - - wepent.muzzle_flash.scale = 0.75; - setthink(wepent.muzzle_flash, W_MachineGun_MuzzleFlash_Think); - wepent.muzzle_flash.nextthink = time + 0.02; - wepent.muzzle_flash.frame = 2; - wepent.muzzle_flash.alpha = 0.75; - wepent.muzzle_flash.angles_z = random() * 180; - wepent.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - wepent.muzzle_flash.owner = wepent.muzzle_flash.realowner = wepent; -} - void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity weaponentity) { - 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); + W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((actor.(weaponentity).misc_bulletcounter == 1) ? WEP_CVAR(WEP_MACHINEGUN, first_damage) : WEP_CVAR(WEP_MACHINEGUN, sustained_damage)), deathtype); + if(!autocvar_g_norecoil) { actor.punchangle_x = random() - 0.5; actor.punchangle_y = random() - 0.5; } + // this attack_finished just enforces a cooldown at the end of a burst - ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor); + ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(WEP_MACHINEGUN, first_refire) * W_WeaponRateFactor(actor); if(actor.(weaponentity).misc_bulletcounter == 1) - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET); + fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, + WEP_CVAR(WEP_MACHINEGUN, first_spread), + WEP_CVAR(WEP_MACHINEGUN, solidpenetration), + WEP_CVAR(WEP_MACHINEGUN, first_damage), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist), + 0, + WEP_CVAR(WEP_MACHINEGUN, first_force), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife), + deathtype, EFFECT_BULLET, true); else - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, sustained_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), deathtype, EFFECT_BULLET); - - Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - - W_MachineGun_MuzzleFlash(actor, weaponentity); - W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0'); + fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, + WEP_CVAR(WEP_MACHINEGUN, sustained_spread), + WEP_CVAR(WEP_MACHINEGUN, solidpenetration), + WEP_CVAR(WEP_MACHINEGUN, sustained_damage), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist), + 0, + WEP_CVAR(WEP_MACHINEGUN, sustained_force), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife), + deathtype, EFFECT_BULLET, true); + + W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir); // casing code if(autocvar_g_casings >= 2) { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), vectoangles(v_forward), 3, actor, weaponentity); } if(actor.(weaponentity).misc_bulletcounter == 1) - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, first_ammo), weaponentity); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(WEP_MACHINEGUN, first_ammo), weaponentity); else - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, sustained_ammo), weaponentity); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(WEP_MACHINEGUN, sustained_ammo), weaponentity); } // weapon frames @@ -84,7 +66,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit if(PHYS_INPUT_BUTTON_ATCK(actor)) { if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity)) - if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); w_ready(thiswep, actor, weaponentity, fire); @@ -92,10 +74,10 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit } actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1; W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity); - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_MACHINEGUN, sustained_refire), W_MachineGun_Attack_Frame); } else - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_MACHINEGUN, sustained_refire), w_ready); } @@ -110,209 +92,220 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity } if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity)) - if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); w_ready(thiswep, actor, weaponentity, fire); return; } - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, sustained_ammo), weaponentity); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(WEP_MACHINEGUN, sustained_ammo), weaponentity); - W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage), thiswep.m_id); + W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(WEP_MACHINEGUN, sustained_damage), thiswep.m_id); if(!autocvar_g_norecoil) { actor.punchangle_x = random() - 0.5; actor.punchangle_y = random() - 0.5; } - 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)); - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, machinegun_spread, WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); + machinegun_spread = bound(WEP_CVAR(WEP_MACHINEGUN, spread_min), WEP_CVAR(WEP_MACHINEGUN, spread_min) + (WEP_CVAR(WEP_MACHINEGUN, spread_add) * actor.(weaponentity).misc_bulletcounter), WEP_CVAR(WEP_MACHINEGUN, spread_max)); + fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, machinegun_spread, WEP_CVAR(WEP_MACHINEGUN, solidpenetration), WEP_CVAR(WEP_MACHINEGUN, sustained_damage), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife), WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist), WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist), 0, + WEP_CVAR(WEP_MACHINEGUN, sustained_force), WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife), thiswep.m_id, EFFECT_BULLET, true); actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1; - Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - - W_MachineGun_MuzzleFlash(actor, weaponentity); - W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0'); + W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir); if(autocvar_g_casings >= 2) // casing code { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), vectoangles(v_forward), 3, actor, weaponentity); } - ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor); - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto); + ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(WEP_MACHINEGUN, first_refire) * W_WeaponRateFactor(actor); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_MACHINEGUN, sustained_refire), W_MachineGun_Attack_Auto); } void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage), thiswep.m_id); + W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(WEP_MACHINEGUN, sustained_damage), thiswep.m_id); if(!autocvar_g_norecoil) { actor.punchangle_x = random() - 0.5; actor.punchangle_y = random() - 0.5; } - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, burst_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); + fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(WEP_MACHINEGUN, burst_spread), WEP_CVAR(WEP_MACHINEGUN, solidpenetration), WEP_CVAR(WEP_MACHINEGUN, sustained_damage), + WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife), WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist), WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist), 0, + WEP_CVAR(WEP_MACHINEGUN, sustained_force), WEP_CVAR(WEP_MACHINEGUN, damagefalloff_forcehalflife), thiswep.m_id, EFFECT_BULLET, true); - Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - - W_MachineGun_MuzzleFlash(actor, weaponentity); - W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0'); + W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir); if(autocvar_g_casings >= 2) // casing code { makevectors(actor.v_angle); // for some reason, this is lost - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), vectoangles(v_forward), 3, actor, weaponentity); } actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1; if(actor.(weaponentity).misc_bulletcounter == 0) { - ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(actor); - weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready); + ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(WEP_MACHINEGUN, burst_refire2) * W_WeaponRateFactor(actor); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(WEP_MACHINEGUN, burst_animtime), w_ready); } else { - weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_refire), W_MachineGun_Attack_Burst); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(WEP_MACHINEGUN, burst_refire), W_MachineGun_Attack_Burst); } } METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { - if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200)) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); - else - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); + if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200)) + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true); + else + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true); } + METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - // forced reload - wait until the bulletcounter is 0 so a burst loop can finish - if(WEP_CVAR(machinegun, reload_ammo) - && actor.(weaponentity).clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)) - && actor.(weaponentity).misc_bulletcounter >= 0) - { - thiswep.wr_reload(thiswep, actor, weaponentity); - } - else if(WEP_CVAR(machinegun, mode) == 1) - { - if(fire & 1) - if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0)) - { - actor.(weaponentity).misc_bulletcounter = 0; - W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire); - } - - // You can "shoot" more rounds than what's "used", and vice versa. - if(fire & 2) - if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0)) - { - if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity)) - if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) - { - W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); - w_ready(thiswep, actor, weaponentity, fire); - return; - } - - float ammo_available; - if (WEP_CVAR(machinegun, reload_ammo) > 0) - { - ammo_available = actor.(weaponentity).clip_load; - } - else - { - ammo_available = GetResource(actor, thiswep.ammo_type); - } - - // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction. - // Also keep the fraction <= 1 otherwise we'd mag dump in one burst. - float burst_fraction = min(1, ammo_available / WEP_CVAR(machinegun, burst_ammo)); - int to_shoot = floor(WEP_CVAR(machinegun, burst) * burst_fraction); - - // We also don't want to use 3 rounds if there's only 2 left. - int to_use = min(WEP_CVAR(machinegun, burst_ammo), ammo_available); - W_DecreaseAmmo(thiswep, actor, to_use, weaponentity); - - // Bursting counts up to 0 from a negative. - actor.(weaponentity).misc_bulletcounter = -to_shoot; - W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire); - } - } - else - { - - if(fire & 1) - if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0)) - { - actor.(weaponentity).misc_bulletcounter = 1; - W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity); // sets attack_finished - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); - } - - if((fire & 2) && WEP_CVAR(machinegun, first)) - if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0)) - { - actor.(weaponentity).misc_bulletcounter = 1; - W_MachineGun_Attack(thiswep, thiswep.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished - weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready); - } - } + // forced reload - wait until the bulletcounter is 0 so a burst loop can finish + if (WEP_CVAR(WEP_MACHINEGUN, reload_ammo) + && actor.(weaponentity).clip_load < min(max(WEP_CVAR(WEP_MACHINEGUN, sustained_ammo), WEP_CVAR(WEP_MACHINEGUN, first_ammo)), WEP_CVAR(WEP_MACHINEGUN, burst_ammo)) + && actor.(weaponentity).misc_bulletcounter >= 0) + { + thiswep.wr_reload(thiswep, actor, weaponentity); + } + else if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1) + { + if(fire & 1) + if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0)) + { + actor.(weaponentity).misc_bulletcounter = 0; + W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire); + } + + // You can "shoot" more rounds than what's "used", and vice versa. + if(fire & 2) + if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0)) + { + if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity)) + if(!(actor.items & IT_UNLIMITED_AMMO)) + { + W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); + w_ready(thiswep, actor, weaponentity, fire); + return; + } + + float ammo_available; + if (WEP_CVAR(WEP_MACHINEGUN, reload_ammo) > 0) + { + ammo_available = actor.(weaponentity).clip_load; + } + else + { + ammo_available = GetResource(actor, thiswep.ammo_type); + } + + int to_shoot = WEP_CVAR(WEP_MACHINEGUN, burst); + if(!(actor.items & IT_UNLIMITED_AMMO)) + { + // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction. + // Also keep the fraction <= 1 otherwise we'd mag dump in one burst. + float burst_fraction = min(1, ammo_available / WEP_CVAR(WEP_MACHINEGUN, burst_ammo)); + to_shoot = floor(to_shoot * burst_fraction); + + // We also don't want to use 3 rounds if there's only 2 left. + int to_use = min(WEP_CVAR(WEP_MACHINEGUN, burst_ammo), ammo_available); + W_DecreaseAmmo(thiswep, actor, to_use, weaponentity); + } + + // Bursting counts up to 0 from a negative. + actor.(weaponentity).misc_bulletcounter = -to_shoot; + W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire); + } + } + else + { + + if(fire & 1) + if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0)) + { + actor.(weaponentity).misc_bulletcounter = 1; + W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity); // sets attack_finished + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_MACHINEGUN, sustained_refire), W_MachineGun_Attack_Frame); + } + + if((fire & 2) && WEP_CVAR(WEP_MACHINEGUN, first)) + if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0)) + { + actor.(weaponentity).misc_bulletcounter = 1; + W_MachineGun_Attack(thiswep, thiswep.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(WEP_MACHINEGUN, first_refire), w_ready); + } + } } + METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount; - if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, sustained_ammo); - else - ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo); - - if(WEP_CVAR(machinegun, reload_ammo)) - { - if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(machinegun, sustained_ammo); - else - ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(machinegun, first_ammo); - } - return ammo_amount; + float ammo_amount; + if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1) + ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MACHINEGUN, sustained_ammo); + else + ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo); + + if(WEP_CVAR(WEP_MACHINEGUN, reload_ammo)) + { + if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1) + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(WEP_MACHINEGUN, sustained_ammo); + else + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo); + } + + return ammo_amount; } + METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount; - float burst_ammo_per_shot = WEP_CVAR(machinegun, burst_ammo) / WEP_CVAR(machinegun, burst); - if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount = GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot; - else - ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo); - - if(WEP_CVAR(machinegun, reload_ammo)) - { - if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= burst_ammo_per_shot; - else - ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(machinegun, first_ammo); - } - return ammo_amount; + float ammo_amount; + float burst_ammo_per_shot = WEP_CVAR(WEP_MACHINEGUN, burst_ammo) / WEP_CVAR(WEP_MACHINEGUN, burst); + + if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1) + ammo_amount = GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot; + else + ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo); + + if(WEP_CVAR(WEP_MACHINEGUN, reload_ammo)) + { + if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1) + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= burst_ammo_per_shot; + else + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo); + } + + return ammo_amount; } + METHOD(MachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { if(actor.(weaponentity).misc_bulletcounter < 0) return; - W_Reload(actor, weaponentity, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(max(WEP_CVAR(WEP_MACHINEGUN, sustained_ammo), WEP_CVAR(WEP_MACHINEGUN, first_ammo)), WEP_CVAR(WEP_MACHINEGUN, burst_ammo)), SND_RELOAD); } + METHOD(MachineGun, wr_suicidemessage, Notification(entity thiswep)) { - return WEAPON_THINKING_WITH_PORTALS; + return WEAPON_THINKING_WITH_PORTALS; } + METHOD(MachineGun, wr_killmessage, Notification(entity thiswep)) { - if(w_deathtype & HITTYPE_SECONDARY) - return WEAPON_MACHINEGUN_MURDER_SNIPE; - else - return WEAPON_MACHINEGUN_MURDER_SPRAY; + if(w_deathtype & HITTYPE_SECONDARY) + return WEAPON_MACHINEGUN_MURDER_SNIPE; + else + return WEAPON_MACHINEGUN_MURDER_SPRAY; } #endif @@ -320,11 +313,10 @@ METHOD(MachineGun, wr_killmessage, Notification(entity thiswep)) METHOD(MachineGun, wr_impacteffect, void(entity thiswep, entity actor)) { - vector org2; - org2 = w_org + w_backoff * 2; - pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1); - if(!w_issilent) - sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTN_NORM); + vector org2 = w_org + w_backoff * 2; + pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1); + if(!w_issilent) + sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTN_NORM); } #endif