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
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)
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)
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"
}
]
}
-
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.
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
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"
}
]
}
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 }
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