refactor(Scripts/AhnKahet): Move Ancient Nerubian Device script to SAI (#17734)
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
--
|
||||||
|
UPDATE `gameobject_template` SET `AIName` = 'SmartGameObjectAI', `ScriptName` = '' WHERE `entry` IN (193093, 193094);
|
||||||
|
|
||||||
|
DELETE FROM `smart_scripts` WHERE (`entryorguid` = 193093) AND (`source_type` = 1) AND (`id` IN (0));
|
||||||
|
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`, `event_param6`, `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
|
||||||
|
(193093, 1, 0, 0, 64, 0, 100, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Ancient Nerubian Device (193093) - On Gossip Hello - Set Instance Data 6 0');
|
||||||
|
|
||||||
|
DELETE FROM `smart_scripts` WHERE (`entryorguid` = 193094) AND (`source_type` = 1) AND (`id` IN (0));
|
||||||
|
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`, `event_param6`, `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
|
||||||
|
(193094, 1, 0, 0, 64, 0, 100, 0, 0, 0, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Ancient Nerubian Device (193094) - On Gossip Hello - Set Instance Data 7 0');
|
||||||
@@ -33,8 +33,6 @@ enum AhnkahetData
|
|||||||
// Other data
|
// Other data
|
||||||
// Teldram encounter related
|
// Teldram encounter related
|
||||||
DATA_PRINCE_TALDARAM_PLATFORM,
|
DATA_PRINCE_TALDARAM_PLATFORM,
|
||||||
DATA_TELDRAM_SPHERE1,
|
|
||||||
DATA_TELDRAM_SPHERE2,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AhnKahetCreatures
|
enum AhnKahetCreatures
|
||||||
@@ -66,6 +64,18 @@ enum AhnKahetActions
|
|||||||
ACTION_REMOVE_PRISON = -1
|
ACTION_REMOVE_PRISON = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum AhnKahetTexts
|
||||||
|
{
|
||||||
|
SAY_SPHERE_ACTIVATED = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
enum AhnKahetPersistentData
|
||||||
|
{
|
||||||
|
DATA_TELDRAM_SPHERE1,
|
||||||
|
DATA_TELDRAM_SPHERE2,
|
||||||
|
MAX_PERSISTENT_DATA
|
||||||
|
};
|
||||||
|
|
||||||
template <class AI, class T>
|
template <class AI, class T>
|
||||||
inline AI* GetAhnKahetAI(T* obj)
|
inline AI* GetAhnKahetAI(T* obj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ enum Event
|
|||||||
|
|
||||||
enum Yells
|
enum Yells
|
||||||
{
|
{
|
||||||
SAY_SPHERE_ACTIVATED = 0,
|
//SAY_SPHERE_ACTIVATED = 0,
|
||||||
SAY_REMOVE_PRISON = 1,
|
SAY_REMOVE_PRISON = 1,
|
||||||
SAY_AGGRO = 2,
|
SAY_AGGRO = 2,
|
||||||
SAY_SLAY = 3,
|
SAY_SLAY = 3,
|
||||||
@@ -212,7 +212,7 @@ struct boss_taldaram : public BossAI
|
|||||||
BossAI::InitializeAI();
|
BossAI::InitializeAI();
|
||||||
|
|
||||||
// Event not started
|
// Event not started
|
||||||
if (instance->GetData(DATA_TELDRAM_SPHERE1) != DONE || instance->GetData(DATA_TELDRAM_SPHERE2) != DONE)
|
if (instance->GetPersistentData(DATA_TELDRAM_SPHERE1) != DONE || instance->GetPersistentData(DATA_TELDRAM_SPHERE2) != DONE)
|
||||||
{
|
{
|
||||||
me->SetImmuneToAll(true);
|
me->SetImmuneToAll(true);
|
||||||
me->SetDisableGravity(true);
|
me->SetDisableGravity(true);
|
||||||
@@ -226,7 +226,7 @@ struct boss_taldaram : public BossAI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance->GetData(DATA_TELDRAM_SPHERE1) == DONE && instance->GetData(DATA_TELDRAM_SPHERE2) == DONE)
|
if (instance->GetPersistentData(DATA_TELDRAM_SPHERE1) == DONE && instance->GetPersistentData(DATA_TELDRAM_SPHERE2) == DONE)
|
||||||
{
|
{
|
||||||
DoAction(ACTION_REMOVE_PRISON_AT_RESET);
|
DoAction(ACTION_REMOVE_PRISON_AT_RESET);
|
||||||
}
|
}
|
||||||
@@ -490,44 +490,6 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @todo: Turn into new script type when Gossips have been updated
|
|
||||||
class go_prince_taldaram_sphere : public GameObjectScript
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
go_prince_taldaram_sphere() : GameObjectScript("go_prince_taldaram_sphere") {}
|
|
||||||
|
|
||||||
bool OnGossipHello(Player* pPlayer, GameObject* go) override
|
|
||||||
{
|
|
||||||
if (pPlayer && pPlayer->IsInCombat())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
InstanceScript* pInstance = go->GetInstanceScript();
|
|
||||||
if (!pInstance)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
go->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
|
|
||||||
go->SetGoState(GO_STATE_ACTIVE);
|
|
||||||
|
|
||||||
uint32 const objectIndex = go->GetEntry() == GO_TELDARAM_SPHERE1 ? DATA_TELDRAM_SPHERE1 : DATA_TELDRAM_SPHERE2;
|
|
||||||
if (pInstance->GetData(objectIndex) == NOT_STARTED)
|
|
||||||
{
|
|
||||||
Creature* taldaram = ObjectAccessor::GetCreature(*go, pInstance->GetGuidData(DATA_PRINCE_TALDARAM));
|
|
||||||
if (taldaram && taldaram->IsAlive())
|
|
||||||
{
|
|
||||||
taldaram->AI()->Talk(SAY_SPHERE_ACTIVATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
pInstance->SetData(objectIndex, DONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 55931 - Conjure Flame Sphere
|
// 55931 - Conjure Flame Sphere
|
||||||
class spell_prince_taldaram_conjure_flame_sphere : public SpellScript
|
class spell_prince_taldaram_conjure_flame_sphere : public SpellScript
|
||||||
{
|
{
|
||||||
@@ -581,7 +543,6 @@ void AddSC_boss_taldaram()
|
|||||||
{
|
{
|
||||||
RegisterAhnKahetCreatureAI(npc_taldaram_flamesphere);
|
RegisterAhnKahetCreatureAI(npc_taldaram_flamesphere);
|
||||||
RegisterAhnKahetCreatureAI(boss_taldaram);
|
RegisterAhnKahetCreatureAI(boss_taldaram);
|
||||||
new go_prince_taldaram_sphere();
|
|
||||||
|
|
||||||
// Spells
|
// Spells
|
||||||
RegisterSpellScript(spell_prince_taldaram_conjure_flame_sphere);
|
RegisterSpellScript(spell_prince_taldaram_conjure_flame_sphere);
|
||||||
|
|||||||
@@ -20,7 +20,18 @@
|
|||||||
#include "ScriptedCreature.h"
|
#include "ScriptedCreature.h"
|
||||||
#include "SpellScript.h"
|
#include "SpellScript.h"
|
||||||
#include "ahnkahet.h"
|
#include "ahnkahet.h"
|
||||||
#include <array>
|
|
||||||
|
ObjectData const creatureData[] =
|
||||||
|
{
|
||||||
|
{ NPC_PRINCE_TALDARAM, DATA_PRINCE_TALDARAM },
|
||||||
|
{ 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
DoorData const doorData[] =
|
||||||
|
{
|
||||||
|
{ GO_TELDARAM_DOOR, DATA_PRINCE_TALDARAM, DOOR_TYPE_PASSAGE },
|
||||||
|
{ 0, 0, DOOR_TYPE_ROOM }
|
||||||
|
};
|
||||||
|
|
||||||
class instance_ahnkahet : public InstanceMapScript
|
class instance_ahnkahet : public InstanceMapScript
|
||||||
{
|
{
|
||||||
@@ -29,180 +40,78 @@ public:
|
|||||||
|
|
||||||
struct instance_ahnkahet_InstanceScript : public InstanceScript
|
struct instance_ahnkahet_InstanceScript : public InstanceScript
|
||||||
{
|
{
|
||||||
instance_ahnkahet_InstanceScript(Map* pMap) : InstanceScript(pMap), canSaveBossStates(false)
|
instance_ahnkahet_InstanceScript(Map* pMap) : InstanceScript(pMap)
|
||||||
{
|
{
|
||||||
SetHeaders(DataHeader);
|
SetHeaders(DataHeader);
|
||||||
SetBossNumber(MAX_ENCOUNTER);
|
SetBossNumber(MAX_ENCOUNTER);
|
||||||
teldaramSpheres.fill(NOT_STARTED);
|
SetPersistentDataCount(MAX_PERSISTENT_DATA);
|
||||||
|
LoadObjectData(creatureData, nullptr);
|
||||||
|
LoadDoorData(doorData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCreatureCreate(Creature* pCreature) override
|
void OnGameObjectCreate(GameObject* go) override
|
||||||
{
|
{
|
||||||
switch (pCreature->GetEntry())
|
switch (go->GetEntry())
|
||||||
{
|
|
||||||
case NPC_ELDER_NADOX:
|
|
||||||
elderNadox_GUID = pCreature->GetGUID();
|
|
||||||
break;
|
|
||||||
case NPC_PRINCE_TALDARAM:
|
|
||||||
princeTaldaram_GUID = pCreature->GetGUID();
|
|
||||||
break;
|
|
||||||
case NPC_JEDOGA_SHADOWSEEKER:
|
|
||||||
jedogaShadowseeker_GUID = pCreature->GetGUID();
|
|
||||||
break;
|
|
||||||
case NPC_HERALD_JOLAZJ:
|
|
||||||
heraldVolazj_GUID = pCreature->GetGUID();
|
|
||||||
break;
|
|
||||||
case NPC_AMANITAR:
|
|
||||||
amanitar_GUID = pCreature->GetGUID();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnGameObjectCreate(GameObject* pGo) override
|
|
||||||
{
|
|
||||||
switch (pGo->GetEntry())
|
|
||||||
{
|
{
|
||||||
case GO_TELDARAM_PLATFORM:
|
case GO_TELDARAM_PLATFORM:
|
||||||
{
|
{
|
||||||
taldaramPlatform_GUID = pGo->GetGUID();
|
taldaramPlatform_GUID = go->GetGUID();
|
||||||
if (IsAllSpheresActivated() || GetBossState(DATA_PRINCE_TALDARAM) == DONE)
|
HandleGameObject(ObjectGuid::Empty, IsAllSpheresActivated(), go);
|
||||||
{
|
|
||||||
HandleGameObject(ObjectGuid::Empty, true, pGo);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GO_TELDARAM_SPHERE1:
|
case GO_TELDARAM_SPHERE1:
|
||||||
case GO_TELDARAM_SPHERE2:
|
case GO_TELDARAM_SPHERE2:
|
||||||
{
|
{
|
||||||
if (teldaramSpheres.at(pGo->GetEntry() == GO_TELDARAM_SPHERE1 ? 0 : 1) == DONE || GetBossState(DATA_PRINCE_TALDARAM) == DONE)
|
if (GetPersistentData(go->GetEntry() == GO_TELDARAM_SPHERE1 ? 0 : 1) == DONE || GetBossState(DATA_PRINCE_TALDARAM) == DONE)
|
||||||
{
|
{
|
||||||
pGo->SetGoState(GO_STATE_ACTIVE);
|
go->SetGoState(GO_STATE_ACTIVE);
|
||||||
pGo->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
|
go->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pGo->RemoveGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
|
go->RemoveGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GO_TELDARAM_DOOR:
|
|
||||||
{
|
|
||||||
taldaramGate_GUID = pGo->GetGUID(); // Web gate past Prince Taldaram
|
|
||||||
if (GetBossState(DATA_PRINCE_TALDARAM) == DONE)
|
|
||||||
{
|
|
||||||
HandleGameObject(ObjectGuid::Empty, true, pGo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InstanceScript::OnGameObjectCreate(go);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetBossState(uint32 type, EncounterState state) override
|
void SetData(uint32 type, uint32 /*data*/) override
|
||||||
{
|
{
|
||||||
if (!InstanceScript::SetBossState(type, state))
|
uint8 index = type == DATA_TELDRAM_SPHERE1 ? 0 : 1;
|
||||||
|
|
||||||
|
if ((type == DATA_TELDRAM_SPHERE1 || type == DATA_TELDRAM_SPHERE2) && GetPersistentData(index) != DONE)
|
||||||
{
|
{
|
||||||
return false;
|
StorePersistentData(index, DONE);
|
||||||
}
|
|
||||||
|
|
||||||
if (type == DATA_PRINCE_TALDARAM && state == DONE)
|
|
||||||
{
|
|
||||||
HandleGameObject(taldaramGate_GUID, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canSaveBossStates)
|
|
||||||
{
|
|
||||||
SaveToDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetData(uint32 type, uint32 data) override
|
|
||||||
{
|
|
||||||
if (type == DATA_TELDRAM_SPHERE1 || type == DATA_TELDRAM_SPHERE2)
|
|
||||||
{
|
|
||||||
|
|
||||||
teldaramSpheres[type == DATA_TELDRAM_SPHERE1 ? 0 : 1] = data;
|
|
||||||
SaveToDB();
|
SaveToDB();
|
||||||
|
|
||||||
if (IsAllSpheresActivated())
|
if (Creature* taldaram = GetCreature(DATA_PRINCE_TALDARAM))
|
||||||
{
|
{
|
||||||
HandleGameObject(taldaramPlatform_GUID, true, nullptr);
|
if (taldaram->IsAlive())
|
||||||
|
|
||||||
Creature* teldaram = instance->GetCreature(princeTaldaram_GUID);
|
|
||||||
if (teldaram && teldaram->IsAlive())
|
|
||||||
{
|
{
|
||||||
teldaram->AI()->DoAction(ACTION_REMOVE_PRISON);
|
taldaram->AI()->Talk(SAY_SPHERE_ACTIVATED);
|
||||||
|
|
||||||
|
if (IsAllSpheresActivated())
|
||||||
|
{
|
||||||
|
HandleGameObject(taldaramPlatform_GUID, true, nullptr);
|
||||||
|
taldaram->AI()->DoAction(ACTION_REMOVE_PRISON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 GetData(uint32 type) const override
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DATA_TELDRAM_SPHERE1:
|
|
||||||
return teldaramSpheres.at(0);
|
|
||||||
case DATA_TELDRAM_SPHERE2:
|
|
||||||
return teldaramSpheres.at(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectGuid GetGuidData(uint32 type) const override
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DATA_ELDER_NADOX:
|
|
||||||
return elderNadox_GUID;
|
|
||||||
case DATA_PRINCE_TALDARAM:
|
|
||||||
return princeTaldaram_GUID;
|
|
||||||
case DATA_JEDOGA_SHADOWSEEKER:
|
|
||||||
return jedogaShadowseeker_GUID;
|
|
||||||
case DATA_HERALD_VOLAZJ:
|
|
||||||
return heraldVolazj_GUID;
|
|
||||||
case DATA_AMANITAR:
|
|
||||||
return amanitar_GUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ObjectGuid::Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReadSaveDataMore(std::istringstream& data) override
|
|
||||||
{
|
|
||||||
data >> teldaramSpheres[0];
|
|
||||||
data >> teldaramSpheres[1];
|
|
||||||
|
|
||||||
canSaveBossStates = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WriteSaveDataMore(std::ostringstream& data) override
|
|
||||||
{
|
|
||||||
data << teldaramSpheres[0] << ' '
|
|
||||||
<< teldaramSpheres[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ObjectGuid elderNadox_GUID;
|
|
||||||
ObjectGuid princeTaldaram_GUID;
|
|
||||||
ObjectGuid jedogaShadowseeker_GUID;
|
|
||||||
ObjectGuid heraldVolazj_GUID;
|
|
||||||
ObjectGuid amanitar_GUID;
|
|
||||||
|
|
||||||
// Teldaram related
|
// Teldaram related
|
||||||
ObjectGuid taldaramPlatform_GUID;
|
ObjectGuid taldaramPlatform_GUID;
|
||||||
ObjectGuid taldaramGate_GUID;
|
|
||||||
std::array<uint32, 2> teldaramSpheres; // Used to identify activation status for sphere activation
|
|
||||||
bool canSaveBossStates; // Indicates that it is safe to trigger SaveToDB call in SetBossState
|
|
||||||
|
|
||||||
bool IsAllSpheresActivated() const
|
bool IsAllSpheresActivated() const
|
||||||
{
|
{
|
||||||
return teldaramSpheres.at(0) == DONE && teldaramSpheres.at(1) == DONE;
|
return GetBossState(DATA_PRINCE_TALDARAM) == DONE ||
|
||||||
|
(GetPersistentData(DATA_TELDRAM_SPHERE1) == DONE && GetPersistentData(DATA_TELDRAM_SPHERE2) == DONE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user