Add trigger_teleport landmark (#952)

* Add trigger_teleport landmark
This commit is contained in:
Lê Hàn Minh Khang 2024-05-08 10:52:41 -04:00 committed by GitHub
parent 8cd9086937
commit 75f142e18a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 1 deletions

View File

@ -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++;
@ -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)

View File

@ -204,6 +204,11 @@ public:
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
@ -393,6 +398,7 @@ class CTriggerTeleport: public CBaseTrigger
{
public:
virtual void Spawn();
virtual void KeyValue(KeyValueData *pkvd);
};
class CBuyZone: public CBaseTrigger

View File

@ -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" []
@ -2264,6 +2265,7 @@
@SolidClass base(Trigger) = trigger_teleport : "Trigger teleport"
[
landmark(string) : "Landmark name"
spawnflags(flags) =
[
256: "Keep angles" : 0