From 6798b907b9c451dec48abafc3403de4b35644769 Mon Sep 17 00:00:00 2001 From: patou01 <2592673+patou01@users.noreply.github.com> Date: Thu, 21 Oct 2021 21:38:48 +0200 Subject: [PATCH] fix(Core/Script): Tomb of 7 in brd (#7991) --- .../rev_1634143017202196500.sql | 30 ++++ .../BlackrockDepths/blackrock_depths.h | 3 - .../BlackrockDepths/boss_tomb_of_seven.cpp | 23 +-- .../instance_blackrock_depths.cpp | 140 +++++++++++------- 4 files changed, 128 insertions(+), 68 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1634143017202196500.sql diff --git a/data/sql/updates/pending_db_world/rev_1634143017202196500.sql b/data/sql/updates/pending_db_world/rev_1634143017202196500.sql new file mode 100644 index 000000000..7ecca631e --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1634143017202196500.sql @@ -0,0 +1,30 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1634143017202196500'); + +-- add doZOneInCombat for the bosses +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 9034) AND (`source_type` = 0) AND (`id` IN (4)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(9034, 0, 4, 0, 0, 0, 100, 0, 5000, 5000, 5000, 5000, 0, 38, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Haterel - in combat - do zone in combat'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 9035) AND (`source_type` = 0) AND (`id` IN (4)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(9035, 0, 4, 0, 0, 0, 100, 0, 5000, 5000, 5000, 5000, 0, 38, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Angerel - in combat - do zone in combat'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 9036) AND (`source_type` = 0) AND (`id` IN (4)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(9036, 0, 4, 0, 0, 0, 100, 0, 5000, 5000, 5000, 5000, 0, 38, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Vilerel - in combat - do zone in combat'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 9038) AND (`source_type` = 0) AND (`id` IN (5)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(9038, 0, 5, 0, 0, 0, 100, 0, 5000, 5000, 5000, 5000, 0, 38, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Seethrel - in combat - do zone in combat'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 9040) AND (`source_type` = 0) AND (`id` IN (5)); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(9040, 0, 5, 0, 0, 0, 100, 0, 5000, 5000, 5000, 5000, 0, 38, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Doperel - in combat - do zone in combat'); + +-- remove the "cannot assist" unit flag +UPDATE `creature_template` SET `unit_flags` = `unit_flags`&~(256) WHERE `entry` IN (9034, 9035, 9036, 9037, 9038, 9039, 9040); + +-- add doomrel text +DELETE FROM `creature_text` WHERE `CreatureID` = 9039; +INSERT INTO `creature_text` (`CreatureID`,`GroupID`,`ID`,`Text`,`Type`,`Language`,`Probability`,`Emote`,`Duration`,`Sound`,`BroadcastTextId`,`TextRange`,`COMMENT`) VALUES +(9039,0,0,'You have challenged the Seven, and now you will die!',12,0,100,0,0,0,4894,0,'start event'); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.h b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.h index a08fbc6a3..b210c08c4 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.h +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.h @@ -55,9 +55,6 @@ enum DataTypes DATA_GO_BAR_DOOR = 18, DATA_GO_CHALICE = 19, - DATA_GHOSTKILL = 20, - DATA_EVENSTARTER = 21, - DATA_GOLEM_DOOR_N = 22, DATA_GOLEM_DOOR_S = 23, diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp index 1ccecf86a..2d0777fcf 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp @@ -37,6 +37,11 @@ enum Misc DATA_SKILLPOINT_MIN = 230 }; +enum Says +{ + SAY_START_FIGHT = 0 +}; + enum Gossip { GOSSIP_TEXT_CONTINUE = 1828, // Continue... @@ -135,7 +140,10 @@ public: // Start encounter InstanceScript* instance = creature->GetInstanceScript(); if (instance) - instance->SetGuidData(DATA_EVENSTARTER, player->GetGUID()); + { + instance->SetData(TYPE_TOMB_OF_SEVEN, IN_PROGRESS); + } + creature->AI()->Talk(SAY_START_FIGHT); break; } return true; @@ -170,16 +178,19 @@ public: Voidwalkers = false; // Reset his gossip menu me->SetFlag(UNIT_FIELD_FLAGS, UNIT_NPC_FLAG_GOSSIP); - me->setFaction(FACTION_FRIEND); // was set before event start, so set again me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - if (instance->GetData(DATA_GHOSTKILL) >= 7) + if (instance->GetData(TYPE_TOMB_OF_SEVEN) == DONE) // what is this trying to do? Probably some kind of crash recovery + { me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); + } else + { me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } } void EnterCombat(Unit* /*who*/) override @@ -200,12 +211,6 @@ public: if (me->IsAlive()) me->GetMotionMaster()->MoveTargetedHome(); me->SetLootRecipient(nullptr); - instance->SetGuidData(DATA_EVENSTARTER, ObjectGuid::Empty); - } - - void JustDied(Unit* /*killer*/) override - { - instance->SetData(DATA_GHOSTKILL, 1); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp index 992337031..a20e30728 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp @@ -16,12 +16,18 @@ */ #include "blackrock_depths.h" +#include "Player.h" #include "InstanceScript.h" #include "ScriptMgr.h" -#define TIMER_TOMBOFTHESEVEN 30000 -#define TIMER_TOMB_START 5000 -#define MAX_ENCOUNTER 6 +#define MAX_ENCOUNTER 6 + +enum Timers +{ + TIMER_TOMBOFTHESEVEN = 30000, + TIMER_TOMB_START = 1000, + TIMER_TOMB_RESET = 15000 +}; enum Creatures { @@ -148,7 +154,7 @@ public: uint32 BarAleCount; uint32 GhostKillCount; ObjectGuid TombBossGUIDs[7]; - ObjectGuid TombEventStarterGUID; + uint32 tombResetTimer; uint32 TombTimer; uint32 TombEventCounter; uint32 OpenedCoofers; @@ -165,6 +171,7 @@ public: TombTimer = TIMER_TOMB_START; TombEventCounter = 0; OpenedCoofers = 0; + tombResetTimer = 0; } void OnCreatureCreate(Creature* creature) override @@ -310,21 +317,20 @@ public: case NPC_WRATH_HAMMER_CONSTRUCT: ArgelmachAdds.remove(unit->GetGUID()); break; - default: + case NPC_ANGERREL: + case NPC_DOPEREL: + case NPC_HATEREL: + case NPC_VILEREL: + case NPC_SEETHREL: + case NPC_GLOOMREL: + case NPC_DOOMREL: + GhostKillCount++; + if (GhostKillCount >= 7) + { + SetData(TYPE_TOMB_OF_SEVEN, DONE); + } break; - } - } - - void SetGuidData(uint32 type, ObjectGuid data) override - { - switch (type) - { - case DATA_EVENSTARTER: - TombEventStarterGUID = data; - if (!TombEventStarterGUID) - TombOfSevenReset();//reset - else - TombOfSevenStart();//start + default: break; } } @@ -349,6 +355,18 @@ public: break; case TYPE_TOMB_OF_SEVEN: encounter[3] = data; + switch (data) + { + case IN_PROGRESS: + HandleGameObject(GoTombExitGUID, false); + HandleGameObject(GoTombEnterGUID, false); + break; + case DONE: + DoRespawnGameObject(GoChestGUID, DAY); + HandleGameObject(GoTombExitGUID, true); + HandleGameObject(GoTombEnterGUID, true); + break; + } break; case TYPE_LYCEUM: encounter[4] = data; @@ -356,9 +374,6 @@ public: case TYPE_IRON_HALL: encounter[5] = data; break; - case DATA_GHOSTKILL: - GhostKillCount += data; - break; case DATA_OPEN_COFFER_DOORS: OpenedCoofers += 1; if (OpenedCoofers == 12) @@ -477,8 +492,6 @@ public: return encounter[4]; case TYPE_IRON_HALL: return encounter[5]; - case DATA_GHOSTKILL: - return GhostKillCount; } return 0; } @@ -509,8 +522,6 @@ public: return GoBarKegTrapGUID; case DATA_GO_BAR_DOOR: return GoBarDoorGUID; - case DATA_EVENSTARTER: - return TombEventStarterGUID; case DATA_SF_BRAZIER_N: return GoSFNGUID; case DATA_SF_BRAZIER_S: @@ -568,18 +579,26 @@ public: { if (Creature* boss = instance->GetCreature(TombBossGUIDs[TombEventCounter])) { + ++TombEventCounter; boss->setFaction(FACTION_HOSTILE); boss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - if (Unit* target = boss->SelectNearestTarget(500)) + + // find suitable target here. + Player* target = boss->SelectNearestPlayer(130); + if (target && boss->CanCreatureAttack(target, true)) + { boss->AI()->AttackStart(target); + boss->AI()->DoZoneInCombat(); + tombResetTimer = TIMER_TOMB_RESET; + } } } } void TombOfSevenReset() { - HandleGameObject(GoTombExitGUID, false);//event reseted, close exit door - HandleGameObject(GoTombEnterGUID, true);//event reseted, open entrance door + HandleGameObject(GoTombExitGUID, false);// close exit door + HandleGameObject(GoTombEnterGUID, true);// open entrance door for (uint8 i = 0; i < 7; ++i) { if (Creature* boss = instance->GetCreature(TombBossGUIDs[i])) @@ -596,54 +615,63 @@ public: boss->SetLootRecipient(nullptr); } boss->setFaction(FACTION_FRIEND); + boss->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); // think this is useless + if (i == 6) // doomrel needs explicit reset + { + boss->AI()->Reset(); + } } } + GhostKillCount = 0; TombEventCounter = 0; TombTimer = TIMER_TOMB_START; SetData(TYPE_TOMB_OF_SEVEN, NOT_STARTED); } - void TombOfSevenStart() + bool CheckTombReset(uint32 diff) { - HandleGameObject(GoTombExitGUID, false);//event started, close exit door - HandleGameObject(GoTombEnterGUID, false);//event started, close entrance door - SetData(TYPE_TOMB_OF_SEVEN, IN_PROGRESS); + bool anyBossAlive = false; // status of the bosses up until the current one + for (uint8 i = 0; i < TombEventCounter; i++) + { + Creature* boss = instance->GetCreature(TombBossGUIDs[i]); + if (boss) + { + anyBossAlive |= boss->IsAlive(); + if (boss->IsAlive() && boss->IsInCombat()) + { + tombResetTimer = TIMER_TOMB_RESET; + return false; // any boss in combat means we shouldn't reset. + } + } + } + if (!anyBossAlive) // no boss alive, put reset timer back up + { + tombResetTimer = TIMER_TOMB_RESET; + } + tombResetTimer -= diff; + return tombResetTimer < diff; } - void TombOfSevenEnd() - { - DoRespawnGameObject(GoChestGUID, DAY); - HandleGameObject(GoTombExitGUID, true);//event done, open exit door - HandleGameObject(GoTombEnterGUID, true);//event done, open entrance door - TombEventStarterGUID.Clear(); - SetData(TYPE_TOMB_OF_SEVEN, DONE); - } void Update(uint32 diff) override { - if (TombEventStarterGUID && GhostKillCount < 7) + if ((GetData(TYPE_TOMB_OF_SEVEN) == IN_PROGRESS) && GhostKillCount < 7) { if (TombTimer <= diff) { TombTimer = TIMER_TOMBOFTHESEVEN; TombOfSevenEvent(); - ++TombEventCounter; - // Check Killed bosses - for (uint8 i = 0; i < 7; ++i) - { - if (Creature* boss = instance->GetCreature(TombBossGUIDs[i])) - { - if (!boss->IsAlive()) - { - GhostKillCount = i + 1; - } - } - } } - else TombTimer -= diff; + else + { + TombTimer -= diff; + } + + if (CheckTombReset(diff)) + { + TombOfSevenReset(); + } } - if (GhostKillCount >= 7 && TombEventStarterGUID) - TombOfSevenEnd(); } }; };