Merge pull request #10933 from MitchesD/SteamVault

Scripts/SteamVault: reworked InstanceScript
This commit is contained in:
joschiwald
2013-09-25 07:13:35 -07:00
5 changed files with 202 additions and 221 deletions
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* 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
@@ -16,18 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Boss_Hydromancer_Thespia
SD%Complete: 80
SDComment: Needs additional adjustments (when instance script is adjusted)
SDCategory: Coilfang Resevoir, The Steamvault
EndScriptData */
/* ContentData
boss_hydromancer_thespia
npc_coilfang_waterelemental
EndContentData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "steam_vault.h"
@@ -77,7 +64,7 @@ public:
EnvelopingWinds_Timer = 9000;
if (instance)
instance->SetData(TYPE_HYDROMANCER_THESPIA, NOT_STARTED);
instance->SetBossState(DATA_HYDROMANCER_THESPIA, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
@@ -85,7 +72,7 @@ public:
Talk(SAY_DEAD);
if (instance)
instance->SetData(TYPE_HYDROMANCER_THESPIA, DONE);
instance->SetBossState(DATA_HYDROMANCER_THESPIA, DONE);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -98,7 +85,7 @@ public:
Talk(SAY_AGGRO);
if (instance)
instance->SetData(TYPE_HYDROMANCER_THESPIA, IN_PROGRESS);
instance->SetBossState(DATA_HYDROMANCER_THESPIA, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* 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
@@ -23,11 +22,6 @@ SDComment: Mechanics' interrrupt heal doesn't work very well, also a proper move
SDCategory: Coilfang Resevoir, The Steamvault
EndScriptData */
/* ContentData
boss_mekgineer_steamrigger
npc_steamrigger_mechanic
EndContentData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "steam_vault.h"
@@ -53,7 +47,7 @@ enum Spells
enum Creatures
{
NPC_STREAMRIGGER_MECHANIC = 17951
NPC_STREAMRIGGER_MECHANIC = 17951
};
class boss_mekgineer_steamrigger : public CreatureScript
@@ -93,7 +87,7 @@ public:
Summon25 = false;
if (instance)
instance->SetData(TYPE_MEKGINEER_STEAMRIGGER, NOT_STARTED);
instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
@@ -101,7 +95,7 @@ public:
Talk(SAY_DEATH);
if (instance)
instance->SetData(TYPE_MEKGINEER_STEAMRIGGER, DONE);
instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, DONE);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -114,7 +108,7 @@ public:
Talk(SAY_AGGRO);
if (instance)
instance->SetData(TYPE_MEKGINEER_STEAMRIGGER, IN_PROGRESS);
instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, IN_PROGRESS);
}
//no known summon spells exist
@@ -223,7 +217,6 @@ public:
}
void MoveInLineOfSight(Unit* /*who*/) OVERRIDE
{
//react only if attacked
}
@@ -234,9 +227,9 @@ public:
{
if (Repair_Timer <= diff)
{
if (instance && instance->GetData64(DATA_MEKGINEERSTEAMRIGGER) && instance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == IN_PROGRESS)
if (instance && instance->GetBossState(DATA_MEKGINEER_STEAMRIGGER) == IN_PROGRESS)
{
if (Unit* pMekgineer = Unit::GetUnit(*me, instance->GetData64(DATA_MEKGINEERSTEAMRIGGER)))
if (Unit* pMekgineer = Unit::GetUnit(*me, instance->GetData64(DATA_MEKGINEER_STEAMRIGGER)))
{
if (me->IsWithinDistInMap(pMekgineer, MAX_REPAIR_RANGE))
{
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* 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
@@ -71,7 +70,7 @@ public:
//hack, due to really weird spell behaviour :(
if (instance)
{
if (instance->GetData(TYPE_DISTILLER) == IN_PROGRESS)
if (instance->GetData(DATA_DISTILLER) == IN_PROGRESS)
{
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -89,14 +88,14 @@ public:
DoCast(me, SPELL_WARLORDS_RAGE_NAGA, true);
if (instance)
instance->SetData(TYPE_DISTILLER, IN_PROGRESS);
instance->SetData(DATA_DISTILLER, IN_PROGRESS);
}
void DamageTaken(Unit* /*done_by*/, uint32 &damage) OVERRIDE
{
if (me->GetHealth() <= damage)
if (instance)
instance->SetData(TYPE_DISTILLER, DONE);
instance->SetData(DATA_DISTILLER, DONE);
}
};
@@ -134,7 +133,7 @@ public:
CanRage = false;
if (instance)
instance->SetData(TYPE_WARLORD_KALITHRESH, NOT_STARTED);
instance->SetBossState(DATA_WARLORD_KALITHRESH, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -142,7 +141,7 @@ public:
Talk(SAY_AGGRO);
if (instance)
instance->SetData(TYPE_WARLORD_KALITHRESH, IN_PROGRESS);
instance->SetBossState(DATA_WARLORD_KALITHRESH, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -155,7 +154,7 @@ public:
//hack :(
if (spell->Id == SPELL_WARLORDS_RAGE_PROC)
if (instance)
if (instance->GetData(TYPE_DISTILLER) == DONE)
if (instance->GetData(DATA_DISTILLER) == DONE)
me->RemoveAurasDueToSpell(SPELL_WARLORDS_RAGE_PROC);
}
@@ -164,7 +163,7 @@ public:
Talk(SAY_DEATH);
if (instance)
instance->SetData(TYPE_WARLORD_KALITHRESH, DONE);
instance->SetBossState(DATA_WARLORD_KALITHRESH, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -202,7 +201,6 @@ public:
DoMeleeAttackIfReady();
}
};
};
void AddSC_boss_warlord_kalithresh()
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* 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
@@ -16,23 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Instance_Steam_Vault
SD%Complete: 80
SDComment: Instance script and access panel GO
SDCategory: Coilfang Resevoir, The Steamvault
EndScriptData */
#include "ScriptMgr.h"
#include "InstanceScript.h"
#include "steam_vault.h"
#define MAX_ENCOUNTER 4
#define MAIN_CHAMBERS_DOOR 183049
#define ACCESS_PANEL_HYDRO 184125
#define ACCESS_PANEL_MEK 184126
/* Steam Vaults encounters:
1 - Hydromancer Thespia Event
2 - Mekgineer Steamrigger Event
@@ -41,190 +27,189 @@ EndScriptData */
class go_main_chambers_access_panel : public GameObjectScript
{
public:
go_main_chambers_access_panel() : GameObjectScript("go_main_chambers_access_panel") { }
public:
go_main_chambers_access_panel() : GameObjectScript("go_main_chambers_access_panel") { }
bool OnGossipHello(Player* /*player*/, GameObject* go)
{
InstanceScript* instance = go->GetInstanceScript();
bool OnGossipHello(Player* /*player*/, GameObject* go)
{
InstanceScript* instance = go->GetInstanceScript();
if (!instance)
return false;
if (!instance)
return false;
if (go->GetEntry() == ACCESS_PANEL_HYDRO && (instance->GetData(TYPE_HYDROMANCER_THESPIA) == DONE || instance->GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL))
instance->SetData(TYPE_HYDROMANCER_THESPIA, SPECIAL);
if (go->GetEntry() == GO_ACCESS_PANEL_HYDRO && (instance->GetBossState(DATA_HYDROMANCER_THESPIA) == DONE || instance->GetBossState(DATA_HYDROMANCER_THESPIA) == SPECIAL))
{
instance->SetBossState(DATA_HYDROMANCER_THESPIA, SPECIAL);
go->SetGoState(GO_STATE_ACTIVE);
}
if (go->GetEntry() == ACCESS_PANEL_MEK && (instance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == DONE || instance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL))
instance->SetData(TYPE_MEKGINEER_STEAMRIGGER, SPECIAL);
return true;
}
if (go->GetEntry() == GO_ACCESS_PANEL_MEK && (instance->GetBossState(DATA_MEKGINEER_STEAMRIGGER) == DONE || instance->GetBossState(DATA_MEKGINEER_STEAMRIGGER) == SPECIAL))
{
instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, SPECIAL);
go->SetGoState(GO_STATE_ACTIVE);
}
return true;
}
};
class instance_steam_vault : public InstanceMapScript
{
public:
instance_steam_vault() : InstanceMapScript("instance_steam_vault", 545) { }
public:
instance_steam_vault() : InstanceMapScript(SteamVaultScriptName, 545) { }
InstanceScript* GetInstanceScript(InstanceMap* map) const
{
return new instance_steam_vault_InstanceMapScript(map);
}
struct instance_steam_vault_InstanceMapScript : public InstanceScript
{
instance_steam_vault_InstanceMapScript(Map* map) : InstanceScript(map) {}
uint32 m_auiEncounter[MAX_ENCOUNTER];
uint64 ThespiaGUID;
uint64 MekgineerGUID;
uint64 KalithreshGUID;
uint64 MainChambersDoor;
uint64 AccessPanelHydro;
uint64 AccessPanelMek;
void Initialize() OVERRIDE
struct instance_steam_vault_InstanceMapScript : public InstanceScript
{
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
ThespiaGUID = 0;
MekgineerGUID = 0;
KalithreshGUID = 0;
MainChambersDoor = 0;
AccessPanelHydro = 0;
AccessPanelMek = 0;
}
bool IsEncounterInProgress() const OVERRIDE
{
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
if (m_auiEncounter[i] == IN_PROGRESS)
return true;
return false;
}
void OnCreatureCreate(Creature* creature) OVERRIDE
{
switch (creature->GetEntry())
instance_steam_vault_InstanceMapScript(Map* map) : InstanceScript(map)
{
case 17797: ThespiaGUID = creature->GetGUID(); break;
case 17796: MekgineerGUID = creature->GetGUID(); break;
case 17798: KalithreshGUID = creature->GetGUID(); break;
}
}
SetBossNumber(EncounterCount);
void OnGameObjectCreate(GameObject* go) OVERRIDE
{
switch (go->GetEntry())
{
case MAIN_CHAMBERS_DOOR: MainChambersDoor = go->GetGUID(); break;
case ACCESS_PANEL_HYDRO: AccessPanelHydro = go->GetGUID(); break;
case ACCESS_PANEL_MEK: AccessPanelMek = go->GetGUID(); break;
}
}
ThespiaGUID = 0;
MekgineerGUID = 0;
KalithreshGUID = 0;
void SetData(uint32 type, uint32 data) OVERRIDE
{
switch (type)
{
case TYPE_HYDROMANCER_THESPIA:
if (data == SPECIAL)
{
HandleGameObject(AccessPanelHydro, true);
if (GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL)
HandleGameObject(MainChambersDoor, true);
TC_LOG_DEBUG(LOG_FILTER_TSCR, "Instance Steamvault: Access panel used.");
}
m_auiEncounter[0] = data;
break;
case TYPE_MEKGINEER_STEAMRIGGER:
if (data == SPECIAL)
{
HandleGameObject(AccessPanelMek, true);
if (GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL)
HandleGameObject(MainChambersDoor, true);
TC_LOG_DEBUG(LOG_FILTER_TSCR, "Instance Steamvault: Access panel used.");
}
m_auiEncounter[1] = data;
break;
case TYPE_WARLORD_KALITHRESH:
m_auiEncounter[2] = data;
break;
case TYPE_DISTILLER:
m_auiEncounter[3] = data;
break;
MainChambersDoorGUID = 0;
DistillerState = 0;
}
if (data == DONE || data == SPECIAL)
SaveToDB();
}
uint32 GetData(uint32 type) const OVERRIDE
{
switch (type)
void OnCreatureCreate(Creature* creature) OVERRIDE
{
case TYPE_HYDROMANCER_THESPIA:
return m_auiEncounter[0];
case TYPE_MEKGINEER_STEAMRIGGER:
return m_auiEncounter[1];
case TYPE_WARLORD_KALITHRESH:
return m_auiEncounter[2];
case TYPE_DISTILLER:
return m_auiEncounter[3];
switch (creature->GetEntry())
{
case NPC_HYDROMANCER_THESPIA:
ThespiaGUID = creature->GetGUID();
break;
case NPC_MEKGINEER_STEAMRIGGER:
MekgineerGUID = creature->GetGUID();
break;
case NPC_WARLORD_KALITHRESH:
KalithreshGUID = creature->GetGUID();
break;
default:
break;
}
}
return 0;
}
uint64 GetData64(uint32 data) const OVERRIDE
{
switch (data)
void OnGameObjectCreate(GameObject* go) OVERRIDE
{
case DATA_THESPIA:
return ThespiaGUID;
case DATA_MEKGINEERSTEAMRIGGER:
return MekgineerGUID;
case DATA_KALITRESH:
return KalithreshGUID;
switch (go->GetEntry())
{
case GO_MAIN_CHAMBERS_DOOR:
MainChambersDoorGUID = go->GetGUID();
break;
default:
break;
}
}
return 0;
}
std::string GetSaveData() OVERRIDE
{
OUT_SAVE_INST_DATA;
std::ostringstream stream;
stream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3];
OUT_SAVE_INST_DATA_COMPLETE;
return stream.str();
}
void Load(const char* in) OVERRIDE
{
if (!in)
uint64 GetData64(uint32 type) const OVERRIDE
{
OUT_LOAD_INST_DATA_FAIL;
return;
switch (type)
{
case DATA_HYDROMANCER_THESPIA:
return ThespiaGUID;
case DATA_MEKGINEER_STEAMRIGGER:
return MekgineerGUID;
case DATA_WARLORD_KALITHRESH:
return KalithreshGUID;
default:
break;
}
return 0;
}
OUT_LOAD_INST_DATA(in);
std::istringstream stream(in);
stream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
if (m_auiEncounter[i] == IN_PROGRESS)
m_auiEncounter[i] = NOT_STARTED;
OUT_LOAD_INST_DATA_COMPLETE;
}
};
void SetData(uint32 type, uint32 data) OVERRIDE
{
if (type == DATA_DISTILLER)
DistillerState = data;
}
uint32 GetData(uint32 type) const OVERRIDE
{
if (type == DATA_DISTILLER)
return DistillerState;
return 0;
}
bool SetBossState(uint32 type, EncounterState state) OVERRIDE
{
if (!InstanceScript::SetBossState(type, state))
return false;
switch (type)
{
case DATA_HYDROMANCER_THESPIA:
if (state == SPECIAL)
{
if (GetBossState(DATA_MEKGINEER_STEAMRIGGER) == SPECIAL)
HandleGameObject(MainChambersDoorGUID, true);
TC_LOG_DEBUG(LOG_FILTER_TSCR, "Instance Steamvault: Access panel used.");
}
break;
case DATA_MEKGINEER_STEAMRIGGER:
if (state == SPECIAL)
{
if (GetBossState(DATA_HYDROMANCER_THESPIA) == SPECIAL)
HandleGameObject(MainChambersDoorGUID, true);
TC_LOG_DEBUG(LOG_FILTER_TSCR, "Instance Steamvault: Access panel used.");
}
break;
default:
break;
}
return true;
}
std::string GetSaveData() OVERRIDE
{
OUT_SAVE_INST_DATA;
std::ostringstream saveStream;
saveStream << GetBossSaveData();
OUT_SAVE_INST_DATA_COMPLETE;
return saveStream.str();
}
void Load(char const* str) OVERRIDE
{
if (!str)
{
OUT_LOAD_INST_DATA_FAIL;
return;
}
OUT_LOAD_INST_DATA(str);
std::istringstream loadStream(str);
for (uint32 i = 0; i < EncounterCount; ++i)
{
uint32 tmpState;
loadStream >> tmpState;
if (tmpState == IN_PROGRESS || tmpState > SPECIAL)
tmpState = NOT_STARTED;
SetBossState(i, EncounterState(tmpState));
}
OUT_LOAD_INST_DATA_COMPLETE;
}
protected:
uint64 ThespiaGUID;
uint64 MekgineerGUID;
uint64 KalithreshGUID;
uint64 MainChambersDoorGUID;
uint8 DistillerState;
};
InstanceScript* GetInstanceScript(InstanceMap* map) const
{
return new instance_steam_vault_InstanceMapScript(map);
}
};
void AddSC_instance_steam_vault()
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* 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
@@ -19,17 +18,36 @@
#ifndef DEF_STEAM_VAULT_H
#define DEF_STEAM_VAULT_H
#define SteamVaultScriptName "instance_steam_vault"
uint32 const EncounterCount = 3;
enum DataTypes
{
TYPE_HYDROMANCER_THESPIA = 1,
TYPE_MEKGINEER_STEAMRIGGER = 2,
TYPE_WARLORD_KALITHRESH = 3,
TYPE_DISTILLER = 4,
DATA_MEKGINEERSTEAMRIGGER = 5,
DATA_KALITRESH = 6,
DATA_THESPIA = 7
DATA_HYDROMANCER_THESPIA = 0,
DATA_MEKGINEER_STEAMRIGGER = 1,
DATA_WARLORD_KALITHRESH = 2,
DATA_DISTILLER = 3
};
#endif
enum CreatureIds
{
NPC_HYDROMANCER_THESPIA = 17797,
NPC_MEKGINEER_STEAMRIGGER = 17796,
NPC_WARLORD_KALITHRESH = 17798
};
enum GameObjectIds
{
GO_MAIN_CHAMBERS_DOOR = 183049,
GO_ACCESS_PANEL_HYDRO = 184125,
GO_ACCESS_PANEL_MEK = 184126
};
template<class AI>
AI* GetSteamVaultAI(Creature* creature)
{
return GetInstanceAI<AI>(creature, SteamVaultScriptName);
}
#endif