[solved] resistances: what does `decrease` mean?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

[solved] resistances: what does `decrease` mean?

Post by aubergine18 »

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.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: resistances: what does `decrease` mean?

Post by Mooncat »

aubergine18 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)?
Percentage = based on the damage amount
Decrease = fixed amount
I guess. :P

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: resistances: what does `decrease` mean?

Post by aubergine18 »

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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13918
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: resistances: what does `decrease` mean?

Post by Rseding91 »

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)?
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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: resistances: what does `decrease` mean?

Post by Mooncat »

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

Post Reply

Return to “Modding help”