Name | Type | is_array | initial_value |
Talent__Button | integer | No | |
Talent__Choice | destructable | No | |
Talent__Event | real | No | |
Talent__Level | integer | No | |
Talent__Unit | unit | No | |
Talent__UnitCode | unitcode | No | |
TalentControlPreventReset | boolean | Yes | |
TalentGUI_Head | string | No | |
TalentGUI_Icon | imagefile | No | |
TalentGUI_Level | integer | No | |
TalentGUI_ReplacedSpell | abilcode | No | |
TalentGUI_Spell | abilcode | No | |
TalentGUI_TasAgi | integer | No | |
TalentGUI_TasArmor | real | No | |
TalentGUI_TasAttackspeed | real | No | |
TalentGUI_TasCastBackswing | real | No | |
TalentGUI_TasCastPoint | real | No | |
TalentGUI_TasDamage | integer | No | |
TalentGUI_TasInt | integer | No | |
TalentGUI_TasLife | integer | No | |
TalentGUI_TasLifeReg | real | No | |
TalentGUI_TasMana | integer | No | |
TalentGUI_TasManaReg | real | No | |
TalentGUI_TasStr | integer | No | |
TalentGUI_TasTurnspeed | real | No | |
TalentGUI_Text | string | No | |
TalentGUI_UnitType | unitcode | No | |
TalentGUI_UnitTypeCopied | unitcode | No | |
TalentGUIAddSpell | trigger | No | |
TalentGUIAddTasSpellField | trigger | No | |
TalentGUIAddTasStats | trigger | No | |
TalentGUICopy | trigger | No | |
TalentGUICreateChoice | trigger | No | |
Unit | unit | No |
Make sure World Editor generates unknown variables in Preferences is set.
Copy the Talent Lua Folder.
export
war3mapImported\TalentBox.fdf
war3mapImported\TalentBox.toc
then import them into your map
Installed
-------
Check Talent Example Heroes, if you write Lua by "hand"
Or TalentGUI if you wana use GUI.
TalentGUI is optional, it can be removed when you don't want it.
Acion_Event Variables can be removed as well, if you don't want it
FrameLoader is a optional helper resource to make Talent work after using warcraft 3 Loading.
As custom UI Save&Load is buggy in Warcraft 3 V 1.31.1 and even in V1.32.10
Fix FourCC is needed in Warcraft 3 V1.31.1 Lua otherwise FourCC breks after Save&Load.
It also upgorades FourCC to support none 4 digit rawcodes.
TasFrameAction is required you need this in your map to use Talent Lui, but only once at a higher place than Talent.
TalentStats is an optional feature making it easier for Choices to give some base bonuses.
-------
-- in 1.31 and upto 1.32.9 PTR (when I wrote this). Frames are not correctly saved and loaded, breaking the game.
-- This runs all functions added to it with a 0s delay after the game was loaded.
FrameLoader = {
OnLoadTimer = function ()
for _,v in ipairs(FrameLoader) do v() end
end
,OnLoadAction = function()
TimerStart(FrameLoader.Timer, 0, false, FrameLoader.OnLoadTimer)
end
}
function FrameLoaderAdd(func)
if not FrameLoader.Timer then
FrameLoader.Trigger = CreateTrigger()
FrameLoader.Timer = CreateTimer()
TriggerRegisterGameEvent(FrameLoader.Trigger, EVENT_GAME_LOADED)
TriggerAddAction(FrameLoader.Trigger, FrameLoader.OnLoadAction)
end
table.insert(FrameLoader, func)
end
-- Credits Luashine
-- FourCC breaks after Save & Load and only worked for 4 digit rawcodes
function FourCC(str)
local n = 0
local len = #str
for i = len, 1, -1 do
n = n + (str:byte(i,i) << 8*(len-i)) -- shift by 0,8,16,24
end
return n
end
--[[ TasFrameAction V1.2 by Tasyen
TasFrameAction is an Lua system to not have to care about Trigger and FrameEvents for FrameAction. All FrameEvents are binded to one trigger that trigger than calls the action for
handles frame Events in one trigger, care only about the actionFunction itself.
calls give Actions inside xpcall.
Supports only one Action per Event+Frame
Example
TasSliderAction(sliderFrame, function(frame, player, value)
print(BlzFrameGetName(frame), GetPlayerId(player), value)
end)
TasButtonAction(frame, function(frame, player))
wrapper for TasFrameAction meant for BUTTON just ControlClick
Removes focus & StopCamera
takes FRAMEEVENT_CONTROL_CLICK from TasFrameAction for this frame
TasSliderAction(frame, function(frame, player, value)[, StepSize, scrollTarget])
action happens when a Value is set
TasSliderAction.AvoidPoll (true) skip actions with the same value in a row by 1 player
set scrollTarget from the outside TasSliderAction.Target[frame] = scrollTarget
scrollTarget most likely removes the action from happen for frame.
takes FRAMEEVENT_MOUSE_WHEEL and FRAMEEVENT_SLIDER_VALUE_CHANGED from TasFrameAction for this frame
TasEditBoxAction(frame[, actionEnter, actionEdit])
skip an action to not have one for that event
function(frame, player, text)
TasDialogAction(frame, function(frame, player, accept))
TasCheckBoxAction(frame, function(frame, player, checked))
TasFrameMouseMoveAction(frame, actionEnter(frame, player), actionLeave(frame, player), actionWheel(frame, player, upwards))
TasFrameMouseUpAction(frame, function(frame, player, rightClick)
Happens when the mouse click is released over frame
rightClick does not work probably during Paused Games
takes FRAMEEVENT_MOUSE_UP
TasMenuAction(frame, function(frame, player, value))
for POPUPMENU
functions above use an entry in TasFrameAction
TasFrameAction(frame, action, frameEvent)
action = function(frame, player, value, text)
]]
TasFrameAction = setmetatable({
EVENTNAME= {
"CONTROL_CLICK", "MOUSE_ENTER", "MOUSE_LEAVE", "MOUSE_UP"
, "MOUSE_DOWN", "MOUSE_WHEEL", "CHECKBOX_CHECKED", "CHECKBOX_UNCHECKED"
, "EDITBOX_TEXT_CHANGED", "POPUPMENU_ITEM_CHANGED", "MOUSE_DOUBLECLICK", "SPRITE_ANIM_UPDATE"
, "SLIDER_VALUE_CHANGED", "DIALOG_CANCEL", "DIALOG_ACCEPT", "EDITBOX_ENTER"
}
,ERROR = function(x)
print("TasFrameAction - ERROR")
print("FrameName", BlzFrameGetName(BlzGetTriggerFrame()), TasFrameAction.EVENTNAME[GetHandleId(BlzGetTriggerFrameEvent())]
, "PlayerId:", GetPlayerId(GetTriggerPlayer())
-- , BlzGetTriggerFrameValue(), BlzGetTriggerFrameText()
)
print(x)
return x
end
}
,{
__call = function(table, frame, action, frameEvent)
-- first call?
if not TasFrameAction.Trigger then
-- FrameEventData
for i = 1, 16 do
TasFrameAction[ConvertFrameEventType(i)] = {}
end
-- yes, Create the Trigger and the click handler.
TasFrameAction.Trigger = CreateTrigger()
TriggerAddAction(TasFrameAction.Trigger, function()
local frame = BlzGetTriggerFrame()
local event = BlzGetTriggerFrameEvent()
-- call the action set for that frame&Event
if TasFrameAction[event][frame] then
xpcall(TasFrameAction[event][frame], TasFrameAction.ERROR, frame, GetTriggerPlayer(), BlzGetTriggerFrameValue(), BlzGetTriggerFrameText())
--TasFrameAction[event][frame](frame, GetTriggerPlayer(), BlzGetTriggerFrameValue(), BlzGetTriggerFrameText())
end
frame = nil
event = nil
end)
end
-- create the click event only when it does not exist yet.
if not TasFrameAction[frameEvent][frame] then
BlzTriggerRegisterFrameEvent(TasFrameAction.Trigger, frame, frameEvent)
end
-- Using [frameEvent][frame] brings a fixed amout of Tables.
TasFrameAction[frameEvent][frame] = action
end
})
TasSliderAction = setmetatable({
AvoidPoll = true -- current value is used by all TasSliderActions
,StepSize = {}
,Target = { } -- some other Frame get scrolled?
,WHEEL = function(frame, player, value, text)
if GetLocalPlayer() == player then
local target = TasSliderAction.Target[frame]
if not target then target = frame end
if value > 0 then
BlzFrameSetValue(target, BlzFrameGetValue(target) + TasSliderAction.StepSize[frame])
else
BlzFrameSetValue(target, BlzFrameGetValue(target) - TasSliderAction.StepSize[frame])
end
end
end
,VALUE = function(frame, player, value, text)
if not TasSliderAction[frame] then return end
-- avoid Polling
if not TasSliderAction.AvoidPoll or TasSliderAction.AvoidPollData[player][frame] ~= value then
TasSliderAction.AvoidPollData[player][frame] = value
TasSliderAction[frame](frame, player, value)
end
end
}
,{__call = function(table, frame, action, stepSize, scrollTarget)
-- first call?
if not TasSliderAction.AvoidPollData then
TasSliderAction.AvoidPollData = {}
for i=0, bj_MAX_PLAYER_SLOTS - 1 do TasSliderAction.AvoidPollData[Player(i)] = __jarray(0.0) end
end
TasFrameAction(frame, TasSliderAction.WHEEL, FRAMEEVENT_MOUSE_WHEEL)
TasFrameAction(frame, TasSliderAction.VALUE, FRAMEEVENT_SLIDER_VALUE_CHANGED)
if type(action) =="function" then
TasSliderAction[frame] = action
end
TasSliderAction.StepSize[frame] = stepSize or 1
TasSliderAction.Target[frame] = scrollTarget
end
})
TasSliderAction.Set = TasSliderAction
TasButtonAction = setmetatable({
ACTION = function(frame, player, value, text)
-- remove Focus for the local clicking player
if player == GetLocalPlayer() then
BlzFrameSetEnable(frame, false)
BlzFrameSetEnable(frame, true)
StopCamera()
end
-- call the action set for that frame
TasButtonAction[frame](frame, player)
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasButtonAction.ACTION, FRAMEEVENT_CONTROL_CLICK)
TasButtonAction[frame] = action
end
})
TasButtonAction.Set = TasButtonAction
TasEditBoxAction = setmetatable({
A = {}
,B = {}
,ENTER = function(frame, player, value, text)
TasEditBoxAction.A[frame](frame, player, text)
end
,EDIT = function(frame, player, value, text)
TasEditBoxAction.B[frame](frame, player, text)
end
},{
__call = function(table, frame, actionEnter, actionEdit)
if actionEnter then
TasFrameAction(frame, TasEditBoxAction.ENTER, FRAMEEVENT_EDITBOX_ENTER)
TasEditBoxAction.A[frame] = actionEnter
end
if actionEdit then
TasFrameAction(frame, TasEditBoxAction.EDIT, FRAMEEVENT_EDITBOX_TEXT_CHANGED)
TasEditBoxAction.B[frame] = actionEdit
end
end
})
TasEditBoxAction.Set = TasEditBoxAction
TasDialogAction = setmetatable({
ACTION = function(frame, player)
TasDialogAction[frame](frame, player, BlzGetTriggerFrameEvent() == FRAMEEVENT_DIALOG_ACCEPT)
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasDialogAction.ACTION, FRAMEEVENT_DIALOG_ACCEPT)
TasFrameAction(frame, TasDialogAction.ACTION, FRAMEEVENT_DIALOG_CANCEL)
TasDialogAction[frame] = action
end
})
TasDialogAction.Set = TasDialogAction
TasCheckBoxAction = setmetatable({
ACTION = function(frame, player)
TasCheckBoxAction[frame](frame, player, BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED)
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasCheckBoxAction.ACTION, FRAMEEVENT_CHECKBOX_CHECKED)
TasFrameAction(frame, TasCheckBoxAction.ACTION, FRAMEEVENT_CHECKBOX_UNCHECKED)
TasCheckBoxAction[frame] = action
end
})
TasCheckBoxAction.Set = TasCheckBoxAction
TasFrameMouseMoveAction = setmetatable({
A = {}
,B = {}
,C = {}
,ENTER = function(frame, player)
TasFrameMouseMoveAction.A[frame](frame, player)
end
,LEAVE = function(frame, player)
TasFrameMouseMoveAction.B[frame](frame, player)
end
,WHEEL = function(frame, player, value)
TasFrameMouseMoveAction.C[frame](frame, player, value > 0)
end
},{
__call = function(table, frame, actionEnter, actionLeave, actionWheel)
if actionEnter then
TasFrameAction(frame, TasFrameMouseMoveAction.ENTER, FRAMEEVENT_MOUSE_ENTER)
TasFrameMouseMoveAction.A[frame] = actionEnter
end
if actionLeave then
TasFrameAction(frame, TasFrameMouseMoveAction.LEAVE, FRAMEEVENT_MOUSE_LEAVE)
TasFrameMouseMoveAction.B[frame] = actionLeave
end
if actionWheel then
TasFrameAction(frame, TasFrameMouseMoveAction.WHEEL, FRAMEEVENT_MOUSE_WHEEL)
TasFrameMouseMoveAction.C[frame] = actionWheel
end
end
})
TasFrameMouseMoveAction.Set = TasFrameMouseMoveAction
TasFrameMouseUpAction = setmetatable({
TriggerCount = 0
,ACTION = function(frame, player)
-- during Pause EVENT_PLAYER_MOUSE_UP does not work, -> when The counter didn't increase since last Time do not allow this count as right click
local clickWorked = GetTriggerExecCount(TasFrameMouseUpAction.MouseTrigger) > TasFrameMouseUpAction.TriggerCount
TasFrameMouseUpAction[frame](frame, player, TasFrameMouseUpAction.RightClick[player] and clickWorked)
TasFrameMouseUpAction.TriggerCount = GetTriggerExecCount(TasFrameMouseUpAction.MouseTrigger)
end
},{
__call = function(table, frame, action)
if not TasFrameMouseUpAction.MouseTrigger then
TasFrameMouseUpAction.RightClick = __jarray(false)
TasFrameMouseUpAction.MouseTrigger = CreateTrigger()
for i = 0, bj_MAX_PLAYERS - 1 do
TriggerRegisterPlayerEvent(TasFrameMouseUpAction.MouseTrigger, Player(i), EVENT_PLAYER_MOUSE_UP)
end
TriggerAddAction(TasFrameMouseUpAction.MouseTrigger, function()
TasFrameMouseUpAction.RightClick[GetTriggerPlayer()] = GetHandleId(BlzGetTriggerPlayerMouseButton()) == GetHandleId(MOUSE_BUTTON_TYPE_RIGHT)
end)
end
TasFrameAction(frame, TasFrameMouseUpAction.ACTION, FRAMEEVENT_MOUSE_UP)
TasFrameMouseUpAction[frame] = action
end
})
TasFrameMouseUpAction.Set = TasFrameMouseUpAction
TasMenuAction = setmetatable({
ACTION = function(frame, player, value)
TasMenuAction[frame](frame, player, value)
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasMenuAction.ACTION, FRAMEEVENT_POPUPMENU_ITEM_CHANGED)
TasMenuAction[frame] = action
end
})
TasMenuAction.Set = TasMenuAction
--[[
Talent Lui 1.39
By Tasyen
===========================================================================
Talent provides at wanted Levels a choice from a collection (Tier), from which the user picks one.
Tiers are unitType specific (a paladin has different Choices then a demon hunter), This also includes the Levels obtaining them.
One can choices by Events or one can bind Code beeing executed when picking a choice.
Regardless using Events or binded , creating a reset (revert picking a choice) is quite easy.
Talent is mui.
===========================================================================
function TalentMacroDo(unit, text)
executes a bunch of Picks/Resets for unit
"-U123" ->Unlearn all, Pick 1, Pick 2, Pick 3
"-112" -> Pick 1, Pick 1, Pick 2, s has to start with "-"
Each done action will evoke events/actions.
function TalentGetMacro(unit)
returns the text to be used inside TalentMacroDo to pick the current Picks.
the use of this function is to save Talentpicks in files.
function TalentAddUnitSheet(unitSheetFunction)
unitSheetFunction will be called when the game started.
function TalentHeroCopy(unitCode, copyOrigin)
units of unitCode will use the Talents of copyOrigin.
also works for units but your need to make sure the unit has Talent data given by TalentAddUnit(unit)
function TalentHeroCreate(unitCode)
Create a plan for units of that Type has to be done before adding choices/tiers.
This should be the first Talent related action inside a unitSheetFunction. Copies should not use this.
function TalentHeroCreateTier(unitCode, level)
Creates for unitCode at level an tier.
You should create Tiers from level 1 to x you can have gaps but it is recommented to add the rising.
function TalentHeroCreateChoice(unitCode) returns table
Adds to the tier with the highest level of that unitCode an new choice, should be the last created one.
Returns the new choice
function TalentHeroCreateChoiceAtLevel(unitCode, level) returns table
calls TalentHeroCreate if needed.
Creates a tier if needed and creates a new choice to it.
Returns the new choice
function TalentChoiceAddAbility(choice, gainedAbility, lostAbility)
when picking choice the unit gains gainedAbility and loses loseAbility with loseAbility = 0 no ability is lost.
This behavior can be altered much with Settings.
function TalentChoiceAddSpells(choice, spells)
Add many abilities to this choice in one String
TalentChoiceAddSpells(choice, "AHbz,AHwe,AHab,AHmt")
function TalentChoiceCreateAddSpells(...)
creates a new choice, add it to the last created Tier. This choice will give all abilities mentioned
This will also set choice.Text to: GetLocalizedString("COLON_SPELLS") spellA, spellB, ...
Expected Format TalentChoiceCreateAddSpells('AHbz','AHwe','AHab','AHmt')
function TalentChoiceCreateReplaceSpell(oldSpell, newSpell )
creates a new choice, add it to the last created Tier. This choice will take away oldSpell and give newSpell
function TalentChoiceCreateAddSpell(spell, useButtonInfos)
Create a new choice giving spell, useButtonInfos(true) sets Text/Head/Icon to the one of spellCode
function TalentChoiceCreateTasUnitBonusEx(bonusTable)
Create a new choice that provides an TasUnitBonus
wrappers they use what you last mentioned for removed arguments from the not-Ex versions.
function TalentHeroCreateTierEx(level)
function TalentHeroCreateChoiceEx()
function TalentHeroCreateChoiceAtLevelEx(level)
function TalentChoiceAddAbilityEx(gainedAbility, lostAbility)
function TalentChoiceAddSpellsEx(spells)
function TalentMacroDoEx(player, text)
wrapper for current TalentTarget of player
function TalentGetMacroEx(player)
function TalentGetUnitCode(unitCode)
returns the unitCode beeing used inside Talent.
supports unitCode and unit
function TalentAddUnit(unit)
Manualy add an Unit to Talent, use this when The autodetection is disabled.
function TalentAddSelection(unit)
Manualy check for choices.
===========================================================================
Variables inside Events and Code Binding:
===========================================================================
udg_Talent__Unit = the unit doing the choice
udg_Talent__UnitCode = the unitCode the unit is using
udg_Talent__Choice = selected choice its a table.
udg_Talent__Level = the level from which this choice/Tier is.
udg_Talent__Button = the Index of the Button used, 1 to Settings.BoxOptionMaxCount.
, this variable is needed for Event based Talent usage.
===========================================================================
Event:
===========================================================================
To identyfy a choice in an Event use udg_Talent__UnitCode, udg_Talent__Level and udg_Talent__Button.
Inside condition check for heroType, to use the correct talent tree for this Event.
udg_Talent__UnitCode equal to (==) "wanted orignal Type"
Now create ifs one for each udg_Talent__Level that tree has. (it is the level of the tier picked from).
Inside this ifs check the Button beeing used: udg_Talent__Button equal (==) 1 -> yes, do actions of Level x Button 1
Create another one with udg_Talent__Button equal (==) 2 -> yes, do actions of Level x, Button 2.
You can skip Button Ifs not beeing used for that hero-Class on that Level.
udg_Talent__Event
1 => on Choice.
after the Auotskills are added
2 => Tier aviable, does only when there is no choice for this hero yet, Reset does not trigger this event.
3 => Finished all choices of its hero Type.
-1 => on Reset for each choice reseted.
before the autoskills are removed
Events can be indivudal (de)activaded inside Settings
===========================================================================
Choice Data
===========================================================================
choice.OnLearn = when that choice is picked function(unit, unitCode, buttonNr, choice, tierLevel)
choice.OnReset = when that choice is lost function(unit, unitCode, buttonNr, choice, tierLevel)
choice.Head = The Title shown
choice.Text = The description of this choice
choice.Icon = The Icon shown
choice.Abilities = a table with paris of gained/lost abilities
inside the action udg_Talent__Choice.Head would give the headText.
=====
--]]
do
-- the table TalentBox should be in TalentBox but requires more work to seperate
TalentBox = {
Settings = {},
Trigger = {},
Frame = {},
Control = {},
OptionTitlePrefix = __jarray(""),
OptionTitleSufix = __jarray("")
}
Talent = {
Settings = { UnitSheet = {}},
Trigger = {}
,Strings = {}
}
local Settings = Talent.Settings
do
--System Starts itself, (false) -> use TalentStartInit()
Settings.AutoRun = true
--AutoDetectUnitsEvent (true) will create an " enters map" for Talent.Trigger.AutoDetect
--AutoDetectUnitsInit (true) will enum all units on the map at 0.0s and add all units having TalentData to Talent.
Settings.AutoDetectUnitsEvent = true
Settings.AutoDetectUnitsInit = true
--When you disabled both you have to manualy add Units to Talent.
--Increases the Level of abilities gained by choices, if the is already owned.
Settings.ImproveAbilities = true
--(true) only add the new if the has the to replaced Ability
Settings.ReplacedAbilityRequiered = true
--Throw an Event when an picks a choiceTalent
Settings.ThrowEventPick = true
--Throw an Event when an gains a choice to pick a talent
Settings.ThrowEventAvailable = true
--Throw an Event when an resets a choice
Settings.ThrowEventReset = true
--Throw an Event when an picked the last Talent of its unitType.
Settings.ThrowEventFinish = true
-- Allow using Talent for unit, this is for more dynamic conditions like Position, has buff and such
Settings.UseCondition = function(unit)
local allowed = true
udg_Talent__Unit = unit
if gg_trg_TasTalent_UseCondition then allowed = TriggerEvaluate(gg_trg_TasTalent_UseCondition) end
if not allowed then
DisplayTimedTextToPlayer(GetOwningPlayer(unit), 0, 0, 20, GetUnitName(unit).." can currently not use Talent.")
end
return allowed
end
end
function TalentHeroLevel2SelectionIndex(unitCode, level)
unitCode = TalentGetUnitCode(unitCode)
if not Talent[unitCode]["Tier"][level] then --The level has no tier?
return -1
end
-- pairs sorts it bad so loop from 1 to Talent[unitCode].MaxLevel
local counter = 0
for i = 1, Talent[unitCode].MaxLevel do
if Talent[unitCode]["Tier"][i] then
counter = counter + 1
if i == level then
return counter
end
end
end
return 0
end
function TalentMacroDo(unit, text)
if not Settings.UseCondition(unit) then return end
if SubString(text, 0, 1) ~= "-" then --Invalid macro, macro has to start with "-"
return
end
local sLength = StringLength(text)
for i = 0, sLength
do
local char = SubString(text, i, i + 1)
if char == "U" or char == "u" then
while (TalentResetDo(unit)) do end
end
local charAsInt = S2I(char)
if charAsInt > 0 then
TalentPickDo(unit, charAsInt)
end
end
end
function TalentMacroDoEx(player, text)
TalentMacroDo(TalentBox.Control[player].Target, text)
end
function TalentGetMacro(unit)
local text = "-U"
for int = 1, TalentUnitGetSelectionsDone(unit) do
text = text .. Talent[unit].SelectionsDone[int].ButtonNr
end
return text
end
function TalentGetMacroEx(player)
return TalentGetMacro(TalentBox.Control[player].Target)
end
function TalentHeroCreate(unitCode)
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
Talent[unitCode] = { Tier = {}, MaxLevel = 0 }
Talent.LastUsedUnitCode = unitCode
end
function TalentGetUnitCode(unitCode)
if type(unitCode) == "userdata" then
local unit = unitCode
unitCode = GetUnitTypeId(unit)
if Talent[unit] and Talent[unit].Copy then return TalentGetUnitCode(Talent[unit].Copy) end
end
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
--if that unitCode has data check if it has copyData
if Talent[unitCode] and Talent[unitCode].Copy then return TalentGetUnitCode(Talent[unitCode].Copy) end
return unitCode
end
function TalentHeroCopy(unitCode, copyOrigin)
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
if type(copyOrigin) == "string" then copyOrigin = FourCC(copyOrigin) end
if not Talent[unitCode] then
Talent[unitCode] = {Copy = copyOrigin}
else Talent[unitCode].Copy = copyOrigin end
end
function TalentHeroCreateTier(unitCode, level)
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
Talent[unitCode]["Tier"][level] = {}
Talent[unitCode].MaxLevel = IMaxBJ(Talent[unitCode].MaxLevel, level)
Talent.LastUsedUnitCode = unitCode
end
function TalentHeroCreateTierEx(level) TalentHeroCreateTier(Talent.LastUsedUnitCode, level) end
function TalentHeroCreateChoiceAtLevel(unitCode, level)
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
if not Talent[unitCode] then TalentHeroCreate(unitCode) end
if not Talent[unitCode]["Tier"][level] then --create not existing Tier
Talent[unitCode]["Tier"][level] = {}
Talent[unitCode].MaxLevel = IMaxBJ(Talent[unitCode].MaxLevel, level)
end
local choice = { Abilities = {}, Icon = "", Text = "", Head = "" }
Talent.LastUsedUnitCode = unitCode
Talent.LastUsedChoice = choice
table.insert(Talent[unitCode]["Tier"][level], choice) --add new choice
return choice
end
function TalentHeroCreateChoiceAtLevelEx(level) return TalentHeroCreateChoiceAtLevel(Talent.LastUsedUnitCode, level) end
function TalentHeroCreateChoice(unitCode) --adds a choice to the highest Level Tier for that hero.
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
local choice = { Abilities = {}, Icon = "", Text = "", Head = "" }
Talent.LastUsedUnitCode = unitCode
Talent.LastUsedChoice = choice
table.insert(Talent[unitCode]["Tier"][Talent[unitCode].MaxLevel], choice) --add new choice
return choice
end
function TalentHeroCreateChoiceEx() return TalentHeroCreateChoice(Talent.LastUsedUnitCode) end
function TalentChoiceCreateAddSpell(spellCode, useButtonInfos)
if type(spellCode) == "string" then spellCode = FourCC(spellCode) end
local choice = TalentHeroCreateChoiceEx()
TalentChoiceAddAbilityEx(spellCode, 0)
if useButtonInfos then
choice.Text = BlzGetAbilityExtendedTooltip(spellCode,0)
choice.Head = BlzGetAbilityTooltip(spellCode,0)
choice.Icon = BlzGetAbilityIcon(spellCode)
end
return choice
end
function TalentChoiceCreateReplaceSpell(oldSpell, newSpell )
if type(oldSpell) == "string" then oldSpell = FourCC(oldSpell) end
if type(newSpell) == "string" then newSpell = FourCC(newSpell) end
local choice = TalentHeroCreateChoiceEx()
TalentChoiceAddAbilityEx(newSpell, oldSpell)
return choice
end
function TalentChoiceCreateAddSpells(...)
local arg = {...} -- get the variable arguments
local choice = TalentHeroCreateChoiceEx()
choice.Text = GetLocalizedString("COLON_SPELLS")
for i = 1, #arg, 1 do
if type(arg[i]) == "string" then arg[i] = FourCC(arg[i]) end
TalentChoiceAddAbilityEx(arg[i], 0)
if i == 1 then
choice.Text = choice.Text .. " " .. GetObjectName(arg[i]).."|r"
else
choice.Text = choice.Text .. ", " .. GetObjectName(arg[i]).."|r"
end
end
return choice
end
function TalentChoiceAddAbility(choice, gainedAbility, lostAbility)
if type(gainedAbility) == "string" then gainedAbility = FourCC(gainedAbility) end
if lostAbility and type(lostAbility) == "string" then lostAbility = FourCC(lostAbility) end
table.insert(choice.Abilities, {gainedAbility, lostAbility})
end
function TalentChoiceAddAbilityEx(gainedAbility, lostAbility) TalentChoiceAddAbility(Talent.LastUsedChoice, gainedAbility, lostAbility) end
function TalentChoiceAddSpells(choice, spells)
local startIndex = 1
while startIndex + 3 <= string.len(spells) do
local skillCode = string.sub(spells, startIndex, startIndex + 3)
startIndex = startIndex + 5
TalentChoiceAddAbility(choice, skillCode)
end
return choice
end
function TalentChoiceAddSpellsEx(spells) TalentChoiceAddSpells(Talent.LastUsedChoice, spells) end
function TalentChoiceCreateTasUnitBonusEx(bonusTable)
local choice = TalentHeroCreateChoiceEx()
choice.TasUnitBonus = bonusTable
return choice
end
function TalentUnitAddSelectionDone(unit, level, buttonNr)
if not Talent[unit] then TalentAddUnit(unit) end
Talent[unit].SelectionsDoneCount = Talent[unit].SelectionsDoneCount + 1
Talent[unit].MaxLevel = IMaxBJ(Talent[unit].MaxLevel, level)
Talent[unit].SelectionsDone[Talent[unit].SelectionsDoneCount] = {
Level = level,
ButtonNr = buttonNr,
UnLearned = false}
--table.insert(Talent[unit].SelectionsDone, {Level = level, ButtonNr = buttonNr})
end
function TalentUnitGetButtonUsed(unit, level)
for k,v in pairs(Talent[unit].SelectionsDone)
do
if v.Level == level then return v.ButtonNr end
end
return 0
end
function TalentUnitGetSelectionsDone(unit)
return Talent[unit].SelectionsDoneCount
end
function TalentUnitGetCurrentLevel(unit)
if Talent[unit] then
return Talent[unit].CurrentLevel
else
return 0
end
end
function TalentUnitSetCurrentLevel(unit, level)
Talent[unit].CurrentLevel = level
end
function TalentUnitSetHasChoice(unit, flag)
Talent[unit].HasChoice = flag
end
function TalentAddSkill(unit, skillGained, newLevel)
local skillGainedLevel = GetUnitAbilityLevel(unit, skillGained)
if skillGainedLevel == 0 then --Already got skillGained?
UnitAddAbility(unit, skillGained)
UnitMakeAbilityPermanent(unit, true, skillGained)
SetUnitAbilityLevel(unit, skillGained, newLevel)
elseif Settings.ImproveAbilities then--Can upgrade Levels?
SetUnitAbilityLevel(unit, skillGained, skillGainedLevel + 1)
end
end
function TalentRemoveSkill(unit, skillLost)
local skillLostLevel = GetUnitAbilityLevel(unit, skillLost)
if Settings.ImproveAbilities and skillLostLevel > 1 then --Can Decrease Level?
skillLostLevel = skillLostLevel - 1
SetUnitAbilityLevel(unit, skillLost, skillLostLevel)
else
UnitRemoveAbility(unit, skillLost)
end
end
function TalentReplaceSkill(unit, skillReplaced, skillGained)
local skillReplacedLevel = GetUnitAbilityLevel(unit, skillReplaced)
if not Settings.ReplacedAbilityRequiered or skillReplacedLevel ~= 0 then
TalentRemoveSkill(unit, skillReplaced)
if skillGained and skillGained > 0 then
TalentAddSkill(unit, skillGained, skillReplacedLevel)
end
end
end
function TalentAddUnit(unit)
if not Talent[unit] then
Talent[unit] = {
SelectionsDone = {},
SelectionsDoneCount = 0,
CurrentLevel = 0,
HasChoice = false,
MaxLevel = 0
}
end
end
function TalentAddSelection(unit)
local unitCode = TalentGetUnitCode(unit)
local currentLevel = IMaxBJ(GetHeroLevel(unit), GetUnitLevel(unit))
local lastSelection = TalentUnitGetCurrentLevel(unit)
-- Only show 1 SelectionContainer at the same time.
if Talent[unit].HasChoice then return end
-- pairs sorts it bad so loop from 1 to Talent[unitCode].MaxLevel
--for level, tier in pairs(Talent[unitCode]["Tier"]) do
for level = 1, Talent[unitCode].MaxLevel do
if level > currentLevel then break end
if level > lastSelection and Talent[unitCode]["Tier"][level] then
TalentUnitSetCurrentLevel(unit, level)
TalentUnitSetHasChoice(unit, true)
if Settings.ThrowEventAvailable then --Throw Selection Event
udg_Talent__Choice = nil
udg_Talent__Unit = unit
udg_Talent__UnitCode = unitCode
udg_Talent__Level = level
globals.udg_Talent__Event = 0.0
globals.udg_Talent__Event = 2.0
globals.udg_Talent__Event = 0.0
end
--break
return
end
end
--if this part of is reached there is no choice avaible
end
function TalentCallBackError(x)
print(TalentCallBackErrorAction,"Unit",GetUnitName(udg_Talent__Unit), "TalentUnitCode", GetObjectName(udg_Talent__UnitCode),"ButtonNr", udg_Talent__Button, "TierLevel", udg_Talent__Level)
print(x)
end
function TalentPickDo(unit, buttonNr)
if not Settings.UseCondition(unit) then return end
local unitCode = TalentGetUnitCode(unit)
local tierLevel = Talent[unit].CurrentLevel
local tier = Talent[unitCode]["Tier"][tierLevel]
local choice = tier[buttonNr]
if not Talent[unit].HasChoice or not choice then --Requiers to have a Choice
return false
end
for k, v in pairs(choice.Abilities) do
local skillGained = v[1]
local skillReplaced = v[2]
if skillReplaced and skillReplaced > 0 then --Replaces?
TalentReplaceSkill(unit, skillReplaced, skillGained)
else
TalentAddSkill(unit, skillGained,1)
end
end
--Load Data for Action/Event
udg_Talent__Unit = unit
udg_Talent__UnitCode = unitCode
udg_Talent__Button = buttonNr
udg_Talent__Choice = choice
udg_Talent__Level = tierLevel
--print(GetObjectName(udg_Talent__UnitCode), "Level: "..udg_Talent__Level,"ButtonNr: "..udg_Talent__Button)
-- Talent.TasStats api
-- allows to give choices basic boni by setting a TableKey to x
if Talent.TasStats then
for k, v in pairs(Talent.TasStats) do
if choice[k] then v(unit, choice[k]) end
end
if choice.TasSpellField then
local abi
for spellCode, data in pairs(choice.TasSpellField) do
if type(spellCode) == "string" then spellCode = FourCC(spellCode) end
abi = BlzGetUnitAbility(unit, spellCode)
for field, value in pairs(data) do
TalentTasSpellField(abi, field, value, "+")
end
-- force update
IncUnitAbilityLevel(unit, spellCode)
DecUnitAbilityLevel(unit, spellCode)
end
abi = nil
end
end
-- have the lib TasUnitBonus & this choice want to apply a TasUnitBonus
if TasUnitBonus and choice.TasUnitBonus then TasUnitBonus.UnitAdd(unit, choice.TasUnitBonus, 1) end
if not TasUnitBonus and choice.TasUnitBonus then print("Want to use TasUnitBonus, but not found", GetObjectName(unitCode), tierLevel, buttonNr) end
if choice.OnLearn then TalentCallBackErrorAction = "OnLearn" xpcall(choice.OnLearn, TalentCallBackError, unit, unitCode, buttonNr, choice, tierLevel) end
if Settings.ThrowEventPick then --Throw Selection Event
globals.udg_Talent__Event = 0.0
globals.udg_Talent__Event = 1.0
globals.udg_Talent__Event = 0.0
end
--Save Choice don
TalentUnitAddSelectionDone(unit, tierLevel, buttonNr)
--Unmark having a selection.
TalentUnitSetHasChoice(unit, false)
--Last choice for this heroType?
if Talent[unitCode].MaxLevel == tierLevel then
--Throw Finish Choices Event.
if Settings.ThrowEventFinish then
globals.udg_Talent__Event = 0.0
globals.udg_Talent__Event = 3.0
globals.udg_Talent__Event = 0.0
end
else
--Check for further choices.
TalentAddSelection(unit)
end
return true
end
function TalentResetDo(unit)
if not Settings.UseCondition(unit) then return false end
if Talent[unit].SelectionsDoneCount <= 0 then return false end --No selections done -> skip the rest.
local lastSelection = Talent[unit].SelectionsDone[Talent[unit].SelectionsDoneCount]
local unitCode = TalentGetUnitCode(unit)
local buttonNr = lastSelection.ButtonNr
local tierLevel = lastSelection.Level
local tier = Talent[unitCode]["Tier"][tierLevel]
local choice = tier[buttonNr]
--Load Data for Action/Event
udg_Talent__Unit = unit
udg_Talent__UnitCode = unitCode
udg_Talent__Button = buttonNr
udg_Talent__Choice = choice
udg_Talent__Level = tierLevel
--print(GetObjectName(udg_Talent__UnitCode), "Level: "..udg_Talent__Level,"ButtonNr: "..udg_Talent__Button)
-- Talent.TasStats api
-- allows to give choices basic boni by setting a TableKey to x
if Talent.TasStats then
for k, v in pairs(Talent.TasStats) do
if choice[k] then v(unit, -choice[k]) end
end
if choice.TasSpellField then
local abi
for spellCode, data in pairs(choice.TasSpellField) do
if type(spellCode) == "string" then spellCode = FourCC(spellCode) end
abi = BlzGetUnitAbility(unit, spellCode)
for field, value in pairs(data) do
TalentTasSpellField(abi, field, value, "-")
end
-- force update
IncUnitAbilityLevel(unit, spellCode)
DecUnitAbilityLevel(unit, spellCode)
-- force update by disable + enable tells auras to send a update pulse
BlzUnitDisableAbility(unit, spellCode, true, true)
BlzUnitDisableAbility(unit, spellCode, false, false)
end
abi = nil
end
end
if TasUnitBonus and choice.TasUnitBonus then TasUnitBonus.UnitAdd(unit, choice.TasUnitBonus, -1) end
if choice.OnReset then TalentCallBackErrorAction = "OnReset" xpcall(choice.OnReset, TalentCallBackError, unit, unitCode, buttonNr, choice, tierLevel) end
--Remove Autoadded Skills
for k, v in pairs(choice.Abilities)do
local skillGained = v[1]
local skillReplaced = v[2]
if skillReplaced and skillReplaced > 0 then --Replaces?
TalentReplaceSkill(unit, skillGained, skillReplaced)
else
TalentRemoveSkill(unit, skillGained)
end
end
lastSelection.UnLearned = true
Talent[unit].SelectionsDoneCount = Talent[unit].SelectionsDoneCount - 1
TalentUnitSetCurrentLevel(unit, tierLevel)
TalentUnitSetHasChoice(unit, true)
if Settings.ThrowEventReset then --Throw a that this choice is going to be lost.
globals.udg_Talent__Event = 0.0
globals.udg_Talent__Event = -1.0
globals.udg_Talent__Event = 0.0
end
return true
end
function TalentInit()
Talent.Trigger.LevelUp = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(Talent.Trigger.LevelUp, EVENT_PLAYER_HERO_LEVEL, nil)
TriggerAddAction(Talent.Trigger.LevelUp, function()
TalentAddSelection(GetTriggerUnit())
end)
--Get Choices on Entering Map for lvl 1.
if Settings.AutoDetectUnitsEvent then
Talent.Trigger.AutoDetect = CreateTrigger()
TriggerRegisterEnterRectSimple(Talent.Trigger.AutoDetect, GetPlayableMapRect())
TriggerAddAction(Talent.Trigger.AutoDetect, function() TalentAddUnit(GetTriggerUnit()) TalentAddSelection(GetTriggerUnit()) end)
TriggerAddCondition(Talent.Trigger.AutoDetect, Condition( function() return Talent[TalentGetUnitCode(GetTriggerUnit())] ~= nil end))
end
end
--Adds an function to the queue beeing executed as soon the game started.
function TalentAddUnitSheet(unitSheetFunction)
table.insert(Settings.UnitSheet, unitSheetFunction)
end
function TalentUnitSheetError(x)
print("Talent UnitSheet Error")
local codeString = string.pack(">I4", Talent.LastUsedUnitCode)
print(GetObjectName(Talent.LastUsedUnitCode), codeString)
Talent.HaveUnitSheetError = true
print(x)
end
--Calls all unitSheetFunctions Added as soon the game starts.
do
function TalentStartInit()
TalentInit()
TalentBox.Control.SelectionCheckGroup = CreateGroup()
if TalentBoxInit then TalentBoxInit() end
if TalentGridInit then TalentGridInit() end
--create needed tables for players
for i = 0, bj_MAX_PLAYER_SLOTS - 1, 1 do
TalentBox.Control[Player(i)] = {}
TalentBox.Control[Player(i)].Levels = {}
TalentBox.Control[Player(i)].PreventResetButton = false
TalentBox.Control[Player(i)].SingleMode = true
end
if TalentPreMadeChoiceStrings then TalentPreMadeChoiceStrings() end
--call all added UnitSheets
for k,v in pairs(Settings.UnitSheet)
do
xpcall(v, TalentUnitSheetError)
end
if not Talent.HaveUnitSheetError and Settings.AutoDetectUnitsInit then
--Add possible choices to all Units having the Talent book.
local g = TalentBox.Control.SelectionCheckGroup
GroupEnumUnitsInRect(g, GetPlayableMapRect(), nil)
for i = 0, BlzGroupGetSize(g) - 1 do
unit = BlzGroupUnitAt(g, i)
if Talent[TalentGetUnitCode(unit)] ~= nil then
TalentAddUnit(unit)
TalentAddSelection(unit)
end
end
--cleanup
GroupClear(g)
end
Settings.UnitSheet = nil
end
if Settings.AutoRun then
local real = MarkGameStarted
function MarkGameStarted()
real()
TalentStartInit()
end
end
end
end
--[[
TalentGrid 1.2b
By Tasyen
===========================================================================
TalentGrid displays Tiers in rows one can scroll up and down.
===========================================================================
--]]
do
TalentGrid = {
Trigger = {},
Settings = {},
Frame = {},
OptionTitlePrefix = __jarray(""),
OptionTitleSufix = __jarray(""),
Offset = __jarray(0)
}
-- one can change most Settings from outside of TalentGrid by using TalentGrid.Settings.<key> = x
-- beaware that some Settings should not be changed or don't change anything at runtime
local Settings = TalentGrid.Settings
Settings.StringButtonResetTooltip = "Unlearn all choosen Talents.|nIn GroupMode this applies to all selected using the same Talents"
Settings.StringButtonResetText = "UnLearn"
Settings.StringButtonShowText = "Show TalentGrid"
Settings.StringTitlePrefix = "Talent: "
Settings.StringNoTalentUser = "No Talent User"
Settings.StringTooltipGroupModeHead = "Group Mode"
Settings.StringTooltipGroupModeText = "During GroupMode all selected Units using the same Talent and with the same amount of selections done, will do picks/Unlearn/Relearn together.|n|nClick to disable Group Mode."
Settings.StringTooltipGroupModeIcon = "ui/widgets/battlenet/bnet-mainmenu-customteam-up"
Settings.StringTooltipSingleModeHead = "Single Mode"
Settings.StringTooltipSingleModeText = "Only the selected Unit will do picks, unlearns|n|nClick to enable Group Mode."
Settings.StringTooltipSingleModeIcon = "ui/widgets/battlenet/bnet-mainmenu-customteam-disabled"
Settings.Scale = 1.0
Settings.ToolTipScale = 1.0
-- under which parent TalentGrid & TalentGridShow are created?
Settings.Parent = function()
return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
end
--Settings.Pack = true, changes the Size of the UI so that the current displayed fits.
--it is recommented to use a cornerPoint for Settings.PosType with enabled Pack
Settings.Pack = false
--Settings.ESCClose = true, Pressing ESC will close the UI
Settings.ESCClose = true
-- Closes the UI when no unit is selected
Settings.AutoCloseWithoutSelection = false
-- Closes the UI after doing a choice without being able to pick again
Settings.AutoCloseWhenDone = true
--With false the unlearn Button won't be shown/enabled
--TalentBox.Control[GetConvertedPlayerId(player)].PreventResetButton = true will prevent player to use reset/Relearn button.
Settings.HaveResetButton = true
-- FixedTarget (true) Talent will not change TalentBox.Control[player].Target
Settings.FixedTarget = false
-- OnlyOwnUnit (true) can not pick Talents for Shared Control of other player's Units.
Settings.OnlyOwnUnit = false
--The Buttons of the Grid to Pick/display choices.
--ColsAmount should be equal or higher than the highest choice count in a tier
-- Do not set Cols/Rows during runtime
Settings.RowsAmount = 5
Settings.ColsAmount = 5
Settings.ResetSizeX = 0.07
Settings.ResetSizeY = 0.025
--Default Position of the TalentGrid
Settings.PosX = 0.4
Settings.PosY = 0.55
Settings.PosType = FRAMEPOINT_TOP
Settings.OptionHaveTooltip = true
-- Tooltip Pos
Settings.OptionTooltipFixedPos = true
-- Fixed
Settings.OptionTooltipPosX = 0.79
Settings.OptionTooltipPosY = 0.165
Settings.OptionTooltipPos = FRAMEPOINT_BOTTOMRIGHT
-- Relative to TalentGrid
Settings.OptionTooltipRelaPosX = 0.001
Settings.OptionTooltipRelaPosY = -0.052
Settings.OptionTooltipRelaPosA = FRAMEPOINT_TOPLEFT
Settings.OptionTooltipRelaPosB = FRAMEPOINT_TOPRIGHT
-- XSize of the Tooltip
Settings.OptionTooltipSizeX = 0.2
--Bigger Options allow bigger texts, but also take more space of the screen, which reduces the possible amount of showing options in one tier.
--XSize of an option in the TalentGrid
Settings.OptionSizeX = 0.11
--YSize of an option in the TalentGrid
Settings.OptionSizeY = 0.04
Settings.OptionShowText = true
--IconSize, should be smaller than OptionSizeY and OptionSizeX
Settings.OptionIconSize = 0.03
Settings.OptionLevelSizeX = 0.04
--YSize of an option in the TalentGrid
Settings.OptionLevelSizeY = 0.04
--Default Position for the ShowTalentGridButton
Settings.ShowButtonPosX = 0.00
Settings.ShowButtonPosY = 0.28
Settings.ShowButtonSizeX = 0.05
Settings.ShowButtonSizeY = 0.05
Settings.ShowButtonPosType = FRAMEPOINT_BOTTOMLEFT
Settings.ShowButtonIcon = "" -- when ShowButtonIcon is not "" or not nil then an IconButton is created.
-- Display a Sprite on the Show Button when the current Unit can do a choice
Settings.ShowButtonSprite = true
-- Settings.ShowButtonSpritePath & Settings.ShowButtonSpriteSize have no runtime change support
Settings.ShowButtonSpritePath = "ui/feedback/autocast/ui-modalbuttonon.mdx"
Settings.ShowButtonSpriteSize = 0.039
function TalentGridShowEmpty(player)
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentGrid.Frame.ItemParent, false)
BlzFrameSetText(TalentGrid.Frame.Title, GetLocalizedString(Settings.StringNoTalentUser))
end
end
function TalentGridHasControl(player, unit)
return IsUnitOwnedByPlayer(unit, player) or (not Settings.OnlyOwnUnit and GetPlayerAlliance(GetOwningPlayer(unit), player, ALLIANCE_SHARED_CONTROL))
end
function TalentGridShow(target, activePlayer)
if not Settings.FixedTarget then
TalentBox.Control[activePlayer].Target = target
else
-- in case of FixedTarget take the one in the array
target = TalentBox.Control[activePlayer].Target
end
if Talent[target] then
TalentGrid.Offset[activePlayer] = 0
local unitCode = TalentGetUnitCode(target)
local count = 0
for _ in pairs(Talent[unitCode]["Tier"]) do
count = count + 1
end
if GetLocalPlayer() == activePlayer then
BlzFrameSetVisible(TalentGrid.Frame.Slider, count > Settings.RowsAmount)
BlzFrameSetText(TalentGrid.Frame.Title, GetLocalizedString(Settings.StringTitlePrefix) .. GetObjectName(unitCode))
if IsUnitType(target, UNIT_TYPE_HERO) then
BlzFrameSetText(TalentGrid.Frame.Title, BlzFrameGetText(TalentGrid.Frame.Title) .. " ("..GetHeroProperName(target)..")" )
end
end
BlzFrameSetMinMaxValue(TalentGrid.Frame.Slider, 0, math.max(0, count - Settings.RowsAmount))
BlzFrameSetVisible(TalentGrid.Frame.ItemParent, true)
TalentGridUpdate(activePlayer)
BlzFrameSetVisible(TalentGrid.Frame.Reset, Settings.HaveResetButton and TalentGridHasControl(activePlayer, target))
else
TalentGridShowEmpty(activePlayer)
BlzFrameSetVisible(TalentGrid.Frame.Reset, false)
end
end
function TalentGridUpdate(player)
if GetLocalPlayer() ~= player then return end
local rows = Settings.RowsAmount
local cols = Settings.ColsAmount
local unit = TalentBox.Control[player].Target
local unitCode = TalentGetUnitCode(unit)
if not Talent[unitCode] then return end
local offset = TalentGrid.Offset[player]
local y = 0
local tierCount = 0
local frameObject
local choice
local colsMax = 0
local rowsMax = 0
local hasControl = TalentGridHasControl(player, unit)
BlzFrameSetVisible(TalentGrid.Frame.ShowSprite, Settings.ShowButtonSprite and Talent[unit].HasChoice and hasControl)
BlzFrameSetEnable(TalentGrid.Frame.Reset, hasControl and Settings.HaveResetButton and not TalentBox.Control[player].PreventResetButton and not udg_TalentControlPreventReset[GetConvertedPlayerId(player)])
-- walk the tiers of the current unit
-- pairs sorts it bad so loop from 1 to Talent[unitCode].MaxLevel
--for level, tier in pairs(Talent[unitCode]["Tier"]) do
for level = 1, Talent[unitCode].MaxLevel do
if Talent[unitCode]["Tier"][level] then
tierCount = tierCount + 1
-- skip tiers before offset
if tierCount > offset then
y = y + 1
if y > rowsMax then rowsMax = y end
frameObject = TalentGrid.Frame[y]
if not frameObject then break end
BlzFrameSetVisible(frameObject.LevelFrame, true)
BlzFrameSetText(frameObject.LevelFrameText, level)
local buttonUsed = TalentUnitGetButtonUsed(unit, level)
if buttonUsed > 0 and not Talent[unit].SelectionsDone[tierCount].UnLearned then
BlzFrameSetVisible(frameObject.Selected,true)
else
BlzFrameSetVisible(frameObject.Selected,false)
end
-- walk the cols and update each button
for x = 1, cols do
choice = Talent[unitCode]["Tier"][level][x]
if choice then
if x > colsMax then colsMax = x end
BlzFrameSetVisible(frameObject[x].Frame, true)
BlzFrameSetEnable(frameObject[x].Frame, hasControl and Talent[unit].CurrentLevel == level and Talent[unit].HasChoice)
BlzFrameSetSize(frameObject[x].Frame, Settings.OptionSizeX, Settings.OptionSizeY)
BlzFrameSetSize(frameObject[x].Icon, Settings.OptionIconSize, Settings.OptionIconSize)
BlzFrameSetTexture(frameObject[x].Icon, GetLocalizedString(choice.Icon), 0, true)
BlzFrameSetText(frameObject[x].Text, GetLocalizedString(choice.Head))
BlzFrameSetVisible(frameObject[x].Text, Settings.OptionShowText)
BlzFrameSetVisible(frameObject[x].ToolTipFrame, Settings.OptionHaveTooltip)
if Settings.OptionHaveTooltip then
BlzFrameSetSize(frameObject[x].ToolTipFrameText, Settings.OptionTooltipSizeX, 0)
BlzFrameSetText(frameObject[x].ToolTipFrameText, GetLocalizedString(choice.Text))
BlzFrameSetTexture(frameObject[x].ToolTipFrameIcon, GetLocalizedString(choice.Icon), 0, true)
BlzFrameSetText(frameObject[x].ToolTipFrameName, TalentBox.OptionTitlePrefix[x] .. GetLocalizedString(choice.Head) .. TalentBox.OptionTitleSufix[x] )
end
if x == buttonUsed then
BlzFrameClearAllPoints(frameObject.Selected)
BlzFrameSetAllPoints(frameObject.Selected, frameObject[x].Frame)
end
else
BlzFrameSetVisible(frameObject[x].Frame, false)
end
end
end
end
end
-- hide the rows not used
y = y + 1
while y <= Settings.RowsAmount do
BlzFrameSetVisible(TalentGrid.Frame[y].LevelFrame, false)
BlzFrameSetVisible(TalentGrid.Frame[y].Selected,false)
for x = 1, cols do
BlzFrameSetVisible(TalentGrid.Frame[y][x].Frame, false)
end
y = y + 1
end
if Settings.Pack then
BlzFrameSetSize(TalentGrid.Frame.Box, 0.033 + Settings.OptionLevelSizeX + colsMax*Settings.OptionSizeX, 0.09 + Settings.OptionSizeY*rowsMax)
else
BlzFrameSetSize(TalentGrid.Frame.Box, 0.033 + Settings.OptionLevelSizeX + cols*Settings.OptionSizeX, 0.09 + Settings.OptionSizeY*rows)
end
BlzFrameSetScale(TalentGrid.Frame.Box, Settings.Scale)
BlzFrameSetScale(TalentGrid.Frame.ToolTipParent, Settings.ToolTipScale)
end
local function CreateTooltip(frame, icon, head, text)
-- create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
local toolTipFrameFrame = BlzCreateFrame("TasButtonListTooltipBoxFrame", TalentGrid.Frame.ToolTipParent, 0, 0)
local toolTipFrame = BlzGetFrameByName("TasButtonListTooltipBox", 0)
local toolTipFrameIcon = BlzGetFrameByName("TasButtonListTooltipIcon", 0)
local toolTipFrameName = BlzGetFrameByName("TasButtonListTooltipName", 0)
local toolTipFrameSeperator = BlzGetFrameByName("TasButtonListTooltipSeperator", 0)
local toolTipFrameText = BlzGetFrameByName("TasButtonListTooltipText", 0)
BlzFrameSetSize(toolTipFrameText, Settings.OptionTooltipSizeX, 0)
BlzFrameSetText(toolTipFrameText, GetLocalizedString(text))
BlzFrameSetText(toolTipFrameName, GetLocalizedString(head))
BlzFrameSetTexture(toolTipFrameIcon, GetLocalizedString(icon), 0, true)
if Settings.OptionTooltipFixedPos then
BlzFrameSetAbsPoint(toolTipFrameText, Settings.OptionTooltipPos, Settings.OptionTooltipPosX, Settings.OptionTooltipPosY)
else
BlzFrameSetPoint(toolTipFrameText, Settings.OptionTooltipRelaPosA, TalentGrid.Frame.Box, Settings.OptionTooltipRelaPosB, Settings.OptionTooltipRelaPosX, Settings.OptionTooltipRelaPosY)
end
BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_TOPLEFT, toolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_BOTTOMRIGHT, toolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
BlzFrameSetTooltip(frame, toolTipFrameFrame)
end
-- this functions runs when not the slider is mouse wheel rolled
function TalentGridWheel(frame, player, value, text)
if GetLocalPlayer() == player then
if value > 0 then
BlzFrameSetValue(TalentGrid.Frame.Slider, BlzFrameGetValue(TalentGrid.Frame.Slider) + 1)
else
BlzFrameSetValue(TalentGrid.Frame.Slider, BlzFrameGetValue(TalentGrid.Frame.Slider) - 1)
end
end
end
function TalentGridCreate()
local rows = Settings.RowsAmount
local cols = Settings.ColsAmount
BlzLoadTOCFile("war3mapImported/Talentbox.toc")
local parent = BlzCreateFrameByType("BUTTON", "TalentGridParent", Settings.Parent(), "", 0)
BlzFrameSetAllPoints(BlzCreateFrameByType("BACKDROP", "TalentGridBackground", parent, "TalentBoxBackground", 0), parent)
BlzFrameSetSize(parent, 0.1, 0.1)
BlzFrameSetAbsPoint(parent, Settings.PosType, Settings.PosX, Settings.PosY)
TalentGrid.Frame.Box = parent
TasFrameAction(parent, TalentGridWheel, FRAMEEVENT_MOUSE_WHEEL)
TalentGrid.Frame.Title = BlzCreateFrameByType("TEXT", "TalentGridTitle", parent, "TalentBoxTitle", 0)
BlzFrameSetPoint(TalentGrid.Frame.Title, FRAMEPOINT_TOP, parent, FRAMEPOINT_TOP, 0.0, -0.024)
BlzFrameSetText(TalentGrid.Frame.Title, GetLocalizedString(Settings.StringTitlePrefix))
TalentGrid.Frame.ItemParent = BlzCreateFrameByType("FRAME", "TalentGridOptionParent", parent, "", 0)
-- ToolTipParent is a BUTTON to allow BlzFrameSetLevel
TalentGrid.Frame.ToolTipParent = BlzCreateFrameByType("BUTTON", "TalentGridOptionParent", parent, "", 0)
TalentGrid.Frame.Close = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentCloseButton", parent, "ScriptDialogButton", 0)
BlzFrameSetText(TalentGrid.Frame.Close, "X")
BlzFrameSetSize(TalentGrid.Frame.Close, 0.035, 0.035)
BlzFrameSetPoint(TalentGrid.Frame.Close, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPRIGHT, 0.0, 0)
if Settings.ShowButtonIcon and Settings.ShowButtonIcon ~= "" then
TalentGrid.Frame.Show = BlzCreateFrameByType("GLUEBUTTON", "TalentGridShowButton", Settings.Parent(), "IconButtonTemplate", 0)
TalentGrid.Frame.ShowIcon = BlzCreateFrameByType("BACKDROP", "TalentGridShowButtonIcon", TalentGrid.Frame.Show, "", 0)
BlzFrameSetTexture(TalentGrid.Frame.ShowIcon, Settings.ShowButtonIcon, 0, true)
BlzFrameSetAllPoints(TalentGrid.Frame.ShowIcon, TalentGrid.Frame.Show)
else
TalentGrid.Frame.Show = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentGridShowButton", Settings.Parent(), "ScriptDialogButton", 0)
end
BlzFrameSetSize(TalentGrid.Frame.Show, Settings.ShowButtonSizeX, Settings.ShowButtonSizeY)
BlzFrameSetText(TalentGrid.Frame.Show, GetLocalizedString(Settings.StringButtonShowText))
BlzFrameSetAbsPoint(TalentGrid.Frame.Show, Settings.ShowButtonPosType, Settings.ShowButtonPosX, Settings.ShowButtonPosY)
TalentGrid.Frame.ShowSprite = BlzCreateFrameByType("SPRITE", "TalentGridShowButtonSprite", TalentGrid.Frame.Show, "", 0)
BlzFrameSetModel(TalentGrid.Frame.ShowSprite, Settings.ShowButtonSpritePath, 0)
BlzFrameSetAllPoints(TalentGrid.Frame.ShowSprite, TalentGrid.Frame.Show)
BlzFrameSetScale(TalentGrid.Frame.ShowSprite, BlzFrameGetWidth(TalentGrid.Frame.Show)/Settings.ShowButtonSpriteSize)
BlzFrameSetVisible(TalentGrid.Frame.ShowSprite, false)
TasButtonAction.Set(TalentGrid.Frame.Show, function(frame, player)
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentGrid.Frame.Box, true)
BlzFrameSetVisible(TalentGrid.Frame.Show, false)
TalentGridUpdate(player)
end
end)
TasButtonAction.Set(TalentGrid.Frame.Close, function(frame, player)
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentGrid.Frame.Box, false)
BlzFrameSetVisible(TalentGrid.Frame.Show, true)
end
end)
local data
for y = 1, rows do
data = {}
TalentGrid.Frame[y] = data
data.LevelFrame = BlzCreateFrame("TalentBoxGridText", TalentGrid.Frame.ItemParent, 0, 0)
data.LevelFrameText = BlzGetFrameByName("TalentBoxGridTextValue", 0)
BlzFrameSetSize(data.LevelFrame, Settings.OptionLevelSizeX, Settings.OptionLevelSizeY)
TasFrameAction(data.LevelFrame, TalentGridWheel, FRAMEEVENT_MOUSE_WHEEL)
if y == 1 then
BlzFrameSetPoint(data.LevelFrame, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, 0.015, -0.045)
else
BlzFrameSetPoint(data.LevelFrame, FRAMEPOINT_TOPLEFT, TalentGrid.Frame[y - 1].LevelFrame, FRAMEPOINT_BOTTOMLEFT, 0, 0)
end
for x = 1, cols do
data[x] = {}
data[x].Frame = BlzCreateFrame("TalentBoxGridItem", TalentGrid.Frame.ItemParent, 0, 0)
data[x].Icon = BlzGetFrameByName("TalentBoxGridItemIcon", 0)
data[x].Text = BlzGetFrameByName("TalentBoxGridItemTitle", 0)
BlzFrameSetSize(data[x].Frame, Settings.OptionSizeX, Settings.OptionSizeY)
BlzFrameSetSize(data[x].Icon, Settings.OptionIconSize, Settings.OptionIconSize)
BlzFrameSetVisible(data[x].Text, Settings.OptionShowText)
TalentGrid[data[x].Frame] = x
if x == 1 then
BlzFrameSetPoint(data[x].Frame, FRAMEPOINT_BOTTOMLEFT, data.LevelFrame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
else
BlzFrameSetPoint(data[x].Frame, FRAMEPOINT_BOTTOMLEFT, data[x - 1].Frame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
end
TasButtonAction.Set(data[x].Frame, function(frame, player)
local index = TalentGrid[frame]
if not Settings.FixedTarget and not TalentBox.Control[player].SingleMode then
local unit
local unitCode =TalentGetUnitCode(TalentBox.Control[player].Target)
local selectionsDone = TalentUnitGetSelectionsDone(TalentBox.Control[player].Target)
GroupEnumUnitsSelected(TalentBox.Control.SelectionCheckGroup, player, nil)
for i = 0, BlzGroupGetSize(TalentBox.Control.SelectionCheckGroup) - 1 do
unit = BlzGroupUnitAt(TalentBox.Control.SelectionCheckGroup, i)
if TalentGetUnitCode(unit) == unitCode
and TalentUnitGetSelectionsDone(unit) == selectionsDone
then
TalentPickDo(unit, index)
end
end
unit = nil
else
TalentPickDo(TalentBox.Control[player].Target, index)
end
if Settings.AutoCloseWhenDone and not Talent[TalentBox.Control[player].Target].HasChoice then
if GetLocalPlayer() == player then
BlzFrameClick(TalentGrid.Frame.Close)
end
else
TalentGridUpdate(player)
end
end)
local frameObject = data[x]
-- create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
frameObject.ToolTipFrameFrame = BlzCreateFrame("TasButtonListTooltipBoxFrame", TalentGrid.Frame.ToolTipParent, 0, 0)
frameObject.ToolTipFrame = BlzGetFrameByName("TasButtonListTooltipBox", 0)
frameObject.ToolTipFrameIcon = BlzGetFrameByName("TasButtonListTooltipIcon", 0)
frameObject.ToolTipFrameName = BlzGetFrameByName("TasButtonListTooltipName", 0)
frameObject.ToolTipFrameSeperator = BlzGetFrameByName("TasButtonListTooltipSeperator", 0)
frameObject.ToolTipFrameText = BlzGetFrameByName("TasButtonListTooltipText", 0)
BlzFrameSetSize(frameObject.ToolTipFrameText, Settings.OptionTooltipSizeX, 0)
if Settings.OptionTooltipFixedPos then
BlzFrameSetAbsPoint(frameObject.ToolTipFrameText, Settings.OptionTooltipPos, Settings.OptionTooltipPosX, Settings.OptionTooltipPosY)
else
BlzFrameSetPoint(frameObject.ToolTipFrameText, Settings.OptionTooltipRelaPosA, TalentGrid.Frame.Box, Settings.OptionTooltipRelaPosB, Settings.OptionTooltipRelaPosX, Settings.OptionTooltipRelaPosY)
end
BlzFrameSetPoint(frameObject.ToolTipFrame, FRAMEPOINT_TOPLEFT, frameObject.ToolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
BlzFrameSetPoint(frameObject.ToolTipFrame, FRAMEPOINT_BOTTOMRIGHT, frameObject.ToolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
BlzFrameSetTooltip(frameObject.Frame, frameObject.ToolTipFrameFrame)
BlzFrameSetVisible(frameObject.ToolTipFrame, Settings.OptionHaveTooltip)
end
data.Selected = BlzCreateFrame("TalentHighlight", TalentGrid.Frame.ItemParent, 0, 0)
BlzFrameSetVisible(data.Selected, false)
end
BlzFrameSetSize(parent, 0.033 + Settings.OptionLevelSizeX + cols*Settings.OptionSizeX, 0.09 + Settings.OptionSizeY*rows)
local slider = BlzCreateFrameByType("SLIDER", "FrameFlowSlider", TalentGrid.Frame.ItemParent, "QuestMainListScrollBar", 0)
BlzFrameClearAllPoints(slider)
BlzFrameSetStepSize(slider, 1)
BlzFrameSetSize(slider, 0.012, BlzFrameGetHeight(TalentGrid.Frame[1].LevelFrame) * rows)
BlzFrameSetPoint(slider, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPRIGHT, -0.0075, -0.045)
BlzFrameSetVisible(slider, true)
TalentGrid.Frame.Slider = slider
TasSliderAction(slider, function(frame, player, value)
TalentGrid.Offset[player] = value
TalentGridUpdate(player)
end)
TalentGrid.Frame.Reset = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentResetButton", TalentGrid.Frame.ItemParent, "ScriptDialogButton", 0)
CreateTooltip(TalentGrid.Frame.Reset, "UI/Widgets/EscMenu/Human/blank-background", Settings.StringButtonResetText, Settings.StringButtonResetTooltip)
BlzFrameSetText(TalentGrid.Frame.Reset, GetLocalizedString(Settings.StringButtonResetText))
BlzFrameSetSize(TalentGrid.Frame.Reset, Settings.ResetSizeX, Settings.ResetSizeY)
BlzFrameSetPoint(TalentGrid.Frame.Reset, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_BOTTOMRIGHT, -0.027, 0.02)
TasButtonAction.Set(TalentGrid.Frame.Reset, function(frame, player)
local function Reset(unit)
if not Talent.Settings.UseCondition(unit) then return false end
while(TalentUnitGetSelectionsDone(unit) > 0)
do
TalentResetDo(unit)
end
end
if not Settings.FixedTarget and not TalentBox.Control[player].SingleMode then
local unit
local unitCode = TalentGetUnitCode(TalentBox.Control[player].Target)
local selectionsDone = TalentUnitGetSelectionsDone(TalentBox.Control[player].Target)
GroupEnumUnitsSelected(TalentBox.Control.SelectionCheckGroup, player, nil)
for i = 0, BlzGroupGetSize(TalentBox.Control.SelectionCheckGroup) - 1 do
unit = BlzGroupUnitAt(TalentBox.Control.SelectionCheckGroup, i)
if TalentGetUnitCode(unit) == unitCode
--and TalentUnitGetSelectionsDone(unit) == selectionsDone
then
Reset(unit)
end
unit = nil
end
else
Reset(TalentBox.Control[player].Target)
end
TalentGridUpdate(player)
end)
BlzFrameSetVisible(TalentGrid.Frame.Reset, Settings.HaveResetButton)
TalentGrid.Frame.GroupMode = BlzCreateFrame("TalentButtonGroupMode", TalentGrid.Frame.ItemParent, 0, 0)
TalentGrid.Frame.SingleMode = BlzCreateFrame("TalentButtonSingleMode", TalentGrid.Frame.ItemParent, 0, 0)
BlzFrameSetPoint(TalentGrid.Frame.GroupMode, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_BOTTOMRIGHT, -0.027 - Settings.ResetSizeX , 0.02)
BlzFrameSetPoint(TalentGrid.Frame.SingleMode, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_BOTTOMRIGHT, -0.027 - Settings.ResetSizeX, 0.02)
BlzFrameSetVisible(TalentGrid.Frame.GroupMode, false)
--BlzFrameSetVisible(TalentGrid.Frame.SingleMode, false)
TasButtonAction.Set(TalentGrid.Frame.SingleMode, function(frame, player)
-- I mixed up the images so the mode is reversed
TalentBox.Control[player].SingleMode = false
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentGrid.Frame.SingleMode, false)
BlzFrameSetVisible(TalentGrid.Frame.GroupMode, true)
end
--print(TalentBox.Control[player].SingleMode)
end)
TasButtonAction.Set(TalentGrid.Frame.GroupMode, function(frame, player)
-- I mixed up the images so the mode is reversed
TalentBox.Control[player].SingleMode = true
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentGrid.Frame.SingleMode, true)
BlzFrameSetVisible(TalentGrid.Frame.GroupMode, false)
end
--print(TalentBox.Control[player].SingleMode)
end)
CreateTooltip(TalentGrid.Frame.GroupMode, Settings.StringTooltipGroupModeIcon, Settings.StringTooltipGroupModeHead, Settings.StringTooltipGroupModeText)
CreateTooltip(TalentGrid.Frame.SingleMode, Settings.StringTooltipSingleModeIcon, Settings.StringTooltipSingleModeHead, Settings.StringTooltipSingleModeText)
-- make the ToolTipParent take the highest slot
BlzFrameSetLevel(TalentGrid.Frame.ToolTipParent, 99)
BlzFrameSetScale(parent, Settings.Scale)
BlzFrameSetScale(TalentGrid.Frame.ToolTipParent, Settings.ToolTipScale)
BlzFrameSetVisible(parent, false)
end
function TalentGridInit()
TalentGrid.Trigger.Select = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(TalentGrid.Trigger.Select, EVENT_PLAYER_UNIT_SELECTED)
TriggerAddAction(TalentGrid.Trigger.Select, function()
TalentGridShow(GetTriggerUnit(), GetTriggerPlayer())
end)
TalentGrid.Trigger.ESC = CreateTrigger()
for i = 0, bj_MAX_PLAYER_SLOTS-1 do TriggerRegisterPlayerEvent(TalentGrid.Trigger.ESC, Player(i), EVENT_PLAYER_END_CINEMATIC) end
TriggerAddAction(TalentGrid.Trigger.ESC, function()
if Settings.ESCClose and GetLocalPlayer() == GetTriggerPlayer() then
BlzFrameSetVisible(TalentGrid.Frame.Box, false)
BlzFrameSetVisible(TalentGrid.Frame.Show, true)
end
end)
TalentGridCreate()
if FrameLoaderAdd then FrameLoaderAdd(TalentGridCreate) end
TalentGrid.SelectionCheckTimer = CreateTimer()
TimerStart(TalentGrid.SelectionCheckTimer, 0.25, true, function()
GroupEnumUnitsSelected(TalentBox.Control.SelectionCheckGroup, GetLocalPlayer(), nil)
if Settings.AutoCloseWithoutSelection and GetHandleId(FirstOfGroup(TalentBox.Control.SelectionCheckGroup)) == 0 then
BlzFrameSetVisible(TalentGrid.Frame.Box, false)
BlzFrameSetVisible(TalentGrid.Frame.Show, true)
else
TalentGridUpdate(GetLocalPlayer())
end
GroupClear(TalentBox.Control.SelectionCheckGroup)
end)
end
end
--[[
TalentBox for Talent Lui 1.39
By Tasyen
===========================================================================
Displays one Tier at a time and has Buttons to swap the current shown Tier.
===========================================================================
--]]
do
local Settings = TalentBox.Settings
do
Settings.StringButtonResetTooltip = "Unlearn choosen Talents from this Level and higher Levels.|nCan also be used to relearn Talents from this level upwards."
Settings.StringButtonResetText = "(Un)Learn"
Settings.StringTitleLevel = "Talent Level: "
Settings.StringButtonShowText = "Show Talent"
Settings.StringNoTalentUser = "No Talent User"
Settings.StringTooltipGroupModeHead = "Group Mode"
Settings.StringTooltipGroupModeText = "During GroupMode all selected Units using the same Talent and with the same amount of selections done, will do picks/Unlearn/Relearn together.|n|nClick to disable Group Mode."
Settings.StringTooltipGroupModeIcon = "ui/widgets/battlenet/bnet-mainmenu-customteam-up"
Settings.StringTooltipSingleModeHead = "Single Mode"
Settings.StringTooltipSingleModeText = "Only the selected Unit will do picks, unlearns|n|nClick to enable Group Mode."
Settings.StringTooltipSingleModeIcon = "ui/widgets/battlenet/bnet-mainmenu-customteam-disabled"
TalentBox.OptionTitlePrefix[1] = "|cffffcc00" --Prefix for first option Title
TalentBox.OptionTitleSufix[1] = "" --Prefix for first option
TalentBox.OptionTitlePrefix[2] = "|cffff00cc"
TalentBox.OptionTitlePrefix[3] = "|cffcccccc"
end
do
-- under which parent TalentBox & TalentBoxShow are created?
Settings.Parent = function()
return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
end
Settings.CloseWhenNoChoice = true
Settings.AutoCloseWithoutSelection = true
--With false the unlearn Button won't exist
--TalentBox.Control[GetConvertedPlayerId(player)].PreventResetButton = true will prevent player to use reset/Relearn button.
Settings.BoxHaveResetButton = true
-- FixedTarget (true) Talent will not change TalentBox.Control[player].Target
Settings.FixedTarget = false
-- OnlyOwnUnit (true) can not pick Talents for Shared Control of other player's Units.
Settings.OnlyOwnUnit = false
--Settings.ESCClose = true, Pressing ESC will close the UI
Settings.ESCClose = true
--MaxAmount of Options shown in the UI of one tier.
--The Buttons start with 1 and include Settings.BoxOptionMaxCount
--One could still learn the Choice when a chat command would be provided.
Settings.BoxOptionMaxCount = 6
--Amount of LevelBoxes, if an got more tiers there will be a page control.
--if you want lest more boxes you might change TalentBoxLevelSizeX & TalentBoxLevelSizeY
Settings.BoxLevelAmount = 5
Settings.BoxLevelSizeX = 0.02 --sane values are below 0.05
Settings.BoxLevelSizeY = 0.02 --sane values are below 0.05<
--Bigger Options allow bigger texts, but also take more space of the screen, which reduces the possible amount of showing options in one tier.
--XSize of an option in the TalentBox
Settings.BoxOptionSizeX = 0.25
--YSize of an option in the TalentBox, shouldn't be smaller than 0.04, when using Font 0.0085
Settings.BoxOptionSizeY = 0.045
Settings.BoxResetSizeX = 0.07
Settings.BoxResetSizeY = 0.025
--IconSize, should be smaller than TalentBoxOptionSizeY
Settings.BoxOptionIconSize = 0.028
--Show the Text inside the option, excludes the Head.
-- (false) allows quite small Options.
Settings.BoxOptionShowText = true
Settings.BoxOptionHaveTooltip = true
-- Tooltip Pos
Settings.BoxOptionTooltipFixedPos = false
-- Fixed
Settings.BoxOptionTooltipPosX = 0.79
Settings.BoxOptionTooltipPosY = 0.165
Settings.BoxOptionTooltipPos = FRAMEPOINT_BOTTOMRIGHT
-- Relative to TalentBox
Settings.BoxOptionTooltipRelaPosX = 0.001
Settings.BoxOptionTooltipRelaPosY = -0.052
Settings.BoxOptionTooltipRelaPosA = FRAMEPOINT_TOPLEFT
Settings.BoxOptionTooltipRelaPosB = FRAMEPOINT_TOPRIGHT
-- XSize of the Tooltip
Settings.BoxOptionTooltipSizeX = 0.2
--YSpace between 2 options, + values increases the space between, - values reduces they can also overlap.
Settings.BoxOption2OptionGap = -0.005
--YSpace between Title and option at the top.
Settings.BoxOption2TitleGap = 0.05
--YSpace between LevelBoxes and option at the bottom
Settings.BoxOption2BottomGap = 0.0
--The total y size varies with amount of shown options.
Settings.BoxBaseSizeY = 0.02
--Default Position of the TalentBox
Settings.BoxPosX = 0.005
Settings.BoxPosY = 0.2
Settings.BoxPosType = FRAMEPOINT_BOTTOMLEFT
--Default Position for the ShowTalentBoxButton
Settings.BoxShowButtonPosX = 0.00
Settings.BoxShowButtonPosY = 0.18
Settings.BoxShowButtonSizeX = 0.05
Settings.BoxShowButtonSizeY = 0.05
Settings.BoxShowButtonPosType = FRAMEPOINT_BOTTOMLEFT
Settings.BoxShowButtonIcon = "ReplaceableTextures/PassiveButtons/PASBTNStatUp.tga" -- when BoxShowButtonIcon is not "" or not nil then an IconButton is created.
-- Display a Sprite on the Show Button when the current Unit can do a choice
Settings.ShowButtonSprite = true
Settings.ShowButtonSpritePath = "ui/feedback/autocast/ui-modalbuttonon.mdx"
Settings.ShowButtonSpriteSize = 0.039
end
function TalentBoxShowEmpty(player)
local frameSizeY = 0.08
local frameSizeX = Settings.BoxOptionSizeX + 0.05
local optionSizeY = Settings.BoxOptionSizeY
TalentBox.Control[player].LevelsCurrent = 0
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.Option.Parent, false)
BlzFrameSetVisible(TalentBox.Frame.Level.Parent, false)
BlzFrameSetSize(TalentBox.Frame.Box, frameSizeX, frameSizeY)
BlzFrameSetText(TalentBox.Frame.BoxTitle, GetLocalizedString(Settings.StringNoTalentUser))
end
end
function TalentBoxHasControl(player, unit)
return IsUnitOwnedByPlayer(unit, player) or (not Settings.OnlyOwnUnit and GetPlayerAlliance(GetOwningPlayer(unit), player, ALLIANCE_SHARED_CONTROL))
end
function TalentBoxSetTier(level, player)
local unit = TalentBox.Control[player].Target
if unit == nil then return end
if not Talent[unit] then return end
local unitCode = TalentGetUnitCode(unit)
local buttonused = TalentUnitGetButtonUsed(unit, level)
local enable = TalentBoxHasControl(player, unit) and Talent[unit].CurrentLevel == level and Talent[unit].HasChoice
local frameSizeY = Settings.BoxBaseSizeY + Settings.BoxOption2TitleGap + Settings.BoxOption2BottomGap + RMaxBJ(Settings.BoxResetSizeY, Settings.BoxLevelSizeY)
local frameSizeX = Settings.BoxOptionSizeX + 0.05
local optionSizeY = Settings.BoxOptionSizeY
TalentBox.Control[player].LevelsCurrent = level
--print("TalentBoxSetTier", player, level)
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.Option.Parent, true)
--BlzFrameSetVisible(TalentBox.Frame.Level.Parent, true)
for i = Settings.BoxOptionMaxCount, 1, -1
do
local choice = Talent[unitCode]["Tier"][level][i]
--print(i, choice)
if choice then
--print(choice.Text, choice.Icon, choice.Head)
BlzFrameSetVisible(TalentBox.Frame.Option[i].Frame, true)
BlzFrameSetText(TalentBox.Frame.Option[i].TextText, GetLocalizedString(choice.Text))
BlzFrameSetTexture( TalentBox.Frame.Option[i].Icon, GetLocalizedString(choice.Icon), 0, true)
BlzFrameSetText(TalentBox.Frame.Option[i].Title, TalentBox.OptionTitlePrefix[i] .. GetLocalizedString(choice.Head) .. TalentBox.OptionTitleSufix[i] )
BlzFrameSetVisible(TalentBox.Frame.Option[i].TextBox, Settings.BoxOptionShowText)
if Settings.BoxOptionHaveTooltip then
BlzFrameSetText(TalentBox.Frame.Option[i].ToolTipFrameText, GetLocalizedString(choice.Text))
BlzFrameSetTexture( TalentBox.Frame.Option[i].ToolTipFrameIcon, GetLocalizedString(choice.Icon), 0, true)
BlzFrameSetText(TalentBox.Frame.Option[i].ToolTipFrameName, TalentBox.OptionTitlePrefix[i] .. GetLocalizedString(choice.Head) .. TalentBox.OptionTitleSufix[i] )
end
if i < Settings.BoxOptionMaxCount and i > 1 then
frameSizeY = frameSizeY + optionSizeY + Settings.BoxOption2OptionGap
else
frameSizeY = frameSizeY + optionSizeY
end
else
BlzFrameSetVisible(TalentBox.Frame.Option[i].Frame, false)
end
BlzFrameSetEnable(TalentBox.Frame.Option[i].Frame, enable)
end
--has something selected for this tier this unit has earlier selected something and that earlier selected one is not Unlearned
--TalentHeroLevel2SelectionIndex(unitCode, level) > 0 has to be done to avoid nil pointers.
if buttonused > 0 and TalentHeroLevel2SelectionIndex(unit, level) > 0 and not Talent[unit].SelectionsDone[TalentHeroLevel2SelectionIndex(unit, level)].UnLearned then
BlzFrameSetVisible(TalentBox.Frame.Selected,true)
BlzFrameClearAllPoints(TalentBox.Frame.Selected)
--BlzFrameSetParent(TalentBox.Frame.Selected, TalentBox.Frame.Option[buttonused].Frame)
BlzFrameSetAllPoints(TalentBox.Frame.Selected, TalentBox.Frame.Option[buttonused].Frame)
else
BlzFrameSetVisible(TalentBox.Frame.Selected,false)
end
BlzFrameSetSize(TalentBox.Frame.Box, frameSizeX, frameSizeY)
BlzFrameSetText(TalentBox.Frame.BoxTitle, GetLocalizedString(Settings.StringTitleLevel) .. level)
if Settings.BoxHaveResetButton then BlzFrameSetEnable(TalentBox.Frame.Reset, TalentUnitGetCurrentLevel(unit) >= level and not TalentBox.Control[player].PreventResetButton and not udg_TalentControlPreventReset[GetConvertedPlayerId(player)]) end
end
end
function TalentBoxUpdate(player)
local unit = TalentBox.Control[player].Target
--print(TalentUnitGetCurrentLevel(unit))
TalentBoxSetTier(TalentBox.Control[player].LevelsCurrent, player)
if GetLocalPlayer() == player then
if Talent[unit] then
BlzFrameSetVisible(TalentBox.Frame.ShowSprite, Settings.ShowButtonSprite and Talent[unit].HasChoice and TalentBoxHasControl(player, unit))
else
BlzFrameSetVisible(TalentBox.Frame.ShowSprite, false)
end
end
end
local function TalentBoxUpdateLevelBoxes(player, levelStart)
local unitCode = TalentGetUnitCode(TalentBox.Control[player].Target)
local count = 0
if Talent[unitCode] then
local level = levelStart
local finalLevel = Talent[unitCode].MaxLevel
if level > finalLevel then level = 1 end
if level < 1 then level = 1 end
while (level <= finalLevel) do
if Talent[unitCode]["Tier"][level] then --Have tier on that Level?
count = count + 1
TalentBox.Control[player].Levels[count] = level
TalentBox.Control[player].MaxLevel = level
if GetLocalPlayer() == player then
BlzFrameSetText(TalentBox.Frame.Level[count], I2S(level))
BlzFrameSetVisible(TalentBox.Frame.Level[count], true)
end
if count >= Settings.BoxLevelAmount then break end
end
level = level + 1
end
BlzFrameSetVisible(TalentBox.Frame.Level.Parent, count > 1) --when there is only one level to choose from hide the levels
if GetLocalPlayer() == player and levelStart <= 1 then -- only Local Player and update only at first page
BlzFrameSetVisible(TalentBox.Frame.PageDown, TalentBox.Control[player].MaxLevel < finalLevel)
BlzFrameSetVisible(TalentBox.Frame.PageUp, TalentBox.Control[player].MaxLevel < finalLevel)
end
TalentBoxSetTier(TalentBox.Control[player].Levels[1], player)
else
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.PageDown, false)
BlzFrameSetVisible(TalentBox.Frame.PageUp, false)
end
end
for i = count + 1, Settings.BoxLevelAmount, 1 do
--print("hide", i)
BlzFrameSetVisible(TalentBox.Frame.Level[i], false)
end
end
local function TalentBoxUpdateLevelBoxesDown(player, levelStart)
local count = Settings.BoxLevelAmount + 1
local level = levelStart
local unitCode = TalentGetUnitCode(TalentBox.Control[player].Target)
local finalLevel = Talent[unitCode].MaxLevel
local first = true
if level < 1 then level = finalLevel end
if TalentHeroLevel2SelectionIndex(TalentBox.Control[player].Target, level) < Settings.BoxLevelAmount then count = TalentHeroLevel2SelectionIndex(TalentBox.Control[player].Target, level) + 1 end
while (level > 0 and count > 1) do
if Talent[unitCode]["Tier"][level] then --Have tier on that Level?
count = count - 1
TalentBox.Control[player].Levels[count] = level
if first then
TalentBox.Control[player].MaxLevel = TalentBox.Control[player].Levels[count]
first = false
end
if GetLocalPlayer() == player then
BlzFrameSetText(TalentBox.Frame.Level[count], level)
BlzFrameSetVisible(TalentBox.Frame.Level[count], true)
end
end
level = level - 1
end
TalentBoxSetTier(TalentBox.Control[player].MaxLevel, player)
end
--Shows the TalentBox and sets the target for activePlayer.
function TalentBoxShow(target, activePlayer)
--print("Select", GetUnitName(target))
if not Settings.FixedTarget then
TalentBox.Control[activePlayer].Target = target
else
-- in case of FixedTarget take the one in the array
target = TalentBox.Control[activePlayer].Target
end
if Talent[target] then
TalentBoxUpdateLevelBoxes(activePlayer, 0)
TalentBoxSetTier(TalentUnitGetCurrentLevel(target), activePlayer)
BlzFrameSetVisible(TalentBox.Frame.Reset, Settings.BoxHaveResetButton and TalentBoxHasControl(activePlayer, target))
else
TalentBoxShowEmpty(activePlayer)
if Settings.BoxHaveResetButton then
BlzFrameSetVisible(TalentBox.Frame.Reset, false)
end
end
end
local function FrameLoseFocus()
if GetLocalPlayer() == GetTriggerPlayer() then
BlzFrameSetEnable(BlzGetTriggerFrame(), false)
BlzFrameSetEnable(BlzGetTriggerFrame(), true)
end
end
local function CreateTooltip(frame, icon, head, text)
-- create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
local toolTipFrameFrame = BlzCreateFrame("TasButtonListTooltipBoxFrame", frame, 0, 0)
local toolTipFrame = BlzGetFrameByName("TasButtonListTooltipBox", 0)
local toolTipFrameIcon = BlzGetFrameByName("TasButtonListTooltipIcon", 0)
local toolTipFrameName = BlzGetFrameByName("TasButtonListTooltipName", 0)
local toolTipFrameSeperator = BlzGetFrameByName("TasButtonListTooltipSeperator", 0)
local toolTipFrameText = BlzGetFrameByName("TasButtonListTooltipText", 0)
BlzFrameSetSize(toolTipFrameText, Settings.BoxOptionTooltipSizeX, 0)
BlzFrameSetText(toolTipFrameText, GetLocalizedString(text))
BlzFrameSetText(toolTipFrameName, GetLocalizedString(head))
BlzFrameSetTexture(toolTipFrameIcon, GetLocalizedString(icon), 0, true)
if Settings.BoxOptionTooltipFixedPos then
BlzFrameSetAbsPoint(toolTipFrameText, Settings.BoxOptionTooltipPos, Settings.BoxOptionTooltipPosX, Settings.BoxOptionTooltipPosY)
else
BlzFrameSetPoint(toolTipFrameText, Settings.BoxOptionTooltipRelaPosA, TalentBox.Frame.Box, Settings.BoxOptionTooltipRelaPosB, Settings.BoxOptionTooltipRelaPosX, Settings.BoxOptionTooltipRelaPosY)
end
BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_TOPLEFT, toolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_BOTTOMRIGHT, toolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
BlzFrameSetTooltip(frame, toolTipFrameFrame)
end
function TalentBoxCreate()
BlzLoadTOCFile("war3mapimported\\talentbox.toc")
TalentBox.Frame = {}
TalentBox.Frame.Box = BlzCreateFrameByType("BACKDROP", "TalentBox", Settings.Parent(), "TalentBoxBackground", 0)
TalentBox.Frame.BoxTitle = BlzCreateFrame("TalentBoxTitle", TalentBox.Frame.Box, 0, 0)
TalentBox.Frame.Option = {}
TalentBox.Frame.Option.Parent = BlzCreateFrameByType("FRAME", "TalentBoxOptionParent", TalentBox.Frame.Box, "", 0)
TalentBox.Frame.Level = {}
TalentBox.Frame.Level.Parent = BlzCreateFrameByType("FRAME", "TalentBoxLevelParent", TalentBox.Frame.Box, "", 0)
TalentBox.Frame.PageUp = BlzCreateFrame("TalentButtonUp", TalentBox.Frame.Level.Parent, 0, 0)
TalentBox.Frame.PageDown = BlzCreateFrame("TalentButtonDown", TalentBox.Frame.Level.Parent, 0, 0)
TalentBox.Frame.Close = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentCloseButton",TalentBox.Frame.Box, "ScriptDialogButton", 0)
if Settings.BoxShowButtonIcon and Settings.BoxShowButtonIcon ~= "" then
TalentBox.Frame.Show = BlzCreateFrameByType("GLUEBUTTON", "TalentShowButton", Settings.Parent(), "IconButtonTemplate", 0)
TalentBox.Frame.ShowIcon = BlzCreateFrameByType("BACKDROP", "TalentShowButtonIcon", TalentBox.Frame.Show, "", 0)
BlzFrameSetTexture(TalentBox.Frame.ShowIcon, Settings.BoxShowButtonIcon, 0, true)
BlzFrameSetAllPoints(TalentBox.Frame.ShowIcon, TalentBox.Frame.Show)
else
TalentBox.Frame.Show = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentShowButton", Settings.Parent(), "ScriptDialogButton", 0)
end
TalentBox.Frame.GroupMode = BlzCreateFrame("TalentButtonGroupMode", TalentBox.Frame.Option.Parent, 0, 0)
TalentBox.Frame.SingleMode = BlzCreateFrame("TalentButtonSingleMode", TalentBox.Frame.Option.Parent, 0, 0)
BlzFrameSetPoint(TalentBox.Frame.GroupMode, FRAMEPOINT_BOTTOMRIGHT, TalentBox.Frame.Box, FRAMEPOINT_BOTTOMRIGHT, -0.027 - Settings.BoxResetSizeX , 0.02)
BlzFrameSetPoint(TalentBox.Frame.SingleMode, FRAMEPOINT_BOTTOMRIGHT, TalentBox.Frame.Box, FRAMEPOINT_BOTTOMRIGHT, -0.027 - Settings.BoxResetSizeX, 0.02)
BlzFrameSetVisible(TalentBox.Frame.GroupMode, false)
--BlzFrameSetVisible(TalentBox.Frame.SingleMode, false)
TasButtonAction.Set(TalentBox.Frame.SingleMode, function(frame, player)
-- I mixed up the images so the mode is reversed
TalentBox.Control[player].SingleMode = false
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.SingleMode, false)
BlzFrameSetVisible(TalentBox.Frame.GroupMode, true)
end
--print(TalentBox.Control[player].SingleMode)
end)
TasButtonAction.Set(TalentBox.Frame.GroupMode, function(frame, player)
-- I mixed up the images so the mode is reversed
TalentBox.Control[player].SingleMode = true
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.SingleMode, true)
BlzFrameSetVisible(TalentBox.Frame.GroupMode, false)
end
--print(TalentBox.Control[player].SingleMode)
end)
CreateTooltip(TalentBox.Frame.GroupMode, Settings.StringTooltipGroupModeIcon, Settings.StringTooltipGroupModeHead, Settings.StringTooltipGroupModeText)
CreateTooltip(TalentBox.Frame.SingleMode, Settings.StringTooltipSingleModeIcon, Settings.StringTooltipSingleModeHead, Settings.StringTooltipSingleModeText)
--CreateTooltip(frame, icon, head, text)
BlzFrameSetSize(TalentBox.Frame.Show, Settings.BoxShowButtonSizeX, Settings.BoxShowButtonSizeY)
BlzFrameSetText(TalentBox.Frame.Show, GetLocalizedString(Settings.StringButtonShowText))
BlzFrameSetAbsPoint(TalentBox.Frame.Show, Settings.BoxShowButtonPosType, Settings.BoxShowButtonPosX, Settings.BoxShowButtonPosY)
TalentBox.Frame.ShowSprite = BlzCreateFrameByType("SPRITE", "TalentBoxShowButtonSprite", TalentBox.Frame.Show, "", 0)
BlzFrameSetModel(TalentBox.Frame.ShowSprite, Settings.ShowButtonSpritePath, 0)
BlzFrameSetAllPoints(TalentBox.Frame.ShowSprite, TalentBox.Frame.Show)
BlzFrameSetScale(TalentBox.Frame.ShowSprite, BlzFrameGetWidth(TalentBox.Frame.Show)/Settings.ShowButtonSpriteSize)
BlzFrameSetVisible(TalentBox.Frame.ShowSprite, false)
BlzFrameSetPoint(TalentBox.Frame.BoxTitle, FRAMEPOINT_TOP, TalentBox.Frame.Box, FRAMEPOINT_TOP, 0.0, -0.03)
BlzFrameSetText(TalentBox.Frame.BoxTitle, GetLocalizedString(Settings.StringTitleLevel))
BlzFrameSetText(TalentBox.Frame.Close, "X")
BlzFrameSetSize(TalentBox.Frame.Close, 0.035, 0.035)
BlzFrameSetAbsPoint(TalentBox.Frame.Box, Settings.BoxPosType, Settings.BoxPosX, Settings.BoxPosY)
TasButtonAction.Set(TalentBox.Frame.PageDown, function(frame, player)
TalentBoxUpdateLevelBoxesDown(player, TalentBox.Control[player].Levels[1]-1)
end)
TasButtonAction.Set(TalentBox.Frame.PageUp, function(frame, player)
TalentBoxUpdateLevelBoxes(player, TalentBox.Control[player].MaxLevel + 1)
end)
TasButtonAction.Set(TalentBox.Frame.Close, function(frame, player)
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.Box, false)
BlzFrameSetVisible(TalentBox.Frame.Show, true)
end
end)
TasButtonAction.Set(TalentBox.Frame.Show, function(frame, player)
if GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.Box, true)
BlzFrameSetVisible(TalentBox.Frame.Show, false)
TalentBoxUpdate(player)
end
end)
for i = 1, Settings.BoxOptionMaxCount do
local fh = BlzCreateFrame("TalentBoxItem", TalentBox.Frame.Option.Parent, 0, i)
local frameObject = {}
TalentBox.Frame.Option[i] = frameObject
frameObject.Frame = fh
frameObject.InfoText = BlzGetFrameByName("TalentBoxItemInfoText", i)
frameObject.TextBox = BlzGetFrameByName("TalentBoxItemText", i)
frameObject.TextText = BlzGetFrameByName("TalentBoxItemTextText", i)
frameObject.Title = BlzGetFrameByName("TalentBoxItemTitle", i)
frameObject.Icon = BlzGetFrameByName("TalentBoxItemIcon", i)
TalentBox.Frame[fh] = i --remember this is button i
if i > 1 then
BlzFrameSetPoint(fh, FRAMEPOINT_BOTTOM, TalentBox.Frame.Option[i - 1].Frame, FRAMEPOINT_TOP, 0, Settings.BoxOption2OptionGap)
end
BlzFrameSetVisible(frameObject.TextBox, Settings.BoxOptionShowText)
BlzFrameSetSize(fh, Settings.BoxOptionSizeX, Settings.BoxOptionSizeY)
BlzFrameSetSize(TalentBox.Frame.Option[i].Icon, Settings.BoxOptionIconSize, Settings.BoxOptionIconSize)
TasButtonAction.Set(fh, function(frame, player)
local index = TalentBox.Frame[frame]
if not Settings.FixedTarget and not TalentBox.Control[player].SingleMode then
local unit
local unitCode =TalentGetUnitCode(TalentBox.Control[player].Target)
local selectionsDone = TalentUnitGetSelectionsDone(TalentBox.Control[player].Target)
GroupEnumUnitsSelected(TalentBox.Control.SelectionCheckGroup, player, nil)
for i = 0, BlzGroupGetSize(TalentBox.Control.SelectionCheckGroup) - 1 do
unit = BlzGroupUnitAt(TalentBox.Control.SelectionCheckGroup, i)
if TalentGetUnitCode(unit) == unitCode
and TalentUnitGetSelectionsDone(unit) == selectionsDone
then
TalentPickDo(unit, index)
end
end
unit = nil
else
TalentPickDo(TalentBox.Control[player].Target, index)
end
if Settings.CloseWhenNoChoice and not Talent[TalentBox.Control[player].Target].HasChoice and GetLocalPlayer() == player then
BlzFrameSetVisible(TalentBox.Frame.Box, false)
BlzFrameSetVisible(TalentBox.Frame.Show, true)
else
TalentBoxSetTier(TalentUnitGetCurrentLevel(TalentBox.Control[player].Target), player)
end
TalentBoxUpdate(player)
end)
if Settings.BoxOptionHaveTooltip then
-- create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
frameObject.ToolTipFrameFrame = BlzCreateFrame("TasButtonListTooltipBoxFrame", frameObject.Frame, 0, 0)
frameObject.ToolTipFrame = BlzGetFrameByName("TasButtonListTooltipBox", 0)
frameObject.ToolTipFrameIcon = BlzGetFrameByName("TasButtonListTooltipIcon", 0)
frameObject.ToolTipFrameName = BlzGetFrameByName("TasButtonListTooltipName", 0)
frameObject.ToolTipFrameSeperator = BlzGetFrameByName("TasButtonListTooltipSeperator", 0)
frameObject.ToolTipFrameText = BlzGetFrameByName("TasButtonListTooltipText", 0)
BlzFrameSetSize(frameObject.ToolTipFrameText, Settings.BoxOptionTooltipSizeX, 0)
if Settings.BoxOptionTooltipFixedPos then
BlzFrameSetAbsPoint(frameObject.ToolTipFrameText, Settings.BoxOptionTooltipPos, Settings.BoxOptionTooltipPosX, Settings.BoxOptionTooltipPosY)
else
BlzFrameSetPoint(frameObject.ToolTipFrameText, Settings.BoxOptionTooltipRelaPosA, TalentBox.Frame.Box, Settings.BoxOptionTooltipRelaPosB, Settings.BoxOptionTooltipRelaPosX, Settings.BoxOptionTooltipRelaPosY)
end
BlzFrameSetPoint(frameObject.ToolTipFrame, FRAMEPOINT_TOPLEFT, frameObject.ToolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
BlzFrameSetPoint(frameObject.ToolTipFrame, FRAMEPOINT_BOTTOMRIGHT, frameObject.ToolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
BlzFrameSetTooltip(frameObject.Frame, frameObject.ToolTipFrameFrame)
end
end
BlzFrameSetPoint(TalentBox.Frame.Option[1].Frame, FRAMEPOINT_BOTTOMLEFT, TalentBox.Frame.Box, FRAMEPOINT_BOTTOMLEFT, 0.025, 0.02 + Settings.BoxOption2BottomGap + RMaxBJ(Settings.BoxLevelSizeY, Settings.BoxResetSizeY))
BlzFrameSetPoint(TalentBox.Frame.Close, FRAMEPOINT_TOPRIGHT, TalentBox.Frame.Box, FRAMEPOINT_TOPRIGHT, 0.0, 0)
-- TalentBox.Frame.Selected has to be created after the Pick buttons are created so it takes a higher position
TalentBox.Frame.Selected = BlzCreateFrame("TalentHighlight", TalentBox.Frame.Option.Parent, 0, 0)
BlzFrameSetVisible(TalentBox.Frame.Selected, false)
for i = 1, Settings.BoxLevelAmount do
local fh = BlzCreateFrame("TalentBoxLevelButton", TalentBox.Frame.Level.Parent, 0, i)
TalentBox.Frame.Level[i] = fh
TalentBox.Frame[fh] = i --remember this is button i
if i > 1 then
BlzFrameSetPoint(fh, FRAMEPOINT_BOTTOMLEFT,TalentBox.Frame.Level[i - 1] , FRAMEPOINT_BOTTOMRIGHT, 0,0)
end
BlzFrameSetSize(fh, Settings.BoxLevelSizeX, Settings.BoxLevelSizeY)
TasButtonAction.Set(fh, function(frame, player)
local index = TalentBox.Frame[frame]
TalentBoxSetTier(TalentBox.Control[player].Levels[index], player)
end)
end
BlzFrameSetPoint(TalentBox.Frame.Level[1], FRAMEPOINT_BOTTOMLEFT, TalentBox.Frame.Box, FRAMEPOINT_BOTTOMLEFT, 0.027,0.02)
BlzFrameSetVisible(TalentBox.Frame.Box, false)
BlzFrameSetPoint(TalentBox.Frame.PageDown, FRAMEPOINT_BOTTOMLEFT, TalentBox.Frame.Level[Settings.BoxLevelAmount], FRAMEPOINT_BOTTOMRIGHT, 0, 0.0005)
BlzFrameSetPoint(TalentBox.Frame.PageUp, FRAMEPOINT_BOTTOM, TalentBox.Frame.PageDown, FRAMEPOINT_TOP, 0, -0.0005)
if Settings.BoxHaveResetButton then
TalentBox.Frame.Reset = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentResetButton",TalentBox.Frame.Box, "ScriptDialogButton", 0)
CreateTooltip(TalentBox.Frame.Reset, "UI/Widgets/EscMenu/Human/blank-background", Settings.StringButtonResetText, Settings.StringButtonResetTooltip)
BlzFrameSetText(TalentBox.Frame.Reset, GetLocalizedString(Settings.StringButtonResetText))
BlzFrameSetSize(TalentBox.Frame.Reset, Settings.BoxResetSizeX, Settings.BoxResetSizeY)
BlzFrameSetPoint(TalentBox.Frame.Reset, FRAMEPOINT_BOTTOMRIGHT, TalentBox.Frame.Box, FRAMEPOINT_BOTTOMRIGHT, -0.027, 0.02)
TasButtonAction.Set(TalentBox.Frame.Reset, function(frame, player)
local function Reset(unit)
if not Talent.Settings.UseCondition(unit) then return false end
-- local unit = TalentBox.Control[player].Target
local shownLevel = TalentBox.Control[player].LevelsCurrent
local selectedCount = TalentUnitGetSelectionsDone(unit)
local selectedLevel = 0
if selectedCount > 0 then selectedLevel = Talent[unit].SelectionsDone[selectedCount].Level end
-- print("selectedCount", selectedCount)
-- print("selectedLevel", selectedLevel)
--print("shownLevel", shownLevel)
if selectedLevel >= shownLevel then
--print("Reset")
while(TalentUnitGetSelectionsDone(unit) > 0 and Talent[unit].SelectionsDone[TalentUnitGetSelectionsDone(unit)].Level >= shownLevel)
do
--print("Reset", Talent[unit].SelectionsDone[TalentUnitGetSelectionsDone(unit)].Level)
TalentResetDo(unit)
end
else
--if TalentUnitGetCurrentLevel(unit) < shownLevel then print("lower talents not selected") end --Has to be avoided by disabling the option to do this in this case
--learn reseted talents from the shown level to the max Level learned.
for k, v in pairs(Talent[unit].SelectionsDone) do
if v.Level <= Talent[unit].MaxLevel and v.Level >= shownLevel then
--print("ReLearn", "Level: "..v.Level, "ButtonNr: "..v.ButtonNr)
TalentPickDo(unit, v.ButtonNr)
end
end
end
end
if not Settings.FixedTarget and not TalentBox.Control[player].SingleMode then
local unit
local unitCode = TalentGetUnitCode(TalentBox.Control[player].Target)
local selectionsDone = TalentUnitGetSelectionsDone(TalentBox.Control[player].Target)
GroupEnumUnitsSelected(TalentBox.Control.SelectionCheckGroup, player, nil)
for i = 0, BlzGroupGetSize(TalentBox.Control.SelectionCheckGroup) - 1 do
unit = BlzGroupUnitAt(TalentBox.Control.SelectionCheckGroup, i)
if TalentGetUnitCode(unit) == unitCode
and TalentUnitGetSelectionsDone(unit) == selectionsDone
then
Reset(unit)
end
unit = nil
end
else
Reset(TalentBox.Control[player].Target)
end
TalentBoxUpdate(player)
end)
end
end
function TalentBoxInit()
TalentBoxCreate()
if FrameLoaderAdd then FrameLoaderAdd(TalentBoxCreate) end
TalentBox.Trigger.Select = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(TalentBox.Trigger.Select, EVENT_PLAYER_UNIT_SELECTED)
TriggerAddAction(TalentBox.Trigger.Select, function()
TalentBoxShow(GetTriggerUnit(), GetTriggerPlayer())
end)
TalentBox.Trigger.ESC = CreateTrigger()
for i = 0, bj_MAX_PLAYER_SLOTS-1 do TriggerRegisterPlayerEvent(TalentBox.Trigger.ESC, Player(i), EVENT_PLAYER_END_CINEMATIC) end
TriggerAddAction(TalentBox.Trigger.ESC, function()
if Settings.ESCClose and GetLocalPlayer() == GetTriggerPlayer() then
BlzFrameSetVisible(TalentBox.Frame.Box, false)
BlzFrameSetVisible(TalentBox.Frame.Show, true)
end
end)
TalentBox.SelectionCheckTimer = CreateTimer()
TimerStart(TalentBox.SelectionCheckTimer, 0.25, true, function()
GroupEnumUnitsSelected(TalentBox.Control.SelectionCheckGroup, GetLocalPlayer(), nil)
if Settings.AutoCloseWithoutSelection and GetHandleId(FirstOfGroup(TalentBox.Control.SelectionCheckGroup)) == 0 then
BlzFrameSetVisible(TalentBox.Frame.Box, false)
BlzFrameSetVisible(TalentBox.Frame.Show, true)
else
TalentBoxUpdate(GetLocalPlayer())
end
GroupClear(TalentBox.Control.SelectionCheckGroup)
end)
end
end
--[[ Talent.TasStats
addon for Talent Lui V1.35+ by Tasyen
A set of choice keys adds stats.
This includes changing ability fields.
Having Talent.TasStats installed makes picking/reseting choices a little bit heavier
, but it reduces the need of OnLearn/OnReset callbacks quite much with that the Unitsheets smaller.
should replace TalentPreMadeChoice as that was built very jassy
Example:
-- choice add 20 Str
choice.TasStr = 20
-- add cast Range and imporve Cooldown of Holy Light
-- beaware that the unit needs to have the manipulated ability before it picks the talent
choice.TasSpellField = {
-- holy Light
AHhb = {
-- add 120 range (all levels)
ABILITY_RLF_CAST_RANGE = 120
-- also reduce cooldown by 5 seconds (all levels)
ABILITY_RLF_COOLDOWN = -5
}
Ability Fields support Level specific changes, instead of a number use a table
choice.TasSpellField = {
-- holy Light
AHhb = {
-- reduce cooldown of Level 3 (object Editor Level 3)
ABILITY_RLF_COOLDOWN = {-0, -0, -5}
-- Instead of Listing this 0 you could write to an int index. Don't forget the [], if you plan to use this feature.
ABILITY_RLF_COOLDOWN = {[3] = -5}
}
]]
--
Talent.TasStatsStrings = {
TasStr = "STRENGTH"
,TasAgi = "AGILITY"
,TasInt = "INTELLECT"
,TasLife = "Life"
,TasLifeReg = "Life/s"
,TasMana = "Mana"
,TasManaReg = "Mana/s"
,TasArmor = "COLON_ARMOR"
,TasDamage = "COLON_DAMAGE"
,TasAttackSpeed = "AttackSpeed"
,TasTurnSpeed = "TurnSpeed"
,TasCastPoint = "CastPoint"
,TasCastBackswing = "CastBackswing"
,__index = function (table, key)
return key
end
}
Talent.TasStats = {
GainNewLifeMana = false
,TasStr = function(unit, value) SetHeroStr(unit, GetHeroStr(unit, false) + value, true) end
,TasAgi = function(unit, value) SetHeroAgi(unit, GetHeroAgi(unit, false) + value, true) end
,TasInt = function(unit, value) SetHeroInt(unit, GetHeroInt(unit, false) + value, true) end
,TasLife = function(unit, value)
BlzSetUnitMaxHP(unit, BlzGetUnitMaxHP(unit) + value)
if Talent.TasStats.GainNewLifeMana and value > 0 then SetUnitState(unit, UNIT_STATE_LIFE, GetUnitState(unit, UNIT_STATE_LIFE) + value) end
end
,TasLifeReg = function(unit, value) BlzSetUnitRealField(unit, UNIT_RF_HIT_POINTS_REGENERATION_RATE, BlzGetUnitRealField(unit, UNIT_RF_HIT_POINTS_REGENERATION_RATE) + value) end
,TasMana = function(unit, value)
BlzSetUnitMaxMana(unit, BlzGetUnitMaxMana(unit) + value)
if Talent.TasStats.GainNewLifeMana and value > 0 then SetUnitState(unit, UNIT_STATE_MANA, GetUnitState(unit, UNIT_STATE_MANA) + value) end
end
,TasManaReg = function(unit, value) BlzSetUnitRealField(unit, UNIT_RF_MANA_REGENERATION, BlzGetUnitRealField(unit, UNIT_RF_MANA_REGENERATION) + value) end
,TasArmor = function(unit, value) BlzSetUnitArmor(unit, BlzGetUnitArmor(unit) + value) end
,TasDamage = function(unit, value)
BlzSetUnitBaseDamage(unit, BlzGetUnitBaseDamage(unit, 0) + value, 0)
BlzSetUnitBaseDamage(unit, BlzGetUnitBaseDamage(unit, 1) + value, 1)
end
,TasAttackSpeed = function(unit, value)
BlzSetUnitAttackCooldown(unit, BlzGetUnitAttackCooldown(unit, 0) + value, 0)
BlzSetUnitAttackCooldown(unit, BlzGetUnitAttackCooldown(unit, 1) + value, 1)
end
,TasTurnSpeed = function(unit, value) SetUnitTurnSpeed(unit, GetUnitTurnSpeed(unit) + value) end
-- TasCastPoint TasCastBackswing don't affect abilities the unit already has. One would have to lose and regain all to make it work.
,TasCastPoint = function(unit, value) BlzSetUnitRealField(unit, UNIT_RF_CAST_POINT, BlzGetUnitRealField(unit, UNIT_RF_CAST_POINT) + value) end
,TasCastBackswing = function(unit, value) BlzSetUnitRealField(unit, UNIT_RF_CAST_BACK_SWING, BlzGetUnitRealField(unit, UNIT_RF_CAST_BACK_SWING) + value) end
}
function TalentTasStatsGetText(choice, doNotSetText)
if not choice then choice = Talent.LastUsedChoice end
local text = ""
local first = true
local seperator = {[false] =", ", [true] = ""}
for key in pairs(Talent.TasStats) do
if choice[key] then
text = text .. seperator[first].. choice[key] .. " " .. GetLocalizedString(Talent.TasStatsStrings[key])
first = false
end
end
if not doNotSetText then
choice.Text = text
end
return text
end
function TalentTasModValueHelper(oldValue, value, modi)
if not modi or modi == "+" then
return oldValue + value
elseif modi == "-" then
return oldValue - value
--elseif modi == "*" then
-- return oldValue * value
--elseif modi == "/" then
--return oldValue / value
--elseif modi == "=" then
--return value
--elseif modi == "^" then
--return math.pow(oldValue, value)
end
return oldValue
end
TalentTasSpellField = function(abi, field, value, modi)
if type(field) == "string" then field = _G[field] end
local typeString = tostring(field)
local oldValue
if string.find(typeString, "abilityreallevelfield:") then
for i = 0, BlzGetAbilityIntegerField(abi, ABILITY_IF_LEVELS) - 1 do
oldValue = BlzGetAbilityRealLevelField(abi, field, i)
-- support Level specific changes by {1,2,34,5}
if type(value) == "table" then
-- support only Level x changes {[3] = 5}
if value[i + 1] then
BlzSetAbilityRealLevelField(abi, field, i, TalentTasModValueHelper(oldValue, value[i + 1], modi))
end
else
BlzSetAbilityRealLevelField(abi, field, i, TalentTasModValueHelper(oldValue, value, modi))
end
end
elseif string.find(typeString, "abilityintegerlevelfield:") then
for i = 0, BlzGetAbilityIntegerField(abi, ABILITY_IF_LEVELS) - 1 do
oldValue = BlzGetAbilityIntegerLevelField(abi, field, i)
if type(value) == "table" then
if value[i + 1] then
BlzSetAbilityIntegerLevelField(abi, field, i, TalentTasModValueHelper(oldValue, value[i + 1], modi))
end
else
BlzSetAbilityIntegerLevelField(abi, field, i, TalentTasModValueHelper(oldValue, value, modi))
end
end
elseif string.find(typeString, "abilityrealfield:") then
oldValue = BlzGetAbilityRealField(abi, field)
BlzSetAbilityRealField(abi, field, TalentTasModValueHelper(oldValue, value, modi))
elseif string.find(typeString, "abilityintegerfield:") then
oldValue = BlzGetAbilityIntegerField(abi, field)
BlzSetAbilityIntegerField(abi, field, TalentTasModValueHelper(oldValue, value, modi))
end
end
--Example for using Talent by Tasyen.
TalentAddUnitSheet(function()
local choice
TalentHeroCreate('H005') --Custom BloodMage
TalentHeroCreateTierEx(1)
choice = TalentChoiceCreateAddSpells('AHfs', 'ANbf', 'ANfb')
choice.Head = "Fire Magic"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNFire.blp"
-- choice = TalentChoiceCreateAddSpells( 'ANfl', 'AOcl', 'ANmo')
choice = TalentChoiceCreateAddSpells( 'ANfl', 'AOcl')
choice.Head = "Lightning Magic"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNMonsoon.blp"
--LEVEL 5
TalentHeroCreateTierEx(5)
choice = TalentHeroCreateChoiceEx()
choice.TasStr = 6
choice.TasAgi = 3
choice.TasInt = 3
choice.Head = "Magic Power: Str"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHelmOfValor.blp"
-- set the text of the last Created Choice based on TasStats
TalentTasStatsGetText()
choice = TalentHeroCreateChoiceEx()
choice.TasStr = 3
choice.TasAgi = 6
choice.TasInt = 3
choice.Head = "Magic Power: AGI"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHoodOfCunning.blp"
TalentTasStatsGetText()
choice = TalentHeroCreateChoiceEx()
choice.TasStr = 3
choice.TasAgi = 3
choice.TasInt = 6
choice.Head = "Magic Power: Int"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNPipeOfInsight.blp"
TalentTasStatsGetText()
--Level 10
TalentHeroCreateTierEx(10)
TalentChoiceCreateAddSpell('AHpx',true)
TalentChoiceCreateAddSpell('AUin',true)
end)
function TalentStatChange( )
ModifyHeroStat(udg_Talent__Choice.StatType, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, udg_Talent__Choice.StatPower )
end
function TalentStatChangeReset( )
ModifyHeroStat(udg_Talent__Choice.StatType, udg_Talent__Unit, bj_MODIFYMETHOD_SUB, udg_Talent__Choice.StatPower )
end
--Example for using Talent by Tasyen.
TalentAddUnitSheet(function()
--Which HeroType is this; Custom Paladin
local heroTypeId = FourCC('H001')
local choice
TalentHeroCreate(heroTypeId)
--HeroTypeId gains at Level 0: create a new Tier
TalentHeroCreateTierEx(1)
--Create a new Choice and add it to the last Created Tier
choice = TalentHeroCreateChoiceEx() --activade TalentStr when Picking this Talent
choice.OnLearn = function() ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 ) end
choice.OnReset = function() ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_SUB, 6 ) end
choice.Text = "Gain 6 Str"
choice.Head = "Handschuhe der Kraft"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower.blp"
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = function() ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 ) end
choice.OnReset = function() ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_SUB, 6 ) end
choice.Text = "Gain 6 Agi"
choice.Head = "Schuhe der Beweglichkeit"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility.blp"
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = function() ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 ) end
choice.OnReset = function() ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_SUB, 6 ) end
choice.Text = "Gain 6 Int"
choice.Head = "Robe der Weißen"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
--Level 2
TalentHeroCreateTierEx(2)
choice = TalentHeroCreateChoiceEx()
abilityId = FourCC('Awfb')
TalentChoiceAddAbility(choice, abilityId) --Skill gained when picking this choice
choice.Text = BlzGetAbilityExtendedTooltip(abilityId,1)
choice.Head = BlzGetAbilityTooltip(abilityId,1)
choice.Icon = BlzGetAbilityIcon(abilityId)
choice = TalentHeroCreateChoiceEx()
abilityId = FourCC('AHhb')
TalentChoiceAddAbility(choice, abilityId)
choice.Text = BlzGetAbilityExtendedTooltip(abilityId,1)
choice.Head = BlzGetAbilityTooltip(abilityId,1)
choice.Icon = BlzGetAbilityIcon(abilityId)
--Level 4
TalentHeroCreateTierEx(4)
choice = TalentHeroCreateChoiceEx()
abilityId = FourCC('ACif')
TalentChoiceAddAbility(choice, abilityId)
choice.Text = BlzGetAbilityExtendedTooltip(abilityId,1)
choice.Head = BlzGetAbilityTooltip(abilityId,1)
choice.Icon = BlzGetAbilityIcon(abilityId)
choice = TalentHeroCreateChoiceEx()
abilityId = FourCC('Afbt')
TalentChoiceAddAbility(choice, abilityId)
choice.Text = BlzGetAbilityExtendedTooltip(abilityId,1)
choice.Head = BlzGetAbilityTooltip(abilityId,1)
choice.Icon = BlzGetAbilityIcon(abilityId)
--Create Own Variabes and attach them
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = TalentStatChange
choice.OnReset = TalentStatChangeReset
choice.Text = "Gain 8 Str"
choice.Head = "Gürtel der Gigantenkraft"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNBelt.blp"
choice.StatType = bj_HEROSTAT_STR --save custom Data, one should not overwrite indexes expected with different data
choice.StatPower = 8
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = TalentStatChange
choice.OnReset = TalentStatChangeReset
choice.Text = "Gain 8 Int"
choice.Head = "Robe der Weißen"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
choice.StatType = bj_HEROSTAT_INT
choice.StatPower = 8
--Level 6
TalentHeroCreateTierEx(6)
choice = TalentHeroCreateChoiceEx()
abilityId = FourCC('AHre')
TalentChoiceAddAbilityEx(abilityId, 0)
choice.Text = BlzGetAbilityExtendedTooltip(abilityId,1)
choice.Head = BlzGetAbilityTooltip(abilityId,1)
choice.Icon = BlzGetAbilityIcon(abilityId)
choice = TalentHeroCreateChoiceEx()
abilityId = FourCC('AHav')
TalentChoiceAddAbilityEx(abilityId, 0)
choice.Text = BlzGetAbilityExtendedTooltip(abilityId,1)
choice.Head = BlzGetAbilityTooltip(abilityId,1)
choice.Icon = BlzGetAbilityIcon(abilityId)
--Level 8
TalentHeroCreateTierEx(8)
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = function()
ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
end
choice.OnReset = function()
ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_SUB, 6 )
ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_SUB, 6 )
ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_SUB, 6 )
end
choice.Text = "Gain + 6 to all stats"
choice.Head = "Krone des Königs"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHelmutPurple.blp"
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = function() BlzSetUnitBaseDamage(udg_Talent__Unit, BlzGetUnitBaseDamage(udg_Talent__Unit, 0) + 20, 0) end
choice.OnReset = function() BlzSetUnitBaseDamage(udg_Talent__Unit, BlzGetUnitBaseDamage(udg_Talent__Unit, 0) - 20, 0) end
choice.Text = "Gain 20 ATK"
choice.Head = "Mithril Blade"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNArcaniteMelee.blp"
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = function() BlzSetUnitArmor(udg_Talent__Unit, BlzGetUnitArmor(udg_Talent__Unit) + 10) end
choice.OnReset = function() BlzSetUnitArmor(udg_Talent__Unit, BlzGetUnitArmor(udg_Talent__Unit) - 10) end
choice.Text = "Gain 10 Armor"
choice.Head = "Mithril Armor"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpThree.blp"
end)
TalentAddUnitSheet(function()
TalentHeroCopy('H003', 'H001') -- FourCC('H003') uses the same talents as FourCC('H001')
TalentHeroCopy('H004', 'H002')
TalentHeroCopy('H007', 'H006')
end)
--Example for using Talent by Tasyen.
TalentAddUnitSheet(function()
local choice
--Which HeroType is this; Footmen
TalentHeroCreate('hfoo')
TalentHeroCreateTierEx(1)
--Create a new Choice and add it to the last Created Tier
choice = TalentHeroCreateChoiceEx()
choice.TasDamage = 6
choice.Head = "Deadly Footman"
choice.Text = "Increases Base AttackDamage by 6"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNSteelMelee.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasArmor = 4
choice.Head = "Tanky Footman"
choice.Text = "Increases Armor by 4"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpOne.blp"
end)
--Example for using Talent by Tasyen.
TalentAddUnitSheet(function()
local choice
--Which HeroType is this; Shadow Priest
TalentHeroCreate('nfsp')
TalentHeroCreateTierEx(1)
--Create a new Choice and add it to the last Created Tier
choice = TalentChoiceCreateReplaceSpell(FourCC('Anh1'),FourCC('Anh2'))
choice.Head = "More Heal"
choice.Text = "Increases Heal by 13"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHealOn.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasSpellField = {
Anh1 = {
ABILITY_ILF_MANA_COST = -2
,ABILITY_RLF_COOLDOWN = -0.1
}
}
choice.Head = "Cheaper Heal"
choice.Text = "Reduce Manacosts by 2 and improves cooldown by 0.1s"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHealOn.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasLife = 200
choice.TasMana = 100
choice.TasArmor = 1
choice.Head = "Sustain Healer"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNForestTrollShadowPriest.blp"
TalentTasStatsGetText()
end)
--Example for using Talent by Tasyen.
TalentAddUnitSheet(function()
local choice
--Which HeroType is this; Human Sorceress
TalentHeroCreate('hsor')
TalentHeroCreateTierEx(1)
choice = TalentHeroCreateChoiceEx()
choice.TasSpellField = {
Aslo = {
ABILITY_IF_REQUIRED_LEVEL = 6
}
,Aply = {
ABILITY_IF_REQUIRED_LEVEL = 6
,ABILITY_ILF_MAXIMUM_CREEP_LEVEL_PLY1 = 100
}
}
choice.Head = "Powerful Magic"
choice.Text = "Slow & Poly can be used on spell immune targets, Removes Level cap for poly"
choice.Icon = "ReplaceableTextures/CommandButtons/BTNControlMagic"
choice = TalentHeroCreateChoiceEx()
choice.TasLife = 200
choice.TasMana = 100
choice.Head = "Sustain"
choice.Icon = "ReplaceableTextures/CommandButtons/BTNRingGreen"
TalentTasStatsGetText()
choice = TalentHeroCreateChoiceEx()
choice.OnLearn = function(unit)
-- castpoint only updates when the abilities are regained
UnitRemoveAbility(unit, FourCC('Aivs'))
UnitRemoveAbility(unit, FourCC('Aply'))
UnitRemoveAbility(unit, FourCC('Aslo'))
UnitAddAbility(unit, FourCC('Aivs'))
UnitAddAbility(unit, FourCC('Aply'))
UnitAddAbility(unit, FourCC('Aslo'))
end
choice.OnReset = function(unit)
UnitRemoveAbility(unit, FourCC('Aivs'))
UnitRemoveAbility(unit, FourCC('Aply'))
UnitRemoveAbility(unit, FourCC('Aslo'))
UnitAddAbility(unit, FourCC('Aivs'))
UnitAddAbility(unit, FourCC('Aply'))
UnitAddAbility(unit, FourCC('Aslo'))
end
choice.TasCastPoint = -0.45
choice.TasCastBackswing = -1.080
choice.Head = "Quick Magic"
choice.Text = "Removes normal cast time"
choice.Icon = "ReplaceableTextures/CommandButtons/BTNRingJadeFalcon"
TalentHeroCreateTierEx(2)
choice = TalentHeroCreateChoiceEx()
TalentChoiceAddAbilityEx('Apiv')
choice.Head = "Passive Invis"
choice.Text = "Get Perma Invis"
choice.Icon = "ReplaceableTextures/CommandButtons/BTNInvisibility"
choice = TalentHeroCreateChoiceEx()
choice.TasDamage = 7
choice.Head = "Deadly Magic"
choice.Text = "+7 Damage"
choice.Icon = "ReplaceableTextures/CommandButtons/BTNFeedBack"
end)
--Example for using Talent by Tasyen.
TalentAddUnitSheet(function()
local choice
TalentHeroCreate('H002') --Custom Uther
TalentHeroCreateTierEx(1)
choice = TalentHeroCreateChoiceEx()
choice.TasStr = 6
choice.Text = "Gain 6 Str & Int"
choice.Head = "Handschuhe der Kraft"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasAgi = 6
choice.Text = "Gain 6 agi"
choice.Head = "Schuhe der Beweglichkeit"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasInt = 6
choice.Text = "Gain 6 Int"
choice.Head = "Robe der Weißen"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
-- add cast Range and improve Cooldown of Holy Light
-- beaware that the unit needs to have the manipulated ability before it picks the talent
choice = TalentHeroCreateChoiceEx()
choice.TasSpellField = {
AHhb = {
-- add 220 range for Level 3 but 0 for 1, 2
-- ABILITY_RLF_CAST_RANGE = {0,0,220}
ABILITY_RLF_CAST_RANGE = {[3]=220}
-- increase healing by 100
,ABILITY_RLF_AMOUNT_HEALED_DAMAGED_HHB1 = 100
}
}
choice.Head = "Paladin Healer"
choice.Text = "Holy Light heals 100 more and has 0/0/220 more cast Range"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHolyBolt"
TalentHeroCreateTierEx(2)
choice = TalentHeroCreateChoiceEx()
choice.TasInt = 3
choice.TasAgi = 3
choice.TasStr = 6
choice.Head = "Magic Power: Str"
choice.Text = "Int +3 Agi +3 Str + 6"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHelmOfValor.blp"
TalentTasStatsGetText(choice, true)
choice = TalentHeroCreateChoiceEx()
choice.TasInt = 3
choice.TasAgi = 6
choice.TasStr = 3
choice.Head = "Magic Power: AGI"
choice.Text = "Int +3 Agi +6 Str + 3"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHoodOfCunning.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasInt = 6
choice.TasAgi = 3
choice.TasStr = 3
choice.Head = "Magic Power: Int"
choice.Text = "Int +6 Agi +3 Str + 3"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNPipeOfInsight.blp"
TalentHeroCreateTierEx(3)
TalentChoiceCreateAddSpell('ACif',true)
TalentChoiceCreateAddSpell('Afbt',true)
choice = TalentHeroCreateChoiceEx()
choice.TasStr = 8
choice.Head = "Gürtel der Kraft"
choice.Text = "Str + 8"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNBelt.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasInt = 8
choice.Head = "Robe der Weißen"
choice.Text = "Int + 8"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
TalentChoiceCreateAddSpell('ACam',true)
TalentChoiceCreateAddSpell('ACmp',true)
TalentHeroCreateTierEx(4)
TalentChoiceCreateAddSpell('AHre',true)
TalentChoiceCreateAddSpell('AHav',true)
TalentHeroCreateTierEx(5)
choice = TalentHeroCreateChoiceEx()
choice.TasInt = 5
choice.TasAgi = 5
choice.TasStr = 5
choice.Text = "Gain + 5 to all stats"
choice.Head = "Krone des Königs"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHelmutPurple.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasDamage = 20
choice.Text = "Gain 20 ATK"
choice.Head = "Mithril Blade"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNArcaniteMelee.blp"
choice = TalentHeroCreateChoiceEx()
choice.TasArmor = 10
choice.Text = "Gain 10 Armor"
choice.Head = "Mithril Armor"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpThree.blp"
end)
--TasUnitBonus Example for Talent by Tasyen.
TalentAddUnitSheet(function()
local choice
TalentHeroCreate('O000') --Custom BladeMaster
TalentHeroCreateTierEx(1)
choice = TalentChoiceCreateTasUnitBonusEx({Attack = 6, Life = 50})
choice.Text = "Gain 6 ATK & 50 HP"
choice.Head = "Handschuhe der Kraft"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower.blp"
choice = TalentChoiceCreateTasUnitBonusEx({AttackSpeed = -0.1})
choice.Text = "Improve Base Attackspeed by 0.1s"
choice.Head = "Schuhe der Beweglichkeit"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility.blp"
choice = TalentChoiceCreateTasUnitBonusEx({ManaReg = 3, Mana = 100})
choice.Text = "Gain 3 MP/s & 100 MP"
choice.Head = "Robe der Weißen"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
TalentHeroCreateTierEx(2)
choice = TalentChoiceCreateTasUnitBonusEx({Int = 3, Agi = 3, Str = 6})
choice.Head = "Magic Power: Str"
choice.Text = "Int +3 Agi +3 Str + 6"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHelmOfValor.blp"
TalentTasStatsGetText(choice, true)
choice = TalentChoiceCreateTasUnitBonusEx({Int = 3, Agi = 6, Str = 3})
choice.Head = "Magic Power: AGI"
choice.Text = "Int +3 Agi +6 Str + 3"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHoodOfCunning.blp"
choice = TalentChoiceCreateTasUnitBonusEx({Int = 6, Agi = 3, Str = 3})
choice.Head = "Magic Power: Int"
choice.Text = "Int +6 Agi +3 Str + 3"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNPipeOfInsight.blp"
TalentHeroCreateTierEx(3)
choice = TalentChoiceCreateTasUnitBonusEx({Ability = 'ACbl', Ability2 = 'AChx'})
choice.Head = "SpellCaster"
choice.Text = "Gain BloodLust & Hex"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNShamanAdept.blp"
choice = TalentChoiceCreateTasUnitBonusEx({Str = 8})
choice.Head = "Gürtel der Kraft"
choice.Text = "Str + 8"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNBelt.blp"
choice = TalentChoiceCreateTasUnitBonusEx({Int = 8})
choice.Head = "Robe der Weißen"
choice.Text = "Int + 8"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
TalentChoiceCreateAddSpell('ACam',true)
TalentChoiceCreateAddSpell('ACmp',true)
TalentHeroCreateTierEx(4)
TalentChoiceCreateAddSpell('AHre',true)
TalentChoiceCreateAddSpell('AHav',true)
TalentHeroCreateTierEx(5)
choice = TalentChoiceCreateTasUnitBonusEx({Int = 5, Agi = 5, Str = 5})
choice.Text = "Gain + 5 to all stats"
choice.Head = "Krone des Königs"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHelmutPurple.blp"
choice = TalentChoiceCreateTasUnitBonusEx({Attack = 20})
choice.Text = "Gain 20 ATK"
choice.Head = "Mithril Blade"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNArcaniteMelee.blp"
choice = TalentChoiceCreateTasUnitBonusEx({Armor = 10})
choice.Text = "Gain 10 Armor"
choice.Head = "Mithril Armor"
choice.Icon = "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpThree.blp"
end)
--Example for using Talent by Tasyen.
TalentAddUnitSheet(function()
--Which HeroType is this; Pitlord
TalentHeroCreate(FourCC('N000'))
local a = FourCC('bgst')
local b = FourCC('belv')
local c = FourCC('ciri')
for i = 1, 20, 1 do
TalentHeroCreateTierEx(i)
local choice
choice = TalentHeroCreateChoiceEx()
choice.TasStr = 6
choice.Text = BlzGetAbilityExtendedTooltip(a, 0)
choice.Head = GetObjectName(a)
choice.Icon = BlzGetAbilityIcon(a)
choice = TalentHeroCreateChoiceEx()
choice.TasAgi = 6
choice.Text = BlzGetAbilityExtendedTooltip(b, 0)
choice.Head = GetObjectName(b)
choice.Icon = BlzGetAbilityIcon(b)
choice = TalentHeroCreateChoiceEx()
choice.TasInt = 6
choice.Text = BlzGetAbilityExtendedTooltip(c, 0)
choice.Head = GetObjectName(c)
choice.Icon = BlzGetAbilityIcon(c)
end
end)
--Example for using Talent by Tasyen. StringList
-- This example shows how to use a StringList to setup Text/Icon/Head. (Requires Talent 1.34d)
TalentAddUnitSheet(function()
-- define a Load function,
local function OnLoad()
BlzLoadTOCFile("war3mapImported/TalentPriest.toc")
end
-- call the Toc loading in the fdf with the StringList
OnLoad()
-- frame Api does not persist game save&Load in (1.31.1 upto 1.32.10)
-- repeat the Toc loading after game load
if FrameLoaderAdd then FrameLoaderAdd(OnLoad) end
-- create a new TalentTree for Priest
TalentHeroCreate('hmpr') -- Priest
-- create a Tier at Level 1
TalentHeroCreateTierEx(1)
local choice
--Create a new Choice and add it to the last Created Tier
choice = TalentHeroCreateChoiceEx()
choice.Text = "TalentPriest1Text"
choice.Head = "TalentPriest1Head"
choice.Icon = "TalentPriest1Icon"
choice.TasMana = 100
choice.TasManaReg = 1
--Create a new Choice and add it to the last Created Tier
choice = TalentHeroCreateChoiceEx() --activade TalentStr when Picking this Talent
choice.Text = "TalentPriest2Text"
choice.Head = "TalentPriest2Head"
choice.Icon = "TalentPriest2Icon"
choice.TasSpellField = {
-- Human Heal
Ahea = {
-- + 5 to Heal
ABILITY_RLF_HIT_POINTS_GAINED_HEA1 = 5
}
-- Dispel Magic
,Adis = {
-- + 50 AoE
ABILITY_RLF_AREA_OF_EFFECT = 50
}
-- Human Inner Fire
,Ainf = {
-- + 20 Duration for Hero and Units
ABILITY_RLF_DURATION_HERO = 20
,ABILITY_RLF_DURATION_NORMAL = 20
}
}
--Create a new Choice and add it to the last Created Tier
choice = TalentHeroCreateChoiceEx() --activade TalentStr when Picking this Talent
choice.Text = "TalentPriest3Text"
choice.Head = "TalentPriest3Head"
choice.Icon = "TalentPriest3Icon"
choice.TasLife = 200
choice.TasLifeReg = 2
end)
--Talent GUI 1.04
--by Tasyen
--===========================================================================
-- Makes Talent Registering useable using GUI only.
--===========================================================================
do
local real = InitBlizzard
function InitBlizzard()
real()
udg_TalentGUICreateChoice = CreateTrigger()
TriggerAddAction(udg_TalentGUICreateChoice, function()
local choice = TalentHeroCreateChoiceAtLevel(udg_TalentGUI_UnitType, udg_TalentGUI_Level)
choice.Text = udg_TalentGUI_Text
choice.Head = udg_TalentGUI_Head
choice.Icon = udg_TalentGUI_Icon
TalentChoiceAddAbility(choice, udg_TalentGUI_Spell, udg_TalentGUI_ReplacedSpell)
udg_TalentGUI_Spell = 0
udg_TalentGUI_ReplacedSpell = 0
end)
udg_TalentGUIAddSpell = CreateTrigger()
TriggerAddAction(udg_TalentGUIAddSpell, function()
TalentChoiceAddAbility(Talent.LastCreatedChoice, udg_TalentGUI_Spell, udg_TalentGUI_ReplacedSpell)
udg_TalentGUI_Spell = 0
end)
udg_TalentGUICopy = CreateTrigger()
TriggerAddAction(udg_TalentGUICopy, function()
TalentHeroCopy(udg_TalentGUI_UnitType, udg_TalentGUI_UnitTypeCopied)
end)
udg_TalentGUIAddTasStats = CreateTrigger()
TriggerAddAction(udg_TalentGUIAddTasStats, function()
local choice = Talent.LastUsedChoice
if udg_TalentGUI_TasStr and udg_TalentGUI_TasStr ~= 0 then choice.TasStr = udg_TalentGUI_TasStr end
if udg_TalentGUI_TasAgi and udg_TalentGUI_TasAgi ~= 0 then choice.TasAgi = udg_TalentGUI_TasAgi end
if udg_TalentGUI_TasInt and udg_TalentGUI_TasInt ~= 0 then choice.TasInt = udg_TalentGUI_TasInt end
if udg_TalentGUI_TasDamage and udg_TalentGUI_TasDamage ~= 0 then choice.TasDamage = udg_TalentGUI_TasDamage end
if udg_TalentGUI_TasMana and udg_TalentGUI_TasMana ~= 0 then choice.TasMana = udg_TalentGUI_TasMana end
if udg_TalentGUI_TasManaReg and udg_TalentGUI_TasManaReg ~= 0 then choice.TasManaReg = udg_TalentGUI_TasManaReg end
if udg_TalentGUI_TasLife and udg_TalentGUI_TasLife ~= 0 then choice.TasLife = udg_TalentGUI_TasLife end
if udg_TalentGUI_TasLifeReg and udg_TalentGUI_TasLifeReg ~= 0 then choice.TasLifeReg = udg_TalentGUI_TasLifeReg end
if udg_TalentGUI_TasArmor and udg_TalentGUI_TasArmor ~= 0 then choice.TasArmor = udg_TalentGUI_TasArmor end
if udg_TalentGUI_TasAttackspeed and udg_TalentGUI_TasAttackspeed ~= 0 then choice.TasAttackSpeed = udg_TalentGUI_TasAttackspeed end
if udg_TalentGUI_TasTurnspeed and udg_TalentGUI_TasTurnspeed ~= 0 then choice.TasTurnSpeed = udg_TalentGUI_TasTurnspeed end
if udg_TalentGUI_TasCastPoint and udg_TalentGUI_TasCastPoint ~= 0 then choice.TasCastPoint = udg_TalentGUI_TasCastPoint end
if udg_TalentGUI_TasCastBackswing and udg_TalentGUI_TasCastBackswing ~= 0 then choice.TasCastBackswing = udg_TalentGUI_TasCastBackswing end
-- reset TasStat GUI variables
udg_TalentGUI_TasStr = 0
udg_TalentGUI_TasAgi = 0
udg_TalentGUI_TasInt = 0
udg_TalentGUI_TasDamage = 0
udg_TalentGUI_TasMana = 0
udg_TalentGUI_TasManaReg = 0.0
udg_TalentGUI_TasLife = 0
udg_TalentGUI_TasLifeReg = 0.0
udg_TalentGUI_TasArmor = 0.0
udg_TalentGUI_TasAttackspeed = 0.0
udg_TalentGUI_TasTurnspeed = 0.0
udg_TalentGUI_TasCastPoint = 0.0
udg_TalentGUI_TasCastBackswing = 0.0
end)
-- TasSpellField does not work in GUI, because TriggerData mentions wrong extend Type for abilityxxxfield is should be handle not integer.
-- makes this whole feature unuseable in GUI with default TriggerData
udg_TalentGUIAddTasSpellField = CreateTrigger()
TriggerAddAction(udg_TalentGUIAddTasSpellField, function()
local choice = Talent.LastUsedChoice
if not choice.TasSpellField then choice.TasSpellField = {} end
if not choice.TasSpellField[udg_TalentGUI_Spell] then choice.TasSpellField[udg_TalentGUI_Spell] = {} end
if udg_TalentGUI_TasSpellFieldRL then
if udg_TalentGUI_TasSpellReal[0] then
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldRL] = udg_TalentGUI_TasSpellReal[0]
else
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldRL] = {}
for i, v in pairs(udg_TalentGUI_TasSpellReal) do
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldRL][i] = v
end
end
end
if udg_TalentGUI_TasSpellFieldIL then
if udg_TalentGUI_TasSpellInt[0] then
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldIL] = udg_TalentGUI_TasSpellInt[0]
else
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldIL] = {}
for i, v in pairs(udg_TalentGUI_TasSpellInt) do
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldIL][i] = v
end
end
end
if udg_TalentGUI_TasSpellFieldI then
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldI] = udg_TalentGUI_TasSpellInt[0]
end
if udg_TalentGUI_TasSpellFieldR then
choice.TasSpellField[udg_TalentGUI_Spell][udg_TalentGUI_TasSpellFieldR] = udg_TalentGUI_TasSpellReal[0]
end
-- reset
udg_TalentGUI_TasSpellReal = __jarray(0.0)
udg_TalentGUI_TasSpellInt = __jarray(0)
udg_TalentGUI_TasSpellFieldRL = nil
udg_TalentGUI_TasSpellFieldIL = nil
udg_TalentGUI_TasSpellFieldI = nil
udg_TalentGUI_TasSpellFieldR = nil
end)
end
end
-- some demo feature that gives an editbox to execute give Lua code at runtime
do
local realInitBlizzard = InitBlizzard
local function INit()
BlzLoadTOCFile("war3mapImported\\Templates.toc")
BlzCreateFrame("EscMenuEditBoxTemplate", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
BlzFrameSetAbsPoint(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), FRAMEPOINT_TOPLEFT, 0.005, 0.55)
BlzFrameSetSize(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), 0.20, 0.04)
TasEditBoxAction(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), function(frame)
xpcall(function() load(BlzFrameGetText(frame))() end, print)
end)
end
function InitBlizzard()
realInitBlizzard()
INit()
if FrameLoaderAdd then FrameLoaderAdd(INit) end
end
end
-- a textarea display explaining Talent
do
local realInitBlizzard = InitBlizzard
function InitBlizzard()
realInitBlizzard()
TimerStart(CreateTimer(),1,false, function()
local fh = BlzCreateFrame("TalentBoxTextArea", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
BlzFrameSetSize(fh, 0.22, 0.22)
BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPRIGHT, 0.8, 0.55)
BlzFrameSetText(fh, "Talent Lui, gives units/heroes at levels you want a tier. An unit can pick 1 option from the given options the tier has.|n|nSelect an unit and click the ShowTalent Button to show the TalentBox.|n|nWhen the talentBox is shown you can observe talents choosen from the selected unit regardless of ownerhship.|n|nYou can pick/unlearn talents from any unit you have shared control of.")
BlzFrameSetEnable(fh, false)
end)
end
end