• 🏆 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!

Collision/Pathing Problem

Status
Not open for further replies.
Level 4
Joined
May 12, 2008
Messages
49
Well, you see in my newest map Post Azeroth I've encountered a bit of a problem you see.

The Problem: I have 2 bases that both have a gate, and the gate works fine, had to work a bit with animations. But a few hours ago I noticed that if the door is closed (like it is in the beginning) it works fine (units can't move through it) but if I open it and then close it and try the same, the units move through the gate like there is no collision or pathing there to stop them.


Here's a video:

Here's the code for that gate:


Open Gate
JASS:
function Trig_Open_Gate_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A009' ) ) then
        return false
    endif
    if ( not ( GetSpellAbilityUnit() == gg_unit_n002_0013 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Open_Gate_Actions takes nothing returns nothing
    set udg_GateOpen = 1
    set udg_NWBGateHP = GetDestructableLife(gg_dest_DTg5_0000)
    call ModifyGateBJ( bj_GATEOPERATION_OPEN, gg_dest_DTg5_0000 )
    call ModifyGateBJ( bj_GATEOPERATION_OPEN, gg_dest_DTg5_0000 )
    call SetDestructableAnimationBJ( gg_dest_DTg5_0000, "Morph" )
endfunction

//===========================================================================
function InitTrig_Open_Gate takes nothing returns nothing
    set gg_trg_Open_Gate = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Open_Gate, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Open_Gate, Condition( function Trig_Open_Gate_Conditions ) )
    call TriggerAddAction( gg_trg_Open_Gate, function Trig_Open_Gate_Actions )
endfunction



Close Gate
JASS:
function Trig_Close_Gate_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00A' ) ) then
        return false
    endif
    if ( not ( GetSpellAbilityUnit() == gg_unit_n002_0013 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Close_Gate_Actions takes nothing returns nothing
    set udg_GateOpen = 0
    call SetDestructableLife( gg_dest_DTg5_0000, udg_NWBGateHP )
    call ModifyGateBJ( bj_GATEOPERATION_CLOSE, gg_dest_DTg5_0000 )
    call SetDestructableAnimationBJ( gg_dest_DTg5_0000, "Morph Alternate" )
endfunction

//===========================================================================
function InitTrig_Close_Gate takes nothing returns nothing
    set gg_trg_Close_Gate = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Close_Gate, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Close_Gate, Condition( function Trig_Close_Gate_Conditions ) )
    call TriggerAddAction( gg_trg_Close_Gate, function Trig_Close_Gate_Actions )
endfunction

Repair Gate
JASS:
function Trig_Repair_Gate_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00D' ) ) then
        return false
    endif
    if ( not ( GetSpellAbilityUnit() == gg_unit_n002_0013 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Repair_Gate_Func001C takes nothing returns boolean
    if ( not ( udg_GateOpen == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Repair_Gate_Actions takes nothing returns nothing
    if ( Trig_Repair_Gate_Func001C() ) then
        call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(gg_unit_n002_0013)), "TRIGSTR_246" )
    else
        set udg_NWBRepair = GetDestructableLife(gg_dest_DTg5_0000)
        call PauseUnitBJ( true, gg_unit_n002_0013 )
        call EnableTrigger( gg_trg_Repair_Gate_Timer )
    endif
endfunction

//===========================================================================
function InitTrig_Repair_Gate takes nothing returns nothing
    set gg_trg_Repair_Gate = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Repair_Gate, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Repair_Gate, Condition( function Trig_Repair_Gate_Conditions ) )
    call TriggerAddAction( gg_trg_Repair_Gate, function Trig_Repair_Gate_Actions )
endfunction

Repair Gate Timer (Not initially on)
JASS:
function Trig_Repair_Gate_Timer_Func003001 takes nothing returns boolean
    return ( udg_NWBRepair >= 10000.00 )
endfunction

function Trig_Repair_Gate_Timer_Actions takes nothing returns nothing
    set udg_NWBRepair = ( udg_NWBRepair + 100.00 )
    call SetDestructableLife( gg_dest_DTg5_0000, udg_NWBRepair )
    loop
        exitwhen ( Trig_Repair_Gate_Timer_Func003001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.10))
    endloop
    call SetDestructableLifePercentBJ( gg_dest_DTg5_0000, 100 )
    set udg_NWBRepair = 0.00
    call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(gg_unit_n002_0013)), "TRIGSTR_237" )
    call PauseUnitBJ( false, gg_unit_n002_0013 )
    call DisableTrigger( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_Repair_Gate_Timer takes nothing returns nothing
    set gg_trg_Repair_Gate_Timer = CreateTrigger(  )
    call DisableTrigger( gg_trg_Repair_Gate_Timer )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Repair_Gate_Timer, 0.50 )
    call TriggerAddAction( gg_trg_Repair_Gate_Timer, function Trig_Repair_Gate_Timer_Actions )
endfunction

First of all I'd just like to say that I don't write in Jass, I just converted the codes to jass for easier copying (lazy me :grin:)

I'll upload a video later, to show how it looks like.
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Okay, I already wanted to say that your coding is really ugly, untill I read your last line :p (GUI is ugly).

Perhaps I could advise you an even quicker way to copy GUI-triggers though:

- Go to the trigger editor and select the trigger you wish to copy
- Above the events, right-click the trigger name and select "Copy as text"
- Write [trigger ] [/trigger] and then press CTRL + V between these tags

Congratulations, you now have a GUI trigger inside the hive and you don't need to waste my time figuring out converted GUI and your time converting the trigger.
 
Status
Not open for further replies.
Top