From e1d1c11992e6f97037f6e6ab5baba015d2922db0 Mon Sep 17 00:00:00 2001 From: Hamdi Date: Tue, 11 Jul 2023 03:57:50 +0100 Subject: [PATCH] add FTRACE_KNIFE flag (#817) * trace flags * remove unused flags * add FTRACE_KNIFE flag --- regamedll/common/const.h | 1 + regamedll/dlls/wpn_shared/wpn_knife.cpp | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/regamedll/common/const.h b/regamedll/common/const.h index d667a6b8..024a2a3d 100644 --- a/regamedll/common/const.h +++ b/regamedll/common/const.h @@ -100,6 +100,7 @@ // Starting from BIT(16) to reserve space for more flags for Engine #define FTRACE_BULLET BIT(16) #define FTRACE_FLASH BIT(17) +#define FTRACE_KNIFE BIT(18) // walkmove modes #define WALKMOVE_NORMAL 0 // normal walkmove diff --git a/regamedll/dlls/wpn_shared/wpn_knife.cpp b/regamedll/dlls/wpn_shared/wpn_knife.cpp index aa7e177c..fcbf2d94 100644 --- a/regamedll/dlls/wpn_shared/wpn_knife.cpp +++ b/regamedll/dlls/wpn_shared/wpn_knife.cpp @@ -129,6 +129,9 @@ void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, fl distance = 1e6f; vecHullEnd = vecSrc + ((vecHullEnd - vecSrc) * 2); +#ifdef REGAMEDLL_ADD + gpGlobals->trace_flags = FTRACE_KNIFE; +#endif UTIL_TraceLine(vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace); if (tmpTrace.flFraction < 1.0f) @@ -147,6 +150,9 @@ void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, fl vecEnd.y = vecHullEnd.y + minmaxs[j][1]; vecEnd.z = vecHullEnd.z + minmaxs[k][2]; +#ifdef REGAMEDLL_ADD + gpGlobals->trace_flags = FTRACE_KNIFE; +#endif UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace); if (tmpTrace.flFraction < 1.0f) @@ -274,11 +280,21 @@ BOOL CKnife::Swing(BOOL fFirst) vecSrc = m_pPlayer->GetGunPosition(); vecEnd = vecSrc + gpGlobals->v_forward * KnifeSwingDistance(); +#ifdef REGAMEDLL_ADD + gpGlobals->trace_flags = FTRACE_KNIFE; +#endif UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, m_pPlayer->edict(), &tr); if (tr.flFraction >= 1.0f) { +#ifdef REGAMEDLL_ADD + gpGlobals->trace_flags = FTRACE_KNIFE; +#endif UTIL_TraceHull(vecSrc, vecEnd, dont_ignore_monsters, head_hull, m_pPlayer->edict(), &tr); +#ifdef REGAMEDLL_ADD + // We manually reset it because Engine doesn't unlike TraceLine + gpGlobals->trace_flags = 0; +#endif if (tr.flFraction < 1.0f) { @@ -457,11 +473,21 @@ BOOL CKnife::Stab(BOOL fFirst) vecSrc = m_pPlayer->GetGunPosition(); vecEnd = vecSrc + gpGlobals->v_forward * KnifeStabDistance(); +#ifdef REGAMEDLL_ADD + gpGlobals->trace_flags = FTRACE_KNIFE; +#endif UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, m_pPlayer->edict(), &tr); if (tr.flFraction >= 1.0f) { +#ifdef REGAMEDLL_ADD + gpGlobals->trace_flags = FTRACE_KNIFE; +#endif UTIL_TraceHull(vecSrc, vecEnd, dont_ignore_monsters, head_hull, m_pPlayer->edict(), &tr); +#ifdef REGAMEDLL_ADD + // We manually reset it because Engine doesn't unlike TraceLine + gpGlobals->trace_flags = 0; +#endif if (tr.flFraction < 1.0f) {