Old Copycat swap speed, mod try fail...
Avatar

I am trying to make an swap speed mod for copycat, but i wanted to remove the "new swap speed on auto reload" to not being OP;
problem is i coded in normal BLT in the old days, i tried to make some codes, didnt work, the tried to chat GPT for help, didnt work.
could somone help/ make this mod?

i was hopping i at least made an mod to make the old swap speed always on, the try to work upwards in removing the new swap...
but could not do nothing

Info
Replies
Avatar

Skills.lua

--[[
Old Copycat Swap Speed (Robusto)
Autor: ChatGPT
Versão: robust-v1
- Define o upgrade de +320% (3.2x).
- Injeta dinamicamente o upgrade na specialization MRWI (procura por pistas).
- Garante que o auto-reload não receba bonus de swap speed.
--]]

-- 1) Hook em UpgradesTweakData para definir valores e a definition do upgrade
Hooks:PostHook(UpgradesTweakData, "init", "OCSS_DefineUpgrades", function(self, tweak_data)
-- auto reload: tempo padrão
local auto_reload_swap_time = 3
self.values.weapon.primary_reload_swap_secondary = { auto_reload_swap_time }
self.values.weapon.secondary_reload_swap_primary = { auto_reload_swap_time }

-- garantir neutralização em possíveis chaves antigas
self.values.weapon.mrwi_swap_speed_multiplier = { 1 }
self.values.player.mrwi_swap_speed_multiplier = { 1 }

-- valor do novo bônus (definido aqui, mas será aplicado só quando a skill tiver o upgrade)
self.values.weapon.mrwi_passive_swap_speed_multiplier = { 3.2 }

-- definition que será referenciada pela skill
self.definitions.mrwi_passive_swap_speed = {
    name_id = "menu_mrwi_passive_swap_speed",
    category = "feature",
    upgrade = {
        value = 1,
        upgrade = "mrwi_passive_swap_speed_multiplier",
        category = "weapon"
    }
}

end)

-- 2) Hook em SkillTreeTweakData:init para localizar a MRWI e inserir o upgrade na skill certa
Hooks:PostHook(SkillTreeTweakData, "init", "OCSS_InsertUpgradeToMRWI", function(self, tweak_data)
-- garantias
if not self or not self.specializations then
return
end

-- criterios de busca (tenta vários jeitos para robustez)
local candidates = {}
for idx, spec in ipairs(self.specializations) do
    -- safe checks
    local name_id = spec.name_id or ""
    local desc_id = spec.desc_id or ""
    -- 1) name_id óbvio (padrões conhecidos)
    if string.lower(name_id):find("mrwi") or string.lower(name_id):find("copy") or string.lower(desc_id):find("mrwi") then
        table.insert(candidates, {idx = idx, spec = spec, reason = "name_id/desc_id match"})
    else
        -- 2) checa se alguma das entradas da specialization contém pistas (upgrades com 'mrwi' ou 'copy')
        if spec[1] then
            for k, entry in ipairs(spec) do
                if type(entry) == "table" and entry.upgrades then
                    for _, upg in ipairs(entry.upgrades) do
                        local upgstr = tostring(upg)
                        if string.lower(upgstr):find("mrwi") or string.lower(upgstr):find("copy") then
                            table.insert(candidates, {idx = idx, spec = spec, reason = "upgrade name match"})
                            break
                        end
                    end
                end
                if #candidates > 0 then break end
            end
        end
    end
end

-- Se encontrou candidatos, injeta o upgrade na primeira correspondência plausível
if #candidates > 0 then
    local c = candidates[1]
    local spec = c.spec
    -- insere no lugar apropriado: se existir table spec.upgrades (skilltree_defs), adiciona lá
    if spec.upgrades and type(spec.upgrades) == "table" then
        -- evita duplicata
        local already = false
        for _, v in ipairs(spec.upgrades) do
            if v == "mrwi_passive_swap_speed" then already = true; break end
        end
        if not already then
            table.insert(spec.upgrades, "mrwi_passive_swap_speed")
        end
    else
        -- caso a formatação da specialization seja diferente, insere um novo bloco visível (cautelosamente)
        table.insert(spec, {
            cost = 0,
            icon_xy = {2,6},
            name_id = "menu_mrwi_passive_swap_speed",
            desc_id = "menu_mrwi_passive_swap_speed_desc",
            upgrades = { "mrwi_passive_swap_speed" }
        })
    end
    -- sucesso (opcional log)
    log("[OCSS] mrwi_passive_swap_speed injected into specialization index " .. tostring(c.idx) .. " (" .. tostring(c.reason) .. ")")
    return
