Ranged to-hit chance, and other things concerning archers

Anything that has spoilers in it should go in here

Moderator: Moderator

Post Reply
Message
Author
Lord Estraven
Uruivellas
Posts: 712
Joined: Tue Dec 13, 2005 12:35 am

Ranged to-hit chance, and other things concerning archers

#1 Post by Lord Estraven »

One of the things I've noticed with archery is that most archers can't hit the broad side of a barn!

At clevel 1, you can wield your short bow and arrows, go into the swamps, crank up to Berserker/Running, and start shooting at a green naga... And you will miss the naga every time, all the way down to point blank range. Even with a potion of Heroism, you will miss it about nine times out of ten.

The situation does improve at medium levels, when magical ammo becomes available and your archery skill is higher... The problem is getting there, which you basically cannot do with the short bow and unenchanted ammo. As I observed elsewhere, it's more effective to buy wands of Manathrust and pump Magic Device skill.

IMO this is pretty broken compared to Vanilla behavior, where low-level characters can usually hit low-level opponents with unenchanted ammo. Anyone concur?

Edit: it occurs to me that one could instead provide more reliable ways to get junk for forging ammo... That might be a tad unbalancing at higher levels though, because forged ammo can be very powerful.

Yottle
Reaper
Posts: 1735
Joined: Sun Jan 26, 2003 11:49 pm
Location: West Virginia

Re: Ranged to-hit chance, and other things concerning archer

#2 Post by Yottle »

Perhaps that is the reason that I never had the patience to play an archer. When I have tried I ended up playing as a low-grade melee warrior.

Lord Estraven
Uruivellas
Posts: 712
Joined: Tue Dec 13, 2005 12:35 am

Re: Ranged to-hit chance, and other things concerning archer

#3 Post by Lord Estraven »

[Warning: long post ahead.]

I'm still not exactly sure what the problem is... This line in xtra1.c

Code: Select all

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: Select all

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: Select all

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: Select all

/*
 * 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: Select all

/*
 * 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.

Lord Estraven
Uruivellas
Posts: 712
Joined: Tue Dec 13, 2005 12:35 am

Re: Ranged to-hit chance, and other things concerning archer

#4 Post by Lord Estraven »

So, I created a puny human archer with the amusing (random) name of Morewyn. Turns out for his +to-hit from Berserker/Running is +10, not +12, so we should have +115 to hit... Shouldn't change things much I think, I'll just shoot from 5 spaces give or take.

Okay. Debug mode on, Wizard mode on. Archery is now 22, combat 11, I'll adjust the distance to 10 paces again. Create, wield, and activate a Ring of Lightning so the dragon won't kill me if it breathes... Summon it, phase door around a little, and here we go...

Okay, 20 shots, 11 hits. Actually most of these were from more like 5 spaces, I wasn't being that careful. Still seems reasonable for a totally unscientific test with small sample size, though... (Especially considering that this character has -5 luck, which I didn't notice earlier.)

Oh wait, I think I see the issue here. Some low-level monsters (like green nagas) have high AC - the naga has 40. I recall that Vanilla recently had lots of AC ratings recalibrated, perhaps because some of them didn't make sense? Anyway between range penalties and lack of to-hit bonuses, I can see why archers have trouble hitting certain monsters.

I'll also note that enchanted bows are a big deal. Bow and ammo bonuses are stacked and then multiplied by the bow multiplier. Critical hits also matter, a "good hit" looks to do about double damage. Problem you can't do any of that stuff at low levels...

Hmm.

I would consider maybe adding p_ptr->to_d to the damage count after the multiplier. This should provide a needed damage boost at low levels without making archers overwhelmingly powerful at high levels... I think. I'll check it out.

Edit: Hmm. I'll note also that right now, nothing in the game affects to_d_ranged... Anyway, adding to_d is a little better, but still strikes me as too powerful at low levels (when you can hit anything anyway, to-hit is still an issue).

(Ideally it would be nice if armor worked more realistically, absorbing damage instead of decreasing hit chance. That might solve a lot of issues, but it would be a fundamental change to gameplay.)

Post Reply