[solved] resistances: what does `decrease` mean?
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
[solved] resistances: what does `decrease` mean?
When defining resistances, a `percentage` and/or a `decrease` can be defined. The `percentage` is fairly self-explanatory (0 = normal, >0 = resist, <0 = susceptible), but I have no clue what the `decrease` means - does it decrease the resistance (if so, why not just decrease the percentage)?
Last edited by aubergine18 on Tue Oct 04, 2016 2:11 pm, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: resistances: what does `decrease` mean?
Percentage = based on the damage amountaubergine18 wrote:When defining resistances, a `percentage` and/or a `decrease` can be defined. The `percentage` is fairly self-explanatory (0 = normal, >0 = resist, <0 = susceptible), but I have no clue what the `decrease` means - does it decrease the resistance (if so, why not just decrease the percentage)?
Decrease = fixed amount
I guess.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: resistances: what does `decrease` mean?
But both of them can be used together - why would you increase the percentage (percentage > 0) and at the same time decrease the value (decrease > 0)?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: resistances: what does `decrease` mean?
For things like cars: if the car moves at a low speed and hits something it takes no damage (fixed value resistance) but at higher speeds it still has a % resistance.aubergine18 wrote:But both of them can be used together - why would you increase the percentage (percentage > 0) and at the same time decrease the value (decrease > 0)?
If you want to get ahold of me I'm almost always on Discord.
Re: resistances: what does `decrease` mean?
So we now know "decrease" is calculated before "percentage":
taken damage = math.max(0, (damage - resistance.decrease) * (resistance.percentage * 0.01))
More generically:
decrease = the lower the damage amount, the higher efficiency the resistance will be
e.g. decrease = 50: if damage < 50, 100% of it will be reduced; if damage = 100, it will be reduced by 50%.
percentage = the higher the damage amount, the higher efficiency the resistance will be
e.g. percentage = 50: if damage = 50, 25 damage will be reduced; if damage = 100, 50 damage will be reduced.
Edit: corrected the formula.
taken damage = math.max(0, (damage - resistance.decrease) * (resistance.percentage * 0.01))
More generically:
decrease = the lower the damage amount, the higher efficiency the resistance will be
e.g. decrease = 50: if damage < 50, 100% of it will be reduced; if damage = 100, it will be reduced by 50%.
percentage = the higher the damage amount, the higher efficiency the resistance will be
e.g. percentage = 50: if damage = 50, 25 damage will be reduced; if damage = 100, 50 damage will be reduced.
Edit: corrected the formula.