• 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.

[JASS] Multiboard Display for Each Player

Status
Not open for further replies.
Level 4
Joined
Jun 8, 2007
Messages
89
So, I have been working on a map recently in which a player can get many different kinds of resources (lumber, food, oil, ect...). The problem lies in how I am to display these resources. At first I thought of using a multiboard to display all of the data, but it appears that one multiboard cannot be shown to only one player.

Is there any way to make each player see a different multiboard, or maybe a way to show different values for each player? If not, then it would be nice if someone could help me find another way. :wink:

Thanks in advance.
 
Level 2
Joined
Feb 24, 2007
Messages
37
You could make a multiboard array, for each player one multiboard then do:

JASS:
if GetLocalPlayer() == Player(*Your Player*) then
call MultiboardDisplay(*The Players Multiboard*, true)
endif


For example:

JASS:
local integer counter = 0
loop
exitwhen counter > 6 //Lets say player 5 is the last player 
if GetLocalPlayer() == Player(counter) then
call MultiboardDisplay(udg_Multiboard[counter], true)
endif
set counter = counter + 1
endloop


Though im not sure if it causes desync. My guess is that it doesnt.
 
Last edited:
Level 4
Joined
Jun 8, 2007
Messages
89
Sweet, thanks. Odd though, I tried that, but when I did, it showed up for everybody. Why does this work now? :hohum:

*Edit*
So, this seems to work; however, now i get an error in this function "hit op limit in". It used to tell me that it was on the line "call MultiboardSetItemWidthBJ(udg_mbEmpData, 1, j, 7.5)", but stopped doing so while I was trying to fix it. Any help would be greatly appreciated.

JASS:
function Trig_initEmpData_Actions takes nothing returns nothing
    local integer i = 0
    local integer j
    
    loop
        exitwhen i > 9
        
            // ensure the player exists
        if (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) then
            call CreateMultiboardBJ( 2, 12, GetPlayerName(ConvertedPlayer(i+1)) + "'s Statistics" )
            set udg_mbEmpData[i] = GetLastCreatedMultiboard()
        
            set j = 1
            loop 
                exitwhen j > 12
                    // formatting
                call MultiboardSetItemStyleBJ(udg_mbEmpData[i], 1, j, true, false)
                call MultiboardSetItemStyleBJ(udg_mbEmpData[i], 2, j, true, false)
                call MultiboardSetItemWidthBJ(udg_mbEmpData[i], 1, j, 7.5)
                call MultiboardSetItemWidthBJ(udg_mbEmpData[i], 2, j, 4.0)
            
                set j = j + 1
            endloop
                
                // set colors
            call MultiboardSetItemColorBJ(udg_mbEmpData[i], 1, 1, 25, 25, 175, 0)
            call MultiboardSetItemColorBJ(udg_mbEmpData[i], 1, 2, 15, 15, 215, 0)
            call MultiboardSetItemColorBJ(udg_mbEmpData[i], 1, 3, 250, 25, 25, 0)
            call MultiboardSetItemColorBJ(udg_mbEmpData[i], 1, 1, 25, 25, 175, 0)
            call MultiboardSetItemColorBJ(udg_mbEmpData[i], 1, 6, 25, 25, 175, 0)
            
                // set labels
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 1, "Hero" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 2, "Lives:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 3, "Attributes:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 4, "Skill Points:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 5, " " )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 6, "Empire:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 7, "Happiness:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 8, "Population:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 9, "Food:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 10, "Lumber:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 11, "Ore:" )
            call MultiboardSetItemValueBJ( udg_mbEmpData[i], 1, 12, "Oil:" )
            set i = i + 1
        endif
    endloop
endfunction

//===========================================================================
function InitTrig_initMulti takes nothing returns nothing
    set gg_trg_initMulti = CreateTrigger(  )
    call TriggerAddAction( gg_trg_initMulti, function Trig_initEmpData_Actions )
endfunction
 
Last edited:
Level 2
Joined
Feb 24, 2007
Messages
37
My bad should have been >.

The OP limit means too much is done at the same time wich might create lag. You could add short waits.

Though i dont think it really matters as long as you dont run this every 0.01s.
 
Level 4
Joined
Jun 8, 2007
Messages
89
Hatred, your trigger makes no sense. You exit the loop when counter < 6. Since it starts at 0, the actions inside shouldn't even ever happen...

Yeah, figured as much, but hey, we all make mistakes... Thats why I'm here in the first place. :xxd:

My bad should have been >.

The OP limit means too much is done at the same time wich might create lag. You could add short waits.

Though i dont think it really matters as long as you dont run this every 0.01s.

Dang, I assumed that the game would have crashed had I run it without war3err, as thats what it did last time i got this error. Guess I should have checked. :thumbs_up:

Thanks
 
