Jump to content

Sanity penalty while fighting


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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...