From d2ef341bbb456bea9be8faa86557cefd67158c86 Mon Sep 17 00:00:00 2001 From: KitRifty Date: Tue, 22 Aug 2023 20:56:34 +0000 Subject: [PATCH 1/4] Propagate events triggered in OnEnd() Replace event result stack with counter PtrToPawnAddress leftovers for actions --- extension/cbasenpc_behavior.cpp | 75 ++++++++++--------- extension/cbasenpc_behavior.h | 30 +------- extension/sourcesdk/NextBot/NextBotBehavior.h | 2 + 3 files changed, 44 insertions(+), 63 deletions(-) diff --git a/extension/cbasenpc_behavior.cpp b/extension/cbasenpc_behavior.cpp index 4ac9d24..efa6bf5 100644 --- a/extension/cbasenpc_behavior.cpp +++ b/extension/cbasenpc_behavior.cpp @@ -19,7 +19,7 @@ ActionResult< INextBot > CBaseNPCPluginAction:: funcName (INextBot* me, ##__VA_A ResetPluginActionResult(); \ IPluginFunction* pCallback = m_pFactory->GetCallback( CBaseNPCPluginActionFactory::CallbackType::typeName ); \ if (pCallback && pCallback->IsRunnable()) { \ - pCallback->PushCell((cell_t)this); pCallback->PushCell(gamehelpers->EntityToBCompatRef(me->GetEntity())); + pCallback->PushCell(PtrToPawnAddress(this)); pCallback->PushCell(gamehelpers->EntityToBCompatRef(me->GetEntity())); #define BEGINACTIONCALLBACK(funcName, ...) BEGINACTIONCALLBACKEX(funcName, funcName, ##__VA_ARGS__) @@ -35,7 +35,7 @@ QueryResultType CBaseNPCPluginAction:: funcName ( const INextBot *me, ##__VA_ARG cell_t result = ANSWER_UNDEFINED; \ IPluginFunction* pCallback = m_pFactory->GetQueryCallback( CBaseNPCPluginActionFactory::QueryCallbackType::funcName ); \ if (pCallback && pCallback->IsRunnable()) { \ - CBPUSHCELL(this); CBPUSHCELL(me); + CBPUSHCELL(PtrToPawnAddress(this)); CBPUSHCELL(PtrToPawnAddress(me)); #define ENDQUERYCALLBACK() \ pCallback->Execute(&result); \ @@ -45,11 +45,11 @@ QueryResultType CBaseNPCPluginAction:: funcName ( const INextBot *me, ##__VA_ARG #define BEGINEVENTCALLBACKEX(funcName, typeName, ...) \ EventDesiredResult< INextBot > CBaseNPCPluginAction:: funcName (INextBot* me, ##__VA_ARGS__) { \ - m_eventResultStack.push( m_pluginEventResult ); \ + m_inEventCallback++; \ ResetPluginEventResult(); \ IPluginFunction* pCallback = m_pFactory->GetEventCallback( CBaseNPCPluginActionFactory::EventResponderCallbackType::typeName ); \ if (pCallback && pCallback->IsRunnable()) { \ - pCallback->PushCell((cell_t)this); \ + pCallback->PushCell(PtrToPawnAddress(this)); \ pCallback->PushCell(gamehelpers->EntityToBCompatRef(me->GetEntity())); #define BEGINEVENTCALLBACK(funcName, ...) BEGINEVENTCALLBACKEX(funcName, funcName, ##__VA_ARGS__) @@ -63,18 +63,14 @@ EventDesiredResult< INextBot > CBaseNPCPluginAction:: funcName (INextBot* me, ## #define ENDEVENTCALLBACK() \ pCallback->Execute(nullptr); \ } \ - EventDesiredResult< INextBot > result = m_pluginEventResult; \ - m_pluginEventResult = m_eventResultStack.front(); \ - m_eventResultStack.pop(); \ - return result; \ + m_inEventCallback--; \ + return m_pluginEventResult; \ } #define ENDEVENTCALLBACK_NOEXECUTE() \ } \ - EventDesiredResult< INextBot > result = m_pluginEventResult; \ - m_pluginEventResult = m_eventResultStack.front(); \ - m_eventResultStack.pop(); \ - return result; \ + m_inEventCallback--; \ + return m_pluginEventResult; \ } // https://github.com/alliedmodders/sourcemod/blob/6928d21bcf746920b0f2f54e2c28b34097a66be2/core/smn_keyvalues.h#L42 @@ -103,6 +99,7 @@ CBaseNPCPluginAction::CBaseNPCPluginAction(CBaseNPCPluginActionFactory* pFactory ResetPluginEventResult(); m_bInActionCallback = false; + m_inEventCallback = 0; pFactory->OnActionCreated(this); } @@ -188,7 +185,7 @@ void CBaseNPCPluginAction::PluginTryToSustain( EventResultPriorityType priority, // Actions BEGINACTIONCALLBACK(OnStart, Action< INextBot > *prevAction) - CBPUSHCELL(prevAction) + CBPUSHCELL(PtrToPawnAddress(prevAction)) ENDACTIONCALLBACK() BEGINACTIONCALLBACK(Update, float interval) @@ -196,11 +193,11 @@ BEGINACTIONCALLBACK(Update, float interval) ENDACTIONCALLBACK() BEGINACTIONCALLBACK(OnSuspend, Action< INextBot > *interruptingAction) - CBPUSHCELL(interruptingAction) + CBPUSHCELL(PtrToPawnAddress(interruptingAction)) ENDACTIONCALLBACK() BEGINACTIONCALLBACK(OnResume, Action< INextBot > *interruptingAction) - CBPUSHCELL(interruptingAction) + CBPUSHCELL(PtrToPawnAddress(interruptingAction)) ENDACTIONCALLBACK() void CBaseNPCPluginAction::OnEnd( INextBot * me, Action< INextBot > *nextAction ) @@ -208,11 +205,17 @@ void CBaseNPCPluginAction::OnEnd( INextBot * me, Action< INextBot > *nextAction IPluginFunction* pCallback = m_pFactory->GetCallback( CBaseNPCPluginActionFactory::CallbackType::OnEnd ); if (pCallback && pCallback->IsRunnable()) { - CBPUSHCELL(this) + CBPUSHCELL(PtrToPawnAddress(this)) CBPUSHENTITY(me->GetEntity()) - CBPUSHCELL(nextAction) + CBPUSHCELL(PtrToPawnAddress(nextAction)) + + // Allow events in OnEnd to propagate to buried actions. + bool oldStarted = m_isStarted; + m_isStarted = true; pCallback->Execute(nullptr); + + m_isStarted = oldStarted; } } @@ -223,13 +226,13 @@ Action< INextBot >* CBaseNPCPluginAction::InitialContainedAction( INextBot * me IPluginFunction* pCallback = m_pFactory->GetCallback( CBaseNPCPluginActionFactory::CallbackType::InitialContainedAction ); if (pCallback && pCallback->IsRunnable()) { - CBPUSHCELL(this) + CBPUSHCELL(PtrToPawnAddress(this)) CBPUSHENTITY(me->GetEntity()) pCallback->Execute(&result); } - return (Action< INextBot >*)result; + return (Action< INextBot >*)PawnAddressToPtr(result); } bool CBaseNPCPluginAction::IsAbleToBlockMovementOf( const INextBot *botInMotion ) const @@ -239,8 +242,8 @@ bool CBaseNPCPluginAction::IsAbleToBlockMovementOf( const INextBot *botInMotion IPluginFunction* pCallback = m_pFactory->GetCallback( CBaseNPCPluginActionFactory::CallbackType::IsAbleToBlockMovementOf ); if (pCallback && pCallback->IsRunnable()) { - CBPUSHCELL(this) - CBPUSHCELL(botInMotion) + CBPUSHCELL(PtrToPawnAddress(this)) + CBPUSHCELL(PtrToPawnAddress(botInMotion)) pCallback->Execute(&result); } @@ -261,7 +264,7 @@ BEGINQUERYCALLBACK(ShouldRetreat) ENDQUERYCALLBACK() BEGINQUERYCALLBACK(ShouldAttack, const CKnownEntity *them) - CBPUSHCELL(them) + CBPUSHCELL(PtrToPawnAddress(them)) ENDQUERYCALLBACK() BEGINQUERYCALLBACK(IsHindrance, CBaseEntity* blocker) @@ -280,8 +283,8 @@ Vector CBaseNPCPluginAction::SelectTargetPoint( const INextBot* me, const CBaseC buffer[1] = sp_ftoc(result[1]); buffer[2] = sp_ftoc(result[2]); - CBPUSHCELL(this) - CBPUSHCELL(me) + CBPUSHCELL(PtrToPawnAddress(this)) + CBPUSHCELL(PtrToPawnAddress(me)) CBPUSHENTITY((CBaseCombatCharacter*)subject) pCallback->PushArray(buffer, 3, SM_PARAM_COPYBACK); pCallback->Execute(nullptr); @@ -308,15 +311,15 @@ const CKnownEntity * CBaseNPCPluginAction::SelectMoreDangerousThreat( const INex IPluginFunction* pCallback = m_pFactory->GetQueryCallback( CBaseNPCPluginActionFactory::QueryCallbackType::SelectMoreDangerousThreat ); if (pCallback && pCallback->IsRunnable()) { - CBPUSHCELL(this) - CBPUSHCELL(me) + CBPUSHCELL(PtrToPawnAddress(this)) + CBPUSHCELL(PtrToPawnAddress(me)) CBPUSHENTITY((CBaseCombatCharacter*)subject) - CBPUSHCELL(threat1) - CBPUSHCELL(threat2) + CBPUSHCELL(PtrToPawnAddress(threat1)) + CBPUSHCELL(PtrToPawnAddress(threat2)) pCallback->Execute(&result); } - return (const CKnownEntity*)result; + return (const CKnownEntity*)PawnAddressToPtr(result); } // Events @@ -331,15 +334,15 @@ ENDEVENTCALLBACK() BEGINEVENTCALLBACK(OnContact, CBaseEntity* other, CGameTrace* traceResult) EVENTPUSHENTITY(other) - EVENTPUSHCELL(traceResult) + EVENTPUSHCELL(PtrToPawnAddress(traceResult)) ENDEVENTCALLBACK() BEGINEVENTCALLBACK(OnMoveToSuccess, const Path *path) - EVENTPUSHCELL(path) + EVENTPUSHCELL(PtrToPawnAddress(path)) ENDEVENTCALLBACK() BEGINEVENTCALLBACK(OnMoveToFailure, const Path *path, MoveToFailureType reason) - EVENTPUSHCELL(path) + EVENTPUSHCELL(PtrToPawnAddress(path)) EVENTPUSHCELL(reason) ENDEVENTCALLBACK() @@ -438,7 +441,7 @@ ENDEVENTCALLBACK_NOEXECUTE() BEGINEVENTCALLBACK(OnSpokeConcept, CBaseCombatCharacter* who, AIConcept_t concept, AI_Response *response) EVENTPUSHENTITY(who) EVENTPUSHCELL(concept) - EVENTPUSHCELL(response) + EVENTPUSHCELL(PtrToPawnAddress(response)) ENDEVENTCALLBACK() BEGINEVENTCALLBACK(OnWeaponFired, CBaseCombatCharacter* whoFired, CBaseEntity* weapon ) @@ -447,8 +450,8 @@ BEGINEVENTCALLBACK(OnWeaponFired, CBaseCombatCharacter* whoFired, CBaseEntity* w ENDEVENTCALLBACK() BEGINEVENTCALLBACK(OnNavAreaChanged, CNavArea *newArea, CNavArea *oldArea) - EVENTPUSHCELL(newArea) - EVENTPUSHCELL(oldArea) + EVENTPUSHCELL(PtrToPawnAddress(newArea)) + EVENTPUSHCELL(PtrToPawnAddress(oldArea)) ENDEVENTCALLBACK() BEGINEVENTCALLBACK(OnModelChanged) @@ -756,7 +759,7 @@ void CBaseNPCPluginActionFactory::OnCreateInitialAction(Action * pActi IPluginFunction * pCallback = GetCallback( CreateInitialAction ); if (pCallback && pCallback->IsRunnable()) { - pCallback->PushCell((cell_t)pAction); + pCallback->PushCell(PtrToPawnAddress(pAction)); pCallback->Execute(nullptr); } } diff --git a/extension/cbasenpc_behavior.h b/extension/cbasenpc_behavior.h index 82ba966..a4b7987 100644 --- a/extension/cbasenpc_behavior.h +++ b/extension/cbasenpc_behavior.h @@ -22,24 +22,6 @@ class CBaseNPCPluginAction : public Action private: ActionResult< INextBot > m_pluginActionResult; - - /** - * Stores event result states. - * - * A stack is used to maintain event result states for each event callback. - * This is because events are not atomic; an event can trigger another event - * during execution of a callback. Since the plugin natives write results - * to the shared m_pluginEventResult member, an inner event can overwrite - * the result of the outer event causing unexpected behavior, especially if - * the outer event does not actually use a Try*() native. Thus, the stack - * is used to restore the event result state when exiting an event - * callback. - * - * A stack is not used for m_pluginActionResult because OnStart(), Update(), - * OnSuspend(), OnResume(), and OnEnd() are all atomic; these callbacks - * will never execute within each other. - */ - SourceHook::CStack> m_eventResultStack; EventDesiredResult< INextBot > m_pluginEventResult; void * m_pData; @@ -47,6 +29,7 @@ class CBaseNPCPluginAction : public Action CBaseNPCPluginActionFactory * m_pFactory; bool m_bInActionCallback; + int m_inEventCallback; public: CBaseNPCPluginAction(CBaseNPCPluginActionFactory * pFactory); @@ -64,15 +47,8 @@ class CBaseNPCPluginAction : public Action void PluginSuspendFor( Action< INextBot > *action, const char *reason ); void PluginDone( const char *reason ); - bool IsInActionCallback() - { - return m_bInActionCallback; - } - - bool IsInEventCallback() - { - return m_eventResultStack.size() > 0; - } + bool IsInActionCallback() const { return m_bInActionCallback; } + bool IsInEventCallback() const { return m_inEventCallback > 0; } virtual ActionResult< INextBot > OnStart( INextBot *me, Action< INextBot > *prevAction ) override final; virtual ActionResult< INextBot > Update( INextBot *me, float interval ) override final; diff --git a/extension/sourcesdk/NextBot/NextBotBehavior.h b/extension/sourcesdk/NextBot/NextBotBehavior.h index 6675146..56cf1b7 100644 --- a/extension/sourcesdk/NextBot/NextBotBehavior.h +++ b/extension/sourcesdk/NextBot/NextBotBehavior.h @@ -961,7 +961,9 @@ class Action : public INextBotEventResponder, public IContextualQuery Actor *m_actor; // only valid after OnStart() mutable EventDesiredResult< Actor > m_eventResult; // set by event handlers +protected: bool m_isStarted; // Action doesn't start until OnStart() is invoked +private: bool m_isSuspended; // are we suspended for another Action public: Action< Actor > *GetActionBuriedUnderMe( void ) const // return Action just "under" us that we will resume to when we finish From 2f022713746497fabf904c9551864986cdc8b64f Mon Sep 17 00:00:00 2001 From: KitRifty Date: Tue, 22 Aug 2023 23:06:09 +0000 Subject: [PATCH 2/4] Skip events for ending actions - It doesn't really make sense for events to be processed when an action is being transitioned out (their event result doesn't even matter!). Events should be processed by actions that are still running though. --- extension/cbasenpc_behavior.cpp | 23 ++++++++++--------- extension/cbasenpc_behavior.h | 1 + .../nb_test_scout/behavior/baitaction.sp | 10 ++++++++ .../nb_test_scout/behavior/mainaction.sp | 14 +++++++++++ 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/extension/cbasenpc_behavior.cpp b/extension/cbasenpc_behavior.cpp index efa6bf5..988e95a 100644 --- a/extension/cbasenpc_behavior.cpp +++ b/extension/cbasenpc_behavior.cpp @@ -45,6 +45,7 @@ QueryResultType CBaseNPCPluginAction:: funcName ( const INextBot *me, ##__VA_ARG #define BEGINEVENTCALLBACKEX(funcName, typeName, ...) \ EventDesiredResult< INextBot > CBaseNPCPluginAction:: funcName (INextBot* me, ##__VA_ARGS__) { \ + if (m_skipEvents) { return TryContinue(); } \ m_inEventCallback++; \ ResetPluginEventResult(); \ IPluginFunction* pCallback = m_pFactory->GetEventCallback( CBaseNPCPluginActionFactory::EventResponderCallbackType::typeName ); \ @@ -100,6 +101,7 @@ CBaseNPCPluginAction::CBaseNPCPluginAction(CBaseNPCPluginActionFactory* pFactory m_bInActionCallback = false; m_inEventCallback = 0; + m_skipEvents = false; pFactory->OnActionCreated(this); } @@ -200,23 +202,22 @@ BEGINACTIONCALLBACK(OnResume, Action< INextBot > *interruptingAction) CBPUSHCELL(PtrToPawnAddress(interruptingAction)) ENDACTIONCALLBACK() -void CBaseNPCPluginAction::OnEnd( INextBot * me, Action< INextBot > *nextAction ) -{ +void CBaseNPCPluginAction::OnEnd( INextBot * me, Action< INextBot > *nextAction ) { + bool oldStarted = m_isStarted; + + // Allow events in OnEnd to propagate to buried actions. + m_isStarted = true; + m_skipEvents = true; // pass over myself since I'm ending + IPluginFunction* pCallback = m_pFactory->GetCallback( CBaseNPCPluginActionFactory::CallbackType::OnEnd ); - if (pCallback && pCallback->IsRunnable()) - { + if (pCallback && pCallback->IsRunnable()) { CBPUSHCELL(PtrToPawnAddress(this)) CBPUSHENTITY(me->GetEntity()) CBPUSHCELL(PtrToPawnAddress(nextAction)) - - // Allow events in OnEnd to propagate to buried actions. - bool oldStarted = m_isStarted; - m_isStarted = true; - pCallback->Execute(nullptr); - - m_isStarted = oldStarted; } + + m_isStarted = oldStarted; } Action< INextBot >* CBaseNPCPluginAction::InitialContainedAction( INextBot * me ) diff --git a/extension/cbasenpc_behavior.h b/extension/cbasenpc_behavior.h index a4b7987..3c2511b 100644 --- a/extension/cbasenpc_behavior.h +++ b/extension/cbasenpc_behavior.h @@ -30,6 +30,7 @@ class CBaseNPCPluginAction : public Action bool m_bInActionCallback; int m_inEventCallback; + bool m_skipEvents; public: CBaseNPCPluginAction(CBaseNPCPluginActionFactory * pFactory); diff --git a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp index 54e834a..985ffc7 100644 --- a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp +++ b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp @@ -21,6 +21,7 @@ methodmap TestScoutBotBaitAction < NextBotAction ActionFactory.SetCallback(NextBotActionCallbackType_OnEnd, OnEnd); ActionFactory.SetCallback(NextBotActionCallbackType_OnSuspend, OnSuspend); ActionFactory.SetEventCallback(EventResponderType_OnInjured, OnInjured); + ActionFactory.SetEventCallback(EventResponderType_OnCommandString, OnCommandString); } public TestScoutBotBaitAction() @@ -57,6 +58,8 @@ methodmap TestScoutBotBaitAction < NextBotAction static int OnStart(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction prevAction) { + actor.MyNextBotPointer().GetIntentionInterface().OnCommandString("started baiting"); + for (int i = 0; i < sizeof(g_sStartSounds); i++) { PrecacheSound(g_sStartSounds[i]); @@ -135,6 +138,7 @@ static int Update(TestScoutBotBaitAction action, TestScoutBot actor, float inter static void OnEnd(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction nextAction) { + actor.MyNextBotPointer().GetIntentionInterface().OnCommandString("stopped baiting"); } static int OnSuspend(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction interruptingAction) @@ -154,4 +158,10 @@ static int OnInjured(TestScoutBotBaitAction action, const float damagePosition[3], int damageCustom ) { return action.TryDone(); +} + +static void OnCommandString(TestScoutBotBaitAction action, TestScoutBot actor, const char[] command) { + if (strcmp(command, "started baiting") == 0 || strcmp(command, "stopped baiting") == 0) { + LogError("You shouldn't be seeing this."); + } } \ No newline at end of file diff --git a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp index b7c571a..4436420 100644 --- a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp +++ b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp @@ -14,6 +14,7 @@ methodmap TestScoutBotMainAction < NextBotAction ActionFactory.SetCallback(NextBotActionCallbackType_OnEnd, OnEnd); ActionFactory.SetEventCallback(EventResponderType_OnInjured, OnInjured); ActionFactory.SetEventCallback(EventResponderType_OnKilled, OnKilled); + ActionFactory.SetEventCallback(EventResponderType_OnCommandString, OnCommandString); } public static NextBotActionFactory GetFactory() @@ -151,4 +152,17 @@ static int OnKilled(TestScoutBotMainAction action, const float damagePosition[3], int damageCustom) { return action.TryChangeTo(TestScoutBotDeathAction(damagetype), RESULT_CRITICAL); +} + +static void OnCommandString(TestScoutBotMainAction action, TestScoutBot actor, const char[] command) { + if (strcmp(command, "started baiting") == 0) { + if (actor.MyNextBotPointer().IsDebugging(DEBUG_BEHAVIOR)) { + PrintToChatAll("The Scout #%d: I started taunting!", actor.index); + } + } + else if (strcmp(command, "stopped baiting") == 0) { + if (actor.MyNextBotPointer().IsDebugging(DEBUG_BEHAVIOR)) { + PrintToChatAll("The Scout #%d: I stopped taunting!", actor.index); + } + } } \ No newline at end of file From 710b69359c6378c8752690b4a7984f74d83b3e40 Mon Sep 17 00:00:00 2001 From: KitRifty Date: Wed, 23 Aug 2023 15:28:01 +0000 Subject: [PATCH 3/4] Strip modified event propagation Revert changes to example plugin --- extension/cbasenpc_behavior.cpp | 10 ---------- extension/cbasenpc_behavior.h | 1 - extension/sourcesdk/NextBot/NextBotBehavior.h | 2 -- .../nb_test_scout/behavior/baitaction.sp | 10 ---------- .../nb_test_scout/behavior/mainaction.sp | 14 -------------- 5 files changed, 37 deletions(-) diff --git a/extension/cbasenpc_behavior.cpp b/extension/cbasenpc_behavior.cpp index 988e95a..d2073ba 100644 --- a/extension/cbasenpc_behavior.cpp +++ b/extension/cbasenpc_behavior.cpp @@ -45,7 +45,6 @@ QueryResultType CBaseNPCPluginAction:: funcName ( const INextBot *me, ##__VA_ARG #define BEGINEVENTCALLBACKEX(funcName, typeName, ...) \ EventDesiredResult< INextBot > CBaseNPCPluginAction:: funcName (INextBot* me, ##__VA_ARGS__) { \ - if (m_skipEvents) { return TryContinue(); } \ m_inEventCallback++; \ ResetPluginEventResult(); \ IPluginFunction* pCallback = m_pFactory->GetEventCallback( CBaseNPCPluginActionFactory::EventResponderCallbackType::typeName ); \ @@ -101,7 +100,6 @@ CBaseNPCPluginAction::CBaseNPCPluginAction(CBaseNPCPluginActionFactory* pFactory m_bInActionCallback = false; m_inEventCallback = 0; - m_skipEvents = false; pFactory->OnActionCreated(this); } @@ -203,12 +201,6 @@ BEGINACTIONCALLBACK(OnResume, Action< INextBot > *interruptingAction) ENDACTIONCALLBACK() void CBaseNPCPluginAction::OnEnd( INextBot * me, Action< INextBot > *nextAction ) { - bool oldStarted = m_isStarted; - - // Allow events in OnEnd to propagate to buried actions. - m_isStarted = true; - m_skipEvents = true; // pass over myself since I'm ending - IPluginFunction* pCallback = m_pFactory->GetCallback( CBaseNPCPluginActionFactory::CallbackType::OnEnd ); if (pCallback && pCallback->IsRunnable()) { CBPUSHCELL(PtrToPawnAddress(this)) @@ -216,8 +208,6 @@ void CBaseNPCPluginAction::OnEnd( INextBot * me, Action< INextBot > *nextAction CBPUSHCELL(PtrToPawnAddress(nextAction)) pCallback->Execute(nullptr); } - - m_isStarted = oldStarted; } Action< INextBot >* CBaseNPCPluginAction::InitialContainedAction( INextBot * me ) diff --git a/extension/cbasenpc_behavior.h b/extension/cbasenpc_behavior.h index 3c2511b..a4b7987 100644 --- a/extension/cbasenpc_behavior.h +++ b/extension/cbasenpc_behavior.h @@ -30,7 +30,6 @@ class CBaseNPCPluginAction : public Action bool m_bInActionCallback; int m_inEventCallback; - bool m_skipEvents; public: CBaseNPCPluginAction(CBaseNPCPluginActionFactory * pFactory); diff --git a/extension/sourcesdk/NextBot/NextBotBehavior.h b/extension/sourcesdk/NextBot/NextBotBehavior.h index 56cf1b7..6675146 100644 --- a/extension/sourcesdk/NextBot/NextBotBehavior.h +++ b/extension/sourcesdk/NextBot/NextBotBehavior.h @@ -961,9 +961,7 @@ class Action : public INextBotEventResponder, public IContextualQuery Actor *m_actor; // only valid after OnStart() mutable EventDesiredResult< Actor > m_eventResult; // set by event handlers -protected: bool m_isStarted; // Action doesn't start until OnStart() is invoked -private: bool m_isSuspended; // are we suspended for another Action public: Action< Actor > *GetActionBuriedUnderMe( void ) const // return Action just "under" us that we will resume to when we finish diff --git a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp index 985ffc7..54e834a 100644 --- a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp +++ b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp @@ -21,7 +21,6 @@ methodmap TestScoutBotBaitAction < NextBotAction ActionFactory.SetCallback(NextBotActionCallbackType_OnEnd, OnEnd); ActionFactory.SetCallback(NextBotActionCallbackType_OnSuspend, OnSuspend); ActionFactory.SetEventCallback(EventResponderType_OnInjured, OnInjured); - ActionFactory.SetEventCallback(EventResponderType_OnCommandString, OnCommandString); } public TestScoutBotBaitAction() @@ -58,8 +57,6 @@ methodmap TestScoutBotBaitAction < NextBotAction static int OnStart(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction prevAction) { - actor.MyNextBotPointer().GetIntentionInterface().OnCommandString("started baiting"); - for (int i = 0; i < sizeof(g_sStartSounds); i++) { PrecacheSound(g_sStartSounds[i]); @@ -138,7 +135,6 @@ static int Update(TestScoutBotBaitAction action, TestScoutBot actor, float inter static void OnEnd(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction nextAction) { - actor.MyNextBotPointer().GetIntentionInterface().OnCommandString("stopped baiting"); } static int OnSuspend(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction interruptingAction) @@ -158,10 +154,4 @@ static int OnInjured(TestScoutBotBaitAction action, const float damagePosition[3], int damageCustom ) { return action.TryDone(); -} - -static void OnCommandString(TestScoutBotBaitAction action, TestScoutBot actor, const char[] command) { - if (strcmp(command, "started baiting") == 0 || strcmp(command, "stopped baiting") == 0) { - LogError("You shouldn't be seeing this."); - } } \ No newline at end of file diff --git a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp index 4436420..b7c571a 100644 --- a/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp +++ b/scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp @@ -14,7 +14,6 @@ methodmap TestScoutBotMainAction < NextBotAction ActionFactory.SetCallback(NextBotActionCallbackType_OnEnd, OnEnd); ActionFactory.SetEventCallback(EventResponderType_OnInjured, OnInjured); ActionFactory.SetEventCallback(EventResponderType_OnKilled, OnKilled); - ActionFactory.SetEventCallback(EventResponderType_OnCommandString, OnCommandString); } public static NextBotActionFactory GetFactory() @@ -152,17 +151,4 @@ static int OnKilled(TestScoutBotMainAction action, const float damagePosition[3], int damageCustom) { return action.TryChangeTo(TestScoutBotDeathAction(damagetype), RESULT_CRITICAL); -} - -static void OnCommandString(TestScoutBotMainAction action, TestScoutBot actor, const char[] command) { - if (strcmp(command, "started baiting") == 0) { - if (actor.MyNextBotPointer().IsDebugging(DEBUG_BEHAVIOR)) { - PrintToChatAll("The Scout #%d: I started taunting!", actor.index); - } - } - else if (strcmp(command, "stopped baiting") == 0) { - if (actor.MyNextBotPointer().IsDebugging(DEBUG_BEHAVIOR)) { - PrintToChatAll("The Scout #%d: I stopped taunting!", actor.index); - } - } } \ No newline at end of file From 6ebde936d066bdb467d13d255ff49c089b3e29c1 Mon Sep 17 00:00:00 2001 From: Benoist <14257866+Kenzzer@users.noreply.github.com> Date: Wed, 23 Aug 2023 20:44:22 +0200 Subject: [PATCH 4/4] Update product.version --- product.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product.version b/product.version index 81c871d..4dae298 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -1.10.0 +1.10.1