• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Need help with Multiboard Color Refresh

Status
Not open for further replies.
Level 6
Joined
Feb 12, 2008
Messages
207
First.. ill explain... On my map i made a multiboard to display to each player with his status (shows % of life and mana)
Well... here it goes: Is there any other way to make a multiboard color to change depending on the % number (i mean... when the % is 100 it will be green, then at 90% will be green yellowish, then at 50 yellow, and at 0 would be RED... progressively...), that without using the large If/Then/Else triggering? if not... could there be any JASS code to make it?

my thanks to you in advance :)
 
Last edited:
Level 6
Joined
Feb 12, 2008
Messages
207
in RGB = 100% R, 100% G, 0% B

dont know how to do the formula by myself :p

and remember that multiboard item text color is editted in R, G and B percentage values
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Not true, the multibaord colour native takes values from 0-255 for every colour, including alpha.

JASS:
//
native MultiboardSetItemValueColor takes multiboarditem mbi,integer red,integer green,integer blue,integer alpha returns nothing
native MultiboardSetItemsValueColor takes multiboard lb,integer red,integer green,integer blue,integer alpha returns nothing
//

Anyway the formula is (for that native) for the red colour

JASS:
RMinBJ(255,R2I(510-510*p))

and for the green colour

JASS:
RMinBJ(255,R2I(510*p))

where p is the real (as in decimal) form of the hitpoint percentage (IE 1.0 = 100%HP and you use the 1.0 for p).
 
Level 6
Joined
Feb 12, 2008
Messages
207
oh... thats kinda difficult for me... i just began using JASS yesterday so im not that good xD
i think ill be using the long but useful If/Then/Else as busterkomo recommended xP

anyway thanks... i could use your code when im more familiar with JASS ^^

+rep
 
Level 6
Joined
Feb 12, 2008
Messages
207
yeah, just what i wanted to do :) ill keep it so i can implement it later :)

again, thanks for the help

EDIT: if you want to tell me how to use it exactly... i will appreciate it a lot...
as far as i understand i need a variable for each color... could i use arrays?
I have a multiboard variable called Multiboard (array, size:10), then in the 1st row i have 2 columns saying "Health" and "Energy"... and in the 2nd row there are the percentage values for each... the percentage value variables are called "Status_Health" and "Status_Energy" respectively.. and they are arrays with a size of 10 each (the number of each player)... i finally could use JASS in order to display each Multiboard to each player..

so each Multiboard works like this:

  • WindowInit
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Multiboard - Create a multiboard with 2 columns and 2 rows, titled Status
          • Multiboard - Set the width for (Last created multiboard) item in column 1, row 1 to 6.00% of the total screen width
          • Multiboard - Set the width for (Last created multiboard) item in column 2, row 1 to 6.00% of the total screen width
          • Multiboard - Set the width for (Last created multiboard) item in column 1, row 2 to 6.00% of the total screen width
          • Multiboard - Set the width for (Last created multiboard) item in column 2, row 2 to 6.00% of the total screen width
          • Multiboard - Set the icon for (Last created multiboard) item in column 1, row 1 to ReplaceableTextures\CommandButtons\BTNStatUp.blp
          • Multiboard - Set the icon for (Last created multiboard) item in column 2, row 1 to ReplaceableTextures\CommandButtons\BTNSleep.blp
          • Multiboard - Set the text for (Last created multiboard) item in column 1, row 1 to Health
          • Multiboard - Set the text for (Last created multiboard) item in column 2, row 1 to Energy
          • Multiboard - Set the text for (Last created multiboard) item in column 1, row 2 to ((String((Integer(Status_Health[(Integer A)])))) + %)
          • Multiboard - Set the text for (Last created multiboard) item in column 2, row 2 to ((String((Integer(Status_Energy[(Integer A)])))) + %)
          • Multiboard - Hide (Last created multiboard)
          • Set Multiboard[(Integer A)] = (Last created multiboard)
