Home | History | Annotate | Line # | Download | only in rogue
use.c revision 1.10
      1  1.10  dholland /*	$NetBSD: use.c,v 1.10 2009/08/12 08:44:45 dholland 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.10  dholland __RCSID("$NetBSD: use.c,v 1.10 2009/08/12 08:44:45 dholland 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.9  dholland 
     68   1.9  dholland static const char strange_feeling[] =
     69   1.9  dholland 	"you have a strange feeling for a moment, then it passes";
     70   1.1       cgd 
     71  1.10  dholland static const char *get_ench_color(void);
     72  1.10  dholland static void go_blind(void);
     73  1.10  dholland static void hold_monster(void);
     74  1.10  dholland static void idntfy(void);
     75  1.10  dholland static void potion_heal(int);
     76  1.10  dholland static void uncurse_all(void);
     77  1.10  dholland 
     78   1.4     lukem void
     79   1.9  dholland quaff(void)
     80   1.1       cgd {
     81   1.1       cgd 	short ch;
     82   1.1       cgd 	object *obj;
     83   1.1       cgd 
     84   1.1       cgd 	ch = pack_letter("quaff what?", POTION);
     85   1.1       cgd 
     86   1.1       cgd 	if (ch == CANCEL) {
     87   1.1       cgd 		return;
     88   1.1       cgd 	}
     89   1.1       cgd 	if (!(obj = get_letter_object(ch))) {
     90   1.7  dholland 		messagef(0, "no such item.");
     91   1.1       cgd 		return;
     92   1.1       cgd 	}
     93   1.1       cgd 	if (obj->what_is != POTION) {
     94   1.7  dholland 		messagef(0, "you can't drink that");
     95   1.1       cgd 		return;
     96   1.1       cgd 	}
     97   1.1       cgd 	switch(obj->which_kind) {
     98   1.1       cgd 		case INCREASE_STRENGTH:
     99   1.7  dholland 			messagef(0, "you feel stronger now, what bulging muscles!");
    100   1.1       cgd 			rogue.str_current++;
    101   1.1       cgd 			if (rogue.str_current > rogue.str_max) {
    102   1.1       cgd 				rogue.str_max = rogue.str_current;
    103   1.1       cgd 			}
    104   1.1       cgd 			break;
    105   1.1       cgd 		case RESTORE_STRENGTH:
    106   1.1       cgd 			rogue.str_current = rogue.str_max;
    107   1.7  dholland 			messagef(0, "this tastes great, you feel warm all over");
    108   1.1       cgd 			break;
    109   1.1       cgd 		case HEALING:
    110   1.7  dholland 			messagef(0, "you begin to feel better");
    111   1.1       cgd 			potion_heal(0);
    112   1.1       cgd 			break;
    113   1.1       cgd 		case EXTRA_HEALING:
    114   1.7  dholland 			messagef(0, "you begin to feel much better");
    115   1.1       cgd 			potion_heal(1);
    116   1.1       cgd 			break;
    117   1.1       cgd 		case POISON:
    118   1.1       cgd 			if (!sustain_strength) {
    119   1.1       cgd 				rogue.str_current -= get_rand(1, 3);
    120   1.1       cgd 				if (rogue.str_current < 1) {
    121   1.1       cgd 					rogue.str_current = 1;
    122   1.1       cgd 				}
    123   1.1       cgd 			}
    124   1.7  dholland 			messagef(0, "you feel very sick now");
    125   1.1       cgd 			if (halluc) {
    126   1.1       cgd 				unhallucinate();
    127   1.1       cgd 			}
    128   1.1       cgd 			break;
    129   1.1       cgd 		case RAISE_LEVEL:
    130   1.1       cgd 			rogue.exp_points = level_points[rogue.exp - 1];
    131   1.7  dholland 			messagef(0, "you suddenly feel much more skillful");
    132   1.1       cgd 			add_exp(1, 1);
    133   1.1       cgd 			break;
    134   1.1       cgd 		case BLINDNESS:
    135   1.1       cgd 			go_blind();
    136   1.1       cgd 			break;
    137   1.1       cgd 		case HALLUCINATION:
    138   1.7  dholland 			messagef(0, "oh wow, everything seems so cosmic");
    139   1.1       cgd 			halluc += get_rand(500, 800);
    140   1.1       cgd 			break;
    141   1.1       cgd 		case DETECT_MONSTER:
    142   1.1       cgd 			show_monsters();
    143   1.1       cgd 			if (!(level_monsters.next_monster)) {
    144   1.7  dholland 				messagef(0, "%s", strange_feeling);
    145   1.1       cgd 			}
    146   1.1       cgd 			break;
    147   1.1       cgd 		case DETECT_OBJECTS:
    148   1.1       cgd 			if (level_objects.next_object) {
    149   1.1       cgd 				if (!blind) {
    150   1.1       cgd 					show_objects();
    151   1.1       cgd 				}
    152   1.1       cgd 			} else {
    153   1.7  dholland 				messagef(0, "%s", strange_feeling);
    154   1.1       cgd 			}
    155   1.1       cgd 			break;
    156   1.1       cgd 		case CONFUSION:
    157   1.7  dholland 			messagef(0, (halluc ? "what a trippy feeling" :
    158   1.7  dholland 			"you feel confused"));
    159   1.1       cgd 			cnfs();
    160   1.1       cgd 			break;
    161   1.1       cgd 		case LEVITATION:
    162   1.7  dholland 			messagef(0, "you start to float in the air");
    163   1.1       cgd 			levitate += get_rand(15, 30);
    164   1.1       cgd 			being_held = bear_trap = 0;
    165   1.1       cgd 			break;
    166   1.1       cgd 		case HASTE_SELF:
    167   1.7  dholland 			messagef(0, "you feel yourself moving much faster");
    168   1.1       cgd 			haste_self += get_rand(11, 21);
    169   1.1       cgd 			if (!(haste_self % 2)) {
    170   1.1       cgd 				haste_self++;
    171   1.1       cgd 			}
    172   1.1       cgd 			break;
    173   1.1       cgd 		case SEE_INVISIBLE:
    174   1.8  dholland 			messagef(0, "hmm, this potion tastes like %sjuice",
    175   1.7  dholland 				 fruit);
    176   1.1       cgd 			if (blind) {
    177   1.1       cgd 				unblind();
    178   1.1       cgd 			}
    179   1.1       cgd 			see_invisible = 1;
    180   1.1       cgd 			relight();
    181   1.1       cgd 			break;
    182   1.1       cgd 	}
    183   1.1       cgd 	print_stats((STAT_STRENGTH | STAT_HP));
    184   1.1       cgd 	if (id_potions[obj->which_kind].id_status != CALLED) {
    185   1.1       cgd 		id_potions[obj->which_kind].id_status = IDENTIFIED;
    186   1.1       cgd 	}
    187   1.1       cgd 	vanish(obj, 1, &rogue.pack);
    188   1.1       cgd }
    189   1.1       cgd 
    190   1.4     lukem void
    191   1.9  dholland read_scroll(void)
    192   1.1       cgd {
    193   1.1       cgd 	short ch;
    194   1.1       cgd 	object *obj;
    195   1.1       cgd 
    196   1.1       cgd 	ch = pack_letter("read what?", SCROL);
    197   1.1       cgd 
    198   1.1       cgd 	if (ch == CANCEL) {
    199   1.1       cgd 		return;
    200   1.1       cgd 	}
    201   1.1       cgd 	if (!(obj = get_letter_object(ch))) {
    202   1.7  dholland 		messagef(0, "no such item.");
    203   1.1       cgd 		return;
    204   1.1       cgd 	}
    205   1.1       cgd 	if (obj->what_is != SCROL) {
    206   1.7  dholland 		messagef(0, "you can't read that");
    207   1.1       cgd 		return;
    208   1.1       cgd 	}
    209   1.1       cgd 	switch(obj->which_kind) {
    210   1.1       cgd 		case SCARE_MONSTER:
    211   1.7  dholland 			messagef(0, "you hear a maniacal laughter in the distance");
    212   1.1       cgd 			break;
    213   1.1       cgd 		case HOLD_MONSTER:
    214   1.1       cgd 			hold_monster();
    215   1.1       cgd 			break;
    216   1.1       cgd 		case ENCH_WEAPON:
    217   1.1       cgd 			if (rogue.weapon) {
    218   1.1       cgd 				if (rogue.weapon->what_is == WEAPON) {
    219   1.7  dholland 					messagef(0, "your %sglow%s %sfor a moment",
    220   1.7  dholland 						name_of(rogue.weapon),
    221   1.7  dholland 						((rogue.weapon->quantity <= 1) ? "s" : ""),
    222   1.7  dholland 						get_ench_color());
    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.7  dholland 				messagef(0, "your hands tingle");
    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.7  dholland 				messagef(0, "your armor glows %sfor a moment",
    237   1.7  dholland 					get_ench_color());
    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.7  dholland 				messagef(0, "your skin crawls");
    243   1.1       cgd 			}
    244   1.1       cgd 			break;
    245   1.1       cgd 		case IDENTIFY:
    246   1.7  dholland 			messagef(0, "this is a scroll of identify");
    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.7  dholland 			messagef(0, "you fall asleep");
    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.7  dholland 				messagef(0, "your armor is covered by a shimmering gold shield");
    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.7  dholland 				messagef(0, "your acne seems to have disappeared");
    265   1.1       cgd 			}
    266   1.1       cgd 			break;
    267   1.1       cgd 		case REMOVE_CURSE:
    268   1.7  dholland 				messagef(0, (!halluc) ?
    269   1.1       cgd 					"you feel as though someone is watching over you" :
    270   1.7  dholland 					"you feel in touch with the universal oneness");
    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.7  dholland 			messagef(0, "this scroll seems to have a map on it");
    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.8  dholland 			messagef(0, "your hands glow %sfor a moment",
    286   1.7  dholland 				 get_ench_color());
    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.4     lukem void
    300   1.9  dholland vanish(object *obj, short rm, object *pack)
    301   1.1       cgd {
    302   1.1       cgd 	if (obj->quantity > 1) {
    303   1.1       cgd 		obj->quantity--;
    304   1.1       cgd 	} else {
    305   1.1       cgd 		if (obj->in_use_flags & BEING_WIELDED) {
    306   1.1       cgd 			unwield(obj);
    307   1.1       cgd 		} else if (obj->in_use_flags & BEING_WORN) {
    308   1.1       cgd 			unwear(obj);
    309   1.1       cgd 		} else if (obj->in_use_flags & ON_EITHER_HAND) {
    310   1.1       cgd 			un_put_on(obj);
    311   1.1       cgd 		}
    312   1.1       cgd 		take_from_pack(obj, pack);
    313   1.1       cgd 		free_object(obj);
    314   1.1       cgd 	}
    315   1.1       cgd 	if (rm) {
    316   1.8  dholland 		(void)reg_move();
    317   1.1       cgd 	}
    318   1.1       cgd }
    319   1.1       cgd 
    320  1.10  dholland static void
    321   1.9  dholland potion_heal(int extra)
    322   1.1       cgd {
    323   1.1       cgd 	float ratio;
    324   1.1       cgd 	short add;
    325   1.1       cgd 
    326   1.1       cgd 	rogue.hp_current += rogue.exp;
    327   1.1       cgd 
    328   1.1       cgd 	ratio = ((float)rogue.hp_current) / rogue.hp_max;
    329   1.1       cgd 
    330   1.1       cgd 	if (ratio >= 1.00) {
    331   1.1       cgd 		rogue.hp_max += (extra ? 2 : 1);
    332   1.1       cgd 		extra_hp += (extra ? 2 : 1);
    333   1.1       cgd 		rogue.hp_current = rogue.hp_max;
    334   1.1       cgd 	} else if (ratio >= 0.90) {
    335   1.1       cgd 		rogue.hp_max += (extra ? 1 : 0);
    336   1.1       cgd 		extra_hp += (extra ? 1 : 0);
    337   1.1       cgd 		rogue.hp_current = rogue.hp_max;
    338   1.1       cgd 	} else {
    339   1.1       cgd 		if (ratio < 0.33) {
    340   1.1       cgd 			ratio = 0.33;
    341   1.1       cgd 		}
    342   1.1       cgd 		if (extra) {
    343   1.1       cgd 			ratio += ratio;
    344   1.1       cgd 		}
    345   1.9  dholland 		add = (short)(ratio * (rogue.hp_max - rogue.hp_current));
    346   1.1       cgd 		rogue.hp_current += add;
    347   1.1       cgd 		if (rogue.hp_current > rogue.hp_max) {
    348   1.1       cgd 			rogue.hp_current = rogue.hp_max;
    349   1.1       cgd 		}
    350   1.1       cgd 	}
    351   1.1       cgd 	if (blind) {
    352   1.1       cgd 		unblind();
    353   1.1       cgd 	}
    354   1.1       cgd 	if (confused && extra) {
    355   1.9  dholland 		unconfuse();
    356   1.1       cgd 	} else if (confused) {
    357   1.1       cgd 		confused = (confused / 2) + 1;
    358   1.1       cgd 	}
    359   1.1       cgd 	if (halluc && extra) {
    360   1.1       cgd 		unhallucinate();
    361   1.1       cgd 	} else if (halluc) {
    362   1.1       cgd 		halluc = (halluc / 2) + 1;
    363   1.1       cgd 	}
    364   1.1       cgd }
    365   1.1       cgd 
    366  1.10  dholland static void
    367   1.9  dholland idntfy(void)
    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.7  dholland 		messagef(0, "no such item, try again");
    381   1.7  dholland 		messagef(0, "%s", "");	/* gcc objects to just "" */
    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.7  dholland 	get_desc(obj, desc, sizeof(desc));
    391   1.7  dholland 	messagef(0, "%s", desc);
    392   1.1       cgd }
    393   1.1       cgd 
    394   1.4     lukem void
    395   1.9  dholland eat(void)
    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 
    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.7  dholland 		messagef(0, "no such item.");
    408   1.1       cgd 		return;
    409   1.1       cgd 	}
    410   1.1       cgd 	if (obj->what_is != FOOD) {
    411   1.7  dholland 		messagef(0, "you can't eat that");
    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.7  dholland 			messagef(0, "yum, that tasted good");
    418   1.1       cgd 		} else {
    419   1.7  dholland 			messagef(0, "my, that was a yummy %s", fruit);
    420   1.1       cgd 		}
    421   1.1       cgd 	} else {
    422   1.1       cgd 		moves = get_rand(750, 950);
    423   1.7  dholland 		messagef(0, "yuk, that food tasted awful");
    424   1.1       cgd 		add_exp(2, 1);
    425   1.1       cgd 	}
    426   1.1       cgd 	rogue.moves_left /= 3;
    427   1.1       cgd 	rogue.moves_left += moves;
    428   1.1       cgd 	hunger_str[0] = 0;
    429   1.1       cgd 	print_stats(STAT_HUNGER);
    430   1.1       cgd 
    431   1.1       cgd 	vanish(obj, 1, &rogue.pack);
    432   1.1       cgd }
    433   1.1       cgd 
    434  1.10  dholland static void
    435   1.9  dholland hold_monster(void)
    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.7  dholland 		messagef(0, "you feel a strange sense of loss");
    460   1.1       cgd 	} else if (mcount == 1) {
    461   1.7  dholland 		messagef(0, "the monster freezes");
    462   1.1       cgd 	} else {
    463   1.7  dholland 		messagef(0, "the monsters around you freeze");
    464   1.1       cgd 	}
    465   1.1       cgd }
    466   1.1       cgd 
    467   1.4     lukem void
    468   1.9  dholland tele(void)
    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.4     lukem void
    481   1.9  dholland hallucinate(void)
    482   1.1       cgd {
    483   1.1       cgd 	object *obj, *monster;
    484   1.1       cgd 	short ch;
    485   1.1       cgd 
    486   1.1       cgd 	if (blind) return;
    487   1.1       cgd 
    488   1.1       cgd 	obj = level_objects.next_object;
    489   1.1       cgd 
    490   1.1       cgd 	while (obj) {
    491   1.1       cgd 		ch = mvinch(obj->row, obj->col);
    492   1.1       cgd 		if (((ch < 'A') || (ch > 'Z')) &&
    493   1.1       cgd 			((obj->row != rogue.row) || (obj->col != rogue.col)))
    494   1.1       cgd 		if ((ch != ' ') && (ch != '.') && (ch != '#') && (ch != '+')) {
    495   1.1       cgd 			addch(gr_obj_char());
    496   1.1       cgd 		}
    497   1.1       cgd 		obj = obj->next_object;
    498   1.1       cgd 	}
    499   1.1       cgd 	monster = level_monsters.next_monster;
    500   1.1       cgd 
    501   1.1       cgd 	while (monster) {
    502   1.1       cgd 		ch = mvinch(monster->row, monster->col);
    503   1.1       cgd 		if ((ch >= 'A') && (ch <= 'Z')) {
    504   1.1       cgd 			addch(get_rand('A', 'Z'));
    505   1.1       cgd 		}
    506   1.1       cgd 		monster = monster->next_monster;
    507   1.1       cgd 	}
    508   1.1       cgd }
    509   1.1       cgd 
    510   1.4     lukem void
    511   1.9  dholland unhallucinate(void)
    512   1.1       cgd {
    513   1.1       cgd 	halluc = 0;
    514   1.1       cgd 	relight();
    515   1.7  dholland 	messagef(1, "everything looks SO boring now");
    516   1.1       cgd }
    517   1.1       cgd 
    518   1.4     lukem void
    519   1.9  dholland unblind(void)
    520   1.1       cgd {
    521   1.1       cgd 	blind = 0;
    522   1.7  dholland 	messagef(1, "the veil of darkness lifts");
    523   1.1       cgd 	relight();
    524   1.1       cgd 	if (halluc) {
    525   1.1       cgd 		hallucinate();
    526   1.1       cgd 	}
    527   1.1       cgd 	if (detect_monster) {
    528   1.1       cgd 		show_monsters();
    529   1.1       cgd 	}
    530   1.1       cgd }
    531   1.1       cgd 
    532   1.4     lukem void
    533   1.9  dholland relight(void)
    534   1.1       cgd {
    535   1.1       cgd 	if (cur_room == PASSAGE) {
    536   1.1       cgd 		light_passage(rogue.row, rogue.col);
    537   1.1       cgd 	} else {
    538   1.1       cgd 		light_up_room(cur_room);
    539   1.1       cgd 	}
    540   1.1       cgd 	mvaddch(rogue.row, rogue.col, rogue.fchar);
    541   1.1       cgd }
    542   1.1       cgd 
    543   1.4     lukem void
    544   1.9  dholland take_a_nap(void)
    545   1.1       cgd {
    546   1.1       cgd 	short i;
    547   1.1       cgd 
    548   1.1       cgd 	i = get_rand(2, 5);
    549   1.1       cgd 	md_sleep(1);
    550   1.1       cgd 
    551   1.1       cgd 	while (i--) {
    552   1.1       cgd 		mv_mons();
    553   1.1       cgd 	}
    554   1.1       cgd 	md_sleep(1);
    555   1.7  dholland 	messagef(0, "%s", you_can_move_again);
    556   1.1       cgd }
    557   1.1       cgd 
    558  1.10  dholland static void
    559   1.9  dholland go_blind(void)
    560   1.1       cgd {
    561   1.1       cgd 	short i, j;
    562   1.1       cgd 
    563   1.1       cgd 	if (!blind) {
    564   1.7  dholland 		messagef(0, "a cloak of darkness falls around you");
    565   1.1       cgd 	}
    566   1.1       cgd 	blind += get_rand(500, 800);
    567   1.1       cgd 
    568   1.1       cgd 	if (detect_monster) {
    569   1.1       cgd 		object *monster;
    570   1.1       cgd 
    571   1.1       cgd 		monster = level_monsters.next_monster;
    572   1.1       cgd 
    573   1.1       cgd 		while (monster) {
    574   1.1       cgd 			mvaddch(monster->row, monster->col, monster->trail_char);
    575   1.1       cgd 			monster = monster->next_monster;
    576   1.1       cgd 		}
    577   1.1       cgd 	}
    578   1.1       cgd 	if (cur_room >= 0) {
    579   1.1       cgd 		for (i = rooms[cur_room].top_row + 1;
    580   1.1       cgd 			 i < rooms[cur_room].bottom_row; i++) {
    581   1.1       cgd 			for (j = rooms[cur_room].left_col + 1;
    582   1.1       cgd 				 j < rooms[cur_room].right_col; j++) {
    583   1.1       cgd 				mvaddch(i, j, ' ');
    584   1.1       cgd 			}
    585   1.1       cgd 		}
    586   1.1       cgd 	}
    587   1.1       cgd 	mvaddch(rogue.row, rogue.col, rogue.fchar);
    588   1.1       cgd }
    589   1.1       cgd 
    590  1.10  dholland static const char *
    591   1.9  dholland get_ench_color(void)
    592   1.1       cgd {
    593   1.1       cgd 	if (halluc) {
    594   1.1       cgd 		return(id_potions[get_rand(0, POTIONS-1)].title);
    595   1.1       cgd 	} else if (con_mon) {
    596   1.1       cgd 		return("red ");
    597   1.8  dholland 	}
    598   1.1       cgd 	return("blue ");
    599   1.1       cgd }
    600   1.1       cgd 
    601   1.4     lukem void
    602   1.9  dholland cnfs(void)
    603   1.1       cgd {
    604   1.1       cgd 	confused += get_rand(12, 22);
    605   1.1       cgd }
    606   1.1       cgd 
    607   1.4     lukem void
    608   1.9  dholland unconfuse(void)
    609   1.1       cgd {
    610   1.1       cgd 	confused = 0;
    611   1.7  dholland 	messagef(1, "you feel less %s now", (halluc ? "trippy" : "confused"));
    612   1.1       cgd }
    613   1.1       cgd 
    614  1.10  dholland static void
    615   1.9  dholland uncurse_all(void)
    616   1.1       cgd {
    617   1.1       cgd 	object *obj;
    618   1.1       cgd 
    619   1.1       cgd 	obj = rogue.pack.next_object;
    620   1.1       cgd 
    621   1.1       cgd 	while (obj) {
    622   1.1       cgd 		obj->is_cursed = 0;
    623   1.1       cgd 		obj = obj->next_object;
    624   1.1       cgd 	}
    625   1.1       cgd }
    626