"My map worked on westfall but not on 1.24"

cleeezzz

The Undead Ranger.
Reaction score
268
JASS:
globals
    group GLOBAL_GROUP
    unit ReturnHandle
endglobals

function GetClosestUnitInRange takes real x, real y, real radius, boolean closest, boolexpr filter returns unit
    local group g = GLOBAL_GROUP
    local unit curUnit = null
    local unit loopUnit
    local real curDist
    local real dX
    local real dY
    local real loopDist
    call GroupClear( g )
    call GroupEnumUnitsInRange( g, x, y, radius, filter )
    if closest then
        set curDist = radius + 1
    else
        set curDist = 0
    endif
    loop
        set loopUnit = FirstOfGroup( g )
        exitwhen loopUnit == null
        set dX = x - GetUnitX( loopUnit )
        set dY = y - GetUnitY( loopUnit )
        set loopDist = SquareRoot( dX * dX + dY * dY )
        if loopDist < curDist == closest then
            set curDist = loopDist
            set curUnit = loopUnit
        endif
        call GroupRemoveUnit( g, loopUnit )
    endloop
    set ReturnHandle = curUnit
    set filter = null
    set loopUnit = null
    set curUnit = null
    return ReturnHandle
endfunction


to make it syntax, i had to make the global unit and group, but it loaded fine o_O
 

SerraAvenger

Cuz I can
Reaction score
234
JASS:
globals
    group GLOBAL_GROUP
    unit ReturnHandle
endglobals

function GetClosestUnitInRange takes real x, real y, real radius, boolean closest, boolexpr filter returns unit
    local group g = GLOBAL_GROUP
    local unit curUnit = null
    local unit loopUnit
    local real curDist
    local real dX
    local real dY
    local real loopDist
    call GroupClear( g )
    call GroupEnumUnitsInRange( g, x, y, radius, filter )
    if closest then
        set curDist = radius + 1
    else
        set curDist = 0
    endif
    loop
        set loopUnit = FirstOfGroup( g )
        exitwhen loopUnit == null
        set dX = x - GetUnitX( loopUnit )
        set dY = y - GetUnitY( loopUnit )
        set loopDist = SquareRoot( dX * dX + dY * dY )
        if loopDist < curDist == closest then
            set curDist = loopDist
            set curUnit = loopUnit
        endif
        call GroupRemoveUnit( g, loopUnit )
    endloop
    set ReturnHandle = curUnit
    set filter = null
    set loopUnit = null
    set curUnit = null
    return ReturnHandle
endfunction


to make it syntax, i had to make the global unit and group, but it loaded fine o_O
fascinating. I double checked it and it didn't for me. Oh well...

EDIT:
Problem was ReturnHandle was a handle for me, not a unit : )
Thanks for helping to find the error!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top