Jump to content

Recommended Posts

Hi everyone, I'm new to modding and I'm making my first character here.

I'm almost done tweaking it's abilities and such, but I needed to add a penalty to balance it out. I wanted her to be afraid of fighting, so I want to know if it's possible to lose flat amounts of sanity (5/15/25 etc) for hitting or being hit by other creatures. And if not, how can I configure an aura similar to willow's that drains sanity when in combat instead? Thanks for your time!

It's really easy to do flat amounts when attacking or being attacked.

Put this in your character's master_postinit function, and change the -5 value to whatever you want.

inst:ListenForEvent("onattackother", function(inst, data)
	-- The data object you get contains different variables, like:
	-- target (entity), weapon (entity, if any), projectile (entity, if any), stimuli (I don't know)
	-- Change true to false, if you do not want the sanity badge to pulse and
	-- make a sound when you subtract the sanity.
	inst.components.sanity:DoDelta(-5, true)
end)

inst:ListenForEvent("attacked", function(inst, data)
	-- The data object you get contains different variables, like:
	-- attacker (entity), damage, weapon (entity), redirected (whether this was redirected damage)
	-- Change true to false, if you do not want the sanity badge to pulse and
	-- make a sound when you subtract the sanity.
	inst.components.sanity:DoDelta(-5, true)
end)

 

Otherwise, we can make a timed task, constantly removing small amounts of sanity. The task would then be started, or the gets the end-time refreshed, whenever you are attacked or get attacked.

Edited by Ultroman
On 8/9/2019 at 7:40 PM, Ultroman said:

It's really easy to do flat amounts when attacking or being attacked.

Put this in your character's master_postinit function, and change the -5 value to whatever you want.


inst:ListenForEvent("onattackother", function(inst, data)
	-- The data object you get contains different variables, like:
	-- target (entity), weapon (entity, if any), projectile (entity, if any), stimuli (I don't know)
	-- Change true to false, if you do not want the sanity badge to pulse and
	-- make a sound when you subtract the sanity.
	inst.components.sanity:DoDelta(-5, true)
end)

inst:ListenForEvent("attacked", function(inst, data)
	-- The data object you get contains different variables, like:
	-- attacker (entity), damage, weapon (entity), redirected (whether this was redirected damage)
	-- Change true to false, if you do not want the sanity badge to pulse and
	-- make a sound when you subtract the sanity.
	inst.components.sanity:DoDelta(-5, true)
end)

 

Otherwise, we can make a timed task, constantly removing small amounts of sanity. The task would then be started, or the gets the end-time refreshed, whenever you are attacked or get attacked.

Thank you, it worked perfectly <3

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...