feat(Core/Scripting): implement OnlyOnceAreaTrigger & Zul'Gurub's in… (#8850)
Co-authored-by: Treeston <treeston.mmoc@gmail.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1635649346761519900');
|
||||||
|
|
||||||
|
DELETE FROM `areatrigger_scripts` WHERE `entry` = 3957;
|
||||||
|
INSERT INTO `areatrigger_scripts` (`entry`, `ScriptName`) VALUES
|
||||||
|
(3957, 'at_zulgurub_entrance_speech');
|
||||||
|
|
||||||
|
UPDATE `creature_text` SET `TextRange` = 3 WHERE `CreatureID` = 14834 AND `GroupID` = 3 AND `ID` = 0;
|
||||||
@@ -1101,7 +1101,7 @@ void WorldObject::RemoveFromWorld()
|
|||||||
Object::RemoveFromWorld();
|
Object::RemoveFromWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceScript* WorldObject::GetInstanceScript()
|
InstanceScript* WorldObject::GetInstanceScript() const
|
||||||
{
|
{
|
||||||
Map* map = GetMap();
|
Map* map = GetMap();
|
||||||
return map->IsDungeon() ? map->ToInstanceMap()->GetInstanceScript() : nullptr;
|
return map->IsDungeon() ? map->ToInstanceMap()->GetInstanceScript() : nullptr;
|
||||||
|
|||||||
@@ -853,7 +853,7 @@ public:
|
|||||||
[[nodiscard]] bool IsOutdoors() const;
|
[[nodiscard]] bool IsOutdoors() const;
|
||||||
LiquidData const& GetLiquidData() const;
|
LiquidData const& GetLiquidData() const;
|
||||||
|
|
||||||
InstanceScript* GetInstanceScript();
|
InstanceScript* GetInstanceScript() const;
|
||||||
|
|
||||||
[[nodiscard]] std::string const& GetName() const { return m_name; }
|
[[nodiscard]] std::string const& GetName() const { return m_name; }
|
||||||
void SetName(std::string const& newname) { m_name = newname; }
|
void SetName(std::string const& newname) { m_name = newname; }
|
||||||
|
|||||||
@@ -242,6 +242,11 @@ public:
|
|||||||
|
|
||||||
uint32 GetEncounterCount() const { return bosses.size(); }
|
uint32 GetEncounterCount() const { return bosses.size(); }
|
||||||
|
|
||||||
|
// Only used by areatriggers that inherit from OnlyOnceAreaTriggerScript
|
||||||
|
void MarkAreaTriggerDone(uint32 id) { _activatedAreaTriggers.insert(id); }
|
||||||
|
void ResetAreaTriggerDone(uint32 id) { _activatedAreaTriggers.erase(id); }
|
||||||
|
bool IsAreaTriggerDone(uint32 id) const { return _activatedAreaTriggers.find(id) != _activatedAreaTriggers.end(); }
|
||||||
|
|
||||||
// Allows to perform particular actions
|
// Allows to perform particular actions
|
||||||
virtual void DoAction(int32 /*action*/) {}
|
virtual void DoAction(int32 /*action*/) {}
|
||||||
protected:
|
protected:
|
||||||
@@ -272,6 +277,7 @@ private:
|
|||||||
ObjectInfoMap _gameObjectInfo;
|
ObjectInfoMap _gameObjectInfo;
|
||||||
ObjectGuidMap _objectGuids;
|
ObjectGuidMap _objectGuids;
|
||||||
uint32 completedEncounters; // completed encounter mask, bit indexes are DungeonEncounter.dbc boss numbers, used for packets
|
uint32 completedEncounters; // completed encounter mask, bit indexes are DungeonEncounter.dbc boss numbers, used for packets
|
||||||
|
std::unordered_set<uint32> _activatedAreaTriggers;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "DatabaseEnv.h"
|
#include "DatabaseEnv.h"
|
||||||
#include "DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "GossipDef.h"
|
#include "GossipDef.h"
|
||||||
|
#include "InstanceScript.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "OutdoorPvPMgr.h"
|
#include "OutdoorPvPMgr.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
@@ -3239,6 +3240,36 @@ AreaTriggerScript::AreaTriggerScript(const char* name)
|
|||||||
ScriptRegistry<AreaTriggerScript>::AddScript(this);
|
ScriptRegistry<AreaTriggerScript>::AddScript(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OnlyOnceAreaTriggerScript::OnTrigger(Player* player, AreaTrigger const* trigger)
|
||||||
|
{
|
||||||
|
uint32 const triggerId = trigger->entry;
|
||||||
|
if (InstanceScript* instance = player->GetInstanceScript())
|
||||||
|
{
|
||||||
|
if (instance->IsAreaTriggerDone(triggerId))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instance->MarkAreaTriggerDone(triggerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _OnTrigger(player, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlyOnceAreaTriggerScript::ResetAreaTriggerDone(InstanceScript* script, uint32 triggerId)
|
||||||
|
{
|
||||||
|
script->ResetAreaTriggerDone(triggerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlyOnceAreaTriggerScript::ResetAreaTriggerDone(Player const* player, AreaTrigger const* trigger)
|
||||||
|
{
|
||||||
|
if (InstanceScript* instance = player->GetInstanceScript())
|
||||||
|
{
|
||||||
|
ResetAreaTriggerDone(instance, trigger->entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BattlegroundScript::BattlegroundScript(const char* name)
|
BattlegroundScript::BattlegroundScript(const char* name)
|
||||||
: ScriptObject(name)
|
: ScriptObject(name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -552,6 +552,19 @@ public:
|
|||||||
[[nodiscard]] virtual bool OnTrigger(Player* /*player*/, AreaTrigger const* /*trigger*/) { return false; }
|
[[nodiscard]] virtual bool OnTrigger(Player* /*player*/, AreaTrigger const* /*trigger*/) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OnlyOnceAreaTriggerScript : public AreaTriggerScript
|
||||||
|
{
|
||||||
|
using AreaTriggerScript::AreaTriggerScript;
|
||||||
|
|
||||||
|
public:
|
||||||
|
[[nodiscard]] bool OnTrigger(Player* /*player*/, AreaTrigger const* /*trigger*/) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool _OnTrigger(Player* /*player*/, AreaTrigger const* /*trigger*/) = 0;
|
||||||
|
void ResetAreaTriggerDone(InstanceScript* /*instance*/, uint32 /*triggerId*/);
|
||||||
|
void ResetAreaTriggerDone(Player const* /*player*/, AreaTrigger const* /*trigger*/);
|
||||||
|
};
|
||||||
|
|
||||||
class BattlegroundScript : public ScriptObject
|
class BattlegroundScript : public ScriptObject
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Category: Zul'Gurub
|
|||||||
|
|
||||||
#include "ScriptedCreature.h"
|
#include "ScriptedCreature.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
|
#include "Player.h"
|
||||||
#include "zulgurub.h"
|
#include "zulgurub.h"
|
||||||
|
|
||||||
enum Says
|
enum Says
|
||||||
@@ -175,7 +176,35 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class at_zulgurub_entrance_speech : public OnlyOnceAreaTriggerScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
at_zulgurub_entrance_speech() : OnlyOnceAreaTriggerScript("at_zulgurub_entrance_speech") {}
|
||||||
|
|
||||||
|
bool _OnTrigger(Player* player, const AreaTrigger* /*at*/) override
|
||||||
|
{
|
||||||
|
if (InstanceScript* instance = player->GetInstanceScript())
|
||||||
|
{
|
||||||
|
// Instance map's enormous, Hakkar's GRID is not loaded by the time players enter.
|
||||||
|
// Without this, the creature never says anything, because it doesn't load in time.
|
||||||
|
player->GetMap()->LoadGrid(-11783.99f, -1655.27f);
|
||||||
|
|
||||||
|
if (Creature* hakkar = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_HAKKAR)))
|
||||||
|
{
|
||||||
|
hakkar->setActive(true);
|
||||||
|
if (hakkar->GetAI())
|
||||||
|
{
|
||||||
|
hakkar->AI()->Talk(SAY_PROTECT_ALTAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void AddSC_boss_hakkar()
|
void AddSC_boss_hakkar()
|
||||||
{
|
{
|
||||||
new boss_hakkar();
|
new boss_hakkar();
|
||||||
|
new at_zulgurub_entrance_speech();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ public:
|
|||||||
case NPC_ARLOKK:
|
case NPC_ARLOKK:
|
||||||
_arlokkGUID = creature->GetGUID();
|
_arlokkGUID = creature->GetGUID();
|
||||||
break;
|
break;
|
||||||
|
case NPC_HAKKAR:
|
||||||
|
_hakkarGUID = creature->GetGUID();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +126,8 @@ public:
|
|||||||
return _arlokkGUID;
|
return _arlokkGUID;
|
||||||
case GO_GONG_OF_BETHEKK:
|
case GO_GONG_OF_BETHEKK:
|
||||||
return _goGongOfBethekkGUID;
|
return _goGongOfBethekkGUID;
|
||||||
|
case DATA_HAKKAR:
|
||||||
|
return _hakkarGUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ObjectGuid::Empty;
|
return ObjectGuid::Empty;
|
||||||
@@ -181,6 +186,7 @@ public:
|
|||||||
ObjectGuid _vilebranchSpeakerGUID;
|
ObjectGuid _vilebranchSpeakerGUID;
|
||||||
ObjectGuid _arlokkGUID;
|
ObjectGuid _arlokkGUID;
|
||||||
ObjectGuid _goGongOfBethekkGUID;
|
ObjectGuid _goGongOfBethekkGUID;
|
||||||
|
ObjectGuid _hakkarGUID;
|
||||||
};
|
};
|
||||||
|
|
||||||
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ enum CreatureIds
|
|||||||
NPC_MANDOKIR = 11382, // Mandokir Event
|
NPC_MANDOKIR = 11382, // Mandokir Event
|
||||||
NPC_OHGAN = 14988, // Mandokir Event
|
NPC_OHGAN = 14988, // Mandokir Event
|
||||||
NPC_VILEBRANCH_SPEAKER = 11391, // Mandokir Event
|
NPC_VILEBRANCH_SPEAKER = 11391, // Mandokir Event
|
||||||
NPC_CHAINED_SPIRT = 15117 // Mandokir Event
|
NPC_CHAINED_SPIRT = 15117, // Mandokir Event
|
||||||
|
NPC_HAKKAR = 14834
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GameobjectIds
|
enum GameobjectIds
|
||||||
|
|||||||
Reference in New Issue
Block a user