• 🏆 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!

Jass Needed - Multiboard

Status
Not open for further replies.
Level 30
Joined
Jan 31, 2010
Messages
3,551
First of all, thanks for watching at this thread. What I need is an advanced script that will follow the lines listed down. I need it for my project map, which is about to be released. Credits and reputation will be given, of course.

1. The Basics
I need a multiboard like on the table bellow.
The K/D/A stands for Kills/Deaths/Assists. Since I already have variables for those that keep the count, it should be made, if possible, in a way that the script "reads" the variable and uses it to declare the value.
The Gold integer displays current gold of each player. Nothing more.
The Items section displays 6 icons of hero's inventory.
The Team one is red colored - it's player 1. That's why the non-AI players go with 2, 3 and 4. Same for team 2 - the player 5 is yellow AI; 6, 7 and 8 are players. The statistics of KDA in team1/team 2 fields are sums of players in their team, meaning that player's blue, teal and purple kills are summed up in the kills of the red AI field. Same for Deaths, but not for assists, gold and items. Add up some colors to player names. Also, hero icons are a must next to player's name.
2. Faded Players
I also need a trigger, when a player leaves, his statistics turn gray, as well as his name.

Warning: this is what I seek. KDA, gold, items - those are random numbers just for you to see how it should look like.

KDAGoldItems

TEAM 12030

Player 210152625123456

Player 3663652123456

Player 4494145123456

TEAM 23020

Player 62066125123456

Player 7257789123456

Player 8898896123456

And please, make it easy configurable, or leave comments where needed.
You will be credited in the Multiboard title, or in Quests, where you like it more.
Hoping for a script. Have a nice day!
 
Level 9
Joined
Aug 2, 2008
Messages
219
I think i can work out such a multiboard but i'd like to use vJass for this because doing something like this in plain jass would be very much pain in the ass.

Further there could be a problem with the icons since there is actually no jass command which gets the iconpath of a unit or an item. The only way i can imagine to acquire an icon is to have some sort of table which links the unit/item type id with their corresponding icons and that method would still require me some time to set that all up.

Just a question about the assist counter. Do you already have some sort of assisting system that takes care of the counting ?
I'm asking this because i need to know if i need to create an assist counter system myself or if i can use the already existing variables.

The rest seems easy to realize.

[EDIT]
I've already formatted a board so it fits your example. Might wanna take a look at it:
attachment.php
 

Attachments

  • board.png
    board.png
    58 KB · Views: 184
Last edited:
Level 30
Joined
Jan 31, 2010
Messages
3,551
I have JNPG all configured and ready - do it whatever way you think it's easier and more effective.
And the multiboard is just perfect! I just have one question: since my Killing and Assistance systems are configured and executed in GUI, can vJass "translate & use" GUI variables, since the statistics are stored within them?
Also, if you go with an example which I will have to follow, I can set the paths of all icons I use withing a script, making them more effective to use.
 
Level 9
Joined
Aug 2, 2008
Messages
219
I just have one question: since my Killing and Assistance systems are configured and executed in GUI, can vJass "translate & use" GUI variables, since the statistics are stored within them?
Yes. It would be helpful to see how the system stores the K/D/A statistics so i can create an adequate interface for you.

I've created some simple script that links an icon to its actual reference in the object editor.
JASS:
library MultiboardIconLib initializer Init

    globals
        private Table OIDS
        private string array Paths
        private integer Counter = 1
    endglobals

    function LinkOID2Icon takes integer rawcode, string path returns nothing
        
        set OIDS[rawcode] = Counter
        set Paths[Counter] = path
        set Counter = Counter +1
        
    endfunction
    
    function GetIiconFromOID takes integer rawcode returns string
        return Paths[OIDS[rawcode]]    
    endfunction
    
    private function SetupIconLib takes nothing returns nothing
    
        //Example usage: This line links the UnitTypeId of the Paladin to his Icon
        call LinkOID2Icon( /*Paladin*/ 'Hpal',"ReplaceableTextures\\CommandButtons\\BTNHeroPaladin.blp")
        
    endfunction

    private function Init takes nothing returns nothing
        set OIDS = Table.create()
        set Paths[0] = "ReplaceableTextures\\CommandButtons\\BTNSelectHeroOn.blp"
        call SetupIconLib()
    endfunction
    
endlibrary
Just insert call LinkOID2Icon( /*Object Name*/ 'ObjectID', "Icon Path" ) for every object (doesnt matter if its a unit or an item or any other object type) in the function SetupIconLib.
I guess this will be a lot of work so i'd feel better when you just repeat this for 4~5 times and may show me how you did it, because it's just a big waste of time if you repeat this for all objects in the wrong way.

Besides are there a lot of items and heros on your map ?
 
Level 30
Joined
Jan 31, 2010
Messages
3,551
Currently, there are 22 heroes (I plan 24 before release), and about 50 items. Can you also create me a scrypt or show me how to do it in vJass, that when a hero enters tavern region, the icon is declared?

Edit: Forgot to put the variables. Basically, here is how they are set:
  • Revive Heroes
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is A Hero) Equal to True
          • (Unit-type of (Dying unit)) Not equal to Hero - (Dummy)
        • Then - Actions
          • Set kill_count[(Player number of (Owner of (Killing unit)))] = (kill_count[(Player number of (Owner of (Killing unit)))] + 1)
          • Set death_count[(Player number of (Owner of (Triggering unit)))] = (death_count[(Player number of (Owner of (Triggering unit)))] + 1)
        • Else - Actions
 
