mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 06:06:23 +00:00
fix(Core/Events): Implement Spirit of Competition event (#16963)
* fix(Core/Events): Implement Spirit of Competition event Co-Authored-By: Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> * Update Battleground.cpp * Update rev_1691529514989936100.sql * more stuff * bye bye magic numbers * fix dberrors * Update Battleground.cpp * Update Battleground.cpp * Update Battleground.cpp Co-Authored-By: Anton Popovichenko <walkline.ua@gmail.com> * Update Battleground.cpp * Update Battleground.cpp * Update Battleground.cpp * Update Battleground.cpp * Update rev_1691529514989936100.sql * commoneers * Update src/server/game/Battlegrounds/Battleground.cpp Co-authored-by: Anton Popovichenko <walkline.ua@gmail.com> * ci * Update rev_1691529514989936100.sql * unnecessary whitespace * Update src/server/game/Battlegrounds/Battleground.cpp * Update src/server/game/Battlegrounds/Battleground.cpp * Update src/server/game/Battlegrounds/Battleground.cpp * Update Battleground.cpp --------- Co-authored-by: Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> Co-authored-by: Anton Popovichenko <walkline.ua@gmail.com>
This commit is contained in:
@@ -916,9 +916,49 @@ void Battleground::EndBattleground(PvPTeamId winnerTeamId)
|
||||
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, player->GetMapId());
|
||||
}
|
||||
|
||||
if (IsEventActive(EVENT_SPIRIT_OF_COMPETITION) && isBattleground())
|
||||
SpiritofCompetitionEvent(winnerTeamId);
|
||||
|
||||
sScriptMgr->OnBattlegroundEnd(this, GetTeamId(winnerTeamId));
|
||||
}
|
||||
|
||||
bool Battleground::SpiritofCompetitionEvent(PvPTeamId winnerTeamId)
|
||||
{
|
||||
// Everyone is eligible for tabard reward
|
||||
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
Player* player = itr->second;
|
||||
bool questStatus = player->GetQuestStatus(QUEST_FLAG_PARTICIPANT) != QUEST_STATUS_REWARDED;
|
||||
|
||||
if (player && questStatus)
|
||||
player->CastSpell(player, SPELL_SPIRIT_OF_COMPETITION_PARTICIPANT, true);
|
||||
}
|
||||
|
||||
// In case of a draw nobody get rewarded
|
||||
if (winnerTeamId == PVP_TEAM_NEUTRAL)
|
||||
return false;
|
||||
|
||||
std::vector<Player*> filteredPlayers;
|
||||
|
||||
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
Player* player = itr->second;
|
||||
bool playerTeam = player->GetBgTeamId() == GetTeamId(winnerTeamId);
|
||||
bool questStatus = player->GetQuestStatus(QUEST_FLAG_WINNER) != QUEST_STATUS_REWARDED;
|
||||
|
||||
if (player && playerTeam && questStatus)
|
||||
filteredPlayers.push_back(player);
|
||||
}
|
||||
|
||||
if (filteredPlayers.size())
|
||||
{
|
||||
if (Player* wPlayer = filteredPlayers[rand() % filteredPlayers.size()])
|
||||
wPlayer->CastSpell(wPlayer, SPELL_SPIRIT_OF_COMPETITION_WINNER, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const
|
||||
{
|
||||
//variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
|
||||
|
||||
@@ -237,6 +237,15 @@ enum BattlegroundStartingEventsIds
|
||||
BG_STARTING_EVENT_FOURTH = 3
|
||||
};
|
||||
|
||||
enum SpiritOfCompetitionEvent
|
||||
{
|
||||
EVENT_SPIRIT_OF_COMPETITION = 46,
|
||||
QUEST_FLAG_PARTICIPANT = 12187,
|
||||
QUEST_FLAG_WINNER = 12186,
|
||||
SPELL_SPIRIT_OF_COMPETITION_PARTICIPANT = 48163,
|
||||
SPELL_SPIRIT_OF_COMPETITION_WINNER = 48164,
|
||||
};
|
||||
|
||||
constexpr auto BG_STARTING_EVENT_COUNT = 4;
|
||||
|
||||
class ArenaLogEntryData
|
||||
@@ -337,6 +346,9 @@ public:
|
||||
[[nodiscard]] uint32 GetScriptId() const { return ScriptId; }
|
||||
[[nodiscard]] uint32 GetBonusHonorFromKill(uint32 kills) const;
|
||||
|
||||
// Spirit of Competition event
|
||||
bool SpiritofCompetitionEvent(PvPTeamId winnerTeamId);
|
||||
|
||||
bool IsRandom() { return m_IsRandom; }
|
||||
|
||||
// Set methods:
|
||||
|
||||
@@ -4917,6 +4917,87 @@ class spell_gen_curse_of_pain : public AuraScript
|
||||
}
|
||||
};
|
||||
|
||||
enum SpiritofCompetition
|
||||
{
|
||||
// Spells
|
||||
SPELL_SPIRIT_OF_COMPETITION_PARTICIPANT_EFFECT = 48056,
|
||||
SPELL_SPIRIT_OF_COMPETITION_WINNER_EFFECT = 48057,
|
||||
// Mail
|
||||
MAIL_THE_COMPETITIORS_TABARD = 195,
|
||||
MAIL_A_GOLD_MEDALLION = 196,
|
||||
// NPC
|
||||
NPC_SPIRIT_OF_COMPETITION = 27217,
|
||||
// Items
|
||||
ITEM_COMPETITORS_TABARD = 36941,
|
||||
ITEM_GOLD_MEDALLION = 37297,
|
||||
};
|
||||
|
||||
class spell_gen_spirit_of_competition_participant : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_gen_spirit_of_competition_participant);
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo({ SPELL_SPIRIT_OF_COMPETITION_PARTICIPANT_EFFECT });
|
||||
}
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Player* player = GetHitPlayer())
|
||||
{
|
||||
player->CastSpell(player, SPELL_SPIRIT_OF_COMPETITION_PARTICIPANT_EFFECT, true);
|
||||
|
||||
Item* item = Item::CreateItem(ITEM_COMPETITORS_TABARD, 1);
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
MailDraft(MAIL_THE_COMPETITIORS_TABARD)
|
||||
.AddItem(item)
|
||||
.SendMailTo(trans, player, MailSender(NPC_SPIRIT_OF_COMPETITION), MAIL_CHECK_MASK_HAS_BODY);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_gen_spirit_of_competition_participant::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_gen_spirit_of_competition_winner : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_gen_spirit_of_competition_winner);
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo({ SPELL_SPIRIT_OF_COMPETITION_WINNER_EFFECT });
|
||||
}
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Player* player = GetHitPlayer())
|
||||
{
|
||||
player->CastSpell(player, SPELL_SPIRIT_OF_COMPETITION_WINNER_EFFECT, true);
|
||||
|
||||
Item* item = Item::CreateItem(ITEM_GOLD_MEDALLION, 1);
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
MailDraft(MAIL_A_GOLD_MEDALLION)
|
||||
.AddItem(item)
|
||||
.SendMailTo(trans, player, MailSender(NPC_SPIRIT_OF_COMPETITION), MAIL_CHECK_MASK_HAS_BODY);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_gen_spirit_of_competition_winner::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_generic_spell_scripts()
|
||||
{
|
||||
RegisterSpellScript(spell_silithyst);
|
||||
@@ -5063,4 +5144,6 @@ void AddSC_generic_spell_scripts()
|
||||
RegisterSpellScript(spell_gen_threshalisk_charge);
|
||||
RegisterSpellScript(spell_gen_shriveling_gaze);
|
||||
RegisterSpellScript(spell_gen_curse_of_pain);
|
||||
RegisterSpellScript(spell_gen_spirit_of_competition_participant);
|
||||
RegisterSpellScript(spell_gen_spirit_of_competition_winner);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user