Jingu mastery Datadriven

Who knows how to make Jingu Mastery Datadriven ability ?

Comments

  • its literally on spell library

  • edited February 2017 Posts: 96

    Not sure if this is in spell library yet since it's Monkey King ability and I didn't find it when searching in the library. Though, the ability should be very straight forward similar to this

    In KV file

    "jingu_mastery_datadriven"
    {
      // Set whatever variables you want
    
      "Modifiers"
      {
        // Passive of the ability
        "modifier_counter_manager"
        {
          // Set passive and whatever needed
          "OnAttackLanded"
          {
            "RunScript"
            {
              // Whatever path to your lua
              "Function"  "modify_counter"
            }
          }  
        }
    
        // Victim debuff modifier
        "modifier_victim_debuff"
        {
          // set whatever needed here
        }
    
        // Hitter modifier
        "modifier_caster_buff"
        {
          // Set passive and whatever needed
          "OnCreated"
          {
            "RunScript"
            {
              // Whatever path to your lua
              "Function"  "remove_victim_counter"
            }
          }
        }
      }
    }
    

    In lua file

    function modify_counter(keys)
        local caster = keys.caster
        local target = keys.target
        local ability = keys.ability
    
        -- Check if caster does not have buff active so counter wouldn't run while buff is active
        if not caster:HasModifier(....) then
          -- Initialize
          if not caster.jingu_targets then
            caster.jingu_targets = { }
          end
    
          -- Add modifier debuff modifier to target
          if not target:HasModifier(....) then
            ability:ApplyDataDrivenModifier(....)
            -- Add to table
            table.insert(caster.jingu_targets, target)
          else
            target:SetModifierStackCount(....) -- Add one more counter to target
            if target:GetModifierStackCount(....) then
              -- Add buff to caster
              ability:ApplyDataDrivenModifier(....)
              caster:SetModifierStackCount(....) -- Set how many time you can use the buff
          end
        end
      -- If unit has buff, then reduce the buff counter
      else
        caster:SetModifierStackCount(....) -- Reduce the counter by 1
        if caster:GetModifierStackCount(....) == 0 then
          caster:RemoveModifierByName(....) -- Remove buff
        end
      end
    end
    
    function remove_victim_counter(keys)
      local caster = keys.caster
      local ability = keys.ability
    
      if caster.jingu_targets then
        for _, target in pairs(caster.jingu_targets) do
          target:RemoveModifierByName(....)
        end
        -- Reset table
        caster.jingu_targets = nil
      end
    end
    

    It would be something along this line. I wrote this up very quickly and I didn't test the code but it should work after every values is put in and properly tested.

  • https://github.com/Pizzalol/SpellLibrary/pull/107/files

    hasnt gotten merged yet because spelllibrary gets updated like once every 3 months

  • Wow. thanks so much. <3