## problem in stat_modify_dammage

If you are interested in helping with tiles, vaults, patches or documentation, this is the place for that.

Dungeon Dilettante

Posts: 2

Joined: Monday, 19th December 2016, 05:06

### problem in stat_modify_dammage

first, this is fight simulation in 0.18.1,
human, all skill = 27, unarmed attack, no armour, dex = 30, vs ogre

str 8 vs str 12

str8-12
힘8-12.png (57.19 KiB) Viewed 830 times

there is only little dammage difference, huh?
and that difference is just because I forgot about off hand punch.

in 0.18.1, there is no damage bonus between str8 and str12 (execept aux and ER)

[attack.cc file in dcss 0.18.1]

int attack::player_stat_modify_damage(int damage)
{
int dammod = 39;

if (you.strength() > 11)
dammod += (random2(you.strength() - 11) * 2);
else if (you.strength() < 9)
dammod -= (random2(9 - you.strength()) * 3);

damage *= dammod;
damage /= 39;

return damage;
}

as you know, random2(max) equals to 1d(max) -1

let's calculate, you will gain this result

~ str7, dammod = 42 - (1d( 9 - str )) *3
str8~12 , dammod =39
str13~, dammod = 37 + (1d( str - 11 )) *2

1. I can't understand why str 9/11 is not assigned
2. when your str is 8/12, dammod is still 39. because 1d(1) - 1 = 0
3. this code is sucks

this part was changed in 7 may

https://github.com/crawl/crawl/commit/6c060d3771dd4915b9da9e6cd1bb37106e1dba0d

Tightened the 0 bonus/penalty range for STR.
STR = 9,10,11 would not pass either if statement, providing no appreciable benefit to damage scaling for going from 9 to 11 strength. This was a classic inclusive/exclusive range if statement bug.

but there is still problem

int attack::player_stat_modify_damage(int damage)
{
int dammod = 39;

if (you.strength() > 10)
dammod += (random2(you.strength() - 10) * 2);
else if (you.strength() < 10)
dammod -= (random2(10 - you.strength()) * 3);

damage *= dammod;
damage /= 39;

return damage;
}

when calculated,

str = 14, dammod = 39 + (1d(3) - 1)*2 = 37 + (1d4)*2 avg 42
str = 13, dammod = 39 + (1d(3) - 1)*2 = 37 + (1d3)*2 avg 41
str = 12, dammod = 39 + (1d(2) - 1)*2 = 37 + (1d2)*2 avg 40
str = 11, dammod = 39 + (1d(1) - 1)*2 = 39
str = 10, dammod = 39
str = 9, dammod = 39 - (1d(1) - 1)*3 = 39
str = 8, dammod = 39 - (1d(2) - 1)*3 = 42 - (1d2)*3 avg 37.5
str = 7, dammod = 39 - (1d(2) - 1)*3 = 42 - (1d3)*3 avg 36

ok, now 8 and 12 is fine, but it seems he dosen't have accomplished purpose enough

the thing confusing me more is

[melee_attack.cc in 0.18.1]

int melee_attack::player_aux_stat_modify_damage(int damage)
{
int dammod = 20;

if (you.strength() > 10)
dammod += random2(you.strength() - 9);
else if (you.strength() < 10)
dammod -= random2(11 - you.strength());

damage *= dammod;
damage /= 20;

return damage;
}

this is stat modifier for auxiliary attack, and it totally works!

so, main dammage calculation is broken while additional dammage calculation is correct.

???????????????????

For this message the author Roleplayer has received thanks: 2
Brannock, neil

Dungeon Master

Posts: 202

Joined: Thursday, 5th December 2013, 05:01

### Re: problem in stat_modify_dammage

Fixed, thank you for finding this.

Dungeon Dilettante

Posts: 2

Joined: Monday, 19th December 2016, 05:06

### Re: problem in stat_modify_dammage

How amazing
neglect horrible error for more than 1 year, (which is easily found by anyone trying to read the code)
tried to fix but failed,
and now, can't write just 2 number correctly

two questions,

1. Did you considered that this will be little buff for strength which is most powerful stat already?

heightening dammod from 39 to 42~46 will adjust this,
but I think buffing dex would be better

2. Do you have plan for fixing bugs and improving codes?

it is obvious that this is not the only error in dcss.
developers may have more time to do this if they stop meaningless things like killing 2 species and reviving ogre mage

Ziggurat Zagger

Posts: 4152

Joined: Friday, 8th May 2015, 17:51

### Re: problem in stat_modify_dammage

Yes, you should stop sending them checks probably... Maybe even fire them. What a horrible bug, Str 10 was equivalent of Str 11 for damage purposes, that's completely broken...
Underestimated: cleaving, Deep Elf, Formicid, Vehumet, EV
Overestimated: AC, GDS
Twin account of Sandman25

For this message the author VeryAngryFelid has received thanks: 2
Sprucery, ThreeInvisibleDucks

Posts: 536

Joined: Friday, 1st April 2016, 18:15

### Re: problem in stat_modify_dammage

Bughunting, bugfixing, nitty-gritty individual additions, and long-term planning and discussion - all of these are important tasks for a developer.

*nods wisely*
twelwe wrote:It's like Blink, but you end up drowning.

Barkeep

Posts: 1785

Joined: Saturday, 29th June 2013, 16:52

### Re: problem in stat_modify_dammage

Thank you, Roleplayer, but in the future, please use Mantis for bug reports, and if you're interested in influencing the development of Crawl, please try to be polite. Thread locked.