Jump to content

Recommended Posts

modmain.lua

AddComponentPostInit("combat", function(self)
	local oldGetAttacked = self.GetAttacked
	function self:GetAttacked(attacker, damage, weapon, stimuli)												--25% sanity or lower				--40% chance to actually trigger
		if self.inst:HasTag("insanity_blocker") and self.inst.components.sanity and self.inst.components.sanity:GetPercentWithPenalty() <= (25/100) and math.random() < (40/100) then
			damage = 0.01	--use this if u want to still do the attacked animation
			--return false 	--use this if u want to skip the attacked animation
		end
		return oldGetAttacked(self, attacker, damage, weapon, stimuli)
	end
end)

When you make your equippable item, make it add the tag "insanity_blocker" when equipped, and remove the tag when unequipped.

the values 25 and 40 can be changed to anything to your liking. Read the comments for any other adjustments

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
×
  • Create New...