//TESH.scrollpos=0
//TESH.alwaysfold=0
Name | Type | is_array | initial_value |
PlayerColors | string | Yes | |
PlayerDeaths | integer | Yes | |
PlayerGold | integer | Yes | |
PlayerKills | integer | Yes | |
PlayerLevels | integer | Yes | |
TeamDeaths | integer | Yes | |
TeamKills | integer | Yes |
//TESH.scrollpos=285
//TESH.alwaysfold=0
library Multiboard initializer Init
//____________________________________________________________________
// |
// Combat Multiboard System v1.02 |
// by Magtheridon96 |
// |
// Copyright 2011 |
// |
// Coded in vJASS |
// [GUI Friendly] |
// |
// www.hiveworkshop.com |
//____________________________________________________________________|
// |
// There are many multiboard systems on the hive like this one, |
// but this particular system stands out before all of them due to: |
// |
// - The fact that this is written in vJass |
// - It doesn't leave empty slots in the multiboard |
// - It's GUI Friendly |
// - It's not too complicated |
// - No Crap ^^ |
// |
//____________________________________________________________________|
// |
// Changelog |
// |
// *** v1.00 *** |
// Uploaded - First Release |
// |
// *** v1.00b *** |
// Removed one local variable |
// |
// *** v1.01 *** |
// Rewrote some parts of the system. |
// It's now much more efficient and slightly shorter. |
// |
// *** v1.02 *** |
// Fixed a major bug |
// Added a Gold feature |
// Gave an ingame screenshot |
// Make GUI Implementation 10x easier :) |
// Major Improvements :D |
// |
//____________________________________________________________________|
// |
// Why should you use my system? |
// |
// My system has several pros and maybe a few cons, but it's |
// an overall "sufficient :p" system. |
// |
// PROS: |
// - I'm not providing you with crap |
// like HP bars and stuff that would affect |
// visuals :) |
// - No empty slots |
// - Compact Multiboards |
// - Efficiency ... i think |
// - MPI :D |
// |
// CONS: |
// - I used 6 BJs :( |
// - Some people might want more features in |
// a Multiboard, but it's all just crap to |
// me, so I just gave you a Multiboard with |
// the essentials :) (You might not like this :P) |
// - The update function is Overkill >.< |
//____________________________________________________________________|
// |
// Implementation: |
// |
// *** Create a new trigger |
// *** Convert it to custom text |
// *** Paste all the contents of this trigger into it |
// *** Go to the "runtextmacro" line at the end of the code |
// *** Insert your variable names there :) |
// *** Enjoy ^^ |
//____________________________________________________________________|
globals
// CONFIGURABLES
// The multiboard colors:
private constant string LeftColor = "|cff080808"
private constant string KillsColor = "|cffff0000"
private constant string DeathsColor = "|cff0036ff"
private constant string LevelsColor = "|cffa7a7a7"
private constant string GoldColor = "|cffffcc00"
// The Multiboard texts:
private constant string GAMETITLE = "|cffffcc00Multiboard System v1.02 by Magtheridon96|r" // Also Optional, but you'll have to edit the code
private constant string MISCTITLE = "" // This text will appear in column 0 row 0. (Column 1 Row 1 if you're a GUIer ;p) It is highly optional
// The team names:
private constant string Name1 = "|cffffcc00Team 1|r"
private constant string Name2 = "|cffffcc00Team 2|r"
// Integer Constants:
private constant integer MaxPlayers = 12 // Will not function properly if this isn't an even number
// NOTE: This may not function properly if the maximum number of players on
// the first team is not the same as the number of players on the second team.
// If your game is for 4 players for example, if it's a 1v3 game, this won't function properly :)
// END OF CONFIGURABLES
// The multiboard
private multiboard array MB
// A multipurpose temporary integer
private integer Tempint
// An integer used for the loop in the update function
private integer int
// The multiboard title(s)
private string MBtitle
// The number of columns
private constant integer Cols = 5 // Not Configurable
// The number or rows (Do not touch)
private integer Rows
// Two constants used for readability
private constant playerslotstate left = PLAYER_SLOT_STATE_LEFT
private constant playerslotstate playing = PLAYER_SLOT_STATE_PLAYING
// Used for "local" reduction
private playerslotstate array pss
endglobals
// I need the following function because for some strange reason,
// GetPlayers() isn't working :/
private function GetNumberPlayers takes nothing returns integer
local integer i = 0
local integer n = 0
loop
exitwhen i > MaxPlayers-1
if GetPlayerSlotState(Player(i))==playing then
set n = n + 1
endif
set i = i + 1
endloop
return n
endfunction
// DO NOT EDIT WITHIN THIS TEXTMACRO
//! textmacro SYSTEMCODE takes k, d, l, c, g, tk, td
// Used for code size reduction
// It is used to evaluate each player's stats and update
// his values
private function Pf takes player p returns nothing
local playerslotstate ps = GetPlayerSlotState(p)
local string pn = GetPlayerName(p)
local integer i = GetPlayerId(p)
local multiboarditem mbi1
local multiboarditem mbi2
local multiboarditem mbi3
local multiboarditem mbi4
local multiboarditem mbi5
set Tempint = Tempint + 1
set mbi1 = MultiboardGetItem(MB[int], Tempint, 0)
set mbi2 = MultiboardGetItem(MB[int], Tempint, 1)
set mbi3 = MultiboardGetItem(MB[int], Tempint, 2)
set mbi4 = MultiboardGetItem(MB[int], Tempint, 3)
set mbi5 = MultiboardGetItem(MB[int], Tempint, 4)
if ps == left then
call MultiboardSetItemValue(mbi1, LeftColor + pn + "|r")
call MultiboardSetItemValue(mbi2, LevelsColor + I2S(udg_$l$[i+1]+1) + "|r")
call MultiboardSetItemValue(mbi3, KillsColor + I2S(udg_$k$[i+1]) + "|r")
call MultiboardSetItemValue(mbi4, DeathsColor + I2S(udg_$d$[i+1]) + "|r")
call MultiboardSetItemValue(mbi5, GoldColor + I2S(udg_$g$[i+1]) + "|r")
else
call MultiboardSetItemValue(mbi1, udg_$c$[i+1] + pn + "|r")
call MultiboardSetItemValue(mbi2, LevelsColor + I2S(udg_$l$[i+1]+1) + "|r")
call MultiboardSetItemValue(mbi3, KillsColor + I2S(udg_$k$[i+1]) + "|r")
call MultiboardSetItemValue(mbi4, DeathsColor + I2S(udg_$d$[i+1]) + "|r")
call MultiboardSetItemValue(mbi5, GoldColor + I2S(udg_$g$[i+1]) + "|r")
endif
call MultiboardReleaseItem(mbi1)
call MultiboardReleaseItem(mbi2)
call MultiboardReleaseItem(mbi3)
call MultiboardReleaseItem(mbi4)
call MultiboardReleaseItem(mbi5)
set ps = null
set mbi1 = null
set mbi2 = null
set mbi3 = null
set mbi4 = null
set mbi5 = null
endfunction
// CREATE MULTIBOARD FUNCTION
//
// This function is called at 0.01 seconds of gametime.
// You don't need to call it :)
private function CreateMB takes nothing returns nothing
local integer i = 1
local integer index = 0
local multiboarditem tmbi
local string s1
local string s2
loop
exitwhen i > MaxPlayers
set pss[i] = GetPlayerSlotState(Player(i-1))
set i = i + 1
endloop
set int = 0
loop
exitwhen int > MaxPlayers
set int = int + 1
set MB[int] = CreateMultiboard()
call MultiboardClear(MB[int])
set s1 = I2S(udg_$k$[int])
set s2 = I2S(udg_$d$[int])
call MultiboardSetTitleText(MB[int], "|cffaaaaaa" + s1 + "/" + s2 + "|r - " + GAMETITLE)
call MultiboardSetColumnCount(MB[int], Cols)
call MultiboardSetRowCount(MB[int], GetNumberPlayers()+4)
set tmbi = MultiboardGetItem(MB[int], 0, 0)
call MultiboardSetItemValue(tmbi, MISCTITLE)
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 1)
call MultiboardSetItemValue(tmbi, LevelsColor + "L|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 2)
call MultiboardSetItemValue(tmbi, KillsColor + "K|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + "D|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 4)
call MultiboardSetItemValue(tmbi, GoldColor + "G|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 1, 0)
call MultiboardSetItemValue(tmbi, Name1)
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 1, 2)
call MultiboardSetItemValue(tmbi, KillsColor + "0|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 1, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + "0|r")
call MultiboardReleaseItem(tmbi)
set Tempint = 1
loop
exitwhen index > MaxPlayers/2 - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
set Tempint = Tempint + 2
set tmbi = MultiboardGetItem(MB[int], Tempint, 0)
call MultiboardSetItemValue(tmbi, Name2)
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], Tempint, 2)
call MultiboardSetItemValue(tmbi, KillsColor + "0|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], Tempint, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + "0|r")
call MultiboardReleaseItem(tmbi)
loop
exitwhen index > MaxPlayers - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
// I'm ashamed :(
call MultiboardSetItemStyleBJ(MB[int], 0, 0, true, false)
call MultiboardSetItemWidthBJ(MB[int], 1, 0, 12.25)
call MultiboardSetItemWidthBJ(MB[int], 2, 0, 3.00)
call MultiboardSetItemWidthBJ(MB[int], 3, 0, 3.00)
call MultiboardSetItemWidthBJ(MB[int], 4, 0, 3.00)
call MultiboardSetItemWidthBJ(MB[int], 5, 0, 3.00)
if GetLocalPlayer() == Player(int-1) then
call MultiboardDisplay(MB[int], true)
endif
set index = 0
endloop
set tmbi = null
endfunction
// This function is used to update the multiboard COMPLETELY
// If you want to update something specific, use the alternate functions below
function UpMB takes nothing returns nothing
local integer i = 1
local integer index = 0
local multiboarditem tmbi
local string s1
local string s2
loop
exitwhen i > MaxPlayers
set pss[i] = GetPlayerSlotState(Player(i-1))
set i = i + 1
endloop
set int = 0
loop
exitwhen int > MaxPlayers
set int = int + 1
set s1 = I2S(udg_$k$[int])
set s2 = I2S(udg_$d$[int])
call MultiboardSetTitleText(MB[int], "|cffaaaaaa" + s1 + "/" + s2 + "|r - " + GAMETITLE)
set udg_$tk$[1] = udg_$k$[1] + udg_$k$[2] + udg_$k$[3] + udg_$k$[4] + udg_$k$[5]
set tmbi = MultiboardGetItem(MB[int], 1, 2)
call MultiboardSetItemValue(tmbi, KillsColor + I2S(udg_$tk$[1]) + "|r")
call MultiboardReleaseItem(tmbi)
set udg_$td$[1] = udg_$d$[1] + udg_$d$[2] + udg_$d$[3] + udg_$d$[4] + udg_$d$[5]
set tmbi = MultiboardGetItem(MB[int], 1, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + I2S(udg_$td$[1]) + "|r")
call MultiboardReleaseItem(tmbi)
set Tempint = 1
loop
exitwhen index > MaxPlayers/2 - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
set Tempint = Tempint + 2
set udg_$tk$[2] = udg_$k$[6] + udg_$k$[7] + udg_$k$[8] + udg_$k$[9] + udg_$k$[10]
set tmbi = MultiboardGetItem(MB[int], Tempint, 2)
call MultiboardSetItemValue(tmbi, KillsColor + I2S(udg_$tk$[2]) + "|r")
call MultiboardReleaseItem(tmbi)
set udg_$td$[2] = udg_$d$[6] + udg_$d$[7] + udg_$d$[8] + udg_$d$[9] + udg_$d$[10]
set tmbi = MultiboardGetItem(MB[int], Tempint, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + I2S(udg_$td$[2]) + "|r")
call MultiboardReleaseItem(tmbi)
loop
exitwhen index > MaxPlayers - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
set index = 0
endloop
set tmbi = null
endfunction
//! endtextmacro
// !!! A T T E N T I O N A L L G U I E R S !!!
// THIS IS YOUR CONFIGURATION LINE:
// You're supposed to put the variable names in GUI
// KILLS DEATHS LEVELS COLORS GOLD TEAM KILLS TEAM DEATHS
//! runtextmacro SYSTEMCODE("PlayerKills", "PlayerDeaths", "PlayerLevels", "PlayerColors", "PlayerGold", "TeamKills", "TeamDeaths")
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.01, false)
call TriggerAddAction(t, function CreateMB)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Multiboard initializer Init
globals
private constant string LeftColor = "|cff080808"
private constant string KillsColor = "|cffff0000"
private constant string DeathsColor = "|cff0036ff"
private constant string LevelsColor = "|cffa7a7a7"
private constant string GoldColor = "|cffffcc00"
private constant string GAMETITLE = "|cffffcc00Multiboard System v1.02 by Magtheridon96|r"
private constant string MISCTITLE = ""
private constant string Name1 = "|cffffcc00Team 1|r"
private constant string Name2 = "|cffffcc00Team 2|r"
private constant integer MaxPlayers = 12
private multiboard array MB
private integer Tempint
private integer int
private string MBtitle
private constant integer Cols = 5
private integer Rows
private constant playerslotstate left = PLAYER_SLOT_STATE_LEFT
private constant playerslotstate playing = PLAYER_SLOT_STATE_PLAYING
private playerslotstate array pss
endglobals
private function GetNumberPlayers takes nothing returns integer
local integer i = 0
local integer n = 0
loop
exitwhen i > MaxPlayers-1
if GetPlayerSlotState(Player(i))==playing then
set n = n + 1
endif
set i = i + 1
endloop
return n
endfunction
//! textmacro SYSTEMCODE takes k, d, l, c, g, tk, td
private function Pf takes player p returns nothing
local playerslotstate ps = GetPlayerSlotState(p)
local string pn = GetPlayerName(p)
local integer i = GetPlayerId(p)
local multiboarditem mbi1
local multiboarditem mbi2
local multiboarditem mbi3
local multiboarditem mbi4
local multiboarditem mbi5
set Tempint = Tempint + 1
set mbi1 = MultiboardGetItem(MB[int], Tempint, 0)
set mbi2 = MultiboardGetItem(MB[int], Tempint, 1)
set mbi3 = MultiboardGetItem(MB[int], Tempint, 2)
set mbi4 = MultiboardGetItem(MB[int], Tempint, 3)
set mbi5 = MultiboardGetItem(MB[int], Tempint, 4)
if ps == left then
call MultiboardSetItemValue(mbi1, LeftColor + pn + "|r")
call MultiboardSetItemValue(mbi2, LevelsColor + I2S(udg_$l$[i+1]+1) + "|r")
call MultiboardSetItemValue(mbi3, KillsColor + I2S(udg_$k$[i+1]) + "|r")
call MultiboardSetItemValue(mbi4, DeathsColor + I2S(udg_$d$[i+1]) + "|r")
call MultiboardSetItemValue(mbi5, GoldColor + I2S(udg_$g$[i+1]) + "|r")
else
call MultiboardSetItemValue(mbi1, udg_$c$[i+1] + pn + "|r")
call MultiboardSetItemValue(mbi2, LevelsColor + I2S(udg_$l$[i+1]+1) + "|r")
call MultiboardSetItemValue(mbi3, KillsColor + I2S(udg_$k$[i+1]) + "|r")
call MultiboardSetItemValue(mbi4, DeathsColor + I2S(udg_$d$[i+1]) + "|r")
call MultiboardSetItemValue(mbi5, GoldColor + I2S(udg_$g$[i+1]) + "|r")
endif
call MultiboardReleaseItem(mbi1)
call MultiboardReleaseItem(mbi2)
call MultiboardReleaseItem(mbi3)
call MultiboardReleaseItem(mbi4)
call MultiboardReleaseItem(mbi5)
set ps = null
set mbi1 = null
set mbi2 = null
set mbi3 = null
set mbi4 = null
set mbi5 = null
endfunction
private function CreateMB takes nothing returns nothing
local integer i = 1
local integer index = 0
local multiboarditem tmbi
local string s1
local string s2
loop
exitwhen i > MaxPlayers
set pss[i] = GetPlayerSlotState(Player(i-1))
set i = i + 1
endloop
set int = 0
loop
exitwhen int > MaxPlayers
set int = int + 1
set MB[int] = CreateMultiboard()
call MultiboardClear(MB[int])
set s1 = I2S(udg_$k$[int])
set s2 = I2S(udg_$d$[int])
call MultiboardSetTitleText(MB[int], "|cffaaaaaa" + s1 + "/" + s2 + "|r - " + GAMETITLE)
call MultiboardSetColumnCount(MB[int], Cols)
call MultiboardSetRowCount(MB[int], GetNumberPlayers()+4)
set tmbi = MultiboardGetItem(MB[int], 0, 0)
call MultiboardSetItemValue(tmbi, MISCTITLE)
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 1)
call MultiboardSetItemValue(tmbi, LevelsColor + "L|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 2)
call MultiboardSetItemValue(tmbi, KillsColor + "K|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + "D|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 0, 4)
call MultiboardSetItemValue(tmbi, GoldColor + "G|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 1, 0)
call MultiboardSetItemValue(tmbi, Name1)
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 1, 2)
call MultiboardSetItemValue(tmbi, KillsColor + "0|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], 1, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + "0|r")
call MultiboardReleaseItem(tmbi)
set Tempint = 1
loop
exitwhen index > MaxPlayers/2 - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
set Tempint = Tempint + 2
set tmbi = MultiboardGetItem(MB[int], Tempint, 0)
call MultiboardSetItemValue(tmbi, Name2)
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], Tempint, 2)
call MultiboardSetItemValue(tmbi, KillsColor + "0|r")
call MultiboardReleaseItem(tmbi)
set tmbi = MultiboardGetItem(MB[int], Tempint, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + "0|r")
call MultiboardReleaseItem(tmbi)
loop
exitwhen index > MaxPlayers - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
call MultiboardSetItemStyleBJ(MB[int], 0, 0, true, false)
call MultiboardSetItemWidthBJ(MB[int], 1, 0, 12.25)
call MultiboardSetItemWidthBJ(MB[int], 2, 0, 3.00)
call MultiboardSetItemWidthBJ(MB[int], 3, 0, 3.00)
call MultiboardSetItemWidthBJ(MB[int], 4, 0, 3.00)
call MultiboardSetItemWidthBJ(MB[int], 5, 0, 3.00)
if GetLocalPlayer() == Player(int-1) then
call MultiboardDisplay(MB[int], true)
endif
set index = 0
endloop
set tmbi = null
endfunction
function UpMB takes nothing returns nothing
local integer i = 1
local integer index = 0
local multiboarditem tmbi
local string s1
local string s2
loop
exitwhen i > MaxPlayers
set pss[i] = GetPlayerSlotState(Player(i-1))
set i = i + 1
endloop
set int = 0
loop
exitwhen int > MaxPlayers
set int = int + 1
set s1 = I2S(udg_$k$[int])
set s2 = I2S(udg_$d$[int])
call MultiboardSetTitleText(MB[int], "|cffaaaaaa" + s1 + "/" + s2 + "|r - " + GAMETITLE)
set udg_$tk$[1] = udg_$k$[1] + udg_$k$[2] + udg_$k$[3] + udg_$k$[4] + udg_$k$[5]
set tmbi = MultiboardGetItem(MB[int], 1, 2)
call MultiboardSetItemValue(tmbi, KillsColor + I2S(udg_$tk$[1]) + "|r")
call MultiboardReleaseItem(tmbi)
set udg_$td$[1] = udg_$d$[1] + udg_$d$[2] + udg_$d$[3] + udg_$d$[4] + udg_$d$[5]
set tmbi = MultiboardGetItem(MB[int], 1, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + I2S(udg_$td$[1]) + "|r")
call MultiboardReleaseItem(tmbi)
set Tempint = 1
loop
exitwhen index > MaxPlayers/2 - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
set Tempint = Tempint + 2
set udg_$tk$[2] = udg_$k$[6] + udg_$k$[7] + udg_$k$[8] + udg_$k$[9] + udg_$k$[10]
set tmbi = MultiboardGetItem(MB[int], Tempint, 2)
call MultiboardSetItemValue(tmbi, KillsColor + I2S(udg_$tk$[2]) + "|r")
call MultiboardReleaseItem(tmbi)
set udg_$td$[2] = udg_$d$[6] + udg_$d$[7] + udg_$d$[8] + udg_$d$[9] + udg_$d$[10]
set tmbi = MultiboardGetItem(MB[int], Tempint, 3)
call MultiboardSetItemValue(tmbi, DeathsColor + I2S(udg_$td$[2]) + "|r")
call MultiboardReleaseItem(tmbi)
loop
exitwhen index > MaxPlayers - 1
if pss[index+1] == playing or pss[index+1] == left then
call Pf(Player(index))
endif
set index = index + 1
endloop
set index = 0
endloop
set tmbi = null
endfunction
//! endtextmacro
//! runtextmacro SYSTEMCODE("PlayerKills", "PlayerDeaths", "PlayerLevels", "PlayerColors", "PlayerGold", "TeamKills", "TeamDeaths")
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.01, false)
call TriggerAddAction(t, function CreateMB)
endfunction
endlibrary