1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Problems with conditions

Discussion in 'Triggers & Scripts' started by Saishy, Oct 28, 2009.

  1. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    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)

    Code (vJASS):
    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