From 62b78ba0371d0a148ad1f59a61e56c7e31e90c6c Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 10 Apr 2024 21:56:49 +0300 Subject: [PATCH] Hero movement affects water bubble direction --- doc/fixes3-7-0.txt | 1 + include/extern.h | 1 + src/hack.c | 4 +++- src/mkmaze.c | 22 ++++++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 2e77d74cb..5333a8226 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1396,6 +1396,7 @@ unblind telepathy range depends on number of telepathy granting items worn gold thrown or kicked at a sleeping monster with the 'greedy' attribute gets caught instead of being treated as an attack but the catch message neglected to report that target monster was awakened in the process +hero movement affects the water bubble movement direction Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index 1ff918be4..1e533c96f 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1550,6 +1550,7 @@ extern void movebubbles(void); extern void water_friction(void); extern void save_waterlevel(NHFILE *) NONNULLARG1; extern void restore_waterlevel(NHFILE *) NONNULLARG1; +extern void maybe_adjust_hero_bubble(void); /* ### mkobj.c ### */ diff --git a/src/hack.c b/src/hack.c index 0930cdf3a..2286e7b87 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2506,8 +2506,10 @@ domove(void) gd.domove_succeeded = 0L; domove_core(); /* gd.domove_succeeded is available to make assessments now */ - if ((gd.domove_succeeded & (DOMOVE_RUSH | DOMOVE_WALK)) != 0) + if ((gd.domove_succeeded & (DOMOVE_RUSH | DOMOVE_WALK)) != 0) { maybe_smudge_engr(ux1, uy1, u.ux, u.uy); + maybe_adjust_hero_bubble(); + } gd.domove_attempting = 0L; } diff --git a/src/mkmaze.c b/src/mkmaze.c index 872a4674b..e16d7fbd6 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1489,6 +1489,9 @@ fumaroles(void) #define gbxmax (gx.xmax - 1) #define gbymax (gy.ymax - 1) +/* the bubble hero is in */ +static struct bubble *hero_bubble = NULL; + staticfn void set_wportal(void); staticfn void mk_bubble(coordxy, coordxy, int); staticfn void mv_bubble(struct bubble *, coordxy, coordxy, boolean); @@ -1513,6 +1516,8 @@ movebubbles(void) vision_recalc(2); + hero_bubble = NULL; + if (Is_waterlevel(&u.uz)) { /* keep attached ball&chain separate from bubble objects */ if (Punished) @@ -1583,6 +1588,7 @@ movebubbles(void) cons->next = b->cons; b->cons = cons; + hero_bubble = b; } if ((btrap = t_at(x, y)) != 0) { cons = (struct container *) alloc(sizeof *cons); @@ -1875,6 +1881,22 @@ mk_bubble(coordxy x, coordxy y, int n) mv_bubble(b, 0, 0, TRUE); } +/* maybe change the movement direction of the bubble hero is in */ +void +maybe_adjust_hero_bubble(void) +{ + if (!Is_waterlevel(&u.uz)) + return; + + if (!u.dx && !u.dy) + return; + + if (hero_bubble && !rn2(2)) { + hero_bubble->dx = u.dx; + hero_bubble->dy = u.dy; + } +} + /* * The player, the portal and all other objects and monsters * float along with their associated bubbles. Bubbles may overlap