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 haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  4. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  5. 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] Why does the Trigger Stop

Discussion in 'Triggers & Scripts' started by chaoslord301, Feb 3, 2010.

  1. chaoslord301

    chaoslord301

    Joined:
    Sep 18, 2007
    Messages:
    105
    Resources:
    0
    Resources:
    0
    I have a trigger running on map initialization, I have 2 debug messages in this trigger, the first (1) works and appears after the initialization trigger action function is called, and the second (1a) is supposed to fire at the end of the intialization trigger action, but for some reason it doesn't. And when you see the comments like: "//Himiko", the above actions were just copied and pasted (the unit creation, adding to the group, and the loop).

    Init Trig
    Code (vJASS):
    globals
        group XiahouYuanUnits = CreateGroup()
        group HimikoUnits = CreateGroup()
        group GuoJiaUnits = CreateGroup()
        group LiDianUnits = CreateGroup()
        group YueJinUnits = CreateGroup()
        group LiuBeiUnits = CreateGroup()
        group GuanYuUnits = CreateGroup()
        group ZhangFeiUnits = CreateGroup()
            group MeiMeiUnits = CreateGroup()
            group LiLiUnits = CreateGroup()
        group MeiSanniangUnits = CreateGroup()
        group ZhaoYunUnits = CreateGroup()
    endglobals

    function Init_Actions takes nothing returns nothing
        local real x = GetRectCenterX(bj_mapInitialPlayableArea)
        local real y = GetRectCenterY(bj_mapInitialPlayableArea)

        //Xiahou Yuan
            call CreateUnit(Player(0), 'O003', x, y, x)
            call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Himiko
        call CreateUnit(Player(1), 'H00f', x, y, x)
        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guo Jia
        call CreateUnit(Player(2), 'H00E', x, y, x)
        call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Li Dian
        call CreateUnit(Player(3), 'H00H', x, y, x)
        call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Yue Jin
        call CreateUnit(Player(4), 'O005', x, y, x)
        call GroupAddUnit(YueJinUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Liu Bei
        call CreateUnit(Player(5), 'O004', x, y, x)
        call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guan Yu
        call CreateUnit(Player(6), 'H00G', x, y, x)
        call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhang Fei
        call CreateUnit(Player(7), 'O001', x, y, x)
        call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 30
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00D', x, y, x)
                    call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
            //Mei Mei
            call CreateUnit(Player(7), 'E001', x, y, x)
            call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                        call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
            //Li Li
            call CreateUnit(Player(7), 'N000', x, y, x)
            call GroupAddUnit(LiLiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
        //Mei Sanniang
        call CreateUnit(Player(8), 'E002', x, y, x)
        call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhao Yun
        call CreateUnit(Player(9), 'O002', x, y, x)
        call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
    call BJDebugMsg("Debug1a")
    endfunction

    //===========================================================================
    function InitTrig_Initialization takes nothing returns nothing
        local trigger Init = CreateTrigger()
        call TriggerAddAction( Init, function Init_Actions )
        call BJDebugMsg("Debug1")
    endfunction
     
    Last edited: Feb 4, 2010
  2. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    No wonder, you have to initialize your groups before using them.
    Code (vJASS):
    group  XiahouYuanUnits = CreateGroup()
     
  3. chaoslord301

    chaoslord301

    Joined:
    Sep 18, 2007
    Messages:
    105
    Resources:
    0
    Resources:
    0
    Ah, that's right, thanks.

    Edit: Still doesn't work
     
    Last edited: Feb 4, 2010
  4. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Have you considered arrays?
     
  5. chaoslord301

    chaoslord301

    Joined:
    Sep 18, 2007
    Messages:
    105
    Resources:
    0
    Resources:
    0
    The thought did occur to me, but for some idiotic reason I went against it.
     
  6. themerion

    themerion

    Joined:
    Jan 27, 2010
    Messages:
    132
    Resources:
    0
    Resources:
    0
    The trigger is never triggered, it has no event.

    Since you're using vJass, just omit the trigger and use a library with an Init function instead. That will also guarantee that the rest of your scripts can access the variables.

    Also, you're not supposed to call functions (like CreateGroup) in global blocks... Also, if you do too many function-calls in globals blocks, your Init-thread might crash.

    Code (vJASS):
    library JapanGroups initializer Init

    // .....

    private function Init takes nothing returns nothing
        call Init_Action()
    endfunction

    endlibrary
     
    Last edited: Feb 5, 2010
  7. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    ?!
    Wrong, ofcourse you can.
     
  8. themerion

    themerion

    Joined:
    Jan 27, 2010
    Messages:
    132
    Resources:
    0
    Resources:
    0
    Vexorian says can't:

    "...there is one limitation though, you can't use functions or non-constant values in the default value, for example you can make a global start on null, 1 , 19923 , 0xFFF, true, false, "Hi" , etc. But you can't make them initialize with any function call or with a native (although it is possible to use a native, most natives tend to crash the thread when used in globals declaration)."

    Source: JassHelper Manual
     
  9. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    Code (vJASS):
        native CreateGroup takes nothing returns group


    CreateGroup() is one of them. Don't blindly believe what others say unless you've tested it yourself.

    Code (vJASS):
    library Bla initializer init

        globals
            private group g = CreateGroup()
            private group g2
            private group g3
        endglobals
       
        function init takes nothing returns nothing
            if g != null then
                //Is displayed
                call BJDebugMsg("Initialized! #1")
            endif
           
            set g2 = CreateGroup()
            if g2 != null then
                //Is displayed aswell
                call BJDebugMsg("Initialized! #2")
            endif
           
            if g3 != null then
                //Isn't displayed
                call BJDebugMsg("Initialized! #3")
            endif
           
            //Isn't displayed aswell, because non-initialized variables will cause a thread crash when used.
            call BJDebugMsg("Finished")
        endfunction
       
    endlibrary

    To test it yourself if you don't believe me.
     
  10. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    You have always been able to use natives in global declarations. I have done it since the dawn of vJass.

    You shouldn't be so worried about the technicalities right now if you're not at good rhythm with them yet. Eventually it will come naturally to do things a certain way.
     
  11. themerion

    themerion

    Joined:
    Jan 27, 2010
    Messages:
    132
    Resources:
    0
    Resources:
    0
    Just to be clear:

    Just like the manual says, it is possible to use certain natives in global blocks. I said shouldn't, which is my interpretation of what is written in the manual.

    As it currently works, you might make the Init thread crash if you do it too much (causing map to be unplayable).

    Also, I personally find it a nice habit to assign all non-simple values in the Init-function, since that always will work. On the other hand, I can clearly see why people would prefer to init stuff like groups at declaration.

    PS. Sorry for 'abusing' the delete function. I figured it wouldn't matter since you didn't respond to my post at all anyway.
     
    Last edited: Feb 5, 2010
  12. chaoslord301

    chaoslord301

    Joined:
    Sep 18, 2007
    Messages:
    105
    Resources:
    0
    Resources:
    0
    Thanks for the suggestions, and themerion, you are close, Chinese names, not Japanese. But I still get an error, it says:

    Undeclared Function: Init_Action()
    Trigger
    Code (vJASS):

    library Groups initializer Init
    globals
        group XiahouYuanUnits = CreateGroup()
        group HimikoUnits = CreateGroup()
        group GuoJiaUnits = CreateGroup()
        group LiDianUnits = CreateGroup()
        group YueJinUnits = CreateGroup()
        group LiuBeiUnits = CreateGroup()
        group GuanYuUnits = CreateGroup()
        group ZhangFeiUnits = CreateGroup()
            group MeiMeiUnits = CreateGroup()
            group LiLiUnits = CreateGroup()
        group MeiSanniangUnits = CreateGroup()
        group ZhaoYunUnits = CreateGroup()
    endglobals

    private function Init takes nothing returns nothing
        call Init_Action()
    endfunction
    endlibrary

    function Init_Action takes nothing returns nothing
        local real x = GetRectCenterX(bj_mapInitialPlayableArea)
        local real y = GetRectCenterY(bj_mapInitialPlayableArea)

        //Xiahou Yuan
            call CreateUnit(Player(0), 'O003', x, y, x)
            call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Himiko
        call CreateUnit(Player(1), 'H00f', x, y, x)
        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guo Jia
        call CreateUnit(Player(2), 'H00E', x, y, x)
        call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Li Dian
        call CreateUnit(Player(3), 'H00H', x, y, x)
        call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Yue Jin
        call CreateUnit(Player(4), 'O005', x, y, x)
        call GroupAddUnit(YueJinUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Liu Bei
        call CreateUnit(Player(5), 'O004', x, y, x)
        call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guan Yu
        call CreateUnit(Player(6), 'H00G', x, y, x)
        call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhang Fei
        call CreateUnit(Player(7), 'O001', x, y, x)
        call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 30
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00D', x, y, x)
                    call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
            //Mei Mei
            call CreateUnit(Player(7), 'E001', x, y, x)
            call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                        call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
            //Li Li
            call CreateUnit(Player(7), 'N000', x, y, x)
            call GroupAddUnit(LiLiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
        //Mei Sanniang
        call CreateUnit(Player(8), 'E002', x, y, x)
        call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhao Yun
        call CreateUnit(Player(9), 'O002', x, y, x)
        call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
    call BJDebugMsg("Debug1a")
    endfunction

    //===========================================================================
    function InitTrig_Initialization takes nothing returns nothing
        local trigger Init = CreateTrigger()
        call TriggerAddAction( Init, function Init_Action )
        call BJDebugMsg("Debug1")
    endfunction
     
  13. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    Because your initializer says the name should be "Init" whilt it's "Init_Action"
     
  14. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    its because of your wrong placement of the endlibrary... also you cannot call a function that is below the line where you used call XX (I mean Init should be placed below Init_Action)... here see this...

    CODE

    Code (vJASS):

    library Groups initializer Init
    globals
        group XiahouYuanUnits = CreateGroup()
        group HimikoUnits = CreateGroup()
        group GuoJiaUnits = CreateGroup()
        group LiDianUnits = CreateGroup()
        group YueJinUnits = CreateGroup()
        group LiuBeiUnits = CreateGroup()
        group GuanYuUnits = CreateGroup()
        group ZhangFeiUnits = CreateGroup()
            group MeiMeiUnits = CreateGroup()
            group LiLiUnits = CreateGroup()
        group MeiSanniangUnits = CreateGroup()
        group ZhaoYunUnits = CreateGroup()
    endglobals

    function Init_Action takes nothing returns nothing
        local real x = GetRectCenterX(bj_mapInitialPlayableArea)
        local real y = GetRectCenterY(bj_mapInitialPlayableArea)

        //Xiahou Yuan
            call CreateUnit(Player(0), 'O003', x, y, x)
            call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Himiko
        call CreateUnit(Player(1), 'H00f', x, y, x)
        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guo Jia
        call CreateUnit(Player(2), 'H00E', x, y, x)
        call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Li Dian
        call CreateUnit(Player(3), 'H00H', x, y, x)
        call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Yue Jin
        call CreateUnit(Player(4), 'O005', x, y, x)
        call GroupAddUnit(YueJinUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Liu Bei
        call CreateUnit(Player(5), 'O004', x, y, x)
        call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guan Yu
        call CreateUnit(Player(6), 'H00G', x, y, x)
        call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhang Fei
        call CreateUnit(Player(7), 'O001', x, y, x)
        call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 30
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00D', x, y, x)
                    call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
            //Mei Mei
            call CreateUnit(Player(7), 'E001', x, y, x)
            call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                        call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
            //Li Li
            call CreateUnit(Player(7), 'N000', x, y, x)
            call GroupAddUnit(LiLiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
        //Mei Sanniang
        call CreateUnit(Player(8), 'E002', x, y, x)
        call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhao Yun
        call CreateUnit(Player(9), 'O002', x, y, x)
        call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
    call BJDebugMsg("Debug1a")
    endfunction


    private function Init takes nothing returns nothing
        call Init_Action()
    endfunction

    endlibrary //It should be placed here
     
     
  15. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    Why not simply set the initializer to Init_Action instead of this?!
     
  16. chaoslord301

    chaoslord301

    Joined:
    Sep 18, 2007
    Messages:
    105
    Resources:
    0
    Resources:
    0
    I went with Adiktuz's suggestion, it worked, and your's came up with a compile error(probably my fault, it was something with a prototype and Init_Action not taking anything from the library).

    But like the previous posts, whenever someone tells me a fix, another problem persists. The Heroes are created, but the units aren't. (The units are in the loops, maybe I shouldn't use the loops at the initialization?)

    Trigger
    Code (vJASS):
    library Groups initializer Init_Action
    globals
        group XiahouYuanUnits = CreateGroup()
        group HimikoUnits = CreateGroup()
        group GuoJiaUnits = CreateGroup()
        group LiDianUnits = CreateGroup()
        group YueJinUnits = CreateGroup()
        group LiuBeiUnits = CreateGroup()
        group GuanYuUnits = CreateGroup()
        group ZhangFeiUnits = CreateGroup()
            group MeiMeiUnits = CreateGroup()
            group LiLiUnits = CreateGroup()
        group MeiSanniangUnits = CreateGroup()
        group ZhaoYunUnits = CreateGroup()
    endglobals


    //endlibrary

    function Init_Action takes nothing returns nothing
        local real x = GetRectCenterX(bj_mapInitialPlayableArea)
        local real y = GetRectCenterY(bj_mapInitialPlayableArea)

        //Xiahou Yuan
            call CreateUnit(Player(0), 'O003', x, y, x)
            call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Himiko
        call CreateUnit(Player(1), 'H00f', x, y, x)
        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guo Jia
        call CreateUnit(Player(2), 'H00E', x, y, x)
        call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Li Dian
        call CreateUnit(Player(3), 'H00H', x, y, x)
        call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Yue Jin
        call CreateUnit(Player(4), 'O005', x, y, x)
        call GroupAddUnit(YueJinUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Liu Bei
        call CreateUnit(Player(5), 'O004', x, y, x)
        call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Guan Yu
        call CreateUnit(Player(6), 'H00G', x, y, x)
        call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhang Fei
        call CreateUnit(Player(7), 'O001', x, y, x)
        call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 30
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00D', x, y, x)
                    call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
            //Mei Mei
            call CreateUnit(Player(7), 'E001', x, y, x)
            call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                        call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
            //Li Li
            call CreateUnit(Player(7), 'N000', x, y, x)
            call GroupAddUnit(LiLiUnits, bj_lastCreatedUnit)
                set bj_forLoopAIndex = 1
                set bj_forLoopAIndexEnd = 10
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                        set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
                endloop
        //Mei Sanniang
        call CreateUnit(Player(8), 'E002', x, y, x)
        call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
        //Zhao Yun
        call CreateUnit(Player(9), 'O002', x, y, x)
        call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
            set bj_forLoopAIndex = 1
            set bj_forLoopAIndexEnd = 50
            loop
                exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
                    set bj_forLoopAIndex = (bj_forLoopAIndex + 1)
            endloop
    call BJDebugMsg("Debug1a")
    endfunction

    //===========================================================================
    //function InitTrig_Initialization takes nothing returns nothing
    //    local trigger Init = CreateTrigger()
    //    call TriggerAddAction( Init, function Init_Action )
    //    call BJDebugMsg("Debug1")
    //endfunction

    private function Init takes nothing returns nothing
        call Init_Action()
    endfunction
    endlibrary
     
  17. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    You should use your own integer variables (remember to set them to 0 at the beginning!) for the loops.
     
  18. chaoslord301

    chaoslord301

    Joined:
    Sep 18, 2007
    Messages:
    105
    Resources:
    0
    Resources:
    0
    Still nothing, would the thread be crashing from there being too much looping?

    Trigger
    Code (vJASS):
    library Groups initializer Init_Action
    globals
        group XiahouYuanUnits = CreateGroup()
        group HimikoUnits = CreateGroup()
        group GuoJiaUnits = CreateGroup()
        group LiDianUnits = CreateGroup()
        group YueJinUnits = CreateGroup()
        group LiuBeiUnits = CreateGroup()
        group GuanYuUnits = CreateGroup()
        group ZhangFeiUnits = CreateGroup()
            group MeiMeiUnits = CreateGroup()
            group LiLiUnits = CreateGroup()
        group MeiSanniangUnits = CreateGroup()
        group ZhaoYunUnits = CreateGroup()
    endglobals

    function Init_Action takes nothing returns nothing
        local real x = GetRectCenterX(bj_mapInitialPlayableArea)
        local real y = GetRectCenterY(bj_mapInitialPlayableArea)
        local integer int = 0
        local integer intend = 0
        //Xiahou Yuan
            call CreateUnit(Player(0), 'O003', x, y, x)
            call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(XiahouYuanUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Himiko
        call CreateUnit(Player(1), 'H00f', x, y, x)
        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Guo Jia
        call CreateUnit(Player(2), 'H00E', x, y, x)
        call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(GuoJiaUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Li Dian
        call CreateUnit(Player(3), 'H00H', x, y, x)
        call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Yue Jin
        call CreateUnit(Player(4), 'O005', x, y, x)
        call GroupAddUnit(YueJinUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Liu Bei
        call CreateUnit(Player(5), 'O004', x, y, x)
        call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(LiuBeiUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Guan Yu
        call CreateUnit(Player(6), 'H00G', x, y, x)
        call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(GuanYuUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Zhang Fei
        call CreateUnit(Player(7), 'O001', x, y, x)
        call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 30
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00D', x, y, x)
                    call GroupAddUnit(ZhangFeiUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
            //Mei Mei
            call CreateUnit(Player(7), 'E001', x, y, x)
            call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                set int = 1
                set intend = 10
                loop
                    exitwhen int > intend
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'e000', x, y, x)
                        call GroupAddUnit(MeiMeiUnits, bj_lastCreatedUnit)
                        set int = (int + 1)
                endloop
            //Li Li
            call CreateUnit(Player(7), 'N000', x, y, x)
            call GroupAddUnit(LiLiUnits, bj_lastCreatedUnit)
                set int = 1
                set intend = 10
                loop
                    exitwhen int > intend
                        call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                        call GroupAddUnit(HimikoUnits, bj_lastCreatedUnit)
                        set int = (int + 1)
                endloop
        //Mei Sanniang
        call CreateUnit(Player(8), 'E002', x, y, x)
        call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00B', x, y, x)
                    call GroupAddUnit(MeiSanniangUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
        //Zhao Yun
        call CreateUnit(Player(9), 'O002', x, y, x)
        call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    call CreateUnit(GetOwningPlayer(bj_lastCreatedUnit), 'h00C', x, y, x)
                    call GroupAddUnit(ZhaoYunUnits, bj_lastCreatedUnit)
                    set int = (int + 1)
            endloop
    call BJDebugMsg("Debug1")
    endfunction

    private function Init takes nothing returns nothing
        call Init_Action()
    endfunction
    endlibrary
     
  19. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    I see the problem, you're referencing bj_lastCreatedUnit, while the native CreateUnit doesn't overwrite this variable. Try this:

    Code (vJASS):
    library Groups initializer Init_Action
    globals
        group XiahouYuanUnits = CreateGroup()
        group HimikoUnits = CreateGroup()
        group GuoJiaUnits = CreateGroup()
        group LiDianUnits = CreateGroup()
        group YueJinUnits = CreateGroup()
        group LiuBeiUnits = CreateGroup()
        group GuanYuUnits = CreateGroup()
        group ZhangFeiUnits = CreateGroup()
            group MeiMeiUnits = CreateGroup()
            group LiLiUnits = CreateGroup()
        group MeiSanniangUnits = CreateGroup()
        group ZhaoYunUnits = CreateGroup()
    endglobals

    function Init_Action takes nothing returns nothing
        local real x = GetRectCenterX(bj_mapInitialPlayableArea)
        local real y = GetRectCenterY(bj_mapInitialPlayableArea)
        local integer int = 0
        local integer intend = 0
        local unit u
        //Xiahou Yuan
            set u = CreateUnit(Player(0), 'O003', x, y, x)
            call GroupAddUnit(XiahouYuanUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00B', x, y, x)
                    call GroupAddUnit(XiahouYuanUnits, u)
                    set int = (int + 1)
            endloop
        //Himiko
        set u = CreateUnit(Player(1), 'H00f', x, y, x)
        call GroupAddUnit(HimikoUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00C', x, y, x)
                    call GroupAddUnit(HimikoUnits, u)
                    set int = (int + 1)
            endloop
        //Guo Jia
        set u = CreateUnit(Player(2), 'H00E', x, y, x)
        call GroupAddUnit(GuoJiaUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00C', x, y, x)
                    call GroupAddUnit(GuoJiaUnits, u)
                    set int = (int + 1)
            endloop
        //Li Dian
        set u = CreateUnit(Player(3), 'H00H', x, y, x)
        call GroupAddUnit(LiDianUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, u)
                    set int = (int + 1)
            endloop
        //Yue Jin
        set u = CreateUnit(Player(4), 'O005', x, y, x)
        call GroupAddUnit(YueJinUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'e000', x, y, x)
                    call GroupAddUnit(LiDianUnits, u)
                    set int = (int + 1)
            endloop
        //Liu Bei
        set u = CreateUnit(Player(5), 'O004', x, y, x)
        call GroupAddUnit(LiuBeiUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00C', x, y, x)
                    call GroupAddUnit(LiuBeiUnits, u)
                    set int = (int + 1)
            endloop
        //Guan Yu
        set u = CreateUnit(Player(6), 'H00G', x, y, x)
        call GroupAddUnit(GuanYuUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00B', x, y, x)
                    call GroupAddUnit(GuanYuUnits, u)
                    set int = (int + 1)
            endloop
        //Zhang Fei
        set u = CreateUnit(Player(7), 'O001', x, y, x)
        call GroupAddUnit(ZhangFeiUnits, u)
            set int = 1
            set intend = 30
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00D', x, y, x)
                    call GroupAddUnit(ZhangFeiUnits, u)
                    set int = (int + 1)
            endloop
            //Mei Mei
            set u = CreateUnit(Player(7), 'E001', x, y, x)
            call GroupAddUnit(MeiMeiUnits, u)
                set int = 1
                set intend = 10
                loop
                    exitwhen int > intend
                        set u = CreateUnit(GetOwningPlayer(u), 'e000', x, y, x)
                        call GroupAddUnit(MeiMeiUnits, u)
                        set int = (int + 1)
                endloop
            //Li Li
            set u = CreateUnit(Player(7), 'N000', x, y, x)
            call GroupAddUnit(LiLiUnits, u)
                set int = 1
                set intend = 10
                loop
                    exitwhen int > intend
                        set u = CreateUnit(GetOwningPlayer(u), 'h00C', x, y, x)
                        call GroupAddUnit(HimikoUnits, u)
                        set int = (int + 1)
                endloop
        //Mei Sanniang
        set u = CreateUnit(Player(8), 'E002', x, y, x)
        call GroupAddUnit(MeiSanniangUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00B', x, y, x)
                    call GroupAddUnit(MeiSanniangUnits, u)
                    set int = (int + 1)
            endloop
        //Zhao Yun
        set u = CreateUnit(Player(9), 'O002', x, y, x)
        call GroupAddUnit(ZhaoYunUnits, u)
            set int = 1
            set intend = 50
            loop
                exitwhen int > intend
                    set u = CreateUnit(GetOwningPlayer(u), 'h00C', x, y, x)
                    call GroupAddUnit(ZhaoYunUnits, u)
                    set int = (int + 1)
            endloop
    call BJDebugMsg("Debug1")
        set u = null
    endfunction

    endlibrary
     
    Last edited: Feb 10, 2010
  20. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Code (vJASS):
        local real x = GetRectCenterX(bj_mapInitialPlayableArea)
        local real y = GetRectCenterY(bj_mapInitialPlayableArea)
        local integer int = 0
        local integer intend = 0
        unit u
     


    One of these things is not like the other one.

    Picture = Words * 1000
    [​IMG]