if Talents == nil then
Talents = {}
Talents.__index = Talents
end
function Talents:HasTalent(hero, talentName)
if hero:HasAbility(talentName) then
if hero:FindAbilityByName(talentName):GetLevel() > 0 then return true end
end
return false
end
function Talents:FindTalentValue(hero, talentName)
if hero:HasAbility(talentName) then
return hero:FindAbilityByName(talentName):GetSpecialValueFor("value")
end
return nil
end
function Talents:GetTalentSpecialValueFor(ability, value)
local base = ability:GetSpecialValueFor(value)
local talentName
local kv = ability:GetAbilityKeyValues()
for k,v in pairs(kv) do -- trawl through keyvalues
if k == "AbilitySpecial" then
for l,m in pairs(v) do
if m[value] then
talentName = m["LinkedSpecialBonus"]
end
end
end
end
if talentName then
local talent = ability:GetCaster():FindAbilityByName(talentName)
if talent and talent:GetLevel() > 0 then base = base + talent:GetSpecialValueFor("value") end
end
return base
end