• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Life bar multiboard request

Status
Not open for further replies.
Level 9
Joined
Apr 7, 2010
Messages
480
BUMP! :)

JASS:
library Multibars initializer InitMultibars

globals
    // ====================
    // PUBLIC CONSTANTS
    // ====================    
    
    // These constants should not be modified
    
    constant integer MULTIBAR_TYPE_HEALTH = 1
    constant integer MULTIBAR_TYPE_MANA = 2
    constant integer MULTIBAR_TYPE_EXPERIENCE = 3
    constant integer MULTIBAR_TYPE_BUILD = 4
    constant integer MULTIBAR_TYPE_CHUNK = 5
    constant integer MULTIBAR_TYPE_RADIO = 6
    constant integer MULTIBAR_TYPE_MAC = 7
    constant integer MULTIBAR_TYPE_ORANGE = 8
    constant integer MULTIBAR_TYPE_HEARTS = 9
    constant integer MULTIBAR_TYPE_HEARTS_UP = 10
    constant integer MULTIBAR_TYPE_MAGIC = 11
    
    
    // ====================
    // END PUBLIC CONSTANTS
    // ====================
    
    
    //Private Variables    
    
    private integer Gcurrent = 0        
    private string array Gbartype
    private string array Gfiletype
    private string array Gdir
    private integer array Gdivs     
      
endglobals

struct Multibar
    integer row
    integer colstart
    integer numcols
    integer numdivs
    real max
    real current
    string bartype
    string filetype
    string dir
    multiboard whichboard
    integer array curfill[16]

    static method create takes multiboard whichboard, integer colstart, integer row, integer size, real maxval, real currentval, integer bartype returns Multibar
        local Multibar b = Multibar.allocate()
        local integer i = 0
        set b.whichboard = whichboard
        if row > 32 then
            debug call BJDebugMsg("Multibars Error: Multiboards only have 32 rows!")
        elseif row < 0 then
            debug call BJDebugMsg("Multibars Error: Multiboards do not have negative rows!")
        endif
        set b.row = row
        set b. colstart = colstart
        if colstart > 16 then
            debug call BJDebugMsg("Multibars Error: Multiboards only have 16 columns")
        elseif colstart < 0 then
            debug call BJDebugMsg("Multibars Error: Multiboards do not have negative columns!")
        endif
        if size < 2 then
            debug call BJDebugMsg("Multibars Error: Bar size must be greater than 1!")
        elseif size > 16 then
            debug call BJDebugMsg("Multibars Error: Bar size must be less than 17!")
        endif
        set b.numcols = size
        set b.max = maxval
        if maxval < 0 then
            debug call BJDebugMsg("Multibars Error: Multibars does not support negative values!")
            set b.max = 1
        endif
        set b.current = currentval
        if currentval < 0 then
            debug call BJDebugMsg("Multibars Error: Multibars does not support negative values!")
            set b.current = 0
        elseif currentval > b.max then
            debug call BJDebugMsg("Multibars Error: Value cannot exceed max value!")
            set b.current = b.max
        endif
        if bartype > Gcurrent then
            debug call BJDebugMsg("Multibars Error: Invalid bartype!")
        endif
        set b.numdivs = Gdivs[bartype]
        set b.bartype = Gbartype[bartype]
        set b.filetype = Gfiletype[bartype]
        set b.dir = Gdir[bartype]
        loop
            exitwhen i > 15
            set b.curfill[i] = -1
            set i = i + 1
        endloop
        call b.SetMultiboardBar()
        call b.UpdateBoard()
        return b
    endmethod
    
    method onDestroy takes nothing returns nothing
        set .whichboard = null
    endmethod
    
    private method UpdateBoard takes nothing returns nothing
        local real step = .max/.numcols
        local real step2 = step/.numdivs
        local real val = .current
        local multiboarditem mbi
        local integer col = .colstart
        local integer num
        loop
            exitwhen val <= 0.
            if val >= step then
                if .curfill[col] != .numdivs then // check if it requires an update
                    set mbi = MultiboardGetItem(.whichboard, .row, col)
                    if col == .colstart then
                        call MultiboardSetItemIcon(mbi, .dir+.bartype+"L"+I2S(.numdivs)+.filetype) // Left
                    elseif col == .colstart+.numcols-1 then
                        call MultiboardSetItemIcon(mbi, .dir+.bartype+"R"+I2S(.numdivs)+.filetype) // Right
                    else
                        call MultiboardSetItemIcon(mbi, .dir+.bartype+"M"+I2S(.numdivs)+.filetype) // Middle
                    endif
                    call MultiboardReleaseItem(mbi)
                    set .curfill[col] = .numdivs
                endif
                set val = val - step
            else
                set num = R2I((val/step2)+0.5)
                if .curfill[col] != num then // check if it requires an update
                    set mbi = MultiboardGetItem(.whichboard, .row, col)
                    if col == .colstart then
                        call MultiboardSetItemIcon(mbi, .dir+.bartype+"L"+I2S(num)+.filetype) // Left
                    elseif col == .colstart+.numcols-1 then
                        call MultiboardSetItemIcon(mbi, .dir+.bartype+"R"+I2S(num)+.filetype) // Right
                    else
                        call MultiboardSetItemIcon(mbi, .dir+.bartype+"M"+I2S(num)+.filetype) // Middle
                    endif
                    call MultiboardReleaseItem(mbi)
                    set .curfill[col] = num
                endif
                set val = 0.
            endif
            set col = col + 1
        endloop
        loop
            exitwhen col >= .colstart + .numcols
            if .curfill[col] != 0 then // check if it requires an update
                set mbi = MultiboardGetItem(.whichboard, .row, col)
                if col == .colstart then
                    call MultiboardSetItemIcon(mbi, .dir+.bartype+"L0"+.filetype) // Left
                elseif col == .colstart+.numcols-1 then
                    call MultiboardSetItemIcon(mbi, .dir+.bartype+"R0"+.filetype) // Right
                else
                    call MultiboardSetItemIcon(mbi, .dir+.bartype+"M0"+.filetype) // Middle
                endif
                call MultiboardReleaseItem(mbi)
                set .curfill[col] = 0
            endif
            set col = col + 1
        endloop
        set mbi = null
    endmethod
    
    method UpdateValue takes real newvalue, boolean update returns nothing
        if newvalue > .max then
            set .current = .max
        elseif newvalue < 0. then
            set .current = 0.
        else
            set .current = newvalue
        endif
        if update then
            call .UpdateBoard()
        endif
    endmethod
    
    method UpdateMaxValue takes real newvalue, boolean update returns nothing
        if newvalue < 1 then
            set .max = 1
        else
            set .max = newvalue
        endif
        if .current > .max then
                set .current = .max
            endif
        if update then
            call .UpdateBoard()
        endif
    endmethod
    
    private method SetMultiboardBar takes nothing returns nothing
        local integer col = .colstart
        local integer end = col + .numcols
        local multiboarditem mbi
        loop
            exitwhen col >= end
            set mbi = MultiboardGetItem(.whichboard, .row, col)
            call MultiboardSetItemWidth(mbi, 0.01)
            call MultiboardSetItemStyle(mbi, false, true)
            call MultiboardReleaseItem(mbi)
            set col = col + 1
        endloop
        set mbi = null
    endmethod
