diff options
author | MitchesD <majklprofik@seznam.cz> | 2015-05-02 15:35:07 +0200 |
---|---|---|
committer | MitchesD <majklprofik@seznam.cz> | 2015-05-02 15:38:15 +0200 |
commit | 5dba91fb0e38c65eb3ae66d7e63754321d3e235d (patch) | |
tree | 3d1e464080b320b97175d1c8d353864c823f99b8 | |
parent | d2224dcd7adca251c17d61125cdbeae6af84399c (diff) |
Core/SAI: SMART_ACTION_SET_COUNTER now can be used for all targets, not just for self
(cherry picked from commit feabc6dff18cfcd00647e885133d066fcbab0724)
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index a5698092d69..267c038faaf 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1321,7 +1321,31 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_SET_COUNTER: { - StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset); + if (ObjectList* targets = GetTargets(e, unit)) + { + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) + { + if (IsCreature(*itr)) + { + if (SmartAI* ai = CAST_AI(SmartAI, (*itr)->ToCreature()->AI())) + ai->GetScript()->StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset); + else + TC_LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping"); + } + else if (IsGameObject(*itr)) + { + if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, (*itr)->ToGameObject()->AI())) + ai->GetScript()->StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset); + else + TC_LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping"); + } + } + + delete targets; + } + else + StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset); + break; } case SMART_ACTION_WP_START: |