From 3d03cb64ba109fd845ca0e96a921d0385765d937 Mon Sep 17 00:00:00 2001 From: sudlud Date: Mon, 24 Jun 2024 10:10:31 +0200 Subject: [PATCH] =?UTF-8?q?fix(Scripts/Midsummer):=20fix=20handling=20of?= =?UTF-8?q?=20unwanted=20npc=20and=20gameobject=20s=E2=80=A6=20(#19141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Scripts/Midsummer): fix handling of unwanted npc and gameobject spawns - properly spawn bonfire spell focus for city bonfires - properly despawn unwanted creatures and gameobjects which are spawned by linked traps - all midsummer bonfire gameobjects have a linked trap "181290 Midsummer Bonfire Spawn Trap" - the trap is linked to the spell "28784 Summon Midsummer Bonfire Bunnies" which then spawns npc "16592 Midsummer Bonfire", npc "16606 Midsummer Bonfire Despawner" and gameobject "181371 Midsummer Bonfire Spell Focus" i have no idea how this trap is beeing triggered, but it's doing only harm right now --- .../rev_1719166715720224400.sql | 5 ++++ src/server/scripts/Events/midsummer.cpp | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1719166715720224400.sql diff --git a/data/sql/updates/pending_db_world/rev_1719166715720224400.sql b/data/sql/updates/pending_db_world/rev_1719166715720224400.sql new file mode 100644 index 000000000..36e55a35f --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1719166715720224400.sql @@ -0,0 +1,5 @@ +-- 16606 'Midsummer Bonfire Despawner' +-- add TRIGGER flag +UPDATE `creature_template` SET `flags_extra` = (`flags_extra` | 128) WHERE (`entry` = 16606); +-- Script +UPDATE `creature_template` SET `ScriptName` = 'npc_midsummer_bonfire_despawner' WHERE (`entry` = 16606); diff --git a/src/server/scripts/Events/midsummer.cpp b/src/server/scripts/Events/midsummer.cpp index 03cf34fb9..ee50e9919 100644 --- a/src/server/scripts/Events/midsummer.cpp +++ b/src/server/scripts/Events/midsummer.cpp @@ -31,6 +31,7 @@ enum eBonfire { + GO_MIDSUMMER_BONFIRE_SPELL_FOCUS = 181371, GO_MIDSUMMER_BONFIRE_CAMPFIRE_SPELL_FOCUS = 181377, GO_AHUNE_BONFIRE = 188073, @@ -182,6 +183,10 @@ struct npc_midsummer_bonfire : public ScriptedAI { npc_midsummer_bonfire(Creature* creature) : ScriptedAI(creature) { + // Midsummer Bonfire Spawn Trap also spawns this NPC (currently unwanted) + if (me->ToTempSummon()) + me->DespawnOrUnsummon(); + _isStampedOut = nullptr; _teamId = TEAM_NEUTRAL; _type = BONFIRE_TYPE_NONE; @@ -300,6 +305,7 @@ struct npc_midsummer_bonfire : public ScriptedAI if ((_bonfire = me->FindNearestGameObject(GoBonfireCity[i], 10.0f))) { _type = BONFIRE_TYPE_CITY; + Ignite(); return true; } } @@ -362,6 +368,23 @@ private: GameObject* _bonfire; }; +struct npc_midsummer_bonfire_despawner : public ScriptedAI +{ + npc_midsummer_bonfire_despawner(Creature* creature) : ScriptedAI(creature) + { + std::list gobjList; + me->GetGameObjectListWithEntryInGrid(gobjList, GO_MIDSUMMER_BONFIRE_SPELL_FOCUS, 10.0f); + for (std::list::const_iterator itr = gobjList.begin(); itr != gobjList.end(); ++itr) + { + // spawnID is 0 for temp spawns + if (0 == (*itr)->GetSpawnId()) + (*itr)->DespawnOrUnsummon(); + } + + me->DespawnOrUnsummon(); + } +}; + enum torchToss { GO_TORCH_TARGET_BRAZIER = 187708, @@ -1265,6 +1288,7 @@ void AddSC_event_midsummer_scripts() // NPCs RegisterCreatureAI(npc_midsummer_bonfire); + RegisterCreatureAI(npc_midsummer_bonfire_despawner); RegisterCreatureAI(npc_midsummer_torch_target); RegisterCreatureAI(npc_midsummer_ribbon_pole_target);