Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ class CBaseTrigger : public CBaseToggle
void InitTrigger( void );

virtual int ObjectCaps( void ) { return CBaseToggle :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }

// For trigger_teleport TriggerTouch
int m_iszLandmarkName = 0;
};

class CChangeLevel : public CBaseTrigger
Expand Down
41 changes: 40 additions & 1 deletion dlls/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,27 @@ void CBaseTrigger :: TeleportTouch( CBaseEntity *pOther )

if ( pOther->IsPlayer() )
{
tmp.z -= pOther->pev->mins.z;// make origin adjustments in case the teleportee is a player. (origin in center, not at feet)
// If a landmark was specified, offset the player relative to the landmark
if (m_iszLandmarkName)
{
edict_t *pentLandmark = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_iszLandmarkName));

if (!FNullEnt(pentLandmark))
{
Vector diff = pevToucher->origin - VARS(pentLandmark)->origin;
tmp += diff;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dlls/vector.h:

inline Vector operator+=(const Vector& v) { return (*this = *this + v); }

tmp.z--; // offset by -1 because it will +1 of this scope.
}
else
{
// fallback, shouldn't happen but anyway.
tmp.z -= pOther->pev->mins.z;
}
}
else
{
tmp.z -= pOther->pev->mins.z;// make origin adjustments in case the teleportee is a player. (origin in center, not at feet)
}
}

tmp.z++;
Expand Down Expand Up @@ -1950,6 +1970,7 @@ class CTriggerTeleport : public CBaseTrigger
{
public:
void Spawn( void );
void KeyValue(KeyValueData *pkvd);
};
LINK_ENTITY_TO_CLASS( trigger_teleport, CTriggerTeleport );

Expand All @@ -1960,6 +1981,24 @@ void CTriggerTeleport :: Spawn( void )
SetTouch( &CTriggerTeleport::TeleportTouch );
}

void CTriggerTeleport :: KeyValue(KeyValueData *pkvd)
{
if (FStrEq(pkvd->szKeyName, "landmark"))
{
if (Q_strlen(pkvd->szValue) > 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no Q_ wrappers in the project, so:

strlen(pkvd->szValue) > 0

{
m_iszLandmarkName = ALLOC_STRING(pkvd->szValue);
}

// If empty, handle it in the teleport touch instead
pkvd->fHandled = TRUE;
}
else
{
CBaseTrigger::KeyValue(pkvd);
}
}


LINK_ENTITY_TO_CLASS( info_teleport_destination, CPointEntity );

Expand Down