Skip to content

Commit

Permalink
Merge branch 'opfor' into opforfixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Nov 23, 2024
2 parents f02215c + 3bf4876 commit 4dad799
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
3 changes: 2 additions & 1 deletion dlls/gearbox/displacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void CDisplacer::Teleport( void )
if( pTarget )
tmp = pTarget->pev->origin;

if( pTarget && /*HACK*/( tmp != Vector( 0, 0, 0 )/*HACK*/ ) )
if( pTarget )
{
if( (m_pPlayer->m_afPhysicsFlags & PFLAG_ONROPE) )
m_pPlayer->LetGoRope();
Expand All @@ -592,6 +592,7 @@ void CDisplacer::Teleport( void )
tmp.z+=37;

m_pPlayer->pev->flags &= ~FL_ONGROUND;
m_pPlayer->m_DisplacerReturn = m_pPlayer->pev->origin;

UTIL_SetOrigin(m_pPlayer->pev, tmp);

Expand Down
42 changes: 36 additions & 6 deletions dlls/gearbox/gearbox_triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CTriggerXenReturn : public CTriggerTeleport
public:
void Spawn(void);
void EXPORT TeleportTouch(CBaseEntity *pOther);
CBaseEntity* GetEarthTarget(CBaseEntity* pOther);
};


Expand All @@ -55,7 +56,6 @@ void CTriggerXenReturn::Spawn(void)
void CTriggerXenReturn::TeleportTouch(CBaseEntity* pOther)
{
entvars_t* pevToucher = pOther->pev;
edict_t *pentTarget = NULL;

// Only teleport monsters or clients
if (!FBitSet(pevToucher->flags, FL_CLIENT | FL_MONSTER))
Expand All @@ -80,11 +80,11 @@ void CTriggerXenReturn::TeleportTouch(CBaseEntity* pOther)
}
}

pentTarget = FIND_ENTITY_BY_CLASSNAME(pentTarget, "info_displacer_earth_target");
if (FNullEnt(pentTarget))
CBaseEntity* pTarget = GetEarthTarget(pOther);
if (!pTarget)
return;

Vector tmp = VARS(pentTarget)->origin;
Vector tmp = pTarget->pev->origin;

if (pOther->IsPlayer())
{
Expand All @@ -97,11 +97,11 @@ void CTriggerXenReturn::TeleportTouch(CBaseEntity* pOther)

UTIL_SetOrigin(pevToucher, tmp);

pevToucher->angles = pentTarget->v.angles;
pevToucher->angles = pTarget->pev->angles;

if (pOther->IsPlayer())
{
pevToucher->v_angle = pentTarget->v.angles;
pevToucher->v_angle = pTarget->pev->angles;
}

pevToucher->fixangle = TRUE;
Expand All @@ -121,6 +121,36 @@ void CTriggerXenReturn::TeleportTouch(CBaseEntity* pOther)
EMIT_SOUND(ENT(pOther->pev), CHAN_STATIC, "debris/beamstart7.wav", 1, ATTN_NORM );
}

CBaseEntity* CTriggerXenReturn::GetEarthTarget(CBaseEntity* pOther)
{
float flMinDist = 8192;
CBaseEntity* pEarthTarget = NULL;
CBasePlayer* pPlayer = NULL;
if (pOther && pOther->IsPlayer())
{
pPlayer = (CBasePlayer*)pOther;
}
CBaseEntity* pDestination = NULL;
while ((pDestination = UTIL_FindEntityByClassname(pDestination, "info_displacer_earth_target")) != NULL)
{
if (pPlayer)
{
const float flDist = (pPlayer->m_DisplacerReturn - pDestination->pev->origin).Length();
if (flDist <= flMinDist)
{
pEarthTarget = pDestination;
flMinDist = flDist;
}
}
else
{
pEarthTarget = pDestination;
break;
}
}
return pEarthTarget;
}

//=========================================================
// CTriggerGenewormHit
//=========================================================
Expand Down
1 change: 1 addition & 0 deletions dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] =
DEFINE_FIELD( CBasePlayer, m_iFOV, FIELD_INTEGER ),

DEFINE_FIELD(CBasePlayer, m_fInXen, FIELD_BOOLEAN),
DEFINE_FIELD(CBasePlayer, m_DisplacerReturn, FIELD_VECTOR),
DEFINE_FIELD(CBasePlayer, m_pRope, FIELD_CLASSPTR),

//DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games
Expand Down
1 change: 1 addition & 0 deletions dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class CBasePlayer : public CBaseMonster
// Op4 player attributes.
//
BOOL m_fInXen;
Vector m_DisplacerReturn;

friend class CDisplacer;
friend class CTriggerXenReturn;
Expand Down

0 comments on commit 4dad799

Please sign in to comment.