How to properly utilize ApplyDataDrivenModifier

Hello all,

For a mod that im helping with I need to give the caster (and eventually targets) a buff that increases their armor by 12 percent of whatever armor the caster has. I thought this might involve editing the AbilitySpecial values, but im pretty sure that you cant do that. However it seems like you can edit it through ApplyDataDrivenModifier() in lua.

Here is the lua code

function ShatterApply( event )
    caster = event.caster
    ability = event.ability

    armor = caster:GetPhysicalArmorValue() * 0.12

    ability:ApplyDataDrivenModifier(caster, caster, "modifier_taric_shatter_armor_percentage", {armor_percentage = armor})
end

and here the relevant kv code

"AbilitySpecial"
        {
            "01"
            {
                "var_type"              "FIELD_INTEGER"
                "armor_percentage"      "0"
            }
        }
"OnSpellStart"
        {
            "RunScript"
            {
                "ScriptFile"    "heroes/hero_taric/taric_shatter.lua"
                "Function"      "ShatterApply"
            }
"Modifiers"
        {
            "modifier_taric_shatter_armor_percentage"
            {
                "IsBuff"        "1"
                "Properties"
                {
                    "MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS" "%armor_percentage"
                }
            }

For testing instead of using whatever the lua armor variable was I changed it to a big number. Even so the issue im having is that the hModifierTable arg in ApplyDataDrivenModifier() does not seem to affect anything. The bonus armor just remains whatever the kv AbilitySpecial value is. I cant find many examples of editing a modifier like this through a lua function so im not sure if I am doing it correctly.

If not then how would I go about applying 12 percent of a casters armor onto a target or caster? (there is no ApplyBonusArmorAmount().

Comments

  • Posts: 1,670

    I don't think you can do that this way, you'll have to use Lua abilities/modifiers for this, or stack counters for each point of armor you want to remove.

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Posts: 4

    Stacking counters might be what il have to do then. Thank you for the help. What exactly is the purpose of the modifierArgs handle then?

  • Posts: 1,670

    It's useful to set the duration dynamically, you can do { duration = stacks*multiplier } for example. The other version of modifier-applying, AddNewModifier, has more options you can pass to it

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||