HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problems with custom-set alliances

07-21-2007, 10:45 PM#1
darkwulfv
Alright. I'm using player 13 for my neutrals since player 12 (Hostile) is stupid and can't have alliances set. Anyways, for some odd reason, all the alliances are successfully set... except for players 1-9 (in JASS terms. That's players 2-10 for those who don't know.) Here's my script.
The integer "i" is for the alliance settings 0-8, which upon setting them all to false, makes player A full enemies with Player B. It's repeated so Player B is full enemies with player A. The first loop is for human players 0-9, and the second loop is for players 10 + 11 (dark green and brown), whom are computers. My issue here is that only player(0) is affected by the alliance changes. Players 10 + 11 are also, but those are seperate loops. The BjDebugMsg returns that the loop is going through all the players, but for some reason, units owned by player 13 only auto-aquire to Player 0, not players 1-9. But players 1-9 can target and kill them. Can anyone help?

Collapse JASS:
function Set_Extra_Alliances_Actions takes nothing returns nothing
    local integer i = 0
    local integer i2 = 0
    loop
        exitwhen i2 > 9
        call BJDebugMsg("Player " + I2S(i2) + ", setting alliances")
        call SetPlayerAlliance(Player(i2), Player(13), ConvertAllianceType(i), false)
        call SetPlayerAlliance(Player(13), Player(i2), ConvertAllianceType(i), false)
        if i < 8 then
        set i = i + 1
        endif
        set i2 = i2 + 1
    endloop

set i = 0

   loop
   exitwhen i > 5
       call SetPlayerAlliance(Player(10), Player(13), ConvertAllianceType(i), true)
       call SetPlayerAlliance(Player(11), Player(13), ConvertAllianceType(i), true)
       call SetPlayerAlliance(Player(13), Player(10), ConvertAllianceType(i), true)
       call SetPlayerAlliance(Player(13), Player(11), ConvertAllianceType(i), true)
   set i = i + 1
   endloop
endfunction
//===========================================================================
function InitTrig_Set_Extra_Alliances takes nothing returns nothing
    call TimerStart(CreateTimer(), .02, false, function Set_Extra_Alliances_Actions)
endfunction
07-22-2007, 01:52 AM#2
Naakaloh
You're changing the alliancetype each iteration, but only changing one alliancetype per player...

So Player 0 gets alliancetype 0, Player 1 gets alliancetype 1... etc...

You'll want something like this...

Collapse JASS:
    loop
        exitwhen i2 > 9
        call BJDebugMsg("Player " + I2S(i2) + ", setting alliances")
        loop
             exitwhen i > 8
             call SetPlayerAlliance(Player(i2), Player(13), ConvertAllianceType(i), false)
             call SetPlayerAlliance(Player(13), Player(i2), ConvertAllianceType(i), false)
             set i = i + 1
        endloop
        set i = 0
        set i2 = i2 + 1
    endloop

07-22-2007, 04:45 AM#3
darkwulfv
Oooohh, that makes sense. Thanks, +rep for you.