• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

Building Collision Maps

Status
Not open for further replies.
I have a unit move forward based on triggers (without any collision) and it goes near a building, but inside it's pathing map, but not close enough to the x,y coords of the building for my trigger to detect it's 'collided'. The unit clearly goes through the building and War 3's AoE spells can detect the collision, as in the blizzard spell.

With a farm this isn't nearly as noticeable, because of the small pathing map. However, for a castle it's quite noticeable.

IsTerrainPathable() is for terrain pathing, but doesn't check doodads, destructables, or buildings.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
move an item to the desired position and check if it still is there
if it's gone the point is not pathable

but there are three cases with bug potential
if you got a higher cliff which is 100% filled with trees the item has no new point to snap to so it will just stay there
this can be checked by moving a second item there because it will get stuck on the first one (usually it will plop right next to it)
the second case is that you can only detect pathable points of item size this way so units can't fit through all the time (can be checked by moving items 32 left/right/up/down to that point but is rather slow)
the third case is that items can be blocked by items so all items in the target area should be hidden first and revealed later

will look similar to to this:
  • Custom Script: call SetItemPosition(udg_item1, udg_x, udg_y)
  • Custom Script: call SetItemPosition(udg_item2, udg_x, udg_y)
  • Custom Script: if GetWidgetX(udg_item1)==udg_x and GetWidgetY(udg_item1)==udg_y and GetWidgetX(udg_item2)!=udg_x and GetWidgetY(udg_item2)!=udg_y then
  • ----- Pathable -----
  • Custom Script: endif

another option would be to replace the items with a unit with collision and use the GUI move function
 
Thanks, i'll try that. I was thinking of using units to check, but items are smaller and less intensive on the computer when you use a hundred or so of them to check.

Edit: Seems to work in theroy, but it keep's 'colliding' with my casting unit, and there's no easy way to fix that, still thanks for giving a solution that would normally work. (can't +rep you again it seems)

EDIT: Still fails, could be how i'm checking it, all well, i'll mess with it some more


Okay, I fixed my function and it works now, im so happy.

JASS:
function IsPathableEnum takes nothing returns boolean
    local unit u=GetFilterUnit()
    local boolean b=not(IsUnitType(u,UNIT_TYPE_STRUCTURE))or not(IsUnitInGroup(u,udg_PSG_Projectiles))
    set u=null
    if b then
        set udg_PSG_Count2=udg_PSG_Count2+1
    endif
    return b
endfunction
function IsPathable takes real x,real y,integer id returns boolean
    local item I=CreateItem(id,x,y)
    local boolean B=false
    local location l=Location(x,y)
    local group g
    local integer i
    call SetItemPosition(I,x,y)
    set udg_PSG_Count2=0
    set g=GetUnitsInRangeOfLocMatching(24,l,Condition(function IsPathableEnum))
    set i=udg_PSG_Count2
    call DestroyGroup(g)
    call RemoveLocation(l)
    set l=null
    set g=null
    if (SquareRoot((GetItemX(I)-x)*(GetItemX(I)-x)+(GetItemY(I)-y)*(GetItemY(I)-y))>=32)and i==0then
        set B=true
    endif
    call RemoveItem(I)
    set I=null
    return B
endfunction

Might not be the cleanest function, but I'm working on it.
 
Last edited:
Status
Not open for further replies.
Top