Home | History | Annotate | Line # | Download | only in rogue
use.c revision 1.6.22.1
      1  1.6.22.1     matt /*	$NetBSD: use.c,v 1.6.22.1 2008/01/09 01:31:00 matt Exp $	*/
      2       1.3      cgd 
      3       1.1      cgd /*
      4       1.3      cgd  * Copyright (c) 1988, 1993
      5       1.3      cgd  *	The Regents of the University of California.  All rights reserved.
      6       1.1      cgd  *
      7       1.1      cgd  * This code is derived from software contributed to Berkeley by
      8       1.1      cgd  * Timothy C. Stoehr.
      9       1.1      cgd  *
     10       1.1      cgd  * Redistribution and use in source and binary forms, with or without
     11       1.1      cgd  * modification, are permitted provided that the following conditions
     12       1.1      cgd  * are met:
     13       1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     14       1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     15       1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     17       1.1      cgd  *    documentation and/or other materials provided with the distribution.
     18       1.6      agc  * 3. Neither the name of the University nor the names of its contributors
     19       1.1      cgd  *    may be used to endorse or promote products derived from this software
     20       1.1      cgd  *    without specific prior written permission.
     21       1.1      cgd  *
     22       1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23       1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24       1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25       1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26       1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27       1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28       1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29       1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30       1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31       1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32       1.1      cgd  * SUCH DAMAGE.
     33       1.1      cgd  */
     34       1.1      cgd 
     35       1.4    lukem #include <sys/cdefs.h>
     36       1.1      cgd #ifndef lint
     37       1.3      cgd #if 0
     38       1.3      cgd static char sccsid[] = "@(#)use.c	8.1 (Berkeley) 5/31/93";
     39       1.3      cgd #else
     40  1.6.22.1     matt __RCSID("$NetBSD: use.c,v 1.6.22.1 2008/01/09 01:31:00 matt Exp $");
     41       1.3      cgd #endif
     42       1.1      cgd #endif /* not lint */
     43       1.1      cgd 
     44       1.1      cgd /*
     45       1.1      cgd  * use.c
     46       1.1      cgd  *
     47       1.1      cgd  * This source herein may be modified and/or distributed by anybody who
     48       1.1      cgd  * so desires, with the following restrictions:
     49       1.1      cgd  *    1.)  No portion of this notice shall be removed.
     50       1.1      cgd  *    2.)  Credit shall not be taken for the creation of this source.
     51       1.1      cgd  *    3.)  This code is not to be traded, sold, or used for personal
     52       1.1      cgd  *         gain or profit.
     53       1.1      cgd  *
     54       1.1      cgd  */
     55       1.1      cgd 
     56       1.1      cgd #include "rogue.h"
     57       1.1      cgd 
     58       1.1      cgd short halluc = 0;
     59       1.1      cgd short blind = 0;
     60       1.1      cgd short confused = 0;
     61       1.1      cgd short levitate = 0;
     62       1.1      cgd short haste_self = 0;
     63       1.1      cgd boolean see_invisible = 0;
     64       1.1      cgd short extra_hp = 0;
     65       1.1      cgd boolean detect_monster = 0;
     66       1.1      cgd boolean con_mon = 0;
     67       1.5  hubertf const char *strange_feeling = "you have a strange feeling for a moment, then it passes";
     68       1.1      cgd 
     69       1.4    lukem void
     70       1.1      cgd quaff()
     71       1.1      cgd {
     72       1.1      cgd 	short ch;
     73       1.1      cgd 	object *obj;
     74       1.1      cgd 
     75       1.1      cgd 	ch = pack_letter("quaff what?", POTION);
     76       1.1      cgd 
     77       1.1      cgd 	if (ch == CANCEL) {
     78       1.1      cgd 		return;
     79       1.1      cgd 	}
     80       1.1      cgd 	if (!(obj = get_letter_object(ch))) {
     81  1.6.22.1     matt 		messagef(0, "no such item.");
     82       1.1      cgd 		return;
     83       1.1      cgd 	}
     84       1.1      cgd 	if (obj->what_is != POTION) {
     85  1.6.22.1     matt 		messagef(0, "you can't drink that");
     86       1.1      cgd 		return;
     87       1.1      cgd 	}
     88       1.1      cgd 	switch(obj->which_kind) {
     89       1.1      cgd 		case INCREASE_STRENGTH:
     90  1.6.22.1     matt 			messagef(0, "you feel stronger now, what bulging muscles!");
     91       1.1      cgd 			rogue.str_current++;
     92       1.1      cgd 			if (rogue.str_current > rogue.str_max) {
     93       1.1      cgd 				rogue.str_max = rogue.str_current;
     94       1.1      cgd 			}
     95       1.1      cgd 			break;
     96       1.1      cgd 		case RESTORE_STRENGTH:
     97       1.1      cgd 			rogue.str_current = rogue.str_max;
     98  1.6.22.1     matt 			messagef(0, "this tastes great, you feel warm all over");
     99       1.1      cgd 			break;
    100       1.1      cgd 		case HEALING:
    101  1.6.22.1     matt 			messagef(0, "you begin to feel better");
    102       1.1      cgd 			potion_heal(0);
    103       1.1      cgd 			break;
    104       1.1      cgd 		case EXTRA_HEALING:
    105  1.6.22.1     matt 			messagef(0, "you begin to feel much better");
    106       1.1      cgd 			potion_heal(1);
    107       1.1      cgd 			break;
    108       1.1      cgd 		case POISON:
    109       1.1      cgd 			if (!sustain_strength) {
    110       1.1      cgd 				rogue.str_current -= get_rand(1, 3);
    111       1.1      cgd 				if (rogue.str_current < 1) {
    112       1.1      cgd 					rogue.str_current = 1;
    113       1.1      cgd 				}
    114       1.1      cgd 			}
    115  1.6.22.1     matt 			messagef(0, "you feel very sick now");
    116       1.1      cgd 			if (halluc) {
    117       1.1      cgd 				unhallucinate();
    118       1.1      cgd 			}
    119       1.1      cgd 			break;
    120       1.1      cgd 		case RAISE_LEVEL:
    121       1.1      cgd 			rogue.exp_points = level_points[rogue.exp - 1];
    122  1.6.22.1     matt 			messagef(0, "you suddenly feel much more skillful");
    123       1.1      cgd 			add_exp(1, 1);
    124       1.1      cgd 			break;
    125       1.1      cgd 		case BLINDNESS:
    126       1.1      cgd 			go_blind();
    127       1.1      cgd 			break;
    128       1.1      cgd 		case HALLUCINATION:
    129  1.6.22.1     matt 			messagef(0, "oh wow, everything seems so cosmic");
    130       1.1      cgd 			halluc += get_rand(500, 800);
    131       1.1      cgd 			break;
    132       1.1      cgd 		case DETECT_MONSTER:
    133       1.1      cgd 			show_monsters();
    134       1.1      cgd 			if (!(level_monsters.next_monster)) {
    135  1.6.22.1     matt 				messagef(0, "%s", strange_feeling);
    136       1.1      cgd 			}
    137       1.1      cgd 			break;
    138       1.1      cgd 		case DETECT_OBJECTS:
    139       1.1      cgd 			if (level_objects.next_object) {
    140       1.1      cgd 				if (!blind) {
    141       1.1      cgd 					show_objects();
    142       1.1      cgd 				}
    143       1.1      cgd 			} else {
    144  1.6.22.1     matt 				messagef(0, "%s", strange_feeling);
    145       1.1      cgd 			}
    146       1.1      cgd 			break;
    147       1.1      cgd 		case CONFUSION:
    148  1.6.22.1     matt 			messagef(0, (halluc ? "what a trippy feeling" :
    149  1.6.22.1     matt 			"you feel confused"));
    150       1.1      cgd 			cnfs();
    151       1.1      cgd 			break;
    152       1.1      cgd 		case LEVITATION:
    153  1.6.22.1     matt 			messagef(0, "you start to float in the air");
    154       1.1      cgd 			levitate += get_rand(15, 30);
    155       1.1      cgd 			being_held = bear_trap = 0;
    156       1.1      cgd 			break;
    157       1.1      cgd 		case HASTE_SELF:
    158  1.6.22.1     matt 			messagef(0, "you feel yourself moving much faster");
    159       1.1      cgd 			haste_self += get_rand(11, 21);
    160       1.1      cgd 			if (!(haste_self % 2)) {
    161       1.1      cgd 				haste_self++;
    162       1.1      cgd 			}
    163       1.1      cgd 			break;
    164       1.1      cgd 		case SEE_INVISIBLE:
    165  1.6.22.1     matt 			messagef(0, "hmm, this potion tastes like %sjuice",
    166  1.6.22.1     matt 				 fruit);
    167       1.1      cgd 			if (blind) {
    168       1.1      cgd 				unblind();
    169       1.1      cgd 			}
    170       1.1      cgd 			see_invisible = 1;
    171       1.1      cgd 			relight();
    172       1.1      cgd 			break;
    173       1.1      cgd 	}
    174       1.1      cgd 	print_stats((STAT_STRENGTH | STAT_HP));
    175       1.1      cgd 	if (id_potions[obj->which_kind].id_status != CALLED) {
    176       1.1      cgd 		id_potions[obj->which_kind].id_status = IDENTIFIED;
    177       1.1      cgd 	}
    178       1.1      cgd 	vanish(obj, 1, &rogue.pack);
    179       1.1      cgd }
    180       1.1      cgd 
    181       1.4    lukem void
    182       1.1      cgd read_scroll()
    183       1.1      cgd {
    184       1.1      cgd 	short ch;
    185       1.1      cgd 	object *obj;
    186       1.1      cgd 
    187       1.1      cgd 	ch = pack_letter("read what?", SCROL);
    188       1.1      cgd 
    189       1.1      cgd 	if (ch == CANCEL) {
    190       1.1      cgd 		return;
    191       1.1      cgd 	}
    192       1.1      cgd 	if (!(obj = get_letter_object(ch))) {
    193  1.6.22.1     matt 		messagef(0, "no such item.");
    194       1.1      cgd 		return;
    195       1.1      cgd 	}
    196       1.1      cgd 	if (obj->what_is != SCROL) {
    197  1.6.22.1     matt 		messagef(0, "you can't read that");
    198       1.1      cgd 		return;
    199       1.1      cgd 	}
    200       1.1      cgd 	switch(obj->which_kind) {
    201       1.1      cgd 		case SCARE_MONSTER:
    202  1.6.22.1     matt 			messagef(0, "you hear a maniacal laughter in the distance");
    203       1.1      cgd 			break;
    204       1.1      cgd 		case HOLD_MONSTER:
    205       1.1      cgd 			hold_monster();
    206       1.1      cgd 			break;
    207       1.1      cgd 		case ENCH_WEAPON:
    208       1.1      cgd 			if (rogue.weapon) {
    209       1.1      cgd 				if (rogue.weapon->what_is == WEAPON) {
    210  1.6.22.1     matt 					messagef(0, "your %sglow%s %sfor a moment",
    211  1.6.22.1     matt 						name_of(rogue.weapon),
    212  1.6.22.1     matt 						((rogue.weapon->quantity <= 1) ? "s" : ""),
    213  1.6.22.1     matt 						get_ench_color());
    214       1.1      cgd 					if (coin_toss()) {
    215       1.1      cgd 						rogue.weapon->hit_enchant++;
    216       1.1      cgd 					} else {
    217       1.1      cgd 						rogue.weapon->d_enchant++;
    218       1.1      cgd 					}
    219       1.1      cgd 				}
    220       1.1      cgd 				rogue.weapon->is_cursed = 0;
    221       1.1      cgd 			} else {
    222  1.6.22.1     matt 				messagef(0, "your hands tingle");
    223       1.1      cgd 			}
    224       1.1      cgd 			break;
    225       1.1      cgd 		case ENCH_ARMOR:
    226       1.1      cgd 			if (rogue.armor) {
    227  1.6.22.1     matt 				messagef(0, "your armor glows %sfor a moment",
    228  1.6.22.1     matt 					get_ench_color());
    229       1.1      cgd 				rogue.armor->d_enchant++;
    230       1.1      cgd 				rogue.armor->is_cursed = 0;
    231       1.1      cgd 				print_stats(STAT_ARMOR);
    232       1.1      cgd 			} else {
    233  1.6.22.1     matt 				messagef(0, "your skin crawls");
    234       1.1      cgd 			}
    235       1.1      cgd 			break;
    236       1.1      cgd 		case IDENTIFY:
    237  1.6.22.1     matt 			messagef(0, "this is a scroll of identify");
    238       1.1      cgd 			obj->identified = 1;
    239       1.1      cgd 			id_scrolls[obj->which_kind].id_status = IDENTIFIED;
    240       1.1      cgd 			idntfy();
    241       1.1      cgd 			break;
    242       1.1      cgd 		case TELEPORT:
    243       1.1      cgd 			tele();
    244       1.1      cgd 			break;
    245       1.1      cgd 		case SLEEP:
    246  1.6.22.1     matt 			messagef(0, "you fall asleep");
    247       1.1      cgd 			take_a_nap();
    248       1.1      cgd 			break;
    249       1.1      cgd 		case PROTECT_ARMOR:
    250       1.1      cgd 			if (rogue.armor) {
    251  1.6.22.1     matt 				messagef(0, "your armor is covered by a shimmering gold shield");
    252       1.1      cgd 				rogue.armor->is_protected = 1;
    253       1.1      cgd 				rogue.armor->is_cursed = 0;
    254       1.1      cgd 			} else {
    255  1.6.22.1     matt 				messagef(0, "your acne seems to have disappeared");
    256       1.1      cgd 			}
    257       1.1      cgd 			break;
    258       1.1      cgd 		case REMOVE_CURSE:
    259  1.6.22.1     matt 				messagef(0, (!halluc) ?
    260       1.1      cgd 					"you feel as though someone is watching over you" :
    261  1.6.22.1     matt 					"you feel in touch with the universal oneness");
    262       1.1      cgd 			uncurse_all();
    263       1.1      cgd 			break;
    264       1.1      cgd 		case CREATE_MONSTER:
    265       1.1      cgd 			create_monster();
    266       1.1      cgd 			break;
    267       1.1      cgd 		case AGGRAVATE_MONSTER:
    268       1.1      cgd 			aggravate();
    269       1.1      cgd 			break;
    270       1.1      cgd 		case MAGIC_MAPPING:
    271  1.6.22.1     matt 			messagef(0, "this scroll seems to have a map on it");
    272       1.1      cgd 			draw_magic_map();
    273       1.1      cgd 			break;
    274       1.1      cgd 		case CON_MON:
    275       1.1      cgd 			con_mon = 1;
    276  1.6.22.1     matt 			messagef(0, "your hands glow %sfor a moment",
    277  1.6.22.1     matt 				 get_ench_color());
    278       1.1      cgd 			break;
    279       1.1      cgd 	}
    280       1.1      cgd 	if (id_scrolls[obj->which_kind].id_status != CALLED) {
    281       1.1      cgd 		id_scrolls[obj->which_kind].id_status = IDENTIFIED;
    282       1.1      cgd 	}
    283       1.1      cgd 	vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
    284       1.1      cgd }
    285       1.1      cgd 
    286       1.1      cgd /* vanish() does NOT handle a quiver of weapons with more than one
    287       1.1      cgd  *  arrow (or whatever) in the quiver.  It will only decrement the count.
    288       1.1      cgd  */
    289       1.1      cgd 
    290       1.4    lukem void
    291       1.1      cgd vanish(obj, rm, pack)
    292       1.4    lukem 	object *obj;
    293       1.4    lukem 	short rm;
    294       1.4    lukem 	object *pack;
    295       1.1      cgd {
    296       1.1      cgd 	if (obj->quantity > 1) {
    297       1.1      cgd 		obj->quantity--;
    298       1.1      cgd 	} else {
    299       1.1      cgd 		if (obj->in_use_flags & BEING_WIELDED) {
    300       1.1      cgd 			unwield(obj);
    301       1.1      cgd 		} else if (obj->in_use_flags & BEING_WORN) {
    302       1.1      cgd 			unwear(obj);
    303       1.1      cgd 		} else if (obj->in_use_flags & ON_EITHER_HAND) {
    304       1.1      cgd 			un_put_on(obj);
    305       1.1      cgd 		}
    306       1.1      cgd 		take_from_pack(obj, pack);
    307       1.1      cgd 		free_object(obj);
    308       1.1      cgd 	}
    309       1.1      cgd 	if (rm) {
    310       1.1      cgd 		(void) reg_move();
    311       1.1      cgd 	}
    312       1.1      cgd }
    313       1.1      cgd 
    314       1.4    lukem void
    315       1.1      cgd potion_heal(extra)
    316       1.4    lukem 	int extra;
    317       1.1      cgd {
    318       1.1      cgd 	float ratio;
    319       1.1      cgd 	short add;
    320       1.1      cgd 
    321       1.1      cgd 	rogue.hp_current += rogue.exp;
    322       1.1      cgd 
    323       1.1      cgd 	ratio = ((float)rogue.hp_current) / rogue.hp_max;
    324       1.1      cgd 
    325       1.1      cgd 	if (ratio >= 1.00) {
    326       1.1      cgd 		rogue.hp_max += (extra ? 2 : 1);
    327       1.1      cgd 		extra_hp += (extra ? 2 : 1);
    328       1.1      cgd 		rogue.hp_current = rogue.hp_max;
    329       1.1      cgd 	} else if (ratio >= 0.90) {
    330       1.1      cgd 		rogue.hp_max += (extra ? 1 : 0);
    331       1.1      cgd 		extra_hp += (extra ? 1 : 0);
    332       1.1      cgd 		rogue.hp_current = rogue.hp_max;
    333       1.1      cgd 	} else {
    334       1.1      cgd 		if (ratio < 0.33) {
    335       1.1      cgd 			ratio = 0.33;
    336       1.1      cgd 		}
    337       1.1      cgd 		if (extra) {
    338       1.1      cgd 			ratio += ratio;
    339       1.1      cgd 		}
    340       1.1      cgd 		add = (short)(ratio * ((float)rogue.hp_max - rogue.hp_current));
    341       1.1      cgd 		rogue.hp_current += add;
    342       1.1      cgd 		if (rogue.hp_current > rogue.hp_max) {
    343       1.1      cgd 			rogue.hp_current = rogue.hp_max;
    344       1.1      cgd 		}
    345       1.1      cgd 	}
    346       1.1      cgd 	if (blind) {
    347       1.1      cgd 		unblind();
    348       1.1      cgd 	}
    349       1.1      cgd 	if (confused && extra) {
    350       1.1      cgd 			unconfuse();
    351       1.1      cgd 	} else if (confused) {
    352       1.1      cgd 		confused = (confused / 2) + 1;
    353       1.1      cgd 	}
    354       1.1      cgd 	if (halluc && extra) {
    355       1.1      cgd 		unhallucinate();
    356       1.1      cgd 	} else if (halluc) {
    357       1.1      cgd 		halluc = (halluc / 2) + 1;
    358       1.1      cgd 	}
    359       1.1      cgd }
    360       1.1      cgd 
    361       1.4    lukem void
    362       1.1      cgd idntfy()
    363       1.1      cgd {
    364       1.1      cgd 	short ch;
    365       1.1      cgd 	object *obj;
    366       1.1      cgd 	struct id *id_table;
    367       1.1      cgd 	char desc[DCOLS];
    368       1.1      cgd AGAIN:
    369       1.1      cgd 	ch = pack_letter("what would you like to identify?", ALL_OBJECTS);
    370       1.1      cgd 
    371       1.1      cgd 	if (ch == CANCEL) {
    372       1.1      cgd 		return;
    373       1.1      cgd 	}
    374       1.1      cgd 	if (!(obj = get_letter_object(ch))) {
    375  1.6.22.1     matt 		messagef(0, "no such item, try again");
    376  1.6.22.1     matt 		messagef(0, "%s", "");	/* gcc objects to just "" */
    377       1.1      cgd 		check_message();
    378       1.1      cgd 		goto AGAIN;
    379       1.1      cgd 	}
    380       1.1      cgd 	obj->identified = 1;
    381       1.1      cgd 	if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) {
    382       1.1      cgd 		id_table = get_id_table(obj);
    383       1.1      cgd 		id_table[obj->which_kind].id_status = IDENTIFIED;
    384       1.1      cgd 	}
    385  1.6.22.1     matt 	get_desc(obj, desc, sizeof(desc));
    386  1.6.22.1     matt 	messagef(0, "%s", desc);
    387       1.1      cgd }
    388       1.1      cgd 
    389       1.4    lukem void
    390       1.1      cgd eat()
    391       1.1      cgd {
    392       1.1      cgd 	short ch;
    393       1.1      cgd 	short moves;
    394       1.1      cgd 	object *obj;
    395       1.1      cgd 
    396       1.1      cgd 	ch = pack_letter("eat what?", FOOD);
    397       1.1      cgd 
    398       1.1      cgd 	if (ch == CANCEL) {
    399       1.1      cgd 		return;
    400       1.1      cgd 	}
    401       1.1      cgd 	if (!(obj = get_letter_object(ch))) {
    402  1.6.22.1     matt 		messagef(0, "no such item.");
    403       1.1      cgd 		return;
    404       1.1      cgd 	}
    405       1.1      cgd 	if (obj->what_is != FOOD) {
    406  1.6.22.1     matt 		messagef(0, "you can't eat that");
    407       1.1      cgd 		return;
    408       1.1      cgd 	}
    409       1.1      cgd 	if ((obj->which_kind == FRUIT) || rand_percent(60)) {
    410       1.1      cgd 		moves = get_rand(950, 1150);
    411       1.1      cgd 		if (obj->which_kind == RATION) {
    412  1.6.22.1     matt 			messagef(0, "yum, that tasted good");
    413       1.1      cgd 		} else {
    414  1.6.22.1     matt 			messagef(0, "my, that was a yummy %s", fruit);
    415       1.1      cgd 		}
    416       1.1      cgd 	} else {
    417       1.1      cgd 		moves = get_rand(750, 950);
    418  1.6.22.1     matt 		messagef(0, "yuk, that food tasted awful");
    419       1.1      cgd 		add_exp(2, 1);
    420       1.1      cgd 	}
    421       1.1      cgd 	rogue.moves_left /= 3;
    422       1.1      cgd 	rogue.moves_left += moves;
    423       1.1      cgd 	hunger_str[0] = 0;
    424       1.1      cgd 	print_stats(STAT_HUNGER);
    425       1.1      cgd 
    426       1.1      cgd 	vanish(obj, 1, &rogue.pack);
    427       1.1      cgd }
    428       1.1      cgd 
    429       1.4    lukem void
    430       1.1      cgd hold_monster()
    431       1.1      cgd {
    432       1.1      cgd 	short i, j;
    433       1.1      cgd 	short mcount = 0;
    434       1.1      cgd 	object *monster;
    435       1.1      cgd 	short row, col;
    436       1.1      cgd 
    437       1.1      cgd 	for (i = -2; i <= 2; i++) {
    438       1.1      cgd 		for (j = -2; j <= 2; j++) {
    439       1.1      cgd 			row = rogue.row + i;
    440       1.1      cgd 			col = rogue.col + j;
    441       1.1      cgd 			if ((row < MIN_ROW) || (row > (DROWS-2)) || (col < 0) ||
    442       1.1      cgd 				 (col > (DCOLS-1))) {
    443       1.1      cgd 				continue;
    444       1.1      cgd 			}
    445       1.1      cgd 			if (dungeon[row][col] & MONSTER) {
    446       1.1      cgd 				monster = object_at(&level_monsters, row, col);
    447       1.1      cgd 				monster->m_flags |= ASLEEP;
    448       1.1      cgd 				monster->m_flags &= (~WAKENS);
    449       1.1      cgd 				mcount++;
    450       1.1      cgd 			}
    451       1.1      cgd 		}
    452       1.1      cgd 	}
    453       1.1      cgd 	if (mcount == 0) {
    454  1.6.22.1     matt 		messagef(0, "you feel a strange sense of loss");
    455       1.1      cgd 	} else if (mcount == 1) {
    456  1.6.22.1     matt 		messagef(0, "the monster freezes");
    457       1.1      cgd 	} else {
    458  1.6.22.1     matt 		messagef(0, "the monsters around you freeze");
    459       1.1      cgd 	}
    460       1.1      cgd }
    461       1.1      cgd 
    462       1.4    lukem void
    463       1.1      cgd tele()
    464       1.1      cgd {
    465       1.1      cgd 	mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));
    466       1.1      cgd 
    467       1.1      cgd 	if (cur_room >= 0) {
    468       1.1      cgd 		darken_room(cur_room);
    469       1.1      cgd 	}
    470       1.1      cgd 	put_player(get_room_number(rogue.row, rogue.col));
    471       1.1      cgd 	being_held = 0;
    472       1.1      cgd 	bear_trap = 0;
    473       1.1      cgd }
    474       1.1      cgd 
    475       1.4    lukem void
    476       1.1      cgd hallucinate()
    477       1.1      cgd {
    478       1.1      cgd 	object *obj, *monster;
    479       1.1      cgd 	short ch;
    480       1.1      cgd 
    481       1.1      cgd 	if (blind) return;
    482       1.1      cgd 
    483       1.1      cgd 	obj = level_objects.next_object;
    484       1.1      cgd 
    485       1.1      cgd 	while (obj) {
    486       1.1      cgd 		ch = mvinch(obj->row, obj->col);
    487       1.1      cgd 		if (((ch < 'A') || (ch > 'Z')) &&
    488       1.1      cgd 			((obj->row != rogue.row) || (obj->col != rogue.col)))
    489       1.1      cgd 		if ((ch != ' ') && (ch != '.') && (ch != '#') && (ch != '+')) {
    490       1.1      cgd 			addch(gr_obj_char());
    491       1.1      cgd 		}
    492       1.1      cgd 		obj = obj->next_object;
    493       1.1      cgd 	}
    494       1.1      cgd 	monster = level_monsters.next_monster;
    495       1.1      cgd 
    496       1.1      cgd 	while (monster) {
    497       1.1      cgd 		ch = mvinch(monster->row, monster->col);
    498       1.1      cgd 		if ((ch >= 'A') && (ch <= 'Z')) {
    499       1.1      cgd 			addch(get_rand('A', 'Z'));
    500       1.1      cgd 		}
    501       1.1      cgd 		monster = monster->next_monster;
    502       1.1      cgd 	}
    503       1.1      cgd }
    504       1.1      cgd 
    505       1.4    lukem void
    506       1.1      cgd unhallucinate()
    507       1.1      cgd {
    508       1.1      cgd 	halluc = 0;
    509       1.1      cgd 	relight();
    510  1.6.22.1     matt 	messagef(1, "everything looks SO boring now");
    511       1.1      cgd }
    512       1.1      cgd 
    513       1.4    lukem void
    514       1.1      cgd unblind()
    515       1.1      cgd {
    516       1.1      cgd 	blind = 0;
    517  1.6.22.1     matt 	messagef(1, "the veil of darkness lifts");
    518       1.1      cgd 	relight();
    519       1.1      cgd 	if (halluc) {
    520       1.1      cgd 		hallucinate();
    521       1.1      cgd 	}
    522       1.1      cgd 	if (detect_monster) {
    523       1.1      cgd 		show_monsters();
    524       1.1      cgd 	}
    525       1.1      cgd }
    526       1.1      cgd 
    527       1.4    lukem void
    528       1.1      cgd relight()
    529       1.1      cgd {
    530       1.1      cgd 	if (cur_room == PASSAGE) {
    531       1.1      cgd 		light_passage(rogue.row, rogue.col);
    532       1.1      cgd 	} else {
    533       1.1      cgd 		light_up_room(cur_room);
    534       1.1      cgd 	}
    535       1.1      cgd 	mvaddch(rogue.row, rogue.col, rogue.fchar);
    536       1.1      cgd }
    537       1.1      cgd 
    538       1.4    lukem void
    539       1.1      cgd take_a_nap()
    540       1.1      cgd {
    541       1.1      cgd 	short i;
    542       1.1      cgd 
    543       1.1      cgd 	i = get_rand(2, 5);
    544       1.1      cgd 	md_sleep(1);
    545       1.1      cgd 
    546       1.1      cgd 	while (i--) {
    547       1.1      cgd 		mv_mons();
    548       1.1      cgd 	}
    549       1.1      cgd 	md_sleep(1);
    550  1.6.22.1     matt 	messagef(0, "%s", you_can_move_again);
    551       1.1      cgd }
    552       1.1      cgd 
    553       1.4    lukem void
    554       1.1      cgd go_blind()
    555       1.1      cgd {
    556       1.1      cgd 	short i, j;
    557       1.1      cgd 
    558       1.1      cgd 	if (!blind) {
    559  1.6.22.1     matt 		messagef(0, "a cloak of darkness falls around you");
    560       1.1      cgd 	}
    561       1.1      cgd 	blind += get_rand(500, 800);
    562       1.1      cgd 
    563       1.1      cgd 	if (detect_monster) {
    564       1.1      cgd 		object *monster;
    565       1.1      cgd 
    566       1.1      cgd 		monster = level_monsters.next_monster;
    567       1.1      cgd 
    568       1.1      cgd 		while (monster) {
    569       1.1      cgd 			mvaddch(monster->row, monster->col, monster->trail_char);
    570       1.1      cgd 			monster = monster->next_monster;
    571       1.1      cgd 		}
    572       1.1      cgd 	}
    573       1.1      cgd 	if (cur_room >= 0) {
    574       1.1      cgd 		for (i = rooms[cur_room].top_row + 1;
    575       1.1      cgd 			 i < rooms[cur_room].bottom_row; i++) {
    576       1.1      cgd 			for (j = rooms[cur_room].left_col + 1;
    577       1.1      cgd 				 j < rooms[cur_room].right_col; j++) {
    578       1.1      cgd 				mvaddch(i, j, ' ');
    579       1.1      cgd 			}
    580       1.1      cgd 		}
    581       1.1      cgd 	}
    582       1.1      cgd 	mvaddch(rogue.row, rogue.col, rogue.fchar);
    583       1.1      cgd }
    584       1.1      cgd 
    585       1.5  hubertf const char *
    586       1.1      cgd get_ench_color()
    587       1.1      cgd {
    588       1.1      cgd 	if (halluc) {
    589       1.1      cgd 		return(id_potions[get_rand(0, POTIONS-1)].title);
    590       1.1      cgd 	} else if (con_mon) {
    591       1.1      cgd 		return("red ");
    592       1.1      cgd 	}
    593       1.1      cgd 	return("blue ");
    594       1.1      cgd }
    595       1.1      cgd 
    596       1.4    lukem void
    597       1.1      cgd cnfs()
    598       1.1      cgd {
    599       1.1      cgd 	confused += get_rand(12, 22);
    600       1.1      cgd }
    601       1.1      cgd 
    602       1.4    lukem void
    603       1.1      cgd unconfuse()
    604       1.1      cgd {
    605       1.1      cgd 	confused = 0;
    606  1.6.22.1     matt 	messagef(1, "you feel less %s now", (halluc ? "trippy" : "confused"));
    607       1.1      cgd }
    608       1.1      cgd 
    609       1.4    lukem void
    610       1.1      cgd uncurse_all()
    611       1.1      cgd {
    612       1.1      cgd 	object *obj;
    613       1.1      cgd 
    614       1.1      cgd 	obj = rogue.pack.next_object;
    615       1.1      cgd 
    616       1.1      cgd 	while (obj) {
    617       1.1      cgd 		obj->is_cursed = 0;
    618       1.1      cgd 		obj = obj->next_object;
    619       1.1      cgd 	}
    620       1.1      cgd }
    621