fix(Core/Script): Tomb of 7 in brd (#7991)

This commit is contained in:
patou01
2021-10-21 21:38:48 +02:00
committed by GitHub
parent 8c20978449
commit 6798b907b9
4 changed files with 128 additions and 68 deletions
@@ -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');
@@ -55,9 +55,6 @@ enum DataTypes
DATA_GO_BAR_DOOR = 18, DATA_GO_BAR_DOOR = 18,
DATA_GO_CHALICE = 19, DATA_GO_CHALICE = 19,
DATA_GHOSTKILL = 20,
DATA_EVENSTARTER = 21,
DATA_GOLEM_DOOR_N = 22, DATA_GOLEM_DOOR_N = 22,
DATA_GOLEM_DOOR_S = 23, DATA_GOLEM_DOOR_S = 23,
@@ -37,6 +37,11 @@ enum Misc
DATA_SKILLPOINT_MIN = 230 DATA_SKILLPOINT_MIN = 230
}; };
enum Says
{
SAY_START_FIGHT = 0
};
enum Gossip enum Gossip
{ {
GOSSIP_TEXT_CONTINUE = 1828, // Continue... GOSSIP_TEXT_CONTINUE = 1828, // Continue...
@@ -135,7 +140,10 @@ public:
// Start encounter // Start encounter
InstanceScript* instance = creature->GetInstanceScript(); InstanceScript* instance = creature->GetInstanceScript();
if (instance) if (instance)
instance->SetGuidData(DATA_EVENSTARTER, player->GetGUID()); {
instance->SetData(TYPE_TOMB_OF_SEVEN, IN_PROGRESS);
}
creature->AI()->Talk(SAY_START_FIGHT);
break; break;
} }
return true; return true;
@@ -170,16 +178,19 @@ public:
Voidwalkers = false; Voidwalkers = false;
// Reset his gossip menu // Reset his gossip menu
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_NPC_FLAG_GOSSIP); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_NPC_FLAG_GOSSIP);
me->setFaction(FACTION_FRIEND); me->setFaction(FACTION_FRIEND);
// was set before event start, so set again // was set before event start, so set again
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); 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); me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
}
else else
{
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
}
} }
void EnterCombat(Unit* /*who*/) override void EnterCombat(Unit* /*who*/) override
@@ -200,12 +211,6 @@ public:
if (me->IsAlive()) if (me->IsAlive())
me->GetMotionMaster()->MoveTargetedHome(); me->GetMotionMaster()->MoveTargetedHome();
me->SetLootRecipient(nullptr); me->SetLootRecipient(nullptr);
instance->SetGuidData(DATA_EVENSTARTER, ObjectGuid::Empty);
}
void JustDied(Unit* /*killer*/) override
{
instance->SetData(DATA_GHOSTKILL, 1);
} }
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
@@ -16,12 +16,18 @@
*/ */
#include "blackrock_depths.h" #include "blackrock_depths.h"
#include "Player.h"
#include "InstanceScript.h" #include "InstanceScript.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#define TIMER_TOMBOFTHESEVEN 30000 #define MAX_ENCOUNTER 6
#define TIMER_TOMB_START 5000
#define MAX_ENCOUNTER 6 enum Timers
{
TIMER_TOMBOFTHESEVEN = 30000,
TIMER_TOMB_START = 1000,
TIMER_TOMB_RESET = 15000
};
enum Creatures enum Creatures
{ {
@@ -148,7 +154,7 @@ public:
uint32 BarAleCount; uint32 BarAleCount;
uint32 GhostKillCount; uint32 GhostKillCount;
ObjectGuid TombBossGUIDs[7]; ObjectGuid TombBossGUIDs[7];
ObjectGuid TombEventStarterGUID; uint32 tombResetTimer;
uint32 TombTimer; uint32 TombTimer;
uint32 TombEventCounter; uint32 TombEventCounter;
uint32 OpenedCoofers; uint32 OpenedCoofers;
@@ -165,6 +171,7 @@ public:
TombTimer = TIMER_TOMB_START; TombTimer = TIMER_TOMB_START;
TombEventCounter = 0; TombEventCounter = 0;
OpenedCoofers = 0; OpenedCoofers = 0;
tombResetTimer = 0;
} }
void OnCreatureCreate(Creature* creature) override void OnCreatureCreate(Creature* creature) override
@@ -310,21 +317,20 @@ public:
case NPC_WRATH_HAMMER_CONSTRUCT: case NPC_WRATH_HAMMER_CONSTRUCT:
ArgelmachAdds.remove(unit->GetGUID()); ArgelmachAdds.remove(unit->GetGUID());
break; 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; break;
} default:
}
void SetGuidData(uint32 type, ObjectGuid data) override
{
switch (type)
{
case DATA_EVENSTARTER:
TombEventStarterGUID = data;
if (!TombEventStarterGUID)
TombOfSevenReset();//reset
else
TombOfSevenStart();//start
break; break;
} }
} }
@@ -349,6 +355,18 @@ public:
break; break;
case TYPE_TOMB_OF_SEVEN: case TYPE_TOMB_OF_SEVEN:
encounter[3] = data; 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; break;
case TYPE_LYCEUM: case TYPE_LYCEUM:
encounter[4] = data; encounter[4] = data;
@@ -356,9 +374,6 @@ public:
case TYPE_IRON_HALL: case TYPE_IRON_HALL:
encounter[5] = data; encounter[5] = data;
break; break;
case DATA_GHOSTKILL:
GhostKillCount += data;
break;
case DATA_OPEN_COFFER_DOORS: case DATA_OPEN_COFFER_DOORS:
OpenedCoofers += 1; OpenedCoofers += 1;
if (OpenedCoofers == 12) if (OpenedCoofers == 12)
@@ -477,8 +492,6 @@ public:
return encounter[4]; return encounter[4];
case TYPE_IRON_HALL: case TYPE_IRON_HALL:
return encounter[5]; return encounter[5];
case DATA_GHOSTKILL:
return GhostKillCount;
} }
return 0; return 0;
} }
@@ -509,8 +522,6 @@ public:
return GoBarKegTrapGUID; return GoBarKegTrapGUID;
case DATA_GO_BAR_DOOR: case DATA_GO_BAR_DOOR:
return GoBarDoorGUID; return GoBarDoorGUID;
case DATA_EVENSTARTER:
return TombEventStarterGUID;
case DATA_SF_BRAZIER_N: case DATA_SF_BRAZIER_N:
return GoSFNGUID; return GoSFNGUID;
case DATA_SF_BRAZIER_S: case DATA_SF_BRAZIER_S:
@@ -568,18 +579,26 @@ public:
{ {
if (Creature* boss = instance->GetCreature(TombBossGUIDs[TombEventCounter])) if (Creature* boss = instance->GetCreature(TombBossGUIDs[TombEventCounter]))
{ {
++TombEventCounter;
boss->setFaction(FACTION_HOSTILE); boss->setFaction(FACTION_HOSTILE);
boss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); 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()->AttackStart(target);
boss->AI()->DoZoneInCombat();
tombResetTimer = TIMER_TOMB_RESET;
}
} }
} }
} }
void TombOfSevenReset() void TombOfSevenReset()
{ {
HandleGameObject(GoTombExitGUID, false);//event reseted, close exit door HandleGameObject(GoTombExitGUID, false);// close exit door
HandleGameObject(GoTombEnterGUID, true);//event reseted, open entrance door HandleGameObject(GoTombEnterGUID, true);// open entrance door
for (uint8 i = 0; i < 7; ++i) for (uint8 i = 0; i < 7; ++i)
{ {
if (Creature* boss = instance->GetCreature(TombBossGUIDs[i])) if (Creature* boss = instance->GetCreature(TombBossGUIDs[i]))
@@ -596,54 +615,63 @@ public:
boss->SetLootRecipient(nullptr); boss->SetLootRecipient(nullptr);
} }
boss->setFaction(FACTION_FRIEND); 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; GhostKillCount = 0;
TombEventCounter = 0; TombEventCounter = 0;
TombTimer = TIMER_TOMB_START; TombTimer = TIMER_TOMB_START;
SetData(TYPE_TOMB_OF_SEVEN, NOT_STARTED); SetData(TYPE_TOMB_OF_SEVEN, NOT_STARTED);
} }
void TombOfSevenStart() bool CheckTombReset(uint32 diff)
{ {
HandleGameObject(GoTombExitGUID, false);//event started, close exit door bool anyBossAlive = false; // status of the bosses up until the current one
HandleGameObject(GoTombEnterGUID, false);//event started, close entrance door for (uint8 i = 0; i < TombEventCounter; i++)
SetData(TYPE_TOMB_OF_SEVEN, IN_PROGRESS); {
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 void Update(uint32 diff) override
{ {
if (TombEventStarterGUID && GhostKillCount < 7) if ((GetData(TYPE_TOMB_OF_SEVEN) == IN_PROGRESS) && GhostKillCount < 7)
{ {
if (TombTimer <= diff) if (TombTimer <= diff)
{ {
TombTimer = TIMER_TOMBOFTHESEVEN; TombTimer = TIMER_TOMBOFTHESEVEN;
TombOfSevenEvent(); 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();
} }
}; };
}; };