Hey there,
I'm working slowly on some code in my map, but when saving I keep getting the error 'Undeclared Function GetUnitId'. This function is from AutoIndex, the unit indexing system found at wc3c.
I have no idea why it doesn't recognize this function.
This is what I got so far, but it doesn't allow saving it.
I'm working slowly on some code in my map, but when saving I keep getting the error 'Undeclared Function GetUnitId'. This function is from AutoIndex, the unit indexing system found at wc3c.
I have no idea why it doesn't recognize this function.
This is what I got so far, but it doesn't allow saving it.
JASS:
library Movement initializer OnInit requires AutoIndex
globals
private group g = CreateGroup()
endglobals
private function MovementActions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer Uid = GetUnitId(u)
local player p = GetOwningPlayer(u)
local integer pid = GetPlayerId(p)
local integer x = 0
local integer y = 1
local integer X
local integer Y
local integer i = 0
local integer Speed = GetHeroInt(u,true)
local integer Steps = Speed
if GetSpellAbilityId() == 'A000' and GetUnitAbilityLevel(u, 'A000') == 1 and PlayerTurn == pid then
set SelectionMode[pid] = true
/////Tile Colors/////
loop
exitwhen y == 18
loop
exitwhen x == 10
if GetLocalPlayer() == p then
call ShowDestructable(Tile_Green[x][y], false)
call ShowDestructable(Tile_Yellow[x][y], false)
call ShowDestructable(Tile_Red[x][y], true)
endif
set Field_Pathable[x][y] = false
if RectContainsUnit(Field[x][y], u) == true then
set X = x
set Y = y
endif
set x = x+1
endloop
set x = 0
set y = y+1
endloop
set x = 0
set y = 0
loop
exitwhen x > Speed
loop
exitwhen y > (Speed - x)
if Field_Path[X+x][Y+y] == 0 then ///Field_Path checks if there's already a unit standing on the field or not
if GetLocalPlayer() == p then
call ShowDestructable(Tile_Red[X+x][Y+y], false)
call ShowDestructable(Tile_Green[X+x][Y+y], true)
endif
set Field_Pathable[X+x][Y+y] = true
endif
if Field_Path[X-x][Y+y] == 0 then
if GetLocalPlayer() == p then
call ShowDestructable(Tile_Red[X-x][Y+y], false)
call ShowDestructable(Tile_Green[X-x][Y+y], true)
endif
set Field_Pathable[X-x][Y+y] = true
endif
if Field_Path[X+x][Y-y] == 0 then
if GetLocalPlayer() == p then
call ShowDestructable(Tile_Red[X+x][Y-y], false)
call ShowDestructable(Tile_Green[X+x][Y-y], true)
endif
set Field_Pathable[X+x][Y-y] = true
endif
if Field_Path[X-x][Y-y] == 0 then
if GetLocalPlayer() == p then
call ShowDestructable(Tile_Red[X-x][Y-y], false)
call ShowDestructable(Tile_Green[X-x][Y-y], true)
endif
set Field_Pathable[X-x][Y-y] = true
endif
set y = y +1
set Steps = Steps - 1
endloop
set Steps = Speed - x
set y = 0
set x = x + 1
set Steps = Steps - 1
endloop
/// Center ///
if GetLocalPlayer() == p then
call ShowDestructable(Tile_Red[X][Y], false)
call ShowDestructable(Tile_Green[X][Y], false)
call ShowDestructable(Tile_Yellow[X][Y], true)
endif
set SelectionX[pid] = X
set SelectionY[pid] = Y
set Field_Pathable[X][Y] = false
elseif GetSpellAbilityId() == 'A000' and GetUnitAbilityLevel(u, 'A000') == 2 and PlayerTurn == pid then
if Field_Pathable[SelectionX[pid]][SelectionY[pid]] == true then
call GroupClear(g)
call GroupEnumUnitsOfPlayer(g, p, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if Unit_X[Uid] == Unit_X[GetUnidId(u)] and Unit_Y[Uid] == Unit_Y[GetUnidId(u)] then
call IssuePointOrder(u, "move", GetRectCenterX(Field[SelectionX[pid]][SelectionY[pid]]), GetRectCenterY(Field[SelectionX[pid]][SelectionY[pid]]))
set Unit_X[GetUnitId(u)] = SelectionX[pid]
set Unit_Y[GetUnitId(u)] = SelectionY[pid]
endif
call GroupRemoveUnit(g, u)
endloop
endif
///Colors back to normal///
loop
exitwhen y == 18
loop
exitwhen x == 10
call ShowDestructable(Tile_Red[x][y], false)
call ShowDestructable(Tile_Yellow[x][y], false)
call ShowDestructable(Tile_Green[x][y], false)
if RectContainsUnit(Field[x][y], u) == true then
set X = x
set Y = y
endif
set x = x+1
endloop
set x = 0
set y = y+1
endloop
/////////////////////////////
if GetLocalPlayer() == p then
call ClearSelection()
endif
endif
endfunction
private function OnInit takes nothing returns nothing
call RegisterAnyUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function MovementActions, null)
endfunction
endlibrary