Core/SAI: Added Action SMART_ACTION_DO_ACTION for calling DoAction on target AI (#27964)

This commit is contained in:
Antonio Martín Berti
2022-06-08 10:50:44 -03:00
committed by GitHub
parent be800a983f
commit a4eafbd3f6
3 changed files with 27 additions and 1 deletions

View File

@@ -2481,6 +2481,24 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
}
case SMART_ACTION_DO_ACTION:
{
for (WorldObject* target : targets)
{
if (Unit* unitTarget = Object::ToUnit(target))
{
if (unitTarget->GetAI())
unitTarget->GetAI()->DoAction(e.action.doAction.actionId);
}
else if (GameObject* goTarget = Object::ToGameObject(target))
{
if (goTarget->AI())
goTarget->AI()->DoAction(e.action.doAction.actionId);
}
}
break;
}
default:
TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry " SI64FMTD " SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break;

View File

@@ -1006,6 +1006,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
case SMART_ACTION_ADD_TO_STORED_TARGET_LIST: return sizeof(SmartAction::addToStoredTargets);
case SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER: return sizeof(SmartAction::becomePersonalClone);
case SMART_ACTION_TRIGGER_GAME_EVENT: return sizeof(SmartAction::triggerGameEvent);
case SMART_ACTION_DO_ACTION: return sizeof(SmartAction::doAction);
default:
TC_LOG_WARN("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.",
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
@@ -2299,6 +2300,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_SPAWN_SPAWNGROUP:
case SMART_ACTION_DESPAWN_SPAWNGROUP:
case SMART_ACTION_ADD_TO_STORED_TARGET_LIST:
case SMART_ACTION_DO_ACTION:
break;
case SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER:
{

View File

@@ -604,7 +604,8 @@ enum SMART_ACTION
SMART_ACTION_ADD_TO_STORED_TARGET_LIST = 148, // varID
SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER = 149, // summonType 1-8, duration in ms
SMART_ACTION_TRIGGER_GAME_EVENT = 150, // eventId, useSaiTargetAsGameEventSource
SMART_ACTION_END = 151
SMART_ACTION_DO_ACTION = 151, // actionId
SMART_ACTION_END = 152
};
enum class SmartActionSummonCreatureFlags
@@ -1224,6 +1225,11 @@ struct SmartAction
SAIBool useSaiTargetAsGameEventSource;
} triggerGameEvent;
struct
{
uint32 actionId;
} doAction;
//! Note for any new future actions
//! All parameters must have type uint32