## Problem with damage calculation

Having trouble with the game? Report issues and get help here. Read this first!

Moderators: Forum Moderators, Developers

Forum rules
Before reporting issues in this section, you must read the following topic:
Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

### Problem with damage calculation

Hello,

in my UMC-project it can happen that a lot/some of damage multipliers are involved in an attack.
It seems that if a certain number of multipliers is reached the calculation flattens the damage down to 1.

screenshots to describe the problem

in the damage calculation, damage is set to 1:
Messed up Noluck damage calculations.png (161.45 KiB) Viewed 3250 times

now the question:
if it is the sheer number of the multipliers, how many can wesnoth-engine handle?

most of the multipliers are simple damage-weapon-specials

is there a limit of weapon-special damage multipliers allowed by the engine?
The best bet is your own, good Taste.

Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm

### Re: Problem with damage calculation

All abilities with a multiply effect have an unintentional limit of about 4 multiply/divide operations. As far as I can tell, damage multipliers, defense multipliers, and the time of day count separately here. The exact number depends on the starting value, the size of the multipliers and whether multiply and divide operations are used or only one type. In the case you posted, the limit turned out to be 3 because of the high base damage.

What you're seeing is the code running into integer limits as everything is converted to an integer with a couple of places of precision, presumably for speed or an attempt to avoid accumulated rounding errors. The value then wraps around the integer limit and becomes negative and then the game converts that to 1 as it's the minimum damage.

Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

### Re: Problem with damage calculation

thx for the explanation.
The best bet is your own, good Taste.

Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm

### Re: Problem with damage calculation

For what it's worth, the highest base damage that will permit 4 multipliers is around 42 (and most would have to be less than 1), while the highest with 3 is about 4290.

Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

### Re: Problem with damage calculation

ok, so i stick with 3 then
The best bet is your own, good Taste.

Hex
Posts: 161
Joined: June 15th, 2010, 6:08 am

### Re: Problem with damage calculation

I don't understand what your saying, but I do know that 6 factors with bless as one causes this, and 5 do not, so I don't get why you are talking about 3 verses 4 multipliers since I see the difference happening between 5 and 6.

Anyway, is there any way this limitation might be fixed at some point?

Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

### Re: Problem with damage calculation

Alarantalara wrote:As far as I can tell, damage multipliers, defense multipliers, and the time of day count separately here.
and leadership is (luckily) also seperate.

so what is left in this example are 4 damage multipliers:

1) focus
2) blessing

and 4 of them screw the system.

that means simply for the future, if 3 damage multipliers are alowed, that i must restrict myself to just 1 damage-influencing ability per unit. in SXRPG. as long i want to maintain the "no-luck"-option.

since, 1 per units makes 2, plus the factor from no-luck makes 3.
so three factors will always be involved.

however, all in all no big deal, once you know it, you can avoid it.
that was handled in the recent SXRPG release.

Hex wrote: Anyway, is there any way this limitation might be fixed at some point?
im afraid i cannot wait that long, so i had to find a workaround earlier.
but yes, raising this limit would be fine for me too
The best bet is your own, good Taste.

Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm

### Re: Problem with damage calculation

Mabuse wrote:
Hex wrote: Anyway, is there any way this limitation might be fixed at some point?
im afraid i cannot wait that long, so i had to find a workaround earlier.
but yes, raising this limit would be fine for me too :)
Yes, it's now gone in the future 1.11.

MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

### Re: Problem with damage calculation

Is it relatively easy to add it to a 1.10.X release?

Otherwise thanks a lot for shedding some light.

Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm