fix(Scripts/Creature): multi-raid faction leader credit (#22168)

This commit is contained in:
avarishd
2026-03-07 23:53:58 +02:00
committed by GitHub
parent 33a438a585
commit d3cd637d1f
13 changed files with 226 additions and 15 deletions

View File

@@ -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);

View File

@@ -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))

View File

@@ -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);

View File

@@ -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();

View File

@@ -14,6 +14,7 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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);
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View File

@@ -19,10 +19,6 @@
#include "Player.h"
#include "ScriptedCreature.h"
/*#####
# Support for Quest 925: Cairne's Hoofprint
######*/
// NPC 3057: Cairne Bloodhoof <High Chieftain>
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)
{