stop spawning in the ground / hook CGameRules::IsSpawnPointValid()

This commit is contained in:
rtldg 2021-04-04 14:49:17 +00:00
parent 1531d65f3c
commit 9db01e2eb5
2 changed files with 43 additions and 3 deletions

View File

@ -37,6 +37,12 @@
"linux" "506"
"mac" "506"
}
"CGameRules::IsSpawnPointValid"
{
"windows" "77"
"linux" "78"
"mac" "78"
}
}
}
@ -50,6 +56,12 @@
"linux" "439"
"mac" "439"
}
"CGameRules::IsSpawnPointValid"
{
"windows" "76"
"linux" "77"
"mac" "77"
}
}
}
}

View File

@ -161,6 +161,7 @@ Handle gH_Forwards_OnCheckpointMenuSelect = null;
// dhooks
Handle gH_GetPlayerMaxSpeed = null;
DynamicHook gH_IsSpawnPointValid = null;
// modules
bool gB_Eventqueuefix = false;
@ -362,11 +363,21 @@ public void OnPluginStart()
{
gH_GetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, CCSPlayer__GetPlayerMaxSpeed);
}
else
{
SetFailState("Couldn't get the offset for \"CCSPlayer::GetPlayerMaxSpeed\" - make sure your gamedata is updated!");
}
if ((iOffset = GameConfGetOffset(hGameData, "CGameRules::IsSpawnPointValid")) != -1)
{
gH_IsSpawnPointValid = new DynamicHook(iOffset, HookType_GameRules, ReturnType_Bool, ThisPointer_Ignore);
gH_IsSpawnPointValid.AddParam(HookParamType_CBaseEntity);
gH_IsSpawnPointValid.AddParam(HookParamType_CBaseEntity);
}
else
{
SetFailState("Couldn't get the offset for \"CGameRules::IsSpawnPointValid\" - make sure your gamedata is updated!");
}
}
delete hGameData;
@ -398,6 +409,17 @@ public void OnPluginStart()
gB_Chat = LibraryExists("shavit-chat");
}
public MRESReturn Detour_IsSpawnPointValid(Handle hReturn, Handle hParams)
{
if (gCV_NoBlock.BoolValue)
{
DHookSetReturn(hReturn, true);
return MRES_Supercede;
}
return MRES_Ignored;
}
public void OnClientCookiesCached(int client)
{
if(IsFakeClient(client))
@ -506,6 +528,11 @@ public void OnConfigsExecuted()
public void OnMapStart()
{
if (gH_IsSpawnPointValid != null)
{
gH_IsSpawnPointValid.HookGamerules(Hook_Post, Detour_IsSpawnPointValid);
}
for(int i = 1; i <= MaxClients; i++)
{
ResetCheckpoints(i);
@ -535,8 +562,9 @@ public void OnMapStart()
(iEntity = FindEntityByClassname(iEntity, "info_player_teamspawn")) != -1 || // TF2 spawn point
(iEntity = FindEntityByClassname(iEntity, "info_player_start")) != -1)
{
float fOrigin[3];
float fOrigin[3], fAngles[3];
GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fOrigin);
GetEntPropVector(iEntity, Prop_Data, "m_angAbsRotation", fAngles);
for(int i = 1; i <= gCV_CreateSpawnPoints.IntValue; i++)
{
@ -546,7 +574,7 @@ public void OnMapStart()
if(DispatchSpawn(iSpawnPoint))
{
TeleportEntity(iSpawnPoint, fOrigin, view_as<float>({0.0, 0.0, 0.0}), NULL_VECTOR);
TeleportEntity(iSpawnPoint, fOrigin, fAngles, NULL_VECTOR);
}
}
}