track the handedness of the hero

Don't make either LEFT_HANDED or RIGHT_HANDED be an advantage
or a disadvantage.

use suggested macros
This commit is contained in:
nhmall
2023-12-01 16:11:55 -05:00
parent 8ee8d89814
commit e4e8eea4e8
6 changed files with 54 additions and 17 deletions

View File

@@ -421,6 +421,11 @@ struct you {
Bitfield(uburied, 1); /* you're buried */ Bitfield(uburied, 1); /* you're buried */
Bitfield(uedibility, 1); /* blessed food detect; sense unsafe food */ Bitfield(uedibility, 1); /* blessed food detect; sense unsafe food */
Bitfield(usaving_grace, 1); /* prevents death once */ 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 */ unsigned udg_cnt; /* how long you have been demigod */
struct u_event uevent; /* certain events have happened */ struct u_event uevent; /* certain events have happened */
@@ -538,4 +543,9 @@ struct _hitmon_data {
/* hero at (x,y)? */ /* hero at (x,y)? */
#define u_at(x,y) ((x) == u.ux && (y) == u.uy) #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 */ #endif /* YOU_H */

View File

@@ -2159,7 +2159,9 @@ accessory_or_armor_on(struct obj *obj)
} }
if (uwep) { if (uwep) {
res = !uwep->bknown; /* check this before calling welded() */ 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); const char *hand = body_part(HAND);
/* welded will set bknown */ /* welded will set bknown */
@@ -2387,9 +2389,18 @@ glibr(void)
boolean leftfall, rightfall, wastwoweap = FALSE; boolean leftfall, rightfall, wastwoweap = FALSE;
const char *otherwep = 0, *thiswep, *which, *hand; 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 leftfall = (uleft && !uleft->cursed
&& (!uwep || !welded(uwep) || !bimanual(uwep))); && (!uwep || !welded(uwep) || !bimanual(uwep)));
rightfall = (uright && !uright->cursed && (!welded(uwep))); rightfall = (uright && !uright->cursed && (!welded(uwep)));
*/
if (!uarmg && (leftfall || rightfall) && !nolimbs(gy.youmonst.data)) { if (!uarmg && (leftfall || rightfall) && !nolimbs(gy.youmonst.data)) {
/* changed so cursed rings don't fall off, GAN 10/30/86 */ /* changed so cursed rings don't fall off, GAN 10/30/86 */
Your("%s off your %s.", Your("%s off your %s.",
@@ -2422,7 +2433,7 @@ glibr(void)
if (otmp->quan > 1L) if (otmp->quan > 1L)
otherwep = makeplural(otherwep); otherwep = makeplural(otherwep);
hand = body_part(HAND); 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 " : "", Your("%s %s%s from your %s%s.", otherwep, xfl ? "also " : "",
otense(otmp, "slip"), which, hand); otense(otmp, "slip"), which, hand);
xfl++; xfl++;
@@ -2453,10 +2464,12 @@ glibr(void)
} }
hand = body_part(HAND); hand = body_part(HAND);
which = ""; which = "";
if (bimanual(otmp)) if (bimanual(otmp)) {
hand = makeplural(hand); hand = makeplural(hand);
else if (wastwoweap) } else if (wastwoweap) {
which = "right "; /* preceding msg was about left */ /* preceding msg was about non-dominant hand */
which = URIGHTY ? "right " : "left ";
}
pline("%s %s%s %s%s from your %s%s.", pline("%s %s%s %s%s from your %s%s.",
!strncmp(thiswep, "corpse", 6) ? "The" : "Your", !strncmp(thiswep, "corpse", 6) ? "The" : "Your",
otherwep ? "other " : "", thiswep, xfl ? "also " : "", otherwep ? "other " : "", thiswep, xfl ? "also " : "",
@@ -2511,7 +2524,7 @@ stuck_ring(struct obj *ring, int otyp)
if (nolimbs(gy.youmonst.data) && uamul if (nolimbs(gy.youmonst.data) && uamul
&& uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed) && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed)
return uamul; return uamul;
if (welded(uwep) && (ring == uright || bimanual(uwep))) if (welded(uwep) && ((ring == RING_ON_PRIMARY) || bimanual(uwep)))
return uwep; return uwep;
if (uarmg && uarmg->cursed) if (uarmg && uarmg->cursed)
return uarmg; return uarmg;
@@ -2556,7 +2569,7 @@ select_off(register struct obj *otmp)
} }
glibdummy = cg.zeroobj; glibdummy = cg.zeroobj;
why = 0; /* the item which prevents ring removal */ 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)); Sprintf(buf, "free a weapon %s", body_part(HAND));
why = uwep; why = uwep;
} else if (uarmg && (uarmg->cursed || Glib)) { } else if (uarmg && (uarmg->cursed || Glib)) {

View File

@@ -1406,7 +1406,15 @@ doname_base(
tethered ? "tethered " : "", /* aklys */ tethered ? "tethered " : "", /* aklys */
/* avoid "tethered wielded in right hand" for twoweapon */ /* avoid "tethered wielded in right hand" for twoweapon */
(twoweap_primary && !tethered) ? "wielded" : "weapon", (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 (!Blind) {
if (gw.warn_obj_cnt && obj == uwep if (gw.warn_obj_cnt && obj == uwep
&& (EWarn_of_mon & W_WEP) != 0L) && (EWarn_of_mon & W_WEP) != 0L)
@@ -1423,7 +1431,8 @@ doname_base(
} }
if (obj->owornmask & W_SWAPWEP) { if (obj->owornmask & W_SWAPWEP) {
if (u.twoweap) 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 else
/* TODO: rephrase this when obj isn't a weapon or weptool */ /* TODO: rephrase this when obj isn't a weapon or weptool */
Sprintf(eos(bp), " (alternate weapon%s; not wielded)", Sprintf(eos(bp), " (alternate weapon%s; not wielded)",

View File

@@ -602,7 +602,7 @@ knows_class(char sym)
void void
u_init(void) u_init(void)
{ {
register int i; int i;
struct u_roleplay tmpuroleplay = u.uroleplay; /* set by rcfile options */ struct u_roleplay tmpuroleplay = u.uroleplay; /* set by rcfile options */
flags.female = flags.initgend; flags.female = flags.initgend;
@@ -903,6 +903,9 @@ u_init(void)
break; break;
} }
/* roughly based on distribution in human population */
u.uhandedness = rn2(10) ? RIGHT_HANDED : LEFT_HANDED;
if (discover) if (discover)
ini_inv(Wishing); ini_inv(Wishing);

View File

@@ -5384,12 +5384,12 @@ hmonas(struct monst *mon)
verb = (mattk->aatyp == AT_TUCH) ? "touch" : "claws"; verb = (mattk->aatyp == AT_TUCH) ? "touch" : "claws";
/* decide if silver-hater will be hit by silver ring(s); /* decide if silver-hater will be hit by silver ring(s);
for 'multi_claw' where attacks alternate right/left, for 'multi_claw' where attacks alternate right/left,
assume 'even' claw or touch attacks use right hand assume 'even' claw or touch attacks use dominant hand
or paw, 'odd' ones use left for ring interaction; or paw, 'odd' ones use non-dominant hand for ring
even vs odd is based on actual attacks rather interaction; even vs odd is based on actual attacks
than on index into mon->dat->mattk[] so that {bite, rather than on index into mon->dat->mattk[] so that
claw,claw} instead of {claw,claw,bite} doesn't {bite,claw,claw} instead of {claw,claw,bite} doesn't
make poly'd hero mysteriously become left-handed */ make poly'd hero mysteriously switch handedness */
odd_claw = !odd_claw; odd_claw = !odd_claw;
specialdmg = special_dmgval(&gy.youmonst, mon, specialdmg = special_dmgval(&gy.youmonst, mon,
W_ARMG W_ARMG

View File

@@ -194,8 +194,10 @@ ready_weapon(struct obj *wep)
tmp = thestr; tmp = thestr;
else else
tmp = ""; 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 */ (wep->quan == 1L) ? "itself" : "themselves", /* a3 */
bimanual(wep) ? "" :
(URIGHTY ? "dominant right " : "dominant left "),
bimanual(wep) ? (const char *) makeplural(body_part(HAND)) bimanual(wep) ? (const char *) makeplural(body_part(HAND))
: body_part(HAND)); : body_part(HAND));
set_bknown(wep, 1); set_bknown(wep, 1);