[Question] Phasing
#1
Posted 18 January 2012 - 11:44 AM
#3
Posted 18 January 2012 - 01:48 PM
function FirstLogin_Phaser(event, pPlayer) pPlayer:PhaseSet(xyz) -- replace xyz with a phase end RegisterServerHook(3, "FirstLogin_Phaser")
If you meant you want to make a own phase for each character then import the character id from your database and make 2^id for the number of the phase.
Would look like this: (i think ^^)
function FirstLogin_Phaser(event, pPlayer)
local playerName = pPlayer:GetName()
local playerGuid = CharDBQuery("SELECT guid FROM Characters WHERE name = "..playerName)
local phaseid = 2^playerGuid
pPlayer:PhaseSet(phaseid)
end
RegisterServerHook(3, "FirstLogin_Phaser")I didn't try this stuff it's only a idea ;D
#4
Posted 18 January 2012 - 02:32 PM
There are not many unique phases out there : /
local T = {}
do
local X = 1
while true do
T[2^X] = false
X = X + 1
if(X >= 15) then
break
end
end
end
local function SERVER_HOOK_FIRST_ENTER_WORLD(event, pPlayer)
for k,v in pairs(T) do
if(not v) then
pPlayer:SetPhase(k)
T[k] = pPlayer
break
end
end
end
--[[[
Unphase:
T[pPlayer:GetPhase()] = false
pPlayer:SetPhase(1)
]]
RegisterServerHook(3, SERVER_HOOK_FIRST_ENTER_WORLD)
#5
Posted 18 January 2012 - 05:24 PM
Quote
That's actually a pretty bad idea...
Nothing can use/hold a number that big.
#6
Posted 18 January 2012 - 06:11 PM
local phaseid = 2^playerGuidD: Oh god no. That would cause overflow. A playerGuid is a 64bit number, and a phase is a 16 bit number.. baddddd idea.
#7
Posted 19 January 2012 - 09:32 AM
Quote
You're a "Dev"! You can figure it out!
Sooo, what your saying is, i'm not allowed to ask for help?
#8
Posted 19 January 2012 - 11:35 AM
Strictly speaking, you just asked if it was possible and I answered it :P
Thing is, as you can see by the answers above, is that we didn't really understand what you mean.
Do you want every player to have his own phase when first entering world? Or just one separated from more advanced players?
The second one is much easier, while the first one might need core editing.
#9
Posted 19 January 2012 - 02:23 PM
Quote
Strictly speaking, you just asked if it was possible and I answered it :P
Thing is, as you can see by the answers above, is that we didn't really understand what you mean.
Do you want every player to have his own phase when first entering world? Or just one separated from more advanced players?
The second one is much easier, while the first one might need core editing.
I want every player in his own phase on entering
#10
Posted 19 January 2012 - 02:38 PM
For players not to see each other, they should each be in a phase that's a power of 2 (2^x with maximum x of 15).
So if you'd use phasing it would allow for a maximum of 16 "isolated" phases in which players in one phase cannot see players in the other isolated phases. Using the current system that is.
If you want to make sure player's cannot see each other until a certain condition is met, you'd have to do it smartly in the core.
I'm not aware of any methods in Lua with which you can solve this.
You'd probably have to do something with the Player:CanSee method in the core if you'd wish to accomplish this.
#11
Posted 20 January 2012 - 05:47 AM
Quote
For players not to see each other, they should each be in a phase that's a power of 2 (2^x with maximum x of 15).
So if you'd use phasing it would allow for a maximum of 16 "isolated" phases in which players in one phase cannot see players in the other isolated phases. Using the current system that is.
If you want to make sure player's cannot see each other until a certain condition is met, you'd have to do it smartly in the core.
I'm not aware of any methods in Lua with which you can solve this.
You'd probably have to do something with the Player:CanSee method in the core if you'd wish to accomplish this.
USED_PHASES = {}
local P = USED_PHASES -- local indexing for faster usage
-- Returns a completely new, unique phase where possible for the given identifier.
function GetNewPhase(id)
if P[id] == nil then P[id] = {} end
local p = 1
if #P[id] == 1 then
p = 2
else
p = math.pow(2, #P[id])
end
if p > math.pow(2, 16) then
-- this one just returns the first phase but
-- you could do some more advanced handling if we
-- ran out of unique phases.
return P[id][1]
end
table.insert(P[id], p)
return p
end
-- Returns true if the phase specified is used, false otherwise, for the given identifier.
function IsPhaseUsed(id, phase)
local x = math.ceil(math.log(phase, 2))+1
if P[id][x] ~= nil then
return true
else
return false
end
end[color=cyan]
Now, to decide if a player can see another, I would really recommend that
you use a number and binary operations on said number. If I remember correctly,
LuaHypArc does support binary operations. You can then use these flags to
indicate whether a player should be in this phase or that phase, or whatever.
ie.
local playerState = 0x0000000[color=cyan]
Then when a player completes a quest, you could use a bitwise AND to set that flag.
local playerState = bit.band(playerState, 0x0000001)[color=cyan]
Then you could check to see if a player has done that stage by doing a bitwise OR.
if bit.bor(playerState, 0x00000001) == 0x00000001 then -- player has completed this stage end[color=cyan]
We use the "identifier" thing so that we can seperate each phase table so it's possible
to have, for example, each zone have it's own phase table. The ID thing is really up to
you how you describe it. For example, I could do:
local playerState = 0x0000001
if bit.bor(playerState, 0x00000001) == 0x00000001 then
local phase = GetNewPhase("hello_world_quest_completed")
pPlayer:SetPhase(phase)
end
#12
Posted 20 January 2012 - 11:11 AM
Quote
So to do this properly, scaling with any number of players, it's not doable in Lua as far as I know... Which is what I meant all along.
#13
Posted 20 January 2012 - 12:08 PM
Quote
Quote
So to do this properly, scaling with any number of players, it's not doable in Lua as far as I know... Which is what I meant all along.
Quote
#14
Posted 31 January 2012 - 03:08 PM
Basically when a player logs in for the first time he/she goes through a short NPC cinematic. All I wanted to do was make it so every player is in a different phase so one player can not see the other players cinematic.
Any more input?
THANK YOU in advance!
#15
Posted 31 January 2012 - 03:12 PM
Only 15 players at a time could be phased.
All the needed code to do such is already provided above.
Otherwise you need C++ and I have no idea how :3
#16
Posted 31 January 2012 - 03:29 PM
[code][color=cyan]I came up with a solution that would require some core editing in which you could have a virtual method in the Unit class:
[/color]
virtual bool IsVisibleToUnit(Unit*, Unit*) { return true; }Which you could override to return false. Then, whenever you send a creature update or creature spawn packet, or need to work out if a unit can see another unit (ie, combat), you could doif(pUnit->IsVisibleToUnit(pTarget)) // we can see this unit..[color=cyan]Although I worry about the efficiency of this.[/code]
Similar Topics
![]() |
Poll A questionStarted by Larsi, 22 Nov 2011 |
|
|
|
![]() |
[Skyfire] [CODE]+[Question] SQL-batch for WoW-V-itemsStarted by Cerreth, 21 Jan 2012 |
|
|
|
![]() |
[Question] Is there any Custom Gear powerful enough to solo Raids / Instances ?Started by Ryan432120, 06 Mar 2012 |
|
|
|
![]() |
I got a questionStarted by prs, 19 Apr 2012 |
|
|
|
![]() |
QuestionStarted by Fluqsi33, 29 Mar 2012 |
|
|
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users















