• 🏆 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] Why does the Trigger Stop

Status
Not open for further replies.
Level 4
Joined
Sep 18, 2007
Messages
104
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).

JASS:
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:
Level 4
Joined
Jan 27, 2010
Messages
133
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.

JASS:
library JapanGroups initializer Init

// .....

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

endlibrary
 
Last edited:
Level 4
Joined
Jan 27, 2010
Messages
133
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
 
Level 11
Joined
Apr 29, 2007
Messages
826
although it is possible to use a native
JASS:
    native CreateGroup takes nothing returns group

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

JASS:
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.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
 
Level 4
Joined
Jan 27, 2010
Messages
133
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:
Level 4
Joined
Sep 18, 2007
Messages
104
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()
JASS:
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
 
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...


JASS:
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
 
Level 11
Joined
Apr 29, 2007
Messages
826
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...


JASS:
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

Why not simply set the initializer to Init_Action instead of this?!
 
Level 4
Joined
Sep 18, 2007
Messages
104
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?)

JASS:
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
 
Level 4
Joined
Sep 18, 2007
Messages
104
Still nothing, would the thread be crashing from there being too much looping?

JASS:
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
 
Level 11
Joined
Apr 29, 2007
Messages
826
I see the problem, you're referencing bj_lastCreatedUnit, while the native CreateUnit doesn't overwrite this variable. Try this:

JASS:
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:
Level 18
Joined
Jan 21, 2006
Messages
2,552
JASS:
    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.

 
Status
Not open for further replies.
Top