Page 1 of 1

Remove Collision of Units

Posted: Tue Aug 16, 2011 1:05 pm
by TheChosenOreo
Hi!

I am having trouble removing the collision of units so they can walk through each other while still having control of the units.

For example: In my maze, I want to have my Demon Hunter walk through the other players' Demon Hunters.

I have the following Triggers:

Trigger: locust

Code: Select all

function locust takes nothing returns nothing
    local unit u = GetEnumUnit()

    call UnitAddAbility(u, 'Aloc')
    call ShowUnit(u, false)
    call ShowUnit(u, true)
    call UnitRemoveAbility(u, 'Aloc')

    set u = null
endfunction

function Trig_locust_Actions takes nothing returns nothing
    local group g = GetUnitsInRectAll(GetEntireMapRect())

    call ForGroup( g, function locust )

    call DestroyGroup(g)
    set g = null
endfunction

function InitTrig_locust takes nothing returns nothing
    set gg_trg_locust = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_locust, 0.01 )
    call TriggerAddAction( gg_trg_locust, function Trig_locust_Actions )
endfunction
Then, In the Map Script Itself...

Trigger: MapScript.j

Code: Select all

function NoCollisionsAtAll takes nothing returns nothing
    call SetUnitPathing(GetEnumUnit(), false)
endfunction

function CollideNone takes nothing returns nothing
    local group g = GetUnitsInRectAll(GetEntireMapRect())
    call ForGroup(g, function NoCollisionsAtAll)
    
    call DestroyGroup(g)
    set g = null
endfunction
In another trigger I call the function, "CollideNone"...

Trigger: OneStepInitLVL1

Code: Select all

function createunits takes nothing returns nothing
    set unit_footman[0] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_202), 0.00)
    set unit_footman[1] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_209), 0.00)
    set unit_footman[2] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_208), 0.00)
    set unit_footman[3] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_206), 0.00)
    set unit_footman[4] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_248), 0.00)
    set unit_footman[5] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_237), 0.00)
    set unit_footman[6] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_238), 0.00)
    set unit_footman[7] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_205), 0.00)
    set unit_footman[8] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_244), 0.00)
    set unit_footman[9] = CreateUnitAtLoc(Player(11), 'hfoo', GetRectCenter(gg_rct_Rect_247), 0.00)
endfunction

function Trig_OneStepInit_Actions takes nothing returns nothing
    call createunits()
    call IssuePointOrderLoc( unit_footman[0], "patrol", GetRectCenter(gg_rct_Rect_207) )
    call IssuePointOrderLoc( unit_footman[1], "patrol", GetRectCenter(gg_rct_Rect_204) )
    call IssuePointOrderLoc( unit_footman[2], "patrol", GetRectCenter(gg_rct_Rect_204) )
    call IssuePointOrderLoc( unit_footman[3], "patrol", GetRectCenter(gg_rct_Rect_203) )
    call IssuePointOrderLoc( unit_footman[4], "patrol", GetRectCenter(gg_rct_Rect_249) )
    call IssuePointOrderLoc( unit_footman[5], "patrol", GetRectCenter(gg_rct_Rect_210) )
    call IssuePointOrderLoc( unit_footman[6], "patrol", GetRectCenter(gg_rct_Rect_239) )
    call IssuePointOrderLoc( unit_footman[7], "patrol", GetRectCenter(gg_rct_Rect_242) )
    call IssuePointOrderLoc( unit_footman[8], "patrol", GetRectCenter(gg_rct_Rect_245) )
    call IssuePointOrderLoc( unit_footman[9], "patrol", GetRectCenter(gg_rct_Rect_246) )
    call CollideNone()
endfunction

//===========================================================================
function InitTrig_OneStepInitLVL1 takes nothing returns nothing
    set gg_trg_OneStepInitLVL1 = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_OneStepInitLVL1, 0.01 )
    call TriggerAddAction( gg_trg_OneStepInitLVL1, function Trig_OneStepInit_Actions )
endfunction
Thank you.

-Oreo

Re: Remove Collision of Units

Posted: Tue Aug 16, 2011 1:32 pm
by 3ICE
I just set their movement type to none and collision size to 0. Is all that triggering really necessary?