diff --git a/src/game/shared/tf/tf_player_shared.cpp b/src/game/shared/tf/tf_player_shared.cpp index 65297449744..03e8a54a6f9 100644 --- a/src/game/shared/tf/tf_player_shared.cpp +++ b/src/game/shared/tf/tf_player_shared.cpp @@ -67,6 +67,7 @@ // Server specific. #else +#include "vscript_server.h" #include "tf_player.h" #include "te_effect_dispatch.h" #include "tf_fx.h" @@ -1089,6 +1090,31 @@ class CConditionVars //----------------------------------------------------------------------------- void CTFPlayerShared::AddCond( ETFCond eCond, float flDuration /* = PERMANENT_CONDITION */, CBaseEntity *pProvider /*= NULL */) { +#ifndef CLIENT_DLL + if ( ScriptHookEnabled( "OnAddCond" ) ) + { + IScriptVM *pVM = g_pScriptVM; + + ScriptVariant_t varTable; + pVM->CreateTable( varTable ); + + pVM->SetValue( varTable, "const_entity", ToHScript( m_pOuter ) ); + pVM->SetValue( varTable, "provider", ToHScript( pProvider ) ); + pVM->SetValue( varTable, "duration", flDuration ); + pVM->SetValue( varTable, "condition", eCond ); + pVM->SetValue( varTable, "cancel_condition", false ); + + if ( RunScriptHook( "OnAddCond", varTable ) ) + { + if ( pVM->Get( varTable, "cancel_condition" ) ) + return; + eCond = static_cast( pVM->Get( varTable, "condition" ) ); + flDuration = pVM->Get( varTable, "duration" ); + pProvider = ToEnt( pVM->Get( varTable, "provider" ) ); + } + } +#endif + Assert( eCond >= 0 && eCond < TF_COND_LAST ); Assert( eCond < m_ConditionData.Count() ); @@ -1150,6 +1176,29 @@ void CTFPlayerShared::AddCond( ETFCond eCond, float flDuration /* = PERMANENT_CO //----------------------------------------------------------------------------- void CTFPlayerShared::RemoveCond( ETFCond eCond, bool ignore_duration ) { +#ifndef CLIENT_DLL + if ( ScriptHookEnabled( "OnRemoveCond" ) ) + { + IScriptVM *pVM = g_pScriptVM; + + ScriptVariant_t varTable; + pVM->CreateTable( varTable ); + + pVM->SetValue( varTable, "const_entity", ToHScript( m_pOuter ) ); + pVM->SetValue( varTable, "condition", eCond ); + pVM->SetValue( varTable, "ignore_duration", ignore_duration ); + pVM->SetValue( varTable, "cancel_removal", false ); + + if ( RunScriptHook( "OnRemoveCond", varTable ) ) + { + if ( pVM->Get( varTable, "cancel_removal" ) ) + return; + ignore_duration = pVM->Get( varTable, "ignoreDuration" ); + eCond = static_cast( pVM->Get( varTable, "condition" ) ); + } + } +#endif + Assert( eCond >= 0 && eCond < TF_COND_LAST ); Assert( eCond < m_ConditionData.Count() );