Skip to content

Commit

Permalink
Added auto-identify when anything with the swimming property (includi…
Browse files Browse the repository at this point in the history
…ng gauntlets of swimming) makes you swim.
  • Loading branch information
elunna committed Sep 30, 2023
1 parent 0fac171 commit 4696421
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/do_wear.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions src/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
22 changes: 22 additions & 0 deletions src/wield.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4696421

Please sign in to comment.