Last edited:
Level 9
Joined
Aug 2, 2008
Messages
219
Currently, there are 22 heroes (I plan 24 before release), and about 50 items. Can you also create me a scrypt or show me how to do it in vJass, that when a hero enters tavern region, the icon is declared?
You don't need to do that, i will add this as a build in feature. All you need to do is to link the object IDs to their icons.

For the K/D/A statistics i'll write a function which does the updating stuff. You just need to call it at the end of that trigger you have posted.

You have array variables for the statistics which is great. Since there are kill_count[] and death_count[] i suppose there is also something like assist_count[].
 
Level 9
Joined
Aug 2, 2008
Messages
219
Ok the coding is done so far. Now lets try to import this.

First of all copy the multiboard folder from the map i attached to this post into your map.
Then go to the MB Header Trigger where you will find some configurable constants with a short explanation. Scroll down until you find three public functions (those will read the K/D/A stats). Replace the return i with return udg_VARIABLE_NAME[i+1] and do that for all of the three functions.
JASS:
//This is how it should look like
public function GetPlayerKills takes integer i returns integer
        return udg_kill_count[i+1]
endfunction
After that go to the trigger which does the kill/death counting and add call MBUpdate_UpdateStats() as custom script (This should be the last line in the trigger).

Next go to the trigger in your map where you setup the hero and item icons and copy the entire content of the SetupIconLib function. Then go to the MBIcon Trigger and paste that in the SetupIconLib function of the MBIcon trigger. (The you can get rid of the script i from which you got the content.)

Now the multiboard should be working. You might wanna go back to the MBHeader trigger to do some fine tuning with the constants.

If you have some issues just say so.
 

Attachments

  • multiboard.w3x
    35.6 KB · Views: 108
Level 9
Joined
Aug 2, 2008
Messages
219
Theoretically it is possible but im not sure if that will cause some trouble since i need to use GetLocalPlayer() for that.

Here is how you apply the required changes, but it recommend you to try this with a copy of your map first.

First go to the MBHeader trigger and add this line into the globals block public constant string UNKNOWN_GOLD = "?" (This sign will be displayed instead of the enemy gold amount. You can replace the questionmark with anything you like.).

Then go to the MBUpdate Trigger and navigate to the onBreak method of the struct waiter. Then replace the entire content of the onBreak method with the following code:
JASS:
local item it
local integer i = 0
local player p = GetOwningPlayer(.hero)
local integer pid = GetPlayerId(p) +1

loop
    exitwhen i == 6
    
    set MBSetUp_TmpMBI = MultiboardGetItem( MBHeader_BOARD, pid, i + 5 )
    set it = UnitItemInSlot( .hero, i )
    if (it == null) or IsPlayerEnemy( GetLocalPlayer(), p ) then
        call MultiboardSetItemIcon( MBSetUp_TmpMBI, MBHeader_BLANK_INVENTAR )
    else
        call MultiboardSetItemIcon( MBSetUp_TmpMBI, MBIcon_GetIconFromOID(GetItemTypeId(it)) )
    endif
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    set i = i +1
endloop

set p = null
return true
Then proceed to the UpdateGold function and again replace its entire content with the following code:
JASS:
//Get Team 1 Data
local integer g1 = GetPlayerState( Player(1), PLAYER_STATE_RESOURCE_GOLD )
local integer g2 = GetPlayerState( Player(2), PLAYER_STATE_RESOURCE_GOLD )
local integer g3 = GetPlayerState( Player(3), PLAYER_STATE_RESOURCE_GOLD )
           
if ( GetLocalPlayer() == Player(1) ) or ( GetLocalPlayer() == Player(2) ) or ( GetLocalPlayer() == Player(3) ) then
    
    //Update Player 2 Gold
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,2,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, I2S(g1) )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    //Update Player 3 Gold
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,3,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, I2S(g2) )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    //Update Player 4 Gold
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,4,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, I2S(g3) )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,6,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, MBHeader_UNKNOWN_GOLD )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,7,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, MBHeader_UNKNOWN_GOLD )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,8,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, MBHeader_UNKNOWN_GOLD )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )

else

    //Get Team 2 Data
    set g1 = GetPlayerState( Player(5), PLAYER_STATE_RESOURCE_GOLD )
    set g2 = GetPlayerState( Player(6), PLAYER_STATE_RESOURCE_GOLD )
    set g3 = GetPlayerState( Player(7), PLAYER_STATE_RESOURCE_GOLD )
       
    //Update Player 6 Gold
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,6,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, I2S(g1) )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    //Update Player 7 Gold
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,7,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, I2S(g2) )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    //Update Player 8 Gold
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,8,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, I2S(g3) )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,2,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, MBHeader_UNKNOWN_GOLD )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,3,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, MBHeader_UNKNOWN_GOLD )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )
    
    set MBSetUp_TmpMBI = MultiboardGetItem(MBHeader_BOARD,4,4)
    call MultiboardSetItemValue( MBSetUp_TmpMBI, MBHeader_UNKNOWN_GOLD )
    call MultiboardReleaseItem( MBSetUp_TmpMBI )

endif
That should be it with the code changes. Now you need to test your map in the multiplayer with a real player, one in each team (doesn't matter if bnet or lan mode).
Since i'm not 100% sure if it works it is possible that the game simply crashes or you will expirience a desychronisation.
If anything is fine then keep the changes :)

PS:
Legendary War is a cool map :)
 
Status
Not open for further replies.
Top