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