Creating a Multiboard in JASS

NeuroToxin

New Member
Reaction score
46
I realize how to create it and such, but can anyone explain the basics of creating, well, heres my trigger,
JASS:

library CustomMultiboard initializer Init

    globals
//The number of teams on the multiboard. Can be increased or decreased to set more teams.
        private constant integer NUM_TEAMS = 5
//The number of players to be displayed on the multiboard.
        private constant integer NUM_PLAYERS = 10
//The number of rows to have.
        private constant integer NUM_ROWS = (NUM_PLAYERS + NUM_TEAMS) + 3
//The number of columns to have.
        private constant integer NUM_COLUMNS = 20
//If true, will show each player the same multiboard
        private constant boolean SHOW_FOR_ENEMIES = false
//The number of heroes using this multiboard
        private constant integer NUM_HEROES = 1
//The heroes global, only thing required with this is the number of heroes you're using. To edit the
//unit types look for the function below called SETTING_HEROES
        private constant integer array HEROES[NUM_HEROES]
//Same as above.
        private constant string array HERO_ICONS[NUM_HEROES]
//The decision to show or hide hero icons.
        private constant boolean SHOW_HERO_ICONS = true
    endglobals
    
    private function SETTING_HEROES takes nothing returns nothing
        set HEROES[1] = 'Hamg'
        set HERO_ICONS[1] = "ReplaceableTextures\\CommandButtons\\BTNHeroArchMage.blp"
    endfunction
    
    private function Setup takes nothing returns nothing
    local multiboard m = CreateMultiboard()
    local integer i = 0
    local integer row = 1
    call MultiboardClear(m)
    call MultiboardDisplay( m, true)
    call MultiboardSetColumnCount(m, NUM_COLUMNS)
    call MultiboardSetRowCount(m, NUM_ROWS)
    loop
        call MultiboardSetItemIconBJ( m, 0, row, HERO_ICONS<i>)
        set i = i + 1
        exitwhen i == NUM_HEROES
    endloop
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        call TriggerAddAction( t, function Setup )
    endfunction
endlibrary
</i>


I'm trying to create a custom multiboard, like you can set it up at anytime, anything, however, I need help with the number of rows, and when theres columns, I need it to follow the number of things they have. For example, say that they have kills/deaths enabled, then it adds two columns. I also need help setting the number of rows. In the setup, I'm gonna have a lot of if's, considering I need one for every single boolean I have. Like, how many columns for a players name? (Like space) how many columns for things, how do I get the correct amount of columns? Questions like that, the setup of a FULLY CUSTOMIZABLE multiboard. Like, EVERYTHING is multiboard.
 

Risen

New Member
Reaction score
4
I used to think multiboards were complex, but I was just too lazy to analyze it.

Maybe it's just the red-colored TESH font color from BJ natives

I started using these 2 functions and the problem went away.

JASS:
private function SetItem takes integer row, integer col, string text returns nothing
    local multiboarditem mbi = MultiboardGetItem( MyMultiboard, row, col )
        call MultiboardSetItemValue( mbi, text)
        call MultiboardReleaseItem( mbi )
    set mbi = null
endfunction

private function SetStyle takes integer i, integer place, real width returns nothing
    local multiboarditem mbi = MultiboardGetItem(MyMultiboard, i, place)
        call MultiboardSetItemStyle( mbi, true, false )
        call MultiboardSetItemWidth( mbi, width )
        call MultiboardReleaseItem(mbi)
    set mbi = null
endfunction


With these two functions, I can do:

JASS:
private function MultiboardCreation takes nothing returns nothing
    local integer i = 0
    local string s = &quot;|R&quot;
    set MyMultiboard = CreateMultiboard()
    call MultiboardSetColumnCount(MyMultiboard, 3)
    call MultiboardSetRowCount(MyMultiboard, 7)
    call MultiboardSetTitleText(MyMultiboard, &quot;Game Modes&quot;)
    
    loop
        call SetStyle( i, 0, 0.13 )
        call SetStyle( i, 1, 0.4 )
        call SetStyle( i, 2, 0.2 )
        exitwhen i == 7 //desired maximum rows
        set i = i + 1
    endloop
    
    call SetItem( 0, 0, GOLDCOLOR + &quot;Option&quot; + s)
    call SetItem( 0, 1, GOLDCOLOR + &quot;Input Value&quot; + s)
    call SetItem( 0, 2, GOLDCOLOR + &quot;Current Value&quot; + s)

    call SetItem( 1, 0, PURPLECOLOR + &quot;Game Mode&quot; + s)
    call SetItem( 1, 1, PURPLECOLOR + &quot;| -Lifes | -Rounds | -Last Man Standing | &quot; + s)
    call SetItem( 1, 2, PURPLECOLOR + &quot;- &quot; + &quot;|r&quot;)
    
    call MultiboardDisplay(MyMultiboard, true)

