Banner
Pistol Concealment Boost Remastered
Thumbnail
Downloads546
Views1,806
Publish Date11 months ago
Last Updated10 months ago by
Version3.0
Members
Avatar

Replacing the code with this should catch all weapons categorized as pistols automatically
This should include custom pistols, but not tested
A system is included to force-add the Judge (and akimbo variant), which is not categorized as a pistol

local INCLUDE_JUDGE = true

local function try_insert(v, e)
	if not table.contains(v, e) then
		table.insert(v, e)
	end
end

Hooks:PostHook( WeaponFactoryTweakData, "_add_charms_to_all_weapons", "pc__add_charms_to_all_weapons", function(self, tweak_data)
	local force_include

	if not INCLUDE_JUDGE then
		force_include = {}
	else
		force_include = table.list_to_set({
			"judge",
		})

		for id, x_id in pairs(tweak_data.weapon_akimbo_mappings) do
			force_include[x_id] = force_include[id]
		end
	end

	for _, data in pairs(tweak_data.upgrades.definitions) do
		local weapon = tweak_data.weapon[data.weapon_id]
		local factory = self[data.factory_id]

		if force_include[data.weapon_id] or weapon and weapon.categories and table.contains(weapon.categories, "pistol") then
			if factory and factory.uses_parts then
				try_insert(factory.uses_parts, "wpn_fps_upg_bonus_concealment_p3")

				local factory_npc = self[data.factory_id .. "_npc"]
				if factory_npc and factory_npc.uses_parts then
					try_insert(factory_npc.uses_parts, "wpn_fps_upg_bonus_concealment_p3")
				end
			end
		end
	end
end )
Avatar

I really don't have much of a code experience since this is just a remaster of a existing old mod, so I actually dont have much idea about all of this complex coding, sorry. But I'll try it when i have time and maybe replace it too! Thanks.

Also if I'm not wrong judge is considered as a "wpn_fps_pis_judge". So you might actually not even need the code at the top.

Avatar

The system here cares about WeaponTweakData definitions, where the Judge is not categorized as a pistol

Avatar

@erushinj Oh, my bad. I didn't notice that

Avatar

Just had the time to try now, but I can say its amazing and easier because you can now add in almost every gun in the game with just changing some codes. Will replace the code with this in the next update.

59 817