From 37d92f8dc8588c72a9f082e43e9bfb14edf20648 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Wed, 9 Mar 2022 09:26:25 +0100 Subject: [PATCH] fix(Scripts/Ulduar): Fixed spawning Hodir chests. (#10844) --- .../Northrend/Ulduar/Ulduar/boss_hodir.cpp | 28 ++-- .../Ulduar/Ulduar/instance_ulduar.cpp | 121 +++++++++--------- .../scripts/Northrend/Ulduar/Ulduar/ulduar.h | 5 +- 3 files changed, 76 insertions(+), 78 deletions(-) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index e384ce1af..7a40af519 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp @@ -257,11 +257,6 @@ public: go->SetGoState(GO_STATE_ACTIVE); } - if (pInstance && pInstance->GetData(TYPE_HODIR) != DONE) - { - pInstance->SetData(TYPE_SPAWN_HODIR_CACHE, 0); - } - // Reset helpers if (!summons.size()) SpawnHelpers(); @@ -296,10 +291,13 @@ public: switch (action) { case EVENT_FAIL_HM: - if (GameObject* go = me->FindNearestGameObject(GO_HODIR_CHEST_HARD, 500.0f)) + if (pInstance) { - go->SetGoState(GO_STATE_ACTIVE); - events.ScheduleEvent(EVENT_DESPAWN_CHEST, 3000); + if (GameObject* go = pInstance->instance->GetGameObject(pInstance->GetGuidData(GO_HODIR_CHEST_HARD))) + { + go->SetGoState(GO_STATE_ACTIVE); + events.ScheduleEvent(EVENT_DESPAWN_CHEST, 3000); + } } break; } @@ -425,7 +423,13 @@ public: case EVENT_HARD_MODE_MISSED: { Talk(TEXT_HM_MISS); - me->CastSpell(me->FindNearestGameObject(GO_HODIR_CHEST_HARD, 400.0f), SPELL_SHATTER_CHEST, false); + if (pInstance) + { + if (GameObject* go = pInstance->instance->GetGameObject(pInstance->GetGuidData(GO_HODIR_CHEST_HARD))) + { + me->CastSpell(go, SPELL_SHATTER_CHEST, false); + } + } } break; case EVENT_DESPAWN_CHEST: @@ -1161,15 +1165,17 @@ public: { PrepareSpellScript(spell_hodir_shatter_chestSpellScript) - void destroyWinterCache() + void destroyWinterCache(SpellEffIndex effIndex) { + PreventHitDefaultEffect(effIndex); + if (Unit* hodir = GetCaster()) hodir->GetAI()->DoAction(EVENT_FAIL_HM); } void Register() override { - AfterHit += SpellHitFn(spell_hodir_shatter_chestSpellScript::destroyWinterCache); + OnEffectHit += SpellEffectFn(spell_hodir_shatter_chestSpellScript::destroyWinterCache, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); }; }; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 79da81c85..20f02eda0 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -214,75 +214,74 @@ public: SetData(eventId, 0); } - void SpawnHodirChests(int rd) + void SpawnHodirChests(Difficulty diff, Creature* hodir) { - if (Creature* cr = instance->GetCreature(m_uiHodirGUID)) + switch (diff) { - switch (rd) + case RAID_DIFFICULTY_10MAN_NORMAL: // 10 man chest { - case 0: // 10 man chest + if (!m_hodirNormalChest) { - if (!m_hodirNormalChest) + if (GameObject* go = hodir->SummonGameObject( + GO_HODIR_CHEST_NORMAL, + normalChestPosition.GetPositionX(), + normalChestPosition.GetPositionY(), + normalChestPosition.GetPositionZ(), + normalChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) { - if (GameObject* go = cr->SummonGameObject( - GO_HODIR_CHEST_NORMAL, - normalChestPosition.GetPositionX(), - normalChestPosition.GetPositionY(), - normalChestPosition.GetPositionZ(), - normalChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) - { - m_hodirNormalChest = go->GetGUID(); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - } + m_hodirNormalChest = go->GetGUID(); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } - if (!m_hodirHardmodeChest) - { - if (GameObject* go = cr->SummonGameObject( - GO_HODIR_CHEST_HARD, - hardChestPosition.GetPositionX(), - hardChestPosition.GetPositionY(), - hardChestPosition.GetPositionZ(), - hardChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) - { - m_hodirHardmodeChest = go->GetGUID(); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - hmHodir = true; - } - } - break; } - case 1: // 25 man chest + if (!m_hodirHardmodeChest) { - if (!m_hodirNormalChest) + if (GameObject* go = hodir->SummonGameObject( + GO_HODIR_CHEST_HARD, + hardChestPosition.GetPositionX(), + hardChestPosition.GetPositionY(), + hardChestPosition.GetPositionZ(), + hardChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) { - if (GameObject* go = cr->SummonGameObject( - GO_HODIR_CHEST_NORMAL_HERO, - normalChestPosition.GetPositionX(), - normalChestPosition.GetPositionY(), - normalChestPosition.GetPositionZ(), - normalChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) - { - m_hodirNormalChest = go->GetGUID(); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - } + m_hodirHardmodeChest = go->GetGUID(); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + hmHodir = true; } - if (!m_hodirHardmodeChest) - { - if (GameObject* go = cr->SummonGameObject( - GO_HODIR_CHEST_HARD_HERO, - hardChestPosition.GetPositionX(), - hardChestPosition.GetPositionY(), - hardChestPosition.GetPositionZ(), - hardChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) - { - m_hodirHardmodeChest = go->GetGUID(); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - hmHodir = true; - } - } - break; } + break; } + case RAID_DIFFICULTY_25MAN_NORMAL: // 25 man chest + { + if (!m_hodirNormalChest) + { + if (GameObject* go = hodir->SummonGameObject( + GO_HODIR_CHEST_NORMAL_HERO, + normalChestPosition.GetPositionX(), + normalChestPosition.GetPositionY(), + normalChestPosition.GetPositionZ(), + normalChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) + { + m_hodirNormalChest = go->GetGUID(); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + } + } + if (!m_hodirHardmodeChest) + { + if (GameObject* go = hodir->SummonGameObject( + GO_HODIR_CHEST_HARD_HERO, + hardChestPosition.GetPositionX(), + hardChestPosition.GetPositionY(), + hardChestPosition.GetPositionZ(), + hardChestPosition.GetOrientation(), 0, 0, 0, 0, 0)) + { + m_hodirHardmodeChest = go->GetGUID(); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + hmHodir = true; + } + } + break; + } + default: + break; } } @@ -329,6 +328,7 @@ public: break; case NPC_HODIR: m_uiHodirGUID = creature->GetGUID(); + SpawnHodirChests(instance->GetDifficulty(), creature); break; case NPC_THORIM: m_uiThorimGUID = creature->GetGUID(); @@ -690,11 +690,6 @@ public: if (GetData(TYPE_HODIR) == DONE) setChestsLootable(TYPE_HODIR); break; - - case TYPE_SPAWN_HODIR_CACHE: - // Is the difficulty 10 man(0) ? return 10 man : return 25 man; - SpawnHodirChests(m_difficulty == 0 ? 0 : 1); - break; case TYPE_HODIR_HM_FAIL: if (GameObject* go = instance->GetGameObject(m_hodirHardmodeChest)) { @@ -909,10 +904,8 @@ public: // Hodir chests case GO_HODIR_CHEST_HARD: - case GO_HODIR_CHEST_HARD_HERO: return m_hodirHardmodeChest; case GO_HODIR_CHEST_NORMAL: - case GO_HODIR_CHEST_NORMAL_HERO: return m_hodirNormalChest; // Freya Elders diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h index e913d4c3a..d42daffc3 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h @@ -45,9 +45,8 @@ enum UlduarEncounters TYPE_YOGGSARON = 12, TYPE_ALGALON = 13, TYPE_WATCHERS = 14, - TYPE_SPAWN_HODIR_CACHE = 15, - TYPE_HODIR_HM_FAIL = 16, - TYPE_WINTER_CACHE = 17, + TYPE_HODIR_HM_FAIL = 15, + TYPE_WINTER_CACHE = 16 }; enum UlduarData