HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Boundary

04-10-2009, 02:17 PM#1
wraithseeker
How would I detect if a given point is boundary?
04-10-2009, 02:22 PM#2
Bobo_The_Kodo
Collapse JASS:
function IsTerrainBoundary takes real x, real y returns boolean
     return IsTerrainPathable( x, y, PATHING_TYPE_ANY )
endfunction
04-10-2009, 04:10 PM#3
wraithseeker
Collapse JASS:
scope Block initializer Init

private function Conditions takes nothing returns boolean
    return IsUnitInGroup(GetTriggerUnit(),Submerge)
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t
    local real x
    local real y
    call BJDebugMsg("started")
    if GetOrderTargetUnit() == null then
       set x = GetOrderPointX()
       set y = GetOrderPointY()
       if IsTerrainPathable(x,y,PATHING_TYPE_ANY) == false then
            call IssueImmediateOrder(u,"stop")
        endif
    else
        set t = GetEventTargetUnit()
        set x = GetUnitX(t)
        set y = GetUnitY(t)
        if IsTerrainPathable(x,y,PATHING_TYPE_ANY) == false then
            call IssueImmediateOrder(u,"stop")
        endif
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddAction( t, function Actions )
endfunction
endscope

Failed.
04-10-2009, 04:52 PM#4
Bobo_The_Kodo
not == false

IsTerrainPathable returns opposite ...

look at my first post :)
04-11-2009, 01:35 AM#5
wraithseeker
Collapse JASS:
scope Block initializer Init

private function Conditions takes nothing returns boolean
    return IsUnitInGroup(GetTriggerUnit(),Submerge)
endfunction

function IsTerrainBoundary takes real x, real y returns boolean
     return IsTerrainPathable( x, y, PATHING_TYPE_ANY )
endfunction


private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t
    local real x
    local real y
    if GetOrderTargetUnit() == null then
       set x = GetOrderPointX()
       set y = GetOrderPointY()
       if IsTerrainBoundary(x,y) == true then
            call PauseUnit(u,true)
            call IssueImmediateOrder(u,"stop")
            call PauseUnit(u,false)
            call BJDebugMsg("started")
        endif
    else
        set t = GetEventTargetUnit()
        set x = GetUnitX(t)
        set y = GetUnitY(t)
        if IsTerrainBoundary(x,y) == true then
            call PauseUnit(u,true)
            call IssueImmediateOrder(u,"stop")
            call BJDebugMsg("started")
            call PauseUnit(u,false)
        endif
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddAction( t, function Actions )
endfunction
endscope
04-11-2009, 03:42 AM#6
Bobo_The_Kodo
So does it work?
04-11-2009, 04:15 AM#7
wraithseeker
no