From b5ef9ee3de14980877493a34b1dbec61a7027d3d Mon Sep 17 00:00:00 2001
From: avarishd <46330494+avarishd@users.noreply.github.com>
Date: Mon, 29 May 2023 03:29:51 +0300
Subject: [PATCH] fix(Script/HellfirePeninsula): Beacons not attracting mobs.
(#15296)
* fix(Script/Zone): Hellfire Peninsula - Beacons not attracting mobs.
* update
* add HOME_MOTION_TYPE check to prevent yoyo effect
* Use GetNearPosition
---
.../rev_1678132905589082800.sql | 2 +
.../Outland/zone_hellfire_peninsula.cpp | 72 +++++++++++++++----
2 files changed, 60 insertions(+), 14 deletions(-)
create mode 100644 data/sql/updates/pending_db_world/rev_1678132905589082800.sql
diff --git a/data/sql/updates/pending_db_world/rev_1678132905589082800.sql b/data/sql/updates/pending_db_world/rev_1678132905589082800.sql
new file mode 100644
index 000000000..9d0bb961a
--- /dev/null
+++ b/data/sql/updates/pending_db_world/rev_1678132905589082800.sql
@@ -0,0 +1,2 @@
+-- Hellfire Beacons
+UPDATE `gameobject_template` SET `ScriptName` = 'go_beacon' WHERE `entry` IN (181579, 181580, 181581);
diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
index b3cd980ac..effc40527 100644
--- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
+++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
@@ -15,20 +15,7 @@
* with this program. If not, see .
*/
-/* ScriptData
-SDName: Hellfire_Peninsula
-SD%Complete: 100
-SDComment: Quest support: 9375, 9410, 9418, 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths) "Needs update"
-SDCategory: Hellfire Peninsula
-EndScriptData */
-
-/* ContentData
-npc_aeranas
-npc_ancestral_wolf
-npc_wounded_blood_elf
-npc_fel_guard_hound
-EndContentData */
-
+#include "GameObjectAI.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -403,6 +390,62 @@ public:
}
};
+enum Beacon
+{
+ NPC_STONESCHYE_WHELP = 16927,
+};
+
+class go_beacon : public GameObjectScript
+{
+public:
+ go_beacon() : GameObjectScript("go_beacon") { }
+
+ struct go_beaconAI : public GameObjectAI
+ {
+ go_beaconAI(GameObject* gameObject) : GameObjectAI(gameObject) { }
+
+ std::list creatureList;
+
+ void OnStateChanged(uint32 state, Unit* /*unit*/) override
+ {
+ if (state == GO_ACTIVATED)
+ {
+ me->GetCreaturesWithEntryInRange(creatureList, 40, NPC_STONESCHYE_WHELP);
+ {
+ for (Creature* whelp : creatureList)
+ {
+ if (whelp->IsAlive() && !whelp->IsInCombat() && whelp->GetMotionMaster()->GetCurrentMovementGeneratorType() != HOME_MOTION_TYPE)
+ {
+ whelp->GetMotionMaster()->MovePoint(0, me->GetNearPosition(4.0f, whelp->GetOrientation()));
+ }
+ }
+ }
+ }
+ else if (state == GO_JUST_DEACTIVATED)
+ {
+ {
+ for (Creature* whelp : creatureList)
+ {
+ if (whelp->IsAlive() && !whelp->IsInCombat() && whelp->GetMotionMaster()->GetCurrentMovementGeneratorType() != HOME_MOTION_TYPE)
+ {
+ whelp->GetMotionMaster()->MoveTargetedHome();
+ }
+ }
+ }
+ }
+ else
+ {
+ creatureList.clear();
+ }
+ }
+ };
+
+ GameObjectAI* GetAI(GameObject* go) const override
+ {
+ return new go_beaconAI(go);
+ }
+};
+
void AddSC_hellfire_peninsula()
{
// Ours
@@ -413,4 +456,5 @@ void AddSC_hellfire_peninsula()
new npc_ancestral_wolf();
new npc_wounded_blood_elf();
new npc_fel_guard_hound();
+ new go_beacon();
}