From 8545257cc808bdcba923ae136320c08beaa6aee7 Mon Sep 17 00:00:00 2001 From: Malcrom Date: Thu, 16 Dec 2021 05:35:06 -0400 Subject: [PATCH] fix(Script/Quest): Plagued Lands [2118] (#9541) --- .../rev_1638832657384544715.sql | 16 ++ .../scripts/Kalimdor/zone_darkshore.cpp | 215 ++++++++++++++++++ src/server/scripts/World/go_scripts.cpp | 62 +++++ 3 files changed, 293 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1638832657384544715.sql diff --git a/data/sql/updates/pending_db_world/rev_1638832657384544715.sql b/data/sql/updates/pending_db_world/rev_1638832657384544715.sql new file mode 100644 index 000000000..bd0075f33 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1638832657384544715.sql @@ -0,0 +1,16 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1638832657384544715'); + +UPDATE `creature_template` SET `AIName`='', `ScriptName`='npc_tharnarian' WHERE `entry`=3701; +UPDATE `creature_template` SET `ScriptName`='npc_rabid_thistle_bear' WHERE `entry`=2164; +UPDATE `gameobject_template` SET `ScriptName`='go_bear_trap' WHERE `entry`=109515; +UPDATE `gameobject_template` SET `AIName`='' WHERE `entry`=111148; +DELETE FROM `smart_scripts` WHERE `entryorguid`=111148 AND `source_type`=1; +DELETE FROM `smart_scripts` WHERE `entryorguid`=2164 AND `source_type`=0; +DELETE FROM `smart_scripts` WHERE `entryorguid`=216400 AND `source_type`=9; +DELETE FROM `smart_scripts` WHERE `entryorguid`=3701 AND `source_type`=0; +DELETE FROM `smart_scripts` WHERE `entryorguid`=370100 AND `source_type`=9; + +-- Condition for source Spell implicit target condition type Object entry guid +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceGroup`=1 AND `SourceEntry`=9439 AND `SourceId`=0; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(13, 1, 9439, 0, 0, 31, 0, 3, 2164, 0, 0, 0, 0, '', 'Bear Captured in Trap (effect 0) will hit the potential target of the spell if target is Rabid Thistle Bear.'); diff --git a/src/server/scripts/Kalimdor/zone_darkshore.cpp b/src/server/scripts/Kalimdor/zone_darkshore.cpp index 7caf7cc39..f8bffbea1 100644 --- a/src/server/scripts/Kalimdor/zone_darkshore.cpp +++ b/src/server/scripts/Kalimdor/zone_darkshore.cpp @@ -422,10 +422,225 @@ public: } }; +enum eRabidThistleBear +{ + EVENT_CHECK_FOLLOWING = 1, + NPC_RABID_THISTLE_BEAR = 2164, + NPC_CAPTURED_RABID_THISTLE_BEAR = 11836, + OBJECT_BEAR_TRAP = 111148, + QUEST_PLAGUED_LANDS = 2118, + SPELL_BEAR_CAPTURED_IN_TRAP = 9439, + SPELL_THARNARIUMS_HEAL = 9457 +}; + +class npc_rabid_thistle_bear : public CreatureScript +{ +public: + npc_rabid_thistle_bear() : CreatureScript("npc_rabid_thistle_bear") {} + + struct npc_rabid_thistle_bearAI : public FollowerAI + { + npc_rabid_thistle_bearAI(Creature* creature) : FollowerAI(creature) + { + Initialize(); + } + + void Initialize() + { + me->SetEntry(NPC_RABID_THISTLE_BEAR); + me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + _playerGUID.Clear(); + } + + void Reset() override {} + + void SpellHit(Unit* /*caster*/, SpellInfo const* spellInfo) override + { + if (spellInfo->Id == SPELL_BEAR_CAPTURED_IN_TRAP) + { + if (GameObject* trap = me->FindNearestGameObject(OBJECT_BEAR_TRAP, 5.0f)) + { + if (Unit* owner = trap->GetOwner()) + { + if (Player* player = owner->ToPlayer()) + { + _playerGUID = player->GetGUID(); + me->SetEntry(NPC_CAPTURED_RABID_THISTLE_BEAR); + me->SetFaction(FACTION_FRIENDLY); + me->GetMotionMaster()->MoveFollow(player, 1.0f, PET_FOLLOW_ANGLE - (PET_FOLLOW_ANGLE / 4)); + _events.Reset(); + _events.ScheduleEvent(EVENT_CHECK_FOLLOWING, 1000); + player->KilledMonsterCredit(NPC_CAPTURED_RABID_THISTLE_BEAR); + me->DespawnOrUnsummon(240000); + } + } + } + } + + if (spellInfo->Id == SPELL_THARNARIUMS_HEAL) + { + me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H); // EMOTE_ONESHOT_WOUND + } + } + + void UpdateAI(uint32 diff) override + { + if (me->GetFaction() == FACTION_FRIENDLY) + { + _events.Update(diff); + switch (_events.ExecuteEvent()) + { + case EVENT_CHECK_FOLLOWING: + Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID); + if (!player || me->GetDistance2d(player) > 100.0f || me->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE || player->GetQuestStatus(QUEST_PLAGUED_LANDS) == QUEST_STATUS_NONE) + { + me->DespawnOrUnsummon(); + } + _events.ScheduleEvent(EVENT_CHECK_FOLLOWING, 1000); + break; + } + } + + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } + + private: + EventMap _events; + ObjectGuid _playerGUID; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_rabid_thistle_bearAI(creature); + } +}; + +enum eTharnarian +{ + EVENT_POST_QUEST_ONE = 1, + EVENT_POST_QUEST_TWO = 2, + EVENT_POST_QUEST_THREE = 3, + ITEM_THARNARIUMS_HOPE = 7586, + GUID_SCRIPT_INVOKER = 1, + SAY_BE_CLEANSED = 0 +}; + +class npc_tharnarian : public CreatureScript +{ +public: + npc_tharnarian() : CreatureScript("npc_tharnarian") {} + + struct npc_tharnarianAI : public ScriptedAI + { + npc_tharnarianAI(Creature* creature) : ScriptedAI(creature) + { + Initialize(); + } + + void Initialize() + { + _scriptRunning = false; + _facing = me->GetOrientation(); + } + + void Reset() override + { + _events.Reset(); + } + + void sGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + { + if (gossipListId == 1) + { + CloseGossipMenuFor(player); + player->AddItem(ITEM_THARNARIUMS_HOPE, 1); + } + } + + void SetGUID(ObjectGuid /*guid*/, int32 type) override + { + if (type == GUID_SCRIPT_INVOKER && _scriptRunning == false) + { + if (Creature* bear = me->FindNearestCreature(NPC_CAPTURED_RABID_THISTLE_BEAR, 5.0f)) + { + _bearGUID = bear->GetGUID(); + _scriptRunning = true; + _events.ScheduleEvent(EVENT_POST_QUEST_ONE, 1000); + } + } + } + + void UpdateAI(uint32 diff) override + { + if (_scriptRunning) + { + _events.Update(diff); + switch (_events.ExecuteEvent()) + { + case EVENT_POST_QUEST_ONE: + if (Creature* bear = ObjectAccessor::GetCreature(*me, _bearGUID)) + { + Talk(SAY_BE_CLEANSED); + me->CastSpell(bear, SPELL_THARNARIUMS_HEAL); + } + _events.ScheduleEvent(EVENT_POST_QUEST_TWO, 4000); + break; + case EVENT_POST_QUEST_TWO: + if (Creature* bear = ObjectAccessor::GetCreature(*me, _bearGUID)) + { + bear->SetUInt32Value(UNIT_FIELD_BYTES_1, 7); + } + _events.ScheduleEvent(EVENT_POST_QUEST_THREE, 1000); + break; + case EVENT_POST_QUEST_THREE: + if (Creature* bear = ObjectAccessor::GetCreature(*me, _bearGUID)) + { + bear->DespawnOrUnsummon(); + _scriptRunning = false; + } + break; + } + } + + if (!UpdateVictim()) + { + return; + } + + DoMeleeAttackIfReady(); + } + + private: + EventMap _events; + ObjectGuid _bearGUID; + bool _scriptRunning; + float _facing; + }; + + bool OnQuestReward(Player* player, Creature* creature, const Quest* _Quest, uint32 /*slot*/) override + { + if (_Quest->GetQuestId() == QUEST_PLAGUED_LANDS) + { + creature->AI()->SetGUID(player->GetGUID(), GUID_SCRIPT_INVOKER); + } + return false; + } + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_tharnarianAI(creature); + } +}; + void AddSC_darkshore() { // Ours new npc_murkdeep(); + new npc_rabid_thistle_bear(); + new npc_tharnarian(); // Theirs new npc_kerlonian(); diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 0dab11cf1..af65441f3 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -431,6 +431,66 @@ public: } }; +enum eBearTrap +{ + EVENT_CHECK = 1, + NPC_RABID_THISTLE_BEAR = 2164, + SPELL_BEAR_CAPTURED_IN_TRAP = 9439 +}; + +class go_bear_trap : public GameObjectScript +{ +public: + go_bear_trap() : GameObjectScript("go_bear_trap") {} + + struct go_bear_trapAI : public GameObjectAI + { + go_bear_trapAI(GameObject* gameObject) : GameObjectAI(gameObject) + { + Initialize(); + } + + void Initialize() + { + _events.ScheduleEvent(EVENT_CHECK, 1000); + } + + void UpdateAI(uint32 const diff) override + { + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_CHECK: + { + if (Creature* bear = me->FindNearestCreature(NPC_RABID_THISTLE_BEAR, 1.0f)) + { + bear->CastSpell(bear, SPELL_BEAR_CAPTURED_IN_TRAP); + me->RemoveFromWorld(); + } + else + { + _events.ScheduleEvent(EVENT_CHECK, 1000); + } + break; + } + default: + break; + } + } + } + private: + EventMap _events; + }; + + GameObjectAI* GetAI(GameObject* go) const override + { + return new go_bear_trapAI(go); + } +}; + // Theirs /*#### ## go_brewfest_music @@ -1882,6 +1942,7 @@ void AddSC_go_scripts() new go_tadpole_cage(); new go_flames(); new go_heat(); + new go_bear_trap(); // Theirs new go_brewfest_music(); @@ -1912,3 +1973,4 @@ void AddSC_go_scripts() new go_veil_skith_cage(); new go_bells(); } +