- Joined
- Jul 26, 2008
- Messages
- 1,009
Alright, I have a map where a player can put down groves of trees on the map. It's fine until the player puts a grove of trees on the seam between the blight and the grass. This causes everyone to drop.
It's detected when the PointerHero does something like Smart order, Attack, Patrol, etc.
And this happens when you click a little thing called Grove. These are the steps that allow you to create these groves and the desync lies within. Hopefully someone can help, thanks :3
My theory is that the seam creates inconsistent tree types between the players, causing them to recieve different packets of information and blam. Desync. That or the blight can't decide what type of trees to make underneath it and goes boom. I'm wondering how to fix or solve it. Hell, is there even a way to prevent creation of trees between this area?
EDIT: Alright further testing seems to prove that when the tree is DIRECTLY on the blight and the non-blighted terrain it causes desync. Any help or fix for this?
JASS:
function GetDoodadTypeAtPT takes location pt returns integer
local real dd
local real df
local real ds
local real dg
local real rnd
set udg_GUI_Misc_DoodadFillCount = udg_GUI_Misc_DoodadFillCount + 1
if IsTerrainWalkable(GetLocationX(pt), GetLocationY(pt)) then
if IsTerrainBlended(pt) then
set udg_TEMP_Integer = GetRandomInt(0,1)
if udg_TEMP_Integer == 0 then
return 'ATtr'
else
return 'FTtw'
endif
elseif IsTerrainUnderground(pt) then
return 'GTsh'
elseif IsTerrainDungeon(pt) then
return 'DTsh'
elseif IsTerrainOutland(pt) then
return 'OTtw'
elseif IsTerrainSunkenRuins(pt) then
return 'ZTtw'
elseif IsTerrainBarrens(pt) then
return 'BTtw'
elseif IsTerrainFall(pt) then
return 'FTtw'
elseif IsTerrainWinter(pt) then
set udg_TEMP_Integer = GetRandomInt(0,1)
if udg_TEMP_Integer == 0 then
return 'WTst'
else
return 'WTtw'
endif
elseif IsTerrainForest1(pt) then
return 'CTtr'
elseif IsTerrainForest2(pt) then
return 'ATtr'
elseif IsTerrainCity1(pt) then
return 'LTlt'
elseif IsTerrainCity2(pt) then
return 'YTct'
elseif IsTerrainCity3(pt) then
return 'JTtw'
endif
return 'ATtr'
endif
return 0
endfunction
function DoodadFillArea takes rect area, boolean circle returns nothing
local real inc = 150
local real x
local real y
local location pt
local integer dd
//normalize value to multiple of 150 of world coords to prevent tree seams
set x = I2R(R2I(GetRectMinX(area) / 150)) * 150
loop
exitwhen x > GetRectMaxX(area)
set y = I2R(R2I(GetRectMinY(area) / 150)) * 150
loop
exitwhen y > GetRectMaxY(area)
set pt = Location(x + GetRandomReal(-inc/5, inc/5),y + GetRandomReal(-inc/5, inc/5) + ModuloInteger(R2I(x / inc), 2) * inc / 2)
set dd = GetDoodadTypeAtPT(pt)
if GetBooleanOr(not(circle), DistanceBetweenPoints(pt, GetRectCenter(area)) <= (GetRectMaxX(area) - GetRectMinX(area))/2) then
call CreateDestructableLoc( dd, pt, GetRandomReal(0, 360), 1, GetDoodadVariation(dd) )
call KillDestructable( GetLastCreatedDestructable() )
call DestructableRestoreLife( GetLastCreatedDestructable(), GetDestructableMaxLife(GetLastCreatedDestructable()), true )
if DistanceBetweenPoints(GetDestructableLoc(GetLastCreatedDestructable()), pt) > 100 then
call RemoveDestructable(GetLastCreatedDestructable())
endif
endif
// (prevent trigger from being stopped and prevent game desync(<-?))
set udg_GUI_Misc_DoodadFillCount = udg_GUI_Misc_DoodadFillCount + 1
if udg_GUI_Misc_DoodadFillCount > 500 then
set udg_GUI_Misc_DoodadFillCount = 0
call TriggerSleepAction(0)
endif
call RemoveLocation(pt)
set y = y + inc
endloop
set x = x + inc
endloop
endfunction
JASS:
function OnPointerSmart takes location pt, player pl, boolean isunit returns nothing
local integer id
local force fp
local location loc
local location loc2
local integer dt
local integer goldleft
local integer junk
local group grp
set id = GetConvertedPlayerId(pl)
set fp = bj_FORCE_PLAYER[id-1]
if udg_Status[id] == "doodad_create" then
if udg_DM_SubType[id] == "grove" then
call DoodadFillArea(RectFromCenterSizeBJ(pt, RealBrushSize[id], RealBrushSize[id]), true)
...
It's detected when the PointerHero does something like Smart order, Attack, Patrol, etc.
JASS:
elseif (GetTriggerUnit() == GUI_D_P_Grove) then
set udg_Status[id] = "doodad_create"
set udg_DM_SubType[id] = "grove"
call GUIApplyCamForDM(pl)
call LeaderboardSetPlayerItemLabelBJ( ConvertedPlayer(4), udg_Board[id], "|cFFFFFFFF-> '|r|c0000FF00" + udg_DM_SubType[id] + "|r|cFFFFFFFF'|r" )
call SelectUnitForPlayerSingle( udg_GUI_Pointer[id], pl )
call DisplayTextToForce( fp, " Right click to create a '|c0000FF00" + udg_DM_SubType[id] + "|r'." )
And this happens when you click a little thing called Grove. These are the steps that allow you to create these groves and the desync lies within. Hopefully someone can help, thanks :3
My theory is that the seam creates inconsistent tree types between the players, causing them to recieve different packets of information and blam. Desync. That or the blight can't decide what type of trees to make underneath it and goes boom. I'm wondering how to fix or solve it. Hell, is there even a way to prevent creation of trees between this area?
EDIT: Alright further testing seems to prove that when the tree is DIRECTLY on the blight and the non-blighted terrain it causes desync. Any help or fix for this?
Last edited: