From 7ec04d1408f47f3ed7c6f1e899350bd69d29d284 Mon Sep 17 00:00:00 2001 From: Gultask <100873791+Gultask@users.noreply.github.com> Date: Tue, 27 Jun 2023 19:34:26 -0300 Subject: [PATCH] feat(Core/SAI): Implement New Smart Actions SET_SCALE & SUMMON_RADIAL (#16444) * init * Update SmartScriptMgr.cpp * Update SmartScript.cpp * Update SmartScriptMgr.h * more * scale * dist offset * Update SmartScriptMgr.h --- .../game/AI/SmartScripts/SmartScript.cpp | 51 +++++++++++++++++++ .../game/AI/SmartScripts/SmartScriptMgr.cpp | 6 ++- .../game/AI/SmartScripts/SmartScriptMgr.h | 24 +++++++-- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 114107f7d..a6dfcfdfe 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1644,6 +1644,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u break; } + if (e.action.orientation.turnAngle) + { + float turnOri = me->GetOrientation() + (static_cast(e.action.orientation.turnAngle) * M_PI / 180.0f); + me->SetFacingTo(turnOri); + if (e.action.orientation.quickChange) + me->SetOrientation(turnOri); + break; + } + if (e.GetTargetType() == SMART_TARGET_SELF) { me->SetFacingTo((me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && me->GetTransGUID() ? me->GetTransportHomePosition() : me->GetHomePosition()).GetOrientation()); @@ -2824,6 +2833,48 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } break; } + case SMART_ACTION_SET_SCALE: + { + float scale = static_cast(e.action.setScale.scale) / 100.0f; + + for (WorldObject* target : targets) + { + if (IsUnit(target)) + { + target->ToUnit()->SetObjectScale(scale); + } + } + break; + } + case SMART_ACTION_SUMMON_RADIAL: + { + if (!me) + break; + + TempSummonType spawnType = (e.action.radialSummon.summonDuration > 0) ? TEMPSUMMON_TIMED_DESPAWN : TEMPSUMMON_CORPSE_DESPAWN; + + float startAngle = me->GetOrientation() + (static_cast(e.action.radialSummon.startAngle) * M_PI / 180.0f); + float stepAngle = static_cast(e.action.radialSummon.stepAngle) * M_PI / 180.0f; + + if (e.action.radialSummon.dist) + { + for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++) + { + Position summonPos = me->GetPosition(); + summonPos.RelocatePolarOffset(itr * stepAngle, static_cast(e.action.radialSummon.dist)); + me->SummonCreature(e.action.radialSummon.summonEntry, summonPos, spawnType, e.action.radialSummon.summonDuration); + } + break; + } + + for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++) + { + float currentAngle = startAngle + (itr * stepAngle); + me->SummonCreature(e.action.radialSummon.summonEntry, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), currentAngle, spawnType, e.action.radialSummon.summonDuration); + } + + break; + } default: LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", 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 701ff7f40..df4481507 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -671,7 +671,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e) case SMART_ACTION_SET_COUNTER: return sizeof(SmartAction::setCounter); case SMART_ACTION_STORE_TARGET_LIST: return sizeof(SmartAction::storeTargets); case SMART_ACTION_WP_RESUME: return NO_PARAMS; - case SMART_ACTION_SET_ORIENTATION: return NO_PARAMS; + case SMART_ACTION_SET_ORIENTATION: return sizeof(SmartAction::orientation); case SMART_ACTION_CREATE_TIMED_EVENT: return sizeof(SmartAction::timeEvent); case SMART_ACTION_PLAYMOVIE: return sizeof(SmartAction::movie); case SMART_ACTION_MOVE_TO_POS: return sizeof(SmartAction::moveToPos); @@ -763,6 +763,8 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e) case SMART_ACTION_MUSIC: return sizeof(SmartAction::music); case SMART_ACTION_SET_GUID: return sizeof(SmartAction::setGuid); case SMART_ACTION_DISABLE: return sizeof(SmartAction::disable); + case SMART_ACTION_SET_SCALE: return sizeof(SmartAction::setScale); + case SMART_ACTION_SUMMON_RADIAL: return sizeof(SmartAction::radialSummon); default: LOG_WARN("sql.sql", "SmartAIMgr: entryorguid {} source_type {} id {} action_type {} is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); @@ -1920,6 +1922,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_PLAY_CINEMATIC: case SMART_ACTION_SET_GUID: case SMART_ACTION_DISABLE: + case SMART_ACTION_SET_SCALE: + case SMART_ACTION_SUMMON_RADIAL: break; default: LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type({}), event_type({}), Entry {} SourceType {} Event {}, 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 d33716213..fd841d539 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -588,7 +588,7 @@ enum SMART_ACTION SMART_ACTION_SET_COUNTER = 63, // id, value, reset (0/1) SMART_ACTION_STORE_TARGET_LIST = 64, // varID, SMART_ACTION_WP_RESUME = 65, // none - SMART_ACTION_SET_ORIENTATION = 66, // quick change, random orientation? (0/1) + SMART_ACTION_SET_ORIENTATION = 66, // quick change, random orientation? (0/1), turnAngle SMART_ACTION_CREATE_TIMED_EVENT = 67, // id, InitialMin, InitialMax, RepeatMin(only if it repeats), RepeatMax(only if it repeats), chance SMART_ACTION_PLAYMOVIE = 68, // entry SMART_ACTION_MOVE_TO_POS = 69, // PointId (optional x,y,z offset), transport, controlled, ContactDistance @@ -693,9 +693,11 @@ enum SMART_ACTION SMART_ACTION_DO_ACTION = 223, // ActionId SMART_ACTION_ATTACK_STOP = 224, // SMART_ACTION_SET_GUID = 225, // Sends the invoker's or the base object's own ObjectGuid to target - SMART_ACTION_DISABLE = 226, // Disable the targeted creatures, setting them Invisible and Immune to All + SMART_ACTION_DISABLE = 226, // state + SMART_ACTION_SET_SCALE = 227, // scale + SMART_ACTION_SUMMON_RADIAL = 228, // summonEntry, summonDuration, repetitions, startAngle, stepAngle, dist - SMART_ACTION_AC_END = 227, // placeholder + SMART_ACTION_AC_END = 229, // placeholder }; enum class SmartActionSummonCreatureFlags @@ -1289,6 +1291,7 @@ struct SmartAction { uint32 quickChange; uint32 random; + uint32 turnAngle; } orientation; struct @@ -1376,6 +1379,21 @@ struct SmartAction { SAIBool state; } disable; + + struct + { + uint32 scale; + } setScale; + + struct + { + uint32 summonEntry; + uint32 summonDuration; + uint32 repetitions; + uint32 startAngle; + uint32 stepAngle; + uint32 dist; + } radialSummon; //! Note for any new future actions //! All parameters must have type uint32