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