Level 11
Joined
Aug 25, 2006
Messages
971
The reason you hit the op limit is because your set i = i + 1 is within the if statement. (meaning if the if statement is false, it'll become an infinite loop) So if your not using war3err it causes a computer freeze/thread crash

The op - limit means that too many 'threads' are being run at the same time. Its variable how many threads you can reach, but I hear its pretty high. The only reason you should hit the op limit is if you have an infinite loop. (Or your doing a super massive loop)
 
Level 4
Joined
Jun 8, 2007
Messages
89
The reason you hit the op limit is because your set i = i + 1 is within the if statement. (meaning if the if statement is false, it'll become an infinite loop) So if your not using war3err it causes a computer freeze/thread crash

The op - limit means that too many 'threads' are being run at the same time. Its variable how many threads you can reach, but I hear its pretty high. The only reason you should hit the op limit is if you have an infinite loop. (Or your doing a super massive loop)

Oh my... I didn't even mean to put it in there... Thank you for pointing that out.
By the way, I've been adding rep to those that help. :thumbs_up:

*EDIT*
Also, new question. Hehe.I'm attempting to make it so that a hero can select attributes to increase each time he levels. As of now, I have an ability based off of spell book that holds three abilities (Strength Agility, Intelligence). I then made three functions to detect the usage of these abilities and increase the stats. When I set the variable used to hold the number of free attribute points to two, and use the skills in game, I always am immediately given +1 str and +1 agi (using up both attribute points). Obviously, I want it to just spend one point on one ability (preferably the one I picked :eek:).

I hope my mistake isn't so obvious as to be wasting your time. As always, help is greatly appreciated.

Here are the three triggers:

Strength
JASS:
function Trig_hStrength_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A007' )
endfunction

function Trig_hStrength_Actions takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local integer plyr = GetConvertedPlayerId(GetOwningPlayer(u)) - 1
    
    call SetUnitPosition(u, GetUnitX(u), GetUnitY(u))
    
    if (udg_intAttributes[plyr] > 0) then
        call SetHeroStr(u, GetHeroStr(u, false) + 1, true)
        set udg_intAttributes[plyr] = udg_intAttributes[plyr] - 1
    endif
    
    set u = null
endfunction

//===========================================================================
function InitTrig_hStrength takes nothing returns nothing
    set gg_trg_hStrength = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_hStrength, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_hStrength, Condition( function Trig_hStrength_Conditions ) )
    call TriggerAddAction( gg_trg_hStrength, function Trig_hStrength_Actions )
endfunction

Agility
JASS:
function Trig_hAgility_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A002' )
endfunction

function Trig_hAgility_Actions takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local integer plyr = GetConvertedPlayerId(GetOwningPlayer(u)) - 1
    
    call SetUnitPosition(u, GetUnitX(u), GetUnitY(u))
    
    if (udg_intAttributes[plyr] > 0) then
        call SetHeroAgi(u, GetHeroAgi(u, false) + 1, true)
        set udg_intAttributes[plyr] = udg_intAttributes[plyr] - 1
    endif
    
    set u = null
endfunction

//===========================================================================
function InitTrig_hAgility takes nothing returns nothing
    set gg_trg_hAgility = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_hAgility, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_hAgility, Condition( function Trig_hAgility_Conditions ) )
    call TriggerAddAction( gg_trg_hAgility, function Trig_hAgility_Actions )
endfunction

Intelligence
JASS:
function Trig_hIntelligence_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A008' )
 endfunction

function Trig_hIntelligence_Actions takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local integer plyr = GetConvertedPlayerId(GetOwningPlayer(u)) - 1
    
    call SetUnitPosition(u, GetUnitX(u), GetUnitY(u))
    
    if (udg_intAttributes[plyr] > 0) then
        call SetHeroInt(u, GetHeroInt(u, false) + 1, true)
        set udg_intAttributes[plyr] = udg_intAttributes[plyr] - 1
    endif
    
    set u = null
endfunction

//===========================================================================
function InitTrig_hIntelligence takes nothing returns nothing
    set gg_trg_hIntelligence = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_hIntelligence, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_hIntelligence, Condition( function Trig_hIntelligence_Conditions ) )
    call TriggerAddAction( gg_trg_hIntelligence, function Trig_hIntelligence_Actions )
endfunction
 
Level 11
Joined
Aug 25, 2006
Messages
971
I'm reading through.
I gather the SetUnitPosition is supposed to cancel orders?
Instead use
JASS:
call IssueImmediateOrder( GetSpellAbilityUnit(), "stop" )

So let me get this straight. When you set udg_intAttributes[plyr] to 2. Its instantly used and you get +1 str and +1agi ???

Wait! I think I know your problem. Are the +agi, +int, +str based off of the same ability? Because if thats the case clicking that ability will activate ALL copies of the ability. This is because they have the same orderID. You can only change the orderID of the spell Channel, and Spellbook.
 
Level 4
Joined
Jun 8, 2007
Messages
89
I'm reading through.
I gather the SetUnitPosition is supposed to cancel orders?
Instead use
JASS:
call IssueImmediateOrder( GetSpellAbilityUnit(), "stop" )

So let me get this straight. When you set udg_intAttributes[plyr] to 2. Its instantly used and you get +1 str and +1agi ???

Wait! I think I know your problem. Are the +agi, +int, +str based off of the same ability? Because if thats the case clicking that ability will activate ALL copies of the ability. This is because they have the same orderID. You can only change the orderID of the spell Channel, and Spellbook.

Yeah, that seems to have been my problem, but now when I try to use the channel based ability, he just stands there playing his cast animation over and over again, and not allowing me to issue him any orders.

Thanks

*EDIT*
Hehe... Nevermind. Another stupid mistake on my part.:hohum:
 
Status
Not open for further replies.
Top