--[[
HeroSelector V1.9 by Tasyen
A UI System to pick a Hero/UnitCode also supports ban and requirments
]]
HeroSelector = {}
HeroSelector.TocPath = "war3mapImported\\HeroSelector.toc" --ex/import also "HeroSelector.fdf"
--Box
HeroSelector.BoxFrameName = "HeroSelectorRaceBox" --this is the background box being created
HeroSelector.BackgroundTexture = "" -- if this is not "" it displays it over the box background
HeroSelector.BackgroundTiles = 1 -- 0=streched 1=tileMode
HeroSelector.BoxPosX = 0.5
HeroSelector.BoxPosY = 0.4
HeroSelector.BoxPosPoint = FRAMEPOINT_CENTER
HeroSelector.AutoShow = true --(true) shows the box and the Selection at 0.0 for all players
HeroSelector.AutoCreate = true --(true) create itself when gameStarted. (false) you need to HeroSelector.initHeroes() HeroSelector.initFrames()
--Unique Picks
HeroSelector.UnitCount = 999 --each hero is in total allowed to be picked this amount of times (includes random, repicking allows a hero again).
HeroSelector.UnitCountPerTeam = 1 --Each Team is allowed to pick this amount of each unitType
HeroSelector.ToManyTooltip = "OUTOFSTOCKTOOLTIP"
-- HeroSelector.PickAbleHeroes is a Way to define pickable Units without touching HeroSelector.initHeroes
-- pickable options expects one string like "Hamg,Hmkg,Hpal,Hblm". It can contain 0 to have empty slots "Hamg,0,Hpal,0,Hblm"
-- all melee heroes "Hamg,Hmkg,Hpal,Hblm,Obla,Ofar,Otch,Oshd,Udea,Ulic,Udre,Ucrl,Edem,Ekee,Emoo,Ewar,Nngs,Nbrn,Npbm,Nplh,Nbst,Nfir,Ntin,Nalc"
HeroSelector.PickAbleHeroes = ""
HeroSelector.EnableGUICode = true -- enables the gui parser and throwing the picked event. if you don't use either you should set this to false.
--Ban
HeroSelector.DelayBanUntilPick = false --(true) baning will not be applied instantly, instead it is applied when HeroSelector.enablePick is called the next time.
--Category
HeroSelector.CategoryData = {
--Icon path, tooltip Text (tries to localize), HeroCdes "Hmkg,Hpal"
{"ReplaceableTextures\\CommandButtons\\BTNSteelMelee", "MELEE"}, --1, automatic detected when adding an unit
{"ReplaceableTextures\\CommandButtons\\BTNHumanMissileUpOne", "Ranged"}, --2, automatic detected when adding an unit
{"ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower", "STRENGTH"}, --4
{"ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility", "AGILITY"}, --8
{"ReplaceableTextures\\CommandButtons\\BTNMantleOfIntelligence", "INTELLECT"}, --16
}
HeroSelector.CategoryAffectRandom = true --(false) random will not care about selected category
HeroSelector.CategorySize = 0.02 --the size of the Category Button
HeroSelector.CategorySpaceX = 0.0008 --space between 2 category Buttons, it is meant to need only one line of Categoryy Buttons.
HeroSelector.CategoryFilteredAlpha = 45 -- Alpha value of Heroes being filtered by unselected categories
HeroSelector.CategoryAutoDetect = true -- try to set category of added options automatic
HeroSelector.CategoryAutoDetectHero = true -- (heavy performance wise) create and remove added Heroes to setup the Category for the primary Attribute Str(4) Agi(8) Int(16)
HeroSelector.CategorySingleSelect = __jarray(true) -- (true) clicking category will unselect others, you need this false when you want to have multiselect
HeroSelector.PlayerSelectModeExclusive = __jarray(false) -- (true) hero needs to fit all categories selected (false) needs to fit 1 category
--Indicator
HeroSelector.IndicatorPathPick = "UI\\Feedback\\Autocast\\UI-ModalButtonOn.mdl" --this model is used by the indicator during picking
HeroSelector.IndicatorPathBan = "war3mapImported\\HeroSelectorBan.mdl" --this model is used by the indicator during baning
--Grid
HeroSelector.SpaceBetweenX = 0.008 --space between 2 buttons in one row
HeroSelector.SpaceBetweenY = 0.008 --space between 2 rows
HeroSelector.ButtonColCount = 4 --amount of buttons in one row
HeroSelector.ButtonRowCount = 4 --amount of rows
HeroSelector.ChainedButtons = true --(true) connect to the previous button/ or row, (false) have a offset to the box topLeft in this moving a button has no effect on other buttons.
--Button
HeroSelector.ButtonSize = 0.036 --size of each button
HeroSelector.ButtonBlendAll = false --(true) when a hero icon uses transparenzy
HeroSelector.EmptyButtonPath = "UI\\Widgets\\EscMenu\\Human\\blank-background.blp"
HeroSelector.HideEmptyButtons = true
--Ban Button
HeroSelector.BanButtonTextPrefix = "|cffcf2084" --Prefix Text for the Ban Button
HeroSelector.BanButtonText = "CHAT_ACTION_BAN"
HeroSelector.BanButtonTooltipText = "CHAT_ACTION_BAN" --over the ban button
HeroSelector.BanButtonSizeX = 0.085
HeroSelector.BanButtonSizeY = 0.03
HeroSelector.BanTooltip = "DISALLOWED" -- over the hero button
HeroSelector.BanIgnoreRequirment = true -- (true) Ban is not restricted by Requirments
--BanDone Button
HeroSelector.BanDoneButtonTextPrefix = "|cffcf2084" --Prefix Text for the Ban Button
HeroSelector.BanDoneButtonText = "QUESTACCEPT" --tries to get a Localized String
HeroSelector.BanDoneButtonTooltipText = "I am done with Banning" --tries to get a Localized String
HeroSelector.BanDoneButtonSizeX = 0.085
HeroSelector.BanDoneButtonSizeY = 0.03
HeroSelector.BanDoneButtonIsShown = true --show this button in the Ban Phase
--BanMany Button
HeroSelector.BanManyButtonTextPrefix = "|cffcf2084" --Prefix Text for the Ban Button
HeroSelector.BanManyButtonTooltipText = "String_BanManyButtonTooltip" --Prefix Text for the Ban Button
HeroSelector.BanManyButtonText = "Massen Bann" --tries to get a Localized String
HeroSelector.BanManyButtonSizeX = 0.085
HeroSelector.BanManyButtonSizeY = 0.03
HeroSelector.BanManyBannRemain = __jarray(0) -- how many bans this button does? write a number in __jarray(x) BanMany bans random heroes of current category
HeroSelector.BanManyButtonIsShown = false --show this button in the Ban Phase
--Accept Button
HeroSelector.AcceptButtonTextPrefix = ""
HeroSelector.AcceptButtonText = "ACCEPT"
HeroSelector.AcceptButtonTooltipText = "ACCEPT"
HeroSelector.AcceptButtonSizeX = 0.085
HeroSelector.AcceptButtonSizeY = 0.03
HeroSelector.AcceptButtonIsShown = true --show this button in the Pick Phase
--Random Button
HeroSelector.RandomButtonTextPrefix = ""
HeroSelector.RandomButtonText = "RANDOM" --tries Localizing
HeroSelector.RandomButtonTooltipText = "String_RandomButtonTooltip" --tries Localizing
HeroSelector.RandomButtonTooltipText2 = { [false] ="String_RandomButtonTooltipSelect" ,[true] = "String_RandomButtonTooltipPick"} --tries Localizing
HeroSelector.RandomButtonSizeX = 0.085
HeroSelector.RandomButtonSizeY = 0.03
HeroSelector.RandomButtonIsShown = true --show this button in the Pick Phase
HeroSelector.RandomButtonPick = false --(true) pressing the random button will pick the option. (false) pressing the random button will select a button, random only heroes can not be selected, but that does not matter. This weak random and randomonly should not be combined.
--Repick Button
HeroSelector.RepickButtonTextPrefix = ""
HeroSelector.RepickButtonText = "REPICK" --tries Localizing
HeroSelector.RepickButtonTooltipText = "String_RepickButtonTooltip" --tries Localizing
HeroSelector.RepickButtonTextLimit = "Repick (#)" --tries Localizing # is the variable for the remaining
HeroSelector.RepickButtonSizeX = 0.085
HeroSelector.RepickButtonSizeY = 0.03
HeroSelector.RepickButtonIsShown = true --show this button in the Pick Phase
HeroSelector.RepickMax = 0 -- when bigger than 0 only that amount of Repicks is allowed
--ShowButton
HeroSelector.ShowButtonTextPrefix = ""
HeroSelector.ShowButtonText = "PICK-HERO" --tries Localizing
HeroSelector.ShowButtonSizeX = 0.085
HeroSelector.ShowButtonSizeY = 0.03
HeroSelector.ShowButtonIsShown = false --show this button
HeroSelector.ShowButtonX = 0.42
HeroSelector.ShowButtonY = 0.58
HeroSelector.ShowButtonPoint = FRAMEPOINT_TOPLEFT
HeroSelector.ShowButtonParent = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
--Search
HeroSelector.SearchBoxToolTipText = "Search in Name & Spells.|nNot used by Random."
HeroSelector.SearchBoxSizeX = 0.12
HeroSelector.SearchBoxSizeY = 0.035
HeroSelector.SearchBoxSizeIsShown = false
--MUltiSelect Button
HeroSelector.MultiSelectButtonTextures = {"ui\\widgets\\battlenet\\bnet-mainmenu-friends-disabled", "ui\\widgets\\battlenet\\bnet-mainmenu-friends-up"}
HeroSelector.MultiSelectButtonTooltipText = {"Multi Concentrate", "Multi Expand"}
HeroSelector.MultiSelectButtonIsShown = false
--MUltiSelect Button
HeroSelector.CategoryClearButtonTexture = "replaceabletextures\\commandbuttons\\btncancel"
HeroSelector.CategoryClearButtonTooltipText = "Clear Category"
HeroSelector.CategoryClearButtonIsShown = false
--Tooltip
HeroSelector.TooltipPrefix = "|cffffcc00"
HeroSelector.TooltipOffsetX = 0
HeroSelector.TooltipOffsetY = 0
HeroSelector.TooltipPoint = FRAMEPOINT_BOTTOM --pos the Tooltip with which Point
HeroSelector.TooltipRelativePoint = FRAMEPOINT_TOP --pos the Tooltip to which Point of the Relative
HeroSelector.TooltipRelativIsBox = false --(true) use the box as anchor, (false) use the button as anchor
HeroSelector.TooltipRequires = "QUESTCOMPONENTS"
HeroSelector.TooltipRequires2 = {
[RACE_HUMAN] = "HUMAN"
,[RACE_ORC] = "ORC"
,[RACE_UNDEAD] = "UNDEAD"
,[RACE_NIGHTELF] = "NIGHT_ELF"
,[PLAYER_STATE_RESOURCE_HERO_TOKENS] = "HERO TOCKEN"
}
--Border
HeroSelector.BorderSize = {}
HeroSelector.BorderSize[RACE_HUMAN] = 0.029 --border size seen by Race Human, this is needed cause the borders are different in size.
HeroSelector.BorderSize[RACE_ORC] = 0.029
HeroSelector.BorderSize[RACE_UNDEAD] = 0.035
HeroSelector.BorderSize[RACE_NIGHTELF] = 0.035
HeroSelector.BorderSize[RACE_DEMON] = 0.024
--This runs before the box is created with that the system has the needed data right when it is needed.
--you can add units somewhere else but it is done after the box was created you have to use the update function to update the textures of shown buttons
function HeroSelector.initHeroes()
--create categories setuped in config
local categories = HeroSelector.CategoryData
HeroSelector.Category = {}
for index, value in ipairs(categories) do
HeroSelector.addCategory(value[1], value[2])
end
--read GUI, when the variable exist
if HeroSelector.EnableGUICode and udg_HeroSelectorUnitCode then
local index = 1
--add from index 1 all random only heroes
while udg_HeroSelectorRandomOnly[index] ~= 0 do
HeroSelector.addUnit(udg_HeroSelectorRandomOnly[index], true)
index = index + 1
end
--copy the setuped field
for index = 1, HeroSelector.ButtonColCount*HeroSelector.ButtonRowCount,1 do
HeroSelector.addUnit(udg_HeroSelectorUnitCode[index])
if udg_HeroSelectorCategory and udg_HeroSelectorCategory[index] ~= 0 then
HeroSelector.addUnitCategory(udg_HeroSelectorUnitCode[index], udg_HeroSelectorCategory[index])
end
end
--kill the tables
udg_HeroSelectorUnitCode = nil
udg_HeroSelectorRandomOnly = nil
udg_HeroSelectorCategory = nil
end
--adding further units when using the GUI Array does not make much sense, except you would add rows.
if HeroSelector.PickAbleHeroes and (type(HeroSelector.PickAbleHeroes) =="string" and string.len( HeroSelector.PickAbleHeroes ) >= 4 ) then HeroSelector.addUnit(HeroSelector.PickAbleHeroes) end
local iCat = 1
for index, value in ipairs(categories) do
if value[3] then
HeroSelector.addUnitCategory(value[3], iCat)
end
iCat=iCat*2
end
--skip further demo code
if true then return end
HeroSelector.addUnit("Hgam", true, 0) --antonidas is an only random Hero that can only be randomed by team 0 (for users 1).
HeroSelector.addUnit("Eevi", true, 1) --evil Illidan is an only random Hero that can only be randomed by team 1 (for users 2).
--Adds requirments
--when you have a ban phase it might be better to add the requirments after the ban phase is over, otherwise one can only ban own options.
--paladin requires having 5 footman, Archmage a Hero Tocken other human heroes can only picked by human-Race, as nightelf only for Nightelf
HeroSelector.setUnitReq('Hpal', {FourCC('hfoo'), 5})
HeroSelector.setUnitReq('Hamg', PLAYER_STATE_RESOURCE_HERO_TOKENS)
HeroSelector.setUnitReq('Hblm', RACE_HUMAN)
HeroSelector.setUnitReq('Hmkg', RACE_HUMAN)
--HeroSelector.setUnitReq('Ofar', RACE_ORC)
--HeroSelector.setUnitReq('Oshd', RACE_ORC)
--HeroSelector.setUnitReq('Otch', RACE_ORC)
--HeroSelector.setUnitReq('Obla', RACE_ORC)
HeroSelector.setUnitReq('Emoo', RACE_NIGHTELF)
HeroSelector.setUnitReq('Edem', RACE_NIGHTELF)
HeroSelector.setUnitReq('Ekee', RACE_NIGHTELF)
HeroSelector.setUnitReq('Ewar', RACE_NIGHTELF)
--HeroSelector.setUnitReq('Udea', RACE_UNDEAD)
--HeroSelector.setUnitReq('Ulic', RACE_UNDEAD)
--HeroSelector.setUnitReq('Udre', RACE_UNDEAD)
--HeroSelector.setUnitReq('Ucrl', RACE_UNDEAD)
--[[
local categoryMelee = 1 --autodetected
local categoryRanged = 2 --autodetected
local categoryStr = 4
local categoryAgi = 8
local categoryInt = 16
HeroSelector.addUnitCategory('Hpal', categoryStr)
HeroSelector.addUnitCategory('Hamg', categoryInt)
HeroSelector.addUnitCategory('Hblm', categoryInt)
HeroSelector.addUnitCategory('Hmkg', categoryStr)
HeroSelector.addUnitCategory('Ofar', categoryInt)
HeroSelector.addUnitCategory('Oshd', categoryAgi)
HeroSelector.addUnitCategory('Otch', categoryAgi)
HeroSelector.addUnitCategory('Obla', categoryAgi)
HeroSelector.addUnitCategory('Emoo', categoryAgi)
HeroSelector.addUnitCategory('Edem', categoryAgi)
HeroSelector.addUnitCategory('Ekee', categoryInt)
HeroSelector.addUnitCategory('Ewar', categoryAgi)
HeroSelector.addUnitCategory('Udea', categoryStr)
HeroSelector.addUnitCategory('Ulic', categoryInt)
HeroSelector.addUnitCategory('Udre', categoryStr)
HeroSelector.addUnitCategory('Ucrl', categoryStr)
HeroSelector.setUnitCategory('Hgam', categoryInt + categoryRanged)
HeroSelector.setUnitCategory("Eevi", categoryAgi + categoryMelee)
--]]
--[[
HeroSelector.addUnit('Hpal') --add paladin as selectable Hero
HeroSelector.addUnit('Hamg')
HeroSelector.addUnit('Hblm')
HeroSelector.addUnit('Hmkg')
HeroSelector.addUnit("Obla", true) --this unit can only be randomed
HeroSelector.addUnit("Ofar")
HeroSelector.addUnit("Otch", 1) --this unit can only be randomed
HeroSelector.addUnit() --this is an empty box. It still takes a slot.
HeroSelector.addUnit()
HeroSelector.addUnit("Oshd")
HeroSelector.addUnit("Edem")
HeroSelector.addUnit() --this is an empty box. It still takes a slot.
HeroSelector.addUnit()
HeroSelector.addUnit("Ekee")
HeroSelector.addUnit("Emoo")
HeroSelector.addUnit("Ewar",true)
HeroSelector.addUnit("Udea")
HeroSelector.addUnit("Ulic")
HeroSelector.addUnit("Udre")
HeroSelector.addUnit("Ucrl",1)
--]]
end
function HeroSelector.autoDetectCategory(unitCode)
if HeroSelector.CategoryAutoDetect then
if IsUnitIdType(unitCode, UNIT_TYPE_MELEE_ATTACKER) then
HeroSelector.UnitData[unitCode].Category = 1
elseif IsUnitIdType(unitCode, UNIT_TYPE_RANGED_ATTACKER) then
HeroSelector.UnitData[unitCode].Category = 2
end
if HeroSelector.CategoryAutoDetectHero and IsUnitIdType(unitCode, UNIT_TYPE_HERO) then
local unit = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), unitCode, 0, 0, 270)
local primaryAttribute = BlzGetUnitIntegerField(unit, UNIT_IF_PRIMARY_ATTRIBUTE)
RemoveUnit(unit)
if ConvertHeroAttribute(primaryAttribute) == HERO_ATTRIBUTE_STR then
HeroSelector.UnitData[unitCode].Category = HeroSelector.UnitData[unitCode].Category + 4
elseif ConvertHeroAttribute(primaryAttribute) == HERO_ATTRIBUTE_AGI then
HeroSelector.UnitData[unitCode].Category = HeroSelector.UnitData[unitCode].Category + 8
elseif ConvertHeroAttribute(primaryAttribute) == HERO_ATTRIBUTE_INT then
HeroSelector.UnitData[unitCode].Category = HeroSelector.UnitData[unitCode].Category + 16
end
end
end
end
--what happens to the unit beeing picked, player is the one having pressed the button
function HeroSelector.unitCreated(player, unitCode, isRandom)
bj_lastCreatedUnit = CreateUnit(player, unitCode, GetPlayerStartLocationX(player), GetPlayerStartLocationY(player), 0)
local unit = bj_lastCreatedUnit
HeroSelector.PickedUnit[player] = unit
if isRandom then
--randomed
else
--picked
end
if player == Player(1) then
end
PanCameraToTimedForPlayer(player, GetUnitX(unit), GetUnitY(unit),0)
SelectUnitForPlayerSingle(unit, player)
HeroSelector.enablePick(false, player) --only one pick for this player
if HeroSelector.EnableGUICode then
globals.udg_HeroSelectorEvent = 0
globals.udg_HeroSelectorEvent = 1.0
end
--print(GetPlayerName(player),"picks",GetUnitName(unit))
end
--happens when the banButton is pressed, player is the one having pressed the button
function HeroSelector.unitBaned(player, unitCode)
HeroSelector.enableBan(false, player) --only one ban
--print(GetPlayerName(player),"bans",GetObjectName(unitCode))
end
function HeroSelector.buttonSelected(player, unitCode)
--player who pressed the button
--unitCode the unitCode selected
--this is not picked.
--print(GetPlayerName(player),"selects",GetObjectName(unitCode))
end
function HeroSelector.repick(unit, player)
if not unit then return end
UnitRemoveBuffsBJ(bj_REMOVEBUFFS_ALL, unit) --this is done to undo metamorph
local unitCode = GetUnitTypeId(unit)
if unitCode == 0 then return end
HeroSelector.counterChangeUnitCode(unitCode, -1, player)
if not player then
player = GetOwningPlayer(unit)
end
HeroSelector.PickedUnit[player] = nil
HeroSelector.show(true, player)
HeroSelector.enablePick(true, player)
RemoveUnit(unit)
end
function HeroSelector.actionBanDoneButton(frame, player)
-- HeroSelector.enablePick(true) -> on click finish the Ban Phase and start pick Phase
HeroSelector.enablePick(true)
end
function HeroSelector.actionShowButton(frame, player)
if GetLocalPlayer() == player then BlzFrameSetVisible(HeroSelector.Box, not BlzFrameIsVisible(HeroSelector.Box)) end
end
--[[
This functions are found directly below the config and belong to the config.
They also can be hooked but you might lose the default. Could do it like it is done in TeamViewer create a Backup of the current then overwrite it and call the backup in the replacement.
function HeroSelector.unitCreated(player, unitCode, isRandom)
this function is called when an unit is picked, add here you actions that have to be done for the picked unit
function HeroSelector.buttonSelected(player, unitCode)
this function is called when an player selects an button, this is not the picking.
function HeroSelector.unitBaned(player, unitCode)
this function is called when a player bans an unitCode.
function HeroSelector.actionBanDoneButton(frame, player)
this function happens when the banDone Button is clicked
function HeroSelector.repick(unit[, player])
if player is skiped unit owner sees the selection
this will remove the unit from the game.
Adds thie unitcode of the unit to the randompool
function HeroSelector.autoDetectCategory(unitCode)
this called on every unit added. It is a good place for simple automatic categorizes, on default it categorizes melee as 1 and ranged as 2.
function HeroSelector.initHeroes()
this function will be called before anything is created, when not using GUI to setup data you could add the selectable heroes here.
------
How use the Selection grid?
Each hero can only be once in the grid. When using HeroSelector.addUnit it will add a new slot. There are HeroSelector.ButtonColCount*HeroSelector.ButtonRowCount slots.
3 rows with 4 cols would result into:
01 02 03 04
05 06 07 08
09 10 11 12
When you want to leave fields in the grid empty use HeroSelector.addUnit(0) or HeroSelector.addUnit().
There is a GUI setup which works with indexes, not set indexes will be empty fields.
------
function HeroSelector.setUnitReq(unitCode, who)
adds an requirement: can be a player, a force, a teamNumber, a race, a table {techcode, level}, playerState (need to have 1 of it, mostly useful for PLAYER_STATE_RESOURCE_HERO_TOKENS), skip who or nil will remove an requirment.
unitCode can be a number or a string 'Hpal' or 'Hpal,Ofar,Ulic'
Only when the local player fullfills than he can click the button.
calling this will not update the selected buttonIndex of players nor does this update the clickability.
To update the clickability when setting requirments after the Box was created use HeroSelector.update() and deselect indexes
won't work when the unitCode wasn't added yet.
function HeroSelector.addUnit([unitCode, onlyRandom, requirement])
unitCode can be a number or a string 'Hpal' or 'Hpal,Ofar,Ulic,0,Obla'
can be called without arguments to hava a empty slot calling it with 0 has the same effect
requirement works like who in HeroSelector.setUnitReq.
function HeroSelector.setUnitCategory(unitCode, category)
unitCode can be a number or a string 'Hpal' or 'Hpal,Ofar,Ulic'
sets the category of an added Option.
Category should be a power 2 number. 1 2 4 8 16 32 ....
function HeroSelector.addUnitCategory(unitCode, category)
unitCode can be a number or a string 'Hpal' or 'Hpal,Ofar,Ulic'
Keeps previous setings untouched
function HeroSelector.addCategory(icon, text)
icon is the enabled image, text is the tooltip text.
function HeroSelector.clearUnitData()
removes all current UnitData this includes limit-counters, requirements, categories.
function HeroSelector.show(flag, [who])
Shows/Hides HeroSelector to who
flag = true show it, false = hide it
who can be a player, a force, a teamNumber, a race or nothing = anyone
teamNumbers are the warcraft 3 given teamNumbers starting with 0 for team 1.
the force is expected to be kept alive
function HeroSelector.setFrameText(frame, text[, who])
uses BlzFrameSetText onto frame when the local player is included in who by the rules of function HeroSelector.includesPlayer
function HeroSelector.setTitleText(text[, who])
wrapper HeroSelector.setFrameText
function HeroSelector.setBanButtonText(text[, who])
wrapper HeroSelector.setFrameText
function HeroSelector.setAcceptButtonText(text[, who])
wrapper HeroSelector.setFrameText
function HeroSelector.enablePick(flag[, who])
enable/disable the accept/random button also makes them visible for that players and hides the ban Button.
function HeroSelector.enableBan(flag[, who])
enable/disable the ban button also makes accept/random invisible for that players and shows the ban Button.
function HeroSelector.forceRandom([who])
wrapper for doRandom for player
function HeroSelector.forcePick([who])
forces to pick what currently is selected, if that fails doRandom
function HeroSelector.buttonRequirementDone(unitCode, player)
function HeroSelector.deselectButtons([buttonIndex])
deselect selected buttons for all players with 0 or nil
when an index is given only this specific buttonIndex
function HeroSelector.update()
reDo possible selection, textures and enability for all heroButtons.
function HeroSelector.getDisabledIcon(icon)
ReplaceableTextures\CommandButtons\BTNHeroPaladin.tga -> ReplaceableTextures\CommandButtonsDisabled\DISBTNHeroPaladin.tga
function HeroSelector.showFrame(frame, flag[, who])
Set the visibility of frame to flag when who includes the local player by the rules of function HeroSelector.includesPlayer
function HeroSelector.includesPlayer(who, player)
does player include who?
return true, if yes.
return false otherwise
who can be a number(GetPlayerTeam), a race(GetPlayerRace), a player, a force(BlzForceHasPlayer) or
nil => true
function HeroSelector.counterChangeUnitCode(unitCode, add, player)
increases/decreases the counter for picks of unitCode for the player's team.
This can allow/disallow picking this unit for that team.
function HeroSelector.rollOption(player, includeRandomOnly, excludedIndex, category)
get an random Unitcode from the added options
returns an unitcode or nil when none could be found
function HeroSelector.categoryUsed([unitCode])
returns a string listing the categories and the amount of heroes for each.
Or a table containg the category numbers used by the Hero
function HeroSelector.listHeroes(returnOneLineUnitCodes)
returns a string of pickable UnitCodes and names
(true) return "UnitCode,UnitCode,UnitCode"
--]]