Sign in to follow this  
TragedyTurtle

How do I make an armor have 100% damage absorption against certain mobs?

Recommended Posts

How do I make an armor have 100% damage absorption against mobs with a special tag and have the armor have x damage absorption against all other mobs without that tag?

I've tried meddling with armorhit and onattack, but it didn't work out for me. xD

Share this post


Link to post
Share on other sites
Ultroman    735

Extend the GetAbsorption function of the armor's armor component. Make it check whether the attacker has your tag, and if so, return 1.0. Otherwise, return whatever value the original function would give. Put this at the bottom of the fn() for the armor prefab.

local oldGetAbsorption = inst.components.armor.GetAbsorption
inst.components.armor.GetAbsorption = function(self, attacker, weapon)
	if attacker:HasTag("mytag") then
		return 1.0
	end
	return oldGetAbsorption(self, attacker, weapon)
end

 

Share this post


Link to post
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
Sign in to follow this