diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index f218f076..f454806c 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -1712,6 +1712,10 @@ void CTriggerPush::Touch(CBaseEntity *pOther) } } +#define SF_TELEPORT_KEEP_ANGLES 256 +#define SF_TELEPORT_KEEP_VELOCITY 512 +#define SF_TELEPORT_REDIRECT_VELOCITY_WITH_YAW_DESTINATION 1024 + void CBaseTrigger::TeleportTouch(CBaseEntity *pOther) { entvars_t *pevToucher = pOther->pev; @@ -1766,15 +1770,40 @@ void CBaseTrigger::TeleportTouch(CBaseEntity *pOther) UTIL_SetOrigin(pevToucher, tmp); - pevToucher->angles = pentTarget->v.angles; - - if (pOther->IsPlayer()) +#ifdef REGAMEDLL_ADD + if (!(pev->spawnflags & SF_TELEPORT_KEEP_ANGLES)) +#endif { - pevToucher->v_angle = pentTarget->v.angles; + pevToucher->angles = pentTarget->v.angles; + + if (pOther->IsPlayer()) + { + pevToucher->v_angle = pentTarget->v.angles; + } + + pevToucher->fixangle = 1; } - pevToucher->fixangle = 1; - pevToucher->velocity = pevToucher->basevelocity = g_vecZero; +#ifdef REGAMEDLL_ADD + if (!(pev->spawnflags & SF_TELEPORT_KEEP_VELOCITY)) +#endif + { + pevToucher->velocity = pevToucher->basevelocity = g_vecZero; + } + +#ifdef REGAMEDLL_ADD + if ((pev->spawnflags & SF_TELEPORT_REDIRECT_VELOCITY_WITH_YAW_DESTINATION) && (pev->spawnflags & SF_TELEPORT_KEEP_VELOCITY)) + { + float xy_vel = pevToucher->velocity.Length2D(); + + Vector vecAngles = Vector(0, pentTarget->v.angles.y, 0); + Vector vecForward; + AngleVectors(vecAngles, vecForward, nullptr, nullptr); + + pevToucher->velocity.x = vecForward.x * xy_vel; + pevToucher->velocity.y = vecForward.y * xy_vel; + } +#endif } LINK_ENTITY_TO_CLASS(trigger_teleport, CTriggerTeleport, CCSTriggerTeleport) diff --git a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd index 3953a969..0e683873 100644 --- a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd +++ b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd @@ -2262,7 +2262,15 @@ ] ] -@SolidClass base(Trigger) = trigger_teleport : "Trigger teleport" [] +@SolidClass base(Trigger) = trigger_teleport : "Trigger teleport" +[ + spawnflags(flags) = + [ + 256: "Keep angles" : 0 + 512: "Keep velocity" : 0 + 1024: "Redirect velocity with yaw from destination" : 0 + ] +] // Function entities @SolidClass = func_bomb_target : "Bomb target zone"