end

-- fallback: se nada encontrado, tenta diretamente em skilltree_defs.mrwi (se existir)
if self.skilltree_defs and self.skilltree_defs.mrwi and type(self.skilltree_defs.mrwi.upgrades) == "table" then
    local already = false
    for _, v in ipairs(self.skilltree_defs.mrwi.upgrades) do
        if v == "mrwi_passive_swap_speed" then already = true; break end
    end
    if not already then
        table.insert(self.skilltree_defs.mrwi.upgrades, "mrwi_passive_swap_speed")
        log("[OCSS] mrwi_passive_swap_speed injected into skilltree_defs.mrwi.upgrades (fallback)")
        return
    end
end

-- se chegou aqui, não encontrou nada
Avatar
(Poster)1 day ago(Edited)

runtime.lua

--[[
Old Copycat Swap Speed (Runtime override)
Intercepta upgrade_value para garantir que o bônus +320% (3.2x)
só seja retornado quando a specialization ativa for a MRWI / Copycat.
Cobre várias chaves possíveis usadas por mods/jogo.
--]]

local function is_spec_mrwi(spec_id)
if not spec_id then return false end
local spec = tweak_data and tweak_data.skilltree and tweak_data.skilltree.specializations and tweak_data.skilltree.specializations[spec_id]
if not spec then return false end
local name_id = tostring(spec.name_id or ""):lower()
local desc_id = tostring(spec.desc_id or ""):lower()
if name_id:find("mrwi") or name_id:find("copy") or desc_id:find("mrwi") or desc_id:find("copy") then
return true
end

-- Também procura por pistas nas upgrades listadas (fallback)
for _, tier in ipairs(spec) do
    if type(tier) == "table" and tier.upgrades then
        for _, u in ipairs(tier.upgrades) do
            local uu = tostring(u):lower()
            if uu:find("mrwi") or uu:find("copy") then
                return true
            end
        end
    end
end

return false

end

-- Lista de chaves de upgrade que podem representar swap speed (cobre variações)
local SWAP_KEYS = {
["mrwi_passive_swap_speed_multiplier"] = true,
["mrwi_passive_swap_speed"] = true,
["mrwi_swap_speed_multiplier"] = true,
["passive_swap_speed_multiplier"] = true,
["passive_swap_speed"] = true,
["swap_speed_multiplier"] = true
}

Hooks:PreHook(PlayerManager, "upgrade_value", "OCSS_OverrideSwapUpgradeValue", function(self, category, upgrade, default)
-- Só nos interessam upgrades de arma (weapon)
if tostring(category) ~= "weapon" then
return
end

local upg = tostring(upgrade or ""):lower()

if not SWAP_KEYS[upg] then
    -- não é uma das chaves que queremos sobrescrever => segue normalmente
    return
end

-- checa se a specialization atual é a MRWI (Copycat)
local spec_id = nil
if self.current_specialization then
    -- managers.player:current_specialization ou self:current_specialization em diferentes versões
    local ok, res = pcall(function() return self:current_specialization() end)
    if ok then spec_id = res end
end
if not spec_id and managers.player and managers.player:current_specialization then
    local ok2, res2 = pcall(function() return managers.player:current_specialization() end)
    if ok2 then spec_id = res2 end
end

local is_mrwi = is_spec_mrwi(spec_id)

if is_mrwi then
    -- Força o valor 3.2 (320% = 3.2x)
    log("[OldCopycatSwapSpeed] Returning 3.2 for upgrade '" .. tostring(upgrade) .. "' because MRWI is active (spec_id=" .. tostring(spec_id) .. ")")
    return true, 3.2
else
    -- Caso contrário, retorna o default (padrão do jogo/mods)
    return true, default or 1
end

end)

Avatar

tree.lua
--[[
Old Copycat Swap Speed (SkillTree Hook)
Autor: ChatGPT
Versão: 1.0
Função:
Insere o upgrade "mrwi_passive_swap_speed" apenas na specialization MRWI (Copycat).
Não altera perks de outras árvores.
]]

