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