Skip to content

Commit

Permalink
Scripts/Ulduar: Fix some Flame Leviathan issues
Browse files Browse the repository at this point in the history
Fix some Flame Leviathan issues:
- Fix boss evading all the time due to bad Doors check
- Opened "Lightning Door" to other bosses only after boss dies
- Eject players from the vehicles when boss dies, make them untargetable and despawn them after 5 minutes (adjust the time to the blizzlike time of choice)
  • Loading branch information
jackpoz committed Mar 21, 2015
1 parent 922be41 commit d888e4c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/server/game/Instances/InstanceScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ void InstanceScript::UpdateDoorState(GameObject* door)
door->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY);
}

BossInfo* InstanceScript::GetBossInfo(uint32 id)
{
ASSERT(id < bosses.size());
return &bosses[id];
}

void InstanceScript::AddObject(Creature* obj, bool add)
{
ObjectInfoMap::const_iterator j = _creatureInfo.find(obj->GetEntry());
Expand Down
8 changes: 6 additions & 2 deletions src/server/game/Instances/InstanceScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,16 @@ class InstanceScript : public ZoneScript
void AddObject(GameObject* obj, bool add);
void AddObject(WorldObject* obj, uint32 type, bool add);

void AddDoor(GameObject* door, bool add);
virtual void AddDoor(GameObject* door, bool add);
void AddMinion(Creature* minion, bool add);

void UpdateDoorState(GameObject* door);
virtual void UpdateDoorState(GameObject* door);
void UpdateMinionState(Creature* minion, EncounterState state);

// Exposes private data that should never be modified unless exceptional cases.
// Pay very much attention at how the returned BossInfo data is modified to avoid issues.
BossInfo* GetBossInfo(uint32 id);

// Instance Load and Save
bool ReadSaveDataHeaders(std::istringstream& data);
void ReadSaveDataBossStates(std::istringstream& data);
Expand Down
53 changes: 53 additions & 0 deletions src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "InstanceScript.h"
#include "Vehicle.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
Expand Down Expand Up @@ -91,6 +92,7 @@ class instance_ulduar : public InstanceMapScript

// Creatures
ObjectGuid LeviathanGUID;
GuidVector LeviathanVehicleGUIDs;
ObjectGuid IgnisGUID;
ObjectGuid RazorscaleGUID;
ObjectGuid RazorscaleController;
Expand Down Expand Up @@ -217,6 +219,11 @@ class instance_ulduar : public InstanceMapScript
case NPC_LEVIATHAN:
LeviathanGUID = creature->GetGUID();
break;
case NPC_SALVAGED_DEMOLISHER:
case NPC_SALVAGED_SIEGE_ENGINE:
case NPC_SALVAGED_CHOPPER:
LeviathanVehicleGUIDs.push_back(creature->GetGUID());
break;
case NPC_IGNIS:
IgnisGUID = creature->GetGUID();
break;
Expand Down Expand Up @@ -682,6 +689,24 @@ class instance_ulduar : public InstanceMapScript
switch (type)
{
case BOSS_LEVIATHAN:
if (state == DONE)
{
// Eject all players from vehicles and make them untargetable.
// They will be despawned after a while
for (auto const& vehicleGuid : LeviathanVehicleGUIDs)
{
if (Creature* vehicleCreature = instance->GetCreature(vehicleGuid))
{
if (Vehicle* vehicle = vehicleCreature->GetVehicleKit())
{
vehicle->RemoveAllPassengers();
vehicleCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
vehicleCreature->DespawnOrUnsummon(5 * MINUTE * IN_MILLISECONDS);
}
}
}
}
break;
case BOSS_IGNIS:
case BOSS_RAZORSCALE:
case BOSS_XT002:
Expand Down Expand Up @@ -1143,6 +1168,34 @@ class instance_ulduar : public InstanceMapScript
}
}

void UpdateDoorState(GameObject* door) override
{
// Leviathan doors are set to DOOR_TYPE_ROOM except the one it uses to enter the room
// which has to be set to DOOR_TYPE_PASSAGE
if (door->GetEntry() == GO_LEVIATHAN_DOOR && door->GetPositionX() > 400.f)
door->SetGoState(GetBossState(BOSS_LEVIATHAN) == DONE ? GO_STATE_ACTIVE : GO_STATE_READY);
else
InstanceScript::UpdateDoorState(door);
}

void AddDoor(GameObject* door, bool add) override
{
// Leviathan doors are South except the one it uses to enter the room
// which is North and should not be used for boundary checks in BossAI::CheckBoundary()
if (door->GetEntry() == GO_LEVIATHAN_DOOR && door->GetPositionX() > 400.f)
{
if (add)
GetBossInfo(BOSS_LEVIATHAN)->door[DOOR_TYPE_PASSAGE].insert(door->GetGUID());
else
GetBossInfo(BOSS_LEVIATHAN)->door[DOOR_TYPE_PASSAGE].erase(door->GetGUID());

if (add)
UpdateDoorState(door);
}
else
InstanceScript::AddDoor(door, add);
}

private:
EventMap _events;
uint32 _algalonTimer;
Expand Down
1 change: 1 addition & 0 deletions src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum UlduarNPCs
NPC_LEVIATHAN = 33113,
NPC_SALVAGED_DEMOLISHER = 33109,
NPC_SALVAGED_SIEGE_ENGINE = 33060,
NPC_SALVAGED_CHOPPER = 33062,
NPC_IGNIS = 33118,
NPC_RAZORSCALE = 33186,
NPC_RAZORSCALE_CONTROLLER = 33233,
Expand Down

0 comments on commit d888e4c

Please sign in to comment.