Jump to content

Atrium Stalker summon throttle


Recommended Posts

A person asked if it were possible to edit the atrium stalker's summon periodic timer since it's all in a closed variable system.

The answer is yes, because the timer object itself is not in a closed variable system.

Perhaps someone could make use of this elsewhere for another similar situation without wanting to use the debug library and/or upvalues.

 

This code snippet changes the effects from 'local MINION_SPAWN_PERIOD = 0.75' to a custom value, in this case 5.0.

AddPrefabPostInit(
    "stalker_atrium",
    function(prefab)
        if not GLOBAL.TheWorld.ismastersim
        then
            return
        end
        local metatable = GLOBAL.getmetatable(prefab) or {}
        local metatable_newindex_old = metatable.__newindex
        metatable.__newindex = function(t, k, v)
            if k == "miniontask"
            then
                local callback_old = v.fn
                v:Cancel()
                v = prefab:DoPeriodicTask(5.0, callback_old, 0)
            end
            if metatable_newindex_old ~= nil
            then
                metatable_newindex_old(t, k, v)
            else
                GLOBAL.rawset(t, k, v)
            end
        end
        GLOBAL.setmetatable(prefab, metatable)
    end
)

 

Edited by CarlZalph
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...