- Joined
- Oct 4, 2011
- Messages
- 226
Hi. I was wondering how I would choose the closest unit to index as the target in the hashtable.
Hi. I was wondering how I would choose the closest unit to index as the target in the hashtable.
Are the index and the unit 2 different variables? or does the unit variable have an index. (Array type)
local unit u = GetTriggerUnit()
local unit pu
local player p = GetTriggerPlayer()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local integer index = 0
local integer cv = GetUnitUserData(u)
call GroupEnumUnitsInRange(udg_UG, x, y, 600.00, null)
loop
set pu = FirstOfGroup(udg_UG)
exitwhen (pu==null)
// if dont need if u dont want filter the unit
// if IsUnitAlly(pu, p) then
call SaveUnitHandle(udg_Target_Table, cv, index, pu)
set index = index + 1
// endif
call GroupRemoveUnit(udg_UG, pu)
endloop
set u = null
set p = null
set pu = null
local unit u = GetTriggerUnit()
local unit pu
local player p = GetTriggerPlayer()
local integer cv = GetUnitUserData(u)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
set udg_index = 0
call GroupEnumUnitsInRange(udg_UG, x, y, 600.00, null)
loop
set pu = FirstOfGroup(udg_UG)
exitwhen (pu==null)
//i removed the if but u can put back if u want
set udg_Target[cv] = pu
set udg_index[cv] = udg_index[cv] + 1
call GroupRemoveUnit(udg_UG, pu)
endloop
set u = null
set p = null
set pu = null