Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,239
I am currently using the following function:
This is not finished which is why I don't use the p variable yet etc, but that's not the issue.
The code is supposed to order a peon to build in a specific region but make sure there is nothing blocking the randomized location.
The debug messages show correct values so they are not the issue.
I placed the peon inside the region and it build properly, but when I moved the region it suddenly stopped working, it does exit the loop.
It does not pass the condition, despite it being impossible for it to fail:
JASS:
function Build(player p, integer id)
{
rect toBuild = gg_rct_Region_000;
real x, y;
location l;
group g;
while(true)
{
x = GetRandomReal(GetRectMinX(toBuild), GetRectMaxX(toBuild));
y = GetRandomReal(GetRectMinY(toBuild), GetRectMaxY(toBuild));
l = Location(x, y);
BJDebugMsg(R2S(x)+ " " + R2S(y) + " " + I2S(id));
g = GetUnitsInRangeOfLocAll(100, l);
if(FirstOfGroup(g) != null)
{
IssueBuildOrderById(gg_unit_opeo_0004, id, x, y);
BJDebugMsg("no null");
break;
}
DestroyGroup(g);
RemoveLocation(l);
}
}
This is not finished which is why I don't use the p variable yet etc, but that's not the issue.
The code is supposed to order a peon to build in a specific region but make sure there is nothing blocking the randomized location.
The debug messages show correct values so they are not the issue.

I placed the peon inside the region and it build properly, but when I moved the region it suddenly stopped working, it does exit the loop.
It does not pass the condition, despite it being impossible for it to fail:

Last edited: