1 /* NetHack 3.6 read.c $NHDT-Date: 1457660917 2016/03/11 01:48:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.136 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
7 #define Your_Own_Role(mndx) \
8 ((mndx) == urole.malenum \
9 || (urole.femalenum != NON_PM && (mndx) == urole.femalenum))
10 #define Your_Own_Race(mndx) \
11 ((mndx) == urace.malenum \
12 || (urace.femalenum != NON_PM && (mndx) == urace.femalenum))
16 static NEARDATA
const char readable
[] = { ALL_CLASSES
, SCROLL_CLASS
,
18 static const char all_count
[] = { ALLOW_COUNT
, ALL_CLASSES
, 0 };
20 STATIC_DCL boolean
FDECL(learnscrolltyp
, (SHORT_P
));
21 STATIC_DCL
char * FDECL(erode_obj_text
, (struct obj
*, char *));
22 STATIC_DCL
void NDECL(do_class_genocide
);
23 STATIC_DCL
void FDECL(stripspe
, (struct obj
*));
24 STATIC_DCL
void FDECL(p_glow1
, (struct obj
*));
25 STATIC_DCL
void FDECL(p_glow2
, (struct obj
*, const char *));
26 STATIC_DCL
void FDECL(randomize
, (int *, int));
27 STATIC_DCL
void FDECL(forget_single_object
, (int));
28 STATIC_DCL
void FDECL(forget
, (int));
29 STATIC_DCL
int FDECL(maybe_tame
, (struct monst
*, struct obj
*));
30 STATIC_DCL boolean
FDECL(is_valid_stinking_cloud_pos
, (int, int, BOOLEAN_P
));
31 STATIC_DCL
void FDECL(display_stinking_cloud_positions
, (int));
32 STATIC_PTR
void FDECL(set_lit
, (int, int, genericptr
));
35 learnscrolltyp(scrolltyp
)
38 if (!objects
[scrolltyp
].oc_name_known
) {
40 more_experienced(0, 10);
46 /* also called from teleport.c for scroll of teleportation */
51 /* it's implied that sobj->dknown is set;
52 we couldn't be reading this scroll otherwise */
53 if (sobj
->oclass
!= SPBOOK_CLASS
)
54 (void) learnscrolltyp(sobj
->otyp
);
58 erode_obj_text(otmp
, buf
)
62 int erosion
= greatest_erosion(otmp
);
65 wipeout_text(buf
, (int) (strlen(buf
) * erosion
/ (2 * MAX_ERODE
)),
66 otmp
->o_id
^ (unsigned) ubirthday
);
71 tshirt_text(tshirt
, buf
)
75 static const char *shirt_msgs
[] = {
77 "I explored the Dungeons of Doom and all I got was this lousy T-shirt!",
78 "Is that Mjollnir in your pocket or are you just happy to see me?",
79 "It's not the size of your sword, it's how #enhance'd you are with it.",
80 "Madame Elvira's House O' Succubi Lifetime Customer",
81 "Madame Elvira's House O' Succubi Employee of the Month",
82 "Ludios Vault Guards Do It In Small, Dark Rooms",
83 "Yendor Military Soldiers Do It In Large Groups",
84 "I survived Yendor Military Boot Camp",
85 "Ludios Accounting School Intra-Mural Lacrosse Team",
86 "Oracle(TM) Fountains 10th Annual Wet T-Shirt Contest",
87 "Hey, black dragon! Disintegrate THIS!",
88 "I'm With Stupid -->",
89 "Don't blame me, I voted for Izchak!",
90 "Don't Panic", /* HHGTTG */
91 "Furinkan High School Athletic Dept.", /* Ranma 1/2 */
92 "Hel-LOOO, Nurse!", /* Animaniacs */
94 "100% goblin hair - do not wash",
95 "Aberzombie and Fitch",
96 "cK -- Cockatrice touches the Kop",
97 "Don't ask me, I only adventure here",
99 "d, your dog or a killer?",
100 "FREE PUG AND NEWT!",
103 "Hello, my darlings!", /* Charlie Drake */
104 "Hey! Nymphs! Steal This T-Shirt!",
105 "I <3 Dungeon of Doom",
107 "I am a Valkyrie. If you see me running, try to keep up.",
108 "I am not a pack rat - I am a collector",
109 "I bounced off a rubber tree", /* Monkey Island */
110 "Plunder Island Brimstone Beach Club", /* Monkey Island */
111 "If you can read this, I can hit you with my polearm",
113 "I scored with the princess",
114 "I want to live forever or die in the attempt.",
116 "LOST IN THOUGHT - please send search party",
118 "Minetown Better Business Bureau",
120 "Ms. Palm's House of Negotiable Affection -- A Very Reputable House Of Disrepute",
121 "Protection Racketeer",
122 "Real men love Crom",
123 "Somebody stole my Mojo!",
124 "The Hellhound Gang",
126 "They Might Be Storm Giants",
127 "Weapons don't kill people, I kill people",
129 "You're killing me!",
130 "Anhur State University - Home of the Fighting Fire Ants!",
133 "Real men are valkyries",
134 "Young Men's Cavedigging Association",
135 "Occupy Fort Ludios",
136 "I couldn't afford this T-shirt so I stole it!",
138 "I'm not wearing any pants",
139 "Down with the living!",
145 Strcpy(buf
, shirt_msgs
[tshirt
->o_id
% SIZE(shirt_msgs
)]);
146 return erode_obj_text(tshirt
, buf
);
150 apron_text(apron
, buf
)
154 static const char *apron_msgs
[] = {
156 "I'm making SCIENCE!",
157 "Don't mess with the chef",
158 "Don't make me poison you",
159 "Gehennom's Kitchen",
160 "Rat: The other white meat",
161 "If you can't stand the heat, get out of Gehennom!",
162 "If we weren't meant to eat animals, why are they made out of meat?",
163 "If you don't like the food, I'll stab you",
166 Strcpy(buf
, apron_msgs
[apron
->o_id
% SIZE(apron_msgs
)]);
167 return erode_obj_text(apron
, buf
);
173 register struct obj
*scroll
;
174 boolean confused
, nodisappear
;
177 if (check_capacity((char *) 0))
179 scroll
= getobj(readable
, "read");
183 /* outrumor has its own blindness check */
184 if (scroll
->otyp
== FORTUNE_COOKIE
) {
186 You("break up the cookie and throw away the pieces.");
187 outrumor(bcsign(scroll
), BY_COOKIE
);
189 u
.uconduct
.literate
++;
192 } else if (scroll
->otyp
== T_SHIRT
|| scroll
->otyp
== ALCHEMY_SMOCK
) {
195 You_cant("feel any Braille writing.");
198 /* can't read shirt worn under suit (under cloak is ok though) */
199 if (scroll
->otyp
== T_SHIRT
&& uarm
&& scroll
== uarmu
) {
200 pline("%s shirt is obscured by %s%s.",
201 scroll
->unpaid
? "That" : "Your", shk_your(buf
, uarm
),
202 suit_simple_name(uarm
));
205 u
.uconduct
.literate
++;
208 pline("\"%s\"", (scroll
->otyp
== T_SHIRT
) ? tshirt_text(scroll
, buf
)
209 : apron_text(scroll
, buf
));
211 } else if (scroll
->otyp
== CREDIT_CARD
) {
212 static const char *card_msgs
[] = {
213 "Leprechaun Gold Tru$t - Shamrock Card",
214 "Magic Memory Vault Charge Card", "Larn National Bank", /* Larn */
215 "First Bank of Omega", /* Omega */
216 "Bank of Zork - Frobozz Magic Card", /* Zork */
217 "Ankh-Morpork Merchant's Guild Barter Card",
218 "Ankh-Morpork Thieves' Guild Unlimited Transaction Card",
219 "Ransmannsby Moneylenders Association",
220 "Bank of Gehennom - 99% Interest Card",
221 "Yendorian Express - Copper Card",
222 "Yendorian Express - Silver Card",
223 "Yendorian Express - Gold Card",
224 "Yendorian Express - Mithril Card",
225 "Yendorian Express - Platinum Card", /* must be last */
229 You("feel the embossed numbers:");
235 ? card_msgs
[SIZE(card_msgs
) - 1]
236 : card_msgs
[scroll
->o_id
% (SIZE(card_msgs
) - 1)]);
238 /* Make a credit card number */
239 pline("\"%d0%d %d%d1 0%d%d0\"", ((scroll
->o_id
% 89) + 10),
240 (scroll
->o_id
% 4), (((scroll
->o_id
* 499) % 899999) + 100000),
241 (scroll
->o_id
% 10), (!(scroll
->o_id
% 3)),
242 ((scroll
->o_id
* 7) % 10));
243 u
.uconduct
.literate
++;
245 } else if (scroll
->otyp
== CAN_OF_GREASE
) {
246 pline("This %s has no label.", singular(scroll
, xname
));
248 } else if (scroll
->otyp
== MAGIC_MARKER
) {
250 You_cant("feel any Braille writing.");
255 pline("\"Magic Marker(TM) Red Ink Marker Pen. Water Soluble.\"");
256 u
.uconduct
.literate
++;
258 } else if (scroll
->oclass
== COIN_CLASS
) {
260 You("feel the embossed words:");
261 else if (flags
.verbose
)
263 pline("\"1 Zorkmid. 857 GUE. In Frobs We Trust.\"");
264 u
.uconduct
.literate
++;
266 } else if (scroll
->oartifact
== ART_ORB_OF_FATE
) {
268 You("feel the engraved signature:");
270 pline("It is signed:");
272 u
.uconduct
.literate
++;
274 } else if (scroll
->otyp
== CANDY_BAR
) {
275 static const char *wrapper_msgs
[] = {
277 "Moon Crunchy", /* South Park */
278 "Snacky Cake", "Chocolate Nuggie", "The Small Bar",
279 "Crispy Yum Yum", "Nilla Crunchie", "Berry Bar",
280 "Choco Nummer", "Om-nom", /* Cat Macro */
281 "Fruity Oaty", /* Serenity */
282 "Wonka Bar" /* Charlie and the Chocolate Factory */
286 You_cant("feel any Braille writing.");
289 pline("The wrapper reads: \"%s\"",
290 wrapper_msgs
[scroll
->o_id
% SIZE(wrapper_msgs
)]);
291 u
.uconduct
.literate
++;
293 } else if (scroll
->oclass
!= SCROLL_CLASS
294 && scroll
->oclass
!= SPBOOK_CLASS
) {
295 pline(silly_thing_to
, "read");
297 } else if (Blind
&& (scroll
->otyp
!= SPE_BOOK_OF_THE_DEAD
)) {
298 const char *what
= 0;
299 if (scroll
->oclass
== SPBOOK_CLASS
)
300 what
= "mystic runes";
301 else if (!scroll
->dknown
)
302 what
= "formula on the scroll";
304 pline("Being blind, you cannot read the %s.", what
);
309 confused
= (Confusion
!= 0);
311 if (scroll
->otyp
== SCR_MAIL
) {
312 confused
= FALSE
; /* override */
313 /* reading mail is a convenience for the player and takes
314 place outside the game, so shouldn't affect gameplay;
315 on the other hand, it starts by explicitly making the
316 hero actively read something, which is pretty hard
317 to simply ignore; as a compromise, if the player has
318 maintained illiterate conduct so far, and this mail
319 scroll didn't come from bones, ask for confirmation */
320 if (!u
.uconduct
.literate
) {
321 if (!scroll
->spe
&& yn(
322 "Reading mail will violate \"illiterate\" conduct. Read anyway?"
329 /* Actions required to win the game aren't counted towards conduct */
330 /* Novel conduct is handled in read_tribute so exclude it too*/
331 if (scroll
->otyp
!= SPE_BOOK_OF_THE_DEAD
332 && scroll
->otyp
!= SPE_BLANK_PAPER
&& scroll
->otyp
!= SCR_BLANK_PAPER
333 && scroll
->otyp
!= SPE_NOVEL
)
334 u
.uconduct
.literate
++;
336 if (scroll
->oclass
== SPBOOK_CLASS
) {
337 return study_book(scroll
);
339 scroll
->in_use
= TRUE
; /* scroll, not spellbook, now being read */
340 if (scroll
->otyp
!= SCR_BLANK_PAPER
) {
341 /* a few scroll feedback messages describe something happening
342 to the scroll itself, so avoid "it disappears" for those */
343 nodisappear
= (scroll
->otyp
== SCR_FIRE
344 || (scroll
->otyp
== SCR_REMOVE_CURSE
348 ? "You %s the formula on the scroll."
349 : "As you %s the formula on it, the scroll disappears.",
350 is_silent(youmonst
.data
) ? "cogitate" : "pronounce");
352 pline(nodisappear
? "You read the scroll."
353 : "As you read the scroll, it disappears.");
356 pline("Being so trippy, you screw up...");
358 pline("Being confused, you %s the magic words...",
359 is_silent(youmonst
.data
) ? "misunderstand"
363 if (!seffects(scroll
)) {
364 if (!objects
[scroll
->otyp
].oc_name_known
) {
367 else if (!objects
[scroll
->otyp
].oc_uname
)
370 scroll
->in_use
= FALSE
;
371 if (scroll
->otyp
!= SCR_BLANK_PAPER
)
379 register struct obj
*obj
;
381 if (obj
->blessed
|| obj
->spe
<= 0) {
382 pline1(nothing_happens
);
384 /* order matters: message, shop handling, actual transformation */
385 pline("%s briefly.", Yobjnam2(obj
, "vibrate"));
386 costly_alteration(obj
, COST_UNCHRG
);
388 if (obj
->otyp
== OIL_LAMP
|| obj
->otyp
== BRASS_LANTERN
)
395 register struct obj
*otmp
;
397 pline("%s briefly.", Yobjnam2(otmp
, Blind
? "vibrate" : "glow"));
402 register struct obj
*otmp
;
403 register const char *color
;
405 pline("%s%s%s for a moment.", Yobjnam2(otmp
, Blind
? "vibrate" : "glow"),
406 Blind
? "" : " ", Blind
? "" : hcolor(color
));
409 /* Is the object chargeable? For purposes of inventory display; it is
410 possible to be able to charge things for which this returns FALSE. */
415 if (obj
->oclass
== WAND_CLASS
)
417 /* known && !oc_name_known is possible after amnesia/mind flayer */
418 if (obj
->oclass
== RING_CLASS
)
419 return (boolean
) (objects
[obj
->otyp
].oc_charged
422 && objects
[obj
->otyp
].oc_name_known
)));
423 if (is_weptool(obj
)) /* specific check before general tools */
425 if (obj
->oclass
== TOOL_CLASS
)
426 return (boolean
) objects
[obj
->otyp
].oc_charged
;
427 return FALSE
; /* why are weapons/armor considered charged anyway? */
430 /* recharge an object; curse_bless is -1 if the recharging implement
431 was cursed, +1 if blessed, 0 otherwise. */
433 recharge(obj
, curse_bless
)
438 boolean is_cursed
, is_blessed
;
440 is_cursed
= curse_bless
< 0;
441 is_blessed
= curse_bless
> 0;
443 if (obj
->oclass
== WAND_CLASS
) {
444 int lim
= (obj
->otyp
== WAN_WISHING
)
446 : (objects
[obj
->otyp
].oc_dir
!= NODIR
) ? 8 : 15;
448 /* undo any prior cancellation, even when is_cursed */
453 * Recharging might cause wands to explode.
454 * v = number of previous recharges
455 * v = percentage chance to explode on this attempt
456 * v = cumulative odds for exploding
466 n
= (int) obj
->recharged
;
467 if (n
> 0 && (obj
->otyp
== WAN_WISHING
468 || (n
* n
* n
> rn2(7 * 7 * 7)))) { /* recharge_limit */
469 wand_explode(obj
, rnd(lim
));
472 /* didn't explode, so increment the recharge count */
473 obj
->recharged
= (unsigned) (n
+ 1);
475 /* now handle the actual recharging */
479 n
= (lim
== 3) ? 3 : rn1(5, lim
+ 1 - 5);
487 if (obj
->otyp
== WAN_WISHING
&& obj
->spe
> 3) {
488 wand_explode(obj
, 1);
492 p_glow2(obj
, NH_BLUE
);
495 #if 0 /*[shop price doesn't vary by charge count]*/
496 /* update shop bill to reflect new higher price */
502 } else if (obj
->oclass
== RING_CLASS
&& objects
[obj
->otyp
].oc_charged
) {
503 /* charging does not affect ring's curse/bless status */
504 int s
= is_blessed
? rnd(3) : is_cursed
? -rnd(2) : 1;
505 boolean is_on
= (obj
== uleft
|| obj
== uright
);
507 /* destruction depends on current state, not adjustment */
508 if (obj
->spe
> rn2(7) || obj
->spe
<= -5) {
509 pline("%s momentarily, then %s!", Yobjnam2(obj
, "pulsate"),
510 otense(obj
, "explode"));
513 s
= rnd(3 * abs(obj
->spe
)); /* amount of damage */
515 losehp(Maybe_Half_Phys(s
), "exploding ring", KILLED_BY_AN
);
517 long mask
= is_on
? (obj
== uleft
? LEFT_RING
: RIGHT_RING
) : 0L;
519 pline("%s spins %sclockwise for a moment.", Yname2(obj
),
520 s
< 0 ? "counter" : "");
522 costly_alteration(obj
, COST_DECHNT
);
523 /* cause attributes and/or properties to be updated */
526 obj
->spe
+= s
; /* update the ring while it's off */
528 setworn(obj
, mask
), Ring_on(obj
);
529 /* oartifact: if a touch-sensitive artifact ring is
530 ever created the above will need to be revised */
531 /* update shop bill to reflect new higher price */
532 if (s
> 0 && obj
->unpaid
)
536 } else if (obj
->oclass
== TOOL_CLASS
) {
537 int rechrg
= (int) obj
->recharged
;
539 if (objects
[obj
->otyp
].oc_charged
) {
540 /* tools don't have a limit, but the counter used does */
541 if (rechrg
< 7) /* recharge_limit */
545 case BELL_OF_OPENING
:
557 case EXPENSIVE_CAMERA
:
562 == MAGIC_MARKER
) { /* previously recharged */
563 obj
->recharged
= 1; /* override increment done above */
565 Your("marker seems permanently dried out.");
567 pline1(nothing_happens
);
568 } else if (is_blessed
) {
569 n
= rn1(16, 15); /* 15..30 */
570 if (obj
->spe
+ n
<= 50)
572 else if (obj
->spe
+ n
<= 75)
575 int chrg
= (int) obj
->spe
;
576 if ((chrg
+ n
) > 127)
581 p_glow2(obj
, NH_BLUE
);
583 n
= rn1(11, 10); /* 10..20 */
584 if (obj
->spe
+ n
<= 50)
587 int chrg
= (int) obj
->spe
;
588 if ((chrg
+ n
) > 127)
593 p_glow2(obj
, NH_WHITE
);
602 pline("%s out!", Tobjnam(obj
, "go"));
605 } else if (is_blessed
) {
608 p_glow2(obj
, NH_BLUE
);
620 } else if (is_blessed
) {
622 p_glow2(obj
, NH_BLUE
);
628 pline1(nothing_happens
);
636 } else if (is_blessed
) {
638 obj
->spe
+= rn1(10, 6);
640 obj
->spe
+= rn1(5, 6);
643 p_glow2(obj
, NH_BLUE
);
655 case DRUM_OF_EARTHQUAKE
:
658 } else if (is_blessed
) {
662 p_glow2(obj
, NH_BLUE
);
678 You("have a feeling of loss.");
682 /* Forget known information about this object type. */
684 forget_single_object(obj_id
)
687 objects
[obj_id
].oc_name_known
= 0;
688 objects
[obj_id
].oc_pre_discovered
= 0; /* a discovery when relearned */
689 if (objects
[obj_id
].oc_uname
) {
690 free((genericptr_t
) objects
[obj_id
].oc_uname
);
691 objects
[obj_id
].oc_uname
= 0;
693 undiscover_object(obj_id
); /* after clearing oc_name_known */
695 /* clear & free object names from matching inventory items too? */
698 #if 0 /* here if anyone wants it.... */
699 /* Forget everything known about a particular object class. */
701 forget_objclass(oclass
)
706 for (i
= bases
[oclass
];
707 i
< NUM_OBJECTS
&& objects
[i
].oc_class
== oclass
; i
++)
708 forget_single_object(i
);
712 /* randomize the given list of numbers 0 <= i < count */
714 randomize(indices
, count
)
720 for (i
= count
- 1; i
> 0; i
--) {
721 if ((iswap
= rn2(i
+ 1)) == i
)
724 indices
[i
] = indices
[iswap
];
725 indices
[iswap
] = temp
;
729 /* Forget % of known objects. */
731 forget_objects(percent
)
735 int indices
[NUM_OBJECTS
];
739 if (percent
<= 0 || percent
> 100) {
740 impossible("forget_objects: bad percent %d", percent
);
744 indices
[0] = 0; /* lint suppression */
745 for (count
= 0, i
= 1; i
< NUM_OBJECTS
; i
++)
746 if (OBJ_DESCR(objects
[i
])
747 && (objects
[i
].oc_name_known
|| objects
[i
].oc_uname
))
748 indices
[count
++] = i
;
751 randomize(indices
, count
);
753 /* forget first % of randomized indices */
754 count
= ((count
* percent
) + rn2(100)) / 100;
755 for (i
= 0; i
< count
; i
++)
756 forget_single_object(indices
[i
]);
760 /* Forget some or all of map (depends on parameters). */
771 for (zx
= 0; zx
< COLNO
; zx
++)
772 for (zy
= 0; zy
< ROWNO
; zy
++)
773 if (howmuch
& ALL_MAP
|| rn2(7)) {
774 /* Zonk all memory of this location. */
775 levl
[zx
][zy
].seenv
= 0;
776 levl
[zx
][zy
].waslit
= 0;
777 levl
[zx
][zy
].glyph
= cmap_to_glyph(S_stone
);
778 lastseentyp
[zx
][zy
] = STONE
;
780 /* forget overview data for this level */
781 forget_mapseen(ledger_no(&u
.uz
));
784 /* Forget all traps on the level. */
788 register struct trap
*trap
;
790 /* forget all traps (except the one the hero is in :-) */
791 for (trap
= ftrap
; trap
; trap
= trap
->ntrap
)
792 if ((trap
->tx
!= u
.ux
|| trap
->ty
!= u
.uy
) && (trap
->ttyp
!= HOLE
))
797 * Forget given % of all levels that the hero has visited and not forgotten,
801 forget_levels(percent
)
805 xchar maxl
, this_lev
;
806 int indices
[MAXLINFO
];
811 if (percent
<= 0 || percent
> 100) {
812 impossible("forget_levels: bad percent %d", percent
);
816 this_lev
= ledger_no(&u
.uz
);
817 maxl
= maxledgerno();
819 /* count & save indices of non-forgotten visited levels */
820 /* Sokoban levels are pre-mapped for the player, and should stay
821 * so, or they become nearly impossible to solve. But try to
822 * shift the forgetting elsewhere by fiddling with percent
823 * instead of forgetting fewer levels.
825 indices
[0] = 0; /* lint suppression */
826 for (count
= 0, i
= 0; i
<= maxl
; i
++)
827 if ((level_info
[i
].flags
& VISITED
)
828 && !(level_info
[i
].flags
& FORGOTTEN
) && i
!= this_lev
) {
829 if (ledger_to_dnum(i
) == sokoban_dnum
)
832 indices
[count
++] = i
;
839 randomize(indices
, count
);
841 /* forget first % of randomized indices */
842 count
= ((count
* percent
) + 50) / 100;
843 for (i
= 0; i
< count
; i
++) {
844 level_info
[indices
[i
]].flags
|= FORGOTTEN
;
845 forget_mapseen(indices
[i
]);
851 * Forget some things (e.g. after reading a scroll of amnesia). When called,
852 * the following are always forgotten:
853 * - felt ball & chain
855 * - part (6 out of 7) of the map
857 * Other things are subject to flags:
858 * howmuch & ALL_MAP = forget whole map
859 * howmuch & ALL_SPELLS = forget all spells
866 u
.bc_felt
= 0; /* forget felt ball&chain */
871 /* 1 in 3 chance of forgetting some levels */
873 forget_levels(rn2(25));
875 /* 1 in 3 chance of forgetting some objects */
877 forget_objects(rn2(25));
879 if (howmuch
& ALL_SPELLS
)
882 * Make sure that what was seen is restored correctly. To do this,
883 * we need to go blind for an instant --- turn off the display,
884 * then restart it. All this work is needed to correctly handle
885 * walls which are stone on one side and wall on the other. Turning
886 * off the seen bits above will make the wall revert to stone, but
887 * there are cases where we don't want this to happen. The easiest
888 * thing to do is to run it through the vision system again, which
891 docrt(); /* this correctly will reset vision */
894 /* monster is hit by scroll of taming's effect */
896 maybe_tame(mtmp
, sobj
)
900 int was_tame
= mtmp
->mtame
;
901 unsigned was_peaceful
= mtmp
->mpeaceful
;
905 if (was_peaceful
&& !mtmp
->mpeaceful
)
909 make_happy_shk(mtmp
, FALSE
);
910 else if (!resist(mtmp
, sobj
->oclass
, 0, NOTELL
))
911 (void) tamedog(mtmp
, (struct obj
*) 0);
912 if ((!was_peaceful
&& mtmp
->mpeaceful
) || (!was_tame
&& mtmp
->mtame
))
919 is_valid_stinking_cloud_pos(x
, y
, showmsg
)
923 if (!cansee(x
, y
) || !ACCESSIBLE(levl
[x
][y
].typ
) || distu(x
, y
) >= 32) {
925 You("smell rotten eggs.");
932 display_stinking_cloud_positions(state
)
936 tmp_at(DISP_BEAM
, cmap_to_glyph(S_goodpos
));
937 } else if (state
== 1) {
941 for (dx
= -dist
; dx
<= dist
; dx
++)
942 for (dy
= -dist
; dy
<= dist
; dy
++) {
945 if (isok(x
, y
) && is_valid_stinking_cloud_pos(x
, y
, FALSE
))
953 /* scroll effects; return 1 if we use up the scroll and possibly make it
954 become discovered, 0 if caller should take care of those side-effects */
957 struct obj
*sobj
; /* scroll, or fake spellbook object for scroll-like spell */
959 int cval
, otyp
= sobj
->otyp
;
960 boolean confused
= (Confusion
!= 0), sblessed
= sobj
->blessed
,
961 scursed
= sobj
->cursed
, already_known
, old_erodeproof
,
965 if (objects
[otyp
].oc_magic
)
966 exercise(A_WIS
, TRUE
); /* just for trying */
967 already_known
= (sobj
->oclass
== SPBOOK_CLASS
/* spell */
968 || objects
[otyp
].oc_name_known
);
975 /* "stamped scroll" created via magic marker--without a stamp */
976 pline("This scroll is marked \"postage due\".");
978 /* scroll of mail obtained from bones file or from wishing;
979 * note to the puzzled: the game Larn actually sends you junk
983 "This seems to be junk mail addressed to the finder of the Eye of Larn.");
988 case SCR_ENCHANT_ARMOR
: {
990 boolean special_armor
;
993 otmp
= some_armor(&youmonst
);
995 strange_feeling(sobj
, !Blind
996 ? "Your skin glows then fades."
997 : "Your skin feels warm for a moment.");
998 sobj
= 0; /* useup() in strange_feeling() */
999 exercise(A_CON
, !scursed
);
1000 exercise(A_STR
, !scursed
);
1004 old_erodeproof
= (otmp
->oerodeproof
!= 0);
1005 new_erodeproof
= !scursed
;
1006 otmp
->oerodeproof
= 0; /* for messages */
1008 otmp
->rknown
= FALSE
;
1009 pline("%s warm for a moment.", Yobjnam2(otmp
, "feel"));
1011 otmp
->rknown
= TRUE
;
1012 pline("%s covered by a %s %s %s!", Yobjnam2(otmp
, "are"),
1013 scursed
? "mottled" : "shimmering",
1014 hcolor(scursed
? NH_BLACK
: NH_GOLDEN
),
1016 : (is_shield(otmp
) ? "layer" : "shield"));
1018 if (new_erodeproof
&& (otmp
->oeroded
|| otmp
->oeroded2
)) {
1019 otmp
->oeroded
= otmp
->oeroded2
= 0;
1020 pline("%s as good as new!",
1021 Yobjnam2(otmp
, Blind
? "feel" : "look"));
1023 if (old_erodeproof
&& !new_erodeproof
) {
1024 /* restore old_erodeproof before shop charges */
1025 otmp
->oerodeproof
= 1;
1026 costly_alteration(otmp
, COST_DEGRD
);
1028 otmp
->oerodeproof
= new_erodeproof
? 1 : 0;
1031 /* elven armor vibrates warningly when enchanted beyond a limit */
1032 special_armor
= is_elven_armor(otmp
)
1033 || (Role_if(PM_WIZARD
) && otmp
->otyp
== CORNUTHAUM
);
1035 same_color
= (otmp
->otyp
== BLACK_DRAGON_SCALE_MAIL
1036 || otmp
->otyp
== BLACK_DRAGON_SCALES
);
1038 same_color
= (otmp
->otyp
== SILVER_DRAGON_SCALE_MAIL
1039 || otmp
->otyp
== SILVER_DRAGON_SCALES
1040 || otmp
->otyp
== SHIELD_OF_REFLECTION
);
1044 /* KMH -- catch underflow */
1045 s
= scursed
? -otmp
->spe
: otmp
->spe
;
1046 if (s
> (special_armor
? 5 : 3) && rn2(s
)) {
1047 otmp
->in_use
= TRUE
;
1048 pline("%s violently %s%s%s for a while, then %s.", Yname2(otmp
),
1049 otense(otmp
, Blind
? "vibrate" : "glow"),
1050 (!Blind
&& !same_color
) ? " " : "",
1051 (Blind
|| same_color
) ? "" : hcolor(scursed
? NH_BLACK
1053 otense(otmp
, "evaporate"));
1054 remove_worn_item(otmp
, FALSE
);
1060 ? (rn2(otmp
->spe
) == 0)
1062 ? rnd(3 - otmp
->spe
/ 3)
1064 if (s
>= 0 && Is_dragon_scales(otmp
)) {
1065 /* dragon scales get turned into dragon scale mail */
1066 pline("%s merges and hardens!", Yname2(otmp
));
1067 setworn((struct obj
*) 0, W_ARM
);
1068 /* assumes same order */
1069 otmp
->otyp
+= GRAY_DRAGON_SCALE_MAIL
- GRAY_DRAGON_SCALES
;
1074 } else if (otmp
->cursed
)
1077 setworn(otmp
, W_ARM
);
1079 alter_cost(otmp
, 0L); /* shop bill */
1082 pline("%s %s%s%s%s for a %s.", Yname2(otmp
),
1083 s
== 0 ? "violently " : "",
1084 otense(otmp
, Blind
? "vibrate" : "glow"),
1085 (!Blind
&& !same_color
) ? " " : "",
1086 (Blind
|| same_color
)
1087 ? "" : hcolor(scursed
? NH_BLACK
: NH_SILVER
),
1088 (s
* s
> 1) ? "while" : "moment");
1089 /* [this cost handling will need updating if shop pricing is
1090 ever changed to care about curse/bless status of armor] */
1092 costly_alteration(otmp
, COST_DECHNT
);
1093 if (scursed
&& !otmp
->cursed
)
1095 else if (sblessed
&& !otmp
->blessed
)
1097 else if (!scursed
&& otmp
->cursed
)
1102 known
= otmp
->known
;
1103 /* update shop bill to reflect new higher price */
1104 if (s
> 0 && otmp
->unpaid
)
1105 alter_cost(otmp
, 0L);
1108 if ((otmp
->spe
> (special_armor
? 5 : 3))
1109 && (special_armor
|| !rn2(7)))
1110 pline("%s %s.", Yobjnam2(otmp
, "suddenly vibrate"),
1111 Blind
? "again" : "unexpectedly");
1114 case SCR_DESTROY_ARMOR
: {
1115 otmp
= some_armor(&youmonst
);
1118 strange_feeling(sobj
, "Your bones itch.");
1119 sobj
= 0; /* useup() in strange_feeling() */
1120 exercise(A_STR
, FALSE
);
1121 exercise(A_CON
, FALSE
);
1124 old_erodeproof
= (otmp
->oerodeproof
!= 0);
1125 new_erodeproof
= scursed
;
1126 otmp
->oerodeproof
= 0; /* for messages */
1127 p_glow2(otmp
, NH_PURPLE
);
1128 if (old_erodeproof
&& !new_erodeproof
) {
1129 /* restore old_erodeproof before shop charges */
1130 otmp
->oerodeproof
= 1;
1131 costly_alteration(otmp
, COST_DEGRD
);
1133 otmp
->oerodeproof
= new_erodeproof
? 1 : 0;
1136 if (!scursed
|| !otmp
|| !otmp
->cursed
) {
1137 if (!destroy_arm(otmp
)) {
1138 strange_feeling(sobj
, "Your skin itches.");
1139 sobj
= 0; /* useup() in strange_feeling() */
1140 exercise(A_STR
, FALSE
);
1141 exercise(A_CON
, FALSE
);
1145 } else { /* armor and scroll both cursed */
1146 pline("%s.", Yobjnam2(otmp
, "vibrate"));
1147 if (otmp
->spe
>= -6) {
1151 make_stunned((HStun
& TIMEOUT
) + (long) rn1(10, 10), TRUE
);
1154 case SCR_CONFUSE_MONSTER
:
1155 case SPE_CONFUSE_MONSTER
:
1156 if (youmonst
.data
->mlet
!= S_HUMAN
|| scursed
) {
1158 You_feel("confused.");
1159 make_confused(HConfusion
+ rnd(100), FALSE
);
1160 } else if (confused
) {
1162 Your("%s begin to %s%s.", makeplural(body_part(HAND
)),
1163 Blind
? "tingle" : "glow ",
1164 Blind
? "" : hcolor(NH_PURPLE
));
1165 make_confused(HConfusion
+ rnd(100), FALSE
);
1167 pline("A %s%s surrounds your %s.",
1168 Blind
? "" : hcolor(NH_RED
),
1169 Blind
? "faint buzz" : " glow", body_part(HEAD
));
1170 make_confused(0L, TRUE
);
1174 Your("%s%s %s%s.", makeplural(body_part(HAND
)),
1175 Blind
? "" : " begin to glow",
1176 Blind
? (const char *) "tingle" : hcolor(NH_RED
),
1177 u
.umconf
? " even more" : "");
1181 Your("%s tingle %s sharply.", makeplural(body_part(HAND
)),
1182 u
.umconf
? "even more" : "very");
1184 Your("%s glow a%s brilliant %s.",
1185 makeplural(body_part(HAND
)),
1186 u
.umconf
? "n even more" : "", hcolor(NH_RED
));
1187 /* after a while, repeated uses become less effective */
1191 u
.umconf
+= rn1(8, 2);
1195 case SCR_SCARE_MONSTER
:
1196 case SPE_CAUSE_FEAR
: {
1197 register int ct
= 0;
1198 register struct monst
*mtmp
;
1200 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
1201 if (DEADMONSTER(mtmp
))
1203 if (cansee(mtmp
->mx
, mtmp
->my
)) {
1204 if (confused
|| scursed
) {
1205 mtmp
->mflee
= mtmp
->mfrozen
= mtmp
->msleeping
= 0;
1207 } else if (!resist(mtmp
, sobj
->oclass
, 0, NOTELL
))
1208 monflee(mtmp
, 0, FALSE
, FALSE
);
1210 ct
++; /* pets don't laugh at you */
1213 if (otyp
== SCR_SCARE_MONSTER
|| !ct
)
1214 You_hear("%s %s.", (confused
|| scursed
) ? "sad wailing"
1215 : "maniacal laughter",
1216 !ct
? "in the distance" : "close by");
1219 case SCR_BLANK_PAPER
:
1221 You("don't remember there being any magic words on this scroll.");
1223 pline("This scroll seems to be blank.");
1226 case SCR_REMOVE_CURSE
:
1227 case SPE_REMOVE_CURSE
: {
1228 register struct obj
*obj
;
1230 You_feel(!Hallucination
1231 ? (!confused
? "like someone is helping you."
1232 : "like you need some help.")
1233 : (!confused
? "in touch with the Universal Oneness."
1234 : "the power of the Force against you!"));
1237 pline_The("scroll disintegrates.");
1239 for (obj
= invent
; obj
; obj
= obj
->nobj
) {
1242 /* gold isn't subject to cursing and blessing */
1243 if (obj
->oclass
== COIN_CLASS
)
1245 wornmask
= (obj
->owornmask
& ~(W_BALL
| W_ART
| W_ARTI
));
1246 if (wornmask
&& !sblessed
) {
1247 /* handle a couple of special cases; we don't
1248 allow auxiliary weapon slots to be used to
1249 artificially increase number of worn items */
1250 if (obj
== uswapwep
) {
1253 } else if (obj
== uquiver
) {
1254 if (obj
->oclass
== WEAPON_CLASS
) {
1255 /* mergeable weapon test covers ammo,
1256 missiles, spears, daggers & knives */
1257 if (!objects
[obj
->otyp
].oc_merge
)
1259 } else if (obj
->oclass
== GEM_CLASS
) {
1260 /* possibly ought to check whether
1261 alternate weapon is a sling... */
1265 /* weptools don't merge and aren't
1266 reasonable quivered weapons */
1271 if (sblessed
|| wornmask
|| obj
->otyp
== LOADSTONE
1272 || (obj
->otyp
== LEASH
&& obj
->leashmon
)) {
1273 /* water price varies by curse/bless status */
1274 boolean shop_h2o
= (obj
->unpaid
&& obj
->otyp
== POT_WATER
);
1277 blessorcurse(obj
, 2);
1278 /* lose knowledge of this object's curse/bless
1279 state (even if it didn't actually change) */
1281 /* blessorcurse() only affects uncursed items
1282 so no need to worry about price of water
1283 going down (hence no costly_alteration) */
1284 if (shop_h2o
&& (obj
->cursed
|| obj
->blessed
))
1285 alter_cost(obj
, 0L); /* price goes up */
1286 } else if (obj
->cursed
) {
1288 costly_alteration(obj
, COST_UNCURS
);
1294 if (Punished
&& !confused
)
1296 if (u
.utrap
&& u
.utraptype
== TT_BURIEDBALL
) {
1297 buried_ball_to_freedom();
1298 pline_The("clasp on your %s vanishes.", body_part(LEG
));
1303 case SCR_CREATE_MONSTER
:
1304 case SPE_CREATE_MONSTER
:
1305 if (create_critters(1 + ((confused
|| scursed
) ? 12 : 0)
1306 + ((sblessed
|| rn2(73)) ? 0 : rnd(4)),
1307 confused
? &mons
[PM_ACID_BLOB
]
1308 : (struct permonst
*) 0,
1311 /* no need to flush monsters; we ask for identification only if the
1312 * monsters are not visible
1315 case SCR_ENCHANT_WEAPON
:
1316 /* [What about twoweapon mode? Proofing/repairing/enchanting both
1317 would be too powerful, but shouldn't we choose randomly between
1318 primary and secondary instead of always acting on primary?] */
1319 if (confused
&& uwep
1320 && erosion_matters(uwep
) && uwep
->oclass
!= ARMOR_CLASS
) {
1321 old_erodeproof
= (uwep
->oerodeproof
!= 0);
1322 new_erodeproof
= !scursed
;
1323 uwep
->oerodeproof
= 0; /* for messages */
1325 uwep
->rknown
= FALSE
;
1326 Your("weapon feels warm for a moment.");
1328 uwep
->rknown
= TRUE
;
1329 pline("%s covered by a %s %s %s!", Yobjnam2(uwep
, "are"),
1330 scursed
? "mottled" : "shimmering",
1331 hcolor(scursed
? NH_PURPLE
: NH_GOLDEN
),
1332 scursed
? "glow" : "shield");
1334 if (new_erodeproof
&& (uwep
->oeroded
|| uwep
->oeroded2
)) {
1335 uwep
->oeroded
= uwep
->oeroded2
= 0;
1336 pline("%s as good as new!",
1337 Yobjnam2(uwep
, Blind
? "feel" : "look"));
1339 if (old_erodeproof
&& !new_erodeproof
) {
1340 /* restore old_erodeproof before shop charges */
1341 uwep
->oerodeproof
= 1;
1342 costly_alteration(uwep
, COST_DEGRD
);
1344 uwep
->oerodeproof
= new_erodeproof
? 1 : 0;
1347 if (!chwepon(sobj
, scursed
? -1
1349 : (uwep
->spe
>= 9) ? !rn2(uwep
->spe
)
1350 : sblessed
? rnd(3 - uwep
->spe
/ 3)
1352 sobj
= 0; /* nothing enchanted: strange_feeling -> useup */
1355 case SPE_CHARM_MONSTER
: {
1356 int candidates
, res
, results
, vis_results
;
1360 results
= vis_results
= maybe_tame(u
.ustuck
, sobj
);
1362 int i
, j
, bd
= confused
? 5 : 1;
1365 /* note: maybe_tame() can return either positive or
1366 negative values, but not both for the same scroll */
1367 candidates
= results
= vis_results
= 0;
1368 for (i
= -bd
; i
<= bd
; i
++)
1369 for (j
= -bd
; j
<= bd
; j
++) {
1370 if (!isok(u
.ux
+ i
, u
.uy
+ j
))
1372 if ((mtmp
= m_at(u
.ux
+ i
, u
.uy
+ j
)) != 0
1373 || (!i
&& !j
&& (mtmp
= u
.usteed
) != 0)) {
1375 res
= maybe_tame(mtmp
, sobj
);
1377 if (canspotmon(mtmp
))
1383 pline("Nothing interesting %s.",
1384 !candidates
? "happens" : "seems to happen");
1386 pline_The("neighborhood %s %sfriendlier.",
1387 vis_results
? "is" : "seems",
1388 (results
< 0) ? "un" : "");
1389 if (vis_results
> 0)
1396 You("have found a scroll of genocide!");
1399 do_class_genocide();
1401 do_genocide(!scursed
| (2 * !!Confusion
));
1404 if (!confused
|| rn2(5)) {
1407 litroom(!confused
&& !scursed
, sobj
);
1408 if (!confused
&& !scursed
) {
1409 if (lightdamage(sobj
, TRUE
, 5))
1413 /* could be scroll of create monster, don't set known ...*/
1414 (void) create_critters(1, !scursed
? &mons
[PM_YELLOW_LIGHT
]
1415 : &mons
[PM_BLACK_LIGHT
],
1417 if (!objects
[sobj
->otyp
].oc_uname
)
1421 case SCR_TELEPORTATION
:
1422 if (confused
|| scursed
) {
1425 known
= scrolltele(sobj
);
1428 case SCR_GOLD_DETECTION
:
1429 if ((confused
|| scursed
) ? trap_detect(sobj
) : gold_detect(sobj
))
1430 sobj
= 0; /* failure: strange_feeling() -> useup() */
1432 case SCR_FOOD_DETECTION
:
1433 case SPE_DETECT_FOOD
:
1434 if (food_detect(sobj
))
1435 sobj
= 0; /* nothing detected: strange_feeling -> useup */
1438 /* known = TRUE; -- handled inline here */
1439 /* use up the scroll first, before makeknown() performs a
1440 perm_invent update; also simplifies empty invent check */
1442 sobj
= 0; /* it's gone */
1444 You("identify this as an identify scroll.");
1445 else if (!already_known
|| !invent
)
1446 /* force feedback now if invent became
1447 empty after using up this scroll */
1448 pline("This is an identify scroll.");
1450 (void) learnscrolltyp(SCR_IDENTIFY
);
1454 if (sblessed
|| (!scursed
&& !rn2(5))) {
1456 /* note: if cval==0, identify all items */
1457 if (cval
== 1 && sblessed
&& Luck
> 0)
1460 if (invent
&& !confused
) {
1461 identify_pack(cval
, !already_known
);
1462 } else if (otyp
== SPE_IDENTIFY
) {
1463 /* when casting a spell we know we're not confused,
1464 so inventory must be empty (another message has
1465 already been given above if reading a scroll) */
1466 pline("You're not carrying anything to be identified.");
1472 You_feel("discharged.");
1475 You_feel("charged up!");
1476 u
.uen
+= d(sblessed
? 6 : 4, 4);
1477 if (u
.uen
> u
.uenmax
) /* if current energy is already at */
1478 u
.uenmax
= u
.uen
; /* or near maximum, increase maximum */
1480 u
.uen
= u
.uenmax
; /* otherwise restore current to max */
1485 /* known = TRUE; -- handled inline here */
1486 if (!already_known
) {
1487 pline("This is a charging scroll.");
1490 /* use it up now to prevent it from showing in the
1491 getobj picklist because the "disappears" message
1492 was already delivered */
1494 sobj
= 0; /* it's gone */
1495 otmp
= getobj(all_count
, "charge");
1497 recharge(otmp
, scursed
? -1 : sblessed
? 1 : 0);
1499 case SCR_MAGIC_MAPPING
:
1500 if (level
.flags
.nommap
) {
1501 Your("mind is filled with crazy lines!");
1503 pline("Wow! Modern art.");
1505 Your("%s spins in bewilderment.", body_part(HEAD
));
1506 make_confused(HConfusion
+ rnd(30), FALSE
);
1512 for (x
= 1; x
< COLNO
; x
++)
1513 for (y
= 0; y
< ROWNO
; y
++)
1514 if (levl
[x
][y
].typ
== SDOOR
)
1515 cvt_sdoor_to_door(&levl
[x
][y
]);
1516 /* do_mapping() already reveals secret passages */
1519 case SPE_MAGIC_MAPPING
:
1520 if (level
.flags
.nommap
) {
1521 Your("%s spins as %s blocks the spell!", body_part(HEAD
),
1523 make_confused(HConfusion
+ rnd(30), FALSE
);
1526 pline("A map coalesces in your mind!");
1527 cval
= (scursed
&& !confused
);
1529 HConfusion
= 1; /* to screw up map */
1532 HConfusion
= 0; /* restore */
1533 pline("Unfortunately, you can't grasp the details.");
1538 forget((!sblessed
? ALL_SPELLS
: 0)
1539 | (!confused
|| scursed
? ALL_MAP
: 0));
1540 if (Hallucination
) /* Ommmmmm! */
1541 Your("mind releases itself from mundane concerns.");
1542 else if (!strncmpi(plname
, "Maud", 4))
1544 "As your mind turns inward on itself, you forget everything else.");
1546 pline("Who was that Maud person anyway?");
1548 pline("Thinking of Maud you forget everything else.");
1549 exercise(A_WIS
, FALSE
);
1552 cval
= bcsign(sobj
);
1554 sobj
= 0; /* it's gone */
1556 (void) learnscrolltyp(SCR_FIRE
);
1558 if (Fire_resistance
) {
1559 shieldeff(u
.ux
, u
.uy
);
1561 pline("Oh, look, what a pretty fire in your %s.",
1562 makeplural(body_part(HAND
)));
1564 You_feel("a pleasant warmth in your %s.",
1565 makeplural(body_part(HAND
)));
1567 pline_The("scroll catches fire and you burn your %s.",
1568 makeplural(body_part(HAND
)));
1569 losehp(1, "scroll of fire", KILLED_BY_AN
);
1574 pline_The("%s around you vaporizes violently!", hliquid("water"));
1576 pline_The("scroll erupts in a tower of flame!");
1577 iflags
.last_msg
= PLNMSG_TOWER_OF_FLAME
; /* for explode() */
1580 explode(u
.ux
, u
.uy
, 11, (2 * (rn1(3, 3) + 2 * cval
) + 1) / 3,
1581 SCROLL_CLASS
, EXPL_FIERY
);
1584 /* TODO: handle steeds */
1585 if (!Is_rogue_level(&u
.uz
) && has_ceiling(&u
.uz
)
1586 && (!In_endgame(&u
.uz
) || Is_earthlevel(&u
.uz
))) {
1590 /* Identify the scroll */
1592 You_hear("rumbling.");
1594 pline_The("%s rumbles %s you!", ceiling(u
.ux
, u
.uy
),
1595 sblessed
? "around" : "above");
1599 /* Loop through the surrounding squares */
1601 for (x
= u
.ux
- 1; x
<= u
.ux
+ 1; x
++) {
1602 for (y
= u
.uy
- 1; y
<= u
.uy
+ 1; y
++) {
1603 /* Is this a suitable spot? */
1604 if (isok(x
, y
) && !closed_door(x
, y
)
1605 && !IS_ROCK(levl
[x
][y
].typ
)
1606 && !IS_AIR(levl
[x
][y
].typ
)
1607 && (x
!= u
.ux
|| y
!= u
.uy
)) {
1609 drop_boulder_on_monster(x
, y
, confused
, TRUE
);
1613 /* Attack the player */
1615 drop_boulder_on_player(confused
, !scursed
, TRUE
, FALSE
);
1616 } else if (!nboulders
)
1617 pline("But nothing else happens.");
1620 case SCR_PUNISHMENT
:
1622 if (confused
|| sblessed
) {
1623 You_feel("guilty.");
1628 case SCR_STINKING_CLOUD
: {
1632 You("have found a scroll of stinking cloud!");
1634 pline("Where do you want to center the %scloud?",
1635 already_known
? "stinking " : "");
1638 getpos_sethilite(display_stinking_cloud_positions
);
1639 if (getpos(&cc
, TRUE
, "the desired position") < 0) {
1643 if (!is_valid_stinking_cloud_pos(cc
.x
, cc
.y
, TRUE
))
1645 (void) create_gas_cloud(cc
.x
, cc
.y
, 3 + bcsign(sobj
),
1646 8 + 4 * bcsign(sobj
));
1650 impossible("What weird effect is this? (%u)", otyp
);
1652 return sobj
? 0 : 1;
1656 drop_boulder_on_player(confused
, helmet_protects
, byu
, skip_uswallow
)
1657 boolean confused
, helmet_protects
, byu
, skip_uswallow
;
1662 /* hit monster if swallowed */
1663 if (u
.uswallow
&& !skip_uswallow
) {
1664 drop_boulder_on_monster(u
.ux
, u
.uy
, confused
, byu
);
1668 otmp2
= mksobj(confused
? ROCK
: BOULDER
, FALSE
, FALSE
);
1671 otmp2
->quan
= confused
? rn1(5, 2) : 1;
1672 otmp2
->owt
= weight(otmp2
);
1673 if (!amorphous(youmonst
.data
) && !Passes_walls
1674 && !noncorporeal(youmonst
.data
) && !unsolid(youmonst
.data
)) {
1675 You("are hit by %s!", doname(otmp2
));
1676 dmg
= dmgval(otmp2
, &youmonst
) * otmp2
->quan
;
1677 if (uarmh
&& helmet_protects
) {
1678 if (is_metallic(uarmh
)) {
1679 pline("Fortunately, you are wearing a hard helmet.");
1682 } else if (flags
.verbose
) {
1683 pline("%s does not protect you.", Yname2(uarmh
));
1688 /* Must be before the losehp(), for bones files */
1689 if (!flooreffects(otmp2
, u
.ux
, u
.uy
, "fall")) {
1690 place_object(otmp2
, u
.ux
, u
.uy
);
1695 losehp(Maybe_Half_Phys(dmg
), "scroll of earth", KILLED_BY_AN
);
1699 drop_boulder_on_monster(x
, y
, confused
, byu
)
1701 boolean confused
, byu
;
1703 register struct obj
*otmp2
;
1704 register struct monst
*mtmp
;
1706 /* Make the object(s) */
1707 otmp2
= mksobj(confused
? ROCK
: BOULDER
, FALSE
, FALSE
);
1709 return FALSE
; /* Shouldn't happen */
1710 otmp2
->quan
= confused
? rn1(5, 2) : 1;
1711 otmp2
->owt
= weight(otmp2
);
1713 /* Find the monster here (won't be player) */
1715 if (mtmp
&& !amorphous(mtmp
->data
) && !passes_walls(mtmp
->data
)
1716 && !noncorporeal(mtmp
->data
) && !unsolid(mtmp
->data
)) {
1717 struct obj
*helmet
= which_armor(mtmp
, W_ARMH
);
1720 if (cansee(mtmp
->mx
, mtmp
->my
)) {
1721 pline("%s is hit by %s!", Monnam(mtmp
), doname(otmp2
));
1722 if (mtmp
->minvis
&& !canspotmon(mtmp
))
1723 map_invisible(mtmp
->mx
, mtmp
->my
);
1724 } else if (u
.uswallow
&& mtmp
== u
.ustuck
)
1725 You_hear("something hit %s %s over your %s!",
1726 s_suffix(mon_nam(mtmp
)), mbodypart(mtmp
, STOMACH
),
1729 mdmg
= dmgval(otmp2
, mtmp
) * otmp2
->quan
;
1731 if (is_metallic(helmet
)) {
1732 if (canspotmon(mtmp
))
1733 pline("Fortunately, %s is wearing a hard helmet.",
1736 You_hear("a clanging sound.");
1740 if (canspotmon(mtmp
))
1741 pline("%s's %s does not protect %s.", Monnam(mtmp
),
1742 xname(helmet
), mhim(mtmp
));
1746 if (mtmp
->mhp
<= 0) {
1750 pline("%s is killed.", Monnam(mtmp
));
1754 } else if (u
.uswallow
&& mtmp
== u
.ustuck
) {
1755 obfree(otmp2
, (struct obj
*) 0);
1756 /* fall through to player */
1757 drop_boulder_on_player(confused
, TRUE
, FALSE
, TRUE
);
1760 /* Drop the rock/boulder to the floor */
1761 if (!flooreffects(otmp2
, x
, y
, "fall")) {
1762 place_object(otmp2
, x
, y
);
1764 newsym(x
, y
); /* map the rock */
1769 /* overcharging any wand or zapping/engraving cursed wand */
1771 wand_explode(obj
, chg
)
1773 int chg
; /* recharging */
1775 const char *expl
= !chg
? "suddenly" : "vibrates violently and";
1778 /* number of damage dice */
1780 chg
= 2; /* zap/engrave adjustment */
1783 n
= 2; /* arbitrary minimum */
1784 /* size of damage dice */
1785 switch (obj
->otyp
) {
1789 case WAN_CANCELLATION
:
1792 case WAN_UNDEAD_TURNING
:
1798 case WAN_MAGIC_MISSILE
:
1808 /* inflict damage and destroy the wand */
1810 obj
->in_use
= TRUE
; /* in case losehp() is fatal (or --More--^C) */
1811 pline("%s %s explodes!", Yname2(obj
), expl
);
1812 losehp(Maybe_Half_Phys(dmg
), "exploding wand", KILLED_BY_AN
);
1814 /* obscure side-effect */
1815 exercise(A_STR
, FALSE
);
1818 /* used to collect gremlins being hit by light so that they can be processed
1819 after vision for the entire lit area has been brought up to date */
1824 STATIC_VAR
struct litmon
*gremlins
= 0;
1827 * Low-level lit-field update routine.
1835 struct litmon
*gremlin
;
1839 if ((mtmp
= m_at(x
, y
)) != 0 && mtmp
->data
== &mons
[PM_GREMLIN
]) {
1840 gremlin
= (struct litmon
*) alloc(sizeof *gremlin
);
1841 gremlin
->mon
= mtmp
;
1842 gremlin
->nxt
= gremlins
;
1847 snuff_light_source(x
, y
);
1853 register boolean on
;
1856 char is_lit
; /* value is irrelevant; we use its address
1857 as a `not null' flag for set_lit() */
1859 /* first produce the text (provided you're not blind) */
1861 register struct obj
*otmp
;
1865 pline("It seems even darker in here than before.");
1867 if (uwep
&& artifact_light(uwep
) && uwep
->lamplit
)
1868 pline("Suddenly, the only light left comes from %s!",
1871 You("are surrounded by darkness!");
1875 /* the magic douses lamps, et al, too */
1876 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
1878 (void) snuff_lit(otmp
);
1883 else if (is_animal(u
.ustuck
->data
))
1884 pline("%s %s is lit.", s_suffix(Monnam(u
.ustuck
)),
1885 mbodypart(u
.ustuck
, STOMACH
));
1886 else if (is_whirly(u
.ustuck
->data
))
1887 pline("%s shines briefly.", Monnam(u
.ustuck
));
1889 pline("%s glistens.", Monnam(u
.ustuck
));
1891 pline("A lit field surrounds you!");
1894 /* No-op when swallowed or in water */
1895 if (u
.uswallow
|| Underwater
|| Is_waterlevel(&u
.uz
))
1898 * If we are darkening the room and the hero is punished but not
1899 * blind, then we have to pick up and replace the ball and chain so
1900 * that we don't remember them if they are out of sight.
1902 if (Punished
&& !on
&& !Blind
)
1903 move_bc(1, 0, uball
->ox
, uball
->oy
, uchain
->ox
, uchain
->oy
);
1905 if (Is_rogue_level(&u
.uz
)) {
1906 /* Can't use do_clear_area because MAX_RADIUS is too small */
1907 /* rogue lighting must light the entire room */
1908 int rnum
= levl
[u
.ux
][u
.uy
].roomno
- ROOMOFFSET
;
1912 for (rx
= rooms
[rnum
].lx
- 1; rx
<= rooms
[rnum
].hx
+ 1; rx
++)
1913 for (ry
= rooms
[rnum
].ly
- 1; ry
<= rooms
[rnum
].hy
+ 1; ry
++)
1915 (genericptr_t
) (on
? &is_lit
: (char *) 0));
1916 rooms
[rnum
].rlit
= on
;
1918 /* hallways remain dark on the rogue level */
1920 do_clear_area(u
.ux
, u
.uy
,
1921 (obj
&& obj
->oclass
== SCROLL_CLASS
&& obj
->blessed
)
1923 set_lit
, (genericptr_t
) (on
? &is_lit
: (char *) 0));
1926 * If we are not blind, then force a redraw on all positions in sight
1927 * by temporarily blinding the hero. The vision recalculation will
1928 * correctly update all previously seen positions *and* correctly
1929 * set the waslit bit [could be messed up from above].
1934 /* replace ball&chain */
1935 if (Punished
&& !on
)
1936 move_bc(0, 0, uball
->ox
, uball
->oy
, uchain
->ox
, uchain
->oy
);
1939 vision_full_recalc
= 1; /* delayed vision recalculation */
1941 struct litmon
*gremlin
;
1943 /* can't delay vision recalc after all */
1945 /* after vision has been updated, monsters who are affected
1946 when hit by light can now be hit by it */
1949 gremlins
= gremlin
->nxt
;
1950 light_hits_gremlin(gremlin
->mon
, rnd(5));
1951 free((genericptr_t
) gremlin
);
1959 int i
, j
, immunecnt
, gonecnt
, goodcnt
, class, feel_dead
= 0;
1961 boolean gameover
= FALSE
; /* true iff killed self */
1965 pline1(thats_enough_tries
);
1969 getlin("What class of monsters do you wish to genocide?", buf
);
1970 (void) mungspaces(buf
);
1972 /* choosing "none" preserves genocideless conduct */
1973 if (*buf
== '\033' || !strcmpi(buf
, "none")
1974 || !strcmpi(buf
, "nothing"))
1977 class = name_to_monclass(buf
, (int *) 0);
1978 if (class == 0 && (i
= name_to_mon(buf
)) != NON_PM
)
1979 class = mons
[i
].mlet
;
1980 immunecnt
= gonecnt
= goodcnt
= 0;
1981 for (i
= LOW_PM
; i
< NUMMONS
; i
++) {
1982 if (mons
[i
].mlet
== class) {
1983 if (!(mons
[i
].geno
& G_GENO
))
1985 else if (mvitals
[i
].mvflags
& G_GENOD
)
1991 if (!goodcnt
&& class != mons
[urole
.malenum
].mlet
1992 && class != mons
[urace
.malenum
].mlet
) {
1994 pline("All such monsters are already nonexistent.");
1995 else if (immunecnt
|| class == S_invisible
)
1996 You("aren't permitted to genocide such monsters.");
1997 else if (wizard
&& buf
[0] == '*') {
1998 register struct monst
*mtmp
, *mtmp2
;
2001 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp2
) {
2003 if (DEADMONSTER(mtmp
))
2008 pline("Eliminated %d monster%s.", gonecnt
, plur(gonecnt
));
2011 pline("That %s does not represent any monster.",
2012 strlen(buf
) == 1 ? "symbol" : "response");
2016 for (i
= LOW_PM
; i
< NUMMONS
; i
++) {
2017 if (mons
[i
].mlet
== class) {
2020 Strcpy(nam
, makeplural(mons
[i
].mname
));
2021 /* Although "genus" is Latin for race, the hero benefits
2022 * from both race and role; thus genocide affects either.
2024 if (Your_Own_Role(i
) || Your_Own_Race(i
)
2025 || ((mons
[i
].geno
& G_GENO
)
2026 && !(mvitals
[i
].mvflags
& G_GENOD
))) {
2027 /* This check must be first since player monsters might
2028 * have G_GENOD or !G_GENO.
2030 mvitals
[i
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2032 kill_genocided_monsters();
2033 update_inventory(); /* eggs & tins */
2034 pline("Wiped out all %s.", nam
);
2035 if (Upolyd
&& i
== u
.umonnum
) {
2040 /* finish genociding this class of
2041 monsters before ultimately dying */
2046 /* Self-genocide if it matches either your race
2047 or role. Assumption: male and female forms
2048 share same monster class. */
2049 if (i
== urole
.malenum
|| i
== urace
.malenum
) {
2053 You_feel("dead inside.");
2060 } else if (mvitals
[i
].mvflags
& G_GENOD
) {
2062 pline("All %s are already nonexistent.", nam
);
2063 } else if (!gameover
) {
2064 /* suppress feedback about quest beings except
2065 for those applicable to our own role */
2066 if ((mons
[i
].msound
!= MS_LEADER
2067 || quest_info(MS_LEADER
) == i
)
2068 && (mons
[i
].msound
!= MS_NEMESIS
2069 || quest_info(MS_NEMESIS
) == i
)
2070 && (mons
[i
].msound
!= MS_GUARDIAN
2071 || quest_info(MS_GUARDIAN
) == i
)
2072 /* non-leader/nemesis/guardian role-specific monster
2074 && (i
!= PM_NINJA
/* nuisance */
2075 || Role_if(PM_SAMURAI
))) {
2076 boolean named
, uniq
;
2078 named
= type_is_pname(&mons
[i
]) ? TRUE
: FALSE
;
2079 uniq
= (mons
[i
].geno
& G_UNIQ
) ? TRUE
: FALSE
;
2080 /* one special case */
2081 if (i
== PM_HIGH_PRIEST
)
2084 You("aren't permitted to genocide %s%s.",
2085 (uniq
&& !named
) ? "the " : "",
2086 (uniq
|| named
) ? mons
[i
].mname
: nam
);
2091 if (gameover
|| u
.uhp
== -1) {
2092 killer
.format
= KILLED_BY_AN
;
2093 Strcpy(killer
.name
, "scroll of genocide");
2107 /* 0 = no genocide; create monsters (cursed scroll) */
2108 /* 1 = normal genocide */
2109 /* 3 = forced genocide of player */
2110 /* 5 (4 | 1) = normal genocide from throne */
2113 register int i
, killplayer
= 0;
2115 register struct permonst
*ptr
;
2119 mndx
= u
.umonster
; /* non-polymorphed mon num */
2121 Strcpy(buf
, ptr
->mname
);
2126 /* cursed effect => no free pass (unless rndmonst() fails) */
2127 if (!(how
& REALLY
) && (ptr
= rndmonst()) != 0)
2130 pline1(thats_enough_tries
);
2133 getlin("What monster do you want to genocide? [type the name]",
2135 (void) mungspaces(buf
);
2136 /* choosing "none" preserves genocideless conduct */
2137 if (*buf
== '\033' || !strcmpi(buf
, "none")
2138 || !strcmpi(buf
, "nothing")) {
2139 /* ... but no free pass if cursed */
2140 if (!(how
& REALLY
) && (ptr
= rndmonst()) != 0)
2141 break; /* remaining checks don't apply */
2146 mndx
= name_to_mon(buf
);
2147 if (mndx
== NON_PM
|| (mvitals
[mndx
].mvflags
& G_GENOD
)) {
2148 pline("Such creatures %s exist in this world.",
2149 (mndx
== NON_PM
) ? "do not" : "no longer");
2153 /* Although "genus" is Latin for race, the hero benefits
2154 * from both race and role; thus genocide affects either.
2156 if (Your_Own_Role(mndx
) || Your_Own_Race(mndx
)) {
2161 adjalign(-sgn(u
.ualign
.type
));
2163 adjalign(sgn(u
.ualign
.type
));
2165 if (!(ptr
->geno
& G_GENO
)) {
2167 /* FIXME: unconditional "caverns" will be silly in some
2168 * circumstances. Who's speaking? Divine pronouncements
2169 * aren't supposed to be hampered by deafness....
2172 pline("A thunderous voice booms through the caverns:");
2173 verbalize("No, mortal! That will not be done.");
2177 /* KMH -- Unchanging prevents rehumanization */
2178 if (Unchanging
&& ptr
== youmonst
.data
)
2182 mndx
= monsndx(ptr
); /* needed for the 'no free pass' cases */
2186 if (Hallucination
) {
2188 Strcpy(buf
, youmonst
.data
->mname
);
2190 Strcpy(buf
, (flags
.female
&& urole
.name
.f
) ? urole
.name
.f
2192 buf
[0] = lowc(buf
[0]);
2195 Strcpy(buf
, ptr
->mname
); /* make sure we have standard singular */
2196 if ((ptr
->geno
& G_UNIQ
) && ptr
!= &mons
[PM_HIGH_PRIEST
])
2197 which
= !type_is_pname(ptr
) ? "the " : "";
2200 /* setting no-corpse affects wishing and random tin generation */
2201 mvitals
[mndx
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2202 pline("Wiped out %s%s.", which
,
2203 (*which
!= 'a') ? buf
: makeplural(buf
));
2206 /* might need to wipe out dual role */
2207 if (urole
.femalenum
!= NON_PM
&& mndx
== urole
.malenum
)
2208 mvitals
[urole
.femalenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2209 if (urole
.femalenum
!= NON_PM
&& mndx
== urole
.femalenum
)
2210 mvitals
[urole
.malenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2211 if (urace
.femalenum
!= NON_PM
&& mndx
== urace
.malenum
)
2212 mvitals
[urace
.femalenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2213 if (urace
.femalenum
!= NON_PM
&& mndx
== urace
.femalenum
)
2214 mvitals
[urace
.malenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2218 killer
.format
= KILLED_BY
;
2219 Strcpy(killer
.name
, "genocidal confusion");
2220 } else if (how
& ONTHRONE
) {
2221 /* player selected while on a throne */
2222 killer
.format
= KILLED_BY_AN
;
2223 Strcpy(killer
.name
, "imperious order");
2224 } else { /* selected player deliberately, not confused */
2225 killer
.format
= KILLED_BY_AN
;
2226 Strcpy(killer
.name
, "scroll of genocide");
2229 /* Polymorphed characters will die as soon as they're rehumanized.
2231 /* KMH -- Unchanging prevents rehumanization */
2232 if (Upolyd
&& ptr
!= youmonst
.data
) {
2233 delayed_killer(POLYMORPH
, killer
.format
, killer
.name
);
2234 You_feel("dead inside.");
2237 } else if (ptr
== youmonst
.data
) {
2240 reset_rndmonst(mndx
);
2241 kill_genocided_monsters();
2242 update_inventory(); /* in case identified eggs were affected */
2244 int cnt
= 0, census
= monster_census(FALSE
);
2246 if (!(mons
[mndx
].geno
& G_UNIQ
)
2247 && !(mvitals
[mndx
].mvflags
& (G_GENOD
| G_EXTINCT
)))
2248 for (i
= rn1(3, 4); i
> 0; i
--) {
2249 if (!makemon(ptr
, u
.ux
, u
.uy
, NO_MINVENT
))
2250 break; /* couldn't make one */
2252 if (mvitals
[mndx
].mvflags
& G_EXTINCT
)
2253 break; /* just made last one */
2256 /* accumulated 'cnt' doesn't take groups into account;
2257 assume bringing in new mon(s) didn't remove any old ones */
2258 cnt
= monster_census(FALSE
) - census
;
2259 pline("Sent in %s%s.", (cnt
> 1) ? "some " : "",
2260 (cnt
> 1) ? makeplural(buf
) : an(buf
));
2262 pline1(nothing_happens
);
2270 struct obj
*reuse_ball
= (sobj
&& sobj
->otyp
== HEAVY_IRON_BALL
)
2271 ? sobj
: (struct obj
*) 0;
2273 /* KMH -- Punishment is still okay when you are riding */
2275 You("are being punished for your misbehavior!");
2277 Your("iron ball gets heavier.");
2278 uball
->owt
+= IRON_BALL_W_INCR
* (1 + sobj
->cursed
);
2281 if (amorphous(youmonst
.data
) || is_whirly(youmonst
.data
)
2282 || unsolid(youmonst
.data
)) {
2284 pline("A ball and chain appears, then falls away.");
2285 dropy(mkobj(BALL_CLASS
, TRUE
));
2291 setworn(mkobj(CHAIN_CLASS
, TRUE
), W_CHAIN
);
2293 setworn(mkobj(BALL_CLASS
, TRUE
), W_BALL
);
2295 setworn(reuse_ball
, W_BALL
);
2296 uball
->spe
= 1; /* special ball (see save) */
2299 * Place ball & chain if not swallowed. If swallowed, the ball &
2300 * chain variables will be set at the next call to placebc().
2305 set_bc(1); /* set up ball and chain variables */
2306 newsym(u
.ux
, u
.uy
); /* see ball&chain if can't see self */
2310 /* remove the ball and chain */
2314 struct obj
*savechain
= uchain
;
2316 obj_extract_self(uchain
);
2317 newsym(uchain
->ox
, uchain
->oy
);
2318 setworn((struct obj
*) 0, W_CHAIN
);
2319 dealloc_obj(savechain
);
2321 setworn((struct obj
*) 0, W_BALL
);
2324 /* some creatures have special data structures that only make sense in their
2325 * normal locations -- if the player tries to create one elsewhere, or to
2326 * revive one, the disoriented creature becomes a zombie
2329 cant_revive(mtype
, revival
, from_obj
)
2332 struct obj
*from_obj
;
2334 /* SHOPKEEPERS can be revived now */
2335 if (*mtype
== PM_GUARD
|| (*mtype
== PM_SHOPKEEPER
&& !revival
)
2336 || *mtype
== PM_HIGH_PRIEST
|| *mtype
== PM_ALIGNED_PRIEST
2337 || *mtype
== PM_ANGEL
) {
2338 *mtype
= PM_HUMAN_ZOMBIE
;
2340 } else if (*mtype
== PM_LONG_WORM_TAIL
) { /* for create_particular() */
2341 *mtype
= PM_LONG_WORM
;
2343 } else if (unique_corpstat(&mons
[*mtype
])
2344 && (!from_obj
|| !has_omonst(from_obj
))) {
2345 /* unique corpses (from bones or wizard mode wish) or
2346 statues (bones or any wish) end up as shapechangers */
2347 *mtype
= PM_DOPPELGANGER
;
2354 * Make a new monster with the type controlled by the user.
2356 * Note: when creating a monster by class letter, specifying the
2357 * "strange object" (']') symbol produces a random monster rather
2358 * than a mimic. This behavior quirk is useful so don't "fix" it
2359 * (use 'm'--or "mimic"--to create a random mimic).
2361 * Used in wizard mode only (for ^G command and for scroll or spell
2362 * of create monster). Once upon a time, an earlier incarnation of
2363 * this code was also used for the scroll/spell in explore mode.
2368 char buf
[BUFSZ
], *bufp
, monclass
;
2370 int which
, tryct
, i
, firstchoice
= NON_PM
;
2371 struct permonst
*whichpm
= NULL
;
2373 boolean madeany
= FALSE
, randmonst
= FALSE
,
2374 maketame
, makepeaceful
, makehostile
, saddled
, invisible
,
2380 monclass
= MAXMCLASSES
;
2381 which
= urole
.malenum
; /* an arbitrary index into mons[] */
2382 maketame
= makepeaceful
= makehostile
= FALSE
;
2383 sleeping
= saddled
= invisible
= FALSE
;
2384 fem
= -1; /* gender not specified */
2385 getlin("Create what kind of monster? [type the name or symbol]", buf
);
2386 bufp
= mungspaces(buf
);
2387 if (*bufp
== '\033')
2389 if ((tmpp
= strstri(bufp
, "saddled ")) != 0) {
2391 (void) memset(tmpp
, ' ', sizeof "saddled " - 1);
2393 if ((tmpp
= strstri(bufp
, "sleeping ")) != 0) {
2395 (void) memset(tmpp
, ' ', sizeof "sleeping " - 1);
2397 if ((tmpp
= strstri(bufp
, "invisible ")) != 0) {
2399 (void) memset(tmpp
, ' ', sizeof "invisible " - 1);
2401 /* check "female" before "male" to avoid false hit mid-word */
2402 if ((tmpp
= strstri(bufp
, "female ")) != 0) {
2404 (void) memset(tmpp
, ' ', sizeof "female " - 1);
2406 if ((tmpp
= strstri(bufp
, "male ")) != 0) {
2408 (void) memset(tmpp
, ' ', sizeof "male " - 1);
2410 bufp
= mungspaces(bufp
); /* after potential memset(' ') */
2411 /* allow the initial disposition to be specified */
2412 if (!strncmpi(bufp
, "tame ", 5)) {
2415 } else if (!strncmpi(bufp
, "peaceful ", 9)) {
2417 makepeaceful
= TRUE
;
2418 } else if (!strncmpi(bufp
, "hostile ", 8)) {
2422 /* decide whether a valid monster was chosen */
2423 if (wizard
&& (!strcmp(bufp
, "*") || !strcmp(bufp
, "random"))) {
2427 which
= name_to_mon(bufp
);
2428 if (which
>= LOW_PM
)
2429 break; /* got one */
2430 monclass
= name_to_monclass(bufp
, &which
);
2431 if (which
>= LOW_PM
) {
2432 monclass
= MAXMCLASSES
; /* matters below */
2434 } else if (monclass
> 0) {
2435 which
= urole
.malenum
; /* reset from NON_PM */
2438 /* no good; try again... */
2439 pline("I've never heard of such monsters.");
2440 } while (--tryct
> 0);
2443 pline1(thats_enough_tries
);
2446 firstchoice
= which
;
2447 if (cant_revive(&which
, FALSE
, (struct obj
*) 0)) {
2448 /* wizard mode can override handling of special monsters */
2449 Sprintf(buf
, "Creating %s instead; force %s?",
2450 mons
[which
].mname
, mons
[firstchoice
].mname
);
2452 which
= firstchoice
;
2454 whichpm
= &mons
[which
];
2456 for (i
= 0; i
<= multi
; i
++) {
2457 if (monclass
!= MAXMCLASSES
)
2458 whichpm
= mkclass(monclass
, 0);
2460 whichpm
= rndmonst();
2461 mtmp
= makemon(whichpm
, u
.ux
, u
.uy
, NO_MM_FLAGS
);
2463 /* quit trying if creation failed and is going to repeat */
2464 if (monclass
== MAXMCLASSES
&& !randmonst
)
2466 /* otherwise try again */
2469 /* 'is_FOO()' ought to be called 'always_FOO()' */
2470 if (fem
!= -1 && !is_male(mtmp
->data
) && !is_female(mtmp
->data
))
2471 mtmp
->female
= fem
; /* ignored for is_neuter() */
2473 (void) tamedog(mtmp
, (struct obj
*) 0);
2474 } else if (makepeaceful
|| makehostile
) {
2475 mtmp
->mtame
= 0; /* sanity precaution */
2476 mtmp
->mpeaceful
= makepeaceful
? 1 : 0;
2479 if (saddled
&& can_saddle(mtmp
) && !which_armor(mtmp
, W_SADDLE
)) {
2480 struct obj
*otmp
= mksobj(SADDLE
, TRUE
, FALSE
);
2482 put_saddle_on_mon(otmp
, mtmp
);
2485 mon_set_minvis(mtmp
);
2487 mtmp
->msleeping
= 1;
2489 /* in case we got a doppelganger instead of what was asked
2490 for, make it start out looking like what was asked for */
2491 if (mtmp
->cham
!= NON_PM
&& firstchoice
!= NON_PM
2492 && mtmp
->cham
!= firstchoice
)
2493 (void) newcham(mtmp
, &mons
[firstchoice
], FALSE
, FALSE
);