Heya.
Once again a question but this problem is pretty mysterious to me.
I was working on something to let units move in a given formation towards certain fields on the map. Since the map is devided into various rects these rects are all documented with an X and Y coordinate. Those rects are called Field[X][Y].
All units in the map have an own id that can be tracked by GetUnitId(unit), and every unit has its own X and Y coordinate based on those rects. Those integers are called Unit_X[unit id] and Unit_Y[unit id].
At first I made a typo and this caused the units to move to a weird place and I couldn't figure out why until I found out I made a typo.
Here was my mistake:
As you can see I used GetRectCenterX twice, resulting into wrong coordinates for the units to move to.
However, now that I changed it correctly, the map crashes whenever the UnitLineUp function is being called, while really the only thing I changed was changing an X to an Y.
I have no idea what is causing this crash.:s
Here's the full code now.
Once again a question but this problem is pretty mysterious to me.
I was working on something to let units move in a given formation towards certain fields on the map. Since the map is devided into various rects these rects are all documented with an X and Y coordinate. Those rects are called Field[X][Y].
All units in the map have an own id that can be tracked by GetUnitId(unit), and every unit has its own X and Y coordinate based on those rects. Those integers are called Unit_X[unit id] and Unit_Y[unit id].
At first I made a typo and this caused the units to move to a weird place and I couldn't figure out why until I found out I made a typo.
Here was my mistake:
JASS:
function UnitLineUp takes unit u returns nothing
local integer id = GetUnitId(u)
local real x = GetRectCenterX(Field[Unit_X[id]][Unit_Y[id]])
local real y = GetRectCenterX(Field[Unit_X[id]][Unit_Y[id]])
As you can see I used GetRectCenterX twice, resulting into wrong coordinates for the units to move to.
However, now that I changed it correctly, the map crashes whenever the UnitLineUp function is being called, while really the only thing I changed was changing an X to an Y.
I have no idea what is causing this crash.:s
Here's the full code now.
JASS:
library RegimentHandling
function UnitLineUp takes unit u returns nothing
local integer id = GetUnitId(u)
local real x = GetRectCenterX(Field[Unit_X[id]][Unit_Y[id]])
local real y = GetRectCenterY(Field[Unit_X[id]][Unit_Y[id]])
local integer Spot = Unit_Reg_Spot[id]
local integer Size = Unit_Reg_Size[id]
/// --- Regiment Size: 16 --- ///
if Size == 16 then
/// Setting the X value ///
if Spot == 1 or Spot == 5 or Spot == 9 or Spot == 13 then
set x = x -120.
elseif Spot == 2 or Spot == 6 or Spot == 10 or Spot == 14 then
set x = x -40.
elseif Spot == 3 or Spot == 7 or Spot == 11 or Spot == 15 then
set x = x +40.
else
set x = x +120.
endif
/// Setting the Y value ///
if Spot > 0 and Spot < 5 then
set y = y -120.
elseif Spot > 4 and Spot < 9 then
set y = y -40.
elseif Spot > 8 and Spot < 13 then
set y = y + 40.
else
set y = y + 120.
endif
/// Ordering the unit to move ///
call MoveWithFace(u, x, y)
endif
set u = null
endfunction
endlibrary