From 4696421efe71df54ef124d243b071b3977cf8c0d Mon Sep 17 00:00:00 2001 From: Erik Lunna Date: Sat, 30 Sep 2023 20:57:54 +0200 Subject: [PATCH] Added auto-identify when anything with the swimming property (including gauntlets of swimming) makes you swim. --- src/do_wear.c | 39 ++++++++++++++++++++++++++------------- src/trap.c | 18 ++++++++++++++++++ src/wield.c | 22 ++++++++++++++++++++++ 3 files changed, 66 insertions(+), 13 deletions(-) diff --git a/src/do_wear.c b/src/do_wear.c index dcb5f28bb..9d9d6bf3d 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -295,8 +295,16 @@ long mask; otmp->oprops_known |= ITEM_WWALK; } } - if (props & ITEM_SWIM) + if (props & ITEM_SWIM) { ESwimming |= mask; + if (u.uinwater) { + pline("Hey! %s helping you swim!", + yobjnam(otmp, "are")); + otmp->oprops_known |= ITEM_SWIM; + spoteffects(TRUE); + } + } + } void @@ -387,9 +395,14 @@ long mask; spoteffects(TRUE); } } - if (props & ITEM_SWIM) + if (props & ITEM_SWIM) { ESwimming &= ~mask; - + if (u.uinwater && !Swimming) { + You("begin to thrash about!"); + otmp->oprops_known |= ITEM_SWIM; + spoteffects(TRUE); + } + } } int @@ -961,11 +974,11 @@ Gloves_on(VOID_ARGS) incr_itimeout(&HFumbling, rnd(20)); break; case GAUNTLETS_OF_SWIMMING: - if (u.uinwater) { - pline("Hey! You can swim!"); - spoteffects(TRUE); - } - break; + if (u.uinwater) { + pline("Hey! You can swim!"); + spoteffects(TRUE); + } + break; case GAUNTLETS_OF_POWER: makeknown(uarmg->otyp); context.botl = 1; /* taken care of in attrib.c */ @@ -1031,11 +1044,11 @@ Gloves_off(VOID_ARGS) case PLASTEEL_GLOVES: break; case GAUNTLETS_OF_SWIMMING: - if (u.uinwater) { - You("begin to thrash about!"); - spoteffects(TRUE); - } - break; + if (u.uinwater && !Swimming) { + You("begin to thrash about!"); + spoteffects(TRUE); + } + break; case GAUNTLETS_OF_FUMBLING: if (!(HFumbling & ~TIMEOUT)) HFumbling = EFumbling = 0; diff --git a/src/trap.c b/src/trap.c index 2f61298b7..5ae3c18d5 100644 --- a/src/trap.c +++ b/src/trap.c @@ -4668,6 +4668,24 @@ drown() } if (Amphibious || Swimming) { + /* Copied from the above for water walking boots */ + if (uarmg + && uarmg->otyp == GAUNTLETS_OF_SWIMMING + && !objects[GAUNTLETS_OF_SWIMMING].oc_name_known + && !(Amphibious || HSwimming)) { + pline("Hey! You can swim!"); + makeknown(GAUNTLETS_OF_SWIMMING); + } else if (!HSwimming) { + /* *Something* is making us swim! */ + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp->oprops & ITEM_SWIM && is_worn(otmp) + && !(otmp->oprops_known & ITEM_SWIM)) { + pline("Hey! You can swim!"); + otmp->oprops_known |= ITEM_SWIM; + update_inventory(); + } + } + if (Amphibious) { if (flags.verbose) pline("But you aren't drowning."); diff --git a/src/wield.c b/src/wield.c index c466c8fbe..c643e2fa1 100644 --- a/src/wield.c +++ b/src/wield.c @@ -168,6 +168,11 @@ register struct obj *obj; } if (olduwep->oprops & ITEM_SWIM) { ESwimming &= ~W_WEP; + if (u.uinwater && !Swimming) { + You("begin to thrash about!"); + olduwep->oprops_known |= ITEM_SWIM; + spoteffects(TRUE); + } } if (olduwep->oprops & ITEM_SLEEP) { ESleep_resistance &= ~W_WEP; @@ -239,6 +244,12 @@ register struct obj *obj; } if (uwep->oprops & ITEM_SWIM) { ESwimming |= W_WEP; + if (u.uinwater) { + pline("Hey! %s helping you swim!", + yobjnam(uwep, "are")); + uwep->oprops_known |= ITEM_SWIM; + spoteffects(TRUE); + } } if (uwep->oprops & ITEM_SLEEP) { ESleep_resistance |= W_WEP; @@ -590,9 +601,20 @@ register struct obj *obj; if (uswapwep == obj && (u.twoweap && (uswapwep->oprops & ITEM_SWIM))) { HSwimming |= W_SWAPWEP; + if (u.uinwater) { + pline("Hey! %s helping you swim!", + yobjnam(uswapwep, "are")); + uswapwep->oprops_known |= ITEM_SWIM; + spoteffects(TRUE); + } } if (!u.twoweap && olduswapwep && (olduswapwep->oprops & ITEM_SWIM)) { HSwimming &= ~W_SWAPWEP; + if (u.uinwater && !Swimming) { + You("begin to thrash about!"); + olduswapwep->oprops_known |= ITEM_SWIM; + spoteffects(TRUE); + } } /* Sleep resistance */ if (uswapwep == obj