1 /* aNetHack 0.0.1 read.c $ANH-Date: 1467718299 2016/07/05 11:31:39 $ $ANH-Branch: master $:$ANH-Revision: 1.140 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* aNetHack 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
;
904 setmangry(mtmp
, FALSE
);
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
],
1419 case SCR_TELEPORTATION
:
1420 if (confused
|| scursed
) {
1423 known
= scrolltele(sobj
);
1426 case SCR_GOLD_DETECTION
:
1427 if ((confused
|| scursed
) ? trap_detect(sobj
) : gold_detect(sobj
))
1428 sobj
= 0; /* failure: strange_feeling() -> useup() */
1430 case SCR_FOOD_DETECTION
:
1431 case SPE_DETECT_FOOD
:
1432 if (food_detect(sobj
))
1433 sobj
= 0; /* nothing detected: strange_feeling -> useup */
1436 /* known = TRUE; -- handled inline here */
1437 /* use up the scroll first, before makeknown() performs a
1438 perm_invent update; also simplifies empty invent check */
1440 sobj
= 0; /* it's gone */
1442 You("identify this as an identify scroll.");
1443 else if (!already_known
|| !invent
)
1444 /* force feedback now if invent became
1445 empty after using up this scroll */
1446 pline("This is an identify scroll.");
1448 (void) learnscrolltyp(SCR_IDENTIFY
);
1452 if (sblessed
|| (!scursed
&& !rn2(5))) {
1454 /* note: if cval==0, identify all items */
1455 if (cval
== 1 && sblessed
&& Luck
> 0)
1458 if (invent
&& !confused
) {
1459 identify_pack(cval
, !already_known
);
1460 } else if (otyp
== SPE_IDENTIFY
) {
1461 /* when casting a spell we know we're not confused,
1462 so inventory must be empty (another message has
1463 already been given above if reading a scroll) */
1464 pline("You're not carrying anything to be identified.");
1470 You_feel("discharged.");
1473 You_feel("charged up!");
1474 u
.uen
+= d(sblessed
? 6 : 4, 4);
1475 if (u
.uen
> u
.uenmax
) /* if current energy is already at */
1476 u
.uenmax
= u
.uen
; /* or near maximum, increase maximum */
1478 u
.uen
= u
.uenmax
; /* otherwise restore current to max */
1483 /* known = TRUE; -- handled inline here */
1484 if (!already_known
) {
1485 pline("This is a charging scroll.");
1488 /* use it up now to prevent it from showing in the
1489 getobj picklist because the "disappears" message
1490 was already delivered */
1492 sobj
= 0; /* it's gone */
1493 otmp
= getobj(all_count
, "charge");
1495 recharge(otmp
, scursed
? -1 : sblessed
? 1 : 0);
1497 case SCR_MAGIC_MAPPING
:
1498 if (level
.flags
.nommap
) {
1499 Your("mind is filled with crazy lines!");
1501 pline("Wow! Modern art.");
1503 Your("%s spins in bewilderment.", body_part(HEAD
));
1504 make_confused(HConfusion
+ rnd(30), FALSE
);
1510 for (x
= 1; x
< COLNO
; x
++)
1511 for (y
= 0; y
< ROWNO
; y
++)
1512 if (levl
[x
][y
].typ
== SDOOR
)
1513 cvt_sdoor_to_door(&levl
[x
][y
]);
1514 /* do_mapping() already reveals secret passages */
1517 case SPE_MAGIC_MAPPING
:
1518 if (level
.flags
.nommap
) {
1519 Your("%s spins as %s blocks the spell!", body_part(HEAD
),
1521 make_confused(HConfusion
+ rnd(30), FALSE
);
1524 pline("A map coalesces in your mind!");
1525 cval
= (scursed
&& !confused
);
1527 HConfusion
= 1; /* to screw up map */
1530 HConfusion
= 0; /* restore */
1531 pline("Unfortunately, you can't grasp the details.");
1536 forget((!sblessed
? ALL_SPELLS
: 0)
1537 | (!confused
|| scursed
? ALL_MAP
: 0));
1538 if (Hallucination
) /* Ommmmmm! */
1539 Your("mind releases itself from mundane concerns.");
1540 else if (!strncmpi(plname
, "Maud", 4))
1542 "As your mind turns inward on itself, you forget everything else.");
1544 pline("Who was that Maud person anyway?");
1546 pline("Thinking of Maud you forget everything else.");
1547 exercise(A_WIS
, FALSE
);
1550 cval
= bcsign(sobj
);
1552 sobj
= 0; /* it's gone */
1554 (void) learnscrolltyp(SCR_FIRE
);
1556 if (Fire_resistance
) {
1557 shieldeff(u
.ux
, u
.uy
);
1559 pline("Oh, look, what a pretty fire in your %s.",
1560 makeplural(body_part(HAND
)));
1562 You_feel("a pleasant warmth in your %s.",
1563 makeplural(body_part(HAND
)));
1565 pline_The("scroll catches fire and you burn your %s.",
1566 makeplural(body_part(HAND
)));
1567 losehp(1, "scroll of fire", KILLED_BY_AN
);
1572 pline_The("%s around you vaporizes violently!", hliquid("water"));
1574 pline_The("scroll erupts in a tower of flame!");
1575 iflags
.last_msg
= PLNMSG_TOWER_OF_FLAME
; /* for explode() */
1578 explode(u
.ux
, u
.uy
, 11, (2 * (rn1(3, 3) + 2 * cval
) + 1) / 3,
1579 SCROLL_CLASS
, EXPL_FIERY
);
1582 /* TODO: handle steeds */
1583 if (!Is_rogue_level(&u
.uz
) && has_ceiling(&u
.uz
)
1584 && (!In_endgame(&u
.uz
) || Is_earthlevel(&u
.uz
))) {
1588 /* Identify the scroll */
1590 You_hear("rumbling.");
1592 pline_The("%s rumbles %s you!", ceiling(u
.ux
, u
.uy
),
1593 sblessed
? "around" : "above");
1597 /* Loop through the surrounding squares */
1599 for (x
= u
.ux
- 1; x
<= u
.ux
+ 1; x
++) {
1600 for (y
= u
.uy
- 1; y
<= u
.uy
+ 1; y
++) {
1601 /* Is this a suitable spot? */
1602 if (isok(x
, y
) && !closed_door(x
, y
)
1603 && !IS_ROCK(levl
[x
][y
].typ
)
1604 && !IS_AIR(levl
[x
][y
].typ
)
1605 && (x
!= u
.ux
|| y
!= u
.uy
)) {
1607 drop_boulder_on_monster(x
, y
, confused
, TRUE
);
1611 /* Attack the player */
1613 drop_boulder_on_player(confused
, !scursed
, TRUE
, FALSE
);
1614 } else if (!nboulders
)
1615 pline("But nothing else happens.");
1618 case SCR_PUNISHMENT
:
1620 if (confused
|| sblessed
) {
1621 You_feel("guilty.");
1626 case SCR_STINKING_CLOUD
: {
1630 You("have found a scroll of stinking cloud!");
1632 pline("Where do you want to center the %scloud?",
1633 already_known
? "stinking " : "");
1636 getpos_sethilite(display_stinking_cloud_positions
);
1637 if (getpos(&cc
, TRUE
, "the desired position") < 0) {
1641 if (!is_valid_stinking_cloud_pos(cc
.x
, cc
.y
, TRUE
))
1643 (void) create_gas_cloud(cc
.x
, cc
.y
, 3 + bcsign(sobj
),
1644 8 + 4 * bcsign(sobj
));
1648 impossible("What weird effect is this? (%u)", otyp
);
1650 return sobj
? 0 : 1;
1654 drop_boulder_on_player(confused
, helmet_protects
, byu
, skip_uswallow
)
1655 boolean confused
, helmet_protects
, byu
, skip_uswallow
;
1660 /* hit monster if swallowed */
1661 if (u
.uswallow
&& !skip_uswallow
) {
1662 drop_boulder_on_monster(u
.ux
, u
.uy
, confused
, byu
);
1666 otmp2
= mksobj(confused
? ROCK
: BOULDER
, FALSE
, FALSE
);
1669 otmp2
->quan
= confused
? rn1(5, 2) : 1;
1670 otmp2
->owt
= weight(otmp2
);
1671 if (!amorphous(youmonst
.data
) && !Passes_walls
1672 && !noncorporeal(youmonst
.data
) && !unsolid(youmonst
.data
)) {
1673 You("are hit by %s!", doname(otmp2
));
1674 dmg
= dmgval(otmp2
, &youmonst
) * otmp2
->quan
;
1675 if (uarmh
&& helmet_protects
) {
1676 if (is_metallic(uarmh
)) {
1677 pline("Fortunately, you are wearing a hard helmet.");
1680 } else if (flags
.verbose
) {
1681 pline("%s does not protect you.", Yname2(uarmh
));
1686 /* Must be before the losehp(), for bones files */
1687 if (!flooreffects(otmp2
, u
.ux
, u
.uy
, "fall")) {
1688 place_object(otmp2
, u
.ux
, u
.uy
);
1693 losehp(Maybe_Half_Phys(dmg
), "scroll of earth", KILLED_BY_AN
);
1697 drop_boulder_on_monster(x
, y
, confused
, byu
)
1699 boolean confused
, byu
;
1701 register struct obj
*otmp2
;
1702 register struct monst
*mtmp
;
1704 /* Make the object(s) */
1705 otmp2
= mksobj(confused
? ROCK
: BOULDER
, FALSE
, FALSE
);
1707 return FALSE
; /* Shouldn't happen */
1708 otmp2
->quan
= confused
? rn1(5, 2) : 1;
1709 otmp2
->owt
= weight(otmp2
);
1711 /* Find the monster here (won't be player) */
1713 if (mtmp
&& !amorphous(mtmp
->data
) && !passes_walls(mtmp
->data
)
1714 && !noncorporeal(mtmp
->data
) && !unsolid(mtmp
->data
)) {
1715 struct obj
*helmet
= which_armor(mtmp
, W_ARMH
);
1718 if (cansee(mtmp
->mx
, mtmp
->my
)) {
1719 pline("%s is hit by %s!", Monnam(mtmp
), doname(otmp2
));
1720 if (mtmp
->minvis
&& !canspotmon(mtmp
))
1721 map_invisible(mtmp
->mx
, mtmp
->my
);
1722 } else if (u
.uswallow
&& mtmp
== u
.ustuck
)
1723 You_hear("something hit %s %s over your %s!",
1724 s_suffix(mon_nam(mtmp
)), mbodypart(mtmp
, STOMACH
),
1727 mdmg
= dmgval(otmp2
, mtmp
) * otmp2
->quan
;
1729 if (is_metallic(helmet
)) {
1730 if (canspotmon(mtmp
))
1731 pline("Fortunately, %s is wearing a hard helmet.",
1734 You_hear("a clanging sound.");
1738 if (canspotmon(mtmp
))
1739 pline("%s's %s does not protect %s.", Monnam(mtmp
),
1740 xname(helmet
), mhim(mtmp
));
1744 if (mtmp
->mhp
<= 0) {
1748 pline("%s is killed.", Monnam(mtmp
));
1752 } else if (u
.uswallow
&& mtmp
== u
.ustuck
) {
1753 obfree(otmp2
, (struct obj
*) 0);
1754 /* fall through to player */
1755 drop_boulder_on_player(confused
, TRUE
, FALSE
, TRUE
);
1758 /* Drop the rock/boulder to the floor */
1759 if (!flooreffects(otmp2
, x
, y
, "fall")) {
1760 place_object(otmp2
, x
, y
);
1762 newsym(x
, y
); /* map the rock */
1767 /* overcharging any wand or zapping/engraving cursed wand */
1769 wand_explode(obj
, chg
)
1771 int chg
; /* recharging */
1773 const char *expl
= !chg
? "suddenly" : "vibrates violently and";
1776 /* number of damage dice */
1778 chg
= 2; /* zap/engrave adjustment */
1781 n
= 2; /* arbitrary minimum */
1782 /* size of damage dice */
1783 switch (obj
->otyp
) {
1787 case WAN_CANCELLATION
:
1790 case WAN_UNDEAD_TURNING
:
1796 case WAN_MAGIC_MISSILE
:
1806 /* inflict damage and destroy the wand */
1808 obj
->in_use
= TRUE
; /* in case losehp() is fatal (or --More--^C) */
1809 pline("%s %s explodes!", Yname2(obj
), expl
);
1810 losehp(Maybe_Half_Phys(dmg
), "exploding wand", KILLED_BY_AN
);
1812 /* obscure side-effect */
1813 exercise(A_STR
, FALSE
);
1816 /* used to collect gremlins being hit by light so that they can be processed
1817 after vision for the entire lit area has been brought up to date */
1822 STATIC_VAR
struct litmon
*gremlins
= 0;
1825 * Low-level lit-field update routine.
1833 struct litmon
*gremlin
;
1837 if ((mtmp
= m_at(x
, y
)) != 0 && mtmp
->data
== &mons
[PM_GREMLIN
]) {
1838 gremlin
= (struct litmon
*) alloc(sizeof *gremlin
);
1839 gremlin
->mon
= mtmp
;
1840 gremlin
->nxt
= gremlins
;
1845 snuff_light_source(x
, y
);
1851 register boolean on
;
1854 char is_lit
; /* value is irrelevant; we use its address
1855 as a `not null' flag for set_lit() */
1857 /* first produce the text (provided you're not blind) */
1859 register struct obj
*otmp
;
1863 pline("It seems even darker in here than before.");
1865 if (uwep
&& artifact_light(uwep
) && uwep
->lamplit
)
1866 pline("Suddenly, the only light left comes from %s!",
1869 You("are surrounded by darkness!");
1873 /* the magic douses lamps, et al, too */
1874 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
1876 (void) snuff_lit(otmp
);
1881 else if (is_animal(u
.ustuck
->data
))
1882 pline("%s %s is lit.", s_suffix(Monnam(u
.ustuck
)),
1883 mbodypart(u
.ustuck
, STOMACH
));
1884 else if (is_whirly(u
.ustuck
->data
))
1885 pline("%s shines briefly.", Monnam(u
.ustuck
));
1887 pline("%s glistens.", Monnam(u
.ustuck
));
1889 pline("A lit field surrounds you!");
1892 /* No-op when swallowed or in water */
1893 if (u
.uswallow
|| Underwater
|| Is_waterlevel(&u
.uz
))
1896 * If we are darkening the room and the hero is punished but not
1897 * blind, then we have to pick up and replace the ball and chain so
1898 * that we don't remember them if they are out of sight.
1900 if (Punished
&& !on
&& !Blind
)
1901 move_bc(1, 0, uball
->ox
, uball
->oy
, uchain
->ox
, uchain
->oy
);
1903 if (Is_rogue_level(&u
.uz
)) {
1904 /* Can't use do_clear_area because MAX_RADIUS is too small */
1905 /* rogue lighting must light the entire room */
1906 int rnum
= levl
[u
.ux
][u
.uy
].roomno
- ROOMOFFSET
;
1910 for (rx
= rooms
[rnum
].lx
- 1; rx
<= rooms
[rnum
].hx
+ 1; rx
++)
1911 for (ry
= rooms
[rnum
].ly
- 1; ry
<= rooms
[rnum
].hy
+ 1; ry
++)
1913 (genericptr_t
) (on
? &is_lit
: (char *) 0));
1914 rooms
[rnum
].rlit
= on
;
1916 /* hallways remain dark on the rogue level */
1918 do_clear_area(u
.ux
, u
.uy
,
1919 (obj
&& obj
->oclass
== SCROLL_CLASS
&& obj
->blessed
)
1921 set_lit
, (genericptr_t
) (on
? &is_lit
: (char *) 0));
1924 * If we are not blind, then force a redraw on all positions in sight
1925 * by temporarily blinding the hero. The vision recalculation will
1926 * correctly update all previously seen positions *and* correctly
1927 * set the waslit bit [could be messed up from above].
1932 /* replace ball&chain */
1933 if (Punished
&& !on
)
1934 move_bc(0, 0, uball
->ox
, uball
->oy
, uchain
->ox
, uchain
->oy
);
1937 vision_full_recalc
= 1; /* delayed vision recalculation */
1939 struct litmon
*gremlin
;
1941 /* can't delay vision recalc after all */
1943 /* after vision has been updated, monsters who are affected
1944 when hit by light can now be hit by it */
1947 gremlins
= gremlin
->nxt
;
1948 light_hits_gremlin(gremlin
->mon
, rnd(5));
1949 free((genericptr_t
) gremlin
);
1957 int i
, j
, immunecnt
, gonecnt
, goodcnt
, class, feel_dead
= 0;
1959 boolean gameover
= FALSE
; /* true iff killed self */
1963 pline1(thats_enough_tries
);
1967 getlin("What class of monsters do you wish to genocide?", buf
);
1968 (void) mungspaces(buf
);
1970 /* choosing "none" preserves genocideless conduct */
1971 if (*buf
== '\033' || !strcmpi(buf
, "none")
1972 || !strcmpi(buf
, "nothing"))
1975 class = name_to_monclass(buf
, (int *) 0);
1976 if (class == 0 && (i
= name_to_mon(buf
)) != NON_PM
)
1977 class = mons
[i
].mlet
;
1978 immunecnt
= gonecnt
= goodcnt
= 0;
1979 for (i
= LOW_PM
; i
< NUMMONS
; i
++) {
1980 if (mons
[i
].mlet
== class) {
1981 if (!(mons
[i
].geno
& G_GENO
))
1983 else if (mvitals
[i
].mvflags
& G_GENOD
)
1989 if (!goodcnt
&& class != mons
[urole
.malenum
].mlet
1990 && class != mons
[urace
.malenum
].mlet
) {
1992 pline("All such monsters are already nonexistent.");
1993 else if (immunecnt
|| class == S_invisible
)
1994 You("aren't permitted to genocide such monsters.");
1995 else if (wizard
&& buf
[0] == '*') {
1996 register struct monst
*mtmp
, *mtmp2
;
1999 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp2
) {
2001 if (DEADMONSTER(mtmp
))
2006 pline("Eliminated %d monster%s.", gonecnt
, plur(gonecnt
));
2009 pline("That %s does not represent any monster.",
2010 strlen(buf
) == 1 ? "symbol" : "response");
2014 for (i
= LOW_PM
; i
< NUMMONS
; i
++) {
2015 if (mons
[i
].mlet
== class) {
2018 Strcpy(nam
, makeplural(mons
[i
].mname
));
2019 /* Although "genus" is Latin for race, the hero benefits
2020 * from both race and role; thus genocide affects either.
2022 if (Your_Own_Role(i
) || Your_Own_Race(i
)
2023 || ((mons
[i
].geno
& G_GENO
)
2024 && !(mvitals
[i
].mvflags
& G_GENOD
))) {
2025 /* This check must be first since player monsters might
2026 * have G_GENOD or !G_GENO.
2028 mvitals
[i
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2030 kill_genocided_monsters();
2031 update_inventory(); /* eggs & tins */
2032 pline("Wiped out all %s.", nam
);
2033 if (Upolyd
&& i
== u
.umonnum
) {
2038 /* finish genociding this class of
2039 monsters before ultimately dying */
2044 /* Self-genocide if it matches either your race
2045 or role. Assumption: male and female forms
2046 share same monster class. */
2047 if (i
== urole
.malenum
|| i
== urace
.malenum
) {
2051 You_feel("dead inside.");
2058 } else if (mvitals
[i
].mvflags
& G_GENOD
) {
2060 pline("All %s are already nonexistent.", nam
);
2061 } else if (!gameover
) {
2062 /* suppress feedback about quest beings except
2063 for those applicable to our own role */
2064 if ((mons
[i
].msound
!= MS_LEADER
2065 || quest_info(MS_LEADER
) == i
)
2066 && (mons
[i
].msound
!= MS_NEMESIS
2067 || quest_info(MS_NEMESIS
) == i
)
2068 && (mons
[i
].msound
!= MS_GUARDIAN
2069 || quest_info(MS_GUARDIAN
) == i
)
2070 /* non-leader/nemesis/guardian role-specific monster
2072 && (i
!= PM_NINJA
/* nuisance */
2073 || Role_if(PM_SAMURAI
))) {
2074 boolean named
, uniq
;
2076 named
= type_is_pname(&mons
[i
]) ? TRUE
: FALSE
;
2077 uniq
= (mons
[i
].geno
& G_UNIQ
) ? TRUE
: FALSE
;
2078 /* one special case */
2079 if (i
== PM_HIGH_PRIEST
)
2082 You("aren't permitted to genocide %s%s.",
2083 (uniq
&& !named
) ? "the " : "",
2084 (uniq
|| named
) ? mons
[i
].mname
: nam
);
2089 if (gameover
|| u
.uhp
== -1) {
2090 killer
.format
= KILLED_BY_AN
;
2091 Strcpy(killer
.name
, "scroll of genocide");
2105 /* 0 = no genocide; create monsters (cursed scroll) */
2106 /* 1 = normal genocide */
2107 /* 3 = forced genocide of player */
2108 /* 5 (4 | 1) = normal genocide from throne */
2111 register int i
, killplayer
= 0;
2113 register struct permonst
*ptr
;
2117 mndx
= u
.umonster
; /* non-polymorphed mon num */
2119 Strcpy(buf
, ptr
->mname
);
2124 /* cursed effect => no free pass (unless rndmonst() fails) */
2125 if (!(how
& REALLY
) && (ptr
= rndmonst()) != 0)
2128 pline1(thats_enough_tries
);
2131 getlin("What monster do you want to genocide? [type the name]",
2133 (void) mungspaces(buf
);
2134 /* choosing "none" preserves genocideless conduct */
2135 if (*buf
== '\033' || !strcmpi(buf
, "none")
2136 || !strcmpi(buf
, "nothing")) {
2137 /* ... but no free pass if cursed */
2138 if (!(how
& REALLY
) && (ptr
= rndmonst()) != 0)
2139 break; /* remaining checks don't apply */
2144 mndx
= name_to_mon(buf
);
2145 if (mndx
== NON_PM
|| (mvitals
[mndx
].mvflags
& G_GENOD
)) {
2146 pline("Such creatures %s exist in this world.",
2147 (mndx
== NON_PM
) ? "do not" : "no longer");
2151 /* Although "genus" is Latin for race, the hero benefits
2152 * from both race and role; thus genocide affects either.
2154 if (Your_Own_Role(mndx
) || Your_Own_Race(mndx
)) {
2159 adjalign(-sgn(u
.ualign
.type
));
2161 adjalign(sgn(u
.ualign
.type
));
2163 if (!(ptr
->geno
& G_GENO
)) {
2165 /* FIXME: unconditional "caverns" will be silly in some
2166 * circumstances. Who's speaking? Divine pronouncements
2167 * aren't supposed to be hampered by deafness....
2170 pline("A thunderous voice booms through the caverns:");
2171 verbalize("No, mortal! That will not be done.");
2175 /* KMH -- Unchanging prevents rehumanization */
2176 if (Unchanging
&& ptr
== youmonst
.data
)
2180 mndx
= monsndx(ptr
); /* needed for the 'no free pass' cases */
2184 if (Hallucination
) {
2186 Strcpy(buf
, youmonst
.data
->mname
);
2188 Strcpy(buf
, (flags
.female
&& urole
.name
.f
) ? urole
.name
.f
2190 buf
[0] = lowc(buf
[0]);
2193 Strcpy(buf
, ptr
->mname
); /* make sure we have standard singular */
2194 if ((ptr
->geno
& G_UNIQ
) && ptr
!= &mons
[PM_HIGH_PRIEST
])
2195 which
= !type_is_pname(ptr
) ? "the " : "";
2198 /* setting no-corpse affects wishing and random tin generation */
2199 mvitals
[mndx
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2200 pline("Wiped out %s%s.", which
,
2201 (*which
!= 'a') ? buf
: makeplural(buf
));
2204 /* might need to wipe out dual role */
2205 if (urole
.femalenum
!= NON_PM
&& mndx
== urole
.malenum
)
2206 mvitals
[urole
.femalenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2207 if (urole
.femalenum
!= NON_PM
&& mndx
== urole
.femalenum
)
2208 mvitals
[urole
.malenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2209 if (urace
.femalenum
!= NON_PM
&& mndx
== urace
.malenum
)
2210 mvitals
[urace
.femalenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2211 if (urace
.femalenum
!= NON_PM
&& mndx
== urace
.femalenum
)
2212 mvitals
[urace
.malenum
].mvflags
|= (G_GENOD
| G_NOCORPSE
);
2216 killer
.format
= KILLED_BY
;
2217 Strcpy(killer
.name
, "genocidal confusion");
2218 } else if (how
& ONTHRONE
) {
2219 /* player selected while on a throne */
2220 killer
.format
= KILLED_BY_AN
;
2221 Strcpy(killer
.name
, "imperious order");
2222 } else { /* selected player deliberately, not confused */
2223 killer
.format
= KILLED_BY_AN
;
2224 Strcpy(killer
.name
, "scroll of genocide");
2227 /* Polymorphed characters will die as soon as they're rehumanized.
2229 /* KMH -- Unchanging prevents rehumanization */
2230 if (Upolyd
&& ptr
!= youmonst
.data
) {
2231 delayed_killer(POLYMORPH
, killer
.format
, killer
.name
);
2232 You_feel("dead inside.");
2235 } else if (ptr
== youmonst
.data
) {
2238 reset_rndmonst(mndx
);
2239 kill_genocided_monsters();
2240 update_inventory(); /* in case identified eggs were affected */
2242 int cnt
= 0, census
= monster_census(FALSE
);
2244 if (!(mons
[mndx
].geno
& G_UNIQ
)
2245 && !(mvitals
[mndx
].mvflags
& (G_GENOD
| G_EXTINCT
)))
2246 for (i
= rn1(3, 4); i
> 0; i
--) {
2247 if (!makemon(ptr
, u
.ux
, u
.uy
, NO_MINVENT
))
2248 break; /* couldn't make one */
2250 if (mvitals
[mndx
].mvflags
& G_EXTINCT
)
2251 break; /* just made last one */
2254 /* accumulated 'cnt' doesn't take groups into account;
2255 assume bringing in new mon(s) didn't remove any old ones */
2256 cnt
= monster_census(FALSE
) - census
;
2257 pline("Sent in %s%s.", (cnt
> 1) ? "some " : "",
2258 (cnt
> 1) ? makeplural(buf
) : an(buf
));
2260 pline1(nothing_happens
);
2268 struct obj
*reuse_ball
= (sobj
&& sobj
->otyp
== HEAVY_IRON_BALL
)
2269 ? sobj
: (struct obj
*) 0;
2271 /* KMH -- Punishment is still okay when you are riding */
2273 You("are being punished for your misbehavior!");
2275 Your("iron ball gets heavier.");
2276 uball
->owt
+= IRON_BALL_W_INCR
* (1 + sobj
->cursed
);
2279 if (amorphous(youmonst
.data
) || is_whirly(youmonst
.data
)
2280 || unsolid(youmonst
.data
)) {
2282 pline("A ball and chain appears, then falls away.");
2283 dropy(mkobj(BALL_CLASS
, TRUE
));
2289 setworn(mkobj(CHAIN_CLASS
, TRUE
), W_CHAIN
);
2291 setworn(mkobj(BALL_CLASS
, TRUE
), W_BALL
);
2293 setworn(reuse_ball
, W_BALL
);
2294 uball
->spe
= 1; /* special ball (see save) */
2297 * Place ball & chain if not swallowed. If swallowed, the ball &
2298 * chain variables will be set at the next call to placebc().
2303 set_bc(1); /* set up ball and chain variables */
2304 newsym(u
.ux
, u
.uy
); /* see ball&chain if can't see self */
2308 /* remove the ball and chain */
2312 struct obj
*savechain
= uchain
;
2314 obj_extract_self(uchain
);
2315 newsym(uchain
->ox
, uchain
->oy
);
2316 setworn((struct obj
*) 0, W_CHAIN
);
2317 dealloc_obj(savechain
);
2319 setworn((struct obj
*) 0, W_BALL
);
2322 /* some creatures have special data structures that only make sense in their
2323 * normal locations -- if the player tries to create one elsewhere, or to
2324 * revive one, the disoriented creature becomes a zombie
2327 cant_revive(mtype
, revival
, from_obj
)
2330 struct obj
*from_obj
;
2332 /* SHOPKEEPERS can be revived now */
2333 if (*mtype
== PM_GUARD
|| (*mtype
== PM_SHOPKEEPER
&& !revival
)
2334 || *mtype
== PM_HIGH_PRIEST
|| *mtype
== PM_ALIGNED_PRIEST
2335 || *mtype
== PM_ANGEL
) {
2336 *mtype
= PM_HUMAN_ZOMBIE
;
2338 } else if (*mtype
== PM_LONG_WORM_TAIL
) { /* for create_particular() */
2339 *mtype
= PM_LONG_WORM
;
2341 } else if (unique_corpstat(&mons
[*mtype
])
2342 && (!from_obj
|| !has_omonst(from_obj
))) {
2343 /* unique corpses (from bones or wizard mode wish) or
2344 statues (bones or any wish) end up as shapechangers */
2345 *mtype
= PM_DOPPELGANGER
;
2352 * Make a new monster with the type controlled by the user.
2354 * Note: when creating a monster by class letter, specifying the
2355 * "strange object" (']') symbol produces a random monster rather
2356 * than a mimic. This behavior quirk is useful so don't "fix" it
2357 * (use 'm'--or "mimic"--to create a random mimic).
2359 * Used in wizard mode only (for ^G command and for scroll or spell
2360 * of create monster). Once upon a time, an earlier incarnation of
2361 * this code was also used for the scroll/spell in explore mode.
2366 char buf
[BUFSZ
], *bufp
, monclass
;
2368 int which
, tryct
, i
, firstchoice
= NON_PM
;
2369 struct permonst
*whichpm
= NULL
;
2371 boolean madeany
= FALSE
, randmonst
= FALSE
,
2372 maketame
, makepeaceful
, makehostile
, saddled
, invisible
,
2378 monclass
= MAXMCLASSES
;
2379 which
= urole
.malenum
; /* an arbitrary index into mons[] */
2380 maketame
= makepeaceful
= makehostile
= FALSE
;
2381 sleeping
= saddled
= invisible
= FALSE
;
2382 fem
= -1; /* gender not specified */
2383 getlin("Create what kind of monster? [type the name or symbol]", buf
);
2384 bufp
= mungspaces(buf
);
2385 if (*bufp
== '\033')
2387 if ((tmpp
= strstri(bufp
, "saddled ")) != 0) {
2389 (void) memset(tmpp
, ' ', sizeof "saddled " - 1);
2391 if ((tmpp
= strstri(bufp
, "sleeping ")) != 0) {
2393 (void) memset(tmpp
, ' ', sizeof "sleeping " - 1);
2395 if ((tmpp
= strstri(bufp
, "invisible ")) != 0) {
2397 (void) memset(tmpp
, ' ', sizeof "invisible " - 1);
2399 /* check "female" before "male" to avoid false hit mid-word */
2400 if ((tmpp
= strstri(bufp
, "female ")) != 0) {
2402 (void) memset(tmpp
, ' ', sizeof "female " - 1);
2404 if ((tmpp
= strstri(bufp
, "male ")) != 0) {
2406 (void) memset(tmpp
, ' ', sizeof "male " - 1);
2408 bufp
= mungspaces(bufp
); /* after potential memset(' ') */
2409 /* allow the initial disposition to be specified */
2410 if (!strncmpi(bufp
, "tame ", 5)) {
2413 } else if (!strncmpi(bufp
, "peaceful ", 9)) {
2415 makepeaceful
= TRUE
;
2416 } else if (!strncmpi(bufp
, "hostile ", 8)) {
2420 /* decide whether a valid monster was chosen */
2421 if (wizard
&& (!strcmp(bufp
, "*") || !strcmp(bufp
, "random"))) {
2425 which
= name_to_mon(bufp
);
2426 if (which
>= LOW_PM
)
2427 break; /* got one */
2428 monclass
= name_to_monclass(bufp
, &which
);
2429 if (which
>= LOW_PM
) {
2430 monclass
= MAXMCLASSES
; /* matters below */
2432 } else if (monclass
> 0) {
2433 which
= urole
.malenum
; /* reset from NON_PM */
2436 /* no good; try again... */
2437 pline("I've never heard of such monsters.");
2438 } while (--tryct
> 0);
2441 pline1(thats_enough_tries
);
2444 firstchoice
= which
;
2445 if (cant_revive(&which
, FALSE
, (struct obj
*) 0)) {
2446 /* wizard mode can override handling of special monsters */
2447 Sprintf(buf
, "Creating %s instead; force %s?",
2448 mons
[which
].mname
, mons
[firstchoice
].mname
);
2450 which
= firstchoice
;
2452 whichpm
= &mons
[which
];
2454 for (i
= 0; i
<= multi
; i
++) {
2455 if (monclass
!= MAXMCLASSES
)
2456 whichpm
= mkclass(monclass
, 0);
2458 whichpm
= rndmonst();
2459 mtmp
= makemon(whichpm
, u
.ux
, u
.uy
, NO_MM_FLAGS
);
2461 /* quit trying if creation failed and is going to repeat */
2462 if (monclass
== MAXMCLASSES
&& !randmonst
)
2464 /* otherwise try again */
2467 /* 'is_FOO()' ought to be called 'always_FOO()' */
2468 if (fem
!= -1 && !is_male(mtmp
->data
) && !is_female(mtmp
->data
))
2469 mtmp
->female
= fem
; /* ignored for is_neuter() */
2471 (void) tamedog(mtmp
, (struct obj
*) 0);
2472 } else if (makepeaceful
|| makehostile
) {
2473 mtmp
->mtame
= 0; /* sanity precaution */
2474 mtmp
->mpeaceful
= makepeaceful
? 1 : 0;
2477 if (saddled
&& can_saddle(mtmp
) && !which_armor(mtmp
, W_SADDLE
)) {
2478 struct obj
*otmp
= mksobj(SADDLE
, TRUE
, FALSE
);
2480 put_saddle_on_mon(otmp
, mtmp
);
2483 mon_set_minvis(mtmp
);
2485 mtmp
->msleeping
= 1;
2487 /* in case we got a doppelganger instead of what was asked
2488 for, make it start out looking like what was asked for */
2489 if (mtmp
->cham
!= NON_PM
&& firstchoice
!= NON_PM
2490 && mtmp
->cham
!= firstchoice
)
2491 (void) newcham(mtmp
, &mons
[firstchoice
], FALSE
, FALSE
);