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:
Kitzunu
2023-08-20 00:41:44 +02:00
committed by GitHub
parent 1a1a320ea1
commit 6185b1d73b
4 changed files with 240 additions and 0 deletions

View File

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