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
Avatar
(Poster)29 days 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)

20 319