diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 38 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 9 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 11 |
3 files changed, 55 insertions, 3 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 261c4166a15..c4c208e596e 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2097,13 +2097,47 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u GetBaseObject()->SummonCreatureGroup(e.action.creatureGroup.group, &summonList); for (std::list<TempSummon*>::const_iterator itr = summonList.begin(); itr != summonList.end(); ++itr) - { if (unit && e.action.creatureGroup.attackInvoker) (*itr)->AI()->AttackStart(unit); - } break; } + case SMART_ACTION_SET_POWER: + { + ObjectList* targets = GetTargets(e, unit); + + if (targets) + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) + if (IsUnit(*itr)) + (*itr)->ToUnit()->SetPower(Powers(e.action.power.powerType), e.action.power.newPower); + + delete targets; + break; + } + case SMART_ACTION_ADD_POWER: + { + ObjectList* targets = GetTargets(e, unit); + + if (targets) + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) + if (IsUnit(*itr)) + (*itr)->ToUnit()->SetPower(Powers(e.action.power.powerType), (*itr)->ToUnit()->GetPower(Powers(e.action.power.powerType)) + e.action.power.newPower); + + delete targets; + break; + } + case SMART_ACTION_REMOVE_POWER: + { + ObjectList* targets = GetTargets(e, unit); + + if (targets) + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) + if (IsUnit(*itr)) + (*itr)->ToUnit()->SetPower(Powers(e.action.power.powerType), (*itr)->ToUnit()->GetPower(Powers(e.action.power.powerType)) - e.action.power.newPower); + + delete targets; + break; + } default: TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); break; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index eeeacb36032..aced7ef66cc 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -838,6 +838,15 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) return false; break; } + case SMART_ACTION_SET_POWER: + case SMART_ACTION_ADD_POWER: + case SMART_ACTION_REMOVE_POWER: + if (e.action.power.powerType > MAX_POWERS) + { + TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Power %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.power.powerType); + return false; + } + break; case SMART_ACTION_FOLLOW: case SMART_ACTION_SET_ORIENTATION: case SMART_ACTION_STORE_TARGET_LIST: diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 394ede7fb54..a8ed1ef757b 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -489,8 +489,11 @@ enum SMART_ACTION SMART_ACTION_ADD_GO_FLAG = 105, // Flags SMART_ACTION_REMOVE_GO_FLAG = 106, // Flags SMART_ACTION_SUMMON_CREATURE_GROUP = 107, // Group, attackInvoker + SMART_ACTION_SET_POWER = 108, // PowerType, newPower + SMART_ACTION_ADD_POWER = 109, // PowerType, newPower + SMART_ACTION_REMOVE_POWER = 110, // PowerType, newPower - SMART_ACTION_END = 108 + SMART_ACTION_END = 111 }; struct SmartAction @@ -944,6 +947,12 @@ struct SmartAction uint32 attackInvoker; } creatureGroup; + struct + { + uint32 powerType; + uint32 newPower; + } power; + //! Note for any new future actions //! All parameters must have type uint32 |