[Warning: long post ahead.]
I'm still not exactly sure what the problem is... This line in xtra1.c
Code:
p_ptr->skill_thb += (50 * (((7 * get_skill(SKILL_ARCHERY)) + (3 * get_skill(SKILL_COMBAT))) / 10) / 10);
says that, for a hypothetical character with 20 Archery and 10 Combat, skill_thb should be +85 (assuming no floating-point bugs in Python3

). This is the base hit chance... Bonus effects are calculated by
Code:
bonus = (p_ptr->to_h + p_ptr->to_h_ranged + q_ptr->to_h + j_ptr->to_h);
chance = (p_ptr->skill_thb + (bonus * BTH_PLUS_ADJ));
Where BTH_PLUS_ADJ is defined as 3 elsewhere in defines.h. So, that hypothetical character, at Berserker/Running and with a stack of (+0, +0) ammo and a standard x2 short bow, should get maybe 85 + 12 * 3 =
+121 to hit.Now, test_hit_fire(), which tests whether you're going to hit, is invoked with the distance subtracted from the hit chance:
Code:
if (test_hit_fire(chance - cur_dis, m_ptr->ac, m_ptr->ml))...
Assuming a distance of 10 spaces, that's still
+111 to hit.And here is test_hit_fire():
Code:
/*
* Determine if the player "hits" a monster (normal combat).
* Note -- Always miss 5%, always hit 5%, otherwise random.
*/
bool_ test_hit_fire(int chance, int ac, int vis)
{
int k;
/* Percentile dice */
k = rand_int(100);
/* Hack -- Instant miss or hit */
if (k < 10) return (k < 5);
/* Never hit */
if (chance <= 0) return (FALSE);
/* Invisible monsters are harder to hit */
if (!vis) chance = (chance + 1) / 2;
/* Power competes against armor */
if (rand_int(chance + luck( -10, 10)) < (ac * 3 / 4)) return (FALSE);
/* Assume hit */
return (TRUE);
}
So 5% of the time we hit, 5% we miss. The other 90% of the time, hit chance is determined by
rand_int(
111) + luck(-10, 10) vs. ac * 3 / 4
luck() is this:
Code:
/*
* Return a luck number between a certain range
*/
int luck(int min, int max)
{
int luck = p_ptr->luck_cur;
int range = max - min;
if (luck < -30) luck = -30;
if (luck > 30) luck = 30;
luck += 30;
luck *= range;
luck /= 60;
return (luck + min);
}
So with a neutral luck rating of 0, we should get (30 * 20) / 60 - 10 = 0. Yay.
Now let's assume our foe is a young blue dragon, which should be hittable most of the time for a level 16-ish character, right? Young blue dragons have an AC of 50, so
rand_int(111) vs. 37
which means that I should hit 2/3 of the time on average, assuming the RNG isn't horribly biased. Let's see if that holds up.