Concept: alter or add to existing ability/modifier functions

edited September 2017 in General

this is just a concept, havent done any testing with it yet, but what do you guys think? could this be done?

                              --class, string, function
function OverwriteClassFunc( class, toOverwrite, newFunc )
  local func = class[toOverwrite]
  class[toOverwrite] = function(self, kv)
    func(self, kv)
    newFunc(self, kv)


  • edited September 2017 Posts: 858
  • Posts: 182

    so is there already some way to do this with class() like what was discussed here or is it not possible or..?

    the idea was to actually change the functions of an ability/modifier, not use them as a baseclass like in my link.

    e.g. take vengeful spirit stun and change its OnProjectileHit to something else, or add to it.

  • edited September 2017 Posts: 109

    It is possible, the third parameter of class() is for the base class:

    venge_stun = class({})
    function venge_stun:OnCreated(e) ... end
    function venge_stun:OnProjectileHit(e) ... end
    venge_stun_extended = class({}, {}, venge_stun)
    -- overwrites OnProjectileHit of base venge_stun
    function venge_stun_extended:OnProjectileHit(e)
      -- you can still call the baseclas member, with this you can add functionality
      venge_stun.OnCreated(self, e)
      -- or
      getbase(self).OnCreated(self, e)
      -- or should work to (not sure)
      self:__getbase__.OnCreated(self, e)

    I never used inheritance feature of class() for modifiers but theoretically it should work.

    give it a try tell me if it works.

    EDIT: just tried the method I described above. It doesn't seem to work. Maybe because of the way the engine calls lua ability functions.

    Github: Profile Steam: Profile