From: Mario Date: Tue, 26 Jul 2016 17:02:59 +0000 (+1000) Subject: Fix weapon specific checks for melee X-Git-Tag: xonotic-v0.8.2~700^2~26 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4760fc6e617c998a50302f1d7ad76fdf868115af;p=xonotic%2Fxonotic-data.pk3dir.git Fix weapon specific checks for melee --- diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 991573ff3..1ef5faa59 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -134,7 +134,9 @@ void PM_ClientMovement_UpdateStatus(entity this) do_crouch = false; if(STAT(FROZEN, this)) do_crouch = false; - if((activeweapon == WEP_SHOCKWAVE || activeweapon == WEP_SHOTGUN) && viewmodel.animstate_startframe == viewmodel.anim_fire2_x && time < viewmodel.weapon_nextthink) + if((activeweapon.spawnflags & WEP_TYPE_MELEE_PRI) && viewmodel.animstate_startframe == viewmodel.anim_fire1_x && time < viewmodel.weapon_nextthink) + do_crouch = false; + if((activeweapon.spawnflags & WEP_TYPE_MELEE_SEC) && viewmodel.animstate_startframe == viewmodel.anim_fire2_x && time < viewmodel.weapon_nextthink) do_crouch = false; if (do_crouch) diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 4de39db17..8b844f13e 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -191,6 +191,8 @@ const int WEP_FLAG_HIDDEN = 0x40; // hides from menu const int WEP_FLAG_RELOADABLE = 0x80; // can has reload const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag) +const int WEP_TYPE_MELEE_PRI = 0x400; // primary attack is melee swing (for animation) +const int WEP_TYPE_MELEE_SEC = 0x800; // secondary attack is melee swing (for animation) // variables: string weaponorder_byid; diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 499453ecd..a1e29ad3a 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -2,7 +2,7 @@ CLASS(Shockwave, Weapon) /* ammotype */ //ATTRIB(Shockwave, ammo_field, .int, ammo_none) /* impulse */ ATTRIB(Shockwave, impulse, int, 2) -/* flags */ ATTRIB(Shockwave, spawnflags, int, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN | WEP_FLAG_CANCLIMB | WEP_FLAG_MUTATORBLOCKED); +/* flags */ ATTRIB(Shockwave, spawnflags, int, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN | WEP_FLAG_CANCLIMB | WEP_FLAG_MUTATORBLOCKED | WEP_TYPE_MELEE_SEC); /* rating */ ATTRIB(Shockwave, bot_pickupbasevalue, float, BOT_PICKUP_RATING_LOW); /* color */ ATTRIB(Shockwave, wpcolor, vector, '0.5 0.25 0'); /* modelname */ ATTRIB(Shockwave, mdl, string, "shotgun"); diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 34d2e462c..d96517753 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -2,7 +2,7 @@ CLASS(Shotgun, Weapon) /* ammotype */ ATTRIB(Shotgun, ammo_field, .int, ammo_shells) /* impulse */ ATTRIB(Shotgun, impulse, int, 2) -/* flags */ ATTRIB(Shotgun, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN); +/* flags */ ATTRIB(Shotgun, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_TYPE_MELEE_SEC); /* rating */ ATTRIB(Shotgun, bot_pickupbasevalue, float, BOT_PICKUP_RATING_LOW); /* color */ ATTRIB(Shotgun, wpcolor, vector, '0.5 0.25 0'); /* modelname */ ATTRIB(Shotgun, mdl, string, "shotgun"); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 60f331bb3..5487f6262 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2292,8 +2292,9 @@ void PlayerPreThink (entity this) do_crouch = false; } else if (STAT(FROZEN, this)) { do_crouch = false; - } else if ((PS(this).m_weapon == WEP_SHOTGUN || PS(this).m_weapon == WEP_SHOCKWAVE) && this.(weaponentity).wframe == WFRAME_FIRE2 && time < this.(weaponentity).weapon_nextthink) { - // WEAPONTODO: predict + } else if ((PS(this).m_weapon.spawnflags & WEP_TYPE_MELEE_PRI) && this.(weaponentity).wframe == WFRAME_FIRE1 && time < this.(weaponentity).weapon_nextthink) { + do_crouch = false; + } else if ((PS(this).m_weapon.spawnflags & WEP_TYPE_MELEE_SEC) && this.(weaponentity).wframe == WFRAME_FIRE2 && time < this.(weaponentity).weapon_nextthink) { do_crouch = false; } diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 32e9a5670..7c8061e94 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -391,7 +391,9 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void( if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t) { - int act = (fr == WFRAME_FIRE2 && (PS(actor).m_weapon == WEP_SHOCKWAVE || PS(actor).m_weapon == WEP_SHOTGUN)) + bool primary_melee = boolean(fr == WFRAME_FIRE1 && (PS(actor).m_weapon.spawnflags & WEP_TYPE_MELEE_PRI)); + bool secondary_melee = boolean(fr == WFRAME_FIRE2 && (PS(actor).m_weapon.spawnflags & WEP_TYPE_MELEE_SEC)); + int act = (primary_melee || secondary_melee) ? ANIMACTION_MELEE : ANIMACTION_SHOOT ;