• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Problems with conditions

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
This trigger does not spawn the units at all, and if I remove the Trig_Creep_Spawn_Func they spawn but don't move at all.

I would be grateful if someone can fix it.
(And I know it is poor made, I tried to rush it because its a long time since I last touched my map and I can't remember my own triggers xD)

JASS:
function Trig_Creep_Spawn_CondTA takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'h01M' )
endfunction

function Trig_Creep_Spawn_CondTB takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'h01L' )
endfunction

function Trig_Creep_Spawn_CondJaya takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'h01O' )
endfunction

function Trig_Creep_Spawn_CondFuyuki takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'h01N' )
endfunction

function Trig_Creep_Spawn_FuncTAD takes nothing returns boolean
    return ( CountUnitsInGroup(GetUnitsInRectMatching(gg_rct_TeamA_Down, Condition(function Trig_Creep_Spawn_CondTA))) == 0 )
endfunction

function Trig_Creep_Spawn_FuncTAR takes nothing returns boolean
    return ( CountUnitsInGroup(GetUnitsInRectMatching(gg_rct_TeamA_Right, Condition(function Trig_Creep_Spawn_CondTA))) == 0 )
endfunction

function Trig_Creep_Spawn_FuncTBL takes nothing returns boolean
    return ( CountUnitsInGroup(GetUnitsInRectMatching(gg_rct_TeamB_Left, Condition(function Trig_Creep_Spawn_CondTB))) == 0 )
endfunction

function Trig_Creep_Spawn_FuncTBU takes nothing returns boolean
    return ( CountUnitsInGroup(GetUnitsInRectMatching(gg_rct_TeamB_Up, Condition(function Trig_Creep_Spawn_CondTB))) == 0 )
endfunction

function Trig_Creep_Spawn_FuncJaya takes nothing returns boolean
    return ( CountUnitsInGroup(GetUnitsInRectMatching(gg_rct_Jaya_Creep, Condition(function Trig_Creep_Spawn_CondJaya))) == 0 )
endfunction

function Trig_Creep_Spawn_FuncFuyuki takes nothing returns boolean
    return ( CountUnitsInGroup(GetUnitsInRectMatching(gg_rct_Jaya_Creep, Condition(function Trig_Creep_Spawn_CondFuyuki))) == 0 )
endfunction

function Trig_Creep_Spawn_Actions takes nothing returns nothing
    local unit tempunit
    local real x = GetRectCenterX(gg_rct_TeamA_Down)
    local real y = GetRectCenterY(gg_rct_TeamA_Down)
    local real x2 = GetRectCenterX(gg_rct_1)
    local real y2 = GetRectCenterX(gg_rct_1)
    local integer i = 0
    
//=================== TeamA Down ===================
    if ( Trig_Creep_Spawn_FuncTAD() ) then
        set tempunit = CreateUnit(Player(14), 'h01Y', x, y, 270)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        set tempunit = CreateUnit(Player(14), 'h01Y', x, y, 270)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        call SetUnitUserData(tempunit, 1)
        loop
            set tempunit = CreateUnit(Player(14), 'h01X', x, y, 270)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            set tempunit = CreateUnit(Player(14), 'h01X', x, y, 270)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            call SetUnitUserData(tempunit, 1)
            set i = i + 1
        exitwhen (i == 3)
        endloop
    else
    endif
    
//=================== TeamA Right ===================
    set x = GetRectCenterX(gg_rct_TeamA_Right)
    set y = GetRectCenterY(gg_rct_TeamA_Right)
    set x2 = GetRectCenterX(gg_rct_01)
    set y2 = GetRectCenterX(gg_rct_01)
    set i = 0
    
    if ( Trig_Creep_Spawn_FuncTAR() ) then
        set tempunit = CreateUnit(Player(14), 'h01Y', x, y, 0)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        set tempunit = CreateUnit(Player(14), 'h01Y', x, y, 0)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        call SetUnitUserData(tempunit, 1)
        loop
            set tempunit = CreateUnit(Player(14), 'h01X', x, y, 0)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            set tempunit = CreateUnit(Player(14), 'h01X', x, y, 0)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            call SetUnitUserData(tempunit, 1)
            set i = i + 1
        exitwhen (i == 3)
        endloop
    else
    endif
    
//=================== TeamB Left ===================
    set x = GetRectCenterX(gg_rct_TeamB_Left)
    set y = GetRectCenterY(gg_rct_TeamB_Left)
    set x2 = GetRectCenterX(gg_rct_3)
    set y2 = GetRectCenterX(gg_rct_3)
    set i = 0
    
    if ( Trig_Creep_Spawn_FuncTBL() ) then
        set tempunit = CreateUnit(Player(14), 'h01W', x, y, 0)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        set tempunit = CreateUnit(Player(14), 'h01W', x, y, 0)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        call SetUnitUserData(tempunit, 1)
        loop
            set tempunit = CreateUnit(Player(14), 'h01V', x, y, 0)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            set tempunit = CreateUnit(Player(14), 'h01V', x, y, 0)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            call SetUnitUserData(tempunit, 1)
            set i = i + 1
        exitwhen (i == 3)
        endloop
    else
    endif
    
