Bit Values SF

From Project Skyfire
Jump to: navigation, search

Back to world database list of tables.


Database Help - Bit Values and Phasing SF

This is a brief explaination of bit values, and how they work. This can be used in any system, such as phasing where bit values can become a bit confusing.


Bit Mask Breakdown Chart

Number Bit Value
1 1
2 2
3 4
4 8
5 16
6 32
7 64
8 128
9 256
10 512
11 1024
12 2048
13 4096
14 8192
15 16384
16 32768
17 65536
18 131072
19 262144
20 524288


What is Phasing?

Often times in the database, you may come across an npc or gameobject spawn which has a phasemask that looks a bit off. Obviously, the default phase mask in the game is phase 1, hence the reason most npc and gob spawns are set to default phasemask 1. However, there are some areas of the game which are "phased".

This means two players can be in the exact same map at the exact same location, but not see each other.

  • How is this possible?
It is possible because each map can have up to 9 total unique phases. (We will explain the unique a bit later) What this means is 
that one player is in one unique phase, and the 2nd player is in a different unique phase.

This means that different npcs and gameobjects can exist in the same map at the same time, but in different phases.


Why do we use Phasing?

  • The use of phasing allows us to create multiple events/atmospheres on the same map without interfering with other phases.
  • This prevents the need to have multiple of the same map to have different things going on at the same time.


How does Phasing work?

This can best be explained by looking at the Gilneas starting area. At the very beginning (after making a worgen), there are npcs standing around, a few barking orders, etc. (This would be phase 1)

After you complete the first quest, and go back to the same area, all the worgens are now in the area fighting the npcs. (This would be phase 2)

After completing the first few quests, you go down the hill outside the market area to your class trainer. NOTE: If you weren't paying attention, the class trainers and other misc npcs were not there until you finished all the quests in the market area, but now they are visible. (This would be phase 4)

Now, if you are following along, you would likely have a few questions at this point

  • Why is it now phase 4 and not phase 3?
 The answer to this is a little tricky. It is like phase 3 because it is the 3rd unique phase. However, if you look at the chart above, the bit value 
 for 3 would actually be 4. This is because our phases must be unique for them to be a completely different phase.
 
  • Wait, the npcs fighting in the market square are still fighting there, even though it is now phase 4 and not phase 2. How is this possible? Are the npcs spawned twice, once in each phase?
 The answer is they could be. However, the more likely scenario is that they are spawned in phasemask 6 (Phase 4 + phase 2 = phasemask 6).
 


What makes a phase Unique?

This is often where phasing can become extremely confusing. Unique phases exist at each bit value listed in the chart above.

The reason that ONLY those bit values are unique is because of the bit values adding together.

  • Examples:
  *Phase 4 is unique because you cannot add the other unique phases together to get that value:
    Phase 1 + Phase 2 = Phase 3 (not 4)
   
  *Phase 5 is NOT unique because:
    Phase 1 + Phase 4 = Phase 5 (Remember, you can ONLY add the UNIQUE phase values)
  
  *Phase 13 is NOT unique because:
    Phase 1 + Phase 4 + Phase 8 = Phase 13
    


What are NON-Unique phases used for?

Thinking back to our logic of adding bit values, this allows npcs and gobs to exist in multiple phases.

  • Looking once again at our npcs fighting in phase 2 and phase 4, this is because they are likely spawned with a phasemask of 6 (phase 2 + phase 4).

The same logic holds true throughout all phases.

  • Example:
 If a creature is spawned in Phase 13, it will be visible to the player when the player is in Phases 1,4 and 8 (phase 1 + phase 4 + phase 8 = phase 13).