diff options
author | Shauren <shauren.trinity@gmail.com> | 2012-01-22 16:56:55 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2012-01-22 16:56:55 +0100 |
commit | 94c27e3cce0e056f35f4a17775630ae1e9675345 (patch) | |
tree | 2865732448d46c789fb02ec68c394798f504a69d /src | |
parent | c24248fabdaa4cb63297973d9a0f744c82b99335 (diff) |
Core/SmartAI: Fixed SMART_ACTION_SEND_TARGET_TO_TARGET for gameobject targets
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 0266ee45f28..08583406127 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1783,10 +1783,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u case SMART_ACTION_GO_SET_LOOT_STATE: { ObjectList* targets = GetTargets(e, unit); - + if (!targets) return; - + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) if (IsGameObject(*itr)) (*itr)->ToGameObject()->SetLootState((LootState)e.action.setGoLootState.state); @@ -1797,23 +1797,25 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u case SMART_ACTION_SEND_TARGET_TO_TARGET: { ObjectList* targets = GetTargets(e, unit); - if (!targets) return; - + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - SmartAI* ai = NULL; - if (IsGameObject(*itr)) - ai = CAST_AI(SmartAI, (*itr)->ToGameObject()->AI()); - if (IsCreature(*itr)) - ai = CAST_AI(SmartAI, (*itr)->ToCreature()->AI()); - - if (ai) - ai->GetScript()->StoreTargetList(GetTargetList(e.action.sendTargetToTarget.id), e.action.sendTargetToTarget.id); - else - sLog->outErrorDb("SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping"); + { + if (SmartAI* ai = CAST_AI(SmartAI, (*itr)->ToCreature()->AI())) + ai->GetScript()->StoreTargetList(GetTargetList(e.action.sendTargetToTarget.id), e.action.sendTargetToTarget.id); + else + sLog->outErrorDb("SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping"); + } + else if (IsGameObject(*itr)) + { + if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, (*itr)->ToGameObject()->AI())) + ai->GetScript()->StoreTargetList(GetTargetList(e.action.sendTargetToTarget.id), e.action.sendTargetToTarget.id); + else + sLog->outErrorDb("SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping"); + } } delete targets; |