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
This commit is contained in:
avarishd
2023-05-29 03:29:51 +03:00
committed by GitHub
parent 08b9b016fb
commit b5ef9ee3de
2 changed files with 60 additions and 14 deletions

View File

@@ -15,20 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* 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<Creature*> 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();
}