PropSpawner: Remove collision between func_clip_vphysics and plugin spawned props

This commit is contained in:
Irineu
2026-09-12 16:07:03 -03:00
parent 90cff708d8
commit 53828e527d
2 changed files with 43 additions and 2 deletions
+6
View File
@@ -9,6 +9,12 @@
"linux" "414"
"windows" "413"
}
"ForceVPhysicsCollide"
{
"linux" "160"
"windows" "159"
}
}
}
}
+35
View File
@@ -33,6 +33,7 @@ ArrayList g_aNotifyList;
int g_aPlayerPropColor[MAXPLAYERS + 1][3];
Handle g_PlayerUseSetup = INVALID_HANDLE;
Handle g_ForceVPhysicsCollideSetup = INVALID_HANDLE;
enum struct NotifyListData
{
@@ -116,6 +117,17 @@ public void OnPluginStart()
g_PlayerUseSetup = DHookCreate(PlayerUseOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, PlayerUse_Hook);
}
int ForceVPhysicsCollideOffset = gd.GetOffset("ForceVPhysicsCollide");
if (ForceVPhysicsCollideOffset == -1)
{
LogError("PropSpawner: Missing \"ForceVPhysicsCollide\" offset in gamedata file");
}
else
{
g_ForceVPhysicsCollideSetup = DHookCreate(ForceVPhysicsCollideOffset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, ForceVPhysicsCollide_Hook);
DHookAddParam(g_ForceVPhysicsCollideSetup, HookParamType_CBaseEntity);
}
delete gd;
}
@@ -134,6 +146,12 @@ public void OnPluginStart()
HookEvent("round_end", Event_RoundEnd);
}
public void OnEntityCreated(int entity, const char[] classname)
{
if (StrEqual(classname, "func_clip_vphysics") && g_ForceVPhysicsCollideSetup != INVALID_HANDLE)
DHookEntity(g_ForceVPhysicsCollideSetup, false, entity);
}
public void OnEntityDestroyed(int entity)
{
// Safety net: if a tracked prop is removed by any means other than DeleteProp()
@@ -801,9 +819,12 @@ int FindInNotifyList(int client)
public void OnClientPutInServer(int client)
{
g_aPlayerPropColor[client] = {255, 255, 255};
if (g_PlayerUseSetup != INVALID_HANDLE)
{
DHookEntity(g_PlayerUseSetup, false, client);
DHookEntity(g_PlayerUseSetup, true, client, INVALID_FUNCTION, PlayerUse_HookPost);
}
}
void OnRainbowTimer(Handle timer, any data)
{
@@ -949,3 +970,17 @@ bool UsePushFilter(int entity, int contentsMask)
return true;
}
// No convar for this one rn, didn't find it necessary
MRESReturn ForceVPhysicsCollide_Hook(int pThis, DHookReturn hReturn, DHookParam hParams)
{
int ent = hParams.Get(1);
// Also only works with sm_propspawner_notify_shot 1 cause of this
if (g_aSpawnedProps.FindValue(ent) != -1)
{
hReturn.Value = false;
return MRES_Supercede;
}
return MRES_Ignored;
}