From f131942dd29b0d4b37a2d5df2394e4a2f036acd2 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 24 Mar 2024 10:48:26 +0200 Subject: [PATCH] Another tamedog message Give a different message when a peaceful creature was tamed. Allow suppressing this and the previous message, when the caller handles messaging. --- include/extern.h | 2 +- src/dog.c | 10 ++++++++-- src/dothrow.c | 2 +- src/makemon.c | 2 +- src/music.c | 2 +- src/potion.c | 2 +- src/read.c | 4 ++-- src/spell.c | 2 +- src/timeout.c | 2 +- src/trap.c | 2 +- src/uhitm.c | 2 +- src/were.c | 2 +- src/zap.c | 2 +- 13 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/extern.h b/include/extern.h index 113d42a9a..2f9bb949c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -735,7 +735,7 @@ extern void keepdogs(boolean); extern void migrate_to_level(struct monst *, xint16, xint16, coord *) NONNULLARG1; extern void discard_migrations(void); extern int dogfood(struct monst *, struct obj *) NONNULLPTRS; -extern boolean tamedog(struct monst *, struct obj *) NONNULLARG1; +extern boolean tamedog(struct monst *, struct obj *, boolean) NONNULLARG1; extern void abuse_dog(struct monst *) NONNULLARG1; extern void wary_dog(struct monst *, boolean) NONNULLARG1; diff --git a/src/dog.c b/src/dog.c index 4896e7b09..a856c4a05 100644 --- a/src/dog.c +++ b/src/dog.c @@ -1069,7 +1069,7 @@ dogfood(struct monst *mon, struct obj *obj) * on the original mtmp. It now returns TRUE if the taming succeeded. */ boolean -tamedog(struct monst *mtmp, struct obj *obj) +tamedog(struct monst *mtmp, struct obj *obj, boolean givemsg) { /* reduce timed sleep or paralysis, leaving mtmp->mcanmove as-is (note: if mtmp is donning armor, this will reduce its busy time) */ @@ -1085,9 +1085,11 @@ tamedog(struct monst *mtmp, struct obj *obj) return FALSE; /* worst case, at least it'll be peaceful. */ - if (!mtmp->mpeaceful && canspotmon(mtmp)) + if (givemsg && !mtmp->mpeaceful && canspotmon(mtmp)) { pline("%s seems %s.", Monnam(mtmp), Hallucination ? "really chill" : "more amiable"); + givemsg = FALSE; /* don't give another message below */ + } mtmp->mpeaceful = 1; set_malign(mtmp); if (flags.moonphase == FULL_MOON && night() && rn2(6) && obj @@ -1173,6 +1175,10 @@ tamedog(struct monst *mtmp, struct obj *obj) /* `obj' is now obsolete */ } + if (givemsg && canspotmon(mtmp)) + pline("%s seems quite %s.", Monnam(mtmp), + Hallucination ? "approachable" : "friendly"); + newsym(mtmp->mx, mtmp->my); if (attacktype(mtmp->data, AT_WEAP)) { mtmp->weapon_check = NEED_HTH_WEAPON; diff --git a/src/dothrow.c b/src/dothrow.c index 0b7b52b70..c1afb4b29 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -2220,7 +2220,7 @@ thitmonst( } else if (befriend_with_obj(mon->data, obj) || (mon->mtame && dogfood(mon, obj) <= ACCFOOD)) { - if (tamedog(mon, obj)) { + if (tamedog(mon, obj, TRUE)) { return 1; /* obj is gone */ } else { tmiss(obj, mon, FALSE); diff --git a/src/makemon.c b/src/makemon.c index 48fc326a7..d99649229 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -915,7 +915,7 @@ clone_mon(struct monst *mon, However, tamedog() will not re-tame a tame dog, so m2 must be made non-tame to get initialized properly. */ m2->mtame = 0; - if (tamedog(m2, (struct obj *) 0)) { + if (tamedog(m2, (struct obj *) 0, FALSE)) { assert(has_edog(m2) && has_edog(mon)); *EDOG(m2) = *EDOG(mon); } diff --git a/src/music.c b/src/music.c index ce4510321..740b3dc77 100644 --- a/src/music.c +++ b/src/music.c @@ -210,7 +210,7 @@ charm_monsters(int distance) one; do that even if mtmp resists in order to behave the same as a non-cursed scroll of taming or spell of charm monster */ if (!resist(mtmp, TOOL_CLASS, 0, NOTELL) || mtmp->isshk) - (void) tamedog(mtmp, (struct obj *) 0); + (void) tamedog(mtmp, (struct obj *) 0, TRUE); } } } diff --git a/src/potion.c b/src/potion.c index be7e7f80d..9f5d0c722 100644 --- a/src/potion.c +++ b/src/potion.c @@ -2789,7 +2789,7 @@ djinni_from_bottle(struct obj *obj) break; case 1: verbalize("Thank you for freeing me!"); - (void) tamedog(mtmp, (struct obj *) 0); + (void) tamedog(mtmp, (struct obj *) 0, FALSE); break; case 2: verbalize("You freed me!"); diff --git a/src/read.c b/src/read.c index c2bbc5b41..025829463 100644 --- a/src/read.c +++ b/src/read.c @@ -1037,7 +1037,7 @@ maybe_tame(struct monst *mtmp, struct obj *sobj) /* for a shopkeeper, tamedog() will call make_happy_shk() but not tame the target, so call it even if taming gets resisted */ if (!resist(mtmp, sobj->oclass, 0, NOTELL) || mtmp->isshk) - (void) tamedog(mtmp, (struct obj *) 0); + (void) tamedog(mtmp, (struct obj *) 0, FALSE); if ((!was_peaceful && mtmp->mpeaceful) || (!was_tame && mtmp->mtame)) return 1; } @@ -3194,7 +3194,7 @@ create_particular_creation( } mx = mtmp->mx, my = mtmp->my; if (d->maketame) { - (void) tamedog(mtmp, (struct obj *) 0); + (void) tamedog(mtmp, (struct obj *) 0, FALSE); } else if (d->makepeaceful || d->makehostile) { mtmp->mtame = 0; /* sanity precaution */ mtmp->mpeaceful = d->makepeaceful ? 1 : 0; diff --git a/src/spell.c b/src/spell.c index 47ce6633f..d032817c8 100644 --- a/src/spell.c +++ b/src/spell.c @@ -218,7 +218,7 @@ deadbook_pacify_undead(struct monst *mtmp) if (mtmp->mtame < 20) mtmp->mtame++; } else - (void) tamedog(mtmp, (struct obj *) 0); + (void) tamedog(mtmp, (struct obj *) 0, TRUE); else monflee(mtmp, 0, FALSE, TRUE); } diff --git a/src/timeout.c b/src/timeout.c index 69f72999d..6447f94fa 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1004,7 +1004,7 @@ hatch_egg(anything *arg, long timeout) while it's in your inventory */ if ((yours && !silent) || (carried(egg) && mon->data->mlet == S_DRAGON)) { - if (tamedog(mon, (struct obj *) 0)) { + if (tamedog(mon, (struct obj *) 0, FALSE)) { if (carried(egg) && mon->data->mlet != S_DRAGON) mon->mtame = 20; } diff --git a/src/trap.c b/src/trap.c index 15633bd87..356771b60 100644 --- a/src/trap.c +++ b/src/trap.c @@ -4228,7 +4228,7 @@ domagictrap(void) continue; mtmp = m_at(u.ux + i, u.uy + j); if (mtmp) - (void) tamedog(mtmp, (struct obj *) 0); + (void) tamedog(mtmp, (struct obj *) 0, TRUE); } break; } diff --git a/src/uhitm.c b/src/uhitm.c index 2fdb59841..3e6f75ccf 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -2047,7 +2047,7 @@ demonpet(void) i = !rn2(6) ? ndemon(u.ualign.type) : NON_PM; pm = i != NON_PM ? &mons[i] : gy.youmonst.data; if ((dtmp = makemon(pm, u.ux, u.uy, NO_MM_FLAGS)) != 0) - (void) tamedog(dtmp, (struct obj *) 0); + (void) tamedog(dtmp, (struct obj *) 0, FALSE); exercise(A_WIS, TRUE); } diff --git a/src/were.c b/src/were.c index 563225810..196c66c4d 100644 --- a/src/were.c +++ b/src/were.c @@ -175,7 +175,7 @@ were_summon( *visible += 1; } if (yours && mtmp) - (void) tamedog(mtmp, (struct obj *) 0); + (void) tamedog(mtmp, (struct obj *) 0, FALSE); } return total; } diff --git a/src/zap.c b/src/zap.c index d13695a26..8b1c9f863 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1037,7 +1037,7 @@ revive(struct obj *corpse, boolean by_hero) } /* tame the revived monster if its ghost was tame */ if (ghost->mtame && !mtmp->mtame) { - if (tamedog(mtmp, (struct obj *) 0)) { + if (tamedog(mtmp, (struct obj *) 0, FALSE)) { /* ghost's edog data is ignored */ mtmp->mtame = ghost->mtame; }