From b03ffdcac494d4ce3d94665ac71a565fa0454325 Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Sun, 5 Jan 2025 13:04:34 -0600 Subject: [PATCH] Fix VScript not having "self" during precache, props not using death hook, VScript proxies not cleaning up correctly --- sp/src/game/client/vscript_client.cpp | 2 ++ sp/src/game/server/props.cpp | 6 ++++++ sp/src/game/shared/vscript_shared.cpp | 3 +++ 3 files changed, 11 insertions(+) diff --git a/sp/src/game/client/vscript_client.cpp b/sp/src/game/client/vscript_client.cpp index 7bece925..2312d6ca 100644 --- a/sp/src/game/client/vscript_client.cpp +++ b/sp/src/game/client/vscript_client.cpp @@ -272,6 +272,8 @@ void CScriptMaterialProxy::Release( void ) m_hScriptInstance = NULL; } + g_ScriptPersistableList.FindAndRemove( this ); + delete this; } diff --git a/sp/src/game/server/props.cpp b/sp/src/game/server/props.cpp index 57e33d87..037a0226 100644 --- a/sp/src/game/server/props.cpp +++ b/sp/src/game/server/props.cpp @@ -1338,6 +1338,12 @@ int CBreakableProp::OnTakeDamage( const CTakeDamageInfo &inputInfo ) //----------------------------------------------------------------------------- void CBreakableProp::Event_Killed( const CTakeDamageInfo &info ) { +#ifdef MAPBASE_VSCRIPT + // False = Cheat death + if (ScriptDeathHook( const_cast(&info) ) == false) + return; +#endif + IPhysicsObject *pPhysics = VPhysicsGetObject(); if ( pPhysics && !pPhysics->IsMoveable() ) { diff --git a/sp/src/game/shared/vscript_shared.cpp b/sp/src/game/shared/vscript_shared.cpp index 8ab2ac97..c41ddea6 100644 --- a/sp/src/game/shared/vscript_shared.cpp +++ b/sp/src/game/shared/vscript_shared.cpp @@ -624,6 +624,9 @@ public: if ( g_pScriptVM->GetValue( STRING(pEnt->m_iszScriptId), &variant ) && variant.m_type == FIELD_HSCRIPT ) { pEnt->m_ScriptScope.Init( variant.m_hScript, false ); +#ifdef MAPBASE_VSCRIPT + g_pScriptVM->SetValue( pEnt->m_ScriptScope, "self", pEnt->m_hScriptInstance ); +#endif #ifndef CLIENT_DLL pEnt->RunPrecacheScripts(); #endif