From c605a48f9852e987329522acef2245687001304a Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:59:03 -0300 Subject: [PATCH] refactor(Scripts/Stormwind): Move Bartleby script to SAI (#17731) --- .../rev_1700101479282219800.sql | 13 ++++ .../EasternKingdoms/zone_stormwind_city.cpp | 74 +------------------ 2 files changed, 14 insertions(+), 73 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1700101479282219800.sql diff --git a/data/sql/updates/pending_db_world/rev_1700101479282219800.sql b/data/sql/updates/pending_db_world/rev_1700101479282219800.sql new file mode 100644 index 000000000..d7aad35b3 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1700101479282219800.sql @@ -0,0 +1,13 @@ +-- +UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = 6090; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 6090); +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`, `event_param6`, `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 +(6090, 0, 0, 1, 19, 0, 100, 0, 1640, 0, 0, 0, 0, 0, 2, 168, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Bartleby - On Quest \'Beat Bartleby\' Taken - Set Faction 168'), +(6090, 0, 1, 4, 61, 0, 100, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Bartleby - On Quest \'Beat Bartleby\' Taken - Start Attacking'), +(6090, 0, 2, 3, 2, 0, 100, 0, 0, 15, 0, 0, 0, 0, 15, 1640, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 'Bartleby - Between 0-15% Health - Quest Credit \'Beat Bartleby\''), +(6090, 0, 3, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Bartleby - Between 0-15% Health - Evade'), +(6090, 0, 4, 6, 61, 0, 100, 0, 0, 0, 0, 0, 0, 0, 42, 0, 15, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Bartleby - On Quest \'Beat Bartleby\' Taken - Set Invincibility Hp 15%'), +(6090, 0, 5, 0, 25, 0, 100, 0, 0, 0, 0, 0, 0, 0, 2, 84, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Bartleby - On Reset - Set Faction 84'), +(6090, 0, 6, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Bartleby - On Quest \'Beat Bartleby\' Taken - Store Targetlist'); + diff --git a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp index 060111d4d..1634b59e3 100644 --- a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp @@ -18,13 +18,12 @@ /* ScriptData SDName: Stormwind_City SD%Complete: 100 -SDComment: Quest support: 1640, 1447, 4185, 11223, 434. +SDComment: Quest support: 1447, 4185, 11223, 434. SDCategory: Stormwind City EndScriptData */ /* ContentData npc_archmage_malin -npc_bartleby npc_tyrion npc_tyrion_spybot npc_marzon_silent_blade @@ -37,76 +36,6 @@ EndContentData */ #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" -/*###### -## npc_bartleby -######*/ - -enum Bartleby -{ - QUEST_BEAT = 1640 -}; - -class npc_bartleby : public CreatureScript -{ -public: - npc_bartleby() : CreatureScript("npc_bartleby") { } - - bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override - { - if (quest->GetQuestId() == QUEST_BEAT) - { - creature->SetFaction(FACTION_ENEMY); - creature->AI()->AttackStart(player); - } - return true; - } - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_bartlebyAI(creature); - } - - struct npc_bartlebyAI : public ScriptedAI - { - npc_bartlebyAI(Creature* creature) : ScriptedAI(creature) - { - m_uiNormalFaction = creature->GetFaction(); - } - - uint32 m_uiNormalFaction; - - void Reset() override - { - if (me->GetFaction() != m_uiNormalFaction) - me->SetFaction(m_uiNormalFaction); - } - - void AttackedBy(Unit* pAttacker) override - { - if (me->GetVictim()) - return; - - if (me->IsFriendlyTo(pAttacker)) - return; - - AttackStart(pAttacker); - } - - void DamageTaken(Unit* pDoneBy, uint32& uiDamage, DamageEffectType, SpellSchoolMask) override - { - if (pDoneBy && (uiDamage >= me->GetHealth() || me->HealthBelowPctDamaged(15, uiDamage))) - { - //Take 0 damage - uiDamage = 0; - - if (Player* player = pDoneBy->ToPlayer()) - player->AreaExploredOrEventHappens(QUEST_BEAT); - EnterEvadeMode(); - } - } - }; -}; - /*###### ## npc_lord_gregor_lescovar ######*/ @@ -546,7 +475,6 @@ public: void AddSC_stormwind_city() { - new npc_bartleby(); new npc_tyrion(); new npc_tyrion_spybot(); new npc_lord_gregor_lescovar();