Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/sql/updates/pending_db_world/rev_1747859677740678300.sql
Original file line number Diff line number Diff line change
@@ -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);
14 changes: 14 additions & 0 deletions src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ 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))
Expand Down
3 changes: 3 additions & 0 deletions src/server/game/AI/ScriptedAI/ScriptedCreature.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,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);

Expand Down
1 change: 1 addition & 0 deletions src/server/game/Maps/AreaDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ enum AreaTableIDs : uint32
AREA_EVERSONG_WOODS = 3430,
AREA_GHOSTLANDS = 3433,
AREA_HELLFIRE_PENINSULA = 3483,
AREA_SILVERMOON_CITY = 3487,
AREA_NAGRAND = 3518,
AREA_TEROKKAR_FOREST = 3519,
AREA_SHADOWMOON_VALLEY = 3520,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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();
Expand Down Expand Up @@ -303,7 +303,7 @@ void AddEasternKingdomsScripts()
AddSC_eversong_woods();
AddSC_ghostlands();
AddSC_hinterlands();
// AddSC_ironforge();
AddSC_ironforge();
AddSC_isle_of_queldanas();
AddSC_redridge_mountains();
AddSC_silverpine_forest();
Expand Down
22 changes: 22 additions & 0 deletions src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -215,8 +216,29 @@ struct npc_partygoer : public ScriptedAI
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);
}
73 changes: 73 additions & 0 deletions src/server/scripts/EasternKingdoms/zone_ironforge.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
36 changes: 21 additions & 15 deletions src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* ScriptData
SDName: Stormwind_City
SD%Complete: 100
SDComment: Quest support: 1447, 4185, 11223, 434.
SDCategory: Stormwind City
EndScriptData */

/* ContentData
npc_archmage_malin
npc_tyrion
npc_tyrion_spybot
npc_marzon_silent_blade
npc_lord_gregor_lescovar
EndContentData */

#include "CreatureScript.h"
#include "Player.h"
#include "ScriptedCreature.h"
Expand Down Expand Up @@ -472,10 +457,31 @@ class npc_tyrion : public CreatureScript
}
};

// 29611 - King Varian Wryn
/// @todo add abilities/timers
struct npc_king_varian_wrynn : public ScriptedAI
{
npc_king_varian_wrynn(Creature* creature) : ScriptedAI(creature) { }

void JustDied(Unit* /*killer*/) override
{
DoRewardPlayersInArea();
}

void UpdateAI(uint32 /*diff*/) override
{
if (!UpdateVictim())
return;

DoMeleeAttackIfReady();
}
};

void AddSC_stormwind_city()
{
new npc_tyrion();
new npc_tyrion_spybot();
new npc_lord_gregor_lescovar();
new npc_marzon_silent_blade();
RegisterCreatureAI(npc_king_varian_wrynn);
}
18 changes: 5 additions & 13 deletions src/server/scripts/EasternKingdoms/zone_undercity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* ScriptData
SDName: Undercity
SD%Complete: 95
SDComment: Quest support: 6628, 9180(post-event).
SDCategory: Undercity
EndScriptData */

/* ContentData
npc_lady_sylvanas_windrunner
npc_highborne_lamenter
npc_parqual_fintallas
EndContentData */

#include "CreatureScript.h"
#include "ObjectAccessor.h"
#include "Player.h"
Expand Down Expand Up @@ -131,6 +118,11 @@ class npc_lady_sylvanas_windrunner : public CreatureScript
_events.ScheduleEvent(EVENT_MULTI_SHOT, 10s);
}

void JustDied(Unit* /*killer*/) override
{
DoRewardPlayersInArea();
}

void SetGUID(ObjectGuid guid, int32 type) override
{
if (type == GUID_EVENT_INVOKER)
Expand Down
2 changes: 2 additions & 0 deletions src/server/scripts/Kalimdor/kalimdor_script_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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();
Expand Down Expand Up @@ -172,6 +173,7 @@ void AddKalimdorScripts()
AddSC_silithus();
AddSC_stonetalon_mountains();
AddSC_tanaris();
AddSC_teldrassil();
AddSC_the_barrens();
AddSC_thousand_needles();
AddSC_thunder_bluff();
Expand Down
26 changes: 26 additions & 0 deletions src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,31 @@ class spell_inoculate_nestlewood_owlkin : public AuraScript
}
};

// 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();
Expand All @@ -568,4 +593,5 @@ void AddSC_azuremyst_isle()
new npc_stillpine_capitive();
new go_bristlelimb_cage();
RegisterSpellScript(spell_inoculate_nestlewood_owlkin);
RegisterCreatureAI(npc_prophet_velen);
}
17 changes: 5 additions & 12 deletions src/server/scripts/Kalimdor/zone_orgrimmar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* ScriptData
SDName: Orgrimmar
SD%Complete: 100
SDComment: Quest support: 2460, 6566
SDCategory: Orgrimmar
EndScriptData */

/* ContentData
npc_shenthul
npc_thrall_warchief
EndContentData */

#include "AreaDefines.h"
#include "CreatureScript.h"
#include "Player.h"
Expand Down Expand Up @@ -237,6 +225,11 @@ class npc_thrall_warchief : public CreatureScript

void JustEngagedWith(Unit* /*who*/) override { }

void JustDied(Unit* /*killer*/) override
{
DoRewardPlayersInArea();
}

void DoAction(int32 action) override
{
if (action == ACTION_START_TALKING)
Expand Down
44 changes: 44 additions & 0 deletions src/server/scripts/Kalimdor/zone_teldrassil.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
Loading