# Damage Scaling on Lower Sanity

## Recommended Posts

I was wondering if there was a way to scale damage higher the lower sanity gets. Is an incremental scaling based off the character losing sanity is something that would be possible of would I have to do it based off it they hit X amount?

##### Share on other sites

Damage based on sanity should be possible. @SuperDavid did something similar if i'm not wrong, but i'm not sure.

##### Share on other sites

I only know how to raise the damage at a set number like this,

Spoiler
```
inst:ListenForEvent("sanitydelta", function(inst, data)
if inst.components.sanity.current >= 30 then
inst.components.combat.damagemultiplier = 1.5
elseif inst.components.sanity.current <= 30 then
inst.components.combat.damagemultiplier = 2
end
end)```

I don't know how to scale the damage multiplier with max sanity, unfortunately...

##### Share on other sites

8 minutes ago, SuperDavid said:

I only know how to raise the damage at a set number like this,

I don't know how to scale the damage multiplier with max sanity, unfortunately...

Maths.

```inst:ListenForEvent(
"sanitydelta",
function(inst, data)
inst.components.combat.damagemultiplier = (1.0-inst.components.sanity:GetPercent())*4.0+1.0
end
)
```

At zero sanity, multiplier is 5.0.

At maximum sanity, multiplier is 1.0.

Linear scaling in between.

##### Share on other sites

20 hours ago, Lumina said:

Damage based on sanity should be possible. @SuperDavid did something similar if i'm not wrong, but i'm not sure.

Fortunately SuperDavid was able to help me with a few of my issues that I had with the mod prior; this was just something I was seeing if it was possible.

14 hours ago, CarlZalph said:

Maths.

```
inst:ListenForEvent(
"sanitydelta",
function(inst, data)
inst.components.combat.damagemultiplier = (1.0-inst.components.sanity:GetPercent())*4.0+1.0
end
)
```

At zero sanity, multiplier is 5.0.

At maximum sanity, multiplier is 1.0.

Linear scaling in between.

inst:ListenForEvent(
"sanitydelta",
function(inst, data)
inst.components.combat.damagemultiplier = (1.0-inst.components.sanity:GetPercent())*1.0+1.0
end
)

That should scale the damage to a multiplier of 2.0 at zero sanity right?

Edited by MemphisMyst
##### Share on other sites

(1,0 - 0.0) *1.0 + 1.0 = 2.0 so yes

##### Share on other sites

Thanks; I just wanted to make sure I understood the line. Thanks to everyone whom helped me with the character!

##### Share on other sites

2 hours ago, MemphisMyst said:

Fortunately SuperDavid was able to help me with a few of my issues that I had with the mod prior; this was just something I was seeing if it was possible.

inst:ListenForEvent(
"sanitydelta",
function(inst, data)
inst.components.combat.damagemultiplier = (1.0-inst.components.sanity:GetPercent())*1.0+1.0
end
)

That should scale the damage to a multiplier of 2.0 at zero sanity right?

If that's all you're wanting to scale it by then you can simplify the expression down and shorten calculations via:

2.0-inst.components.sanity:GetPercent()