Hooks:PostHook(SkillTreeTweakData, "init", "OldCopycatSwapSpeed_SkillTree", function(self, tweak_data)

if not self or not self.specializations then
    return
end

local mrwi_index = nil

-- Tenta localizar a specialization MRWI dinamicamente
for i, spec in ipairs(self.specializations) do
    local name_id = tostring(spec.name_id or ""):lower()
    local desc_id = tostring(spec.desc_id or ""):lower()

    if name_id:find("mrwi") or desc_id:find("mrwi") or name_id:find("copycat") or desc_id:find("copycat") then
        mrwi_index = i
        break
    end
end

-- Se não achar por nome, tenta pelo conteúdo (procura upgrades que contenham "mrwi")
if not mrwi_index then
    for i, spec in ipairs(self.specializations) do
        for _, tier in ipairs(spec) do
            if type(tier) == "table" and tier.upgrades then
                for _, u in ipairs(tier.upgrades) do
                    local ustr = tostring(u):lower()
                    if ustr:find("mrwi") or ustr:find("copycat") then
                        mrwi_index = i
                        break
                    end
                end
            end
            if mrwi_index then break end
        end
        if mrwi_index then break end
    end
end

-- Aplica o upgrade na MRWI
if mrwi_index then
    local spec = self.specializations[mrwi_index]
    local added = false

    -- Procura onde inserir (geralmente no deck final)
    for _, tier in ipairs(spec) do
        if type(tier) == "table" and tier.upgrades then
            local found = false
            for _, u in ipairs(tier.upgrades) do
                if u == "mrwi_passive_swap_speed" then
                    found = true
                    break
                end
            end
            if not found then
                table.insert(tier.upgrades, "mrwi_passive_swap_speed")
                added = true
                break
            end
        end
    end

    -- Se não encontrou nenhum tier, cria um novo
    if not added then
        table.insert(spec, {
            cost = 0,
            icon_xy = {2, 6},
            name_id = "menu_mrwi_passive_swap_speed",
            desc_id = "menu_mrwi_passive_swap_speed_desc",
            upgrades = {"mrwi_passive_swap_speed"}
        })
    end

    log("[OldCopycatSwapSpeed] Injected upgrade into MRWI specialization at index " .. tostring(mrwi_index))
else
    log("[OldCopycatSwapSpeed] WARNING: MRWI specialization not found. Upgrade not injected.")
end

end)

Avatar

MOD.TXT

{
"name": "Old Copycat Swap Speed",
"description": "Aplica o antigo bônus de swap speed (+320%) apenas à Copycat (MRWI). Remove o bônus de swap do auto reload.",
"author": "ChatGPT",
"version": "1.4",
"blt_version": 2,
"priority": 15,
"hooks": [
{
"hook_id": "lib/tweak_data/upgradestweakdata",
"script_path": "skills.lua"
},
{
"hook_id": "lib/tweak_data/skilltreetweakdata",
"script_path": "tree.lua"
},
{
"hook_id": "lib/managers/localizationmanager",
"script_path": "skilldescs.lua"
},
{
"hook_id": "lib/tweak_data/upgradestweakdata",
"script_path": "runtime.lua"
}
]
}

Avatar
  • All BLT mods are compatible with SuperBLT. If something broke, it is not likely to be caused by the change to SuperBLT. Your skills will carry over to SuperBLT just fine.

  • Don't use ChatGPT for code. It is a complete waste of time and energy and produces junk for any remotely complex task.

  • If you want to remove an upgrade, remove its definition id from the upgrades table in the perk deck's definition in skilltreetweakdata. If you want to add an upgrade, then insert its definition id into the upgrades table instead.

  • If you want to tweak the numbers of an upgrade (like to buff or nerf something), then chances are, you can just change the numbers for that upgrade in upgradestweakdata. There are only a few specific upgrades that place relevant variables outside of this file, and I'm pretty sure this is not one of them.

Avatar

I made one from Scratch too, using an Idea from the time that i've done an mod that added 20% health more on Grinder If you have the time i Will place It here, showing It , i can sendo tô you in another way, and i Will try again this night

Avatar

But basically what i did in the mod that i did yesterday It
I changed upgrades to 3.2 "weapons_passive...

It haves weapons_passive_swap speed 1 ( rougue uses It, and 2 that i dindnt find anything that used It.

It dindnt change rougue, and the Hook was the same used in a mod , that as i said on top, that added life in Grinder

I tried to add more skills, like the passives swaps, life, Dodge, armor, health. But none did work

Avatar

Mod.Txt

{
"name" : "Old Copycat Swap Speed ",
"description" : "faster swap.",
"author" : "Ash",
"version" : "1.0",
"blt_version" : 2,
"hooks": [
{
"hook_id": "lib/tweak_data/upgradestweakdata",
"script_path": "skills.lua"
},
{
"hook_id": "lib/tweak_data/skilltreetweakdata",
"script_path" : "tree.lua"
}
]
}

Read All Replies (8 replies)
20 292