//=================== TeamB Up ===================
    set x = GetRectCenterX(gg_rct_TeamB_Up)
    set y = GetRectCenterY(gg_rct_TeamB_Up)
    set x2 = GetRectCenterX(gg_rct_05)
    set y2 = GetRectCenterX(gg_rct_05)
    set i = 0
    
    if ( Trig_Creep_Spawn_FuncTBU() ) then
        set tempunit = CreateUnit(Player(14), 'h01W', x, y, 0)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        set tempunit = CreateUnit(Player(14), 'h01W', x, y, 0)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        call SetUnitUserData(tempunit, 1)
        loop
            set tempunit = CreateUnit(Player(14), 'h01V', x, y, 0)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            set tempunit = CreateUnit(Player(14), 'h01V', x, y, 0)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            call SetUnitUserData(tempunit, 1)
            set i = i + 1
        exitwhen (i == 3)
        endloop
    else
    endif
    
//=================== Jaya ===================
    set x = GetRectCenterX(gg_rct_Jaya_Creep)
    set y = GetRectCenterY(gg_rct_Jaya_Creep)
    set x2 = GetRectCenterX(gg_rct_04)
    set y2 = GetRectCenterX(gg_rct_04)
    set i = 0
    
    if (GetOwningPlayer(udg_Jaya) == Player(bj_PLAYER_NEUTRAL_EXTRA) and Trig_Creep_Spawn_FuncJaya()) then
        set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'h024', x, y, 270)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'h024', x, y, 270)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        call SetUnitUserData(tempunit, 1)
        loop
            set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'h023', x, y, 270)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'h023', x, y, 270)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            call SetUnitUserData(tempunit, 1)
            set i = i + 1
        exitwhen (i == 3)
        endloop
    elseif (GetOwningPlayer(udg_Jaya) == Player(bj_PLAYER_NEUTRAL_VICTIM) and Trig_Creep_Spawn_FuncJaya()) then
        set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_VICTIM), 'h024', x, y, 270)
        call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamB_Base), GetRectCenterY(gg_rct_TeamB_Base))
        loop
            set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_VICTIM), 'h023', x, y, 270)
            call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamB_Base), GetRectCenterY(gg_rct_TeamB_Base))
            set i = i + 1
        exitwhen (i == 3)
        endloop
    elseif (GetOwningPlayer(udg_Jaya) == Player(PLAYER_NEUTRAL_AGGRESSIVE) and Trig_Creep_Spawn_FuncJaya()) then
        set tempunit = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'h024', x, y, 270)
        call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamB_Base), GetRectCenterY(gg_rct_TeamB_Base))
        loop
            set tempunit = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'h023', x, y, 270)
            call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamB_Base), GetRectCenterY(gg_rct_TeamB_Base))
            set i = i + 1
        exitwhen (i == 3)
        endloop
    endif

//=================== Fuyuki ===================
    set x = GetRectCenterX(gg_rct_Fuyuki_Creep)
    set y = GetRectCenterY(gg_rct_Fuyuki_Creep)
    set x2 = GetRectCenterX(gg_rct_01)
    set y2 = GetRectCenterX(gg_rct_01)
    set i = 0
    
    if (GetOwningPlayer(udg_Fuyuki) == Player(bj_PLAYER_NEUTRAL_VICTIM) and Trig_Creep_Spawn_FuncFuyuki()) then
        set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_VICTIM), 'h020', x, y, 180)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_VICTIM), 'h020', x, y, 180)
        call IssuePointOrder(tempunit, "attack", x2, y2)
        call SetUnitUserData(tempunit, 1)
        loop
            set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_VICTIM), 'h020', x, y, 180)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_VICTIM), 'h020', x, y, 180)
            call IssuePointOrder(tempunit, "attack", x2, y2)
            call SetUnitUserData(tempunit, 1)
            set i = i + 1
        exitwhen (i == 3)
        endloop
    elseif (GetOwningPlayer(udg_Fuyuki) == Player(bj_PLAYER_NEUTRAL_EXTRA) and Trig_Creep_Spawn_FuncFuyuki()) then
        set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'h01Z', x, y, 180)
        call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamA_Base), GetRectCenterY(gg_rct_TeamA_Base))
        loop
            set tempunit = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'h01Z', x, y, 180)
            call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamA_Base), GetRectCenterY(gg_rct_TeamA_Base))
            set i = i + 1
        exitwhen (i == 3)
        endloop
    elseif (GetOwningPlayer(udg_Fuyuki) == Player(PLAYER_NEUTRAL_AGGRESSIVE) and Trig_Creep_Spawn_FuncFuyuki()) then
        set tempunit = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'h024', x, y, 180)
        call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamA_Base), GetRectCenterY(gg_rct_TeamA_Base))
        loop
            set tempunit = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'h023', x, y, 180)
            call IssuePointOrder(tempunit, "attack", GetRectCenterX(gg_rct_TeamA_Base), GetRectCenterY(gg_rct_TeamA_Base))
            set i = i + 1
        exitwhen (i == 3)
        endloop
    endif

    set tempunit = null
endfunction

//===========================================================================
function InitTrig_Creep_Spawn takes nothing returns nothing
    set gg_trg_Creep_Spawn = CreateTrigger(  )
    call DisableTrigger( gg_trg_Creep_Spawn )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Creep_Spawn, 60.00 )
    call TriggerAddAction( gg_trg_Creep_Spawn, function Trig_Creep_Spawn_Actions )
endfunction
 
Status
Not open for further replies.
Top