endfunction

Dumbed down, this multiboard allows for easy game mode selection by showing what it is in row one, what the commands are in row two, and the current value in row 3.

Each time a player types in a valid command, I add another row to the multiboard for further options.

If you don't get why I posted this; those two functions will make things a lot more simpler and easier on your eyes.

Also, if you have any questions or if I didn't cover something that you asked, just tell me and I'll try to answer.
 

NeuroToxin

New Member
Reaction score
46
A problem I'm having, is that I can't visualize where everything will be. And for example, I need to make it so players can have as many teams as needed, so if they need 10 teams, then there needs to be 10 names on the multiboard -
Team 1
Player 1
Team 2
Player 2
Team 3
Player 3
etc etc. And also, I have the icons for their heroes too, as a boolean of course.

Also, my main problem, is the above, but how do I know, when setting the heroes, (I plan on having the ability to have multiple hero icons.) icons, how do I skip one player if the teams are different. Say that for the above example, it suddenly changes to 3 teams, then it needs to be
Team 1
Player 1
Player 2
Player 3
Team 2
Player 4
Player 5
Player 6.

Which I'll need some math function for.

Maybe
JASS:
local integer i
local integer rowskips
set i = bj_MAX_PLAYER_SLOTS
set rowskips = i / NUM_TEAMS


Etc.
 

emjlr3

Change can be a good thing
Reaction score
395
maybe this can help get you started. its an old multiboard that i just added comments to. it may help to draw out what you want and label it.

JASS:
public function Create takes nothing returns nothing
    local integer i = 1
    local integer j
    local integer team = 1
    local integer play = 1
    
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig,Condition(function DeathConds))
    call TriggerAddAction(trig,function Death)
    
    set trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_HERO_LEVEL)
    call TriggerAddAction(trig,function LevelUp)
    
    // create new multiboard (mb)
    set MB = CreateMultiboard()
    
    // i want rows for every player in my map (rows are horizontal), plus 2 additional rows
    set rows = Total_Players+2
    // make my mb have that many rows
    call MultiboardSetRowCount(MB, rows)
    // i want 5 total columns, so make it so (columns are vertical)
    call MultiboardSetColumnCount(MB, 5)
    // title of the mb
    call MultiboardSetTitleText(MB,MapName+GREY+&quot; : &quot;+I2S(WinsNeeded)+&quot; Kills&quot;)
    // display it, this can also be for a localplayer if desired
    call MultiboardDisplay(MB, true)
    
    // using the bjs, rows/columns start at 1, using the natives they start at 0
    // loop through all of my columns, 1-5
    loop
        exitwhen i&gt;5
        // set their style as showing strings and not showing icons
        // the 0 as the row input selects all rows in that column
        call MultiboardSetItemStyleBJ(MB,i,0,true,false)
        // set up that columns color (r/g/b/t)
        call MultiboardSetItemColorBJ(MB, i, 0, 100, 80, 20, 33.00 )
        set i = i + 1
    endloop
    // starting with row 2, loop up to my last row and stop
    set i = 2
    loop
        exitwhen i&gt;rows-1
        // the 1 denotes column 1, i is the row, set the string in that row as the players name
        call MultiboardSetItemValueBJ(MB,1,i,PlayerNames[GetPlayerId(Players[i-1])])
        // i also want icons in column 1 on that row, so let it be so
        call MultiboardSetItemStyleBJ(MB,1,i,true,true)
        // heroes have not been selected yet, so this is the default icon used
        call MultiboardSetItemIconBJ(MB,1,i,&quot;ReplaceableTextures\\CommandButtons\\BTNSelectHeroOn.blp&quot;)
        // this is so I know that this particular players information is on this row, incase I need to update it sometime
        set players_row[GetPlayerId(Players[i-1])] = i
        set i = i + 1
    endloop
    // last row is for game time, so column 1 has the string &quot;Game Time&quot;
    call MultiboardSetItemValueBJ(MB,1,i,&quot;Game Time&quot;)    
    
    // different columns may need differend widths, depending on what they will say
    // column 1 needs to be wider because it has player names, and they can get big
    // the 0 selects all rows in that column
    call MultiboardSetItemWidthBJ(MB,1,0,9)
    call MultiboardSetItemWidthBJ(MB,2,0,5)
    call MultiboardSetItemWidthBJ(MB,3,0,6)
    call MultiboardSetItemWidthBJ(MB,4,0,5)
    call MultiboardSetItemWidthBJ(MB,5,0,5)
    // i want the mb to start off minimized, again, you can do this for a localplayer
    call MultiboardMinimize(MB,true)
    // for each column, 2-5, I want the starting values to all be a null string (nothing)
    call MultiboardSetItemValueBJ(MB,2,0,&quot;&quot;)
    call MultiboardSetItemValueBJ(MB,3,0,&quot;&quot;)
    call MultiboardSetItemValueBJ(MB,4,0,&quot;&quot;)
    call MultiboardSetItemValueBJ(MB,5,0,&quot;&quot;)
    // each column needs a title, here they are
    call MultiboardSetItemValueBJ(MB,1,1,&quot;|cffcdbe70Players|r&quot;)
    call MultiboardSetItemValueBJ(MB,2,1,&quot;|cffcdbe70Kills|r&quot;)
    call MultiboardSetItemValueBJ(MB,3,1,&quot;|cffcdbe70Deaths|r&quot;)
    call MultiboardSetItemValueBJ(MB,4,1,&quot;|cffcdbe70Spree|r&quot;)
    call MultiboardSetItemValueBJ(MB,5,1,&quot;|cffcdbe70Level|r&quot;)
    
    call MultiboardSetItemValueBJ( MB, 3, i,&quot;|c0020c000Total Kills Mode&quot; )
    
    call TimerStart(GetExpiredTimer(),1.,true,function Update)