endstruct

public function CreateBartype takes string name, string filetype, string directory, integer divisions returns integer
    set Gcurrent = Gcurrent + 1
    set Gbartype[Gcurrent] = name
    set Gfiletype[Gcurrent] = filetype
    set Gdir[Gcurrent] = directory
    set Gdivs[Gcurrent] = divisions
    return Gcurrent
endfunction

private function CreateNativeBartype takes integer bartype, string name, string filetype, string directory, integer divisions returns nothing
    if bartype > Gcurrent then
        set Gcurrent = bartype
    endif
    set Gbartype[bartype] = name
    set Gfiletype[bartype] = filetype
    set Gdir[bartype] = directory
    set Gdivs[bartype] = divisions
endfunction

private function InitMultibars takes nothing returns nothing    
    // Set-up Native Bartypes
    call CreateNativeBartype(MULTIBAR_TYPE_HEALTH, "Health", ".tga", "war3mapImported\\", 8)
    call CreateNativeBartype(MULTIBAR_TYPE_MANA, "Mana", ".tga", "war3mapImported\\", 8)
    call CreateNativeBartype(MULTIBAR_TYPE_EXPERIENCE, "Experience", ".tga", "war3mapImported\\", 8)
    call CreateNativeBartype(MULTIBAR_TYPE_BUILD, "Build", ".tga", "war3mapImported\\", 8)
    call CreateNativeBartype(MULTIBAR_TYPE_CHUNK, "Chunk", ".tga", "war3mapImported\\", 2)
    call CreateNativeBartype(MULTIBAR_TYPE_RADIO, "Radio", ".tga", "war3mapImported\\", 8)
    call CreateNativeBartype(MULTIBAR_TYPE_MAC, "Mac", ".tga", "war3mapImported\\", 8)
    call CreateNativeBartype(MULTIBAR_TYPE_ORANGE, "Orange", ".tga", "war3mapImported\\", 2)
    call CreateNativeBartype(MULTIBAR_TYPE_HEARTS, "ZeldaHearts", ".tga", "war3mapImported\\", 4)
    call CreateNativeBartype(MULTIBAR_TYPE_HEARTS_UP, "ZeldaHeartsUp", ".tga", "war3mapImported\\", 4)
    call CreateNativeBartype(MULTIBAR_TYPE_MAGIC, "ZeldaMagic", ".tga", "war3mapImported\\", 8)
