Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

make some enchantments work better with percentage

Open GuardianDll opened this issue 1 year ago • 2 comments

Summary

None

Purpose of change

While making test suite for enchantment, i found a pretty interesting issue: applying enchantment, that gives you +4 BONUS_DODGE (default dodge amount is 1), and then gives -50% to your bonus dodge result not in 2.5 (rounds down to 2) dodges, but 4. It happens because some enchantments (specifically STR, INT, DEX, PER, BONUS_DODGE and BONUS_BLOCK) use multiplier on the base stat. What does it mean is that if we have add +4, multiply -0.5, our formula would be (1 * 0.5) + 4. While it is a valid approach, it means player would be penalized much less from negative mutations, if they will try to use negative multiplier

Describe the solution

Change the code, so formula would be (1 + 4) * 0.5 - it *will* cause positive multipliers give more benefit, but also make negative multipliers actually meaningful punishment

Describe alternatives you've considered

Not doing it

Testing

Compiled the game, spawned different stat increasing mutations, didn't spot obvious issues

GuardianDll avatar Mar 24 '24 16:03 GuardianDll

This is explained in the docs, yet because they're too long already I guess it's being lost in transit (it's at the values identifier from the enchantments section)

For the topic: I don't think this is the correct approach. This will just do a 180 in how add and multiply are handled, which will be a problem in the future in case someone wants it the other way around. A better way would be to make them respect the order in which they're added, and/or allow support for having multiple value of the same type respect the order in which they're used (which is not working as it just applies the first value type on the list):

        "values": [ 
          { "value": "DEXTERITY", "add": 2, "multiply": -0.5 },
        ] 
vs
        "values": [ 
          { "value": "DEXTERITY", "multiply": -0.5, "add": 2 },
        ] 
vs
        "values": [ 
          { "value": "DEXTERITY", "add": 2 },
          { "value": "DEXTERITY", "multiply": -0.5 },
        ] 

RedMisao avatar Mar 24 '24 17:03 RedMisao

> A better way would be to make them respect the order in which they're added It is not possible since enchantments are stored as sum of all adds and multiply changing it is much higher level task than i can afford

GuardianDll avatar Mar 24 '24 18:03 GuardianDll