From 9079250cfc598e3f3c93cef459261fe63addae06 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 9 Jun 2023 16:09:26 -0700 Subject: [PATCH] testing for Vlad Redo the check for whether a monster is Vlad when deciding whether to keep it out of a bones file. Use the new check in find_defensive() where Vlad won't waste a turn attempting to use a wand of digging when in his undiggable own tower. (Failing to check for vampshifted Vlad in the latter case wasn't actually a bug because if/when shifted, he's unable to use items so couldn't attempt to use wand of digging. Switch to the new check anyway.) --- include/monst.h | 24 ++++++++++++++---------- src/bones.c | 5 ++--- src/muse.c | 3 +-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/monst.h b/include/monst.h index 080039ece..8bed8cf6e 100644 --- a/include/monst.h +++ b/include/monst.h @@ -205,25 +205,29 @@ struct monst { #define MON_WEP(mon) ((mon)->mw) #define MON_NOWEP(mon) ((mon)->mw = (struct obj *) 0) +/* dead monsters stay on the fmon list until dmonsfree() at end of turn */ #define DEADMONSTER(mon) ((mon)->mhp < 1) + #define is_starting_pet(mon) ((mon)->m_id == gc.context.startingpet_mid) -#define is_vampshifter(mon) \ +#define is_vampshifter(mon) \ ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LEADER \ || (mon)->cham == PM_VLAD_THE_IMPALER) #define vampshifted(mon) (is_vampshifter((mon)) && !is_vampire((mon)->data)) +/* Vlad might be vampshifted so just checking monst->data is insufficient */ +#define is_Vlad(m) ((m)->data == &mons[PM_VLAD_THE_IMPALER] \ + || (m)->cham == PM_VLAD_THE_IMPALER) -/* monsters which cannot be displaced: priests, shopkeepers, vault guards, - Oracle, quest leader */ -#define mundisplaceable(mon) ((mon)->ispriest \ - || (mon)->isshk \ - || (mon)->isgd \ - || (mon)->data == &mons[PM_ORACLE] \ - || (mon)->m_id == gq.quest_status.leader_m_id) +/* monsters which cannot be displaced: temple priests, shopkeepers, + vault guards, the Oracle, quest leader */ +#define mundisplaceable(mon) \ + ((mon)->ispriest || (mon)->isshk \ + || (mon)->isgd || (mon)->data == &mons[PM_ORACLE] \ + || (mon)->m_id == gq.quest_status.leader_m_id) /* mimic appearances that block vision/light */ -#define is_lightblocker_mappear(mon) \ +#define is_lightblocker_mappear(mon) \ (is_obj_mappear(mon, BOULDER) \ - || (M_AP_TYPE(mon) == M_AP_FURNITURE \ + || (M_AP_TYPE(mon) == M_AP_FURNITURE \ && ((mon)->mappearance == S_hcdoor \ || (mon)->mappearance == S_vcdoor \ || (mon)->mappearance < S_ndoor /* = walls */ \ diff --git a/src/bones.c b/src/bones.c index ae89e890b..3574942e9 100644 --- a/src/bones.c +++ b/src/bones.c @@ -381,7 +381,7 @@ can_make_bones(void) return TRUE; } -/* monster removed before saving a bones file, +/* monster might need to be removed before saving a bones file, in case these characters are not in their home bases */ static void remove_mon_from_bones(struct monst *mtmp) @@ -390,8 +390,7 @@ remove_mon_from_bones(struct monst *mtmp) if (mtmp->iswiz || mptr == &mons[PM_MEDUSA] || mptr->msound == MS_NEMESIS || mptr->msound == MS_LEADER - || mptr == &mons[PM_VLAD_THE_IMPALER] - || mtmp->cham == PM_VLAD_THE_IMPALER /* in case he's vampshifted */ + || is_Vlad(mtmp) /* mptr == &mons[VLAD_THE_IMPALER] || cham == VLAD */ || (mptr == &mons[PM_ORACLE] && !fixuporacle(mtmp))) mongone(mtmp); } diff --git a/src/muse.c b/src/muse.c index c7f5fc4a8..d1c007f13 100644 --- a/src/muse.c +++ b/src/muse.c @@ -621,8 +621,7 @@ find_defensive(struct monst *mtmp, boolean tryescape) && !(levl[x][y].wall_info & W_NONDIGGABLE) && !(Is_botlevel(&u.uz) || In_endgame(&u.uz)) && !(is_ice(x, y) || is_pool(x, y) || is_lava(x, y)) - && !(mtmp->data == &mons[PM_VLAD_THE_IMPALER] - && In_V_tower(&u.uz))) { + && !(is_Vlad(mtmp) && In_V_tower(&u.uz))) { gm.m.defensive = obj; gm.m.has_defense = MUSE_WAN_DIGGING; }