From 98d2b0ecb3145e698ea1f6155a75f8021d13dcfb Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 3 Nov 2023 13:47:20 -0400 Subject: [PATCH] Follow up on disturbing buried zombies Change 852f8e4 by requiring a minimum impact before a buried zombie nearby will be disturbed: light, but still excluding things like scrolls, if it's a violent impact (dropped while levitating, thrown, or kicked), and fairly heavy if the hero is just placing the item on the ground normally. Moving the call out of flooreffects meant it no longer applied to pushing boulders around, so have moverock disturb nearby zombies. I additionally had wake_nearby do the same thing. Finally, I renamed check_buried_zombies (which doesn't really reflect what it does) to disturb_buried_zombies. --- include/extern.h | 3 ++- src/do.c | 2 +- src/dokick.c | 2 ++ src/dothrow.c | 4 +++- src/hack.c | 26 ++++++++++++++++++++++---- src/mon.c | 1 + 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/include/extern.h b/include/extern.h index 8716af7be..02d7f3b31 100644 --- a/include/extern.h +++ b/include/extern.h @@ -995,7 +995,8 @@ extern boolean test_move(coordxy, coordxy, coordxy, coordxy, int); extern int wiz_debug_cmd_traveldisplay(void); #endif extern boolean u_rooted(void); -extern void check_buried_zombies(coordxy, coordxy); +extern void impact_disturbs_zombies(struct obj *, boolean); +extern void disturb_buried_zombies(coordxy, coordxy); extern boolean u_maybe_impaired(void); extern const char *u_locomotion(const char *); extern void handle_tip(int); diff --git a/src/do.c b/src/do.c index 9f8492316..89160df58 100644 --- a/src/do.c +++ b/src/do.c @@ -305,7 +305,6 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb) && cansee(x,y)) { doaltarobj(obj); } - check_buried_zombies(x, y); gb.bhitpos = save_bhitpos; return res; @@ -779,6 +778,7 @@ dropz(struct obj *obj, boolean with_impact) place_object(obj, u.ux, u.uy); if (with_impact) container_impact_dmg(obj, u.ux, u.uy); + impact_disturbs_zombies(obj, with_impact); if (obj == uball) drop_ball(u.ux, u.uy); else if (gl.level.flags.has_shop) diff --git a/src/dokick.c b/src/dokick.c index 8fc658576..b9935f11b 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -627,6 +627,7 @@ really_kick_object(coordxy x, coordxy y) } if (!flooreffects(gk.kickedobj, u.ux, u.uy, "fall")) { place_object(gk.kickedobj, u.ux, u.uy); + impact_disturbs_zombies(gk.kickedobj, TRUE); stackobj(gk.kickedobj); newsym(u.ux, u.uy); } @@ -770,6 +771,7 @@ really_kick_object(coordxy x, coordxy y) donate_gold(gtg, shkp, FALSE); } place_object(gk.kickedobj, gb.bhitpos.x, gb.bhitpos.y); + impact_disturbs_zombies(gk.kickedobj, TRUE); stackobj(gk.kickedobj); newsym(gk.kickedobj->ox, gk.kickedobj->oy); return 1; diff --git a/src/dothrow.c b/src/dothrow.c index 4a57a0804..f2417169d 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -1777,9 +1777,11 @@ throwit(struct obj *obj, /* container contents might break; do so before turning ownership of gt.thrownobj over to shk (container_impact_dmg handles item already owned by shop) */ - if (!IS_SOFT(levl[gb.bhitpos.x][gb.bhitpos.y].typ)) + if (!IS_SOFT(levl[gb.bhitpos.x][gb.bhitpos.y].typ)) { /* is spot where you initiated throw, not gb.bhitpos */ container_impact_dmg(obj, u.ux, u.uy); + impact_disturbs_zombies(obj, TRUE); + } /* charge for items thrown out of shop; shk takes possession for items thrown into one */ if ((*u.ushops || obj->unpaid) && obj != uball) diff --git a/src/hack.c b/src/hack.c index c466e5583..f4877bca5 100644 --- a/src/hack.c +++ b/src/hack.c @@ -291,6 +291,15 @@ moverock(void) goto cannot_push; } + if (closed_door(rx, ry)) + goto nopushmsg; + + /* at this point the boulder should be able to move (though + potentially into something like a trap, pool, or lava) */ + + /* rumbling disturbs buried zombies */ + disturb_buried_zombies(sx, sy); + if (ttmp) { int newlev = 0; /* lint suppression */ d_level dest; @@ -401,8 +410,6 @@ moverock(void) } } - if (closed_door(rx, ry)) - goto nopushmsg; if (boulder_hits_pool(otmp, rx, ry, TRUE)) continue; @@ -1592,9 +1599,20 @@ u_rooted(void) return FALSE; } +/* maybe disturb buried zombies when an object is dropped or thrown nearby */ +void +impact_disturbs_zombies(struct obj *obj, boolean violent) +{ + /* if object won't make a noticeable impact, let buried zombies rest */ + if (obj->owt < (violent ? 10 : 100) || is_flimsy(obj)) + return; + + disturb_buried_zombies(obj->ox, obj->oy); +} + /* reduce zombification timeout of buried zombies around px, py */ void -check_buried_zombies(coordxy x, coordxy y) +disturb_buried_zombies(coordxy x, coordxy y) { struct obj *otmp; long t; @@ -2601,7 +2619,7 @@ domove_core(void) } if (!Levitation && !Flying && !Stealth) - check_buried_zombies(u.ux, u.uy); + disturb_buried_zombies(u.ux, u.uy); if (hides_under(gy.youmonst.data) || gy.youmonst.data->mlet == S_EEL || u.dx || u.dy) diff --git a/src/mon.c b/src/mon.c index 965a29d3d..98e9e9375 100644 --- a/src/mon.c +++ b/src/mon.c @@ -4033,6 +4033,7 @@ wake_nearto(coordxy x, coordxy y, int distance) } } } + disturb_buried_zombies(x, y); } /* NOTE: we must check for mimicry before calling this routine */