endfunction
 

Risen

New Member
Reaction score
4
Just keep track of the total teams and which player is in which team.

Two integer arrays would do just fine.

You should probably have another section situated before or after the teams that would be named "undecided," or something, and just move the player to a different team by..

JASS:
globals
    private integer array Team
    private integer array CurrentTeam //Use to get rid of a player&#039;s previous spot in multiboard
    private integer array TotalInTeam //To decide how many rows to set for each slot in &quot;Team #.&quot;
    private integer TotalTeams = 0
endglobals

    ...
    ...

local integer DesiredTeam = S2I( Substring of something like &quot;-team 1&quot; )
local integer Pid = GetPlayerId( GetTriggerPlayer() )

    set TotalInTeam[CurrentTeam[Pid] = TotalInTeam[CurrentTeam[Pid] - 1
    set Team[Pid] = DesiredTeam
    set CurrentTeam[Pid] = DesiredTeam
    set TotalInTeam[DesiredTeam] = TotalInTeam[DesiredTeam] + 1 

    if (is new team...) then //you&#039;ll probably need to loop through each team until you reach TotalTeams and check if DesiredTeam == null
        set TotalTeams = TotalTeams + 1
    endif

Of course it's a rough, rough draft, but it should provide an idea of how you should/could do it.

As for the multiboard, every time that trigger is fired, re-do the multiboard entirely (possibly destroy) and re-do the list.

Example
JASS:
local integer LoopInt1 = 0
local integer LoopInt2 = 0
local integer LameName = 0
local integer i2 = 1

call SetItem( 0, 0, &quot;Team 1&quot; )

    loop
        exitwhen LoopInt1 == TotalTeams //Loop for each team
        
            loop
                exitwhen LoopInt2 == bj_MAX_PLAYERS //When it loops in each team slot, it checks for a player in the team
                   
                     if LameName &gt; TotalInTeam[i2] then //If all player slots in the team are set, skip to next spot 
                         call SetItem( i, 0, &quot;Team&quot; + I2S( LoopInt1 ) )
                         set LameName = 0 //Couldn&#039;t think of a better name =/ This keeps track of how many players have been detected in each team.
                     elseif Team[i2] == GetPlayerId( Player( LoopInt2 ) )
                         call SetItem( LoopInt1, 0, GetPlayerName( Player( LoopInt2 ) ) ) //Puts player&#039;s name in slot
                         set LameName = LameName + 1
                     endif
                     
                set LoopInt2 = LoopInt2 + 1
            endloop
        set LoopInt1 = LoopInt1 + 1
    endloop


Again, a rough draft. But it should pretty much cover it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top