xref: /netbsd-src/games/rogue/use.c (revision 1182a44c59cae4d586117d55eca24b4b8b173211)
1*1182a44cSrillig /*	$NetBSD: use.c,v 1.11 2021/05/02 12:50:46 rillig Exp $	*/
27ee35daaScgd 
361f28255Scgd /*
47ee35daaScgd  * Copyright (c) 1988, 1993
57ee35daaScgd  *	The Regents of the University of California.  All rights reserved.
661f28255Scgd  *
761f28255Scgd  * This code is derived from software contributed to Berkeley by
861f28255Scgd  * Timothy C. Stoehr.
961f28255Scgd  *
1061f28255Scgd  * Redistribution and use in source and binary forms, with or without
1161f28255Scgd  * modification, are permitted provided that the following conditions
1261f28255Scgd  * are met:
1361f28255Scgd  * 1. Redistributions of source code must retain the above copyright
1461f28255Scgd  *    notice, this list of conditions and the following disclaimer.
1561f28255Scgd  * 2. Redistributions in binary form must reproduce the above copyright
1661f28255Scgd  *    notice, this list of conditions and the following disclaimer in the
1761f28255Scgd  *    documentation and/or other materials provided with the distribution.
18e5aeb4eaSagc  * 3. Neither the name of the University nor the names of its contributors
1961f28255Scgd  *    may be used to endorse or promote products derived from this software
2061f28255Scgd  *    without specific prior written permission.
2161f28255Scgd  *
2261f28255Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2361f28255Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2461f28255Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2561f28255Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2661f28255Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2761f28255Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2861f28255Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2961f28255Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3061f28255Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3161f28255Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3261f28255Scgd  * SUCH DAMAGE.
3361f28255Scgd  */
3461f28255Scgd 
352736b511Slukem #include <sys/cdefs.h>
3661f28255Scgd #ifndef lint
377ee35daaScgd #if 0
387ee35daaScgd static char sccsid[] = "@(#)use.c	8.1 (Berkeley) 5/31/93";
397ee35daaScgd #else
40*1182a44cSrillig __RCSID("$NetBSD: use.c,v 1.11 2021/05/02 12:50:46 rillig Exp $");
417ee35daaScgd #endif
4261f28255Scgd #endif /* not lint */
4361f28255Scgd 
4461f28255Scgd /*
4561f28255Scgd  * use.c
4661f28255Scgd  *
4761f28255Scgd  * This source herein may be modified and/or distributed by anybody who
4861f28255Scgd  * so desires, with the following restrictions:
4961f28255Scgd  *    1.)  No portion of this notice shall be removed.
5061f28255Scgd  *    2.)  Credit shall not be taken for the creation of this source.
5161f28255Scgd  *    3.)  This code is not to be traded, sold, or used for personal
5261f28255Scgd  *         gain or profit.
5361f28255Scgd  *
5461f28255Scgd  */
5561f28255Scgd 
5661f28255Scgd #include "rogue.h"
5761f28255Scgd 
5861f28255Scgd short halluc = 0;
5961f28255Scgd short blind = 0;
6061f28255Scgd short confused = 0;
6161f28255Scgd short levitate = 0;
6261f28255Scgd short haste_self = 0;
6361f28255Scgd boolean see_invisible = 0;
6461f28255Scgd short extra_hp = 0;
6561f28255Scgd boolean detect_monster = 0;
6661f28255Scgd boolean con_mon = 0;
67130a8172Sdholland 
68130a8172Sdholland static const char strange_feeling[] =
69130a8172Sdholland 	"you have a strange feeling for a moment, then it passes";
7061f28255Scgd 
711e99780eSdholland static const char *get_ench_color(void);
721e99780eSdholland static void go_blind(void);
731e99780eSdholland static void hold_monster(void);
741e99780eSdholland static void idntfy(void);
751e99780eSdholland static void potion_heal(int);
761e99780eSdholland static void uncurse_all(void);
771e99780eSdholland 
782736b511Slukem void
quaff(void)79130a8172Sdholland quaff(void)
8061f28255Scgd {
8161f28255Scgd 	short ch;
8261f28255Scgd 	object *obj;
8361f28255Scgd 
8461f28255Scgd 	ch = pack_letter("quaff what?", POTION);
8561f28255Scgd 
8661f28255Scgd 	if (ch == CANCEL) {
8761f28255Scgd 		return;
8861f28255Scgd 	}
8961f28255Scgd 	if (!(obj = get_letter_object(ch))) {
90e94a5bc9Sdholland 		messagef(0, "no such item.");
9161f28255Scgd 		return;
9261f28255Scgd 	}
9361f28255Scgd 	if (obj->what_is != POTION) {
94e94a5bc9Sdholland 		messagef(0, "you can't drink that");
9561f28255Scgd 		return;
9661f28255Scgd 	}
9761f28255Scgd 	switch(obj->which_kind) {
9861f28255Scgd 		case INCREASE_STRENGTH:
99e94a5bc9Sdholland 			messagef(0, "you feel stronger now, what bulging muscles!");
10061f28255Scgd 			rogue.str_current++;
10161f28255Scgd 			if (rogue.str_current > rogue.str_max) {
10261f28255Scgd 				rogue.str_max = rogue.str_current;
10361f28255Scgd 			}
10461f28255Scgd 			break;
10561f28255Scgd 		case RESTORE_STRENGTH:
10661f28255Scgd 			rogue.str_current = rogue.str_max;
107e94a5bc9Sdholland 			messagef(0, "this tastes great, you feel warm all over");
10861f28255Scgd 			break;
10961f28255Scgd 		case HEALING:
110e94a5bc9Sdholland 			messagef(0, "you begin to feel better");
11161f28255Scgd 			potion_heal(0);
11261f28255Scgd 			break;
11361f28255Scgd 		case EXTRA_HEALING:
114e94a5bc9Sdholland 			messagef(0, "you begin to feel much better");
11561f28255Scgd 			potion_heal(1);
11661f28255Scgd 			break;
11761f28255Scgd 		case POISON:
11861f28255Scgd 			if (!sustain_strength) {
11961f28255Scgd 				rogue.str_current -= get_rand(1, 3);
12061f28255Scgd 				if (rogue.str_current < 1) {
12161f28255Scgd 					rogue.str_current = 1;
12261f28255Scgd 				}
12361f28255Scgd 			}
124e94a5bc9Sdholland 			messagef(0, "you feel very sick now");
12561f28255Scgd 			if (halluc) {
12661f28255Scgd 				unhallucinate();
12761f28255Scgd 			}
12861f28255Scgd 			break;
12961f28255Scgd 		case RAISE_LEVEL:
13061f28255Scgd 			rogue.exp_points = level_points[rogue.exp - 1];
131e94a5bc9Sdholland 			messagef(0, "you suddenly feel much more skillful");
13261f28255Scgd 			add_exp(1, 1);
13361f28255Scgd 			break;
13461f28255Scgd 		case BLINDNESS:
13561f28255Scgd 			go_blind();
13661f28255Scgd 			break;
13761f28255Scgd 		case HALLUCINATION:
138e94a5bc9Sdholland 			messagef(0, "oh wow, everything seems so cosmic");
13961f28255Scgd 			halluc += get_rand(500, 800);
14061f28255Scgd 			break;
14161f28255Scgd 		case DETECT_MONSTER:
14261f28255Scgd 			show_monsters();
14361f28255Scgd 			if (!(level_monsters.next_monster)) {
144e94a5bc9Sdholland 				messagef(0, "%s", strange_feeling);
14561f28255Scgd 			}
14661f28255Scgd 			break;
14761f28255Scgd 		case DETECT_OBJECTS:
14861f28255Scgd 			if (level_objects.next_object) {
14961f28255Scgd 				if (!blind) {
15061f28255Scgd 					show_objects();
15161f28255Scgd 				}
15261f28255Scgd 			} else {
153e94a5bc9Sdholland 				messagef(0, "%s", strange_feeling);
15461f28255Scgd 			}
15561f28255Scgd 			break;
15661f28255Scgd 		case CONFUSION:
157e94a5bc9Sdholland 			messagef(0, (halluc ? "what a trippy feeling" :
158e94a5bc9Sdholland 			"you feel confused"));
15961f28255Scgd 			cnfs();
16061f28255Scgd 			break;
16161f28255Scgd 		case LEVITATION:
162e94a5bc9Sdholland 			messagef(0, "you start to float in the air");
16361f28255Scgd 			levitate += get_rand(15, 30);
16461f28255Scgd 			being_held = bear_trap = 0;
16561f28255Scgd 			break;
16661f28255Scgd 		case HASTE_SELF:
167e94a5bc9Sdholland 			messagef(0, "you feel yourself moving much faster");
16861f28255Scgd 			haste_self += get_rand(11, 21);
16961f28255Scgd 			if (!(haste_self % 2)) {
17061f28255Scgd 				haste_self++;
17161f28255Scgd 			}
17261f28255Scgd 			break;
17361f28255Scgd 		case SEE_INVISIBLE:
174e94a5bc9Sdholland 			messagef(0, "hmm, this potion tastes like %sjuice",
175e94a5bc9Sdholland 				 fruit);
17661f28255Scgd 			if (blind) {
17761f28255Scgd 				unblind();
17861f28255Scgd 			}
17961f28255Scgd 			see_invisible = 1;
18061f28255Scgd 			relight();
18161f28255Scgd 			break;
18261f28255Scgd 	}
18361f28255Scgd 	print_stats((STAT_STRENGTH | STAT_HP));
18461f28255Scgd 	if (id_potions[obj->which_kind].id_status != CALLED) {
18561f28255Scgd 		id_potions[obj->which_kind].id_status = IDENTIFIED;
18661f28255Scgd 	}
18761f28255Scgd 	vanish(obj, 1, &rogue.pack);
18861f28255Scgd }
18961f28255Scgd 
1902736b511Slukem void
read_scroll(void)191130a8172Sdholland read_scroll(void)
19261f28255Scgd {
19361f28255Scgd 	short ch;
19461f28255Scgd 	object *obj;
19561f28255Scgd 
19661f28255Scgd 	ch = pack_letter("read what?", SCROL);
19761f28255Scgd 
19861f28255Scgd 	if (ch == CANCEL) {
19961f28255Scgd 		return;
20061f28255Scgd 	}
20161f28255Scgd 	if (!(obj = get_letter_object(ch))) {
202e94a5bc9Sdholland 		messagef(0, "no such item.");
20361f28255Scgd 		return;
20461f28255Scgd 	}
20561f28255Scgd 	if (obj->what_is != SCROL) {
206e94a5bc9Sdholland 		messagef(0, "you can't read that");
20761f28255Scgd 		return;
20861f28255Scgd 	}
20961f28255Scgd 	switch(obj->which_kind) {
21061f28255Scgd 		case SCARE_MONSTER:
211e94a5bc9Sdholland 			messagef(0, "you hear a maniacal laughter in the distance");
21261f28255Scgd 			break;
21361f28255Scgd 		case HOLD_MONSTER:
21461f28255Scgd 			hold_monster();
21561f28255Scgd 			break;
21661f28255Scgd 		case ENCH_WEAPON:
21761f28255Scgd 			if (rogue.weapon) {
21861f28255Scgd 				if (rogue.weapon->what_is == WEAPON) {
219e94a5bc9Sdholland 					messagef(0, "your %sglow%s %sfor a moment",
22061f28255Scgd 						name_of(rogue.weapon),
22161f28255Scgd 						((rogue.weapon->quantity <= 1) ? "s" : ""),
22261f28255Scgd 						get_ench_color());
22361f28255Scgd 					if (coin_toss()) {
22461f28255Scgd 						rogue.weapon->hit_enchant++;
22561f28255Scgd 					} else {
22661f28255Scgd 						rogue.weapon->d_enchant++;
22761f28255Scgd 					}
22861f28255Scgd 				}
22961f28255Scgd 				rogue.weapon->is_cursed = 0;
23061f28255Scgd 			} else {
231e94a5bc9Sdholland 				messagef(0, "your hands tingle");
23261f28255Scgd 			}
23361f28255Scgd 			break;
23461f28255Scgd 		case ENCH_ARMOR:
23561f28255Scgd 			if (rogue.armor) {
236e94a5bc9Sdholland 				messagef(0, "your armor glows %sfor a moment",
23761f28255Scgd 					get_ench_color());
23861f28255Scgd 				rogue.armor->d_enchant++;
23961f28255Scgd 				rogue.armor->is_cursed = 0;
24061f28255Scgd 				print_stats(STAT_ARMOR);
24161f28255Scgd 			} else {
242e94a5bc9Sdholland 				messagef(0, "your skin crawls");
24361f28255Scgd 			}
24461f28255Scgd 			break;
24561f28255Scgd 		case IDENTIFY:
246e94a5bc9Sdholland 			messagef(0, "this is a scroll of identify");
24761f28255Scgd 			obj->identified = 1;
24861f28255Scgd 			id_scrolls[obj->which_kind].id_status = IDENTIFIED;
24961f28255Scgd 			idntfy();
25061f28255Scgd 			break;
25161f28255Scgd 		case TELEPORT:
25261f28255Scgd 			tele();
25361f28255Scgd 			break;
25461f28255Scgd 		case SLEEP:
255e94a5bc9Sdholland 			messagef(0, "you fall asleep");
25661f28255Scgd 			take_a_nap();
25761f28255Scgd 			break;
25861f28255Scgd 		case PROTECT_ARMOR:
25961f28255Scgd 			if (rogue.armor) {
260e94a5bc9Sdholland 				messagef(0, "your armor is covered by a shimmering gold shield");
26161f28255Scgd 				rogue.armor->is_protected = 1;
26261f28255Scgd 				rogue.armor->is_cursed = 0;
26361f28255Scgd 			} else {
264e94a5bc9Sdholland 				messagef(0, "your acne seems to have disappeared");
26561f28255Scgd 			}
26661f28255Scgd 			break;
26761f28255Scgd 		case REMOVE_CURSE:
268e94a5bc9Sdholland 				messagef(0, (!halluc) ?
26961f28255Scgd 					"you feel as though someone is watching over you" :
270e94a5bc9Sdholland 					"you feel in touch with the universal oneness");
27161f28255Scgd 			uncurse_all();
27261f28255Scgd 			break;
27361f28255Scgd 		case CREATE_MONSTER:
27461f28255Scgd 			create_monster();
27561f28255Scgd 			break;
27661f28255Scgd 		case AGGRAVATE_MONSTER:
27761f28255Scgd 			aggravate();
27861f28255Scgd 			break;
27961f28255Scgd 		case MAGIC_MAPPING:
280e94a5bc9Sdholland 			messagef(0, "this scroll seems to have a map on it");
28161f28255Scgd 			draw_magic_map();
28261f28255Scgd 			break;
28361f28255Scgd 		case CON_MON:
28461f28255Scgd 			con_mon = 1;
285e94a5bc9Sdholland 			messagef(0, "your hands glow %sfor a moment",
286e94a5bc9Sdholland 				 get_ench_color());
28761f28255Scgd 			break;
28861f28255Scgd 	}
28961f28255Scgd 	if (id_scrolls[obj->which_kind].id_status != CALLED) {
29061f28255Scgd 		id_scrolls[obj->which_kind].id_status = IDENTIFIED;
29161f28255Scgd 	}
29261f28255Scgd 	vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
29361f28255Scgd }
29461f28255Scgd 
29561f28255Scgd /* vanish() does NOT handle a quiver of weapons with more than one
29661f28255Scgd  *  arrow (or whatever) in the quiver.  It will only decrement the count.
29761f28255Scgd  */
29861f28255Scgd 
2992736b511Slukem void
vanish(object * obj,short rm,object * pack)300130a8172Sdholland vanish(object *obj, short rm, object *pack)
30161f28255Scgd {
30261f28255Scgd 	if (obj->quantity > 1) {
30361f28255Scgd 		obj->quantity--;
30461f28255Scgd 	} else {
30561f28255Scgd 		if (obj->in_use_flags & BEING_WIELDED) {
30661f28255Scgd 			unwield(obj);
30761f28255Scgd 		} else if (obj->in_use_flags & BEING_WORN) {
30861f28255Scgd 			unwear(obj);
30961f28255Scgd 		} else if (obj->in_use_flags & ON_EITHER_HAND) {
31061f28255Scgd 			un_put_on(obj);
31161f28255Scgd 		}
31261f28255Scgd 		take_from_pack(obj, pack);
31361f28255Scgd 		free_object(obj);
31461f28255Scgd 	}
31561f28255Scgd 	if (rm) {
31661f28255Scgd 		(void)reg_move();
31761f28255Scgd 	}
31861f28255Scgd }
31961f28255Scgd 
3201e99780eSdholland static void
potion_heal(int extra)321130a8172Sdholland potion_heal(int extra)
32261f28255Scgd {
32361f28255Scgd 	float ratio;
32461f28255Scgd 	short add;
32561f28255Scgd 
32661f28255Scgd 	rogue.hp_current += rogue.exp;
32761f28255Scgd 
32861f28255Scgd 	ratio = ((float)rogue.hp_current) / rogue.hp_max;
32961f28255Scgd 
33061f28255Scgd 	if (ratio >= 1.00) {
33161f28255Scgd 		rogue.hp_max += (extra ? 2 : 1);
33261f28255Scgd 		extra_hp += (extra ? 2 : 1);
33361f28255Scgd 		rogue.hp_current = rogue.hp_max;
33461f28255Scgd 	} else if (ratio >= 0.90) {
33561f28255Scgd 		rogue.hp_max += (extra ? 1 : 0);
33661f28255Scgd 		extra_hp += (extra ? 1 : 0);
33761f28255Scgd 		rogue.hp_current = rogue.hp_max;
33861f28255Scgd 	} else {
33961f28255Scgd 		if (ratio < 0.33) {
34061f28255Scgd 			ratio = 0.33;
34161f28255Scgd 		}
34261f28255Scgd 		if (extra) {
34361f28255Scgd 			ratio += ratio;
34461f28255Scgd 		}
345130a8172Sdholland 		add = (short)(ratio * (rogue.hp_max - rogue.hp_current));
34661f28255Scgd 		rogue.hp_current += add;
34761f28255Scgd 		if (rogue.hp_current > rogue.hp_max) {
34861f28255Scgd 			rogue.hp_current = rogue.hp_max;
34961f28255Scgd 		}
35061f28255Scgd 	}
35161f28255Scgd 	if (blind) {
35261f28255Scgd 		unblind();
35361f28255Scgd 	}
35461f28255Scgd 	if (confused && extra) {
35561f28255Scgd 		unconfuse();
35661f28255Scgd 	} else if (confused) {
35761f28255Scgd 		confused = (confused / 2) + 1;
35861f28255Scgd 	}
35961f28255Scgd 	if (halluc && extra) {
36061f28255Scgd 		unhallucinate();
36161f28255Scgd 	} else if (halluc) {
36261f28255Scgd 		halluc = (halluc / 2) + 1;
36361f28255Scgd 	}
36461f28255Scgd }
36561f28255Scgd 
3661e99780eSdholland static void
idntfy(void)367130a8172Sdholland idntfy(void)
36861f28255Scgd {
36961f28255Scgd 	short ch;
37061f28255Scgd 	object *obj;
37161f28255Scgd 	struct id *id_table;
37261f28255Scgd 	char desc[DCOLS];
37361f28255Scgd AGAIN:
37461f28255Scgd 	ch = pack_letter("what would you like to identify?", ALL_OBJECTS);
37561f28255Scgd 
37661f28255Scgd 	if (ch == CANCEL) {
37761f28255Scgd 		return;
37861f28255Scgd 	}
37961f28255Scgd 	if (!(obj = get_letter_object(ch))) {
380e94a5bc9Sdholland 		messagef(0, "no such item, try again");
381e94a5bc9Sdholland 		messagef(0, "%s", "");	/* gcc objects to just "" */
38261f28255Scgd 		check_message();
38361f28255Scgd 		goto AGAIN;
38461f28255Scgd 	}
38561f28255Scgd 	obj->identified = 1;
38661f28255Scgd 	if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) {
38761f28255Scgd 		id_table = get_id_table(obj);
38861f28255Scgd 		id_table[obj->which_kind].id_status = IDENTIFIED;
38961f28255Scgd 	}
390e94a5bc9Sdholland 	get_desc(obj, desc, sizeof(desc));
391e94a5bc9Sdholland 	messagef(0, "%s", desc);
39261f28255Scgd }
39361f28255Scgd 
3942736b511Slukem void
eat(void)395130a8172Sdholland eat(void)
39661f28255Scgd {
39761f28255Scgd 	short ch;
39861f28255Scgd 	short moves;
39961f28255Scgd 	object *obj;
40061f28255Scgd 
40161f28255Scgd 	ch = pack_letter("eat what?", FOOD);
40261f28255Scgd 
40361f28255Scgd 	if (ch == CANCEL) {
40461f28255Scgd 		return;
40561f28255Scgd 	}
40661f28255Scgd 	if (!(obj = get_letter_object(ch))) {
407e94a5bc9Sdholland 		messagef(0, "no such item.");
40861f28255Scgd 		return;
40961f28255Scgd 	}
41061f28255Scgd 	if (obj->what_is != FOOD) {
411e94a5bc9Sdholland 		messagef(0, "you can't eat that");
41261f28255Scgd 		return;
41361f28255Scgd 	}
41461f28255Scgd 	if ((obj->which_kind == FRUIT) || rand_percent(60)) {
41561f28255Scgd 		moves = get_rand(950, 1150);
41661f28255Scgd 		if (obj->which_kind == RATION) {
417e94a5bc9Sdholland 			messagef(0, "yum, that tasted good");
41861f28255Scgd 		} else {
419e94a5bc9Sdholland 			messagef(0, "my, that was a yummy %s", fruit);
42061f28255Scgd 		}
42161f28255Scgd 	} else {
42261f28255Scgd 		moves = get_rand(750, 950);
423e94a5bc9Sdholland 		messagef(0, "yuk, that food tasted awful");
42461f28255Scgd 		add_exp(2, 1);
42561f28255Scgd 	}
42661f28255Scgd 	rogue.moves_left /= 3;
42761f28255Scgd 	rogue.moves_left += moves;
42861f28255Scgd 	hunger_str[0] = 0;
42961f28255Scgd 	print_stats(STAT_HUNGER);
43061f28255Scgd 
43161f28255Scgd 	vanish(obj, 1, &rogue.pack);
43261f28255Scgd }
43361f28255Scgd 
4341e99780eSdholland static void
hold_monster(void)435130a8172Sdholland hold_monster(void)
43661f28255Scgd {
43761f28255Scgd 	short i, j;
43861f28255Scgd 	short mcount = 0;
43961f28255Scgd 	object *monster;
44061f28255Scgd 	short row, col;
44161f28255Scgd 
44261f28255Scgd 	for (i = -2; i <= 2; i++) {
44361f28255Scgd 		for (j = -2; j <= 2; j++) {
44461f28255Scgd 			row = rogue.row + i;
44561f28255Scgd 			col = rogue.col + j;
44661f28255Scgd 			if ((row < MIN_ROW) || (row > (DROWS-2)) || (col < 0) ||
44761f28255Scgd 				 (col > (DCOLS-1))) {
44861f28255Scgd 				continue;
44961f28255Scgd 			}
45061f28255Scgd 			if (dungeon[row][col] & MONSTER) {
45161f28255Scgd 				monster = object_at(&level_monsters, row, col);
45261f28255Scgd 				monster->m_flags |= ASLEEP;
45361f28255Scgd 				monster->m_flags &= (~WAKENS);
45461f28255Scgd 				mcount++;
45561f28255Scgd 			}
45661f28255Scgd 		}
45761f28255Scgd 	}
45861f28255Scgd 	if (mcount == 0) {
459e94a5bc9Sdholland 		messagef(0, "you feel a strange sense of loss");
46061f28255Scgd 	} else if (mcount == 1) {
461e94a5bc9Sdholland 		messagef(0, "the monster freezes");
46261f28255Scgd 	} else {
463e94a5bc9Sdholland 		messagef(0, "the monsters around you freeze");
46461f28255Scgd 	}
46561f28255Scgd }
46661f28255Scgd 
4672736b511Slukem void
tele(void)468130a8172Sdholland tele(void)
46961f28255Scgd {
47061f28255Scgd 	mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));
47161f28255Scgd 
47261f28255Scgd 	if (cur_room >= 0) {
47361f28255Scgd 		darken_room(cur_room);
47461f28255Scgd 	}
47561f28255Scgd 	put_player(get_room_number(rogue.row, rogue.col));
47661f28255Scgd 	being_held = 0;
47761f28255Scgd 	bear_trap = 0;
47861f28255Scgd }
47961f28255Scgd 
4802736b511Slukem void
hallucinate(void)481130a8172Sdholland hallucinate(void)
48261f28255Scgd {
48361f28255Scgd 	object *obj, *monster;
48461f28255Scgd 	short ch;
48561f28255Scgd 
48661f28255Scgd 	if (blind) return;
48761f28255Scgd 
48861f28255Scgd 	obj = level_objects.next_object;
48961f28255Scgd 
49061f28255Scgd 	while (obj) {
49161f28255Scgd 		ch = mvinch(obj->row, obj->col);
49261f28255Scgd 		if (((ch < 'A') || (ch > 'Z')) &&
49361f28255Scgd 			((obj->row != rogue.row) || (obj->col != rogue.col)))
49461f28255Scgd 		if ((ch != ' ') && (ch != '.') && (ch != '#') && (ch != '+')) {
49561f28255Scgd 			addch(gr_obj_char());
49661f28255Scgd 		}
49761f28255Scgd 		obj = obj->next_object;
49861f28255Scgd 	}
49961f28255Scgd 	monster = level_monsters.next_monster;
50061f28255Scgd 
50161f28255Scgd 	while (monster) {
50261f28255Scgd 		ch = mvinch(monster->row, monster->col);
50361f28255Scgd 		if ((ch >= 'A') && (ch <= 'Z')) {
50461f28255Scgd 			addch(get_rand('A', 'Z'));
50561f28255Scgd 		}
50661f28255Scgd 		monster = monster->next_monster;
50761f28255Scgd 	}
50861f28255Scgd }
50961f28255Scgd 
5102736b511Slukem void
unhallucinate(void)511130a8172Sdholland unhallucinate(void)
51261f28255Scgd {
51361f28255Scgd 	halluc = 0;
51461f28255Scgd 	relight();
515e94a5bc9Sdholland 	messagef(1, "everything looks SO boring now");
51661f28255Scgd }
51761f28255Scgd 
5182736b511Slukem void
unblind(void)519130a8172Sdholland unblind(void)
52061f28255Scgd {
52161f28255Scgd 	blind = 0;
522e94a5bc9Sdholland 	messagef(1, "the veil of darkness lifts");
52361f28255Scgd 	relight();
52461f28255Scgd 	if (halluc) {
52561f28255Scgd 		hallucinate();
52661f28255Scgd 	}
52761f28255Scgd 	if (detect_monster) {
52861f28255Scgd 		show_monsters();
52961f28255Scgd 	}
53061f28255Scgd }
53161f28255Scgd 
5322736b511Slukem void
relight(void)533130a8172Sdholland relight(void)
53461f28255Scgd {
53561f28255Scgd 	if (cur_room == PASSAGE) {
53661f28255Scgd 		light_passage(rogue.row, rogue.col);
53761f28255Scgd 	} else {
53861f28255Scgd 		light_up_room(cur_room);
53961f28255Scgd 	}
54061f28255Scgd 	mvaddch(rogue.row, rogue.col, rogue.fchar);
54161f28255Scgd }
54261f28255Scgd 
5432736b511Slukem void
take_a_nap(void)544130a8172Sdholland take_a_nap(void)
54561f28255Scgd {
54661f28255Scgd 	short i;
54761f28255Scgd 
54861f28255Scgd 	i = get_rand(2, 5);
54961f28255Scgd 	md_sleep(1);
55061f28255Scgd 
55161f28255Scgd 	while (i--) {
55261f28255Scgd 		mv_mons();
55361f28255Scgd 	}
55461f28255Scgd 	md_sleep(1);
555e94a5bc9Sdholland 	messagef(0, "%s", you_can_move_again);
55661f28255Scgd }
55761f28255Scgd 
5581e99780eSdholland static void
go_blind(void)559130a8172Sdholland go_blind(void)
56061f28255Scgd {
56161f28255Scgd 	short i, j;
56261f28255Scgd 
56361f28255Scgd 	if (!blind) {
564e94a5bc9Sdholland 		messagef(0, "a cloak of darkness falls around you");
56561f28255Scgd 	}
56661f28255Scgd 	blind += get_rand(500, 800);
56761f28255Scgd 
56861f28255Scgd 	if (detect_monster) {
56961f28255Scgd 		object *monster;
57061f28255Scgd 
57161f28255Scgd 		monster = level_monsters.next_monster;
57261f28255Scgd 
57361f28255Scgd 		while (monster) {
57461f28255Scgd 			mvaddch(monster->row, monster->col, monster->trail_char);
57561f28255Scgd 			monster = monster->next_monster;
57661f28255Scgd 		}
57761f28255Scgd 	}
57861f28255Scgd 	if (cur_room >= 0) {
57961f28255Scgd 		for (i = rooms[cur_room].top_row + 1;
58061f28255Scgd 			 i < rooms[cur_room].bottom_row; i++) {
58161f28255Scgd 			for (j = rooms[cur_room].left_col + 1;
58261f28255Scgd 				 j < rooms[cur_room].right_col; j++) {
58361f28255Scgd 				mvaddch(i, j, ' ');
58461f28255Scgd 			}
58561f28255Scgd 		}
58661f28255Scgd 	}
58761f28255Scgd 	mvaddch(rogue.row, rogue.col, rogue.fchar);
58861f28255Scgd }
58961f28255Scgd 
5901e99780eSdholland static const char *
get_ench_color(void)591130a8172Sdholland get_ench_color(void)
59261f28255Scgd {
59361f28255Scgd 	if (halluc) {
59461f28255Scgd 		return(id_potions[get_rand(0, POTIONS-1)].title);
59561f28255Scgd 	} else if (con_mon) {
59661f28255Scgd 		return("red ");
59761f28255Scgd 	}
59861f28255Scgd 	return("blue ");
59961f28255Scgd }
60061f28255Scgd 
6012736b511Slukem void
cnfs(void)602130a8172Sdholland cnfs(void)
60361f28255Scgd {
60461f28255Scgd 	confused += get_rand(12, 22);
60561f28255Scgd }
60661f28255Scgd 
6072736b511Slukem void
unconfuse(void)608130a8172Sdholland unconfuse(void)
60961f28255Scgd {
61061f28255Scgd 	confused = 0;
611e94a5bc9Sdholland 	messagef(1, "you feel less %s now", (halluc ? "trippy" : "confused"));
61261f28255Scgd }
61361f28255Scgd 
6141e99780eSdholland static void
uncurse_all(void)615130a8172Sdholland uncurse_all(void)
61661f28255Scgd {
61761f28255Scgd 	object *obj;
61861f28255Scgd 
61961f28255Scgd 	obj = rogue.pack.next_object;
62061f28255Scgd 
62161f28255Scgd 	while (obj) {
62261f28255Scgd 		obj->is_cursed = 0;
62361f28255Scgd 		obj = obj->next_object;
62461f28255Scgd 	}
62561f28255Scgd }
626