mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 20:56:23 +00:00
feat(Core/SAI): implemented a new SAI action type SMART_ACTION_DO_ACTION (#8375)
* feat(Core/SAI): implemented a new SAI action type SMART_ACTION_DO_ACTION This will give possibility to trigger certain actions on instance scripts or creatures/gobjects * yet we still love you "blank line" xD
This commit is contained in:
@@ -3232,6 +3232,54 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_DO_ACTION:
|
||||
{
|
||||
int32 const actionId = e.action.doAction.isNegative ? -e.action.doAction.actionId : e.action.doAction.actionId;
|
||||
if (!e.action.doAction.instanceTarget)
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (WorldObject* objTarget : *targets)
|
||||
{
|
||||
if (Creature const* unitTarget = objTarget->ToCreature())
|
||||
{
|
||||
if (unitTarget->IsAIEnabled)
|
||||
{
|
||||
unitTarget->AI()->DoAction(actionId);
|
||||
}
|
||||
}
|
||||
else if (GameObject const* gobjTarget = objTarget->ToGameObject())
|
||||
{
|
||||
gobjTarget->AI()->DoAction(actionId);
|
||||
}
|
||||
}
|
||||
|
||||
delete targets;
|
||||
}
|
||||
else
|
||||
{
|
||||
InstanceScript* instanceScript = nullptr;
|
||||
if (WorldObject* baseObj = GetBaseObject())
|
||||
{
|
||||
instanceScript = baseObj->GetInstanceScript();
|
||||
}
|
||||
// Action is triggered by AreaTrigger
|
||||
else if (trigger && IsPlayer(unit))
|
||||
{
|
||||
instanceScript = unit->GetInstanceScript();
|
||||
}
|
||||
|
||||
if (instanceScript)
|
||||
{
|
||||
instanceScript->DoAction(actionId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
break;
|
||||
|
||||
@@ -1258,6 +1258,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_VORTEX_SUMMON:
|
||||
case SMART_ACTION_PLAYER_TALK:
|
||||
case SMART_ACTION_CU_ENCOUNTER_START:
|
||||
case SMART_ACTION_DO_ACTION:
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);
|
||||
|
||||
@@ -629,8 +629,9 @@ enum SMART_ACTION
|
||||
SMART_ACTION_PLAYER_TALK = 220, // acore_string.entry, yell? (0/1)
|
||||
SMART_ACTION_VORTEX_SUMMON = 221, // entry, duration (0 = perm), spiral scaling, spiral appearance, range max, phi_delta <-- yes confusing math, try it ingame and see, my lovely AC boys!
|
||||
SMART_ACTION_CU_ENCOUNTER_START = 222, // Resets cooldowns on all targets and removes Heroism debuff(s)
|
||||
SMART_ACTION_DO_ACTION = 223, // ActionId
|
||||
|
||||
SMART_ACTION_AC_END = 223, // placeholder
|
||||
SMART_ACTION_AC_END = 224, // placeholder
|
||||
};
|
||||
|
||||
struct SmartAction
|
||||
@@ -1262,6 +1263,12 @@ struct SmartAction
|
||||
uint32 phi_delta;
|
||||
} summonVortex;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 actionId;
|
||||
uint32 isNegative;
|
||||
uint32 instanceTarget;
|
||||
} doAction;
|
||||
//! Note for any new future actions
|
||||
//! All parameters must have type uint32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user