Skip to content

Commit

Permalink
add FTRACE_KNIFE flag (rehlds#817)
Browse files Browse the repository at this point in the history
* trace flags

* remove unused flags

* add FTRACE_KNIFE flag
  • Loading branch information
Hamdi authored Jul 11, 2023
1 parent 6da11fa commit e1d1c11
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions regamedll/common/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions regamedll/dlls/wpn_shared/wpn_knife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit e1d1c11

Please sign in to comment.