From e4e8eea4e8a11a8dd811d74ed19d11c828b68ef1 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 1 Dec 2023 16:11:55 -0500 Subject: [PATCH] track the handedness of the hero Don't make either LEFT_HANDED or RIGHT_HANDED be an advantage or a disadvantage. use suggested macros --- include/you.h | 10 ++++++++++ src/do_wear.c | 27 ++++++++++++++++++++------- src/objnam.c | 13 +++++++++++-- src/u_init.c | 5 ++++- src/uhitm.c | 12 ++++++------ src/wield.c | 4 +++- 6 files changed, 54 insertions(+), 17 deletions(-) diff --git a/include/you.h b/include/you.h index db1c63bc4d..147d388084 100644 --- a/include/you.h +++ b/include/you.h @@ -421,6 +421,11 @@ struct you { Bitfield(uburied, 1); /* you're buried */ Bitfield(uedibility, 1); /* blessed food detect; sense unsafe food */ Bitfield(usaving_grace, 1); /* prevents death once */ + Bitfield(uhandedness, 1); /* There is no advantage for either handedness. + The distinction is only for flavor variation + and for use in messages. */ +#define RIGHT_HANDED 0x00 +#define LEFT_HANDED 0x01 unsigned udg_cnt; /* how long you have been demigod */ struct u_event uevent; /* certain events have happened */ @@ -538,4 +543,9 @@ struct _hitmon_data { /* hero at (x,y)? */ #define u_at(x,y) ((x) == u.ux && (y) == u.uy) +#define URIGHTY (u.uhandedness == RIGHT_HANDED) +#define ULEFTY (u.uhandedness == LEFT_HANDED) +#define RING_ON_PRIMARY (ULEFTY ? uleft : uright) +#define RING_ON_SECONDARY (ULEFTY ? uright : uleft) + #endif /* YOU_H */ diff --git a/src/do_wear.c b/src/do_wear.c index a02b038e85..e421badc2c 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -2159,7 +2159,9 @@ accessory_or_armor_on(struct obj *obj) } if (uwep) { res = !uwep->bknown; /* check this before calling welded() */ - if ((mask == RIGHT_RING || bimanual(uwep)) && welded(uwep)) { + if (((mask == RIGHT_RING && URIGHTY) + || (mask == LEFT_RING && ULEFTY) + || bimanual(uwep)) && welded(uwep)) { const char *hand = body_part(HAND); /* welded will set bknown */ @@ -2387,9 +2389,18 @@ glibr(void) boolean leftfall, rightfall, wastwoweap = FALSE; const char *otherwep = 0, *thiswep, *which, *hand; + leftfall = (uleft && !uleft->cursed + && (!uwep || !(welded(uwep) && ULEFTY) + || !bimanual(uwep))); + rightfall = (uright && !uright->cursed + && (!uwep || !(welded(uwep) && URIGHTY) + || !bimanual(uwep))); +/* leftfall = (uleft && !uleft->cursed && (!uwep || !welded(uwep) || !bimanual(uwep))); rightfall = (uright && !uright->cursed && (!welded(uwep))); +*/ + if (!uarmg && (leftfall || rightfall) && !nolimbs(gy.youmonst.data)) { /* changed so cursed rings don't fall off, GAN 10/30/86 */ Your("%s off your %s.", @@ -2422,7 +2433,7 @@ glibr(void) if (otmp->quan > 1L) otherwep = makeplural(otherwep); hand = body_part(HAND); - which = "left "; + which = URIGHTY ? "left " : "right "; /* text for the off hand */ Your("%s %s%s from your %s%s.", otherwep, xfl ? "also " : "", otense(otmp, "slip"), which, hand); xfl++; @@ -2453,10 +2464,12 @@ glibr(void) } hand = body_part(HAND); which = ""; - if (bimanual(otmp)) + if (bimanual(otmp)) { hand = makeplural(hand); - else if (wastwoweap) - which = "right "; /* preceding msg was about left */ + } else if (wastwoweap) { + /* preceding msg was about non-dominant hand */ + which = URIGHTY ? "right " : "left "; + } pline("%s %s%s %s%s from your %s%s.", !strncmp(thiswep, "corpse", 6) ? "The" : "Your", otherwep ? "other " : "", thiswep, xfl ? "also " : "", @@ -2511,7 +2524,7 @@ stuck_ring(struct obj *ring, int otyp) if (nolimbs(gy.youmonst.data) && uamul && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed) return uamul; - if (welded(uwep) && (ring == uright || bimanual(uwep))) + if (welded(uwep) && ((ring == RING_ON_PRIMARY) || bimanual(uwep))) return uwep; if (uarmg && uarmg->cursed) return uarmg; @@ -2556,7 +2569,7 @@ select_off(register struct obj *otmp) } glibdummy = cg.zeroobj; why = 0; /* the item which prevents ring removal */ - if (welded(uwep) && (otmp == uright || bimanual(uwep))) { + if (welded(uwep) && ((otmp == RING_ON_PRIMARY) || bimanual(uwep))) { Sprintf(buf, "free a weapon %s", body_part(HAND)); why = uwep; } else if (uarmg && (uarmg->cursed || Glib)) { diff --git a/src/objnam.c b/src/objnam.c index e5fbf7f53d..6d7efc136f 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1406,7 +1406,15 @@ doname_base( tethered ? "tethered " : "", /* aklys */ /* avoid "tethered wielded in right hand" for twoweapon */ (twoweap_primary && !tethered) ? "wielded" : "weapon", - twoweap_primary ? "right " : "", hand_s); + URIGHTY ? "right " : "left ", +/* + (twoweap_primary && URIGHTY) + ? "right " + : (twoweap_primary && ULEFTY) + ? "left " + : "", +*/ + hand_s); if (!Blind) { if (gw.warn_obj_cnt && obj == uwep && (EWarn_of_mon & W_WEP) != 0L) @@ -1423,7 +1431,8 @@ doname_base( } if (obj->owornmask & W_SWAPWEP) { if (u.twoweap) - Sprintf(eos(bp), " (wielded in left %s)", body_part(HAND)); + Sprintf(eos(bp), " (wielded in %s %s)", + URIGHTY ? "left" : "right", body_part(HAND)); else /* TODO: rephrase this when obj isn't a weapon or weptool */ Sprintf(eos(bp), " (alternate weapon%s; not wielded)", diff --git a/src/u_init.c b/src/u_init.c index 85291b817f..001be68ce7 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -602,7 +602,7 @@ knows_class(char sym) void u_init(void) { - register int i; + int i; struct u_roleplay tmpuroleplay = u.uroleplay; /* set by rcfile options */ flags.female = flags.initgend; @@ -903,6 +903,9 @@ u_init(void) break; } + /* roughly based on distribution in human population */ + u.uhandedness = rn2(10) ? RIGHT_HANDED : LEFT_HANDED; + if (discover) ini_inv(Wishing); diff --git a/src/uhitm.c b/src/uhitm.c index 8e290b0d32..951e94f00b 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -5384,12 +5384,12 @@ hmonas(struct monst *mon) verb = (mattk->aatyp == AT_TUCH) ? "touch" : "claws"; /* decide if silver-hater will be hit by silver ring(s); for 'multi_claw' where attacks alternate right/left, - assume 'even' claw or touch attacks use right hand - or paw, 'odd' ones use left for ring interaction; - even vs odd is based on actual attacks rather - than on index into mon->dat->mattk[] so that {bite, - claw,claw} instead of {claw,claw,bite} doesn't - make poly'd hero mysteriously become left-handed */ + assume 'even' claw or touch attacks use dominant hand + or paw, 'odd' ones use non-dominant hand for ring + interaction; even vs odd is based on actual attacks + rather than on index into mon->dat->mattk[] so that + {bite,claw,claw} instead of {claw,claw,bite} doesn't + make poly'd hero mysteriously switch handedness */ odd_claw = !odd_claw; specialdmg = special_dmgval(&gy.youmonst, mon, W_ARMG diff --git a/src/wield.c b/src/wield.c index 4e127391db..f06215117f 100644 --- a/src/wield.c +++ b/src/wield.c @@ -194,8 +194,10 @@ ready_weapon(struct obj *wep) tmp = thestr; else tmp = ""; - pline("%s%s %s to your %s!", tmp, aobjnam(wep, "weld"), + pline("%s%s %s to your %s%s!", tmp, aobjnam(wep, "weld"), (wep->quan == 1L) ? "itself" : "themselves", /* a3 */ + bimanual(wep) ? "" : + (URIGHTY ? "dominant right " : "dominant left "), bimanual(wep) ? (const char *) makeplural(body_part(HAND)) : body_part(HAND)); set_bknown(wep, 1);