diff options
author | Andrius Peleckas <32540208+sanctum32@users.noreply.github.com> | 2021-10-14 15:06:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 14:06:28 +0200 |
commit | 5d73180c6130369d6ef54f49598af4250f8fc6d4 (patch) | |
tree | 7e8f333ff7a8b931a7c1ca047250dcb8364772a4 | |
parent | 9e3949232cc0ad1703eb4b8bba66dd54b4246ceb (diff) |
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
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 48 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 1 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 9 |
3 files changed, 57 insertions, 1 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index bf7a0b18ee..ae28629f9b 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -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; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index d3c1844885..dc66d22d90 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -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); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 3288c3efc2..93532f3518 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -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 |