From d3cd637d1f53317e860a5f0b4040806695869db2 Mon Sep 17 00:00:00 2001 From: avarishd <46330494+avarishd@users.noreply.github.com> Date: Sat, 7 Mar 2026 23:53:58 +0200 Subject: [PATCH] fix(Scripts/Creature): multi-raid faction leader credit (#22168) --- .../rev_1747859677740678300.sql | 8 ++ .../game/AI/ScriptedAI/ScriptedCreature.cpp | 10 +++ .../game/AI/ScriptedAI/ScriptedCreature.h | 3 + .../eastern_kingdoms_script_loader.cpp | 4 +- .../EasternKingdoms/zone_eversong_woods.cpp | 22 ++++++ .../EasternKingdoms/zone_ironforge.cpp | 73 +++++++++++++++++++ .../EasternKingdoms/zone_stormwind_city.cpp | 26 +++++-- .../EasternKingdoms/zone_undercity.cpp | 5 ++ .../Kalimdor/kalimdor_script_loader.cpp | 2 + .../scripts/Kalimdor/zone_azuremyst_isle.cpp | 26 +++++++ .../scripts/Kalimdor/zone_orgrimmar.cpp | 5 ++ .../scripts/Kalimdor/zone_teldrassil.cpp | 44 +++++++++++ .../scripts/Kalimdor/zone_thunder_bluff.cpp | 13 ++-- 13 files changed, 226 insertions(+), 15 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1747859677740678300.sql create mode 100644 src/server/scripts/EasternKingdoms/zone_ironforge.cpp create mode 100644 src/server/scripts/Kalimdor/zone_teldrassil.cpp diff --git a/data/sql/updates/pending_db_world/rev_1747859677740678300.sql b/data/sql/updates/pending_db_world/rev_1747859677740678300.sql new file mode 100644 index 000000000..575f6a145 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1747859677740678300.sql @@ -0,0 +1,8 @@ +-- +UPDATE `creature_template` SET `ScriptName` = 'npc_lor_themar_theron' WHERE (`entry` = 16802); +UPDATE `creature_template` SET `ScriptName` = 'npc_king_varian_wrynn' WHERE (`entry` = 29611); +UPDATE `creature_template` SET `ScriptName` = 'npc_tyrande_whisperwind' WHERE (`entry` = 7999); +UPDATE `creature_template` SET `ScriptName` = 'npc_king_magni_bronzebeard', `AIName` = '' WHERE (`entry` = 2784); +UPDATE `creature_template` SET `ScriptName` = 'npc_prophet_velen', `AIName` = '' WHERE (`entry` = 17468); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` IN (2784,17468)) AND (`source_type` = 0); diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index bac61c314..ddce144a1 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -269,6 +269,16 @@ void ScriptedAI::DoStopAttack() me->AttackStop(); } +void ScriptedAI::DoRewardPlayersInArea() +{ + me->GetMap()->DoForAllPlayers([&](Player* player) + { + if (player->GetFaction() != me->GetCreatureTemplate()->faction && !player->IsGameMaster()) + if (player->GetAreaId() == me->GetAreaId()) + player->KilledMonsterCredit(me->GetEntry()); + }); +} + void ScriptedAI::DoCastSpell(Unit* target, SpellInfo const* spellInfo, bool triggered) { if (!target || me->IsNonMeleeSpellCast(false)) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 271366c9d..deb7bba10 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -306,6 +306,9 @@ struct ScriptedAI : public CreatureAI //Stop attack of current victim void DoStopAttack(); + //Reward kill credit to all players from the oposing faction in the area (faction leaders) + void DoRewardPlayersInArea(); + //Cast spell by spell info void DoCastSpell(Unit* target, SpellInfo const* spellInfo, bool triggered = false); diff --git a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp index 89ee4783e..1101b999b 100644 --- a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp +++ b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp @@ -153,7 +153,7 @@ void AddSC_elwynn_forest(); void AddSC_eversong_woods(); void AddSC_ghostlands(); void AddSC_hinterlands(); -//void AddSC_ironforge(); +void AddSC_ironforge(); void AddSC_isle_of_queldanas(); void AddSC_redridge_mountains(); void AddSC_silverpine_forest(); @@ -305,7 +305,7 @@ void AddEasternKingdomsScripts() AddSC_eversong_woods(); AddSC_ghostlands(); AddSC_hinterlands(); -// AddSC_ironforge(); + AddSC_ironforge(); AddSC_isle_of_queldanas(); AddSC_redridge_mountains(); AddSC_silverpine_forest(); diff --git a/src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp b/src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp index 0002c1712..743349903 100644 --- a/src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp +++ b/src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp @@ -14,6 +14,7 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ + #include "CreatureScript.h" #include "ScriptedCreature.h" @@ -215,8 +216,29 @@ private: float _facing; }; +// 16802 - Lor'themar Theron +/// @todo add abilities/timers +struct npc_lor_themar_theron : public ScriptedAI +{ + npc_lor_themar_theron(Creature* creature) : ScriptedAI(creature) { } + + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; + void AddSC_eversong_woods() { RegisterCreatureAI(npc_partygoer_pather); RegisterCreatureAI(npc_partygoer); + RegisterCreatureAI(npc_lor_themar_theron); } diff --git a/src/server/scripts/EasternKingdoms/zone_ironforge.cpp b/src/server/scripts/EasternKingdoms/zone_ironforge.cpp new file mode 100644 index 000000000..4c703389c --- /dev/null +++ b/src/server/scripts/EasternKingdoms/zone_ironforge.cpp @@ -0,0 +1,73 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "CreatureScript.h" +#include "ScriptedCreature.h" + +// 2784 - King Magni Bronzebeard +enum KingMagniBronzebeard +{ + SOUND_AGGRO = 5896, + SPELL_AVATAR = 19135, + SPELL_KNOCK_AWAY = 20686, + SPELL_STORM_BOLT = 20685 +}; + +struct npc_king_magni_bronzebeard : public ScriptedAI +{ + npc_king_magni_bronzebeard(Creature* creature) : ScriptedAI(creature) { } + + void JustEngagedWith(Unit* /*who*/) override + { + me->PlayDirectSound(SOUND_AGGRO); + + ScheduleTimedEvent(5s, 7s, [&] + { + DoCastSelf(SPELL_AVATAR); + }, 25s, 30s); + + ScheduleTimedEvent(8s, 10s, [&] + { + DoCastVictim(SPELL_KNOCK_AWAY); + }, 20s, 30s); + + ScheduleTimedEvent(12s, 15s, [&] + { + DoCastRandomTarget(SPELL_STORM_BOLT); + }, 15s, 20s); + } + + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + scheduler.Update(diff, + std::bind(&ScriptedAI::DoMeleeAttackIfReady, this)); + } + +}; + +void AddSC_ironforge() +{ + RegisterCreatureAI(npc_king_magni_bronzebeard); +} diff --git a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp index 364016c4c..2cfb08110 100644 --- a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp @@ -464,13 +464,26 @@ enum KingVarianWrynn : uint32 // Deathknight Starting Zone End QUEST_WHERE_KINGS_WALK = 13188, }; - -class npc_king_varian_wrynn : public CreatureScript +// 29611 - King Varian Wryn +/// @todo add abilities/timers +struct npc_king_varian_wrynn : public ScriptedAI { -public: - npc_king_varian_wrynn() : CreatureScript("npc_king_varian_wrynn") { } + npc_king_varian_wrynn(Creature* creature) : ScriptedAI(creature) { } - bool OnQuestReward(Player* player, Creature* /*creature*/, Quest const* quest, uint32 /*item*/) override + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } + + bool OnQuestReward(Player* player, Creature* /*creature*/, Quest const* quest, uint32 /*item*/) { if (quest->GetQuestId() == QUEST_WHERE_KINGS_WALK) @@ -486,5 +499,6 @@ void AddSC_stormwind_city() new npc_tyrion_spybot(); new npc_lord_gregor_lescovar(); new npc_marzon_silent_blade(); - new npc_king_varian_wrynn(); + RegisterCreatureAI(npc_king_varian_wrynn); + } diff --git a/src/server/scripts/EasternKingdoms/zone_undercity.cpp b/src/server/scripts/EasternKingdoms/zone_undercity.cpp index 9d39e235a..747a452b3 100644 --- a/src/server/scripts/EasternKingdoms/zone_undercity.cpp +++ b/src/server/scripts/EasternKingdoms/zone_undercity.cpp @@ -118,6 +118,11 @@ public: _events.ScheduleEvent(EVENT_MULTI_SHOT, 10s); } + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + void SetGUID(ObjectGuid const& guid, int32 type) override { if (type == GUID_EVENT_INVOKER) diff --git a/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp b/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp index 3d4d6f279..8e36078be 100644 --- a/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp +++ b/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp @@ -88,6 +88,7 @@ void AddSC_orgrimmar(); void AddSC_silithus(); void AddSC_stonetalon_mountains(); void AddSC_tanaris(); +void AddSC_teldrassil(); void AddSC_the_barrens(); void AddSC_thousand_needles(); void AddSC_thunder_bluff(); @@ -170,6 +171,7 @@ void AddKalimdorScripts() AddSC_silithus(); AddSC_stonetalon_mountains(); AddSC_tanaris(); + AddSC_teldrassil(); AddSC_the_barrens(); AddSC_thousand_needles(); AddSC_thunder_bluff(); diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp index bbcbbd055..2316a2e33 100644 --- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp @@ -559,6 +559,31 @@ public: } }; +// 7999 - Tyrande Whisperwind +/// @todo add abilities/timers +struct npc_prophet_velen : public ScriptedAI +{ + npc_prophet_velen(Creature* creature) : ScriptedAI(creature) { } + + void Reset() override + { + me->setActive(true); + } + + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; + void AddSC_azuremyst_isle() { new npc_draenei_survivor(); @@ -569,4 +594,5 @@ void AddSC_azuremyst_isle() new npc_stillpine_capitive(); new go_bristlelimb_cage(); RegisterSpellScript(spell_inoculate_nestlewood_owlkin); + RegisterCreatureAI(npc_prophet_velen); } diff --git a/src/server/scripts/Kalimdor/zone_orgrimmar.cpp b/src/server/scripts/Kalimdor/zone_orgrimmar.cpp index 19d19c47c..36c6c56c2 100644 --- a/src/server/scripts/Kalimdor/zone_orgrimmar.cpp +++ b/src/server/scripts/Kalimdor/zone_orgrimmar.cpp @@ -234,6 +234,11 @@ public: void JustEngagedWith(Unit* /*who*/) override { } + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + void DoAction(int32 action) override { if (action == ACTION_START_TALKING) diff --git a/src/server/scripts/Kalimdor/zone_teldrassil.cpp b/src/server/scripts/Kalimdor/zone_teldrassil.cpp new file mode 100644 index 000000000..e45f93bd1 --- /dev/null +++ b/src/server/scripts/Kalimdor/zone_teldrassil.cpp @@ -0,0 +1,44 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "CreatureScript.h" +#include "ScriptedCreature.h" + +// 7999 - Tyrande Whisperwind +/// @todo add abilities/timers +struct npc_tyrande_whisperwind : public ScriptedAI +{ + npc_tyrande_whisperwind(Creature* creature) : ScriptedAI(creature) { } + + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; + +void AddSC_teldrassil() +{ + RegisterCreatureAI(npc_tyrande_whisperwind); +} diff --git a/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp b/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp index 7545b1422..ae06ff678 100644 --- a/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp +++ b/src/server/scripts/Kalimdor/zone_thunder_bluff.cpp @@ -19,10 +19,6 @@ #include "Player.h" #include "ScriptedCreature.h" -/*##### -# Support for Quest 925: Cairne's Hoofprint -######*/ - // NPC 3057: Cairne Bloodhoof enum CairneBloodhoof { @@ -34,7 +30,7 @@ enum CairneBloodhoof SPELL_CAIRNES_HOOFPRINT = 23123 }; -// @todo verify abilities/timers +/// @todo verify abilities/timers class npc_cairne_bloodhoof : public CreatureScript { public: @@ -61,12 +57,15 @@ public: } } + void JustDied(Unit* /*killer*/) override + { + DoRewardPlayersInArea(); + } + void UpdateAI(uint32 diff) override { if (!UpdateVictim()) - { return; - } if (_berserkerChargeTimer <= diff) {