diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index c6d0a154f..183fa644d 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1510,6 +1510,7 @@ if a tree and a boulder or statue were at the same location, applying an axe would break the boulder or statue rather than chop the tree avoid premapping outside Sokoban map to prevent showing stone glyphs Grimtooth is permanently poisoned, protects from poison, and can fling poison +cursed magic whistle can teleport you to your pet Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index f6bfe2e43..459b452c9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3124,6 +3124,7 @@ extern int collect_coords(coord *, coordxy, coordxy, int, unsigned, boolean (*)(coordxy, coordxy)) NONNULLARG1; extern boolean safe_teleds(int); extern boolean teleport_pet(struct monst *, boolean) NONNULLARG1; +extern void tele_to_rnd_pet(void); extern void tele(void); extern void scrolltele(struct obj *) NO_NNARGS; extern int dotelecmd(void); diff --git a/src/apply.c b/src/apply.c index 6bf45b266..3af75ce59 100644 --- a/src/apply.c +++ b/src/apply.c @@ -498,6 +498,8 @@ use_magic_whistle(struct obj *obj) You("produce a %shigh-%s.", Underwater ? "very " : "", Deaf ? "frequency vibration" : "pitched humming noise"); wake_nearby(TRUE); + if (!rn2(2)) + tele_to_rnd_pet(); } else { /* it's magic! it works underwater too (at a higher pitch) */ You(Deaf ? alt_whistle_str : whistle_str, diff --git a/src/teleport.c b/src/teleport.c index 3088c461c..3c3d6df3e 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -804,6 +804,28 @@ teleport_pet(struct monst *mtmp, boolean force_it) return TRUE; } +/* teleport to random pet, if valid location next to it */ +void +tele_to_rnd_pet(void) +{ + struct monst *mtmp, *pet = (struct monst *) 0; + int cnt = 0; + + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) + if (!DEADMONSTER(mtmp) && mtmp->mtame && !mon_offmap(mtmp)) { + cnt++; + if (!rn2(cnt)) + pet = mtmp; + } + if (pet && !m_next2u(pet)) { + coordxy tx = pet->mx + rn2(3) - 1, + ty = pet->my + rn2(3) - 1; + + if (isok(tx, ty) && teleok(tx, ty, FALSE)) + teleds(tx, ty, TELEDS_TELEPORT); + } +} + /* teleport the hero via some method other than scroll of teleport */ void tele(void)