- Joined
- Jan 30, 2013
- Messages
- 12,440
THIS ISSUE IS FIXED FOR PATCH 1.31+ ACCORDING TO REPORTS
Introduction of SmartCameraPanBJ
This Guide is made to fix
As some of you may know, the function does desync on multiplayer maps (100% guaranteed).
What is Desync? Desync is an event in multiplayer games where all players that plays (or some players, in that case it's possible to be a server split) become disconnected except the host itself.
CREDITS
PurgeandFire : The Fixing Script and Helping Me with the workaround
Legal_Ease : On our test with http://www.hiveworkshop.com/forums/maps-564/high-road-aos-238438/?prev=status=p made by him, which let me to search for solutions once people point out the issue with
~Daffa the Mage
Introduction of SmartCameraPanBJ
This Guide is made to fix
|
What is Desync? Desync is an event in multiplayer games where all players that plays (or some players, in that case it's possible to be a server split) become disconnected except the host itself.
Copy the code into the Map Header (the one above all triggers folders)
to call the function :
Replace
Remember,
A recommendation for GUI Users is to set these 3 things into variables and call the function with those variables instead, ex (by PurgeandFire) :
Notes : Global Variables uses udg_VariableName in Jass, so don't miss them when calling the custom native!
JASS:
function SmartCameraPanBJModified takes player whichPlayer, location loc, real duration returns nothing
local real tx = GetLocationX(loc)
local real ty = GetLocationY(loc)
local real dx = tx - GetCameraTargetPositionX()
local real dy = ty - GetCameraTargetPositionY()
local real dist = SquareRoot(dx * dx + dy * dy)
if (GetLocalPlayer() == whichPlayer) then
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
call PanCameraToTimed(tx, ty, 0)
// Far away = snap camera immediately to point
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
call PanCameraToTimed(tx, ty, duration)
// Moderately close = pan camera over duration
else
// User is close, don't move camera
endif
endif
endfunction
to call the function :
call SmartCameraPanBJModified( Player(), Location(), Timer() )
Replace
SmartCameraPanBJModified
with your modified name.Remember,
Player()
is the Player, Location()
is the target location and Timer()
is the time amount for the pan.A recommendation for GUI Users is to set these 3 things into variables and call the function with those variables instead, ex (by PurgeandFire) :
|
The Actual Problem with SmartCameraPanBJ
SmartCameraPanBJ desyncs was a mystery, in GUI, this can't be solved, but the actual problem lies on how the function execute itself.
The code create location on local block (this one :
How to solve this problem?
It might looks complicated, but it's not THAT complicated. Read below to know how to fix it :
The script below is the fixer for this issue (Credits to PurgeandFire) :
However, if you directly copy this script to your map header (or a trigger), it will causes map compiling to fail, there are 2 workaround to this :
1. Copy the script to Map Header, to deal with the bug mentioned above, I recommend copy pasting this script instead :
to call the function :
Replace
Remember,
A recommendation for GUI Users is to set these 3 things into variables and call the function with those variables instead, ex (by PurgeandFire) :
Notes : Global Variables uses udg_VariableName in Jass, so don't miss them when calling the custom native!
2. Override the original script at blizzard.j then import it to the map. This will allow you to use the default native without issues, because blizzard.j from the map will be read by the game instead of the default.
SmartCameraPanBJ desyncs was a mystery, in GUI, this can't be solved, but the actual problem lies on how the function execute itself.
JASS:
function SmartCameraPanBJ takes player whichPlayer, location loc, real duration returns nothing
local real dist
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
set dist = DistanceBetweenPoints(loc, GetCameraTargetPositionLoc())
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
// If the user is too far away, snap the camera.
call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), 0)
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
// If the user is moderately close, pan the camera.
call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
else
// User is close enough, so don't touch the camera.
endif
endif
endfunction
set dist = DistanceBetweenPoints(loc, GetCameraTargetPositionLoc())
), which causes desync as location may not be created at local blockHow to solve this problem?
It might looks complicated, but it's not THAT complicated. Read below to know how to fix it :
The script below is the fixer for this issue (Credits to PurgeandFire) :
JASS:
function SmartCameraPanBJ takes player whichPlayer, location loc, real duration returns nothing
local real tx = GetLocationX(loc)
local real ty = GetLocationY(loc)
local real dx = tx - GetCameraTargetPositionX()
local real dy = ty - GetCameraTargetPositionY()
local real dist = SquareRoot(dx * dx + dy * dy)
if (GetLocalPlayer() == whichPlayer) then
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
call PanCameraToTimed(tx, ty, 0)
// Far away = snap camera immediately to point
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
call PanCameraToTimed(tx, ty, duration)
// Moderately close = pan camera over duration
else
// User is close, don't move camera
endif
endif
endfunction
However, if you directly copy this script to your map header (or a trigger), it will causes map compiling to fail, there are 2 workaround to this :
1. Copy the script to Map Header, to deal with the bug mentioned above, I recommend copy pasting this script instead :
JASS:
function SmartCameraPanBJModified takes player whichPlayer, location loc, real duration returns nothing
local real tx = GetLocationX(loc)
local real ty = GetLocationY(loc)
local real dx = tx - GetCameraTargetPositionX()
local real dy = ty - GetCameraTargetPositionY()
local real dist = SquareRoot(dx * dx + dy * dy)
if (GetLocalPlayer() == whichPlayer) then
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
call PanCameraToTimed(tx, ty, 0)
// Far away = snap camera immediately to point
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
call PanCameraToTimed(tx, ty, duration)
// Moderately close = pan camera over duration
else
// User is close, don't move camera
endif
endif
endfunction
to call the function :
call SmartCameraPanBJModified( Player(), Location(), Timer() )
Replace
SmartCameraPanBJModified
with your modified name.Remember,
Player()
is the Player, Location()
is the target location and Timer()
is the time amount for the pan.A recommendation for GUI Users is to set these 3 things into variables and call the function with those variables instead, ex (by PurgeandFire) :
|
2. Override the original script at blizzard.j then import it to the map. This will allow you to use the default native without issues, because blizzard.j from the map will be read by the game instead of the default.
CREDITS
PurgeandFire : The Fixing Script and Helping Me with the workaround
Legal_Ease : On our test with http://www.hiveworkshop.com/forums/maps-564/high-road-aos-238438/?prev=status=p made by him, which let me to search for solutions once people point out the issue with
SmartCameraPanBJ
.~Daffa the Mage
Last edited: