From 69fab3df70f082a4dbfd3703c1476c3c11b6151c Mon Sep 17 00:00:00 2001 From: Gultask <100873791+Gultask@users.noreply.github.com> Date: Wed, 17 May 2023 09:31:50 -0300 Subject: [PATCH] feat(Core/SAI): Implement SMART_ACTION_DISABLE (#16254) * init * Create rev_1684036819129474700.sql * Update rev_1684036819129474700.sql --- .../rev_1684036819129474700.sql | 59 +++++++++++++++++++ .../game/AI/SmartScripts/SmartScript.cpp | 12 ++++ .../game/AI/SmartScripts/SmartScriptMgr.cpp | 2 + .../game/AI/SmartScripts/SmartScriptMgr.h | 8 ++- 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 data/sql/updates/pending_db_world/rev_1684036819129474700.sql diff --git a/data/sql/updates/pending_db_world/rev_1684036819129474700.sql b/data/sql/updates/pending_db_world/rev_1684036819129474700.sql new file mode 100644 index 000000000..8727ddd2e --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1684036819129474700.sql @@ -0,0 +1,59 @@ +-- +DELETE FROM `smart_scripts` WHERE `source_type` = 0 AND `entryorguid` IN (-151019,-151020,-151021,-151022,-151023,-151024,-151025,-151026,-151027,-151028,-151029,-151030,-151031,-151032,-151033,-151034,-151019,-151020,-151021,-151022,-151023,-151024,-151025,-151026,-151027,-151028,-151029,-151030,-151031,-151032,-151033,-151034) AND `action_type` = 80 AND `action_param1` IN (1670011, 1670012); + +DELETE FROM `smart_scripts` WHERE `source_type` = 0 AND `entryorguid` IN (-151019,-151020,-151021,-151022,-151023,-151024,-151025,-151026,-151027,-151028,-151029,-151030,-151031,-151032,-151033,-151034,-151019,-151020,-151021,-151022,-151023,-151024,-151025,-151026,-151027,-151028,-151029,-151030,-151031,-151032,-151033,-151034) AND `action_type` = 226; +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(-151019, 0, 1006, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - On Respawn - Disable'), +(-151020, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Respawn - Disable'), +(-151021, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Respawn - Disable'), +(-151022, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Heathen - On Respawn - Disable'), +(-151023, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shadowmoon Darkcaster - On Respawn - Disable'), +(-151024, 0, 1006, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - On Respawn - Disable'), +(-151025, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Respawn - Disable'), +(-151026, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Respawn - Disable'), +(-151027, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Respawn - Disable'), +(-151028, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shadowmoon Darkcaster - On Respawn - Disable'), +(-151029, 0, 1006, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - On Respawn - Disable'), +(-151030, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Respawn - Disable'), +(-151031, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Respawn - Disable'), +(-151032, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Respawn - Disable'), +(-151033, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Respawn - Disable'), +(-151034, 0, 1001, 0, 11, 0, 100, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Respawn - Disable'), +(-151019, 0, 1007, 1008, 77, 0, 100, 0, 1, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - On Counter 2/2 - Enable'), +(-151020, 0, 1002, 1003, 38, 0, 100, 0, 3, 1, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Data Set 3 1 - Enable'), +(-151021, 0, 1002, 1003, 38, 0, 100, 0, 3, 1, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Data Set 3 1 - Enable'), +(-151022, 0, 1002, 1003, 38, 0, 100, 0, 3, 1, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Heathen - On Data Set 3 1 - Enable'), +(-151023, 0, 1002, 1003, 38, 0, 100, 0, 3, 1, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shadowmoon Darkcaster - On Data Set 3 1 - Enable'), +(-151024, 0, 1007, 1008, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - On Data Set 3 2 - Enable'), +(-151025, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Data Set 3 2 - Enable'), +(-151026, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Data Set 3 2 - Enable'), +(-151027, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Data Set 3 2 - Enable'), +(-151028, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shadowmoon Darkcaster - On Data Set 3 2 - Enable'), +(-151029, 0, 1008, 1009, 10, 0, 100, 267, 0, 90, 0, 0, 1, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - Within 0-90 Range Out of Combat LoS - Enable'), +(-151030, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Data Set 3 2 - Enable'), +(-151031, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Reaver - On Data Set 3 2 - Enable'), +(-151032, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Data Set 3 2 - Enable'), +(-151033, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Data Set 3 2 - Enable'), +(-151034, 0, 1002, 1003, 38, 0, 100, 0, 3, 2, 0, 0, 0, 226, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - On Data Set 3 2 - Enable'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = -151019) AND (`source_type` = 0) AND (`id` IN (1009, 1010, 1011)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(-151019, 0, 1009, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 80, 1670011, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - Linked - Run Script'), +(-151019, 0, 1010, 0, 58, 0, 100, 0, 0, 1670002, 0, 0, 0, 80, 1670013, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - On Waypoint Finished - Run Script'); + +DELETE FROM `smart_scripts` WHERE (`source_type` = 9 AND `entryorguid` = 1670011); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(1670011, 9, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 53, 0, 1670002, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - Actionlist - Start Waypoint'), +(1670011, 9, 1, 0, 0, 0, 100, 0, 400, 400, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - Actionlist - Say Line 5'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = -151024) AND (`source_type` = 0) AND (`id` IN (1008, 1009, 1010)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(-151024, 0, 1008, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 80, 1670012, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - Linked - Run Script'), +(-151024, 0, 1009, 0, 40, 0, 100, 0, 4, 1670004, 0, 0, 0, 80, 1670014, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - On Waypoint Finished - Run Script'); + +DELETE FROM `smart_scripts` WHERE (`source_type` = 9 AND `entryorguid` = 1670012); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(1670012, 9, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 53, 0, 1670004, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - Actionlist - Start Waypoint'), +(1670012, 9, 1, 0, 0, 0, 100, 0, 400, 400, 0, 0, 0, 1, 8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Legionnaire - Actionlist - Say Line 8'); + +UPDATE `smart_scripts` SET `event_flags`=257 WHERE `entryorguid`=-151029 AND `source_type`=0 AND `id`=1008 AND `link`=1009; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 60f3660db..e089c7c24 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2797,6 +2797,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } break; } + case SMART_ACTION_DISABLE: + { + for (WorldObject* target : targets) + { + if (IsUnit(target)) + { + target->ToUnit()->SetImmuneToAll(!e.action.disable.state); + target->ToUnit()->SetVisible(e.action.disable.state); + } + } + 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 26d52bb23..eede4981d 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -762,6 +762,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e) case SMART_ACTION_LOAD_GRID: return NO_PARAMS; 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); 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()); @@ -1918,6 +1919,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_ATTACK_STOP: case SMART_ACTION_PLAY_CINEMATIC: case SMART_ACTION_SET_GUID: + case SMART_ACTION_DISABLE: 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 88d82027e..51fa2ea4a 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -693,8 +693,9 @@ 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_AC_END = 226, // placeholder + SMART_ACTION_AC_END = 227, // placeholder }; enum class SmartActionSummonCreatureFlags @@ -1365,6 +1366,11 @@ struct SmartAction SAIBool invokerGUID; uint32 index; } setGuid; + + struct + { + SAIBool state; + } disable; //! Note for any new future actions //! All parameters must have type uint32