[ SOLVED ] FS22 : how make mod for drastically reducing equipment wear

Your forum for all discussions around Modding.
Nelis
Posts: 8
Joined: Fri Jan 15, 2021 11:13 pm

[ SOLVED ] FS22 : how make mod for drastically reducing equipment wear

Post by Nelis »

hello everyone,

i would appreciate it if anyone can point me in the right direction for making a mod that will drastically reduce how fast equipment will get damaged. i know there is a mod for reducing the cost of maintaining my equipment but i want to actually reduce how fast a machine will wear. in my opinion, 20% damage on a tractor for just hauling a bunch of grass is insane to me.

i am not looking for a discussion about the subject, i just want to know how i can make a mod to achieve a massively reduced wear speed.

i thank you in advance.
Last edited by Nelis on Mon Jan 17, 2022 4:03 pm, edited 1 time in total.
Malidene
Posts: 1
Joined: Sun Nov 29, 2020 8:15 pm

Re: FS22 : how make mod for drastically reducing equipment wear

Post by Malidene »

ImprovedRepairCosts Mod by BigBlueHH

Code: Select all

--[[
	ImprovedRepairCosts.lua
	--- IN DEVELOPMENT ---
	version: 0.2.0.0
	date: 21/12/19
	author: BigBlueHH
]]


ImprovedRepairCosts = {}

-- 100% (default) = 1, 50% = 0.5, 0% = 0, 150% = 1.5
ImprovedRepairCosts.damageMultiplier = 0.25 -- damage over time
ImprovedRepairCosts.wearMultiplier = 0.25 -- wear over time
ImprovedRepairCosts.repairPriceMultiplier = 0.5 -- repair price
ImprovedRepairCosts.repaintPriceMultiplier = 0.1 -- repaint price

-- ###############################################################
-- if you do not know what you do, please do not change any values
-- ###############################################################
ImprovedRepairCosts.balanceMultiplier = 0.1

function ImprovedRepairCosts.prerequisitesPresent(specializations)
	return SpecializationUtil.hasSpecialization(Wearable, specializations)
end

function ImprovedRepairCosts.registerOverwrittenFunctions(vehicleType)
	SpecializationUtil.registerOverwrittenFunction(vehicleType, "getRepairPrice", ImprovedRepairCosts.getRepairPrice)
  SpecializationUtil.registerOverwrittenFunction(vehicleType, "getRepaintPrice", ImprovedRepairCosts.getRepaintPrice)
  SpecializationUtil.registerOverwrittenFunction(vehicleType, "updateDamageAmount", ImprovedRepairCosts.updateDamageAmount)
  SpecializationUtil.registerOverwrittenFunction(vehicleType, "updateWearAmount", ImprovedRepairCosts.updateWearAmount)
end

function ImprovedRepairCosts:getRepairPrice(sFunc)
	local defaultCosts = sFunc(self)
	local multiplier = 1
	local balanceMultiplier = ImprovedRepairCosts.balanceMultiplier
	if self.lifetime ~= nil and self.lifetime ~= 0 then
		local ageMultiplier = 0.3 * math.min(self.age*balanceMultiplier/self.lifetime, 1)
		local operatingTime = self.operatingTime / 3600000
		local operatingTimeMultiplier =  0.7 * math.min(operatingTime*balanceMultiplier / (self.lifetime*EconomyManager.LIFETIME_OPERATINGTIME_RATIO), 1)		
		multiplier = 1 + ageMultiplier + operatingTimeMultiplier
	end
	return defaultCosts * multiplier * ImprovedRepairCosts.repairPriceMultiplier
end

function ImprovedRepairCosts:getRepaintPrice(sFunc)
	local defaultCosts = sFunc(self)
  return defaultCosts * ImprovedRepairCosts.repaintPriceMultiplier
end

function ImprovedRepairCosts:updateDamageAmount(sFunc, dt)
  local amount = sFunc(self, dt)
	return amount * ImprovedRepairCosts.damageMultiplier
end

function ImprovedRepairCosts:updateWearAmount(sFunc, nd, dt)
  local amount = sFunc(self, nd, dt)
	return amount * ImprovedRepairCosts.wearMultiplier
end
Nelis
Posts: 8
Joined: Fri Jan 15, 2021 11:13 pm

Re: FS22 : how make mod for drastically reducing equipment wear

Post by Nelis »

thank you! i have found the mod and installed it. time to play around with the settings to get to where i like it.
Post Reply