HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

gotta be an easier way (MultiBars)

01-21-2008, 04:30 AM#1
SockSquirrelMouthwash
I figured this is more of a general jass thing rather than centered on the multibar thing. From where I left off at:
http://www.wc3campaigns.net/showthre...t=98138&page=2
at the bottom page, I first setup the multibars as:
Collapse JASS:
loop
        exitwhen i == 6
        set i = i + 1
        call GroupAddGroup(udg_activeunits, v)
        loop
            set u = FirstOfGroup(v)
            exitwhen u == null
    
            // Configure Multibars
            set n = GetConvertedPlayerId(GetOwningPlayer(u))
            set udg_outerhp[n] = 15000
            set hpbar[n+(i-1)*6] = Multibar.create(mboards[i], 1, r-1, 10, udg_outerhp[n], udg_outerhp[n], MULTIBAR_TYPE_RADIO)
            set udg_playerentry[n] = r
            set r = r + 1
            if GetOwningPlayer(u) == GetLocalPlayer() then
                call MultiboardDisplay( mboards[GetConvertedPlayerId(GetOwningPlayer(u))], true )
            endif
            call GroupRemoveUnit(v,u)
        endloop
        call DestroyGroup(v)
endloop
As you can see I'm storing all the multibar data into one 36 large array since there are 6 multiboards created for 6 players. Now the above mentioned code works fine and the multibars appear and are in working order, but then when I want to update the bars - this function is brought in:
Collapse JASS:
    local integer n = (GetConvertedPlayerId(GetOwningPlayer(z))-6)
    local unit u
    local group v = CreateGroup()
 
    set udg_outerhp[n] = udg_outerhp[n] - hit
    call ShowUnit(z, false)
    call ExplodeUnitBJ(z)

    call GroupAddGroup(udg_activeunits, v)
    loop
        set u = FirstOfGroup(v)
        exitwhen u == null
        set i = GetConvertedPlayerId(GetOwningPlayer(u))
        call hpbar[i+(n-1)*6].UpdateValue(udg_outerhp[n], true)
        call GroupRemoveUnit(v,u)
    endloop
    call DestroyGroup(v) 

    and so on...

When that function fires off, the multibars don't update at all.
Now I checked to make sure outerhp[n] was correctly updating and it is...

I'll try to make it more clear if need be

Any suggestions?
01-21-2008, 05:07 AM#2
Ammorth
In your update trigger, try removing the -6 in the local integer n = (GetConvertedPlayerId(GetOwningPlayer(z))-6) line. I don't see why you would be doing this.
01-21-2008, 11:34 AM#3
SockSquirrelMouthwash
It's just simply the associated player number that goes with the unit z that's fed into the function. Z is the enemy unit of the computer of that particular player. Player 1-6 are users and players 7-12 are computers. Player 1 is computer 7, player 2 is computer 8, and so on... sorry about the confusion

I'm starting to wonder if the method of determining the correct hpbar[i] for each player's multiboard should even work

Update: I got the multibars at least updating - I was feeding a integer instead of a real value into the UpdateMultibar thing , but when it does update all the bars on my multibar move at the same time as if they were tracking the same thing instead of each individual player
01-21-2008, 02:22 PM#4
Ammorth
Flip your i and your n in the line where you update the multibars.
01-21-2008, 10:34 PM#5
SockSquirrelMouthwash
Well finally fixed it. But it was kinda unexpected but a head banging on the wall kinda thing when I found out.... udg_activeunits also included dead units... when I fixed the problem the multibars worked flawlessly... just kinda relieved it works now.

Thanks for the help anyhow! +rep