endfunction

endlibrary

Problems with removing the other bars, also to double the width and length of the red bar.
 
Level 9
Joined
Apr 7, 2010
Messages
480
no, what i meant is wont the script itself cause errors since there are imported files required?

so how do i remove the things not related to the health bar?

u = For which unit
mb = which multiboard
u = variable
mb = variable too? mb = last created?

EDIT : http://www.hiveworkshop.com/forums/pastebin.php?id=fce6dd
border for loading screen, can i use this for border for health bar? although i extract this from warcraft 3 viewer, is it possible to use this ingame without importing to my map? in other words, im asking if this loading bar is built in warcraft and can already be used in warcraft editor?
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
Just because I want to make your map more awesome, I'm willing to share. Here's the system I'm using in my Powerslave map.

JASS:
library BossBoard initializer Init
    
    globals
        MultibarHelper MBH1
        MultibarHelper MBH2
        multiboard BOSSMB
    endglobals
    
    function BossBarStart takes unit u, string s returns nothing
        local multiboarditem mbi = MultiboardGetItem(BOSSMB, 0, 0)
        call MultiboardSetItemValue(mbi, GetHeroProperName(u) + " - " + GetUnitName(u))
        call MultiboardSetItemIcon(mbi, s)
        set MBH1 = MultibarHelper.create(u, BOSSMB, 0, 1, 12, MULTIBAR_TYPE_HEALTH, MULTIBAR_HELPER_HEALTH)
        set MBH2 = MultibarHelper.create(u, BOSSMB, 0, 2, 12, MULTIBAR_TYPE_MANA, MULTIBAR_HELPER_MANA)
        call MultiboardReleaseItem(mbi)
        set mbi = null
        call MultiboardDisplay(BOSSMB, true)
        //call MultiboardMinimize(BOSSMB, true)
        //call MultiboardMinimize(BOSSMB, false)
    endfunction
    
    function BossBarStop takes nothing returns nothing
        call MultiboardDisplay(BOSSMB, false)
        call MBH1.destroy()
        call MBH2.destroy()
    endfunction
    
    private function Init takes nothing returns nothing
        local multiboarditem mbi
        
        call TriggerSleepAction(0)
        
        set BOSSMB = CreateMultiboard()
        
        call MultiboardSetColumnCount(BOSSMB, 12)
        call MultiboardSetRowCount(BOSSMB, 3)
        
        call MultiboardSetTitleText(BOSSMB, "BOSS FIGHT")
        call MultiboardSetTitleTextColor(BOSSMB, 252, 194, 0, 255)
        
        call MultiboardSetItemsStyle(BOSSMB, false, false)
        call MultiboardSetItemsWidth(BOSSMB, 0)
        
        set mbi = MultiboardGetItem(BOSSMB, 0, 0)
        call MultiboardSetItemStyle(mbi, true, true)
        call MultiboardSetItemValueColor(mbi, 255, 69, 0, 255)
        call MultiboardSetItemWidth(mbi, 0.14)
        call MultiboardReleaseItem(mbi)
        
        set mbi = null
    endfunction

endlibrary

Test trigger on how to use it:
  • Boss bar
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Execution count of (This trigger)) mod 2) Equal to 1
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: start
          • Set u = Blood Mage 0000 <gen>
          • Set s = ReplaceableTextures\CommandButtons\BTNHeroBloodElfPrince.blp
          • Custom script: call BossBarStart(udg_u, udg_s)
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: stop
          • Custom script: call BossBarStop()
You can not use the image you linked without lots of editing. You need to edit the images that belong to the system.
 
Status
Not open for further replies.
Top