Questions about object/player phasing


i try to understand the phasing system from Trinity but i have a few problems. For testing i change the phase mask from my test object to 2 and add me this aura It works and i can see only the phase 2 objects/players/creatures. Now i want to use more phases. My first question: How many phases are exist?

My idea: I have objects in many phases. If a player join the object area then he get the permission to see all objects which have for example the phase mask 2. Annother player get the permission to see all phase 6 objects etc.

My problem: How i can give the player this permission?

There are 31 unique phases. (this comes from the powers of 2 that fit in uint32)

That includes the phase 1, which is the default phase.

Since phase is a bitmask, 6 is actually 4 + 2 = 6, so phases 4 and 2 can see the stuff in phase 6 and the phase 6 can see stuff in 4 and 2 phases.

Phases 4 and 2 cant see each other.

It is possible to script your own phasing system alongside the existing one.

Try seeing how phasing is handled (hint: CanNeverSee())

You can also change the existing phase system to be non masked. So it will have 4294967295 unique phases.

This will break the GM phase very likely and some quests etc. that use phasing obviously. (phasing that requires the masking).

All changes to the system will need core edits.

Mhm so there is no easy way like “player->SetPhase(5)” to change the player phase?

My c++ skills are not so good for the “create a phasing system alongside the existing one” option.

Of course there is /emoticons/default_smile.png

void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)

The problem is that like I mentioned, there are only 31 unique phases.

So 5 would be 4+1. so everyone (normally) would see the player in phase 5 ( everyone in phase 1 and 4 )

Ah i understand… so its better to create a own phase system with a higher number of phases and without the bitmask function.

or remove the bitmask functionality from it. (as mentioned earlier)

I think it is easier to change the existing phase system. What do you mean with this sentence?

This will break the GM phase very likely

That quest wont be work is not a problem.

When you are in GM mode (.gm on) you are in a phase that sees ALL other phases.

Since phases are a mask, so 1+2 = 3, having all unique phases summed together gives you a phase where you see everything.

In GM mode you use that phase. It is 2^32-1.


If you change the phasing system not to be masked, this can not be achieved,

unless you code a special right for a GM to always see everything in GM mode or something.

Ah. Use the .gm visible off command the phase system?


Sorry i hate my english skills. The command .gm visible. Use this command the phase system too? If i modify the existed phase system will be the visible command broken?

The .gm visible commands will likely not be broken.

Not that I checked, but they dont likely use phasing since phasing doesnt make it possible to make it so that you see a player while he doesnt see you.

Do you have a hint for me, where i can start to change the phase system?

Well, I already gave one.

Here is another:


bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask); }

Okay i understand how the two functions work but i dont find the point where i can change the bitmask to “normal” number.

CanNeverSee check the map and call the function InSamePhase. InSamePhase get the phasemask from the object and check it. All phasemask variables are uint32… where is defined that this variables are bitmasks?

Nowhere.They are just used as such.

& operator will check the bits. (its a bitwise operator)

3 = 1+2

3 & 2 = 2 (true), since 3 contains 2. Otherwise it is 0.

You need to change it to check for exact phase number match.

Ah so i must only change

bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask); }

    bool InSamePhase(uint32 phasemask) const
        if(GetPhaseMask() == phasemask)
            return true;
        } else {
            return false;



Yeah it works… so now i must define that a gamemaster can see all phases if he use .gm on. Do you have a idea where i can check this condition?

There might be other places you also need to change the phase thing.

Might …

I did that edit once 1.5 years ago and havent searched now about where and what.

For the GM phase you could add a check in the InSamePhase to return true if the phase is PHASEMASK_ANYWHERE

or possibly if player:IsGameMaster() is true.

Mhm i dont know where the other place be. This solution works with creatures, player, objects, etc.

Player:IsGameMaster() is not possible, because the function do not know what “player” is. What do you mean with “if the phase is PHASEMASK_ANYWHERE”?

You could try converting the worldobject to player etc.
Anyways, the simpler solution is the PHASEMASK_ANYWHERE check.

When a player uses .gm on, his phase is set to PHASEMASK_ANYWHERE. This is 2^32-1. (max uint32 number)

Now. You could just check if either of the phases is PHASEMASK_ANYWHERE, if so, return true.

This of course assumes no player etc can ever achieve PHASEMASK_ANYWHERE.

For example phase 0 is never used anywhere.

So if you would set the GM phase to 0, you could then check if the either phase is 0 and if so, return true, since the other phase is a GM’s phase, which should always see everything.