You can be in multiple phases at once. Thats how GM phase works also (you can see all phases and all phases see you)
30 = 2 + 4 + 8 + 16
The script needs to be made for what you need the phase for.
Do all players on the map need to be in phase 30?
Or just after teleporting? Is it a specific area?
?
This small script sets your phase to 30 (+ any other phases you might have had except phase 1)
When you enter map 1.
It also removes phase 30 and adds phase 1 back when you leave.
#include “ScriptPCH.h”
class PhaseOnMap : public WorldMapScript
{
public:
PhaseOnMap() : WorldMapScript(“PhaseOnMap”, 1) // The mapID
{
}
void OnPlayerEnter(Map* map, Player* player)
{
player->SetPhaseMask(player->GetPhaseMask() & ~1 | 30, true);
}
void OnPlayerLeave(Map* map, Player* player)
{
player->SetPhaseMask(player->GetPhaseMask() & ~30 | 1, true);
}
};
void AddSC_PhaseOnMap()
{
new PhaseOnMap();
}
This patch would only phase when you teleport:
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index c5c97e7…8c6aa28 100644
— a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -7791,8 +7791,8 @@ void ObjectMgr::LoadGameTele()
_gameTeleStore.clear(); // for reload case
- // 0 1 2 3 4 5 6
- QueryResult result = WorldDatabase.Query(“SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele”);
-
// 0 1 2 3 4 5 6 7
-
QueryResult result = WorldDatabase.Query(“SELECT id, position_x, position_y, position_z, orientation, map, name, phase FROM game_tele”);
if (!result)
{
@@ -7816,6 +7816,7 @@ void ObjectMgr::LoadGameTele()
gt.orientation = fields[4].GetFloat();
gt.mapId = fields[5].GetUInt16();
gt.name = fields[6].GetString();
-
gt.phase = fields[7].GetUInt32();
if (!MapManager::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation))
{
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index b1f80af…dfa3284 100644
— a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -133,6 +133,8 @@ typedef UNORDERED_MAP<uint16, InstanceTemplate> InstanceTemplateContainer;
struct GameTele
{
- GameTele() : phase(0) { }
- float position_x;
float position_y;
float position_z;
@@ -140,6 +142,7 @@ struct GameTele
uint32 mapId;
std::string name;
std::wstring wnameLow;
- uint32 phase;
};
typedef UNORDERED_MAP<uint32, GameTele > GameTeleContainer;
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
index f661822…5930bef 100644
— a/src/server/scripts/Commands/cs_tele.cpp
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -191,7 +191,9 @@ public:
// save only in non-flight case
else
target->SaveRecallPosition();
-
-
if (tele->phase)
-
target->SetPhaseMask(tele->phase, true);
target->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
else
@@ -287,7 +289,9 @@ public:
// save only in non-flight case
else
player->SaveRecallPosition();
-
-
if (tele->phase)
-
player->SetPhaseMask(tele->phase, true);
player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
@@ -336,6 +340,8 @@ public:
else
me->SaveRecallPosition();
-
if (tele->phase)
-
me->SetPhaseMask(tele->phase, true);
me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
return true;
}
For that you also need this:
ALTER TABLE `game_tele`
ADD COLUMN `phase` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `map`;