How does the talent tree work?

I know the talent is linked to the main ability via a "LinkedSpecialBonus" but how exactly does it work? Can anyone give a very simple datadriven or lua example on how an ability interacts with a talent? All I want to see is if an ability and its talent can access each other in their respective lua files (so you can get the special values of each other).

Comments

  • edited December 2016 Posts: 858

    It's done in c++, the linkage is just for tooltip updating

    u can easily do in lua caster:GetAbility(talentname):GetLevel() > 0

    MAKE CUSTOM GAMES GREAT AGAIN

    Finished-
    kv checker - https://arhowk.github.io
    panorama video series - https://moddota.com/forums/discussion/2021/inclusive-panorama-tutorial-quest-box

    My pet project This Cursed World/Crestfallen (name pending)
    https://moddota.com/forums/discussion/986/this-cursed-world-rpg#latest

  • Posts: 101

    Thanks! You are smart.

  • ...or with caster:HasModifier(talentmodifier), depends what your talent does...

  • edited December 2016 Posts: 292
    function CDOTA_BaseNPC:HasTalent(talentName)
        if self:HasAbility(talentName) then
            if self:FindAbilityByName(talentName):GetLevel() > 0 then return true end
        end
        return false
    end
    
    function CDOTA_BaseNPC:FindTalentValue(talentName)
        if self:HasAbility(talentName) then
            return self:FindAbilityByName(talentName):GetSpecialValueFor("value")
        end
        return nil
    end
    

    this is what i use to play around with talents, i also have

    function CDOTABaseAbility:GetTalentSpecialValueFor(value)
        local base = self:GetSpecialValueFor(value)
        local talentName
        local kv = self: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 = self:GetCaster():FindAbilityByName(talentName)
            if talent and talent:GetLevel() > 0 then base = base + talent:GetSpecialValueFor("value") end
        end
        return base
    end
    

    but for that one you need to import a table that has all the npc_abilities and npc_abilities_custom values

  • DunDun
    edited December 2016 Posts: 123
    for i=0, 17 do
        local abil = hero:GetAbilityByIndex(i)
        if abil and string.match(abil:GetName(),"special_bonus") then
            -- do all the dirty stuffs you want to do to talent ability
        end
    end
    
  • edited April 14 Posts: 2

    So, I have a custom Abaddon shield that returns damage based on how much damage it's absorbed. What I'm trying to do is change the value it returns once abaddon chooses the talent for it. Pretty much the return damage is supposed to increase by 250% when you choose the talent. However, choosing the talent doesn't do anything. I'm not sure if there's something wrong with my code. Can I get any tips?

    My guess is that you can't test the conditions because they aren't the same type of values?

    if caster:HasAbility("special_bonus_unique_abaddon") ~= nil then
        if caster:GetAbility("special_bonus_unique_abaddon"):GetLevel() > 0 then
            ability.reflector = 2.5
        else
            ability.reflector = 1
        end
    else
        ability.reflector = 1
    end
    
  • Posts: 4

    If there's something wrong in my code, I usually print them to know where it goes wrong.

    If I were you, I'll try this:

    ability.reflector = 1
    local ability = caster:FindAbilityByName("special_bonus_unique_abaddon")
    if ability then
        print("ability found, level:",ability:GetLevel()
        if ability:GetLevel()>0 then
            ability.reflector = 2.5
        end
    else
        print("ability not found")
    end
    

    Then, you'll get insight about:
    - Whether the code is executed in the game (Lua is scripting language)
    - Whether the caster has that specific talent
    - Check if the talent does not leveled up even if you pick it.

    Hope this helps.