Issue491

Title Attack Hit chance over 100%
Priority bug Status resolved
Assigned To Henker Keywords
Linked issues Watchers Henker

Submitted on 2011-10-23 22h32 by Henker, last changed by matthiaskrgr.

Messages
Author: Henker Date: 2011-10-23   22h32
Problem:
With the current formula to compute the chance to hit a bot ("ATTACK"), values
over 100% are achieved.

Current formula: 60% + Dexterity * 1%

Solution:
The formula should decrease the hit chance considering the REMAINING miss chance
(=100%-hit chance), e.g. by x% of the remaining miss chance per dexterity point

Proposed formula: 100% - 40% * 0,97^Dexterity

Example values:
dex     old     new
0	60%	60%
5	66%	65%
10	71%	70%
15	75%	75%
20	78%	80%
25	81%	85%
30	84%	90%
35	86%	95%
40	88%	100%
45	90%	105%
50	91%	110%
55	93%	115%
60	94%	120%
65	94%	125%
70	95%	130%
75	96%	135%
80	97%	140%
85	97%	145%
90	97%	150%
95	98%	155%
100	98%	160%
Author: salimiles Date: 2011-10-24   05h52
Can you specify which file, and what line numbers this is calculated in?
Author: ahuillet Date: 2011-10-24   10h15
Does the issue actually happen in game (ie. chance to hit > 100% for real)?

Can you please propose a formula based on exp(x) and not 0.97^x?
Then all you have to do is implement it and submit it on RB. :)
Author: Henker Date: 2011-10-24   17h42
In the table of example values I mixed up the title for the second and third
column: correctly the middle column is the new value and the right column is the
old value.

@salimiles:
Sure, it is src/character.c, l. 274 (
update_secondary_stats_from_primary_stats() ), but I have Version 0.14.1. I am
not sure about whether the line has changed since then.

@ahuillet:
I looked into the source code for it and the only place to_hit was really used
is in src/bullet.c in the function DoMeleeDamage(). Every value over 100 has
exactly the same effect as the value 100. In other words: every dexterity point
over 40 is absolutely useless for the hit chance.

An adequate formula with exp(x) is
hit chance = 100% - 40% * exp(-0.03 * dexterity)

for source code (src/character.c):
l.274: Me.to_hit = 100 - 40 * exp(- (TOHIT_PERCENT_PER_DEX_POINT / 100) *
Me.Dexterity);
l.43: #define TOHIT_PERCENT_PER_DEX_POINT (3.0)

Maybe this is a silly question, but since I am new here, it is maybe ok to ask
silly questions: What is RB and how do I get the actually newest version to
implement it without version conflict? :)

And again some example values:
old:     the old formula
prop I:  the formula from my first post (with 0,97)
prop II: the formula from this post (with exp)
dex	prop I	prop II	old
0	60%	60%	60%
5	66%	66%	65%
10	71%	70%	70%
15	75%	74%	75%
20	78%	78%	80%
25	81%	81%	85%
30	84%	84%	90%
35	86%	86%	95%
40	88%	88%	100%
45	90%	90%	105%
50	91%	91%	110%
55	93%	92%	115%
60	94%	93%	120%
65	94%	94%	125%
70	95%	95%	130%
75	96%	96%	135%
80	97%	96%	140%
85	97%	97%	145%
90	97%	97%	150%
95	98%	98%	155%
100	98%	98%	160%
Author: ahuillet Date: 2011-10-24   18h01
Your formula looks good to me.

Now - you should grab the game from SVN http://www.freedroid.org/download/#c47
Then do your modifications, and create a diff with SVN diff, then upload it on
ReviewBoard (RB) http://www.freedroid.org/developer-area/contribute/#c56

As for your patch, the #define should be drapped, just hardcode -0.03.

It's OK to ask silly questions - I hope you have the answers above. If not, just
ask again.
Author: Henker Date: 2011-10-24   18h04
"Does the issue actually happen in game (ie. chance to hit > 100% for real)?"
Additionally to say, ingame the "chance to hit > 100%" can be seen in the
character screen - in my current game "ATTACK" is shown with 111%, because I
have dexterity 51 (at level 10 or 11) because of crafted items.
Author: Henker Date: 2011-10-24   18h29
The old formula used that #define - shall I delete it instead of reusing?
Author: ahuillet Date: 2011-10-24   18h33
Yes.
Discussions about patches should take place on ReviewBoard, by the way. We've
set it up for that - you'll find it's easier when you can easily show what part
of the code you're talking about.
Author: Henker Date: 2011-10-24   18h47
That definitely makes sense.

I uploaded the diff to the RB and added you as reviewer:
http://rb.freedroid.org/r/1541/

Thank you very much for all the help. Can I change the status of this bug to
"erledigt" or do I have to wait until the diff is accepted at the RB?
Author: ahuillet Date: 2011-10-24   18h56
A bug is fixed when the patch fixing it has been committed into SVN. So please
leave the ticket as it is for now. :)
Author: matthiaskrgr Date: 2011-10-24   22h18
Fix in r5063. Thanks!
History
Date User Action Args
2011-10-24 22:18:05matthiaskrgrsetstatus: open -> resolved
assignedto: Henker
messages: + msg1751
nosy: + Henker
2011-10-24 18:56:14ahuilletsetmessages: + msg1750
2011-10-24 18:47:42Henkersetmessages: + msg1749
2011-10-24 18:33:05ahuilletsetmessages: + msg1748
2011-10-24 18:29:40Henkersetmessages: + msg1747
2011-10-24 18:04:32Henkersetmessages: + msg1746
2011-10-24 18:01:51ahuilletsetmessages: + msg1744
2011-10-24 17:42:28Henkersetmessages: + msg1742
2011-10-24 10:15:33ahuilletsetmessages: + msg1737
2011-10-24 05:52:49salimilessetmessages: + msg1727
2011-10-23 22:32:40Henkercreate