mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
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();
|
||||
}
|
||||
|
||||
InstanceScript* WorldObject::GetInstanceScript()
|
||||
InstanceScript* WorldObject::GetInstanceScript() const
|
||||
{
|
||||
Map* map = GetMap();
|
||||
return map->IsDungeon() ? map->ToInstanceMap()->GetInstanceScript() : nullptr;
|
||||
|
||||
@@ -853,7 +853,7 @@ public:
|
||||
[[nodiscard]] bool IsOutdoors() const;
|
||||
LiquidData const& GetLiquidData() const;
|
||||
|
||||
InstanceScript* GetInstanceScript();
|
||||
InstanceScript* GetInstanceScript() const;
|
||||
|
||||
[[nodiscard]] std::string const& GetName() const { return m_name; }
|
||||
void SetName(std::string const& newname) { m_name = newname; }
|
||||
|
||||
@@ -242,6 +242,11 @@ public:
|
||||
|
||||
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
|
||||
virtual void DoAction(int32 /*action*/) {}
|
||||
protected:
|
||||
@@ -272,6 +277,7 @@ private:
|
||||
ObjectInfoMap _gameObjectInfo;
|
||||
ObjectGuidMap _objectGuids;
|
||||
uint32 completedEncounters; // completed encounter mask, bit indexes are DungeonEncounter.dbc boss numbers, used for packets
|
||||
std::unordered_set<uint32> _activatedAreaTriggers;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "GossipDef.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "OutdoorPvPMgr.h"
|
||||
#include "Player.h"
|
||||
@@ -3239,6 +3240,36 @@ AreaTriggerScript::AreaTriggerScript(const char* name)
|
||||
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)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
|
||||
@@ -552,6 +552,19 @@ public:
|
||||
[[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
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -24,6 +24,7 @@ Category: Zul'Gurub
|
||||
|
||||
#include "ScriptedCreature.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Player.h"
|
||||
#include "zulgurub.h"
|
||||
|
||||
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()
|
||||
{
|
||||
new boss_hakkar();
|
||||
new at_zulgurub_entrance_speech();
|
||||
}
|
||||
|
||||
@@ -73,6 +73,9 @@ public:
|
||||
case NPC_ARLOKK:
|
||||
_arlokkGUID = creature->GetGUID();
|
||||
break;
|
||||
case NPC_HAKKAR:
|
||||
_hakkarGUID = creature->GetGUID();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +126,8 @@ public:
|
||||
return _arlokkGUID;
|
||||
case GO_GONG_OF_BETHEKK:
|
||||
return _goGongOfBethekkGUID;
|
||||
case DATA_HAKKAR:
|
||||
return _hakkarGUID;
|
||||
}
|
||||
|
||||
return ObjectGuid::Empty;
|
||||
@@ -181,6 +186,7 @@ public:
|
||||
ObjectGuid _vilebranchSpeakerGUID;
|
||||
ObjectGuid _arlokkGUID;
|
||||
ObjectGuid _goGongOfBethekkGUID;
|
||||
ObjectGuid _hakkarGUID;
|
||||
};
|
||||
|
||||
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
||||
|
||||
@@ -57,7 +57,8 @@ enum CreatureIds
|
||||
NPC_MANDOKIR = 11382, // Mandokir Event
|
||||
NPC_OHGAN = 14988, // 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
|
||||
|
||||
Reference in New Issue
Block a user