Zwiebelchen
Hosted Project GR
- Joined
- Sep 17, 2009
- Messages
- 7,234
I have a whole set of hidden destructables for different players.
In order to provide a synced Z detection no matter the visibility state of the destructable, I use this script to temporarily unhide all destructables in a given area.
Don't think about everything outside the innermost loop. It works.
Basicly, what doesn't work is the following:
In the innermost loop, the DebugMsg is displayed properly all the time (9 times in total, as expected). However, the z value returned is 0 although it should be higher (somewhere around 300).
What is even more strange is that sometimes it works, sometimes it doesn't.
No matter what: the "checked" message is ALWAYS displaying the expected behaviour. It's just the z value that is not properly get.
I'm totally confused. This does not make any sense to me!
Just to go sure, I checked the existance of d and all the GetLocationZ() values returned per loop iteration:
- When the destructables are currently shown by other means, the value returned is correct.
- The handles for d always exist (tested by debug message)
- When the destructables are hidden again, for 1 or 2 seconds the correct value is returned, after that, GetLocationZ() in the innermost loop just returns 0
- Even more weird: sometimes even after 2 seconds, the GetLocationZ() returns the correct value for an infinite amount of time.
In order to provide a synced Z detection no matter the visibility state of the destructable, I use this script to temporarily unhide all destructables in a given area.
Don't think about everything outside the innermost loop. It works.
Basicly, what doesn't work is the following:
In the innermost loop, the DebugMsg is displayed properly all the time (9 times in total, as expected). However, the z value returned is 0 although it should be higher (somewhere around 300).
What is even more strange is that sometimes it works, sometimes it doesn't.
No matter what: the "checked" message is ALWAYS displaying the expected behaviour. It's just the z value that is not properly get.
I'm totally confused. This does not make any sense to me!
JASS:
function GetLocationZSynced takes location l returns real
local integer row = R2I((GetLocationY(l)-mapMinY)/TILESIZE)
local integer column = R2I((GetLocationX(l)-mapMinX)/TILESIZE)
local integer x1 = column-1
local integer x2 = column+1
local integer y1 = row-1
local integer y2 = row+1
local integer a
local integer b
local integer j
local integer id
local integer count
local real z = GetLocationZ(l)
local destructable d
//border safety:
if x1 < 0 then
set x1 = 0
elseif x2 >= columns then
set x2 = columns-1
endif
if y1 < 0 then
set y1 = 0
elseif y2 >= rows then
set y2 = rows-1
endif
set a = x1
loop
set b = y1
exitwhen a > x2
loop
exitwhen b > y2
set id = b*columns+a
if not LoadBoolean(hash, id, -1) then //only check hidden squares
set count = LoadInteger(hash, id, 0)
set j = 0
loop
exitwhen j >= count
set j = j + 1
set d = LoadDestructableHandle(hash, id, j)
call ShowDestructable(d, true)
set z = RMaxBJ(z, GetLocationZ(l))
call BJDebugMsg("checked")
call ShowDestructable(d, false)
endloop
endif
set b = b + 1
endloop
set a = a + 1
endloop
set d = null
return z
endfunction
Just to go sure, I checked the existance of d and all the GetLocationZ() values returned per loop iteration:
- When the destructables are currently shown by other means, the value returned is correct.
- The handles for d always exist (tested by debug message)
- When the destructables are hidden again, for 1 or 2 seconds the correct value is returned, after that, GetLocationZ() in the innermost loop just returns 0
- Even more weird: sometimes even after 2 seconds, the GetLocationZ() returns the correct value for an infinite amount of time.
Last edited by a moderator: