--[[ TasHeroLearnEx V3 by Tasyen
A custom UI System, allows an Unit to learn many skills or change the learn pool during the game.
TasHeroLearnEx.UpdateHeroData()
use this when you changed the HeroData from the outside or after InitBlizzard happened
only needed when you wrote strings.
function TasHeroLearnEx.CustomUnitLearnAbility(unit, abiCode)
Make Unit learn/improve abiCode and evoke a Learn Event
considers level requirments
overwrites TriggerRegisterAnyUnitEventBJ, DestroyTrigger (they still do what they should do)
and for a short time GetTriggerUnit, GetTriggerEventId, GetLearningUnit, GetLearnedSkill, GetLearnedSkillLevel, GetTriggerPlayer
only overwrites with hookEvent = true
Can use Hook version 7.0.1 by Bribe When provided
]]
do
local hookEvent = true --[[ Hook into Learn Event Triggers and Throw them? Only read at init
when you don't use hookEvent then you need to fill TasHeroLearnEx.Action with actionFunctions(unit, abiCode, abilityLevel, owner, unitCode)
TasHeroLearnEx.Action[FourCC('AHbz')] = function(unit, abiCode, abilityLevel, owner, unitCode) end
TasHeroLearnEx.Action[0] allways runs (hookEvent = false)
I'd advise to disable hookEvent when you not use GUI for this.
--]]
local AutoRun = true --(true) will create Itself at 0s, (false) you need to TasHeroLearnEx.Init()
local testSkill = FourCC'Agyb' -- should not in the command card
local action
if CreateFourCCTable then action = CreateFourCCTable() else action = {} end
-- the none hookEvent approach runs for any skill learned by TasHeroLearnEx
action[0] = function(unit, abiCode, abilityLevel, owner, unitCode)
print("Action 0", GetUnitName(unit), GetAbilityName(abiCode))
end
TasHeroLearnEx = {
TocPath = "war3mapImported\\TasHeroLearnEx.toc"-- Where is the TOCFile in your map (import Path)?
,BigUIShow = false -- can be async and changed during the match, (true) each choice is displayed as a clickable tooltipbox, (false) show small buttons that show text when pointed at.
,BigUIButtonCount = 6 --made for 3 or 6 buttons
-- BigUI is only shown for own units
-- Data for each UnitCode
,HeroData = {
-- supported Keys unit, unitCode, Player, 0; unit > unitCode > Player > 0
-- [0] is used by everyone, if not one of the others is used currently.
-- [bj_lastCreatedUnit] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
-- [FourCC('Hblm')] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
-- [Player(0)] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
-- [0] = "AEmb,AEim,AEev,AEme,AEer,AEfn,AEah,AEtq"
-- you can set a field from outside of this system, But if you do you should use TasHeroLearnEx.UpdateHeroData() after setting your wanted data.
-- TasHeroLearnEx.HeroData[FourCC('Hblm')] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
-- also supports Lua tables instead of abilitIds and can mix them
-- {Icon = "ReplaceableTextures/CommandButtons/BTNMagicLariet", Text ="Table Test more text", Name = "Table Test", Levels = 3, LevelSkip = 1, LevelReq = 1}
-- Levels, LevelSkip, LevelReq can be skiped defaults to 1 or 0.
-- inside the action/event abiCode is the table.
}
,TasUnitBonus = {} -- store TasUnitBonus gained when this is "learned", like in TasUnitBonusHero
-- { every level, [1] ={ level 1 bonus }}, beaware that array format for every level only works when you dont have specific level bonuses
-- TasHeroLearnEx.TasUnitBonus[FourCC'AHfs'] = {"Life",11} --every level gives 11 current & Max LIfe
,HeroAbilityLevelSkip = 2 -- should match the map gameplay constant
,Filter = function(unit) -- used for HeroData[0] prevent/allow using the every unit pool
if IsUnitIllusion(unit) then return false end
-- if not IsUnitType(unit, UNIT_TYPE_HERO) then return false end
--return true if this unit is allowed to use HeroData[0] HeroData[player]
return true
end
-- smallUI
,Cols = 8 --amout of buttons in one Row
,Rows = 1 -- amount of Rows
,ShowEnemy = true -- can look into enemy builts false/true?
,HideMaxLevelSlot = false -- true shows empty slots for max Leveld skills.
,UserControl = false -- Show the Buttons to toggle ShowEnemy & HideMaxLevelSlot
,HideWithoutUser = true -- hide TasHeroLearnEx UI when currently nothing would be displayed.
,UseUIScale = true -- Warcraft 3 V2.0 option hudScale only affects smallUI
--ToolTip
,ToolTipSizeX = 0.2
,ToolTipPosX = 0.79
,ToolTipPosY = 0.165
,ToolTipPos = FRAMEPOINT_BOTTOMRIGHT
-- Box
--Happens once at creation, decides how TasHeroLearnEx is posed
,PosBox = function(frame)
--BlzFrameSetAbsPoint(frame, FRAMEPOINT_BOTTOMLEFT, 0.195, 0.135)
BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("SimpleInfoPanelUnitDetail", 0), FRAMEPOINT_TOPLEFT, -0.1, 0.02)
end
-- ShowButton
,OpenButtonTexture = "ReplaceableTextures\\CommandButtons\\BTNSkillz.blp"
--Happens once at creation, decides where Open Button is posed
,PosOpen = function(frame)
--BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOPRIGHT, 0.6, 0.15)
--BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("SimpleInfoPanelUnitDetail", 0), FRAMEPOINT_TOPRIGHT, 0.1, 0.015)
BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("SimpleInfoPanelUnitDetail", 0), FRAMEPOINT_TOPLEFT, 0.0, -0.01)
end
-- ParentFunc who you want as parent, this runs at InitBlizzard, if you need more control you need to modify the part that calls local function Init()
,ParentFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
-- how many LearnPoints an unit has to spent
,GetLearnPoints = function(unit)
return GetHeroSkillPoints(unit)
--return GetPlayerState(GetOwningPlayer(unit), PLAYER_STATE_RESOURCE_GOLD)//100
end
-- pay costs function is called inside TasHeroLearnEx.CustomUnitLearnAbility
,Costs = function(unit, abiCode)
-- can't pay return false
if TasHeroLearnEx.GetLearnPoints(unit) <= 0 then return false end
--SetPlayerState(GetOwningPlayer(unit), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(unit), PLAYER_STATE_RESOURCE_GOLD) - 100)
UnitModifySkillPoints(unit, -1)
return true
end
-- System stuff below
...
}