## Problem with damage calculation

**Moderators:** Forum Moderators, Developers

**Forum rules**

Before reporting issues in this section, you

**must**read the following topic:

### 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:

now the question:

can i get more information about what causes this?

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?

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:

now the question:

can i get more information about what causes this?

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:**782**Joined:**April 23rd, 2010, 8:17 pm**Location:**Canada

### 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.

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.

- Alarantalara
- Art Contributor
**Posts:**782**Joined:**April 23rd, 2010, 8:17 pm**Location:**Canada

### 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.

### Re: Problem with damage calculation

ok, so i stick with 3 then

The best bet is your own, good Taste.

### 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?

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

### Re: Problem with damage calculation

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

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

1) focus

2) blessing

3) dreadful sight

4) no-luck CTH adjustment

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.

im afraid i cannot wait that long, so i had to find a workaround earlier.Hex wrote: Anyway, is there any way this limitation might be fixed at some point?

but yes, raising this limit would be fine for me too

The best bet is your own, good Taste.

- Alarantalara
- Art Contributor
**Posts:**782**Joined:**April 23rd, 2010, 8:17 pm**Location:**Canada

### Re: Problem with damage calculation

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

but yes, raising this limit would be fine for me too :)

### 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.

Otherwise thanks a lot for shedding some light.

- Alarantalara
- Art Contributor
**Posts:**782**Joined:**April 23rd, 2010, 8:17 pm**Location:**Canada

### Re: Problem with damage calculation

It's easily possible to add it to 1.10, but it almost certainly will not be done. It would cause that version of 1.10 to have out of sync errors with earlier versions whenever the limit is reached on the old client and stable versions are supposed to be compatible with each other.