Jump to content

Mod help: Do more damage the lower health you have?


Recommended Posts

Hello, I've come into a little trouble with a character mod I'm working on.

 

So basically what I want it to do is make the character do more damage the less health they have, up to 4x damage at their lowest possible. I've done some simple perks before this, but nothing complex like this, and I have no idea if this is something I can do easily. Does anyone know how to do this?

Link to comment
Share on other sites

I actually use the opposite of that for my character. Instead of gaining damage I lose it as I get weaker in health, you'd just have to tweak the formula to reverse it. What you want to do is listen for the health delta event and then set up a function to change the damage. I'd post an example but I'm on my laptop and don't have the files at the moment, but if you temporarily download my character you could go look at the poly.lua in the prefabs to see the way I set up the function. Just make sure you're looking at the health delta and not hunger delta. Or if you wait until I get home (could be a few hours), I could post a more straightforward set of code for you to use~

http://steamcommunity.com/sharedfiles/filedetails/?id=391057471

Edited by polygone
Link to comment
Share on other sites

Allright, well here's what you'd basically do to get it to work. It's set up to make the character's damage 1.5x while at no health, and scales back down to 1.0x while at full health. The multiplier is based off Wilson's strength, and the health is auto-scaled for whatever your character's max health is since I'm basically just getting the % health.

~~~~~

local function Healthy(inst)
inst.components.combat.damagemultiplier = 1.5-(0.5*(inst.components.health.currenthealth/inst.components.health.maxhealth))
end
 

^Add that function in your character.lua file, then put this in your postinit:
inst:ListenForEvent("healthdelta", Healthy)

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