Jump to content

How to make armor that doesn't break at 0%?


Recommended Posts

You'd have to adjust a function or 2 in the armor component

put this in modmain.lua: (untested)

NOTE replace where ever it says "YOUR_PREFAB" with your prefab name (2 occurrences)

AddComponentPostInit("armor", function(self)
	local oldTakeDamage = self.TakeDamage
	local oldGetAbsorption = self.GetAbsorption
	
	function self:TakeDamage(damage_amount)
		if (self.inst.prefab ~= "YOUR_PREFAB" or (self.condition - damage_amount) > 0) then
			return oldTakeDamage(self, damage_amount)
		else
			if (self.condition - damage_amount) <= 0 then
				self.condition = 0	
				
				if self.onfinished ~= nil then
					self.onfinished()
				end
			end
		end
	end
	
	function self:GetAbsorption(attacker, weapon)
		return (self.inst.prefab ~= "YOUR_PREFAB" or self.condition > 0) and oldGetAbsorption(self, attacker, weapon) or nil
	end
end)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...