Skip to content

Commit

Permalink
Dexterity affects armor class.
Browse files Browse the repository at this point in the history
From EvilHack commit d979001b8.

I tweaked this a bit to be more conservative, and punish low dexterity a more.
  • Loading branch information
elunna committed Dec 8, 2023
1 parent fc8cb04 commit fe9628e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/objclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ extern NEARDATA struct objdescr obj_descr[NUM_OBJECTS + 1];
#define is_metallic(otmp) \
(objects[otmp->otyp].oc_material >= IRON \
&& objects[otmp->otyp].oc_material <= MITHRIL)
#define is_heavy_metallic(otmp) \
(objects[otmp->otyp].oc_material >= IRON \
&& objects[otmp->otyp].oc_material <= PLATINUM)

/* primary damage: fire/rust/--- */
/* is_flammable(otmp), is_rottable(otmp) in mkobj.c */
Expand Down
30 changes: 29 additions & 1 deletion src/do_wear.c
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,7 @@ find_ac(void)

/* armor class from worn gear */

int racial_bonus;
int racial_bonus, dex_adjust_ac;;

/* Wearing racial armor is worth +x to the armor's AC; orcs get a slightly
* larger bonus to compensate their sub-standard equipment, lack of equipment,
Expand Down Expand Up @@ -2428,6 +2428,34 @@ find_ac(void)
uac -= u.ublessed;
uac -= u.uspellprot;


/* Dexterity affects your base AC */
dex_adjust_ac = 0;
if (ACURR(A_DEX) <= 6)
dex_adjust_ac += 3;
else if (ACURR(A_DEX) <= 8)
dex_adjust_ac += 2;
else if (ACURR(A_DEX) <= 10)
dex_adjust_ac += 1;
else if (ACURR(A_DEX) <= 14)
dex_adjust_ac -= 0;
else if (ACURR(A_DEX) <= 16)
dex_adjust_ac -= 1;
else if (ACURR(A_DEX) >= 18)
dex_adjust_ac -= 2;

/* Wearing certain types of body armor negates any
* beneficial dexterity bonus. So does being
* encumbered in any way.
*/
if ((uarm && is_heavy_metallic(uarm))
|| (near_capacity() >= SLT_ENCUMBER)) {
if (dex_adjust_ac < 0)
dex_adjust_ac = 0;
}

uac = uac + dex_adjust_ac;

/* put a cap on armor class [3.7: was +127,-128, now reduced to +/- 99 */
if (abs(uac) > AC_MAX)
uac = sgn(uac) * AC_MAX;
Expand Down

0 comments on commit fe9628e

Please sign in to comment.