To-hit/Criticalhit questions
To-hit/Criticalhit questions
While to-damage is very easy to understand (+5 does 5 more damage. That's it.) I've not found an explanation of to-hit. I searched RGRA w/ google groups, but I found several conflicting articles about what influences critical hits, and how. I really don't have much idea how much to-hit helps my hitting.. or my critical hits. Any of you skilled code-readers have any info?
Version 3.12
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z
Re: To-hit/Criticalhit questions
Sure thing, I'll get back to you later.
Critical hits are mainly a function of weapon weight.
Critical hits are mainly a function of weapon weight.
By appreciation, we make excellence in others our own property. (Voltaire)
Re: To-hit/Criticalhit questions
This is specific to MAngband 0.7.2a, and may be different for some variants. It should be 100% accurate for vanilla MAngband 0.7.2 unless Crimson changed it since he released the source. This is especially invalid for OAngband or any other combat-altered variant! You'll need basic algebra skills to figure this sorta-spoiler out... that having been said, on to the document.
(this information can be found by a search for to_h in cmd1.c and cmd2.c)
Melee Weapon To-Hit:
Variable 'bonus' = player to-hit + weapon to-hit.
Variable 'chance' = player fighting skill + (bonus * 3)
(3 is the base to-hit addition. The game defines this as BTH_PLUS_ADJ in defines.h.)
5% chance to automatically hit,
5% chance to automatically miss,
if variable 'chance' is < 0, miss,
if target is invisible, chance = chance / 2
if chance < (target AC + target to-A if target is a player) * 3/4, miss,
otherwise hit and apply weapon critical hit code.
Melee Weapon Critical Hits:
Variable I: (weight*10) + ((player to-hit + weapon to-hit) * 5) + (player level * 3)
If a random integer 0-5000 is <= I then:
Variable K: (weight*10) + random integer 0-650
if K < 400, "good" hit ((2x dmg) + 5), done.
if K < 700, "great" hit ((2x dmg) + 10), done.
if K < 900, "superb" hit ((3x dmg) + 15), done.
if K < 1300, "*GREAT*" hit ((3x dmg) + 20), done.
otherwise '*SUPERB*' hit (( (7/2)x dmg) + 25), done.
To get a superb hit, you need a weapon that weighs at least 5.0 lbs.
To get a *GREAT* hit, you need a weapon that weighs at least 25.0 lbs.
To get a *SUPERB* hit, you need a weapon that weighs at least 65.0 lbs.
Ammo to-hit:
Variable 'bonus': Player to-hit + ammo to-hit + launcher to-hit
Variable 'chance': (Player ranged skill + (bonus * 3)) - distance travelled
(3 is the base to-hit addition. The game defines this as BTH_PLUS_ADJ in defines.h.)
5% chance to automatically hit,
5% chance to automatically miss,
if variable 'chance' is < 0, miss,
if target is invisible, chance = chance / 2
if chance < (target AC + target to-A if target is a player) * 3/4, miss,
otherwise hit and apply ammo critical hit code.
Ammo Critical Hits:
Variable I: (weight*10) + ((player to-hit + launcher to-hit + item to-hit) * 4) + (player level * 2)
If a random integer 0-5000 is <= I then:
Variable K: (weight*10) + random integer 0-500
if K < 500, "good" hit ((2x dmg) + 5), done.
if K < 1000, "great" hit ((2x dmg) + 10), done.
otherwise, "superb" hit ((3x dmg) + 15), done.
By the sources, you need 50 lb units of ammo to get a great hit, and 100 lb ammos to get a superb hit. That's really weird, until you consider that this is used for thrown items as well.
Thrown item to-hit:
This is pretty much the same as ammo to-hit, except no launcher bonuses are applied, and instead of ranged skill, it applies throwing skill - which is hidden from the player, but it's basically the same as your base race/class/level shooting skill. See that part.
[hr]
Currently the heaviest artifact weapon in the game is Grond, at 100 lbs, and the heaviest non-artifact weapon is a Mace of Disruption, at 40 lbs.
The weapons capable of *GREAT* hits out of the box are: Lochaber Axe (25.0 lbs), Scythe (25.0 lbs), Scythe of Slicing (25.0 lbs) Executioner's Sword (26.0 lbs), Two-Handed Flail (28.0 lbs), Lance (30.0 lbs), and Mace of Disruption (40.0 lbs). That is the entire list.
Items capable of great hits: Large wooden chest, Small steel chest, Large iron chest, Large steel chest. The large steel chest is the only thing you can throw that will get a superb hit. That is the entire list.
Artifact melee weapons capable of *GREAT* hits: Zarcuthra, Mormegil, Crisdurian, Eorlingas, Mundwine, Trident of Wrath, Avavir, Grond, Thunderfist, Deathwreaker. That is the entire list.
Grond is the only weapon in the game capable of *SUPERB* hits, which it should get just about every time.
Artifact armor cabable of great hits when thrown: Razorback, Bladeturner.
As far as I know, this is the only complete documentation on weapon, ammo, and thrown to-hit. Enjoy!
- Berendol -
(this information can be found by a search for to_h in cmd1.c and cmd2.c)
Melee Weapon To-Hit:
Variable 'bonus' = player to-hit + weapon to-hit.
Variable 'chance' = player fighting skill + (bonus * 3)
(3 is the base to-hit addition. The game defines this as BTH_PLUS_ADJ in defines.h.)
5% chance to automatically hit,
5% chance to automatically miss,
if variable 'chance' is < 0, miss,
if target is invisible, chance = chance / 2
if chance < (target AC + target to-A if target is a player) * 3/4, miss,
otherwise hit and apply weapon critical hit code.
Melee Weapon Critical Hits:
Variable I: (weight*10) + ((player to-hit + weapon to-hit) * 5) + (player level * 3)
If a random integer 0-5000 is <= I then:
Variable K: (weight*10) + random integer 0-650
if K < 400, "good" hit ((2x dmg) + 5), done.
if K < 700, "great" hit ((2x dmg) + 10), done.
if K < 900, "superb" hit ((3x dmg) + 15), done.
if K < 1300, "*GREAT*" hit ((3x dmg) + 20), done.
otherwise '*SUPERB*' hit (( (7/2)x dmg) + 25), done.
To get a superb hit, you need a weapon that weighs at least 5.0 lbs.
To get a *GREAT* hit, you need a weapon that weighs at least 25.0 lbs.
To get a *SUPERB* hit, you need a weapon that weighs at least 65.0 lbs.
Ammo to-hit:
Variable 'bonus': Player to-hit + ammo to-hit + launcher to-hit
Variable 'chance': (Player ranged skill + (bonus * 3)) - distance travelled
(3 is the base to-hit addition. The game defines this as BTH_PLUS_ADJ in defines.h.)
5% chance to automatically hit,
5% chance to automatically miss,
if variable 'chance' is < 0, miss,
if target is invisible, chance = chance / 2
if chance < (target AC + target to-A if target is a player) * 3/4, miss,
otherwise hit and apply ammo critical hit code.
Ammo Critical Hits:
Variable I: (weight*10) + ((player to-hit + launcher to-hit + item to-hit) * 4) + (player level * 2)
If a random integer 0-5000 is <= I then:
Variable K: (weight*10) + random integer 0-500
if K < 500, "good" hit ((2x dmg) + 5), done.
if K < 1000, "great" hit ((2x dmg) + 10), done.
otherwise, "superb" hit ((3x dmg) + 15), done.
By the sources, you need 50 lb units of ammo to get a great hit, and 100 lb ammos to get a superb hit. That's really weird, until you consider that this is used for thrown items as well.
Thrown item to-hit:
This is pretty much the same as ammo to-hit, except no launcher bonuses are applied, and instead of ranged skill, it applies throwing skill - which is hidden from the player, but it's basically the same as your base race/class/level shooting skill. See that part.
[hr]
Currently the heaviest artifact weapon in the game is Grond, at 100 lbs, and the heaviest non-artifact weapon is a Mace of Disruption, at 40 lbs.
The weapons capable of *GREAT* hits out of the box are: Lochaber Axe (25.0 lbs), Scythe (25.0 lbs), Scythe of Slicing (25.0 lbs) Executioner's Sword (26.0 lbs), Two-Handed Flail (28.0 lbs), Lance (30.0 lbs), and Mace of Disruption (40.0 lbs). That is the entire list.
Items capable of great hits: Large wooden chest, Small steel chest, Large iron chest, Large steel chest. The large steel chest is the only thing you can throw that will get a superb hit. That is the entire list.
Artifact melee weapons capable of *GREAT* hits: Zarcuthra, Mormegil, Crisdurian, Eorlingas, Mundwine, Trident of Wrath, Avavir, Grond, Thunderfist, Deathwreaker. That is the entire list.
Grond is the only weapon in the game capable of *SUPERB* hits, which it should get just about every time.
Artifact armor cabable of great hits when thrown: Razorback, Bladeturner.
As far as I know, this is the only complete documentation on weapon, ammo, and thrown to-hit. Enjoy!
- Berendol -
By appreciation, we make excellence in others our own property. (Voltaire)
Re: To-hit/Criticalhit questions
Ok.. the critical hit part makes absolute sense. However..
Assuming player to-hit of 40 and weapon to-hit of 10
Legendary + (50*3) = Chance
That doesn't make much sense....
I did a search through the codefiles for the word Heroic, a weapon skill level, and got this.
/*
* Returns a "rating" of x depending on y
*/
static cptr likert(int x, int y)
{
/* Paranoia */
if (y <= 0) y = 1;
/* Negative values */
if (x < 0)
{
likert_color = TERM_RED;
return ("Very Bad");
}
/* Analyze the value */
switch ((x / y))
{
case 0:
case 1:
{
likert_color = TERM_RED;
return ("Bad");
}
case 2:
{
likert_color = TERM_RED;
return ("Poor");
}
case 3:
case 4:
{
likert_color = TERM_YELLOW;
return ("Fair");
}
case 5:
{
likert_color = TERM_YELLOW;
return ("Good");
}
case 6:
{
likert_color = TERM_YELLOW;
return ("Very Good");
}
case 7:
case 8:
{
likert_color = TERM_L_GREEN;
return ("Excellent");
}
case 9:
case 10:
case 11:
case 12:
case 13:
{
likert_color = TERM_L_GREEN;
return ("Superb");
}
case 14:
case 15:
case 16:
case 17:
{
likert_color = TERM_L_GREEN;
return ("Heroic");
}
default:
{
likert_color = TERM_L_GREEN;
return ("Legendary");
}
}
}
Can't quite figure out how to get a number for each skill level from that..
(Edit) Reviewing this.. I just got an idea.. does say
Case:7 and 8 under very good mean that very good = 7-8? But there's no "case" under heroic and legendary..
would that mean 17 is the maximum player skill bonus?
Assuming player to-hit of 40 and weapon to-hit of 10
Legendary + (50*3) = Chance
That doesn't make much sense....
I did a search through the codefiles for the word Heroic, a weapon skill level, and got this.
/*
* Returns a "rating" of x depending on y
*/
static cptr likert(int x, int y)
{
/* Paranoia */
if (y <= 0) y = 1;
/* Negative values */
if (x < 0)
{
likert_color = TERM_RED;
return ("Very Bad");
}
/* Analyze the value */
switch ((x / y))
{
case 0:
case 1:
{
likert_color = TERM_RED;
return ("Bad");
}
case 2:
{
likert_color = TERM_RED;
return ("Poor");
}
case 3:
case 4:
{
likert_color = TERM_YELLOW;
return ("Fair");
}
case 5:
{
likert_color = TERM_YELLOW;
return ("Good");
}
case 6:
{
likert_color = TERM_YELLOW;
return ("Very Good");
}
case 7:
case 8:
{
likert_color = TERM_L_GREEN;
return ("Excellent");
}
case 9:
case 10:
case 11:
case 12:
case 13:
{
likert_color = TERM_L_GREEN;
return ("Superb");
}
case 14:
case 15:
case 16:
case 17:
{
likert_color = TERM_L_GREEN;
return ("Heroic");
}
default:
{
likert_color = TERM_L_GREEN;
return ("Legendary");
}
}
}
Can't quite figure out how to get a number for each skill level from that..
(Edit) Reviewing this.. I just got an idea.. does say
Case:7 and 8 under very good mean that very good = 7-8? But there's no "case" under heroic and legendary..
would that mean 17 is the maximum player skill bonus?
Version 3.12
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z
Re: To-hit/Criticalhit questions
You're very close. It's a standard C switch block. The 'case' statements precede what happens if those cases are met - so 7 and 8 return Excellent. You'll notice the 'default' one. That executes if none of the cases are met, which happens when (x/y) > 17.
Here's the short of it:
0, 1: Bad
2: Poor
3, 4: Fair
5: Good
6: Very Good
7, 8: Excellent
9, 10, 11, 12, 13: Superb
14, 15, 16, 17: Heroic
18+: Legendary
Note that no values less than 0 are used. That returns "Very Bad."
Here's the short of it:
0, 1: Bad
2: Poor
3, 4: Fair
5: Good
6: Very Good
7, 8: Excellent
9, 10, 11, 12, 13: Superb
14, 15, 16, 17: Heroic
18+: Legendary
Note that no values less than 0 are used. That returns "Very Bad."
By appreciation, we make excellence in others our own property. (Voltaire)
Re: To-hit/Criticalhit questions
Ok.. this confuses me 
There's nothing random here besides a flat 5% chance of a direct hit or miss, as I see it. If you have more (Tohit*3 + fighting skill) then enemy ac (enemy ac * .75)
then you hit. Otherwise, you miss.. but I don't see that in gameplay... against something with alot of ac, when I have a low to-hit value i'll have maybe half my hits score. Wouldn't it either be 19/20 score or 19/20 miss on average?

There's nothing random here besides a flat 5% chance of a direct hit or miss, as I see it. If you have more (Tohit*3 + fighting skill) then enemy ac (enemy ac * .75)
then you hit. Otherwise, you miss.. but I don't see that in gameplay... against something with alot of ac, when I have a low to-hit value i'll have maybe half my hits score. Wouldn't it either be 19/20 score or 19/20 miss on average?
Version 3.12
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z
Re: To-hit/Criticalhit questions
It's not all that random, really. This is *all* of the math behind it, and you might just get an unusual sequence of random numbers once in awhile.
By appreciation, we make excellence in others our own property. (Voltaire)
Re: To-hit/Criticalhit questions
This has some interesting gameplay implications...
So once you get past a certain to-hit + skill value, you'll be able to hit morgoth 19/20 of the time. Before that, you'll hit him about 1/20 of the time?
Thanks a lot for all the info!

So once you get past a certain to-hit + skill value, you'll be able to hit morgoth 19/20 of the time. Before that, you'll hit him about 1/20 of the time?
Thanks a lot for all the info!

Version 3.12
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z
GAT d- s++:- a14 C++++ UL+ P L+ E? W+ N+ o? K---- w--- O-- M-- V? PS--- PE++ Y+ PGP- t+ 5? X- R+ !tv b+++ DI+++ D+ G+ e- h! !r !z