Added spawnflags for keep player angles & velocity in trigger_teleport (#747)

* Added spawnflags for keep player angles & velocity in trigger_teleport
Co-authored-by: etojuice <etojuice@yandex.ru>
This commit is contained in:
SmileyAG 2022-04-28 15:33:39 +04:00 committed by GitHub
parent 6c47f96998
commit 21dab90571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 7 deletions

View File

@ -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,6 +1770,10 @@ void CBaseTrigger::TeleportTouch(CBaseEntity *pOther)
UTIL_SetOrigin(pevToucher, tmp);
#ifdef REGAMEDLL_ADD
if (!(pev->spawnflags & SF_TELEPORT_KEEP_ANGLES))
#endif
{
pevToucher->angles = pentTarget->v.angles;
if (pOther->IsPlayer())
@ -1774,9 +1782,30 @@ void CBaseTrigger::TeleportTouch(CBaseEntity *pOther)
}
pevToucher->fixangle = 1;
}
#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)
void CTriggerTeleport::Spawn()

View File

@ -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"