mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-03 19:13:49 +00:00
feat(Core/Hook): New GlobalScript hook (#2665)
This allows you to change the behavior of phase system
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "DynamicVisibility.h"
|
#include "DynamicVisibility.h"
|
||||||
|
#include "ScriptMgr.h"
|
||||||
|
|
||||||
#ifdef ELUNA
|
#ifdef ELUNA
|
||||||
#include "LuaEngine.h"
|
#include "LuaEngine.h"
|
||||||
@@ -970,7 +971,7 @@ elunaEvents(NULL),
|
|||||||
#endif
|
#endif
|
||||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isVisibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(NULL),
|
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isVisibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(NULL),
|
||||||
m_transport(NULL), m_currMap(NULL), m_InstanceId(0),
|
m_transport(NULL), m_currMap(NULL), m_InstanceId(0),
|
||||||
m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0), m_executed_notifies(0)
|
m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
||||||
{
|
{
|
||||||
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
|
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
|
||||||
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
|
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
|
||||||
@@ -1056,7 +1057,7 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
|||||||
void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
|
void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
|
||||||
{
|
{
|
||||||
Object::_Create(guidlow, 0, guidhigh);
|
Object::_Create(guidlow, 0, guidhigh);
|
||||||
m_phaseMask = phaseMask;
|
SetPhaseMask(phaseMask, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 WorldObject::GetZoneId(bool /*forceRecalc*/) const
|
uint32 WorldObject::GetZoneId(bool /*forceRecalc*/) const
|
||||||
@@ -2855,7 +2856,8 @@ void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||||
{
|
{
|
||||||
|
sScriptMgr->OnBeforeWorldObjectSetPhaseMask(this, m_phaseMask, newPhaseMask, m_useCombinedPhases, update);
|
||||||
m_phaseMask = newPhaseMask;
|
m_phaseMask = newPhaseMask;
|
||||||
|
|
||||||
if (update && IsInWorld())
|
if (update && IsInWorld())
|
||||||
|
|||||||
@@ -799,7 +799,7 @@ class WorldObject : public Object, public WorldLocation
|
|||||||
virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
|
virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
|
||||||
uint32 GetPhaseMask() const { return m_phaseMask; }
|
uint32 GetPhaseMask() const { return m_phaseMask; }
|
||||||
bool InSamePhase(WorldObject const* obj) const { return InSamePhase(obj->GetPhaseMask()); }
|
bool InSamePhase(WorldObject const* obj) const { return InSamePhase(obj->GetPhaseMask()); }
|
||||||
bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask); }
|
bool InSamePhase(uint32 phasemask) const { return m_useCombinedPhases ? GetPhaseMask() & phasemask : GetPhaseMask() == phasemask; }
|
||||||
|
|
||||||
virtual uint32 GetZoneId(bool forceRecalc = false) const;
|
virtual uint32 GetZoneId(bool forceRecalc = false) const;
|
||||||
virtual uint32 GetAreaId(bool forceRecalc = false) const;
|
virtual uint32 GetAreaId(bool forceRecalc = false) const;
|
||||||
@@ -1047,6 +1047,8 @@ class WorldObject : public Object, public WorldLocation
|
|||||||
//uint32 m_mapId; // object at map with map_id
|
//uint32 m_mapId; // object at map with map_id
|
||||||
uint32 m_InstanceId; // in map copy with instance id
|
uint32 m_InstanceId; // in map copy with instance id
|
||||||
uint32 m_phaseMask; // in area phase state
|
uint32 m_phaseMask; // in area phase state
|
||||||
|
bool m_useCombinedPhases; // true (default): use phaseMask as bit mask combining up to 32 phases
|
||||||
|
// false: use phaseMask to represent single phases only (up to 4294967295 phases)
|
||||||
|
|
||||||
uint16 m_notifyflags;
|
uint16 m_notifyflags;
|
||||||
uint16 m_executed_notifies;
|
uint16 m_executed_notifies;
|
||||||
|
|||||||
@@ -1840,6 +1840,7 @@ void ScriptMgr::OnGroupDisband(Group* group)
|
|||||||
FOREACH_SCRIPT(GroupScript)->OnDisband(group);
|
FOREACH_SCRIPT(GroupScript)->OnDisband(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Global
|
||||||
void ScriptMgr::OnGlobalItemDelFromDB(SQLTransaction& trans, uint32 itemGuid)
|
void ScriptMgr::OnGlobalItemDelFromDB(SQLTransaction& trans, uint32 itemGuid)
|
||||||
{
|
{
|
||||||
ASSERT(trans);
|
ASSERT(trans);
|
||||||
@@ -1887,6 +1888,12 @@ void ScriptMgr::OnAfterUpdateEncounterState(Map* map, EncounterCreditType type,
|
|||||||
FOREACH_SCRIPT(GlobalScript)->OnAfterUpdateEncounterState(map, type, creditEntry, source, difficulty_fixed, encounters, dungeonCompleted, updated);
|
FOREACH_SCRIPT(GlobalScript)->OnAfterUpdateEncounterState(map, type, creditEntry, source, difficulty_fixed, encounters, dungeonCompleted, updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32& oldPhaseMask, uint32& newPhaseMask, bool& useCombinedPhases, bool& update)
|
||||||
|
{
|
||||||
|
FOREACH_SCRIPT(GlobalScript)->OnBeforeWorldObjectSetPhaseMask(worldObject, oldPhaseMask, newPhaseMask, useCombinedPhases, update);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unit
|
||||||
uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit *pVictim, uint32 damage, DamageEffectType damagetype)
|
uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit *pVictim, uint32 damage, DamageEffectType damagetype)
|
||||||
{
|
{
|
||||||
FOR_SCRIPTS_RET(UnitScript, itr, end, damage)
|
FOR_SCRIPTS_RET(UnitScript, itr, end, damage)
|
||||||
|
|||||||
@@ -1103,6 +1103,9 @@ class GlobalScript : public ScriptObject
|
|||||||
|
|
||||||
// Called when a dungeon encounter is updated.
|
// Called when a dungeon encounter is updated.
|
||||||
virtual void OnAfterUpdateEncounterState(Map* /*map*/, EncounterCreditType /*type*/, uint32 /*creditEntry*/, Unit* /*source*/, Difficulty /*difficulty_fixed*/, DungeonEncounterList const* /*encounters*/, uint32 /*dungeonCompleted*/, bool /*updated*/) { }
|
virtual void OnAfterUpdateEncounterState(Map* /*map*/, EncounterCreditType /*type*/, uint32 /*creditEntry*/, Unit* /*source*/, Difficulty /*difficulty_fixed*/, DungeonEncounterList const* /*encounters*/, uint32 /*dungeonCompleted*/, bool /*updated*/) { }
|
||||||
|
|
||||||
|
// Called before the phase for a WorldObject is set
|
||||||
|
virtual void OnBeforeWorldObjectSetPhaseMask(WorldObject const* /*worldObject*/, uint32& /*oldPhaseMask*/, uint32& /*newPhaseMask*/, bool& /*useCombinedPhases*/, bool& /*update*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class BGScript : public ScriptObject
|
class BGScript : public ScriptObject
|
||||||
@@ -1472,7 +1475,7 @@ class ScriptMgr
|
|||||||
void OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData);
|
void OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData);
|
||||||
void OnAfterInitializeLockedDungeons(Player* player);
|
void OnAfterInitializeLockedDungeons(Player* player);
|
||||||
void OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 creditEntry, Unit* source, Difficulty difficulty_fixed, DungeonEncounterList const* encounters, uint32 dungeonCompleted, bool updated);
|
void OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 creditEntry, Unit* source, Difficulty difficulty_fixed, DungeonEncounterList const* encounters, uint32 dungeonCompleted, bool updated);
|
||||||
|
void OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32& oldPhaseMask, uint32& newPhaseMask, bool& useCombinedPhases, bool& update);
|
||||||
|
|
||||||
public: /* Scheduled scripts */
|
public: /* Scheduled scripts */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user