as you can see i use Loops...
this is the loops refresh trigger:
  • WindowRefresh
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Multiboard - Set the text for Multiboard[(Integer A)] item in column 1, row 2 to ((String((Integer(Status_Health[(Integer A)])))) + %)
          • Multiboard - Set the text for Multiboard[(Integer A)] item in column 2, row 2 to ((String((Integer(Status_Energy[(Integer A)])))) + %)
thanks in advance for your help before :)

PS: if ure a little lazy to explain me... dont care... ill figure out by myself anyway :) thanks a lot
 
Last edited:
Level 6
Joined
Feb 12, 2008
Messages
207
i would love someone to help me in this one, im stuck on this part of my project :)

anyway... thx to all
 
Level 6
Joined
Feb 2, 2005
Messages
205
If Status_Health is in percent you could use this,

  • //Custom script: local real udg_color1 <- Not needed
  • //Custom script: local real udg_color2 <- Not needed
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Multiboard - Set the text for Multiboard[(Integer A)] item in column 1, row 2 to ((String((Integer(Status_Health[(Integer A)])))) + %)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • (Status_Health[(Integer A)]) greater than 50.00
        • 'THEN'-Actions
          • Set color1 = (2 x (100 - Status_Health[(Integer A)]))
          • Set color2 = 100
        • 'ELSE'-Actions
          • Set color2 = (2 x Status_Health[(Integer A)])
          • Set color1 = 100
      • Multiboard - Set the color for Multiboard[(Integer A)] item in column 1, row 2 to (color1)%, (color2)%, 0.00%) with 0.00% transparency
edit: damn GUI, dont use the costume script thought, use two globals instead, will work fine anyway color1 and color2 are real global vars.

edit2: tested it and found out the second formula was wrong its should be (2 x Status_Health[(Integer A)]) instead of (100 - (2 x Status_Health[(Integer A)]))
 
Last edited:
Level 6
Joined
Feb 12, 2008
Messages
207
thanks! it does really works... just has a problem... every time it gets below 50, the numbers go black, and progressively to solid green

cant find where the problem is... i used this:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Status_Health[(Integer A)] Greater than or equal to 50.00
    • Then - Actions
      • Set Multiboard_ColorHealth2[(Integer A)] = 100.00
      • Set Multiboard_ColorHealth1[(Integer A)] = (2.00 x (100.00 - Status_Health[(Integer A)]))
    • Else - Actions
      • Set Multiboard_ColorHealth1[(Integer A)] = 0.00
      • Set Multiboard_ColorHealth2[(Integer A)] = (100.00 - (2.00 x Status_Health[(Integer A)]))
  • Multiboard - Set the color for Multiboard[(Integer A)] item in column 1, row 2 to (Multiboard_ColorHealth1[(Integer A)]%, Multiboard_ColorHealth2[(Integer A)]%, 0.00%) with 0.00% transparency
 
Last edited:
Level 6
Joined
Feb 2, 2005
Messages
205
huh, the current displayed Trigger should work fine as it is. I encounter the black letter bug only when i used locals. Here the If i use atm.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • 'IF'-Conditions
      • (Percentage life of Hero[((Integer A) - 1)]) greater than 50.00
    • 'THEN'-Actions
      • Set color1 = (2.00 x (100.00 - (Percentage life of Hero[((Integer A) - 1)])))
      • Set color2 = 100.00
    • 'ELSE'-Actions
      • Set color1 = 100.00
      • Set color2 = (1.00 x (2.00 x (Percentage life of Hero[((Integer A) - 1)])))
edit ye use (2.00 x Status_Health[(Integer A)] instead of (100.00 - (2.00 x Status_Health[(Integer A)]) then it should work fine
 
Level 6
Joined
Feb 12, 2008
Messages
207
yeah! that mat wasnt working properly: "100-(2xVar)"

now it works :)

thanks for the help! got JUST what i wanted ^^
+rep
 
Status
Not open for further replies.
Top