- Joined
- Jan 17, 2010
- Messages
- 149
Plug and play library/snippet
Might be useful for debugging.
Requires - [vJASS] - Sync Local Booleans or equivalent ([vJASS] - Sync (Game Cache), or the new BlzAPI functions) to sync values
HOW IT WORKS:
It creates a (platform - Walkable destructable) Throne ('XOkt' destructable ID) somewhere on the map and exploits the fact they have different models (thus different return values for GetLocationZ) in classic/reforged, and then syncs the boolean to a global array for easy access.
This means you can detect other players playing Reforged in your map even if you do not have Reforged yourself or chosen to use classic.
Might be useful for debugging.
Requires - [vJASS] - Sync Local Booleans or equivalent ([vJASS] - Sync (Game Cache), or the new BlzAPI functions) to sync values
HOW IT WORKS:
It creates a (platform - Walkable destructable) Throne ('XOkt' destructable ID) somewhere on the map and exploits the fact they have different models (thus different return values for GetLocationZ) in classic/reforged, and then syncs the boolean to a global array for easy access.
This means you can detect other players playing Reforged in your map even if you do not have Reforged yourself or chosen to use classic.
JASS:
library DetectReforged initializer init requires BooleanSync optional TimerUtils
globals
private boolean array Reforged
endglobals
function IsReforged takes player p returns boolean
return Reforged[GetPlayerId(p)]
endfunction
private function AssignReforgedFlag takes nothing returns nothing
set Reforged[GetPlayerId(GetTriggerPlayer())] = GetSyncedBoolean()
endfunction
private function checkReforged takes nothing returns nothing
local real x = GetRectMinX(GetWorldBounds()) + 1000
local real y = GetRectMaxY(GetWorldBounds()) - 1000
local location l = Location(x,y)
local destructable d
local real z1 = GetLocationZ(Location(x,y))
local boolean reforged
local integer i = 0
set d = CreateDestructable('XOkt', x,y, 0,1,0)
call MoveLocation(l, x, y)
// 57.431 is the classic height of the throne at it's center if scale == 1
// reforged value is 72.71558
// so if the value is different then its reforged
//call BJDebugMsg(R2S(GetLocationZ(l) - z1))
set z1 = (GetLocationZ(l) - z1) * 100
if R2I(z1) != 5743 then
set reforged = true
// reforged
//call BJDebugMsg(R2S(z1))
else
set reforged = false
// classic
//call BJDebugMsg(R2S(z1))
endif
loop
call SyncBoolean(Player(i), reforged, function AssignReforgedFlag)
set i = i + 1
exitwhen i >= bj_MAX_PLAYER_SLOTS
endloop
call RemoveLocation(l)
call RemoveDestructable(d)
set d = null
set l = null
static if LIBRARY_TimerUtils then
call ReleaseTimer(GetExpiredTimer())
else
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
endif
endfunction
private function init takes nothing returns nothing
static if LIBRARY_TimerUtils then
call TimerStart(NewTimer(), 0.0, false, function checkReforged)
else
call TimerStart(CreateTimer(), 0.0, false, function checkReforged)
endif
endfunction
endlibrary
Last edited: