diff --git a/src/server/scripts/KhazAlgar/Delves/GnarldorIsle/instance_gnarldorisle_delve.cpp b/src/server/scripts/KhazAlgar/Delves/GnarldorIsle/instance_gnarldorisle_delve.cpp new file mode 100644 index 00000000..d1a8c52f --- /dev/null +++ b/src/server/scripts/KhazAlgar/Delves/GnarldorIsle/instance_gnarldorisle_delve.cpp @@ -0,0 +1,332 @@ +/* + * This file is part of the TrinityCore 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 General Public License as published by the + * Free Software Foundation; either version 2 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 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 . + */ + +/* + * Gnarldor Isle - map 3038, difficulty 208, scenario 3385, LFGDungeons 3237, AreaTable 16980. + * Evidence: 70783_gnarldorisledelve_parsed.txt / generated pkt.sql - a FULL delve capture + * (12.1.0.70783) that reaches SMSG_SCENARIO_COMPLETED and the 3424 reward scenario. + * + * Scenario 3385 steps: 16908 -> 16909 -> 17232 -> 16910 -> complete. + * - "Speak with" NPCs (Tormunda 263468 et al.) -> GameEvent 91258 (criteria 111078) + * - "Tortollan Relics recovered" x30 -> GameEvent 103533 (criteria 113584) + * - "Abducted Tortollan rescued" x8 -> GameEvent 103799 (criteria 113775) + * - "'Ol Shalty rescued" -> GameEvent 104810 (criteria 115448) + * - Gralka Snake-Eater (260309) slain -> GameEvent 85913 (criteria 60399, shared) + * + * Every objective tick in the capture is preceded by a self-cast of 431462 "Will of the Dawn" + * (the delve's interact/channel spell), so spell_gnarldor_isle_interact credits the matching + * GameEvent for whatever interactable is in range. Killing a creature carrying the + * "Collect/Loot Event" aura (1290067) also credits a relic - the aura is what spawns the + * Abused Relic (263545) loot objects on retail, so both paths are covered and deduplicated + * per spawn GUID. + * + * 'Ol Shalty (268250) is not a static spawn on retail: the Soup Pot vehicle (268249) carrying + * him is created ~30 s after step 17232 becomes current at the position below, so he is + * summoned when the scenario reaches that step. + * + * Completion objects (capture): Bountiful Coffer 584514 + Bountiful Heavy Trunks + * 584518/584515 + Leave-O-Bot 205496 - positions in DelveCompletionSpawns (delves_common.cpp). + */ + +#include "delves_common.h" +#include "DB2Structure.h" +#include "InstanceScenario.h" +#include "Map.h" +#include "ScriptMgr.h" +#include "SpellScript.h" +#include "Vehicle.h" + +namespace +{ + +static char const* const GnarldorIsleScriptName = "instance_gnarldorisle_delve"; + +enum GnarldorIsleData +{ + BOSS_GRALKA_SNAKE_EATER = 0, + + MAX_ENCOUNTER +}; + +enum GnarldorIsleIds : uint32 +{ + NPC_GRALKA_SNAKE_EATER = 260309, // final boss (DungeonEncounter 3512, static spawn) + NPC_TORMUNDA = 263468, // "Speak with" NPC at the entrance + NPC_ABUSED_RELIC = 263545, // loot object spawned by Collect/Loot Event mobs + NPC_SOUP_POT = 268249, // vehicle carrying 'Ol Shalty + NPC_OL_SHALTY = 268250, // step 17232 rescue target + NPC_ABDUCTED_TORTOLLAN_1 = 264293, // transport prisoners (ride vehicles) + NPC_ABDUCTED_TORTOLLAN_2 = 264294, // scattered prisoners + NPC_ABDUCTED_TORTOLLAN_3 = 264382, // entrance prisoners + + DUNGEON_ENCOUNTER_GRALKA = 3512, // SMSG_ENCOUNTER_START/END + SMSG_BOSS_KILL + SCENARIO_STEP_OL_SHALTY = 17232, // Scenario 3385 step "'Ol Shalty rescued" + + SPELL_WILL_OF_THE_DAWN = 431462, // self-targeted delve interact spell + AURA_COLLECT_LOOT_EVENT = 1290067, // mob aura: kills/interactions yield Abused Relics + + // GameEvents behind the scenario criteria (criteria -> asset mapping from the capture) + GAME_EVENT_SPEAK_WITH = 91258, // criteria 111078 "Speak with ..." + GAME_EVENT_RELIC_RECOVERED = 103533, // criteria 113584 "Tortollan Relics recovered" x30 + GAME_EVENT_TORTOLLAN_RESCUED = 103799, // criteria 113775 "Abducted Tortollan rescued" x8 + GAME_EVENT_OL_SHALTY_RESCUED = 104810, // criteria 115448 "'Ol Shalty rescued" + + INTERACT_SCAN_RANGE = 10, // yards around the caster +}; + +// Capture: Soup Pot vehicle create block (SMSG_UPDATE_OBJECT) ~30 s after step 17232 went current +Position const SoupPotSpawnPos = { 4497.3325f, -11873.903f, 149.15977f, 0.0f }; + +DungeonEncounterData const encounters[] = +{ + { BOSS_GRALKA_SNAKE_EATER, {{ DUNGEON_ENCOUNTER_GRALKA }} } +}; + +class instance_gnarldorisle_delve : public InstanceMapScript +{ +public: + instance_gnarldorisle_delve() : InstanceMapScript(GnarldorIsleScriptName, 3038) { } + + struct instance_gnarldorisle_delve_InstanceScript : public Delves::DelveInstanceScript + { + instance_gnarldorisle_delve_InstanceScript(InstanceMap* map) + : DelveInstanceScript(map, 1 /* tier resolved at OnPlayerEnter from m_delveSelectedTier */) + { + SetBossNumber(MAX_ENCOUNTER); + LoadDungeonEncounterData(encounters); + } + + void OnScenarioStepChanged(ScenarioStepEntry const* step) override + { + // Step 17232 "'Ol Shalty rescued" -> retail spawns the Soup Pot vehicle with 'Ol Shalty + // aboard near the reward room a short time later. + if (step && step->ID == SCENARIO_STEP_OL_SHALTY && !_saltySpawned) + { + _saltySpawned = true; + if (Creature* pot = instance->SummonCreature(NPC_SOUP_POT, SoupPotSpawnPos)) + { + if (Creature* shalty = instance->SummonCreature(NPC_OL_SHALTY, SoupPotSpawnPos)) + { + if (Vehicle* vehicle = pot->GetVehicleKit()) + vehicle->AddVehiclePassenger(shalty, 0); + } + } + } + } + + void OnUnitDeath(Unit* unit) override + { + // No boss AI is bound: close the encounter here so SMSG_BOSS_KILL 3512 goes out. + if (Creature* creature = unit ? unit->ToCreature() : nullptr) + { + if (IsFinalBoss(creature) && GetBossState(BOSS_GRALKA_SNAKE_EATER) != DONE) + SetBossState(BOSS_GRALKA_SNAKE_EATER, DONE); + + // A mob carrying "Collect/Loot Event" yields one Abused Relic on retail + // (the aura spawns the 263545 loot object); credit it directly so the + // "Tortollan Relics recovered" counter cannot soft-lock. + if (creature->HasAura(AURA_COLLECT_LOOT_EVENT)) + CreditRelic(creature->GetGUID(), creature); + } + + DelveInstanceScript::OnUnitDeath(unit); + } + + bool IsFinalBoss(Creature const* creature) const override + { + return creature->GetEntry() == NPC_GRALKA_SNAKE_EATER; + } + + void Update(uint32 diff) override + { + DelveInstanceScript::Update(diff); + + // Tormunda carries no npcflag (her "[DNT] Talk To Me" aura drives the talk client-side), + // so "Speak with" is credited when a player walks up to her - same result as gossip. + if (_talkCredited) + return; + + for (Map::PlayerList::const_iterator itr = instance->GetPlayers().begin(); itr != instance->GetPlayers().end(); ++itr) + { + Player* player = itr->GetSource(); + if (!player) + continue; + + std::list talkTargets; + player->GetCreatureListWithEntryInGrid(talkTargets, NPC_TORMUNDA, 8.0f); + if (!talkTargets.empty()) + { + _talkCredited = true; + CreditGameEvent(GAME_EVENT_SPEAK_WITH, talkTargets.front(), player); + break; + } + } + } + + // Called by spell_gnarldor_isle_interact (431462 "Will of the Dawn") for every cast. + void TryCreditInteractables(Player* player) + { + if (!player || player->GetMapId() != 3038) + return; + + std::list creatures; + player->GetCreatureListInGrid(creatures, INTERACT_SCAN_RANGE); + + for (Creature* creature : creatures) + { + if (!creature || !creature->IsAlive()) + continue; + + switch (creature->GetEntry()) + { + case NPC_TORMUNDA: + if (!_talkCredited) + { + _talkCredited = true; + CreditGameEvent(GAME_EVENT_SPEAK_WITH, creature, player); + } + break; + case NPC_ABUSED_RELIC: + CreditRelic(creature->GetGUID(), creature, player); + break; + case NPC_ABDUCTED_TORTOLLAN_1: + case NPC_ABDUCTED_TORTOLLAN_2: + case NPC_ABDUCTED_TORTOLLAN_3: + if (_rescuedTortollans.insert(creature->GetGUID()).second) + { + CreditGameEvent(GAME_EVENT_TORTOLLAN_RESCUED, creature, player); + creature->DespawnOrUnsummon(Milliseconds(1)); + } + break; + case NPC_SOUP_POT: + case NPC_OL_SHALTY: + break; // handled after the scan below + default: + break; + } + + // Any live mob carrying the Collect/Loot Event aura is a relic source. + if (creature->HasAura(AURA_COLLECT_LOOT_EVENT)) + CreditRelic(creature->GetGUID(), creature, player); + } + + // 'Ol Shalty / the Soup Pot: one credit frees them both. + if (!_saltyCredited) + { + std::list salty; + player->GetCreatureListWithEntryInGrid(salty, NPC_SOUP_POT, INTERACT_SCAN_RANGE); + player->GetCreatureListWithEntryInGrid(salty, NPC_OL_SHALTY, INTERACT_SCAN_RANGE); + if (!salty.empty()) + { + _saltyCredited = true; + CreditGameEvent(GAME_EVENT_OL_SHALTY_RESCUED, salty.front(), player); + for (Creature* creature : salty) + creature->DespawnOrUnsummon(Milliseconds(1)); + } + } + } + + void CreditRelic(ObjectGuid const& guid, Unit* source, Player* player = nullptr) + { + if (!_creditedRelics.insert(guid).second) + return; + + CreditGameEvent(GAME_EVENT_RELIC_RECOVERED, source, player); + + // The physical Abused Relic object is consumed by the rescue + if (Creature* relic = source ? source->ToCreature() : nullptr) + if (relic->GetEntry() == NPC_ABUSED_RELIC) + relic->DespawnOrUnsummon(Milliseconds(1)); + } + + private: + void CreditGameEvent(uint32 gameEventId, WorldObject* source, Player* referencePlayer) + { + InstanceScenario* scenario = instance->GetInstanceScenario(); + if (!scenario) + return; + + if (!referencePlayer) + { + // Scenario criteria are evaluated against a reference player; any participant works. + for (Map::PlayerList::const_iterator itr = instance->GetPlayers().begin(); itr != instance->GetPlayers().end(); ++itr) + if (Player* player = itr->GetSource()) + { + referencePlayer = player; + break; + } + } + + scenario->UpdateCriteria(CriteriaType::AnyoneTriggerGameEventScenario, gameEventId, 0, 0, source, referencePlayer); + } + + GuidUnorderedSet _creditedRelics; + GuidUnorderedSet _rescuedTortollans; + bool _saltySpawned = false; + bool _saltyCredited = false; + bool _talkCredited = false; + }; + + InstanceScript* GetInstanceScript(InstanceMap* map) const override + { + return new instance_gnarldorisle_delve_InstanceScript(map); + } +}; + +// 431462 "Will of the Dawn" - the delve's self-targeted interact spell. Every objective tick in +// the retail capture is preceded by a cast of it, so credit whatever interactable is in range. +class spell_gnarldor_isle_interact : public SpellScriptLoader +{ +public: + spell_gnarldor_isle_interact() : SpellScriptLoader("spell_gnarldor_isle_interact") { } + + class spell_gnarldor_isle_interact_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gnarldor_isle_interact_SpellScript); + + void CreditInteractables(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + if (!caster || caster->GetMapId() != 3038) + return; + + if (InstanceMap* instanceMap = caster->GetMap() ? caster->GetMap()->ToInstanceMap() : nullptr) + if (InstanceScript* script = instanceMap->GetInstanceScript()) + if (auto* delve = dynamic_cast(script)) + delve->TryCreditInteractables(caster); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_gnarldor_isle_interact_SpellScript::CreditInteractables, EFFECT_0, SPELL_EFFECT_ANY); + OnEffectHitTarget += SpellEffectFn(spell_gnarldor_isle_interact_SpellScript::CreditInteractables, EFFECT_ALL, SPELL_EFFECT_ANY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_gnarldor_isle_interact_SpellScript(); + } +}; + +} // anonymous namespace + +void AddSC_instance_gnarldorisle_delve() +{ + new instance_gnarldorisle_delve(); + new spell_gnarldor_isle_interact(); +} diff --git a/src/server/scripts/KhazAlgar/Delves/delves_common.cpp b/src/server/scripts/KhazAlgar/Delves/delves_common.cpp index 7d50fafe..f047a4f1 100644 --- a/src/server/scripts/KhazAlgar/Delves/delves_common.cpp +++ b/src/server/scripts/KhazAlgar/Delves/delves_common.cpp @@ -88,6 +88,11 @@ namespace Delves { 3003, {}, Position(3088.867f, 4811.938f, 598.892f, 0.4189f), Position(3091.364f, 4801.626f, 598.892f, 6.1959f), Position(3200.856f, 4805.387f, 620.936f, 3.1678f), 584518, 584515 }, + // Gnarldor Isle (70783_gnarldorisledelve.pkt.sql): Bountiful Heavy Trunks + // 584518/584515 + Leave-O-Bot 205496. No Fragment of Revelation. + { 3038, {}, Position(4668.157f, -11722.514f, 149.586f, 4.1539f), + Position(4659.626f, -11716.229f, 149.586f, 3.6477f), Position(4529.780f, -11743.117f, 85.800f, 1.4227f), + 584518, 584515 }, }; DelveCompletionSpawns const* GetCompletionSpawns(uint32 mapId) diff --git a/src/server/scripts/KhazAlgar/khaz_algar_script_loader.cpp b/src/server/scripts/KhazAlgar/khaz_algar_script_loader.cpp index fbce7691..8043227a 100644 --- a/src/server/scripts/KhazAlgar/khaz_algar_script_loader.cpp +++ b/src/server/scripts/KhazAlgar/khaz_algar_script_loader.cpp @@ -69,6 +69,7 @@ void AddSC_instance_gulf_of_memory_delve(); void AddSC_instance_collegiate_calamity_delve(); void AddSC_gulf_of_memory_encounters(); void AddSC_instance_the_darkway_delve(); +void AddSC_instance_gnarldorisle_delve(); void AddSC_npc_delve_companion(); void AddSC_delve_objects(); void AddSC_npc_under_lord_viktis(); @@ -130,6 +131,7 @@ void AddKhazAlgarScripts() AddSC_instance_collegiate_calamity_delve(); AddSC_gulf_of_memory_encounters(); AddSC_instance_the_darkway_delve(); + AddSC_instance_gnarldorisle_delve(); AddSC_npc_delve_companion(); AddSC_delve_objects(); AddSC_npc_under_lord_viktis();