mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
fix(Scripts/Midsummer): Implement Midsummer Bonfire mechanics (#18023)
This commit is contained in:
@@ -16,9 +16,11 @@
|
||||
*/
|
||||
|
||||
#include "CreatureScript.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GameObjectScript.h"
|
||||
#include "GameTime.h"
|
||||
#include "Player.h"
|
||||
#include "PlayerScript.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "ScriptedGossip.h"
|
||||
#include "Spell.h"
|
||||
@@ -29,10 +31,28 @@
|
||||
|
||||
enum eBonfire
|
||||
{
|
||||
GO_MIDSUMMER_BONFIRE = 181288,
|
||||
GO_MIDSUMMER_BONFIRE_CAMPFIRE_SPELL_FOCUS = 181377,
|
||||
GO_AHUNE_BONFIRE = 188073,
|
||||
|
||||
SPELL_MIDSUMMER_BONFIRE_BUNNIES_2 = 29114,
|
||||
|
||||
SPELL_STAMP_OUT_BONFIRE = 45437,
|
||||
SPELL_LIGHT_BONFIRE = 29831,
|
||||
SPELL_STAMP_OUT_BONFIRE_ART_KIT = 46903,
|
||||
|
||||
SPELL_TOSS_FUEL_ON_BONFIRE = 28806,
|
||||
SPELL_LIGHT_BONFIRE_ART_KIT = 46904,
|
||||
|
||||
SPELL_BONFIRES_BLESSING = 45444,
|
||||
|
||||
BONFIRE_TYPE_NONE = 0,
|
||||
BONFIRE_TYPE_ALLIANCE = 1,
|
||||
BONFIRE_TYPE_HORDE = 2,
|
||||
BONFIRE_TYPE_CITY = 3,
|
||||
BONFIRE_TYPE_AHUNE = 4,
|
||||
|
||||
COUNT_GO_BONFIRE_ALLIANCE = 40,
|
||||
COUNT_GO_BONFIRE_HORDE = 38,
|
||||
COUNT_GO_BONFIRE_CITY = 9,
|
||||
};
|
||||
|
||||
class go_midsummer_bonfire : public GameObjectScript
|
||||
@@ -49,6 +69,313 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool BonfireStampedOutState[COUNT_GO_BONFIRE_ALLIANCE + COUNT_GO_BONFIRE_HORDE];
|
||||
|
||||
// <mapId, zoneId, teamId>, <state>
|
||||
const std::map<std::tuple<uint32, uint32, TeamId>, bool*> BonfireStateStore = {
|
||||
// Map 0
|
||||
{ { 0, 1, TEAM_ALLIANCE }, &BonfireStampedOutState[0] },
|
||||
{ { 0, 3, TEAM_HORDE }, &BonfireStampedOutState[1] },
|
||||
{ { 0, 4, TEAM_ALLIANCE }, &BonfireStampedOutState[2] },
|
||||
{ { 0, 8, TEAM_HORDE }, &BonfireStampedOutState[3] },
|
||||
{ { 0, 10, TEAM_ALLIANCE }, &BonfireStampedOutState[4] },
|
||||
{ { 0, 11, TEAM_ALLIANCE }, &BonfireStampedOutState[5] },
|
||||
{ { 0, 12, TEAM_ALLIANCE }, &BonfireStampedOutState[6] },
|
||||
{ { 0, 28, TEAM_ALLIANCE }, &BonfireStampedOutState[7] },
|
||||
{ { 0, 33, TEAM_ALLIANCE }, &BonfireStampedOutState[8] },
|
||||
{ { 0, 33, TEAM_HORDE }, &BonfireStampedOutState[9] },
|
||||
{ { 0, 38, TEAM_ALLIANCE }, &BonfireStampedOutState[10] },
|
||||
{ { 0, 40, TEAM_ALLIANCE }, &BonfireStampedOutState[11] },
|
||||
{ { 0, 44, TEAM_ALLIANCE }, &BonfireStampedOutState[12] },
|
||||
{ { 0, 45, TEAM_ALLIANCE }, &BonfireStampedOutState[13] },
|
||||
{ { 0, 45, TEAM_HORDE }, &BonfireStampedOutState[14] },
|
||||
{ { 0, 46, TEAM_ALLIANCE }, &BonfireStampedOutState[15] },
|
||||
{ { 0, 46, TEAM_HORDE }, &BonfireStampedOutState[16] },
|
||||
{ { 0, 47, TEAM_ALLIANCE }, &BonfireStampedOutState[17] },
|
||||
{ { 0, 47, TEAM_HORDE }, &BonfireStampedOutState[18] },
|
||||
{ { 0, 85, TEAM_HORDE }, &BonfireStampedOutState[19] },
|
||||
{ { 0, 130, TEAM_HORDE }, &BonfireStampedOutState[20] },
|
||||
{ { 0, 267, TEAM_ALLIANCE }, &BonfireStampedOutState[21] },
|
||||
{ { 0, 267, TEAM_HORDE }, &BonfireStampedOutState[22] },
|
||||
|
||||
// Map 1
|
||||
{ { 1, 14, TEAM_HORDE }, &BonfireStampedOutState[23] },
|
||||
{ { 1, 15, TEAM_ALLIANCE }, &BonfireStampedOutState[24] },
|
||||
{ { 1, 15, TEAM_HORDE }, &BonfireStampedOutState[25] },
|
||||
{ { 1, 17, TEAM_HORDE }, &BonfireStampedOutState[26] },
|
||||
{ { 1, 141, TEAM_ALLIANCE }, &BonfireStampedOutState[27] },
|
||||
{ { 1, 148, TEAM_ALLIANCE }, &BonfireStampedOutState[28] },
|
||||
{ { 1, 215, TEAM_HORDE }, &BonfireStampedOutState[29] },
|
||||
{ { 1, 331, TEAM_ALLIANCE }, &BonfireStampedOutState[30] },
|
||||
{ { 1, 331, TEAM_HORDE }, &BonfireStampedOutState[31] },
|
||||
{ { 1, 357, TEAM_ALLIANCE }, &BonfireStampedOutState[32] },
|
||||
{ { 1, 357, TEAM_HORDE }, &BonfireStampedOutState[33] },
|
||||
{ { 1, 400, TEAM_HORDE }, &BonfireStampedOutState[34] },
|
||||
{ { 1, 405, TEAM_ALLIANCE }, &BonfireStampedOutState[35] },
|
||||
{ { 1, 405, TEAM_HORDE }, &BonfireStampedOutState[36] },
|
||||
{ { 1, 406, TEAM_HORDE }, &BonfireStampedOutState[37] },
|
||||
{ { 1, 440, TEAM_ALLIANCE }, &BonfireStampedOutState[38] },
|
||||
{ { 1, 440, TEAM_HORDE }, &BonfireStampedOutState[39] },
|
||||
{ { 1, 618, TEAM_ALLIANCE }, &BonfireStampedOutState[40] },
|
||||
{ { 1, 618, TEAM_HORDE }, &BonfireStampedOutState[41] },
|
||||
{ { 1, 1377, TEAM_ALLIANCE }, &BonfireStampedOutState[42] },
|
||||
{ { 1, 1377, TEAM_HORDE }, &BonfireStampedOutState[43] },
|
||||
|
||||
// Map 530
|
||||
{ { 530, 3430, TEAM_HORDE }, &BonfireStampedOutState[44] },
|
||||
{ { 530, 3433, TEAM_HORDE }, &BonfireStampedOutState[45] },
|
||||
{ { 530, 3483, TEAM_ALLIANCE }, &BonfireStampedOutState[46] },
|
||||
{ { 530, 3483, TEAM_HORDE }, &BonfireStampedOutState[47] },
|
||||
{ { 530, 3518, TEAM_ALLIANCE }, &BonfireStampedOutState[48] },
|
||||
{ { 530, 3518, TEAM_HORDE }, &BonfireStampedOutState[49] },
|
||||
{ { 530, 3519, TEAM_ALLIANCE }, &BonfireStampedOutState[50] },
|
||||
{ { 530, 3519, TEAM_HORDE }, &BonfireStampedOutState[51] },
|
||||
{ { 530, 3520, TEAM_ALLIANCE }, &BonfireStampedOutState[52] },
|
||||
{ { 530, 3520, TEAM_HORDE }, &BonfireStampedOutState[53] },
|
||||
{ { 530, 3521, TEAM_ALLIANCE }, &BonfireStampedOutState[54] },
|
||||
{ { 530, 3521, TEAM_HORDE }, &BonfireStampedOutState[55] },
|
||||
{ { 530, 3522, TEAM_ALLIANCE }, &BonfireStampedOutState[56] },
|
||||
{ { 530, 3522, TEAM_HORDE }, &BonfireStampedOutState[57] },
|
||||
{ { 530, 3523, TEAM_ALLIANCE }, &BonfireStampedOutState[58] },
|
||||
{ { 530, 3523, TEAM_HORDE }, &BonfireStampedOutState[59] },
|
||||
{ { 530, 3524, TEAM_ALLIANCE }, &BonfireStampedOutState[60] },
|
||||
{ { 530, 3525, TEAM_ALLIANCE }, &BonfireStampedOutState[61] },
|
||||
|
||||
// Map 571
|
||||
{ { 571, 65, TEAM_ALLIANCE }, &BonfireStampedOutState[62] },
|
||||
{ { 571, 65, TEAM_HORDE }, &BonfireStampedOutState[63] },
|
||||
{ { 571, 66, TEAM_ALLIANCE }, &BonfireStampedOutState[64] },
|
||||
{ { 571, 66, TEAM_HORDE }, &BonfireStampedOutState[65] },
|
||||
{ { 571, 67, TEAM_ALLIANCE }, &BonfireStampedOutState[66] },
|
||||
{ { 571, 67, TEAM_HORDE }, &BonfireStampedOutState[67] },
|
||||
{ { 571, 394, TEAM_ALLIANCE }, &BonfireStampedOutState[68] },
|
||||
{ { 571, 394, TEAM_HORDE }, &BonfireStampedOutState[69] },
|
||||
{ { 571, 495, TEAM_ALLIANCE }, &BonfireStampedOutState[70] },
|
||||
{ { 571, 495, TEAM_HORDE }, &BonfireStampedOutState[71] },
|
||||
{ { 571, 2817, TEAM_ALLIANCE }, &BonfireStampedOutState[72] },
|
||||
{ { 571, 2817, TEAM_HORDE }, &BonfireStampedOutState[73] },
|
||||
{ { 571, 3537, TEAM_ALLIANCE }, &BonfireStampedOutState[74] },
|
||||
{ { 571, 3537, TEAM_HORDE }, &BonfireStampedOutState[75] },
|
||||
{ { 571, 3711, TEAM_ALLIANCE }, &BonfireStampedOutState[76] },
|
||||
{ { 571, 3711, TEAM_HORDE }, &BonfireStampedOutState[77] },
|
||||
};
|
||||
|
||||
uint32 const GoBonfireAlliance[COUNT_GO_BONFIRE_ALLIANCE] = { 187564, 187914, 187916, 187917, 187919, 187920, 187921, 187922, 187923, 187924, 187925, 187926, 187927, 187928, 187929, 187930, 187931, 187932, 187933, 187934, 187935, 187936, 187937, 187938, 187939, 187940, 187941, 187942, 187943, 187944, 187945, 187946, 194032, 194035, 194036, 194038, 194040, 194044, 194045, 194049 };
|
||||
uint32 const GoBonfireHorde[COUNT_GO_BONFIRE_HORDE] = { 187559, 187947, 187948, 187949, 187950, 187951, 187952, 187953, 187954, 187955, 187956, 187957, 187958, 187959, 187960, 187961, 187962, 187963, 187964, 187965, 187966, 187967, 187968, 187969, 187970, 187971, 187972, 187973, 187974, 187975, 194033, 194034, 194037, 194039, 194042, 194043, 194046, 194048 };
|
||||
uint32 const GoBonfireCity[COUNT_GO_BONFIRE_CITY] = { 181332, 181333, 181334, 181335, 181336, 181337, 188128, 188129, 188352 };
|
||||
|
||||
class MidsummerPlayerScript : public PlayerScript
|
||||
{
|
||||
public:
|
||||
MidsummerPlayerScript() : PlayerScript("MidsummerPlayerScript")
|
||||
{
|
||||
}
|
||||
|
||||
void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) override
|
||||
{
|
||||
if (!IsHolidayActive(HOLIDAY_FIRE_FESTIVAL))
|
||||
return;
|
||||
|
||||
auto itr = BonfireStateStore.find(std::make_tuple(player->GetMapId(), newZone, player->GetTeamId()));
|
||||
if ((itr != BonfireStateStore.end()) && (itr->second))
|
||||
{
|
||||
if (!(*(itr->second)))
|
||||
{
|
||||
if (!player->HasAura(SPELL_BONFIRES_BLESSING))
|
||||
player->CastSpell(player, SPELL_BONFIRES_BLESSING, true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player->RemoveAurasDueToSpell(SPELL_BONFIRES_BLESSING);
|
||||
}
|
||||
};
|
||||
|
||||
struct npc_midsummer_bonfire : public ScriptedAI
|
||||
{
|
||||
npc_midsummer_bonfire(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
_isStampedOut = nullptr;
|
||||
_teamId = TEAM_NEUTRAL;
|
||||
_type = BONFIRE_TYPE_NONE;
|
||||
_spellFocus = nullptr;
|
||||
|
||||
if (!IsHolidayActive(HOLIDAY_FIRE_FESTIVAL))
|
||||
return;
|
||||
|
||||
scheduler.Schedule(420ms, [this](TaskContext context)
|
||||
{
|
||||
if (!InitBonfire())
|
||||
context.Repeat();
|
||||
});
|
||||
}
|
||||
|
||||
void Ignite()
|
||||
{
|
||||
if (_isStampedOut)
|
||||
*_isStampedOut = false;
|
||||
|
||||
if (!_spellFocus)
|
||||
{
|
||||
DoCastSelf(SPELL_MIDSUMMER_BONFIRE_BUNNIES_2, true);
|
||||
|
||||
if ((_spellFocus = me->FindNearestGameObject(GO_MIDSUMMER_BONFIRE_CAMPFIRE_SPELL_FOCUS, 10.0f)))
|
||||
me->AddGameObject(_spellFocus);
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case BONFIRE_TYPE_ALLIANCE:
|
||||
case BONFIRE_TYPE_HORDE:
|
||||
DoCastSelf(SPELL_LIGHT_BONFIRE_ART_KIT, true);
|
||||
UpdateBonfireBlessingBuffs();
|
||||
break;
|
||||
case BONFIRE_TYPE_AHUNE:
|
||||
if (_bonfire)
|
||||
_bonfire->SetGoState(GO_STATE_ACTIVE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void StampOut()
|
||||
{
|
||||
switch (_type)
|
||||
{
|
||||
case BONFIRE_TYPE_ALLIANCE:
|
||||
case BONFIRE_TYPE_HORDE:
|
||||
if (_isStampedOut)
|
||||
*_isStampedOut = true;
|
||||
|
||||
if (_spellFocus)
|
||||
{
|
||||
_spellFocus->DespawnOrUnsummon();
|
||||
_spellFocus = nullptr;
|
||||
}
|
||||
|
||||
DoCastSelf(SPELL_STAMP_OUT_BONFIRE_ART_KIT, true);
|
||||
UpdateBonfireBlessingBuffs();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateBonfireBlessingBuffs()
|
||||
{
|
||||
if ((_type != BONFIRE_TYPE_ALLIANCE) && (_type != BONFIRE_TYPE_HORDE))
|
||||
return;
|
||||
|
||||
me->GetMap()->DoForAllPlayers([&](Player* p)
|
||||
{
|
||||
if ((p->GetZoneId() == me->GetZoneId()) && (p->GetTeamId() == _teamId))
|
||||
{
|
||||
if (_isStampedOut)
|
||||
{
|
||||
if (*_isStampedOut)
|
||||
p->RemoveAurasDueToSpell(SPELL_BONFIRES_BLESSING);
|
||||
else
|
||||
{
|
||||
if (!p->HasAura(SPELL_BONFIRES_BLESSING))
|
||||
p->CastSpell(p, SPELL_BONFIRES_BLESSING, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool InitBonfire()
|
||||
{
|
||||
_type = BONFIRE_TYPE_NONE;
|
||||
_teamId = TEAM_NEUTRAL;
|
||||
|
||||
for (uint32 i = 0; (i < COUNT_GO_BONFIRE_ALLIANCE) && (_type == BONFIRE_TYPE_NONE); i++)
|
||||
{
|
||||
if ((_bonfire = me->FindNearestGameObject(GoBonfireAlliance[i], 10.0f)))
|
||||
{
|
||||
_type = BONFIRE_TYPE_ALLIANCE;
|
||||
_teamId = TEAM_ALLIANCE;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32 i = 0; (i < COUNT_GO_BONFIRE_HORDE) && (_type == BONFIRE_TYPE_NONE); i++)
|
||||
{
|
||||
if ((_bonfire = me->FindNearestGameObject(GoBonfireHorde[i], 10.0f)))
|
||||
{
|
||||
_type = BONFIRE_TYPE_HORDE;
|
||||
_teamId = TEAM_HORDE;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32 i = 0; (i < COUNT_GO_BONFIRE_CITY) && (_type == BONFIRE_TYPE_NONE); i++)
|
||||
{
|
||||
if ((_bonfire = me->FindNearestGameObject(GoBonfireCity[i], 10.0f)))
|
||||
{
|
||||
_type = BONFIRE_TYPE_CITY;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((_type == BONFIRE_TYPE_NONE) && (_bonfire = me->FindNearestGameObject(GO_AHUNE_BONFIRE, 10.0f)))
|
||||
{
|
||||
_type = BONFIRE_TYPE_AHUNE;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_type == BONFIRE_TYPE_NONE)
|
||||
return false;
|
||||
|
||||
auto itr = BonfireStateStore.find(std::make_tuple(me->GetMapId(), me->GetZoneId(), _teamId));
|
||||
if ((itr != BonfireStateStore.end()) && (itr->second))
|
||||
_isStampedOut = itr->second;
|
||||
else
|
||||
LOG_ERROR("scripts.midsummer", "NPC {} (GUID{}) in map {}, zone {} with teamId {} can't locate its entry within BonfireStateStore", me->GetGUID().GetEntry(), me->GetSpawnId(), me->GetMapId(), me->GetZoneId(), _teamId);
|
||||
|
||||
Ignite();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SpellHit(Unit* caster, SpellInfo const* spellInfo) override
|
||||
{
|
||||
if (caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
switch (spellInfo->Id)
|
||||
{
|
||||
case SPELL_TOSS_FUEL_ON_BONFIRE:
|
||||
{
|
||||
Ignite();
|
||||
break;
|
||||
}
|
||||
case SPELL_STAMP_OUT_BONFIRE:
|
||||
{
|
||||
StampOut();
|
||||
|
||||
// desecrating other faction's bonfire flags player for PVP
|
||||
caster->SetPvP(true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
scheduler.Update(diff);
|
||||
}
|
||||
|
||||
private:
|
||||
bool* _isStampedOut;
|
||||
TeamId _teamId;
|
||||
uint8 _type;
|
||||
GameObject* _spellFocus;
|
||||
GameObject* _bonfire;
|
||||
};
|
||||
|
||||
enum torchToss
|
||||
{
|
||||
GO_TORCH_TARGET_BRAZIER = 187708,
|
||||
@@ -172,6 +499,30 @@ struct npc_midsummer_torch_target : public ScriptedAI
|
||||
// SPELLS
|
||||
///////////////////////////////
|
||||
|
||||
class spell_bonfires_blessing : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_bonfires_blessing)
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo({ SPELL_BONFIRES_BLESSING });
|
||||
}
|
||||
|
||||
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
if (!IsHolidayActive(HOLIDAY_FIRE_FESTIVAL))
|
||||
{
|
||||
if (Unit* target = GetTarget())
|
||||
target->RemoveAurasDueToSpell(SPELL_BONFIRES_BLESSING);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
AfterEffectApply += AuraEffectApplyFn(spell_bonfires_blessing::OnApply, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
|
||||
}
|
||||
};
|
||||
|
||||
enum CrabDisguise
|
||||
{
|
||||
SPELL_CRAB_DISGUISE = 46337,
|
||||
@@ -879,12 +1230,17 @@ class spell_midsummer_torch_catch : public SpellScript
|
||||
|
||||
void AddSC_event_midsummer_scripts()
|
||||
{
|
||||
// Player
|
||||
new MidsummerPlayerScript();
|
||||
|
||||
// NPCs
|
||||
new go_midsummer_bonfire();
|
||||
RegisterCreatureAI(npc_midsummer_bonfire);
|
||||
RegisterCreatureAI(npc_midsummer_torch_target);
|
||||
RegisterCreatureAI(npc_midsummer_ribbon_pole_target);
|
||||
|
||||
// Spells
|
||||
RegisterSpellScript(spell_bonfires_blessing);
|
||||
RegisterSpellScript(spell_gen_crab_disguise);
|
||||
RegisterSpellScript(spell_midsummer_ribbon_pole_firework);
|
||||
RegisterSpellScript(spell_midsummer_ribbon_pole);
|
||||
|
||||
Reference in New Issue
Block a user