Core/SmartAI: Implement SMART_ACTION_SET_POWER, SMART_ACTION_ADD_POWER and SMART_ACTION_REMOVE_POWER (param1 = powertype, param2 = newPower). Required for upcoming EAI to SAI conversion (for ACTION_T_SET_UNIT_FIELD) (only SMART_ACTION_SET_POWER is required for the conversion but might as well do it right when on it).

This commit is contained in:
Discover- committed 2013-08-10 14:13:17 +02:00
1 parent b7d88a3c46
commit 75ca3573c8
3 files changed
+55 -3

No files matched your search

@@ -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;