Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trigger_teleport landmark #952

Merged
merged 3 commits into from
May 8, 2024
Merged
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
44 changes: 43 additions & 1 deletion regamedll/dlls/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1763,8 +1763,30 @@ void CBaseTrigger::TeleportTouch(CBaseEntity *pOther)

if (pOther->IsPlayer())
{
#ifdef REGAMEDLL_ADD
// 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;
tmp.z--; // offset by +1 because -1 will run out of this scope.
}
else
{
// fallback, shouldn't happen but anyway.
tmp.z -= pOther->pev->mins.z;
}
}
else
#endif
// make origin adjustments in case the teleportee is a player. (origin in center, not at feet)
tmp.z -= pOther->pev->mins.z;
{
tmp.z -= pOther->pev->mins.z;
}
}

tmp.z++;
Expand Down Expand Up @@ -1817,6 +1839,26 @@ void CTriggerTeleport::Spawn()
SetTouch(&CTriggerTeleport::TeleportTouch);
}

void CTriggerTeleport::KeyValue(KeyValueData *pkvd)
{
#ifdef REGAMEDLL_ADD
if (FStrEq(pkvd->szKeyName, "landmark"))
{
if (Q_strlen(pkvd->szValue) > 0)
{
m_iszLandmarkName = ALLOC_STRING(pkvd->szValue);
}

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

LINK_ENTITY_TO_CLASS(info_teleport_destination, CPointEntity, CCSPointEntity)
LINK_ENTITY_TO_CLASS(func_buyzone, CBuyZone, CCSBuyZone)

Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/triggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ class CBaseTrigger: public CBaseToggle
void EXPORT CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
void InitTrigger();

#ifdef REGAMEDLL_ADD
// For trigger_teleport TriggerTouch
int m_iszLandmarkName = 0;
#endif
};

#define SF_TRIGGER_HURT_TARGETONCE BIT(0) // Only fire hurt target once
Expand Down Expand Up @@ -393,6 +398,7 @@ class CTriggerTeleport: public CBaseTrigger
{
public:
virtual void Spawn();
virtual void KeyValue(KeyValueData *pkvd);
};

class CBuyZone: public CBaseTrigger
Expand Down
2 changes: 2 additions & 0 deletions regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,7 @@
bombradius(integer) : "Bomb Radius" : 500
]

@PointClass base(Targetname) iconsprite("sprites/CS/info_target.spr") = info_landmark : "Transition/Relative teleport Landmark" []
@PointClass base(Targetname) iconsprite("sprites/CS/info_target.spr") = info_null : "info_null (spotlight target)" []
@PointClass iconsprite("sprites/CS/info_player_deathmatch.spr") base(PlayerClass) = info_player_deathmatch : "Terrorist start" []
@PointClass iconsprite("sprites/CS/info_player_start.spr") base(PlayerClass) = info_player_start : "Counter-terrorist start" []
Expand Down Expand Up @@ -2264,6 +2265,7 @@

@SolidClass base(Trigger) = trigger_teleport : "Trigger teleport"
[
landmark(string) : "Landmark name"
spawnflags(flags) =
[
256: "Keep angles" : 0
Expand Down
Loading