X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fw_shotgun.qc;h=e126787713a1a2fde315f651ff45b670f752e8d9;hb=e83706a920b62a30d5c15aed0ef6df77632ec73e;hp=c347648dff324c5300e837630fa197b1be17992d;hpb=6818906d7cf84d2bc8f0236058f0cefc10966e4a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index c347648df..e12678771 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -89,6 +89,38 @@ void W_Shotgun_Attack2 (void) W_AttachToShotorg(flash, '5 0 0'); } +void shotgun_meleethink (void) +{ + makevectors(self.owner.v_angle); + vector angle; + angle = v_forward; + + // broken? fix, needs to be easier to hit + //WarpZone_tracebox_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * cvar("g_balance_shotgun_secondary_melee_range") - (v_right + v_up) * cvar("g_balance_shotgun_secondary_melee_size"), self.owner.origin + self.owner.view_ofs + (v_right + v_up) * cvar("g_balance_shotgun_secondary_melee_size"), self.owner.origin + self.owner.view_ofs + angle * cvar("g_balance_shotgun_secondary_melee_range"), FALSE, self.owner, ANTILAG_LATENCY(self.owner)); + WarpZone_traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * cvar("g_balance_shotgun_secondary_melee_range"), FALSE, self.owner, ANTILAG_LATENCY(self.owner)); + + // apply the damage + if(trace_fraction < 1) + { + vector force; + force = angle * cvar("g_balance_shotgun_secondary_force"); + Damage (trace_ent, self.owner, self.owner, cvar("g_balance_shotgun_secondary_damage"), WEP_SHOTGUN, self.owner.origin + self.owner.view_ofs, force); + } + remove(self); +} + +void W_Shotgun_Attack3 (void) +{ + sound (self, CHAN_PROJECTILE, "weapons/shotgun_melee.wav", VOL_BASE, ATTN_NORM); + weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_secondary_animtime"), w_ready); + + entity meleetemp; + meleetemp = spawn(); + meleetemp.owner = self; + meleetemp.think = shotgun_meleethink; + meleetemp.nextthink = time + cvar("g_balance_shotgun_secondary_melee_delay"); +} + // weapon frames void shotgun_fire2_03() { @@ -121,8 +153,16 @@ float w_shotgun(float req) if (self.BUTTON_ATCK2 && cvar("g_balance_shotgun_secondary")) if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire"))) { - W_Shotgun_Attack2(); - weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02); + if(cvar("g_balance_shotgun_secondary_melee")) + { + // force playback of the anim by switching to another anim (that we never play) here... + weapon_thinkf(WFRAME_FIRE1, 0, W_Shotgun_Attack3); + } + else + { + W_Shotgun_Attack2(); + weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02); + } } } else if (req == WR_PRECACHE) @@ -133,13 +173,18 @@ float w_shotgun(float req) precache_model ("models/weapons/h_shotgun.iqm"); precache_sound ("misc/itempickup.wav"); precache_sound ("weapons/shotgun_fire.wav"); + precache_sound ("weapons/shotgun_melee.wav"); } else if (req == WR_SETUP) weapon_setup(WEP_SHOTGUN); else if (req == WR_CHECKAMMO1) return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo"); else if (req == WR_CHECKAMMO2) + { + if(cvar("g_balance_shotgun_secondary_melee")) + return TRUE; return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3; + } return TRUE; }; #endif