Hero movement affects water bubble direction

This commit is contained in:
Pasi Kallinen
2024-04-10 21:57:05 +03:00
parent 46370fc124
commit 62b78ba037
4 changed files with 27 additions and 1 deletions
+22
View File
@@ -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