The game tracks each character’s accuracy and bonus damage through the hitroll and damroll fields in CHAR_DATA; these raw values are later combined with the character’s effective Strength to produce the final combat modifiers.
Building a character’s damroll and hitroll
Strength contributes to both mechanics through the str_app_type table. Each point of effective Strength supplies a tohit bonus for accuracy and a todam bonus for damage, which are added to the character’s base fields when computing the final values.
The helper macros GET_HITROLL(ch) and GET_DAMROLL(ch) therefore return the sum of the character’s stored hitroll/damroll fields and the Strength-based bonuses determined by get_curr_stat (which clamps the current stat to the race/class limits plus modifiers).
Whenever a character is “reset,” the engine zeroes hitroll and damroll, then rebuilds them by iterating over every equipped item and active spell effect. Any affect with location APPLY_HITROLL or APPLY_DAMROLL adds its modifier to the running totals, meaning equipment, buffs, and debuffs directly change the stored fields that feed the macros.
For NPCs, the prototype loader copies the mob index’s predefined hitroll and damage bonus (damage[DICE_BONUS]) into the live character, giving them the same base mechanics as players before Strength and other modifiers are applied.
How hitroll is used when attacking
Each swing in one_hit starts by building an attack skill value (skill = 20 + get_weapon_skill). The helper caps weapon skill between 0 and 100, so skill ranges from 20 for the untrained to 120 for someone with 100% proficiency.
The engine interpolates a class- or act-flag-based THAC0, then subtracts GET_HITROLL(ch) * skill / 100. Because GET_HITROLL already includes Strength, every point of hitroll removes up to 1.2 points from the THAC0 threshold at 120 skill. Low skill also imposes a penalty term 5 * (100 - skill) / 100, so poor training both diminishes the hitroll bonus and directly worsens THAC0.
A pseudo–d20 roll is then compared against thac0 - victim_ac; if the roll is zero (an automatic miss) or below the threshold, the attack fails. Thus higher hitroll reduces the number the attacker must beat, improving the chance to hit regardless of armor.
How damroll affects damage
After base weapon or unarmed dice are evaluated (and bonuses like going shieldless are applied), the code adds skill-based extras such as enhanced damage and situational multipliers. Finally it adds GET_DAMROLL(ch) * UMIN(100, skill) / 100, meaning damroll scales linearly with weapon skill up to 100%; at lower skill, only a proportional share of the damroll applies.
The resulting damage is floored at 1 and then passed to damage(), which enforces a class/stat-driven cap via calculate_damage_cap. This cap doesn’t change how damroll is computed but limits the final outcome if the stacked bonuses (including damroll) would exceed the per-character ceiling.
Key takeaways
Hitroll is an accuracy modifier equal to the sum of all equipment/spell bonuses plus Strength’s tohit, scaled by weapon skill when applied, and it directly reduces the THAC0 needed to land an attack.
Damroll is a flat damage bonus equal to the summed gear/spell modifiers plus Strength’s todam, but only the fraction allowed by current weapon skill (up to 100%) is added to each hit’s damage roll before global damage caps are checked.
Both mechanics are rebuilt from scratch whenever character stats are recalculated, ensuring that equipment changes and temporary effects immediately propagate into combat performance.