Implemented OnUpdateArea hook

it's more accurate than UpdateZone
This commit is contained in:
Yehonal
2017-11-09 10:41:05 +00:00
parent f669732d19
commit 817257c85b
3 changed files with 18 additions and 4 deletions
+2
View File
@@ -7532,6 +7532,8 @@ void Player::UpdateArea(uint32 newArea)
if (InstanceScript* instance = GetInstanceScript()) if (InstanceScript* instance = GetInstanceScript())
instance->OnPlayerAreaUpdate(this, m_areaUpdateId, newArea); instance->OnPlayerAreaUpdate(this, m_areaUpdateId, newArea);
sScriptMgr->OnPlayerUpdateArea(this, m_areaUpdateId, newArea);
// FFA_PVP flags are area and not zone id dependent // FFA_PVP flags are area and not zone id dependent
// so apply them accordingly // so apply them accordingly
m_areaUpdateId = newArea; m_areaUpdateId = newArea;
+13 -4
View File
@@ -1303,6 +1303,11 @@ void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newAre
FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea); FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
} }
void ScriptMgr::OnPlayerUpdateArea(Player* player, uint32 oldArea, uint32 newArea)
{
FOREACH_SCRIPT(PlayerScript)->OnUpdateArea(player, oldArea, newArea);
}
void ScriptMgr::OnPlayerUpdateFaction(Player* player) void ScriptMgr::OnPlayerUpdateFaction(Player* player)
{ {
FOREACH_SCRIPT(PlayerScript)->OnUpdateFaction(player); FOREACH_SCRIPT(PlayerScript)->OnUpdateFaction(player);
@@ -1494,14 +1499,18 @@ void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<uint32, uint32
FOREACH_SCRIPT(GlobalScript)->OnBeforeUpdateArenaPoints(at,ap); FOREACH_SCRIPT(GlobalScript)->OnBeforeUpdateArenaPoints(at,ap);
} }
void ScriptMgr::OnAfterRefCount(LootStoreItem* LootStoreItem, uint32 &maxcount) void ScriptMgr::OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32 &maxcount)
{ {
FOREACH_SCRIPT(GlobalScript)->OnAfterRefCount(LootStoreItem, maxcount); FOREACH_SCRIPT(GlobalScript)->OnAfterRefCount(player, LootStoreItem, loot, canRate, lootMode, maxcount);
} }
void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, LootStoreItem* LootStoreItem) void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem)
{ {
FOREACH_SCRIPT(GlobalScript)->OnBeforeDropAddItem(player, loot, LootStoreItem); FOREACH_SCRIPT(GlobalScript)->OnBeforeDropAddItem(player, loot, canRate, lootMode, LootStoreItem);
}
void ScriptMgr::OnBeforeItemRoll(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem) {
FOREACH_SCRIPT(GlobalScript)->OnBeforeItemRoll(player, loot, canRate, lootMode, LootStoreItem);
} }
void ScriptMgr::OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData) void ScriptMgr::OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData)
+3
View File
@@ -842,6 +842,9 @@ class PlayerScript : public ScriptObject
// Called when a player switches to a new zone // Called when a player switches to a new zone
virtual void OnUpdateZone(Player* /*player*/, uint32 /*newZone*/, uint32 /*newArea*/) { } virtual void OnUpdateZone(Player* /*player*/, uint32 /*newZone*/, uint32 /*newArea*/) { }
// Called when a player switches to a new area (more accurate than UpdateZone)
virtual void OnUpdateArea(Player* /*player*/, uint32 /*oldArea*/, uint32 /*newArea*/) { }
// Called when a player changes to a new map (after moving to new map) // Called when a player changes to a new map (after moving to new map)
virtual void OnMapChanged(Player* /*player*/) { } virtual void OnMapChanged(Player* /*player*/) { }