X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fmachinegun.qc;h=684ae22bc740858542996ce53647b45491b23ab8;hb=HEAD;hp=9d5ed09ef494df030f1174590e9f6babe99cbaab;hpb=42a881cbe552bb6ce4a13106cafc9d2f1a8152de;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 9d5ed09ef..efb4913c0 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -2,69 +2,51 @@ #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); + 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); 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), 0, WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET); + fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, + WEP_CVAR(machinegun, first_spread), + WEP_CVAR(machinegun, solidpenetration), + WEP_CVAR(machinegun, first_damage), + WEP_CVAR(machinegun, damagefalloff_halflife), + WEP_CVAR(machinegun, damagefalloff_mindist), + WEP_CVAR(machinegun, damagefalloff_maxdist), + 0, + WEP_CVAR(machinegun, first_force), + WEP_CVAR(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), 0, 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(machinegun, sustained_spread), + WEP_CVAR(machinegun, solidpenetration), + WEP_CVAR(machinegun, sustained_damage), + WEP_CVAR(machinegun, damagefalloff_halflife), + WEP_CVAR(machinegun, damagefalloff_mindist), + WEP_CVAR(machinegun, damagefalloff_maxdist), + 0, + WEP_CVAR(machinegun, sustained_force), + WEP_CVAR(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) @@ -127,19 +109,18 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity } 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), 0, WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); + fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, machinegun_spread, WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), + WEP_CVAR(machinegun, damagefalloff_halflife), WEP_CVAR(machinegun, damagefalloff_mindist), WEP_CVAR(machinegun, damagefalloff_maxdist), 0, + WEP_CVAR(machinegun, sustained_force), WEP_CVAR(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); @@ -155,17 +136,16 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit 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), 0, WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); - - Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); + fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, burst_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), + WEP_CVAR(machinegun, damagefalloff_halflife), WEP_CVAR(machinegun, damagefalloff_mindist), WEP_CVAR(machinegun, damagefalloff_maxdist), 0, + WEP_CVAR(machinegun, sustained_force), WEP_CVAR(machinegun, damagefalloff_forcehalflife), thiswep.m_id, EFFECT_BULLET, true); - 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; @@ -184,9 +164,9 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit 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); + 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); + 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)) { @@ -320,8 +300,7 @@ METHOD(MachineGun, wr_killmessage, Notification(entity thiswep)) METHOD(MachineGun, wr_impacteffect, void(entity thiswep, entity actor)) { - vector org2; - org2 = w_org + w_backoff * 2; + 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);