changeset 142:6b5fbd7c3ece

Merge arogue7 and xrogue trees.
author John "Elwin" Edwards
date Tue, 12 May 2015 21:39:39 -0400
parents 66b0263af424 (current diff) cc5148bdf345 (diff)
children 7faf4568c295
files
diffstat 51 files changed, 37418 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/LICENSE.TXT	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,178 @@
+Copyright (C) 1991 Robert Pietkivitch
+Portions Copyright (C) 1985 Michael Morgan, Ken Dalka and AT&T
+Portions Copyright (C) 1981 Michael Toy, Ken Arnold and Glenn Wichman
+Portions Copyright (C) 2000 Nicholas J. Kisseberth
+Portions Copyright (C) 1994 David Burren
+All rights reserved.
+
+===========================================================================
+
+XRogue: Expeditions into the Dungeons of Doom
+Copyright (C) 1991 Robert Pietkivitch
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name(s) of the author(s) nor the names of other contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+4. The name "XRogue" must not be used to endorse or promote products 
+   derived from this software without prior written permission.
+5. Products derived from this software may not be called "XRogue",
+   nor may "XRogue" appear in their name, without prior written
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+===========================================================================
+
+Portions of this software are based on the work of Michael Morgan and 
+Ken Dalka. Used under license:
+
+Advanced Rogue
+Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name(s) of the author(s) nor the names of other contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+4. The name "Advanced Rogue" and "ARogue" must not be used to endorse or
+   promote products derived from this software without prior written
+   permission.
+5. Products derived from this software may not be called "Advanced Rogue" or
+   "ARogue", nor may "Advanced Rogue" or "ARogue" appear in their name,
+   without prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+===========================================================================
+
+Portions of this software are based on the work of Michael Toy, Ken Arnold
+and Glenn Wichman. Used under license:
+
+Rogue: Exploring the Dungeons of Doom
+Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name(s) of the author(s) nor the names of other contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+===========================================================================
+
+Portions of this software (save/restore game state) are based on the work 
+of Nicholas J. Kisseberth. Used under license:
+
+Copyright (C) 2000 Nicholas J. Kisseberth
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name(s) of the author(s) nor the names of other contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+===========================================================================
+
+Portions of this software (encryption) are based on the work 
+of David Burren. Used under license:
+
+FreeSec: libcrypt
+
+Copyright (C) 1994 David Burren
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name(s) of the author(s) nor the names of other contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/Makefile	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,115 @@
+#   XRogue: Expeditions into the Dungeons of Doom
+#   Copyright (C) 1991 Robert Pietkivitch
+#   All rights reserved.
+#
+#   Based on "Advanced Rogue"
+#   Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+#   All rights reserved.
+#
+#   Based on "Rogue: Exploring the Dungeons of Doom"
+#   Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+#   All rights reserved.
+#
+#   See the file LICENSE.TXT for full copyright and licensing information.
+
+DISTNAME=xrogue8.0.3
+PROGRAM=xrogue
+
+O=o
+
+HDRS  =	rogue.h mach_dep.h network.h
+
+OBJS1 =	vers.$(O) actions.$(O) bolt.$(O) chase.$(O) command.$(O) daemon.$(O) \
+        daemons.$(O) eat.$(O) effects.$(O) fight.$(O) encumb.$(O) help.$(O) \
+        init.$(O) io.$(O) list.$(O) main.$(O) maze.$(O) misc.$(O) monsters.$(O)
+OBJS2 = mons_def.$(O) move.$(O) n_level.$(O) options.$(O) outside.$(O) pack.$(O) \
+        passages.$(O) player.$(O) potions.$(O) rings.$(O) rip.$(O) rooms.$(O) \
+        save.$(O) scrolls.$(O) sticks.$(O) things.$(O) trader.$(O) util.$(O) \
+        weapons.$(O) wear.$(O) wizard.$(O) rogue.$(O) state.$(O) xcrypt.$(O)
+OBJS  = $(OBJS1) $(OBJS2)
+
+CFILES=	vers.c actions.c bolt.c chase.c command.c daemon.c daemons.c eat.c \
+	effects.c fight.c encumb.c help.c init.c io.c list.c main.c maze.c \
+	misc.c monsters.c mons_def.c move.c n_level.c options.c outside.c \
+	pack.c passages.c player.c potions.c rings.c rip.c rooms.c save.c \
+	scrolls.c sticks.c things.c trader.c util.c weapons.c wear.c wizard.c \
+	rogue.c state.c xcrypt.c
+
+MISC  = Makefile README.TXT LICENSE.TXT $(PROGRAM).sln $(PROGRAM).vcproj
+
+CC    = gcc
+CFLAGS= -O3
+CRLIB = -lcurses
+RM    = rm -f
+TAR   = tar 
+.SUFFIXES: .obj
+
+.c.obj:
+	$(CC) $(CFLAGS) /c $*.c
+
+$(PROGRAM): $(HDRS) $(OBJS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(CRLIB) -o $@
+
+clean:
+	$(RM) $(OBJS1)
+	$(RM) $(OBJS2)
+	$(RM) core a.exe a.out a.exe.stackdump $(PROGRAM) $(PROGRAM).exe $(PROGRAM).tar $(PROGRAM).tar.gz $(PROGRAM).zip
+
+dist.src:
+	make clean
+	tar cf $(DISTNAME)-src.tar $(CFILES) $(HDRS) $(MISC)
+	gzip -f $(DISTNAME)-src.tar
+
+dist.irix:
+	make clean
+	make CC=cc CFLAGS="-woff 1116 -O3" $(PROGRAM)
+	tar cf $(DISTNAME)-irix.tar $(PROGRAM) README.TXT LICENSE.TXT
+	gzip -f $(DISTNAME)-irix.tar
+
+dist.aix:
+	make clean
+	make CC=xlc CFLAGS="-qmaxmem=16768 -O3 -qstrict" $(PROGRAM)
+	tar cf $(DISTNAME)-aix.tar $(PROGRAM) README.TXT LICENSE.TXT
+	gzip -f $(DISTNAME)-aix.tar
+
+dist.linux:
+	make clean
+	make $(PROGRAM)
+	tar cf $(DISTNAME)-linux.tar $(PROGRAM) README.TXT LICENSE.TXT
+	gzip -f $(DISTNAME)-linux.tar
+	
+dist.interix:
+	make clean
+	make $(PROGRAM)
+	tar cf $(DISTNAME)-interix.tar $(PROGRAM) README.TXT LICENSE.TXT
+	gzip -f $(DISTNAME)-interix.tar
+	
+dist.cygwin:
+	make clean
+	make $(PROGRAM)
+	tar cf $(DISTNAME)-cygwin.tar $(PROGRAM).exe README.TXT LICENSE.TXT
+	gzip -f $(DISTNAME)-cygwin.tar
+	
+dist.mingw32:
+	$(MAKE) RM="cmd /c del" clean
+	$(MAKE) CRLIB="-lpdcurses -lWs2_32" $(PROGRAM)
+	cmd /c del $(DISTNAME)-mingw32.zip
+	zip $(DISTNAME)-mingw32.zip $(PROGRAM).exe README.TXT LICENSE.TXT
+	
+dist.msys:
+	$(MAKE) clean
+	$(MAKE) CRLIB="-lcurses -lWs2_32" $(PROGRAM)
+	tar cf $(DISTNAME)-msys.tar $(PROGRAM).exe README.TXT LICENSE.TXT
+	gzip -f $(DISTNAME)-msys.tar
+	
+dist.djgpp:
+	make clean
+	make LDFLAGS="-L$(DJDIR)/LIB" CRLIB="-lpdcurses" $(PROGRAM)
+	rm -f $(DISTNAME)-djgpp.zip
+	zip $(DISTNAME)-djgpp.zip $(PROGRAM) README.TXT LICENSE.TXT
+
+dist.win32:
+	nmake O="obj" RM="-del" clean
+	nmake O="obj" CC="CL" CRLIB="..\pdcurses.lib shell32.lib user32.lib Advapi32.lib Ws2_32.lib" CFLAGS="-DPDC_STATIC_BUILD -nologo -I.. -Ox -wd4033 -wd4716" $(PROGRAM)
+	-del $(DISTNAME)-win32.zip
+	zip $(DISTNAME)-win32.zip $(PROGRAM).exe README.TXT LICENSE.TXT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/README.TXT	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,646 @@
+    Welcome to XRogue
+    http://roguelike.sourceforge.net/xrogue
+
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+
+
+XRogue: Expeditions into the Dungeons of Doom
+---------------------------------------------
+
+Introduction:
+
+Rogue was introduced at the University of California at Berkeley as a
+screen-oriented fantasy game.  The game had 26 types of monsters that
+the player could meet while exploring a Dungeon generated by the computer.
+Scrolls, potions, rings, wands, staves, armor, and weapons helped the
+player to battle these monsters and to gain gold, the basis for scoring.
+
+The version of rogue described in this guide has been expanded to include
+over 200 monsters with many new capabilities and has been renamed xrogue.
+Many of the monsters are intelligent and they, like the player, must avoid
+traps and decide when it is better to fight or to run.  There are also a
+number of new commands in this version not found in previous versions.
+
+The game contains monsters, spells, weapons, armor, potions, and other
+magical items that you will discover during your quest.  The Dungeon's
+geography changes with every game and although many magical items have
+certain identifiable properties, such as turning the player invisible,
+the physical manifestation of the magic changes each game.  A red potion,
+for example, will cause the same reaction throughout a given game but
+it may be a completely different potion in a new game.
+
+Entering the Dungeon with only a little food, armor, and a weapon, the
+player must develop a good strategy of when to fight, when to run, and
+how to best use any magical item found in the Dungeon.  To make things
+interesting the player has a quest to return one of several unique and
+magical artifacts which are rumored to lie deep within the Dungeon.
+Returning with this artifact to the surface brings great honor.
+
+However, after finding the artifact, the player may wish to continue
+his quest deeper into the Dungeon to match wits with an arch-devil, a
+demon-prince, or perhaps Charon the Boatman.  Defeating such a creature
+will gain the player many experience points which is the basis for
+scoring in xrogue.  It is very difficult to return from the Dungeons
+of Doom alive.  Very few players have won this game.
+
+Character Classes:
+
+Before placing the player in the Dungeon, the game requests that you
+select what type of character they would like to be: Fighter, Paladin,
+Ranger, Magic-User, Cleric, Thief, Assassin, Druid, or Monk.
+
+    The Fighter
+
+A Fighter has the best odds at winning battles with monsters.  At high
+experience levels, the Fighter is able to attack his opponent multiple
+times in a single turn.  Strength is the main attribute of the Fighter.
+
+    The Magic-User
+
+A Magic-User is able to cast spells.  Intelligence is the main attribute.
+The number of spells a Magic-User can cast increases as he gains in
+experience points and in intelligence.  His spell casting ability allows
+him to identify any item in the Dungeon.  16 spells.
+
+    The Cleric
+
+A Cleric is able to pray for assistance in battle.  Wisdom is the main
+attribute.  The number of prayers granted to the Cleric increases as he
+gains in experience points and in wisdom.  Clerics can affect (turn) the
+undead monsters to avoid battle.  Ie., zombies, ghouls, etc.  If the
+Cleric is very powerful relative to the undead monster, turning it will
+utterly destroy it.  16 prayers.
+
+    The Paladin
+
+A Paladin is a type of holy warrior, being a cross between a Cleric
+and a Fighter.  He is able to pray and affect the undead like the Cleric
+and fight like the Fighter, but both to a lesser extent.  He is on the
+side of all that is righteous and good and would never attack a monster
+that has not attacked him first.  If he happens to kill such a monster,
+inadvertantly or otherwise, he will begin to feel increasingly uneasy.
+If he kills too many such monsters, he will face karmic retaliation and
+be reduced to a mere Fighter, minus all of the Cleric's ability.
+Charisma is the main attribute with Wisdom second.
+
+    The Ranger
+
+A Ranger is a type of mystical warrior, being a cross between the
+Magic-User and Fighter.  Like the Paladin, he is on the side of all
+that is righteous and good and would never attack a monster that
+has not attacked him first.  A Ranger is able to cast spells like the
+Magic-User and fight like the Fighter, but both to a lesser extent.
+Charisma is the main attribute with Intelligence second.
+
+    The Thief
+
+A Thief is exceptionally dexterous and has great skill at being able
+to set a traps for and/or rob (steal) items from monsters.  Thieves have
+the ability to detect all the gold and hidden traps on each level of
+the Dungeon.  Their dexterous nature gives Thieves the ability to move
+very quietly, so they are not as likely as to wake up sleeping monsters
+as are the other character types.  If a Thief manages to sneak up on a
+creature without waking it he may be able to backstab the monster.  The
+damage from a backstab is greatly increased based upon the experience
+level.  Dexterity is the main attribute.
+
+    The Assassin
+
+An Assassin is a person trained in the art of killing monsters by
+surprise.  He has some of the abilities of the Thief, but he cannot
+sense traps or backstab.  Instead, the Assassin has the chance to kill
+an opponent outright with one deadly blow.  He can recognize and use
+poison found in the Dungeon on his weapon, thereby, making his next
+attack exceptionally lethal.  Dexterity is the main attribute.
+
+    The Druid
+
+A Druid is a type of magical warrior, being a cross between the Cleric
+and the Magic-User.  A Druid can chant both spells and prayers plus a
+few of his own.  The number of chants available to the Druid increases
+as he gains in experience points and in Wisdom.  Wisdom is the main
+attribute.  16 chants.
+
+    The Monk
+
+A Monk is trained in the martial arts.  He wears no armor and does not
+need a weapon (although using them is not forbidden).  As the Monk gains
+in experience points his natural defense or ability to dodge attackers
+increases.  The Mong is a cross between the Druid and Fighter, so he
+can chant and also fight like the Fighter, but both to a lesser extent.
+Constitution is the main attribute, with wisdom second.
+
+Attributes Of The Charaters:
+
+Strength - The primary attribute for encumberance.
+
+Intelligence - The primary attribute for casting spells.
+
+Wisdom - The primary attribute for prayers and chanting.
+
+Dexterity - The primary attribute for stealthiness.
+
+Charisma - The primary attribute for good will.  High Charisma also
+           affects the cost of objects when making transactions.
+
+Constitution - The primary attribute for health.  High Constitution
+               affects the amount of hit points you receive when
+               moving up in experience levels.
+
+Note: The Ranger, Paladin, and Monk do not receive their "special"
+magical abilities until they have advanced a few experience levels.
+
+Experience Levels:
+
+Characters gain experience points mostly from killing monsters.  Other
+actions, such as stealing items from monsters, backstabbing, and turning
+monsters, also add extra experience points.  Each character type gains
+experience points and moves up in experience levels at different rates.
+Moving up in experience levels adds extra hit points to the character
+which determines how many "hits" he can take before being killed.
+
+Allocating Attribute Points To The Characters:
+
+A player starts with 75 attribute points to distribute in to the character
+he has chosen to play.  When you are prompted to distribute the attribute
+points, the screen displays the minimum and maximum allowable values for
+that particular attribute.  The player can type a backspace (Ctrl-H) to go
+back and change a previous value and typing an escape (ESC) sets all the
+remaining attributes to the maximum value possible, given the number of
+remaining attribute points to be distributed.
+
+THE SCREEN
+
+During the normal course of play, the screen consists of three separate
+sections:  the top line, the bottom two lines, and the remaining screen
+in the middle.  The top line reports actions which occur during the game,
+the middle section depicts the Dungeon, and the bottom two lines describe
+the player's current condition.
+
+Whenever anything happens to the player, such as finding a scroll, hitting
+a monster, or being hit by a monster, a short report appears on the top
+line of the screen.  When you see the word 'More' on the top line, that
+means you must press the space key to continue.
+
+The following items may be found within the Dungeon. Some of them have
+more than one interpretation, depending upon whether your character
+recognizes them or not.
+
+|  A wall of a room.
+-  A wall of a room.
+*  A pile of gold.
+%  A way to another level.
++  A doorway.
+.  The floor in a room.
+#  The floor in a passageway.
+    Solid rock (denoted by a space).
+^  The entrance to a Trading Post
+@  The player.
+_  The player, when invisible.
+:  Some food.
+!  A flask containing a potion.
+?  A sealed scroll.
+=  A ring.
+)  A weapon.
+]  Some armor.
+;  A miscellaneous magic item
+,  An artifact
+/  A wand or a staff.
+ >  A trapdoor leading to the next level
+{  An arrow trap
+$  A sleeping gas trap
+}  A beartrap
+~  A trap that teleports you somewhere else
+`  A poison dart trap
+"  A shimmering magic pool
+'  An entrance to a maze
+$  Any magical item. (During magic detection)
+ >  A blessed magical item. (During magic detection)
+<  A cursed magical item. (During magic detection)
+
+Monsters are depicted as letters of the alphabet.  Note that all letters
+denote multiple monsters, depending on which level of the Dungeon you are
+on.  The player may identify a current monster by using the identify
+command ('/') or the clarify command ('=').
+
+The bottom two lines of the screen describe the player's current status.
+The first line gives the player's characteristics:
+
+Intelligence, Strength, Wisdom, Dexterity, Charisma, and Constitution
+all have a normal maximum value of 50 points, but they can go higher if
+augmented by a ring.  Encumberance is a measurement of how much the player
+can carry versus how much he is currently carrying. The more you carry
+relative to your maximum encumberance causes you to use more food.  The
+attribute of Strength fortifies one's encumberance.
+
+The player's current number of hit points are denoted as (Hp) and it is
+followed in parentheses by the player's current maximum hit points.  Hit
+points express the player's survivability.  As a player heals by resting,
+using potions, or spells, the player's current hit points gradually increase
+until they reach the current maximum.  This maximum number will be increased
+each time a player goes up an experience level.  If the player's current hit
+points reach 0, the player becomes "metabolically challenged".
+
+The player's armor class is denoted as (Ac).  This number describes the
+amount of protection provided by the armor, cloaks, and/or rings currently
+worn by the player. It is also affected by high or low dexterity.  Wearing
+no armor is equivalent to an armor class of 10 (Monk excepted).  The lower
+the armor class number, the better.
+
+The player's current experience level is denoted as (Exp), followed by
+the player's experience points.  A new experience level brings extra hit
+points and possibly added abilities, such as new spells for a Magic-user,
+new prayers for a Cleric, and new chants for a Druid.  There are a total
+of 26 experience levels per character.
+
+Commands:
+
+A player can invoke most commands by typing in a single character.
+Some commands, however, require a direction, in which case the player
+types the command character followed by a directional letter.  Many
+commands can be prefaced by a number, indicating how many times the
+command should be executed.
+
+When the player invokes a command referring to an item in the player's
+pack (such as reading a scroll), the game prompts for the item.  The
+player can then type the letter associated with the item.  Typing a '*'
+will produce a list of eligible items.
+
+A list of basic games commands:
+
+?  Preceding a command by a '?' produces a brief explanation of the
+    command.  The command '?*' gives an explanation of all the commands.
+    A '?@' gives information on things you encounter (rock, forest, etc).
+/  Preceding a symbol by a '/' identifies the symbol.
+=  Clarify.  After typing an '=' sign, the player can use the movement
+    keys to position the cursor anywhere on the current level.  As long
+    as the player can normally see the selected position, the game will
+    identify whatever is there.
+h  Move one position to the left.
+j  Move one position down.
+k  Move one position up.
+l  Move one position to the right.
+y  Move one position to the top left.
+u  Move one position to the top right.
+b  Move one position to the bottom left.
+n  Move one position to the bottom right.
+H  Run to the left until reaching something interesting.
+J  Run down until reaching something interesting.
+K  Run up until reaching something interesting.
+L  Run to the right until reaching something interesting.
+Y  Run to the top left until reaching something interesting.
+U  Run to the top right until reaching something interesting.
+B  Run to the bottom left until reaching something interesting.
+N  Run to the bottom right until reaching something interesting.
+
+ >  Go down the stairs to the next level or enter the outer region if you
+    are standing upon the wormhole trap (must be "flying" for this to work).
+<  Go up the stairs to the next level or enter the outer region if you are
+    standing upon the wormhole trap (must be "flying" for this to work).
+
+*  Count the gold in the player's pack.
+!  Escape to the shell level.
+$  Price an item at the Trading Post.
+#  Buy an item at the Trading Post.
+%  Sell an item at the Trading Post.
+.  This command (a period) causes the player to rest one turn.
+^  This command sets traps and is limited to Thieves and Assassins.  If the
+    command is successful the game will ask the player for the trap type and
+    sets it where the player is standing.
+a  Affect the undead.  This command is restricted to Clerics and Paladins
+    and must be followed by a directional letter.
+A  Choose your quest item (at game startup only!).
+c  This command is restricted to Druids and Monks and it produces a list of
+    available chants.  The player can select one of the displayed chants and
+    if the player's energy level is sufficiently high, "chant" it.  The more
+    complicated the spell, the more energy it will take.
+C  This command is restricted to Magic-Users and Rangers and it produces a
+    list of available spells.  The player can select one of the displayed
+    spells and if the player's energy level is sufficiently high, "cast" it.
+    The more complicated the spell, the more energy it will take.
+d  Drop an item from the player's pack.
+D  Dip something into a magic pool.
+e  Eat some food from the player's pack.
+f  When this command is preceded with a directional command, the player will
+    move in the specified direction until he crosses something interesting.
+F  Frighten a monster.  Not available to all characters.  This command
+    loses it's power at around level 10.
+g  Give away or trade a slime-mold for food with a monster.
+G  This command is restricted to Thieves and Assassins.  It causes the game
+    to display all of the gold on the current level.
+i  Display an inventory of the player's pack.
+I  This command prompts for an item from the player's pack and displays
+    the inventory information for that item.
+m  When the player types this command, you are prompted to mark an item
+    with a one-line name.
+o  Typing this command causes the game to display all the settable options.
+    The player can then examine them or change (some of) them
+O  Display your current character type and quest item.
+p  This command is restricted to Clerics and Paladins and it produces a
+    list of available prayers.  The player can then select one of the
+    displayed prayers and if the player's energy level is sufficiently high,
+    "pray" it.  The more complicated the prayer, the more energy it will 
+take.
+P  Pick up the items currently under the player.
+q  Quaff a potion from the player's pack.
+Q  Quit without saving the game.
+r  Read a scroll from the player's pack.
+s  Search for a secret door or a trap in the circle surrounding the player.
+S  Save your game to play at a later time.
+t  This command prompts for an object from the players pack.  The player
+    then can throw the object in the specified direction.
+T  Take off whatever the player is wearing.
+v  Print the current xrogue version number.
+w  Wield a weapon from the player's pack.
+W  Wear some armor, ring, or a miscellaneous magic item from the player's
+    pack.  The player can wear a maximum of 8 rings.
+X  This command is restricted to Thieves only.  It causes the game to 
+display
+    all of the hidden traps on the current level.
+z  This command prompts for a wand or staff from the player's pack and zaps
+    it in the specified direction.
++  Fortune cookie! (Note: if you play xrogue over a modem, typing three
+    consecutive '+' will tell your modem to enter "command" mode.  See your
+    modem manual on how to return from this mode).
+
+Escape  Pressing the Escape key will cancel the current command.
+Ctrl-B  Check your current score.  Scoring is based on experience points
+         and gold.  However, gold is not that important and 10% is hacked
+         off if a player is killed.
+Ctrl-E  Check your current food level.  This command is used when you want
+         to see just how much food you have remaining in your stomach.  A
+         full stomach is measured to be about 2000(2100).  As you play the
+         game, this level drops until you become hungry at about 200(2100).
+         A food level over 2000(2100) makes the character satiated, and a
+         level under 200(2100) makes the character hungry, then weak, and
+         finally fainting.  A level of 2000(2100) is the most the character
+         can eat, a full, satisfied stomach!
+Ctrl-L  Redraw the screen.
+Ctrl-N  When the player types this command, the game prompts you to type a
+         one-line name for a monster or for an item in the player's pack
+         To name a monster, position the cursor over the desired monster and
+         rename it.
+Ctrl-O  Display the current "affects" on the player (such as slow, phased,
+         confused, extra sight, flying, dancing, etc.).
+Ctrl-R  Repeat last message displayed on the top line of the screen.
+Ctrl-T  This command is restricted to Thieves and Assassins.  It must be
+         followed by a directional letter.  If a monster is standing next to
+         the player in the specified direction, the effect is to steal an
+         item from the monster's pack.  If successful, the monster does not
+         notice anything, but if the player is unsuccessful, there is a 
+chance
+         the monster will suddenly wake up and attack.
+Ctrl-U  Use a magic item in the player's pack.
+
+There is no explicit attack command.  If a player wishes to do battle with a
+monster, the player simply moves onto the spot where the monster is 
+standing.
+Whatever the player is wielding will be used as the player's weapon.
+
+As the player moves across items, the game automatically picks them up and
+places them into the player's pack.  If there is no room left in the pack,
+the item is left on the floor.  Setting the "pickup" option to "NO" will
+allow the player to pick up items at will using the 'P' command.
+
+All actions except for bookkeeping commands, such as taking an inventory,
+take time.  The amount of time varies with the command.  Swinging a weapon,
+for example, takes more time than simply moving; so a monster could move
+several spaces in the time it takes the player to make one attack.  The
+time it takes to swing a weapon also varies based on the bulk of the weapon,
+and the time it takes to simply move one space varies with the type of armor
+worn and the player's level of encumberance.  Movement is always faster when
+the player is "flying".
+
+Actions also take time and some of them can be disrupted.  If the player is
+casting a spell for example, and gets hit before finishing it, the spell is
+lost.  Similarly, the player might choke if hit while trying to eat.  These
+same rules apply to monsters as well.
+
+Some of the rooms in the Dungeon possess a natural light source.  In most
+other rooms and in corridors, the player can see only those things within
+a one-space radius around the player.  Dark rooms can be lit with magical
+light or by fire beetles and other monsters.
+
+The player can wield only one weapon at a time.  When a player attacks
+a monster, the amount of damage depends on the particular weapon he is
+wielding.  To fire a projectile weapon, such as a crossbow or a short bow,
+the player should wield the bow and throw the bolt or arrow at the monster.
+
+A weapon may be cursed or blessed which will affect the likelihood of you
+hitting a monster with it and the damage that it will inflict on the 
+monster.
+If the player has identified the weapon he is using, the "to hit" and the
+"to damage" bonuses appear (in that order) before the weapons name in the
+inventory listing.  A positive bonus indicates a blessed weapon, and a
+negative bonus usually indicates a cursed or misguided weapon.  A player
+cannot release a cursed weapon until a remove curse scroll is read or cast
+by magical means.
+
+After the player has identified a suit of armor, the protection bonus 
+appears
+before the armors name in the inventory listing.  If the bonus is positive
+the armor is blessed but if it is negative, the armor is probably cursed.
+The player cannot remove a cursed suit of armor until a remove curse scroll
+is read or cast by magical means.
+
+Some monsters can corrode your armor!  If such a monster hits a player
+when the player is wearing metal armor, the armor will lose some of its
+protective value.  This same corrosive property also applies to weapons
+when a player hits a monster with this ability.  Search for a scroll of
+"protection" to guard against corrosion of your armor and weapon.
+
+A player will find many potions and scrolls in the Dungeon.  Reading a
+scroll or quaffing a potion will usually cause some magical occurrence.
+Potions and scrolls may be either cursed or blessed.  In this version of
+xrogue, Monster Confusion scrolls will turn your hands a variety of colors.
+A blessed Magic Mapping scroll shows very detailed maps.  A scroll of
+Genocide works within the dungeon as well as in the outer region.  A
+scroll of blessed Teleportation will teleport you "upward" a few levels.
+Blessed Remove Curse will cause certain monsters to panic if the scroll
+is read near them.  Charm Monster will let you charm several monsters.
+
+The player can wear a maximum of eight rings.  Some of them have a magical
+effect on the player as long as they are worn.  Some rings also speed up
+the player's metabolism, making the player require food more often.  Rings
+can be cursed or blessed and the player cannot remove a cursed ring until
+a remove curse scroll is read or cast.
+
+Wands, rods, and staves help a player in battle and affect the Dungeon.
+A player uses the "z" (zap) command to use a wand either to shoot at a
+monster, teleport, or to light up a dark room.  Wands can be cursed or
+blessed.
+
+A player must be frugal with his food.  Both moving and searching through
+the Dungeon, and fighting monsters, consumes energy.  Starving results in
+the player's fainting for increasingly longer periods of time, during which
+any nearby monster can attack the player at will.  Food comes in the form
+of standard rations and as a variety of berries.  Some berries have side
+effects in addition to satisfying one's hunger.  Slime-Molds are monster
+food and if you have one, you may be able to trade it for a regular food
+ration, if the monster is of "friendly" persuasion.
+
+Gold has a couple of uses in the Dungeon.  The first use of gold is to buy
+things, either at a Trading Post or from a Quartermaster.  The Trading Post
+when found, is entered via the '>' command, like going down a stairway.
+A Quartermaster ('q') is a Dungeon vendor who appears at certain times and
+will try to sell the player some of his wares.  The Quartermaster's wares
+are never cursed but they can be blessed, though blessed goods do cost more
+than normal goods.  If the player chooses to buy something offered by a
+Quartermaster, he will make the transaction for the specified amount of gold
+and then disappear.  Attacking a Quartermaster causes him to vanish in
+haste!  You can sometimes find gold at the bottom of "magic pools".  Use
+the ">" command to dive for the gold, but be careful you don't drown!
+
+When beginning a new game, a player is placed in the Trading Post with
+an allotment of gold based upon the type of character chosen to play.
+There are some restrictions on the use of certain items by character.
+For example, only Fighters, Paladins, and Rangers can wield two-handed
+swords while Thieves and Assassins can not wear certain types of armor.
+However, the Trading Post (and Quartermaster) will happily sell a player
+anything that he can afford, whether you need it or not.
+
+Miscellaneous magical items such as a Pair of Boots or a Book are numerous
+within the Dungeon.  These items are usually used to a player's advantage,
+assuming they are not cursed.  Some of these items can be worn, such as a
+Cloak, while others are to be used, such as a Book, Beaker, or Ointment.
+The Medicine Crystal will heal you, remove all curses, heal you, and may
+cause panic in some monsters.
+
+There are a number of unique monsters deep within the depths of the Dungeon
+that carry very special magical items or artifacts.  When you begin the 
+game,
+you are asked to choose a "quest item" to retrieve from the Dungeon.  Most
+of these items can be used to the player's advantage, even if they are not
+one's own personal quest item during the game.  However, care must be taken
+when handling some of them for they have intelligence and some will reject
+mishandling or abuse.  These items consume your food (and your gold) so
+carrying them around results in increased food use.  Some of these items 
+will
+kill you outright if you happen to pick them up while wielding another
+artifact as your weapon.  Don't be too greedy with the artifacts!  Quest
+items begin appearing in xrogue between levels 40-50.  The less traumatic
+quest items appear earlier while the more severe ones appear later.  Once
+a unique monster is killed, you will not encounter another one like it in
+the Dungeon.
+
+A variety of traps exist within the Dungeon, including trap doors, bear
+traps, and sleeping traps.  Sometimes they are hidden from sight until
+sprung by a monster or by the player.  A sprung trap continues to function,
+but since it is visible, an intelligent monster is not likely to tread on 
+it.
+A trap called the Wormhole trap, will transport you to the "outer region"
+of the dungeon.  There you will fight strange dinosaurs until you can make
+your way back to a starwell, and promptly return from whence you came.
+
+Each monster except for the Quartermaster appears in a limited range of
+Dungeon levels.  All monsters of the same type share the same abilities.
+All giant rats, for example, can give the player a disease, and all
+jackalweres can put the player to sleep.  Monsters of the same type will
+vary however, in strength and intelligence.  For example, one kobold may
+be much more difficult to kill off than another.  In general, the more
+difficult it is to kill a monster, the more experience points the monster
+is worth.
+
+Most monsters attack by biting and clawing, but some monsters carry weapons
+and can use their breath as a weapon.  Some monsters can even use magical
+items, such as wands and artifacts.  Monsters with distance weapons or magic
+can sometimes attack a player from across a room or from down a corridor.
+
+Some monsters are more intelligent than others, and the more intelligent
+a monster is, the more likely it will run away if it is about to die.
+A fleeing monster will not attack the player unless it is cornered.
+
+It is sometimes possible to enlist a monster's aid.  Reading a charm monster
+scroll, for example, or singing a charm monster chants can make a monster
+believe that the player is its friend.  A charmed monster will fight hostile
+monsters for the player as long as they are not of its own race.  Be sure
+your charmed monsters are in the same room with you when you enter the next
+level, or they will be lost.
+
+Options:
+
+The game has several options, some of which can only be set by the player
+at the beginning of the game and others during the course of play.
+
+      default - Play the character with "default" attribute settings.
+        terse - Shorten messages at top of screen.
+         jump - Speed up the display of the player's movement
+         step - Lists all inventories one line at a time.
+      overlay - Allows listings of inventories to overlay the currnt screen.
+        flush - Supposed to flush all typed-ahead characters.
+        askme - Prompt the player to name new types of scrolls, potions, 
+etc.
+       pickup - Pick up items automatically as you move across them
+         name - The player's name.
+         file - Saved game filename.  Defaults to xrogue.sav.
+        score - Identifies the location of the game scorefile.
+         type - Specifies the character type (unchangable).
+quested item - Set at start up (unchangeable).
+
+A player can set the game options at the beginning of a game via the
+ROGUEOPTS environment variable.
+
+Some examples:
+
+  ROGUEOPTS="default nopickup, nooverlay, name=Corwin, class=magician"
+  ROGUEOPTS="pickup, overlay, file=xrg.sav, score=/home/games/scorefile"
+
+The player may change an option at any time during the game via the 'o'
+(option) command.  On the options menu, typing a new value changes the
+option and a RETURN moves to the next option in the list.  Typing an '-'
+moves you to the previous option and an ESCAPE returns you to the Dungeon.
+
+A new option called "default" was added in xrogue.  When you put the word
+"default" into your ROGUEOPTS environment variable your character will be
+created with "default" attribute settings, armor, weapon, quest item, and
+some food.
+
+Setting "default" will force the game to skip over the beginning screen
+where you can choose/distribute your attribute points and it also skips
+over the beginning "equippage screen" where you can choose your armor,
+weapon, quest item, and etc.
+
+If you use the "class" option with "default" in ROGUEOPTS, you will
+start the game immediately at level 1 with the default selections
+for your character.
+
+Here is a list of the main and secondary attributes, special ability,
+and quest item ("default" settings) for each character type:
+
+  Character Main Attr.    Secondary     Specialties       Def. Quest Item
+  -------------------------------------------------------------------------
+  Fighter   strength      constitution  sense gold        Axe of Aklad
+  Ranger    charisma      intelligence  cast spells       Mandolin of Brian
+  Paladin   charisma      wisdom        affect undead     Ankh of Heil
+  Cleric    wisdom        dexterity     prayer spells     Horn of Geryon
+  Magician  intelligence  dexterity     cast spells       Stonebones Amulet
+  Thief     dexterity     strength      sense traps       Musty Daggers
+  Assassin  dexterity     strength      steal/use poison  Eye of Vecna
+  Druid     wisdom        dexterity     chant spells      Quill of Nagrom
+  Monk      constitution  dexterity     chant spells      Emori Cloak
+
+A different quest item may be chosen ONLY while you are in the beginning
+Trading Post (if you have NOT set the "default" option via ROGUEOPTS).
+
+When a player is killed, his score will be equal to the amount of his
+experience points gained, plus his gold (minus 10%).  A player that
+quits the game will not lose 10% of his gold.  If a player makes it back
+up and out of the Dungeon alive, his score will be equal to the amount
+of experience points, plus the gold, plus additional gold received from
+selling all of the items in his pack.
+
+The game maintains a top-twenty player scorefile.  As an installation
+option, the game may be compiled so as to record only three entries per
+character type and name.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/actions.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,1074 @@
+/*
+    actions.c  -  functions for dealing with monster actions
+   
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <ctype.h>
+#include <curses.h>
+#include <limits.h>
+#include "rogue.h"
+
+int mf_count = 0;       /* move_free counter - see actions.c(m_act()) */
+int mf_jmpcnt = 0;      /* move_free counter for # of jumps           */
+
+/* 
+ * Did we disrupt a spell? 
+ */
+dsrpt_monster(tp, always, see_him)
+register struct thing *tp;
+bool always, see_him;
+{
+    switch (tp->t_action) {
+    case A_SUMMON:
+    case A_MISSILE:
+    case A_SLOW:
+        tp->t_action = A_NIL;   /* Just make the old fellow start over again */
+        tp->t_no_move = movement(tp);
+        tp->t_using = NULL; /* Just to be on the safe side */
+        turn_on(*tp, WASDISRUPTED);
+        if (see_him)
+            msg("%s's spell has been disrupted.",prname(monster_name(tp),TRUE));
+        /*
+         * maybe choose something else to do next time since player
+         * is disrupting us
+         */
+        tp->t_summon *= 2;
+        tp->t_cast /= 2;
+        return;
+    }
+
+    /* We may want to disrupt other actions, too */
+    if (always) {
+        tp->t_action = A_NIL; /* Just make the old fellow start over again */
+        tp->t_no_move = movement(tp);
+        tp->t_using = NULL;/* Just to be on the safe side */
+    }
+}
+
+dsrpt_player()
+{
+    int which, action;
+    struct linked_list *item;
+    struct object *obj;
+    
+    action = player.t_action;
+    which = player.t_selection;
+
+    switch (action) {
+    case C_CAST: /* Did we disrupt a spell? */
+    case C_PRAY:
+    case C_CHANT:
+    {
+        msg("Your %s was disrupted!", action == C_CAST ? "spell" : "prayer");
+
+        /* Charge him 1/4 anyway */
+        if (action == C_CAST)
+            spell_power += magic_spells[which].s_cost / 4;
+        else if (action == C_PRAY)
+            pray_time += cleric_spells[which].s_cost / 4;
+        else if (action == C_CHANT)
+            chant_time += druid_spells[which].s_cost / 4;
+    }
+    when C_COUNT: /* counting of gold? */
+    {
+        if (purse > 0) {
+            msg("Your gold goes flying everywhere!");
+            do {
+                item = spec_item(GOLD, NULL, NULL, NULL);
+                obj = OBJPTR(item);
+                obj->o_count = min(purse, rnd(20)+1);
+                purse -= obj->o_count;
+                obj->o_pos = hero;
+                fall(item, FALSE);
+            } while (purse > 0 && rnd(25) != 1);
+        }
+    }
+    when C_EAT:
+        msg("Ack!  You gag on your food for a moment. ");
+        del_pack(player.t_using);
+        
+    when A_PICKUP:
+        msg("You drop what you are picking up! ");
+
+    when C_SEARCH:      /* searching for traps and secret doors... */
+        msg("Ouch!  You decide to stop searching. ");
+        count = 0;      /* don't search again */
+
+    when C_SETTRAP:
+        msg("Ouch!  You can't set a trap right now. ");
+
+    when A_NIL:
+    default:
+        return;
+    }
+    player.t_no_move = movement(&player); /* disoriented for a while */
+    player.t_action = A_NIL;
+    player.t_selection = 0;
+}
+
+/*
+ * m_act:
+ *      If the critter isn't doing anything, choose an action for it.
+ *      Otherwise, let it perform its chosen action.
+ */
+
+m_act(tp)
+register struct thing *tp;
+{
+    struct object *obj;
+    bool flee;          /* Are we scared? */
+
+    /* What are we planning to do? */
+    switch (tp->t_action) {
+        default:
+            /* An unknown action! */
+            msg("Unknown monster action (%d)", tp->t_action);
+
+            /* Fall through */
+
+        case A_NIL:
+            /* If the monster is fairly intelligent and about to die, it
+             * may turn tail and run.  But if we are a FRIENDLY creature
+             * in the hero's service, don't run.
+             */
+            if (off(*tp, ISFLEE)                                        &&
+                tp->t_stats.s_hpt < tp->maxstats.s_hpt                  &&
+                tp->t_stats.s_hpt < max(10, tp->maxstats.s_hpt/6)       &&
+                (off(*tp, ISFRIENDLY) || tp->t_dest != &hero)           &&
+                rnd(25) < tp->t_stats.s_intel) {
+                    turn_on(*tp, ISFLEE);
+
+                    /* It is okay to turn tail */
+                    tp->t_oldpos = tp->t_pos;
+                }
+
+            /* Should the monster run away? */
+            flee = on(*tp, ISFLEE) ||
+                ((tp->t_dest == &hero) && on(player, ISINWALL) &&
+                 off(*tp, CANINWALL));
+
+            m_select(tp, flee); /* Select an action */
+            return;
+
+        when A_ATTACK:
+            /* 
+             * We're trying to attack the player or monster at t_newpos 
+             * if the prey moved, do nothing
+             */
+            obj = tp->t_using ? OBJPTR(tp->t_using) : NULL;
+            if (ce(tp->t_newpos, hero)) {
+                attack(tp, obj, FALSE);
+            }
+            else if (mvwinch(mw, tp->t_newpos.y, tp->t_newpos.x) &&
+                     step_ok(tp->t_newpos.y, tp->t_newpos.x, FIGHTOK, tp)) {
+                skirmish(tp, &tp->t_newpos, obj, FALSE);
+            }
+
+        when A_SELL:
+                /* Is the quartermaster still next to us? */
+            if (ce(tp->t_newpos, hero)) sell(tp);
+
+                /* The quartermaster moved away */
+            else if (off(player, ISBLIND) && cansee(unc(tp->t_pos)) &&
+                (off(*tp, ISINVIS)     || on(player, CANSEE)) &&
+                (off(*tp, ISSHADOW)    || on(player, CANSEE)) &&
+                (off(*tp, CANSURPRISE) || ISWEARING(R_ALERT)) &&
+        (rnd(12) < 4))
+                msg("%s grunts with frustration",prname(monster_name(tp),TRUE));
+
+        when A_MOVE:
+            /* Let's try to move */
+            do_chase(tp);
+
+            /* If t_no_move > 0, we found that we have to fight! */
+            if (tp->t_no_move > 0) return;
+
+        when A_BREATHE:
+            /* Breathe on the critter */
+            m_breathe(tp);
+
+        when A_SLOW:
+            /* make him move slower */
+            add_slow();
+            turn_off(*tp, CANSLOW);
+
+        when A_MISSILE:
+            /* Start up a magic missile spell */
+            m_spell(tp);
+
+        when A_SONIC:
+            /* Let out a sonic blast! */
+            m_sonic(tp);
+
+        when A_THROW:
+            /* We're throwing something (like an arrow) */
+            missile(tp->t_newpos.y, tp->t_newpos.x, tp->t_using, tp);
+
+        when A_SUMMON:
+            /* We're summoning help */
+            m_summon(tp);
+
+        when A_USERELIC:
+            /* Use our relic */
+            m_use_relic(tp);
+
+        when A_USEWAND:
+            /* use the wand we have */
+            m_use_wand(tp);
+    }
+
+    /* Can we in fact move?  (we might have solidified in solid rock) */
+    if (!step_ok(hero.y, hero.x, NOMONST, &player)) {
+
+         if (move_free > 1) goto jump_over;   /* avoid messages */
+         if (mf_count > 2)  goto jump_over;   /* limit messages */
+
+         if (pstats.s_hpt < 1) {
+         pstats.s_hpt = -1;
+             msg("You have merged into the surroundings!  --More--");
+             wait_for(' ');
+             death(D_PETRIFY);
+         }
+         else {
+             mf_count += 1;  /* count number of times we are here */
+             pstats.s_hpt -= rnd(2)+1;
+             if (pstats.s_hpt < 1) {
+          pstats.s_hpt = -1;
+                  msg("You have merged into the surroundings!  --More--");
+                  wait_for(' ');
+                  death(D_PETRIFY);
+             }
+         }
+         switch (rnd(51)) {
+             case 0: msg("Arrrggghhhhh!! ");
+             when 5: msg("You can't move! "); 
+             when 10: msg("You motion angrily! "); 
+             when 15: msg("You feel so weird! ");
+             when 20: msg("If only you could phase. ");
+             when 25: msg("The rock maggots are closing in! ");
+             when 30: msg("You wrench and wrench and wrench... ");
+             when 35: msg("You wish you could teleport out of here! ");
+             when 40: msg("Your feel your life force ebbing away... ");
+             when 45: msg("You partially regain your senses. ");
+             when 50: msg("The rock maggots have found you!!! "); 
+             otherwise: pstats.s_hpt -= rnd(4)+1;
+         }
+         if (pstats.s_hpt < 1) {
+          pstats.s_hpt = -1;
+              msg("You lose the urge to live...  --More--");
+              wait_for(' ');
+              death(D_PETRIFY);
+     }
+        jump_over:
+        mf_jmpcnt++;          /* count this jump */
+        if (mf_jmpcnt > 9) {  /* take a few turns, then reset it */
+            mf_jmpcnt = 0;
+            mf_count  = 0;
+        }
+    }
+
+    /* No action now */
+    tp->t_action = A_NIL;
+    tp->t_using = NULL;
+}
+
+/*
+ * m_breathe:
+ *      Breathe in the chosen direction.
+ */
+
+m_breathe(tp)
+register struct thing *tp;
+{
+    register int damage;
+    register char *breath = NULL;
+
+    damage = tp->t_stats.s_hpt;
+    turn_off(*tp, CANSURPRISE);
+
+    /* Will it breathe at random */
+    if (on(*tp, CANBRANDOM)) {
+        /* Turn off random breath */
+        turn_off(*tp, CANBRANDOM);
+
+        /* Select type of breath */
+        switch (rnd(10)) {
+            case 0: breath = "acid";
+                    turn_on(*tp, NOACID);
+            when 1: breath = "flame";
+                    turn_on(*tp, NOFIRE);
+            when 2: breath = "lightning bolt";
+                    turn_on(*tp, NOBOLT);
+            when 3: breath = "chlorine gas";
+                    turn_on(*tp, NOGAS);
+            when 4: breath = "ice";
+                    turn_on(*tp, NOCOLD);
+            when 5: breath = "nerve gas";
+                    turn_on(*tp, NOPARALYZE);
+            when 6: breath = "sleeping gas";
+                    turn_on(*tp, NOSLEEP);
+            when 7: breath = "slow gas";
+                    turn_on(*tp, NOSLOW);
+            when 8: breath = "confusion gas";
+                    turn_on(*tp, ISCLEAR);
+            when 9: breath = "fear gas";
+                    turn_on(*tp, NOFEAR);
+        }
+    }
+
+    /* Or can it breathe acid? */
+    else if (on(*tp, CANBACID)) {
+        turn_off(*tp, CANBACID);
+        breath = "acid";
+    }
+
+    /* Or can it breathe fire */
+    else if (on(*tp, CANBFIRE)) {
+        turn_off(*tp, CANBFIRE);
+        breath = "flame";
+    }
+
+    /* Or can it breathe electricity? */
+    else if (on(*tp, CANBBOLT)) {
+        turn_off(*tp, CANBBOLT);
+        breath = "lightning bolt";
+    }
+
+    /* Or can it breathe gas? */
+    else if (on(*tp, CANBGAS)) {
+        turn_off(*tp, CANBGAS);
+        breath = "chlorine gas";
+    }
+
+    /* Or can it breathe ice? */
+    else if (on(*tp, CANBICE)) {
+        turn_off(*tp, CANBICE);
+        breath = "ice";
+    }
+
+    else if (on(*tp, CANBPGAS)) {
+        turn_off(*tp, CANBPGAS);
+        breath = "nerve gas";
+    }
+
+    /* can it breathe sleeping gas */
+    else if (on(*tp, CANBSGAS)) {
+        turn_off(*tp, CANBSGAS);
+        breath = "sleeping gas";
+    }
+
+    /* can it breathe slow gas */
+    else if (on(*tp, CANBSLGAS)) {
+        turn_off(*tp, CANBSLGAS);
+        breath = "slow gas";
+    }
+
+    /* can it breathe confusion gas */
+    else if (on(*tp, CANBCGAS)) {
+        turn_off(*tp, CANBCGAS);
+        breath = "confusion gas";
+    }
+
+    /* can it breathe fear gas */
+    else {
+        turn_off(*tp, CANBFGAS);
+        breath = "fear gas";
+    }
+
+    /* Now breathe */
+    shoot_bolt(tp, tp->t_pos, tp->t_newpos, FALSE, 
+                    tp->t_index, breath, damage);
+
+    running = FALSE;
+    if (fight_flush) flushinp();
+}
+
+/*
+ * m_select:
+ *      Select an action for the monster.
+ */
+
+m_select(th, flee)
+register struct thing *th;
+register bool flee; /* True if running away or player is inaccessible in wall */
+{
+    register struct room *rer, *ree;    /* room of chaser, room of chasee */
+    int dist = INT_MIN;
+    int mindist = INT_MAX, maxdist = INT_MIN;
+    bool rundoor;                       /* TRUE means run to a door */
+    char sch;
+    coord *last_door=0,                 /* Door we just came from */
+           this;                        /* Temporary destination for chaser */
+
+    rer = roomin(&th->t_pos);   /* Find room of chaser */
+    ree = roomin(th->t_dest);   /* Find room of chasee */
+
+    /* First see if we want to use an ability or weapon */
+    if (m_use_it(th, flee, rer, ree)) return;
+
+    /*
+     * We don't count monsters on doors as inside rooms here because when
+     * a monster is in a room and the player is not in that room, the
+     * monster looks for the best door out.  If we counted doors as part
+     * of the room, the monster would already be on the best door out;
+     * so he would never move.
+     */
+    if ((sch = mvwinch(stdscr, th->t_pos.y, th->t_pos.x)) == DOOR ||
+        sch == SECRETDOOR || sch == PASSAGE) {
+        rer = NULL;
+    }
+    this = *th->t_dest;
+
+    /*
+     * If we are in a room heading for the player and the player is not
+     * in the room with us, we run to the "best" door.
+     * If we are in a room fleeing from the player, then we run to the
+     * "best" door if he IS in the same room.
+     *
+     * Note:  We don't bother with doors in mazes or if we can walk
+     * through walls.
+     */
+    if (rer != NULL && levtype != MAZELEV && off(*th, CANINWALL)) {
+        if (flee) rundoor = (rer == ree);
+        else rundoor = (rer != ree);
+    }
+    else rundoor = FALSE;
+
+    if (rundoor) {
+        register struct linked_list *exitptr;   /* For looping through exits */
+        coord *exit,                            /* A particular door */
+              *entrance;                        /* Place just inside doorway */
+        int exity, exitx;                       /* Door's coordinates */
+        char dch='\0';                          /* Door character */
+
+        if ((th->t_doorgoal.x != -1) && (th->t_doorgoal.y != -1))
+            dch = mvwinch(stdscr, th->t_doorgoal.y, th->t_doorgoal.x);
+            
+        /* Do we have a valid goal? */
+        if ((dch == PASSAGE || dch == DOOR) &&  /* A real door */
+            (!flee || !ce(th->t_doorgoal, *th->t_dest))) { /* Prey should not
+                                                             * be at door if
+                                                             * we are running
+                                                             * away
+                                                             */
+            /* Make sure the player is not in the doorway, either */
+            entrance = doorway(rer, &th->t_doorgoal);
+            if (!flee || entrance == NULL || !ce(*entrance, *th->t_dest)) {
+                this = th->t_doorgoal;
+                dist = 0;       /* Indicate that we have our door */
+            }
+        }
+
+        /* Go through all the doors */
+        else for (exitptr = rer->r_exit; exitptr; exitptr = next(exitptr)) {
+            exit = DOORPTR(exitptr);
+            exity = exit->y;
+            exitx = exit->x;
+
+            /* Make sure it is a real door */
+            dch = mvwinch(stdscr, exity, exitx);
+            if (dch == PASSAGE || dch == DOOR) {
+                /* Don't count a door if we are fleeing from someone and
+                 * he is standing on it.  Also, don't count it if he is
+                 * standing in the doorway.
+                 */
+                if (flee) {
+                    if (ce(*exit, *th->t_dest)) continue;
+
+                    entrance = doorway(rer, exit);
+                    if (entrance != NULL && ce(*entrance, *th->t_dest))
+                        continue;
+                }
+                
+                /* Were we just on this door? */
+                if (ce(*exit, th->t_oldpos)) last_door = exit;
+
+                else {
+                    dist = DISTANCE(th->t_dest->y, th->t_dest->x, exity, exitx);
+
+                    /* If fleeing, we want to maximize distance from door to
+                     * what we flee, and minimize distance from door to us.
+                     */
+                    if (flee)
+                       dist -= DISTANCE(th->t_pos.y, th->t_pos.x, exity, exitx);
+
+                    /* Maximize distance if fleeing, otherwise minimize it */
+                    if ((flee && (dist > maxdist)) ||
+                        (!flee && (dist < mindist))) {
+                        th->t_doorgoal = *exit;  /* Use this door */
+                        this = *exit;
+                        mindist = maxdist = dist;
+                    }
+                }
+            }
+        }
+
+        /* Could we not find a door? */
+        if (dist == INT_MIN) {
+            /* If we were on a door, go ahead and use it */
+            if (last_door) {
+                th->t_doorgoal = *last_door;
+                this = th->t_oldpos;
+                dist = 0;       /* Indicate that we found a door */
+            }
+            else th->t_doorgoal.x = th->t_doorgoal.y = -1; /* No more door goal */
+        }
+
+        /* Indicate that we do not want to flee from the door */
+        if (dist != INT_MIN) flee = FALSE;
+    }
+    else th->t_doorgoal.x = th->t_doorgoal.y = -1;    /* Not going to any door */
+
+    /* Now select someplace to go and start the action */
+    chase(th, &this, rer, ree, flee);
+}
+
+/*
+ * m_sonic:
+ *      The monster is sounding a sonic blast.
+ */
+
+m_sonic(tp)
+register struct thing *tp;
+{
+    register int damage;
+    struct object blast =
+    {
+        MISSILE, {0, 0}, 0, "", "150" , NULL, 0, 0, 0, 0
+    };
+
+    turn_off(*tp, CANSONIC);
+    turn_off(*tp, CANSURPRISE);
+    do_motion(&blast, tp->t_newpos.y, tp->t_newpos.x, tp);
+    damage = rnd(61)+40;
+    if (save(VS_BREATH, &player, -3))
+        damage /= 2;
+    msg ("%s's ultra-sonic blast hits you", prname(monster_name(tp), TRUE));
+    if ((pstats.s_hpt -= damage) <= 0) {
+    pstats.s_hpt = -1;
+        death(tp->t_index);
+    }
+    running = FALSE;
+    if (fight_flush) flushinp();
+    dsrpt_player();
+}
+
+/*
+ * m_spell:
+ *      The monster casts a spell.  Currently this is limited to
+ *      magic missile.
+ */
+m_spell(tp)
+register struct thing *tp;
+{
+    struct object missile =
+    {
+        MISSILE, {0, 0}, 0, "", "0d4 " , NULL, 0, WS_MISSILE, 100, 1
+    };
+
+    sprintf(missile.o_hurldmg, "%dd4", tp->t_stats.s_lvl);
+    do_motion(&missile, tp->t_newpos.y, tp->t_newpos.x, tp);
+    hit_monster(unc(missile.o_pos), &missile, tp);
+    turn_off(*tp, CANMISSILE);
+    turn_off(*tp, CANSURPRISE);
+
+    running = FALSE;
+    if (fight_flush) flushinp();
+}
+
+/*
+ * m_summon:
+ *      Summon aid.
+ */
+
+m_summon(tp)
+register struct thing *tp;
+{
+    register char *helpname, *mname;
+    int fail, numsum;
+    register int which, i;
+
+    /* Let's make sure our prey is still here */
+    if (!cansee(unc(tp->t_pos)) || fallpos(&hero, FALSE, 2) == NULL) return;
+
+    /*
+     * Non-uniques can only summon once.  Uniques get fewer
+     * creatures with each successive summoning. Also, the
+     * probability of summoning goes down
+     */
+    if (off(*tp, ISUNIQUE))
+            turn_off(*tp, CANSUMMON);
+
+    turn_off(*tp, CANSURPRISE);
+    mname = monster_name(tp);
+    helpname = monsters[tp->t_index].m_typesum;
+    which = findmindex(helpname);
+
+    if ((off(*tp, ISINVIS)     || on(player, CANSEE)) &&
+        (off(*tp, ISSHADOW)    || on(player, CANSEE)) &&
+        (off(*tp, CANSURPRISE) || ISWEARING(R_ALERT))) {
+        if (monsters[which].m_normal == FALSE) { /* genocided? */
+            msg("%s appears dismayed", prname(mname, TRUE));
+            monsters[tp->t_index].m_numsum = 0;
+        }
+        else {
+            msg("%s summons %ss for help", prname(mname, TRUE), helpname);
+        }
+    }
+    else {
+        if (monsters[which].m_normal == FALSE) /* genocided? */
+            monsters[tp->t_index].m_numsum = 0;
+        else {
+            msg("%ss seem to appear from nowhere!", helpname);
+        }
+    }
+    numsum = monsters[tp->t_index].m_numsum;
+    if (numsum && on(*tp, ISUNIQUE)) {   /* UNIQUEs summon less each time */
+        monsters[tp->t_index].m_numsum--; 
+        tp->t_summon *= 2; /* cut probability in half */
+    }
+
+    /*
+     * try to make all the creatures around player but remember
+     * if unsuccessful
+     */
+    for (i=0, fail=0; i<numsum; i++) {
+         if (!creat_mons(&player, which, FALSE))
+             fail++;    /* remember the failures */
+    }
+
+    /*
+     * try once again to make the buggers
+     */
+    for (i=0; i<fail; i++)
+         creat_mons(tp, which, FALSE);
+    
+    /* Now let the poor fellow see all the trouble */
+    light(&hero);
+    turn_on(*tp, HASSUMMONED);
+}
+
+/*
+ * m_use_it:
+ *      See if the monster (tp) has anything useful it can do
+ *      (ie. an ability or a weapon) other than just move.
+ */
+
+bool
+m_use_it(tp, flee, rer, ree)
+register struct thing *tp;
+bool flee;
+register struct room *rer, *ree;
+{
+    int dist;
+    register coord *ee = tp->t_dest, *er = &tp->t_pos; 
+    coord *shoot_dir = NULL;
+    coord straight_dir;
+    int   straight_shot = FALSE;
+    struct thing *prey;
+    bool dest_player;   /* Are we after the player? */
+
+    /*
+     * If we are fleeing, there's a chance, depending on our
+     * intelligence, that we'll just run in terror.
+     */
+    if (flee && rnd(25) >= tp->t_stats.s_intel) return(FALSE);
+
+    /*
+     * Make sure that we have a living destination, and record whether
+     * it is the player.
+     */
+    if (ee != NULL) {
+        if (ce(*ee, hero)) {
+            dest_player = TRUE;
+            prey = &player;
+        }
+        else {
+            struct linked_list *item;
+
+            dest_player = FALSE;
+
+            /* What is the monster we're chasing? */
+            item = find_mons(ee->y, ee->x);
+            if (item != NULL) prey = THINGPTR(item);
+            else return(FALSE);
+        }
+    }
+    else return(FALSE);
+
+    /*
+     * If we are friendly to the hero, we don't do anything.
+     */
+    if (on(*tp, ISFRIENDLY) && dest_player) return(FALSE);
+
+    /*
+     * Also, for now, if our prey is in a wall, we won't do
+     * anything.  The prey must be in the same room as we are OR
+     * we must have a straight shot at him.  Note that
+     * shoot_dir must get set before rer is checked so
+     * that we get a valid value.
+     */
+ 
+    if (can_shoot(er, ee, &straight_dir) == 0)
+        shoot_dir = &straight_dir;
+    else
+        shoot_dir = NULL;
+
+    if (on(*prey, ISINWALL) ||
+        ( (shoot_dir == NULL) && (rer == NULL || rer != ree)))
+        return(FALSE);
+
+    /*
+     * If we can't see the prey then forget it
+     */
+    if (on(*prey, ISINVIS) && off(*tp, CANSEE))
+        return(FALSE);
+
+    /* How far are we from our prey? */
+    dist = DISTANCE(er->y, er->x, ee->y, ee->x);
+
+    /* 
+     * Shall we summon aid so we don't have to get our hands dirty? 
+     * For now, we will only summon aid against the player.
+     * We'll wait until he's within 2 dots of a missile length.
+     */
+    if (on(*tp, CANSUMMON) && dest_player                       &&
+        dist < (BOLT_LENGTH+2)*(BOLT_LENGTH+2)                  &&
+        rnd(tp->t_summon) < tp->t_stats.s_lvl                   &&
+        monsters[tp->t_index].m_numsum > 0                      &&
+        fallpos(&hero, FALSE, 2) != NULL) {
+        tp->t_action = A_SUMMON;        /* We're going to summon help */
+        tp->t_no_move = movement(tp); /* It takes time! */
+        return(TRUE);
+    }
+
+    /*
+     * If the creature can cast a slow spell and if the prey is within
+     * 2 dots of a missile fire, then see whether we will cast it.
+     * if next to player, lessen chance because we don't like being
+     * disrupted
+     */
+    if (on(*tp, CANSLOW) && dest_player                 && 
+        dist < (BOLT_LENGTH+5)*(BOLT_LENGTH+5)          &&
+        rnd(100) < (dist > 3 ? tp->t_cast : tp->t_cast/2)) {
+            tp->t_action = A_SLOW;              /* We're going to slow him */
+            tp->t_no_move = 3 * movement(tp);   /* Takes time! */
+            debug("casting slow spell!");
+            return(TRUE);
+    }
+
+    /*
+     * If we have a special magic item, we might use it.  We will restrict
+     * this options to uniques with relics and creatures with wands for now.  
+     * Also check for the quartermaster. Don't want him shooting wands....
+     */
+    if ((on(*tp, ISUNIQUE) || on(*tp, CARRYSTICK)) && 
+        off(*tp, CANSELL) && dest_player           &&
+        m_use_pack(tp, ee, dist, shoot_dir)) {
+            return(TRUE);
+    }
+
+    /* From now on, we must have a direct shot at the prey */
+    if (!straight_shot) return(FALSE);
+
+    /* We may use a sonic blast if we can, only on the player */
+    if (on(*tp, CANSONIC)               && 
+        dest_player                     &&
+        (dist < BOLT_LENGTH*2)          &&
+        (rnd(100) < tp->t_breathe)) {
+        tp->t_newpos = *shoot_dir;      /* Save the direction */
+        tp->t_action = A_SONIC; /* We're going to sonic blast */
+        tp->t_no_move = 2 * movement(tp); /* Takes 2 movement periods */
+    }
+
+    /* If we can breathe, we may do so */
+    else if (on(*tp, CANBREATHE)                &&
+         (dist < BOLT_LENGTH*BOLT_LENGTH)       &&
+         (rnd(100) < tp->t_breathe)) {
+            tp->t_newpos = *shoot_dir;  /* Save the direction */
+            tp->t_action = A_BREATHE;   /* We're going to breathe */
+            tp->t_no_move = movement(tp); /* It takes 1 movement period */
+    }
+
+    /* 
+     * We may shoot missiles if we can 
+     * if next to player, lessen chance so we don't get disrupted as often
+     */
+    else if (on(*tp,CANMISSILE) && 
+             rnd(100) < (dist > 3 ? tp->t_cast : tp->t_cast/2)){
+            tp->t_newpos = *shoot_dir;  /* Save the direction */
+            tp->t_action = A_MISSILE;   /* We're going to shoot MM's */
+            tp->t_no_move = 3 * movement(tp); /* Takes time! */
+    }
+
+    /* 
+     * If we can shoot or throw something, we might do so.
+     * If next to player, then forget it
+     */
+    else if ((on(*tp,CANSHOOT)          || on(*tp,CARRYWEAPON) || 
+              on(*tp,CARRYDAGGER)       || on(*tp, CARRYAXE))           &&
+              dist > 3                                                  &&
+              off(*tp, CANSELL)                                         &&
+             (get_hurl(tp) != NULL)) {
+            tp->t_newpos = *shoot_dir;  /* Save the direction */
+            tp->t_action = A_THROW;     /* We're going to throw something */
+            tp->t_using = get_hurl(tp);       /* Save our weapon */
+            tp->t_no_move = 2 * movement(tp); /* Takes 2 movement periods */
+    }
+    
+    /* We couldn't find anything to do */
+    else return(FALSE);
+
+    return(TRUE);
+
+}
+
+reap()
+{
+    _t_free_list(&rlist);
+}
+
+/*
+ * runners:
+ *      Make all the awake monsters try to do something.
+ */
+
+runners(segments)
+int segments;    /* Number of segments since last called */
+{
+    register struct linked_list *item;
+    register struct thing *tp = NULL;
+    register int min_time = 20;     /* Minimum time until a monster can act */
+
+    /*
+     * loop thru the list of running (wandering) monsters and see what
+     * each one will do this time. 
+     *
+     * Note: the special case that one of this buggers kills another.
+     *       if this happens than we have to see if the monster killed
+     *       himself or someone else. In case its himself we have to get next
+     *       one immediately. If it wasn't we have to get next one at very
+     *       end in case he killed the next one.
+     */
+    for (item = mlist; item != NULL; item = item->l_next)
+    {
+        tp = THINGPTR(item);
+        turn_on(*tp, NEEDSTOACT);
+    }
+
+    for(;;)
+    {
+        for (item = mlist; item != NULL; item = item->l_next)
+        {
+            tp = THINGPTR(item);
+
+            if (on(*tp, NEEDSTOACT))
+                break;
+        }
+
+        if (item == NULL)
+            break;
+
+        turn_off(*tp, NEEDSTOACT);
+
+        /* If we are not awake, just skip us */
+
+        if (off(*tp, ISRUN) && off(*tp, ISHELD))
+            continue;
+
+        /* See if it's our turn */
+
+        tp->t_no_move -= segments;
+
+        if (tp->t_no_move > 0)
+        {
+            if (tp->t_no_move < min_time) min_time = tp->t_no_move;
+                continue;
+        }
+
+        /* If we were frozen, we're moving now */
+
+        if (tp->t_action == A_FREEZE)
+            tp->t_action = A_NIL;
+
+        if (on(*tp, ISHELD))
+        {
+            /* Make sure the action and using are nil */
+
+            tp->t_action = A_NIL;
+            tp->t_using = NULL;
+
+            /* Can we break free? */
+
+            if (rnd(tp->t_stats.s_lvl) > 11)
+            {
+                turn_off(*tp, ISHELD);
+
+                runto(tp, &hero);
+
+                if (cansee(tp->t_pos.y, tp->t_pos.x))
+                    msg("%s breaks free from the hold spell", 
+                        prname(monster_name(tp), TRUE));
+            }
+            else /* Too bad -- try again later */
+                tp->t_no_move = movement(tp);
+        }
+
+        /* Heal the creature if it's not in the middle of some action */
+
+        if (tp->t_action == A_NIL)
+           doctor(tp);
+
+        while (off(*tp, ISELSEWHERE) &&
+               off(*tp, ISDEAD) &&
+               tp->t_no_move <= 0 &&
+               off(*tp, ISHELD) &&
+               on(*tp, ISRUN)       )
+        {
+            /* Let's act (or choose an action if t_action = A_NIL) */
+
+            m_act(tp);
+        }
+
+        if ( off(*tp,ISELSEWHERE) && off(*tp,ISDEAD) )
+        {
+            if (tp->t_no_move < min_time)
+               min_time = tp->t_no_move;
+
+            if (tp->t_quiet < 0)
+               tp->t_quiet = 0;
+        }
+    }
+
+    return(min_time);
+}
+
+/*
+ * See if a monster has some magic it can use.  Return TRUE if so.
+ * Only care about relics and wands for now.
+ */
+bool
+m_use_pack(monster, defend_pos, dist, shoot_dir)
+register struct thing *monster;
+coord *defend_pos;
+register int dist;
+register coord *shoot_dir;
+{
+    register struct object *obj;
+    register struct linked_list *pitem, *relic, *stick;
+    register int units = -1;
+
+    relic = stick = NULL;
+
+    for (pitem=monster->t_pack; pitem; pitem=next(pitem)) {
+        obj = OBJPTR(pitem);
+        if (obj->o_flags & ISCURSED) continue;
+        if (obj->o_type == RELIC) {
+            switch (obj->o_which) {
+                case MING_STAFF:
+                    if (shoot_dir != NULL) {
+                        units = 2;      /* Use 2 time units */
+                        relic = pitem;
+                    }
+
+                when EMORI_CLOAK:
+                    if (obj->o_charges != 0     && 
+                        shoot_dir != NULL) {
+                            units = 2;  /* Use 2 time units */
+                            relic = pitem;
+                    }
+
+                when ASMO_ROD:
+                    /* The bolt must be able to reach the defendant */
+                    if (shoot_dir != NULL                       && 
+                        dist < BOLT_LENGTH * BOLT_LENGTH) {
+                        units = 2;      /* Use 2 time units */
+                        relic = pitem;
+                    }
+
+                when BRIAN_MANDOLIN:
+                    /* The defendant must be the player and within 4 spaces */
+                    if (ce(*defend_pos, hero)           && 
+                        dist < 25                       &&
+                        player.t_action != A_FREEZE) {
+                        units = 4;
+                        relic = pitem;
+                    }
+
+                when GERYON_HORN:
+                    /* The defendant must be the player and within 5 spaces */
+                    if (ce(*defend_pos, hero)                                &&
+                        dist < 25                                            &&
+                        (off(player,ISFLEE)|| player.t_dest!=&monster->t_pos)) {
+                        units = 3;
+                        relic = pitem;
+                    }
+            }
+        }
+        if (obj->o_type == STICK) {
+            if (obj->o_charges < 1) continue;
+            switch(obj->o_which) {
+                case WS_ELECT:
+                case WS_FIRE:
+                case WS_COLD:
+                    /* The bolt must be able to reach the defendant */
+                    if (shoot_dir != NULL                       && 
+                        dist < BOLT_LENGTH * BOLT_LENGTH) {
+                            units = 3;
+                            stick = pitem;
+                    }
+
+                when WS_MISSILE:
+                case WS_SLOW_M:
+                case WS_CONFMON:
+                case WS_PARALYZE:
+                case WS_MDEG:
+                case WS_FEAR:
+                    if (shoot_dir != NULL) {
+                        units = 3;
+                        stick = pitem;
+                    }
+                
+                otherwise:
+                    break;
+            }
+        }
+    }
+
+    /* use relics in preference to all others */
+    if (relic) debug("chance to use relic = %d%%", monster->t_artifact);
+    if (stick) debug("chance to use stick = %d%%", monster->t_wand);
+    if (relic && rnd(100) < monster->t_artifact)  {
+        monster->t_action = A_USERELIC;
+        pitem = relic;
+    }
+    else if (stick && rnd(100) < monster->t_wand) {
+        /*
+         * see if the monster will use the wand 
+         */
+        pitem = stick;
+        monster->t_action = A_USEWAND;
+    }
+    else {
+        return(FALSE);
+    }
+
+    monster->t_no_move = units * movement(monster);
+    monster->t_using = pitem;
+    monster->t_newpos = *shoot_dir;
+    return(TRUE);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/bolt.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,401 @@
+/*
+    bolt.c  -  functions shooting an object across the room
+        
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <curses.h>
+#include <ctype.h>
+#include "rogue.h"
+
+/*
+ * shoot_bolt fires a bolt from the given starting point in the
+ *            given direction
+ */
+
+shoot_bolt(shooter, start, dir, get_points, reason, name, damage)
+struct thing *shooter;
+coord start, dir;
+bool get_points;
+short reason;
+char *name;
+int damage;
+{
+    unsigned char dirch = 0, ch;
+    bool used, change, see_him;
+    short y, x, bounces;
+    coord pos;
+    struct linked_list *target=NULL;
+    struct {
+        coord place;
+        char oldch;
+    } spotpos[BOLT_LENGTH];
+
+    switch (dir.y + dir.x) {
+        case 0: dirch = '/';
+        when 1: case -1: dirch = (dir.y == 0 ? '-' : '|');
+        when 2: case -2: dirch = '\\';
+    }
+    pos.y = start.y + dir.y;
+    pos.x = start.x + dir.x;
+    used = FALSE;
+    change = FALSE;
+
+    bounces = 0;        /* No bounces yet */
+    nofont(cw);
+    for (y = 0; y < BOLT_LENGTH && !used; y++) {
+        ch = winat(pos.y, pos.x);
+        spotpos[y].place = pos;
+        spotpos[y].oldch = mvwinch(cw, pos.y, pos.x);
+
+        /* Are we at hero? */
+        if (ce(pos, hero)) goto at_hero;
+
+        switch (ch) {
+            case SECRETDOOR:
+            case VERTWALL:
+            case HORZWALL:
+            case ' ':
+                if (dirch == '-' || dirch == '|') {
+                    dir.y = -dir.y;
+                    dir.x = -dir.x;
+                }
+                else {
+                    unsigned char chx = mvinch(pos.y-dir.y, pos.x),
+                         chy = mvinch(pos.y, pos.x-dir.x);
+                    bool anychange = FALSE; /* Did we change anthing */
+
+                    if (chy == WALL || chy == SECRETDOOR ||
+                        chy == HORZWALL || chy == VERTWALL) {
+                        dir.y = -dir.y;
+                        change ^= TRUE; /* Change at least one direction */
+                        anychange = TRUE;
+                    }
+                    if (chx == WALL || chx == SECRETDOOR ||
+                        chx == HORZWALL || chx == VERTWALL) {
+                        dir.x = -dir.x;
+                        change ^= TRUE; /* Change at least one direction */
+                        anychange = TRUE;
+                    }
+
+                    /* If we didn't make any change, make both changes */
+                    if (!anychange) {
+                        dir.x = -dir.x;
+                        dir.y = -dir.y;
+                    }
+                }
+
+                /* Do we change how the bolt looks? */
+                if (change) {
+                    change = FALSE;
+                    if (dirch == '\\') dirch = '/';
+                    else if (dirch == '/') dirch = '\\';
+                }
+
+                y--;    /* The bounce doesn't count as using up the bolt */
+
+                /* Make sure we aren't in an infinite bounce */
+                if (++bounces > BOLT_LENGTH) used = TRUE;
+                msg("The %s bounces", name);
+                break;
+            default:
+                if (isalpha(ch)) {
+                    register struct linked_list *item;
+                    struct thing *tp;
+                    register char *mname;
+                    bool see_monster = cansee(pos.y, pos.x);
+
+                    item = find_mons(unc(pos));
+                    assert(item != NULL);
+                    tp = THINGPTR(item);
+                    mname = monster_name(tp);
+
+                    /*
+                     * If our prey shot this, let's record the fact that
+                     * he can shoot, regardless of whether he hits us.
+                     */
+                    if (tp->t_dest != NULL && ce(*tp->t_dest, shooter->t_pos)) 
+                        tp->t_wasshot = TRUE;
+
+                    if (!save(VS_BREATH, tp, -(shooter->t_stats.s_lvl/10))) {
+                        if (see_monster) {
+                            if (on(*tp, ISDISGUISE) &&
+                                (tp->t_type != tp->t_disguise)) {
+                                msg("Wait! That's a %s!", mname);
+                                turn_off(*tp, ISDISGUISE);
+                            }
+
+                            turn_off(*tp, CANSURPRISE);
+                            msg("The %s hits %s", name, prname(mname, FALSE));
+                        }
+
+                        /* Should we start to chase the shooter? */
+                        if (shooter != &player                  &&
+                            shooter != tp                       &&
+                            shooter->t_index != tp->t_index     &&
+                            (tp->t_dest == NULL || rnd(100) < 25)) {
+                            /*
+                             * If we're intelligent enough to realize that this
+                             * is a friendly monster, we will attack the hero
+                             * instead.
+                             */
+                            if (on(*shooter, ISFRIENDLY) &&
+                                 roll(3,6) < tp->t_stats.s_intel)
+                                 runto(tp, &hero);
+
+                            /* Otherwise, let's chase the monster */
+                            else runto(tp, &shooter->t_pos);
+                        }
+                        else if (shooter == &player) {
+                            runto(tp, &hero);
+
+                            /*
+                             * If the player shot a charmed monster, it may
+                             * not like being shot at.
+                             */
+                            if (on(*tp, ISCHARMED) && save(VS_MAGIC, tp, 0)) {
+                                msg("The eyes of %s turn clear.", 
+                                    prname(mname, FALSE));
+                                turn_off(*tp, ISCHARMED);
+                                mname = monster_name(tp);
+                            }
+                        }
+
+                        /*
+                         * Let the defender know that the attacker has
+                         * missiles!
+                         */
+                        if (ce(*tp->t_dest, shooter->t_pos))
+                            tp->t_wasshot = TRUE;
+
+                        used = TRUE;
+
+                        /* Hit the monster -- does it do anything? */
+                        if ((EQUAL(name,"ice")           && on(*tp, NOCOLD))  ||
+                            (EQUAL(name,"flame")         && on(*tp, NOFIRE))  ||
+                            (EQUAL(name,"acid")          && on(*tp, NOACID))  ||
+                            (EQUAL(name,"lightning bolt")&& on(*tp,NOBOLT))   ||
+                            (EQUAL(name,"nerve gas")     &&on(*tp,NOPARALYZE))||
+                            (EQUAL(name,"sleeping gas")  &&
+                             (on(*tp, NOSLEEP) || on(*tp, ISUNDEAD)))         ||
+                            (EQUAL(name,"slow gas")      && on(*tp,NOSLOW))   ||
+                            (EQUAL(name,"fear gas")      && on(*tp,NOFEAR))   ||
+                            (EQUAL(name,"confusion gas") && on(*tp,ISCLEAR))  ||
+                            (EQUAL(name,"chlorine gas")  && on(*tp,NOGAS))) {
+                            if (see_monster)
+                                msg("The %s has no effect on %s.",
+                                        name, prname(mname, FALSE));
+                        }
+
+                        else {
+                            see_him = !invisible(tp);
+                           
+                            /* Did a spell get disrupted? */
+                            dsrpt_monster(tp, FALSE, see_him);
+
+                            /* 
+                             * Check for gas with special effects 
+                             */
+                            if (EQUAL(name, "nerve gas")) {
+                                tp->t_no_move = movement(tp) * FREEZETIME;
+                                tp->t_action = A_FREEZE;
+                            }
+                            else if (EQUAL(name, "sleeping gas")) {
+                                tp->t_no_move = movement(tp) * SLEEPTIME;
+                                tp->t_action = A_FREEZE;
+                            }
+                            else if (EQUAL(name, "slow gas")) {
+                                if (on(*tp, ISHASTE))
+                                    turn_off(*tp, ISHASTE);
+                                else
+                                    turn_on(*tp, ISSLOW);
+                            }
+                            else if (EQUAL(name, "fear gas")) {
+                                turn_on(*tp, ISFLEE);
+                                tp->t_dest = &hero;
+
+                                /* It is okay to turn tail */
+                                tp->t_oldpos = tp->t_pos;
+                            }
+                            else if (EQUAL(name, "confusion gas")) {
+                                turn_on(*tp, ISHUH);
+                                tp->t_dest = &hero;
+                            }
+                            else if ((EQUAL(name, "lightning bolt")) &&
+                                     on(*tp, BOLTDIVIDE)) {
+                                    if (creat_mons(tp, tp->t_index, FALSE)) {
+                                      if (see_monster)
+                                       msg("The %s divides %s.",
+                                           name,prname(mname, FALSE));
+                                      light(&hero);
+                                    }
+                                    else if (see_monster)
+                                        msg("The %s has no effect on %s.",
+                                            name, prname(mname, FALSE));
+                            }
+                            else {
+                                if (save(VS_BREATH, tp,
+                                         -(shooter->t_stats.s_lvl/10)))
+                                    damage /= 2;
+
+                                /* The poor fellow got killed! */
+                                if ((tp->t_stats.s_hpt -= damage) <= 0) {
+                                    if (see_monster)
+                                        msg("The %s kills %s", 
+                                            name, prname(mname, FALSE));
+                                    else
+                                     msg("You hear a faint groan in the distance");
+                                    /*
+                                     * Instead of calling killed() here, we
+                                     * will record that the monster was killed
+                                     * and call it at the end of the routine,
+                                     * after we restore what was under the bolt.
+                                     * We have to do this because in the case
+                                     * of a bolt that first misses the monster
+                                     * and then gets it on the bounce.  If we
+                                     * call killed here, the 'missed' space in
+                                     * spotpos puts the monster back on the
+                                     * screen
+                                     */
+                                    target = item;
+                                }
+                                else {  /* Not dead, so just scream */
+                                     if (!see_monster)
+                                       msg("You hear a scream in the distance");
+                                }
+                            }
+                        }
+                    }
+                    else if (isalpha(show(pos.y, pos.x))) {
+                        if (see_monster) {
+                            if (terse)
+                                msg("%s misses", name);
+                            else
+                                msg("The %s whizzes past %s",
+                                            name, prname(mname, FALSE));
+                        }
+                        if (get_points) runto(tp, &hero);
+                    }
+                }
+                else if (pos.y == hero.y && pos.x == hero.x) {
+at_hero:            if (!save(VS_BREATH, &player,
+                                -(shooter->t_stats.s_lvl/10))){
+                        if (terse)
+                            msg("The %s hits you", name);
+                        else
+                            msg("You are hit by the %s", name);
+                        used = TRUE;
+
+                        /* 
+                         * The Amulet of Yendor protects against all "breath" 
+                         *
+                         * The following two if statements could be combined 
+                         * into one, but it makes the compiler barf, so split 
+                         * it up
+                         */
+                        if (cur_relic[YENDOR_AMULET]                        ||
+                            (EQUAL(name,"chlorine gas")&&on(player, NOGAS)) ||
+                            (EQUAL(name,"acid")&&on(player, NOACID))        ||
+                            (EQUAL(name,"sleeping gas")&&ISWEARING(R_ALERT))){
+                             msg("The %s has no effect", name);
+                        }
+                        else if((EQUAL(name, "flame") && on(player, NOFIRE)) ||
+                                (EQUAL(name, "ice")   && on(player, NOCOLD)) ||
+                                (EQUAL(name,"lightning bolt")&& 
+                                                         on(player,NOBOLT))  ||
+                                (EQUAL(name,"fear gas")&&ISWEARING(R_HEROISM))){
+                             msg("The %s has no effect", name);
+                        }
+
+                        else {
+                            dsrpt_player();
+
+                            /* 
+                             * Check for gas with special effects 
+                             */
+                            if (EQUAL(name, "nerve gas")) {
+                                msg("The nerve gas paralyzes you.");
+                                player.t_no_move +=
+                                        movement(&player) * FREEZETIME;
+                                player.t_action = A_FREEZE;
+                            }
+                            else if (EQUAL(name, "sleeping gas")) {
+                                msg("The sleeping gas puts you to sleep.");
+                                player.t_no_move +=
+                                        movement(&player) * SLEEPTIME;
+                                player.t_action = A_FREEZE;
+                            }
+                            else if (EQUAL(name, "confusion gas")) {
+                                if (off(player, ISCLEAR)) {
+                                    if (on(player, ISHUH))
+                                        lengthen(unconfuse,
+                                                 rnd(20)+HUHDURATION);
+                                    else {
+                                        turn_on(player, ISHUH);
+                                        fuse(unconfuse, (VOID *)NULL,
+                                             rnd(20)+HUHDURATION, AFTER);
+                                        msg("The confusion gas has confused you.");
+                                    }
+                                }
+                                else msg("You feel dizzy for a moment, but it quickly passes.");
+                            }
+                            else if (EQUAL(name, "slow gas")) {
+                                add_slow();
+                            }
+                            else if (EQUAL(name, "fear gas")) {
+                                turn_on(player, ISFLEE);
+                                player.t_dest = &shooter->t_pos;
+                                msg("The fear gas terrifies you.");
+                            }
+                            else {
+                                if (EQUAL(name, "acid")                 &&
+                                    cur_armor != NULL                   &&
+                                    !(cur_armor->o_flags & ISPROT)      &&
+                                    !save(VS_BREATH, &player, -2)       &&
+                                    cur_armor->o_ac < pstats.s_arm+1) {
+                                       msg("Your armor corrodes from the acid");
+                                       cur_armor->o_ac++;
+                                }
+                                if (save(VS_BREATH, &player,
+                                         -(shooter->t_stats.s_lvl/10))  &&
+                                         off(player, NOACID))
+                                    damage /= 2;
+                                if ((pstats.s_hpt -= damage) <= 0) 
+                                    death(reason);
+                            }
+                        }
+                    }
+                    else
+                        msg("The %s whizzes by you", name);
+                }
+
+                mvwaddch(cw, pos.y, pos.x, dirch);
+                draw(cw);
+        }
+
+        pos.y += dir.y;
+        pos.x += dir.x;
+    }
+
+    /* Restore what was under the bolt */
+    newfont(cw);
+    for (x = y - 1; x >= 0; x--)
+        mvwaddch(cw, spotpos[x].place.y, spotpos[x].place.x, spotpos[x].oldch);
+
+    /* If we killed something, do so now.  This will also blank the monster. */
+    if (target) killed(target, FALSE, get_points, TRUE);
+    return;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/chase.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,936 @@
+/*
+    chase.c  -  Code for one object to chase another
+
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <ctype.h>
+#include <curses.h>
+#include <limits.h>
+#include "rogue.h"
+
+/*
+ * Canblink checks if the monster can teleport (blink).  If so, it will
+ * try to blink the monster next to the player.
+ */
+
+bool
+can_blink(tp)
+register struct thing *tp;
+{
+    register int y, x, index=9;
+    coord tryp; /* To hold the coordinates for use in diag_ok */
+    bool spots[9], found_one=FALSE;
+
+    /*
+     * First, can the monster even blink?  And if so, there is only a 50%
+     * chance that it will do so.  And it won't blink if it is running or
+     * held.
+     */
+    if (off(*tp, CANBLINK) || (on(*tp, ISHELD)) ||
+        on(*tp, ISFLEE) ||
+        tp->t_action == A_FREEZE ||
+        (rnd(12) < 6)) return(FALSE);
+
+
+    /* Initialize the spots as illegal */
+    do {
+        spots[--index] = FALSE;
+    } while (index > 0);
+
+    /* Find a suitable spot next to the player */
+    for (y=hero.y-1; y<hero.y+2; y++)
+        for (x=hero.x-1; x<hero.x+2; x++, index++) {
+            /* Make sure x coordinate is in range and that we are
+             * not at the player's position
+             */
+            if (x<0 || x >= cols || index == 4) continue;
+
+            /* Is it OK to move there? */
+            if (step_ok(y, x, NOMONST, tp) &&
+                (!isatrap(mvwinch(cw, y, x)) ||
+                  rnd(10) >= tp->t_stats.s_intel ||
+                  on(*tp, ISFLY))) {
+                /* OK, we can go here.  But don't go there if
+                 * monster can't get at player from there
+                 */
+                tryp.y = y;
+                tryp.x = x;
+                if (diag_ok(&tryp, &hero, tp)) {
+                    spots[index] = TRUE;
+                    found_one = TRUE;
+                }
+            }
+        }
+
+    /* If we found one, go to it */
+    if (found_one) {
+        unsigned char rch;       /* What's really where the creatures moves to */
+
+        /* Find a legal spot */
+        while (spots[index=rnd(9)] == FALSE) continue;
+
+        /* Get the coordinates */
+        y = hero.y + (index/3) - 1;
+        x = hero.x + (index % 3) - 1;
+
+        /* Move the monster from the old space */
+        mvwaddch(cw, tp->t_pos.y, tp->t_pos.x, tp->t_oldch);
+
+        /* Move it to the new space */
+        tp->t_oldch = mvwinch(cw, y, x);
+
+        /* Display the creature if our hero can see it */
+        if (cansee(y, x) &&
+            off(*tp, ISINWALL) &&
+            !invisible(tp))
+            mvwaddch(cw, y, x, tp->t_type);
+
+        /* Fix the monster window */
+        mvwaddch(mw, tp->t_pos.y, tp->t_pos.x, ' '); /* Clear old position */
+        mvwaddch(mw, y, x, tp->t_type);
+
+        /* Record the new position */
+        tp->t_pos.y = y;
+        tp->t_pos.x = x;
+
+        /* If the monster is on a trap, trap it */
+        rch = mvinch(y, x);
+        if (isatrap(rch)) {
+            if (cansee(y, x)) tp->t_oldch = rch;
+            be_trapped(tp, &(tp->t_pos));
+        }
+    }
+
+    return(found_one);
+}
+
+/* 
+ * Can_shoot determines if the monster (er) has a direct line of shot 
+ * at the prey (ee).  If so, it returns the direction in which to shoot.
+ */
+
+int
+can_shoot(er, ee, shoot_dir)
+register coord *er, *ee, *shoot_dir;
+{
+    /* 
+     * They must be in the same room or very close (at door)
+     */
+    if (roomin(er) != roomin(ee) && DISTANCE(er->y,er->x,ee->y,ee->x) > 1)
+    {
+        shoot_dir->x = shoot_dir->y = 0;
+        return(-1);
+    }
+
+    /* Do we have a straight shot? */
+    if (!straight_shot(er->y, er->x, ee->y, ee->x, shoot_dir)) 
+    {
+        shoot_dir->x = shoot_dir->y = 0;
+        return(-2);
+    }
+    else 
+        return(0);
+}
+
+/*
+ * chase:
+ *      Find the spot for the chaser(er) to move closer to the
+ *      chasee(ee).  Rer is the room of the chaser, and ree is the
+ *      room of the creature being chased (chasee).
+ */
+
+chase(tp, ee, rer, ree, flee)
+register struct thing *tp;
+register coord *ee;
+register struct room *rer, *ree;
+bool flee; /* True if destination (ee) is player and monster is running away
+            * or the player is in a wall and the monster can't get to it
+            */
+{
+    int dist, thisdist, monst_dist = INT_MAX; 
+    register coord *er = &tp->t_pos; 
+    struct thing *prey;                 /* What we are chasing */
+    coord ch_ret;                       /* Where chasing takes you */
+    unsigned char ch, mch;
+    bool next_player = FALSE;
+
+    /* 
+     * set the distance from the chas(er) to the chas(ee) here and then
+     * we won't have to reset it unless the chas(er) moves (instead of shoots)
+     */
+    dist = DISTANCE(er->y, er->x, ee->y, ee->x);
+
+    /*
+     * See if our destination is a monster or player.  If so, make "prey" point
+     * to it.
+     */
+    if (ce(hero, *ee)) prey = &player;  /* Is it the player? */
+    else if (tp->t_dest && ce(*(tp->t_dest), *ee)) {    /* Is it a monster? */
+        struct linked_list *item;
+
+        /* What is the monster we're chasing? */
+        item = find_mons(ee->y, ee->x);
+        if (item != NULL) prey = THINGPTR(item);
+        else prey = NULL;
+    }
+    else prey = NULL;
+
+    /* We will use at least one movement period */
+    tp->t_no_move = movement(tp);
+    if (on(*tp, ISFLY)) /* If the creature is flying, speed it up */
+        tp->t_no_move /= 2;
+
+    /*
+     * If the thing is confused or it can't see the player,
+     * let it move randomly. 
+     */
+    if ((on(*tp, ISHUH) && rnd(10) < 8) ||
+        (prey && on(*prey, ISINVIS) && off(*tp, CANSEE))) { /* invisible prey */
+        /*
+         * get a valid random move
+         */
+        tp->t_newpos = rndmove(tp);
+        dist = DISTANCE(tp->t_newpos.y, tp->t_newpos.x, ee->y, ee->x);
+    }
+
+    /*
+     * Otherwise, find the empty spot next to the chaser that is
+     * closest to the chasee.
+     */
+    else {
+        register int ey, ex, x, y;
+        int dist_to_old = INT_MIN; /* Dist from goal to old position */
+
+        /*
+         * This will eventually hold where we move to get closer
+         * If we can't find an empty spot, we stay where we are.
+         */
+        dist = flee ? 0 : INT_MAX;
+        ch_ret = *er;
+
+        /* Are we at our goal already? */
+        if (!flee && ce(ch_ret, *ee)) {
+            turn_off(*tp, ISRUN);       /* So stop running! */
+            return;
+        }
+
+        ey = er->y + 1;
+        ex = er->x + 1;
+
+        /* Check all possible moves */
+        for (x = er->x - 1; x <= ex; x++) {
+            if (x < 0 || x >= cols) /* Don't try off the board */
+                continue;
+            for (y = er->y - 1; y <= ey; y++) {
+                coord tryp;
+
+                if ((y < 1) || (y >= lines - 2)) /* Don't try off the board */
+                    continue;
+
+                /* Don't try the player if not going after the player */
+                if ((flee || !ce(hero, *ee) || on(*tp, ISFRIENDLY)) &&
+                    x == hero.x && y == hero.y) {
+                    next_player = TRUE;
+                    continue;
+                }
+
+                tryp.x = x;
+                tryp.y = y;
+
+                /* Is there a monster on this spot closer to our goal?
+                 * Don't look in our spot or where we were.
+                 */
+                if (!ce(tryp, *er) && !ce(tryp, tp->t_oldpos) &&
+                    isalpha(mch = mvwinch(mw, y, x))) {
+                    int test_dist;
+
+                    test_dist = DISTANCE(y, x, ee->y, ee->x);
+                    if (test_dist <= 25 &&   /* Let's be fairly close */
+                        test_dist < monst_dist) {
+                        /* Could we really move there? */
+                        mvwaddch(mw, y, x, ' '); /* Temporarily blank monst */
+                        if (diag_ok(er, &tryp, tp)) monst_dist = test_dist;
+                        mvwaddch(mw, y, x, mch); /* Restore monster */
+                    }
+                }
+
+                /* Can we move onto the spot? */        
+                if (!diag_ok(er, &tryp, tp)) continue;
+
+                ch = mvwinch(cw, y, x); /* Screen character */
+
+                /*
+                 * Stepping on player is NOT okay if we are fleeing.
+                 * If we are friendly to the player and there is a monster
+                 * in the way that is not of our race, it is okay to move
+                 * there.
+                 */
+                if (step_ok(y, x, FIGHTOK, tp) &&
+                    (off(*tp, ISFLEE) || ch != PLAYER))
+                {
+                    /*
+                     * If it is a trap, an intelligent monster may not
+                     * step on it (unless our hero is on top!)
+                     */
+                    if ((isatrap(ch))                   && 
+                        (rnd(10) < tp->t_stats.s_intel) &&
+                        (!on(*tp, ISFLY))               &&
+                        (y != hero.y || x != hero.x)) 
+                            continue;
+
+                    /*
+                     * OK -- this place counts
+                     */
+                    thisdist = DISTANCE(y, x, ee->y, ee->x);
+
+                    /* Adjust distance if we are being shot at */
+                    if (tp->t_wasshot && tp->t_stats.s_intel > 5 &&
+                        prey != NULL) {
+                        /* Move out of line of sight */
+                        if (straight_shot(tryp.y, tryp.x, ee->y, ee->x, (coord *)NULL)) {
+                            if (flee) thisdist -= SHOTPENALTY;
+                            else thisdist += SHOTPENALTY;
+                        }
+
+                        /* But do we want to leave the room? */
+                        else if (rer && rer == ree && ch == DOOR)
+                            thisdist += DOORPENALTY;
+                    }
+
+                    /* Don't move to the last position if we can help it
+                     * (unless out prey just moved there)
+                     */
+                    if (ce(tryp, tp->t_oldpos) && (flee || !ce(tryp, hero)))
+                        dist_to_old = thisdist;
+
+                    else if ((flee && (thisdist > dist)) ||
+                        (!flee && (thisdist < dist)))
+                    {
+                        ch_ret = tryp;
+                        dist = thisdist;
+                    }
+                }
+            }
+        }
+
+        /* If we aren't trying to get the player, but he is in our way,
+         * hit him (unless we have been turned or are friendly).  next_player
+         * being TRUE -> we are next to the player but don't want to hit him.
+         *
+         * If we are friendly to the player, following him, and standing next
+         * to him, we will try to help him out in battle.
+         */
+        if (next_player && off(*tp, WASTURNED)) {
+            if (off(*tp, ISFRIENDLY) &&
+                ((flee && ce(ch_ret, *er)) ||
+                 (!flee && DISTANCE(er->y, er->x, ee->y, ee->x) < dist)) &&
+                step_ok(tp->t_dest->y, tp->t_dest->x, NOMONST, tp)) {
+                /* Okay to hit player */
+                debug("Switching to hero.");
+                tp->t_newpos = hero;
+                tp->t_action = A_MOVE;
+                return;
+            }
+            else if (on(*tp, ISFRIENDLY) && !flee && ce(*ee, hero)) {
+                /*
+                 * Look all around the player.  If there is a fightable
+                 * creature next to both of us, hit it.  Otherwise, if
+                 * there is a fightable creature next to the player, try
+                 * to move next to it.
+                 */
+                dist = INT_MAX;
+                for (x = hero.x - 1; x <= hero.x + 1; x++) {
+                    if (x < 0 || x >= cols) /* Don't try off the board */
+                        continue;
+                    for (y = hero.y - 1; y <= hero.y + 1; y++) {
+                        if ((y < 1) || (y >= lines - 2)) /* Stay on the board */
+                            continue;
+
+                        /* Is there a fightable monster here? */
+                        if (isalpha(mvwinch(mw, y, x)) &&
+                            step_ok(y, x, FIGHTOK, tp) &&
+                            off(*tp, ISSTONE)) {
+                            thisdist = DISTANCE(er->y, er->x, y, x);
+                            if (thisdist < dist) {
+                                dist = thisdist;
+                                ch_ret.y = y;
+                                ch_ret.x = x;
+                            }
+                        }
+                    }
+                }
+
+                /* Are we next to a bad guy? */
+                if (dist <= 2) {        /* Get him! */
+                    tp->t_newpos = ch_ret;
+                    tp->t_action = A_MOVE;
+                }
+
+                /* Try to move to the bad guy */
+                else if (dist < INT_MAX)
+                    chase(tp, &ch_ret,
+                          roomin(&tp->t_pos), roomin(&ch_ret), FALSE);
+
+                else tp->t_action = A_NIL;
+
+                return;
+            }
+        }
+
+        /*
+         * If we have decided that we can move onto a monster (we are
+         * friendly to the player, go to it.
+         */
+        if (!ce(ch_ret, *er) && isalpha(mvwinch(mw, ch_ret.y, ch_ret.x))) {
+            debug("Attack monster");
+            tp->t_newpos = ch_ret;
+            tp->t_action = A_MOVE;
+            return;
+        }
+
+        /* If we can't get closer to the player (if that's our goal)
+         * because other monsters are in the way, just stay put
+         */
+        if (!flee && ce(hero, *ee) && monst_dist < INT_MAX &&
+            DISTANCE(er->y, er->x, hero.y, hero.x) < dist) {
+                tp->t_action = A_NIL; /* do nothing for awhile */
+                return;
+        }
+
+        /* Do we want to go back to the last position? */
+        else if (dist_to_old != INT_MIN &&      /* It is possible to move back */
+            ((flee && dist == 0) ||     /* No other possible moves */
+             (!flee && dist == INT_MAX))) {
+            /* Do we move back or just stay put (default)? */
+            dist = DISTANCE(er->y, er->x, ee->y, ee->x); /* Current distance */
+            if (!flee || (flee && (dist_to_old > dist))) ch_ret = tp->t_oldpos;
+        }
+
+        /* Record the new destination */
+        tp->t_newpos = ch_ret;
+    }
+
+    /*
+     * Do we want to fight or move?  If our selected destination (ch_ret)
+     * is our hero, then we want to fight.  Otherwise, we want to move.
+     */
+    if (ce(tp->t_newpos, hero)) {
+        /* Fight! (or sell) */
+        if (on(*tp, CANSELL)) {
+            tp->t_action = A_SELL;
+            tp->t_no_move += movement(tp); /* takes a little time to sell */
+        }
+        else {
+            tp->t_action = A_ATTACK;
+
+            /*
+             * Try to find a weapon to wield.  Wield_weap will return a
+             * projector if weapon is a projectile (eg. bow for arrow).
+             * If weapon is NULL (the case here), it will try to find
+             * a suitable weapon.
+             *
+             *          Add in rest of time. Fight is 
+             *          movement() + weap_move() + FIGHTBASE
+             */
+            tp->t_using = wield_weap((struct object *)NULL, tp);
+            if (tp->t_using == NULL)
+                tp->t_no_move += weap_move(tp, (struct object *)NULL);
+            else
+                tp->t_no_move += weap_move(tp, OBJPTR(tp->t_using));
+
+            if (on(*tp, ISHASTE))
+                    tp->t_no_move += FIGHTBASE/2;
+            else if (on(*tp, ISSLOW))
+                    tp->t_no_move += FIGHTBASE*2;
+            else
+                    tp->t_no_move += FIGHTBASE;
+        }
+    }
+    else {
+        /* Move */
+        tp->t_action = A_MOVE;
+
+        /*
+         * Check if the creature is not next to the player.  If it
+         * is not and has held or suffocated the player, then stop it!
+         * Note that this code should more appropriately appear in
+         * the area that actually moves the monster, but for now it
+         * is okay here because the player can't move while held or
+         * suffocating.
+         */
+        if (dist > 2) {
+            if (on(*tp, DIDHOLD)) {
+                 turn_off(*tp, DIDHOLD);
+                 turn_on(*tp, CANHOLD);
+                 if (--hold_count == 0) 
+                     turn_off(player, ISHELD);
+            }
+
+            /* If monster was suffocating, stop it */
+            if (on(*tp, DIDSUFFOCATE)) {
+                turn_off(*tp, DIDSUFFOCATE);
+                turn_on(*tp, CANSUFFOCATE);
+                extinguish(suffocate);
+                msg("You can breathe again.....Whew!");
+            }
+        }
+    }
+}
+
+/*
+ * do_chase:
+ *      Make one thing chase another.
+ */
+
+do_chase(th)
+register struct thing *th;
+{
+    register struct room *orig_rer,     /* Original room of chaser */
+                         *new_room;     /* new room of monster */
+    unsigned char floor, rch, sch;
+    coord old_pos,                      /* Old position of monster */
+          ch_ret;                       /* Where we want to go */
+
+    if (on(*th, NOMOVE)) return;
+
+    ch_ret = th->t_newpos;      /* Record our desired new position */
+
+    /*
+     * Make sure we have an open spot (no other monster's gotten in our way,
+     * someone didn't just drop a scare monster there, our prey didn't just
+     * get there, etc.)
+     */
+    if (!step_ok(th->t_newpos.y, th->t_newpos.x, FIGHTOK, th)) {
+        /*
+         * Most monsters get upset now.  Guardians are all friends,
+         * and we don't want to see 50 messages in a row!
+         */
+        if (th->t_stats.s_intel > 4 &&
+            off(*th, ISUNDEAD)      &&
+            off(*th, ISGUARDIAN)    &&
+            off(*th, AREMANY)       &&
+            off(*th, ISHUH)         &&
+            off(*th, ISCHARMED)     &&
+            off(player, ISBLIND)    &&
+            cansee(unc(th->t_pos))  &&
+        !invisible(th) && (rnd(15) < 5)) {
+            switch (rnd(10)) {
+              case 0: case 1:
+            msg("%s lashes out at you! ",prname(monster_name(th),TRUE));
+          when 2: case 3:
+            msg("%s scrambles around. ",prname(monster_name(th), TRUE));
+                  otherwise:
+            msg("%s motions angrily. ", prname(monster_name(th), TRUE));
+            }
+    }
+        return;
+    }
+    else if (ce(th->t_newpos, hero) ||  /* Player just got in our way */
+             isalpha(mvwinch(mw, th->t_newpos.y, th->t_newpos.x))) {
+        bool fightplayer = ce(th->t_newpos, hero);
+
+        /* If we were turned or are friendly, we just have to sit here! */
+        if (fightplayer && (on(*th, WASTURNED) || on(*th, ISFRIENDLY))) return;
+
+        /* Do we want to sell something? */
+        if (fightplayer && on(*th, CANSELL)) {
+            th->t_action = A_SELL;
+            th->t_no_move += movement(th); /* takes a little time to sell */
+            return;
+        }
+
+        /* Let's hit him */
+        th->t_action = A_ATTACK;
+
+        /*
+         * Try to find a weapon to wield.  Wield_weap will return a
+         * projector if weapon is a projectile (eg. bow for arrow).
+         * If weapon is NULL (the case here), it will try to find
+         * a suitable weapon.
+         */
+        th->t_using = wield_weap((struct object *)NULL, th);
+        /*
+         * add in rest of time
+         */
+        if (th->t_using == NULL)
+            th->t_no_move += weap_move(th, (struct object *)NULL);
+        else
+            th->t_no_move += weap_move(th, OBJPTR(th->t_using));
+        if (on(*th, ISHASTE))
+                th->t_no_move += FIGHTBASE/2;
+        else if (on(*th, ISSLOW))
+                th->t_no_move += FIGHTBASE*2;
+        else
+                th->t_no_move += FIGHTBASE;
+        return;
+    }
+
+    /*
+     * Blank out the old position and record the new position --
+     * the blanking must be done first in case the positions are the same.
+     */
+    mvwaddch(mw, th->t_pos.y, th->t_pos.x, ' ');
+    mvwaddch(mw, ch_ret.y, ch_ret.x, th->t_type);
+
+    /* Get new and old rooms of monster */
+    new_room = roomin(&ch_ret);
+    orig_rer = roomin(&th->t_pos);
+
+    /* Store the critter's old position and update the current one */
+    old_pos = th->t_pos;
+    th->t_pos = ch_ret;
+    floor = (roomin(&ch_ret) == NULL) ? PASSAGE : FLOOR;
+
+    /* If we have a scavenger, it can pick something up */
+    if (off(*th, ISGUARDIAN)) {
+        register struct linked_list *n_item, *o_item;
+        register int item_count = 0;
+        bool want_something = FALSE;
+
+        while ((n_item = find_obj(ch_ret.y, ch_ret.x)) != NULL) {
+            register struct object *n_obj, *o_obj;
+            bool wants_it;
+
+            /* Does this monster want anything? */
+            if (want_something == FALSE) {
+                if (on(*th, ISSCAVENGE)  || on(*th, CARRYFOOD)   ||
+                    on(*th, CARRYGOLD)   || on(*th, CARRYSCROLL) ||
+                    on(*th, CARRYPOTION) || on(*th, CARRYRING)   ||
+                    on(*th, CARRYSTICK)  || on(*th, CARRYMISC)   ||
+                    on(*th, CARRYWEAPON) || on(*th, CARRYARMOR)  ||
+                    on(*th, CARRYDAGGER))  {
+                        want_something = TRUE;
+
+                        /*
+                         * Blank the area.  We have to do it only before the
+                         * first item in case an item gets dropped in same
+                         * place.  We don't want to blank it out after it get
+                         * dropped.
+                         */
+                        mvaddch(ch_ret.y, ch_ret.x, floor);
+
+                        /* Were we specifically after something here? */
+                        if (ce(*th->t_dest, ch_ret)) {
+                            /* If we're mean, we go after the hero */
+                            if (on(*th, ISMEAN)) runto(th, &hero);
+
+                            /* Otherwise just go back to sleep */
+                            else {
+                                turn_off(*th, ISRUN);
+                                th->t_dest = NULL;
+                            }
+                        }
+                }
+                else break;
+            }
+
+            item_count++;       /* Count the number of items */
+
+            /*
+             * see if he's got one of this group already
+             */
+            o_item = NULL;
+            n_obj = OBJPTR(n_item);
+            detach(lvl_obj, n_item);
+
+            /* See if he wants it */
+            if (n_obj->o_type == SCROLL && n_obj->o_which == S_SCARE &&
+                th->t_stats.s_intel < 16)
+                wants_it = FALSE; /* Most monsters don't want a scare monster */
+            else if (on(*th, ISSCAVENGE)) wants_it = TRUE;
+            else {
+                wants_it = FALSE;       /* Default case */
+                switch (n_obj->o_type) {
+                    case FOOD:  if(on(*th, CARRYFOOD))   wants_it = TRUE;
+                    when GOLD:  if(on(*th, CARRYGOLD))   wants_it = TRUE;
+                    when SCROLL:if(on(*th, CARRYSCROLL)) wants_it = TRUE;
+                    when POTION:if(on(*th, CARRYPOTION)) wants_it = TRUE;
+                    when RING:  if(on(*th, CARRYRING))   wants_it = TRUE;
+                    when STICK: if(on(*th, CARRYSTICK))  wants_it = TRUE;
+                    when MM:    if(on(*th, CARRYMISC))   wants_it = TRUE;
+                    when ARMOR: if(on(*th, CARRYARMOR))  wants_it = TRUE;
+                    when WEAPON:if(on(*th, CARRYWEAPON) ||
+                                  (on(*th,CARRYDAGGER)&&n_obj->o_which==DAGGER))
+                                        wants_it = TRUE;
+                }
+            }
+            /*
+             * The quartermaster doesn't sell cursed stuff so he won't
+             * pick it up
+             */
+            if (on(*th, CANSELL) && (n_obj->o_flags & ISCURSED))
+                wants_it = FALSE;
+
+            /* If he doesn't want it, throw it away */
+            if (wants_it == FALSE) {
+                fall(n_item, FALSE);
+                continue;
+            }
+
+            /* Otherwise, let's pick it up */
+            if (n_obj->o_group) {
+                for(o_item = th->t_pack; o_item != NULL; o_item = next(o_item)){
+                    o_obj = OBJPTR(o_item);
+                    if (o_obj->o_group == n_obj->o_group) {
+                        o_obj->o_count += n_obj->o_count;
+                        o_discard(n_item);
+                        break;
+                    }
+                }
+            }
+            if (o_item == NULL) {       /* didn't find it */
+                attach(th->t_pack, n_item);
+            }
+        }
+
+        /* If there was anything here, we may have to update the screen */
+        if (item_count) {
+            if (cansee(ch_ret.y, ch_ret.x))
+                mvwaddch(cw, ch_ret.y, ch_ret.x, mvinch(ch_ret.y, ch_ret.x));
+            updpack(TRUE, th); /* Update the monster's encumberance, too */
+        }
+    }
+
+    rch = mvwinch(stdscr, old_pos.y, old_pos.x); 
+    if (th->t_oldch == floor && rch != floor && !isatrap(rch))
+        mvwaddch(cw, old_pos.y, old_pos.x, rch);
+    else
+        mvwaddch(cw, old_pos.y, old_pos.x, th->t_oldch);
+    sch = mvwinch(cw, ch_ret.y, ch_ret.x); /* What player sees */
+    rch = mvwinch(stdscr, ch_ret.y, ch_ret.x); /* What's really there */
+
+    /* If we have a tunneling monster, it may be making a tunnel */
+    if (on(*th, CANTUNNEL)      &&
+        (rch==SECRETDOOR || rch==WALL || rch==VERTWALL || rch==HORZWALL)) {
+        unsigned char nch;       /* The new look to the tunnel */
+
+        if (rch == WALL && levtype == OUTSIDE) nch = FLOOR;
+        else if (rch == WALL) nch = PASSAGE;
+        else if (levtype == MAZELEV || levtype == OUTSIDE) nch = FLOOR;
+        else nch = DOOR;
+        addch(nch);
+
+        if (cansee(ch_ret.y, ch_ret.x)) sch = nch; /* Can player see this? */
+
+        /* Does this make a new exit? */
+        if (rch == VERTWALL || rch == HORZWALL) {
+            struct linked_list *newroom;
+            coord *exit;
+
+            newroom = new_item(sizeof(coord));
+            exit = DOORPTR(newroom);
+            *exit = ch_ret;
+            attach(new_room->r_exit, newroom);
+        }
+    }
+
+    /* Mark if the monster is inside a wall */
+    if (isrock(mvinch(ch_ret.y, ch_ret.x))) turn_on(*th, ISINWALL);
+    else turn_off(*th, ISINWALL);
+
+    /* If the monster can illuminate rooms, check for a change */
+    if (on(*th, HASFIRE)) {
+        register struct linked_list *fire_item;
+
+        /* Is monster entering a room? */
+        if (orig_rer != new_room && new_room != NULL) {
+            fire_item = creat_item();   /* Get an item-only structure */
+            ldata(fire_item) = (char *) th;
+
+            attach(new_room->r_fires, fire_item);
+            new_room->r_flags |= HASFIRE;
+
+            if (cansee(ch_ret.y, ch_ret.x) && next(new_room->r_fires) == NULL)
+                light(&hero);
+        }
+
+        /* Is monster leaving a room? */
+        if (orig_rer != new_room && orig_rer != NULL) {
+            /* Find the bugger in the list and delete him */
+            for (fire_item = orig_rer->r_fires; fire_item != NULL;
+                 fire_item = next(fire_item)) {
+                if (THINGPTR(fire_item) == th)  {       /* Found him! */
+                    detach(orig_rer->r_fires, fire_item);
+                    destroy_item(fire_item);
+                    if (orig_rer->r_fires == NULL) {
+                        orig_rer->r_flags &= ~HASFIRE;
+                        if (cansee(old_pos.y, old_pos.x))
+                            light(&old_pos);
+                    }
+                    break;
+                }
+            }
+        }
+    }
+
+    /* If monster is entering player's room and player can see it,
+     * stop the player's running.
+     */
+    if (new_room != orig_rer && new_room != NULL  &&
+        new_room == roomin(th->t_dest) && cansee(unc(ch_ret))    &&
+        (off(*th, ISINVIS)     || on(player, CANSEE)) &&
+        (off(*th, ISSHADOW)    || on(player, CANSEE)) &&
+        (off(*th, CANSURPRISE) || ISWEARING(R_ALERT))) {
+                running = FALSE;
+                if (fight_flush) flushinp();
+    }
+
+    th->t_oldch = sch;
+
+    /* Let's display those creatures that we can see. */
+    if (cansee(unc(ch_ret)) &&
+        off(*th, ISINWALL) &&
+        !invisible(th))
+        mvwaddch(cw, ch_ret.y, ch_ret.x, th->t_type);
+
+    /* Record monster's last position (if new one is different) */
+    if (!ce(ch_ret, old_pos)) th->t_oldpos = old_pos;
+
+    /* If the monster is on a trap, trap it */
+    sch = mvinch(ch_ret.y, ch_ret.x);
+    if (isatrap(sch)) {
+        if (cansee(ch_ret.y, ch_ret.x)) th->t_oldch = sch;
+        be_trapped(th, &ch_ret);
+    }
+}
+
+/* 
+ * Get_hurl returns the weapon that the monster will "throw" if he has one 
+ */
+
+struct linked_list *
+get_hurl(tp)
+register struct thing *tp;
+{
+    struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL,
+        *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL;
+    register struct linked_list *pitem;
+    register struct object *obj;
+    bool bow=FALSE, crossbow=FALSE, sling=FALSE;
+
+    for (pitem=tp->t_pack; pitem; pitem=next(pitem)) {
+        obj = OBJPTR(pitem);
+        if (obj->o_type == WEAPON)
+            switch (obj->o_which) {
+                case BOW:       bow = TRUE;
+                when CROSSBOW:  crossbow = TRUE;
+                when SLING:     sling = TRUE;
+                when ROCK:      rock = pitem;
+                when ARROW:     arrow = pitem;
+                when BOLT:      bolt = pitem;
+                when SPEAR:     spear = pitem;
+                when DAGGER:
+                    /* Don't throw the dagger if it's our last one */
+                    if (obj->o_count > 1) dagger = pitem;
+                when DART:      dart = pitem;
+            }
+        else if (obj->o_type == RELIC &&
+                 obj->o_which == AXE_AKLAD)
+                    aklad = pitem;
+    }
+    
+    /* Do we have that all-powerful Aklad Axe? */
+    if (aklad) return(aklad);
+
+    /* Use crossbow bolt if possible */
+    if (crossbow && bolt) return(bolt);
+    if (bow && arrow) return(arrow);
+    if (spear) return(spear);
+    if (dagger) return(dagger);
+    if (sling && rock) return(rock);
+    if (dart) return(dart);
+    return(NULL);
+}
+
+/*
+ * runto:
+ *      Set a monster running after something
+ */
+
+runto(runner, spot)
+register struct thing *runner;
+coord *spot;
+{
+    if (on(*runner, ISSTONE))
+        return;
+
+    /* If we are chasing a new creature, forget about thrown weapons */
+    if (runner->t_dest && !ce(*runner->t_dest, *spot)) runner->t_wasshot=FALSE;
+
+    /*
+     * Start the beastie running
+     */
+    runner->t_dest = spot;
+    turn_on(*runner, ISRUN);
+    turn_off(*runner, ISDISGUISE);
+}
+
+/*
+ * straight_shot:
+ *      See if there is a straight line of sight between the two
+ *      given coordinates.  If shooting is not NULL, it is a pointer
+ *      to a structure which should be filled with the direction
+ *      to shoot (if there is a line of sight).  If shooting, monsters
+ *      get in the way.  Otherwise, they do not.
+ */
+
+bool
+straight_shot(ery, erx, eey, eex, shooting)
+register int ery, erx, eey, eex;
+register coord *shooting;
+{
+    register int dy, dx;        /* Deltas */
+    unsigned char ch;
+
+    /* Does the monster have a straight shot at prey */
+    if ((ery != eey) && (erx != eex) &&
+        (abs(ery - eey) != abs(erx - eex))) return(FALSE);
+
+    /* Get the direction to shoot */
+    if (eey > ery) dy = 1;
+    else if (eey == ery) dy = 0;
+    else dy = -1;
+
+    if (eex > erx) dx = 1;
+    else if (eex == erx) dx = 0;
+    else dx = -1;
+
+    /* Make sure we have free area all the way to the player */
+    ery += dy;
+    erx += dx;
+    while ((ery != eey) || (erx != eex)) {
+        switch (ch = winat(ery, erx)) {
+            case VERTWALL:
+            case HORZWALL:
+            case WALL:
+            case DOOR:
+            case SECRETDOOR:
+            case FOREST:
+                return(FALSE);
+            default:
+                if (shooting && isalpha(ch)) return(FALSE);
+        }
+        ery += dy;
+        erx += dx;
+    }
+
+    if (shooting) {     /* If we are shooting -- put in the directions */
+        shooting->y = dy;
+        shooting->x = dx;
+    }
+    return(TRUE);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/command.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,1312 @@
+/*
+    command.c  -  Read and execute the user commands
+ 
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <curses.h>
+#include <ctype.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include "mach_dep.h"
+#include "rogue.h"
+
+/*
+ * command:
+ *      Process the user commands
+ */
+
+command()
+{
+    unsigned int ch;
+    struct linked_list *item;
+    unsigned int countch = 0, direction = 0, newcount = FALSE;
+    int segment = 1;
+    int monst_limit, monst_current;
+
+    monst_limit = monst_current = 1;
+    while (playing) {
+        /*
+         * Let the daemons start up, but only do them once a round
+         * (round = 10 segments).
+         */
+        if (segment >= 10) {
+            do_daemons(BEFORE);
+            do_fuses(BEFORE);
+        }
+
+        after = TRUE;
+        do {
+            /* One more tick of the clock. */
+            if (segment >= 10 && after && (++turns % DAYLENGTH) == 0) {
+                daytime ^= TRUE;
+                if (levtype == OUTSIDE) {
+                    if (daytime) msg("A bright star flares above the horizon.");
+                    else msg("The bright star travels beyond the horizon.");
+                }
+                light(&hero);
+            }
+
+            /*
+             * Don't bother with these updates unless the player's going
+             * to do something.
+             */
+            if (player.t_action == A_NIL && player.t_no_move <= 1) {
+                look(after, FALSE);
+                lastscore = purse;
+                wmove(cw, hero.y, hero.x);
+                if (!((running || count) && jump)) {
+                    status(FALSE);
+                }
+            }
+
+            /* Draw the screen */
+            if (!((running || count) && jump)) {
+                wmove(cw, hero.y, hero.x);
+                draw(cw);
+            }
+
+            after = TRUE;
+
+            /*
+             * Read command or continue run
+             */
+            if (--player.t_no_move <= 0) {
+                take = 0;               /* Nothing here to start with */
+                player.t_no_move = 0;   /* Be sure we don't go too negative */
+                if (!running) door_stop = FALSE;
+
+                /* Was the player being held? */
+                if (player.t_action == A_FREEZE) {
+                    player.t_action = A_NIL;
+                    msg("You can move again.");
+                }
+
+                if (player.t_action != A_NIL) ch = player.t_action;
+                else if (running) {
+                    char scratch;
+
+                    /* If in a corridor or maze, if we are at a turn with
+                     * only one way to go, turn that way.
+                     */
+                    scratch = winat(hero.y, hero.x);
+                    if ((scratch==PASSAGE||scratch==DOOR||levtype==MAZELEV)  &&
+                        off(player, ISHUH)                                   && 
+                        off(player, ISBLIND)) {
+                        int y, x;
+                        if (getdelta(runch, &y, &x) == TRUE) {
+                            corr_move(y, x);
+                        }
+                    }
+                    ch = runch;
+                }
+                else if (count) ch = countch;
+                else {
+                    ch = wgetch(cw);
+                    if (mpos != 0 && !running)  /* Erase message if its there */
+                        msg("");
+                }
+
+                /*
+                 * check for prefixes
+                 */
+                if (isascii(ch) && isdigit(ch))
+                {
+                    count = 0;
+                    newcount = TRUE;
+                    while (isascii(ch) && isdigit(ch))
+                    {
+                        count = count * 10 + (ch - '0');
+                        ch = wgetch(cw);
+                    }
+                    countch = ch;
+                    /*
+                     * turn off count for commands which don't make sense
+                     * to repeat
+                     */
+                    switch (ch) {
+                        case 'h': case 'j': case 'k': case 'l':
+                        case 'y': case 'u': case 'b': case 'n':
+                        case 'H': case 'J': case 'K': case 'L':
+                        case 'Y': case 'U': case 'B': case 'N':
+                        case C_SEARCH: case '.':
+                            break;
+                        default:
+                            count = 0;
+                    }
+                }
+
+                /* Save current direction */
+                if (!running) { /* If running, it is already saved */
+                    switch (ch) {
+                        case 'h': case 'j': case 'k': case 'l':
+                        case 'y': case 'u': case 'b': case 'n':
+                        case 'H': case 'J': case 'K': case 'L':
+                        case 'Y': case 'U': case 'B': case 'N':
+                            runch = tolower(ch);
+                    }
+                }
+
+                /* Perform the action */
+                switch (ch) {
+                    case 'f':
+                        if (!on(player, ISBLIND))
+                        {
+                            door_stop = TRUE;
+                            firstmove = TRUE;
+                        }
+                        if (count && !newcount)
+                            ch = direction;
+                        else
+                            ch = wgetch(cw);
+                        switch (ch)
+                        {
+                            case 'h': case 'j': case 'k': case 'l':
+                            case 'y': case 'u': case 'b': case 'n':
+                                ch = toupper(ch);
+                        }
+                        direction = ch;
+                }
+                newcount = FALSE;
+
+                /*
+                 * execute a command
+                 */
+                if (count && !running)
+                    count--;
+
+                switch (ch) {
+                    case '!' : shell();
+                    case KEY_LEFT       : do_move(0, -1);
+                    when KEY_DOWN       : do_move(1, 0);
+                    when KEY_UP         : do_move(-1, 0);
+                    when KEY_RIGHT      : do_move(0, 1);
+                    when KEY_HOME       : do_move(-1, -1);
+                    when KEY_A1         : do_move(-1, -1);
+                    when KEY_PPAGE      : do_move(-1, 1);
+                    when KEY_A3         : do_move(-1, 1);
+                    when KEY_END         : do_move(1, -1);
+                    when KEY_C1         : do_move(1, -1);
+                    when KEY_NPAGE      : do_move(1, 1);
+                    when KEY_C3         : do_move(1, 1);
+#ifdef CTL_RIGHT
+                    when CTL_RIGHT      : do_run('l');
+                    when CTL_LEFT       : do_run('h');
+                    when CTL_UP         : do_run('k');
+                    when CTL_DOWN       : do_run('j');
+                    when CTL_HOME       : do_run('y');
+                    when CTL_PGUP       : do_run('u');
+                    when CTL_END        : do_run('b');
+                    when CTL_PGDN       : do_run('n');
+#endif
+                    when 'h' : do_move(0, -1);
+                    when 'j' : do_move(1, 0);
+                    when 'k' : do_move(-1, 0);
+                    when 'l' : do_move(0, 1);
+                    when 'y' : do_move(-1, -1);
+                    when 'u' : do_move(-1, 1);
+                    when 'b' : do_move(1, -1);
+                    when 'n' : do_move(1, 1);
+                    when 'H' : do_run('h');
+                    when 'J' : do_run('j');
+                    when 'K' : do_run('k');
+                    when 'L' : do_run('l');
+                    when 'Y' : do_run('y');
+                    when 'U' : do_run('u');
+                    when 'B' : do_run('b');
+                    when 'N' : do_run('n');
+                    when A_ATTACK:
+                        /* Is our attackee still there? */
+                        if (isalpha(winat(player.t_newpos.y,
+                                          player.t_newpos.x))) {
+                            /* Our friend is still here */
+                            player.t_action = A_NIL;
+                            fight(&player.t_newpos, cur_weapon, FALSE);
+                        }
+                        else {  /* Our monster has moved */
+                            player.t_action = A_NIL;
+                        }
+                    when A_PICKUP:
+                        player.t_action = A_NIL;
+                        if (add_pack((struct linked_list *)NULL, FALSE)) {
+                            char tch;
+                            tch = mvwinch(stdscr, hero.y, hero.x);
+                            if (tch != FLOOR && tch != PASSAGE) {
+                                player.t_action = A_PICKUP; /*get more */
+                                player.t_no_move += 2 * movement(&player);
+                            }
+                        }
+                    when A_THROW:
+                        if (player.t_action == A_NIL) {
+                            item = get_item(pack, "throw", ALL, FALSE, FALSE);
+                            if (item != NULL && get_dir(&player.t_newpos)) {
+                                player.t_action = A_THROW;
+                                player.t_using = item;
+                                player.t_no_move = 2 * movement(&player);
+                            }
+                            else
+                                after = FALSE;
+                        }
+                        else {
+                            missile(player.t_newpos.y, player.t_newpos.x, 
+                                    player.t_using, &player);
+                            player.t_action = A_NIL;
+                            player.t_using = 0;
+                        }
+                    when 'a' :
+                        if (player.t_action == A_NIL) {
+                            if (get_dir(&player.t_newpos)) {
+                                player.t_action = 'a';
+                                player.t_no_move = 1 + movement(&player);
+                            }
+                            else
+                                after = FALSE;
+                        }
+                        else {
+                            affect();
+                            player.t_action = A_NIL;
+                        }
+                    when 'A' : choose_qst();  
+                    when 'F' : /* frighten a monster */
+                        if (player.t_action == A_NIL) {
+                            player.t_action = 'F';
+                            player.t_no_move = 2*movement(&player);
+                        }
+                        else {
+                after = FALSE;
+                            player.t_action = A_NIL;
+                            fright();
+                        }
+                    when 'g' : /* Give command: give slime-molds to monsters */
+                        if (player.t_action == A_NIL) {
+                            player.t_action = 'g';
+                            player.t_no_move = 2*movement(&player);
+                        }
+                        else {
+                after = FALSE;
+                            player.t_action = A_NIL;
+                            give();
+                        }
+                    when 'G' :
+                        if (player.t_action == A_NIL) {
+                            player.t_action = 'G';
+                            player.t_no_move = movement(&player);
+                        }
+                        else {
+                            player.t_action = A_NIL;
+                            gsense();
+                        }
+                    when 'i' : after = FALSE; inventory(pack, ALL);
+                    when 'I' : after = FALSE; picky_inven();
+                    when 'm' : nameitem((struct linked_list *)NULL, TRUE);
+                    when 'o' : option();
+                    when 'O' : msg("Charactor type: %s    Quest item: %s", char_class[char_type].name, rel_magic[quest_item].mi_name);
+                    when ',' :
+                    case 'P' :
+                        if (levtype != POSTLEV) {
+                            /* We charge 2 movement units per item */
+                            player.t_no_move =
+                                2 * grab(hero.y, hero.x) * movement(&player);
+                        }
+                        else {
+                            /* Let's quote the wise guy a price */
+                            buy_it();
+                            after = FALSE;
+                        }
+                    when 'Q' : after = FALSE; quit(0);
+                    when 'S' : 
+                        after = FALSE;
+                        if (save_game())
+                            exit_game(EXIT_CLS | EXIT_ENDWIN);
+                    when 'v' : after = FALSE;
+                               msg("Advanced xrogue, Version %s  ", release);
+                    when 'X' :  /* trap sense */
+            after = FALSE;
+                        if (player.t_action == A_NIL) {
+                            player.t_action = 'X';
+                            player.t_no_move = movement(&player);
+                        }
+                        else {
+                            xsense();
+                            player.t_action = A_NIL;
+                        }
+                    when '.' :
+                        player.t_no_move = movement(&player);  /* Rest */
+                        player.t_action = A_NIL;
+                    when ' ' : after = FALSE;   /* Do Nothing */
+                    when '>' : after = FALSE; d_level();
+                    when '<' : after = FALSE; u_level();
+                    when '=' : after = FALSE; display();
+                    when '?' : after = FALSE; help();
+
+            /* no character descriptions yet until updated (help.c) */
+            /* when '\\' : after = FALSE; ident_hero(); */
+            when '\\' : msg("Charon (the Boatman) looks at you... ");
+
+                    when '/' : after = FALSE; identify(NULL);
+                    when C_COUNT : count_gold();
+                    when C_DIP : dip_it();
+                    when C_DROP : player.t_action = C_DROP; 
+                                  drop((struct linked_list *)NULL);
+                    when C_EAT : eat();
+                    when C_QUAFF : quaff(-1, NULL, NULL, TRUE);
+                    when C_READ : read_scroll(-1, NULL, TRUE);
+                    when C_SETTRAP : set_trap(&player, hero.y, hero.x);
+                    when C_SEARCH :
+                        if (player.t_action == A_NIL) {
+                            player.t_action = C_SEARCH;
+                            player.t_no_move = 2 + movement(&player);
+                        }
+                        else {
+                            search(FALSE, FALSE);
+                            player.t_action = A_NIL;
+                        }
+                    when C_TAKEOFF : take_off();
+                    when C_USE : use_mm(-1);
+                    when C_WEAR : wear();
+                    when C_WIELD : wield();
+                    when C_ZAP : if (!player_zap(NULL, FALSE)) after=FALSE;
+                    when C_CAST : cast();
+                    when C_CHANT : chant();
+                    when C_PRAY : pray();
+                    when CTRL('B') : msg("Current score: %d",
+                    pstats.s_exp + (long) purse);
+                    when CTRL('E') : msg("Current food level: %d(2000)",
+                    food_left);
+                    when CTRL('L') : after = FALSE; clearok(curscr, TRUE);
+                                    touchwin(cw);
+                    when CTRL('N') : nameit();
+                    when CTRL('O') : after = FALSE; opt_player();
+                    when CTRL('R') : after = FALSE; msg(huh);
+                    when CTRL('T') :
+                        if (player.t_action == A_NIL) {
+                            if (get_dir(&player.t_newpos)) {
+                                player.t_action = CTRL('T');
+                                player.t_no_move = 2 * movement(&player);
+                            }
+                            else
+                                after = FALSE;
+                        }
+                        else {
+                            steal();
+                            player.t_action = A_NIL;
+                        }
+                    when ESC :  /* Escape */
+                        door_stop = FALSE;
+                        count = 0;
+                        after = FALSE;
+                    when '#':
+                        if (levtype == POSTLEV)         /* buy something */
+                            buy_it();
+                        after = FALSE;
+                    when '$':
+                        if (levtype == POSTLEV)         /* price something */
+                            price_it();
+                        after = FALSE;
+                    when '%':
+                        if (levtype == POSTLEV)         /* sell something */
+                            sell_it();
+                        after = FALSE;
+            when '+':   /* instant karma! */
+            switch (rnd(100)) {
+                case 0:  msg("You waste some time. ");
+                when 5:  msg("An oak tree in the garden. ");
+                when 10: msg("Character is what you become in the dark. ");
+                when 15: msg("May you live all the days of your life. ");
+                when 20: msg("A hero is no braver than an ordinary man, but he is brave five minutes longer. ");
+                when 25: msg("Get down! ");
+                when 30: msg("Go back to sleep. ");
+                when 35: msg("Be here now. ");
+                when 40: msg("Choose the rock that feels right to you. ");
+                when 45: msg("Wait... ");
+                when 50: msg("You take a break (yawn)... ");
+                when 55: msg("Without danger there is no pleasure. ");
+                when 60: msg("Define meaningless? ");
+                when 65: msg("Don't push your luck! ");
+                when 70: msg("Gung ho. ");
+                when 75: msg("You are inside a computer. ");
+                when 80: msg("Directive is now required... ");
+                when 85: msg("Charon (the Boatman) awaits you... ");
+                when 95: msg(nothing);
+                otherwise: msg("");
+            }
+            after = FALSE;
+                    when CTRL('P') :
+#ifdef WIZARD
+                        after = FALSE;
+                        if (wizard)
+                        {
+                            wizard = FALSE;
+                            trader = 0;
+                            msg("Not wizard any more");
+                        }
+                        else
+                        {
+                            if (waswizard || passwd())
+                            {
+                                msg("Welcome, O Mighty Wizard! ");
+                                wizard = waswizard = TRUE;
+                            }
+                            else
+                                msg("Sorry");
+                        }
+#else
+                        msg("Sorry");
+#endif
+
+                    otherwise :
+                        after = FALSE;
+                        if (wizard) switch (ch) {
+                            case 'M' : create_obj(TRUE, 0, 0);
+                            when 'V' : msg("vlevel = %d  turns = %d",
+                                           vlevel, turns);
+                            when CTRL('A') : activity();
+                            when CTRL('C') : do_teleport();
+                            when CTRL('D') : level++;
+                                           take_with();
+                                           new_level(NORMLEV);
+                            when CTRL('F') : overlay(stdscr,cw);
+                            when CTRL('G') :
+                            {
+                                item=get_item(pack,"charge",STICK,FALSE,FALSE);
+                                if (item != NULL) {
+                                    (OBJPTR(item))->o_charges=10000;
+                                }
+                            }
+                            when CTRL('H') :
+                            {
+                                register int i, j;
+                                register struct object *obj;
+
+                                for (i = 0; i < 9; i++)
+                                    raise_level();
+                                /*
+                                 * Give the rogue a sword 
+                                 */
+                                if (cur_weapon==NULL || cur_weapon->o_type !=
+                                    RELIC) {
+                                if (player.t_ctype == C_THIEF   ||
+                                    player.t_ctype == C_ASSASSIN ||
+                                    player.t_ctype == C_MONK)
+                                      item = spec_item(WEAPON, BASWORD, 20, 20);
+                                else
+                                      item = spec_item(WEAPON,TWOSWORD, 20, 20);
+                                    if (add_pack(item, TRUE))
+                                    {
+                                        cur_weapon = OBJPTR(item);
+                                        (OBJPTR(item))->o_flags |= (ISKNOW|ISPROT);
+                                    }
+                                    else
+                                        o_discard(item);
+                                /*
+                                 * And his suit of armor
+                                 */
+                                if (player.t_ctype == C_THIEF   ||
+                                    player.t_ctype == C_ASSASSIN ||
+                                    player.t_ctype == C_MONK)
+                                      j = PADDED_ARMOR;
+                                else
+                                      j = PLATE_ARMOR;
+                                    item = spec_item(ARMOR, j, 20, 0);
+                                    obj = OBJPTR(item);
+                                    obj->o_flags |= (ISKNOW | ISPROT);
+                                    obj->o_weight = armors[j].a_wght;
+                                    if (add_pack(item, TRUE))
+                                        cur_armor = obj;
+                                    else
+                                        o_discard(item);
+                                }
+                                purse += 20000;
+                            }
+                            when CTRL('I') : inventory(lvl_obj, ALL);
+                            when CTRL('J') : teleport();
+                            when CTRL('K') : whatis((struct linked_list *)NULL);
+                            when CTRL('W') : wanderer();
+                            when CTRL('X') : overlay(mw,cw);
+                            when CTRL('Y') : msg("food left: %d\tfood level: %d", 
+                                                    food_left, foodlev);
+                            otherwise :
+                                msg("Illegal wizard command '%s'.", unctrl(ch));
+                                count = 0;
+                        }
+                        else
+                        {
+                            msg("Illegal command '%s'.", unctrl(ch));
+                            count = 0;
+                            after = FALSE;
+                        }
+                }
+
+                /*
+                 * If he ran into something to take, let him pick it up.
+                 * unless it's a trading post
+                 */
+                if (auto_pickup && take != 0 && levtype != POSTLEV) {
+                    /* get ready to pick it up */
+                    player.t_action = A_PICKUP;
+                    player.t_no_move += 2 * movement(&player);
+                }
+            }
+
+            /* If he was fighting, let's stop (for now) */
+            if (player.t_quiet < 0) player.t_quiet = 0;
+
+            if (!running)
+                door_stop = FALSE;
+
+            if (after && segment >= 10) {
+                /*
+                 * Kick off the rest if the daemons and fuses
+                 */
+
+                /* 
+                 * If player is infested, take off a hit point 
+                 */
+                if (on(player, HASINFEST)) {
+            pstats.s_hpt -= infest_dam;
+                    if (pstats.s_hpt == 50 || pstats.s_hpt == 25)
+            msg("You feel yourself withering away... ");
+                    if (pstats.s_hpt < 1) {
+            msg("You die a festering mass.  --More--");
+            wait_for(' ');
+            pstats.s_hpt = -1;
+            death(D_INFESTATION);
+            }
+                }
+
+                /*
+                 * The eye of Vecna is a constant drain on the player
+                 */
+                if (cur_relic[EYE_VECNA]) {
+            pstats.s_hpt -= 1;
+                    if (pstats.s_hpt == 50 || pstats.s_hpt == 25)
+            msg("You feel Vecna's eye looking about. ");
+                    if (pstats.s_hpt <= 10 && pstats.s_hpt >= 3)
+            msg("Vecna's eye moves about very quickly. ");
+                    if (pstats.s_hpt < 1) {
+            msg("Vecna's curse is upon you!  --More--");
+            wait_for(' ');
+            pstats.s_hpt = -1;
+            death(D_RELIC);
+            }
+                }
+
+                /* 
+                 * if player has body rot then take off three hits 
+                 */
+                if (on(player, DOROT)) {
+             pstats.s_hpt -= rnd(3)+1;
+                     if (pstats.s_hpt == 50 || pstats.s_hpt == 25) 
+             msg("Something really begins to stink and smell! ");
+                     if (pstats.s_hpt < 1) {
+             msg("You keel over with rot.  --More--");
+             wait_for(' ');
+             pstats.s_hpt = -1;
+             death(D_ROT);
+             }
+                }
+                do_daemons(AFTER);
+                do_fuses(AFTER);
+            }
+        } while (after == FALSE);
+
+        /* Make the monsters go */
+        if (--monst_current <= 0)
+            monst_current = monst_limit = runners(monst_limit);
+
+        if (++segment > 10) segment = 1;
+        reap(); /* bury all the dead monsters */
+    }
+}
+
+/*
+ * display
+ *      tell the player what is at a certain coordinates assuming
+ *      it can be seen.
+ */
+display()
+{
+    coord c;
+    struct linked_list *item;
+    struct thing *tp;
+    int what;
+
+    msg("What do you want to display (* for help)?");
+    c = get_coordinates();
+    mpos = 0;
+    if (!cansee(c.y, c.x)) {
+        msg("You can't see what is there.");
+        return;
+    }
+    what = mvwinch(cw, c.y, c.x);
+    if (isalpha(what)) {
+        item = find_mons(c.y, c.x);
+        tp = THINGPTR(item);
+        msg("%s", monster_name(tp));
+        return;
+    }
+    if ((item = find_obj(c.y, c.x)) != NULL) {
+        msg("%s", inv_name(OBJPTR(item), FALSE));
+        return;
+    }
+    identify(what);
+}
+
+/*
+ * quit:
+ *      Have player make certain, then exit.
+ */
+
+/*UNUSED*/
+void
+quit(sig)
+int sig;
+{
+    register int oy, ox;
+
+	NOOP(sig);
+
+    /*
+     * Reset the signal in case we got here via an interrupt
+     */
+
+    if ((VOID(*)())signal(SIGINT, quit) != (VOID(*)())quit)
+        mpos = 0;
+
+    getyx(cw, oy, ox);
+    if (level < 1) {    /* if not down in the dungeon proper; exit the game */
+        wclear(hw);
+        wmove(hw, lines-1, 0);
+        draw(hw);
+        wmove(hw, 12, 30);
+        wprintw(hw, "Good-bye!");
+        draw(hw);
+        exit_game(EXIT_ENDWIN);
+    }
+    msg("Really quit? <yes or no> ");   /* otherwise ask about quitting */
+    draw(cw);
+    prbuf[0] = '\0';
+    if ((get_str(prbuf, msgw) == NORM) && strcmp(prbuf, "yes") == 0) {
+        clear();
+        move(lines-1, 0);
+        draw(stdscr);
+        writelog(pstats.s_exp + (long) purse, CHICKEN, 0);
+        score(pstats.s_exp + (long) purse, CHICKEN, 0);
+        exit_game(EXIT_ENDWIN);
+    }
+    else {
+        signal(SIGINT, quit);
+        wmove(msgw, 0, 0);
+        wclrtoeol(msgw);
+        draw(msgw);
+        status(FALSE);
+        wmove(cw, oy, ox);
+        draw(cw);
+        mpos = 0;
+        count = 0;
+        running = FALSE;
+    }
+}
+
+/*
+ * bugkill:
+ *      killed by a program bug instead of voluntarily.
+ */
+
+bugkill(sig)
+int sig;
+{
+    signal(sig, quit);      /* If we get it again, give up */
+    if (levtype == OUTSIDE) {
+        msg("Oh no!  You walk right into a flying swarm of nasty little bugs!! ");
+        msg("One of them penetrates your brain!!!  --More--");
+    }
+    else {
+        msg("Charon (the Boatman) has finally come for you...  --More--");
+    }
+    wait_for(' ');
+    pstats.s_hpt = -1;
+    death(D_SIGNAL);    /* Killed by a bug */
+}
+
+/*
+ * search:
+ *      Player gropes about him to find hidden things.
+ */
+
+search(is_thief, door_chime)
+register bool is_thief, door_chime;
+{
+    register int x, y;
+    register char ch,   /* The trap or door character */
+                 sch;   /* Trap or door character (as seen on screen) */
+    register unsigned char mch;   /* Monster, if a monster is on the trap or door */
+    register struct linked_list *item;
+    register struct thing *mp; /* Status on surrounding monster */
+
+    /*
+     * Look all around the hero, if there is something hidden there,
+     * give him a chance to find it.  If its found, display it.
+     */
+    if (on(player, ISBLIND))
+        return;
+    for (x = hero.x - 1; x <= hero.x + 1; x++)
+        for (y = hero.y - 1; y <= hero.y + 1; y++)
+        {
+            if (y==hero.y && x==hero.x)
+                continue;
+
+            if (x < 0 || y < 0 || x >= cols || y >= lines)
+                continue;
+
+            /* Mch and ch will be the same unless there is a monster here */
+            mch = winat(y, x);
+            ch = mvwinch(stdscr, y, x);
+            sch = mvwinch(cw, y, x);    /* What's on the screen */
+
+            if (door_chime == FALSE && isatrap(ch)) {
+                    register struct trap *tp;
+
+                    /* Is there a monster on the trap? */
+                    if (mch != ch && (item = find_mons(y, x)) != NULL) {
+                        mp = THINGPTR(item);
+                        if (sch == mch) sch = mp->t_oldch;
+                    }
+                    else mp = NULL;
+
+                    /* 
+                     * is this one found already?
+                     */
+                    if (isatrap(sch)) 
+                        continue;       /* give him chance for other traps */
+                    tp = trap_at(y, x);
+                    /* 
+                     * if the thief set it then don't display it.
+                     * if its not a thief he has 50/50 shot
+                     */
+                    if((tp->tr_flags&ISTHIEFSET) || (!is_thief && rnd(100)>50))
+                        continue;       /* give him chance for other traps */
+                    tp->tr_flags |= ISFOUND;
+
+                    /* Let's update the screen */
+                    if (mp != NULL && mvwinch(cw, y, x) == mch)
+                        mp->t_oldch = ch; /* Will change when monst moves */
+                    else mvwaddch(cw, y, x, ch);
+
+                    count = 0;
+                    running = FALSE;
+
+                    /* Stop what we were doing */
+                    player.t_no_move = movement(&player);
+                    player.t_action = A_NIL;
+                    player.t_using = NULL;
+
+                    if (fight_flush) flushinp();
+                    msg(tr_name(tp->tr_type));
+            }
+            else if (ch == SECRETDOOR) {
+                if (door_chime == TRUE || (!is_thief && rnd(100) < 20)) {
+                    struct room *rp;
+                    coord cp;
+
+                    /* Is there a monster on the door? */
+                    if (mch != ch && (item = find_mons(y, x)) != NULL) {
+                        mp = THINGPTR(item);
+
+                        /* Screen will change when monster moves */
+                        if (sch == mch) mp->t_oldch = ch;
+                    }
+                    mvaddch(y, x, DOOR);
+                    count = 0;
+                    /*
+                     * if its the entrance to a treasure room, wake it up
+                     */
+                    cp.y = y;
+                    cp.x = x;
+                    rp = roomin(&cp);
+                    if (rp->r_flags & ISTREAS)
+                        wake_room(rp);
+
+                    /* Make sure we don't shoot into the room */
+                    if (door_chime == FALSE) {
+                        count = 0;
+                        running = FALSE;
+
+                        /* Stop what we were doing */
+                        player.t_no_move = movement(&player);
+                        player.t_action = A_NIL;
+                        player.t_using = NULL;
+                    }
+                }
+            }
+        }
+}
+
+/*
+ * d_level:
+ *      He wants to go down a level
+ */
+
+d_level()
+{
+    bool no_phase=FALSE;
+    char position = winat(hero.y, hero.x);
+    int au;
+
+
+    /* If we are on a trading post, go to a trading post level. */
+    if (position == POST) {
+        take_with();   /* Take charmed monsters with you while shopping */
+        new_level(POSTLEV);
+        return;
+    }
+
+    /* Dive for gold */
+    if (position == POOL) {
+        if (rnd(300) < 2) {
+            msg("Oh no!!!  You drown in the pool!!!  --More--");
+            pstats.s_hpt = -1;
+            wait_for(' ');
+            death(D_DROWN);
+        }
+        else if (rnd(125) < 25) {
+            au = rnd(350) + (level * 10);
+            msg("You dive under the water momentarily.. ");
+            msg("You found %d gold pieces! ", au);
+            purse = purse + au;
+            return;
+        }
+        else return;  /* doesn't happen all of the time */
+    }
+
+    /* Going down traps is hazardous */
+    switch (position) {
+    case WORMHOLE:
+    case TRAPDOOR:
+    case MAZETRAP:
+    case DARTTRAP:
+    case SLEEPTRAP:
+    case ARROWTRAP:
+    case BEARTRAP:
+    case TELTRAP:
+        msg ("You find yourself in some sort of quicksand!? ");
+        msg ("Hey!  There are rock maggots in here!! ");
+        player.t_no_move += movement(&player) * FREEZETIME;
+        player.t_action = A_FREEZE;
+        msg("You can't move. ");                   /* spare monks */
+        if (!ISWEARING(R_HEALTH) && player.t_ctype != C_MONK) {
+            turn_on(player, DOROT);
+            msg("You feel your skin starting to rot and peel away!! ");
+            }
+        return;
+    }
+
+    /* If we are at a top-level trading post, we probably can't go down */
+    if (levtype == POSTLEV && level == 0 && position != STAIRS) {
+        msg("I see no way down.");
+        return;
+    }
+
+    if (winat(hero.y, hero.x) != STAIRS) {
+        if (off(player, CANINWALL) ||   /* Must use stairs if can't phase */
+            (levtype == OUTSIDE && rnd(100) < 90)) {
+            msg("I see no way down.");
+            return;
+        }
+    if (levtype == OUTSIDE) {
+            level++;
+            take_with();
+            new_level(NORMLEV);
+            if (no_phase) unphase();
+            return;
+        }
+
+        /* Is there any dungeon left below? */
+        if (level >= nfloors) {
+            msg("There is only solid rock below.");
+            return;
+        }
+
+        extinguish(unphase);    /* Using phase to go down gets rid of it */
+        no_phase = TRUE;
+    }
+
+    /* Is this the bottom? */
+    if (level >= nfloors) {
+        msg("The stairway only goes up.");
+        return;
+    }
+
+    level++;
+    take_with();
+    new_level(NORMLEV);
+    if (no_phase) unphase();
+}
+
+/*
+ * u_level:
+ *      He wants to go up a level
+ */
+
+u_level()
+{
+    bool no_phase = FALSE;
+    register struct linked_list *item;
+    char position = winat(hero.y, hero.x);
+    struct thing *tp;
+    struct object *obj;
+
+    /* You can go up into the outside if standing on top of a worm hole */
+    if (position == WORMHOLE) {
+            prev_max = 1000;
+        level--;
+        if (level <= 0) level = 1;
+            msg("You find yourself in strange surroundings... ");
+        if (wizard) addmsg("Going up through a worm hole. ");
+            take_with();
+            new_level(OUTSIDE);
+            return;
+   }
+
+    if (winat(hero.y, hero.x) != STAIRS) {
+        if (off(player, CANINWALL)) {   /* Must use stairs if can't phase */
+            msg("I see no way up.");
+            return;
+        }
+
+        extinguish(unphase);
+        no_phase = TRUE;
+    }
+
+    if (position != STAIRS) return;
+
+    if (level == 0 || levtype == OUTSIDE) {
+        msg("The stairway only goes down.");
+        return;
+    }
+
+    /*
+     * does he have the item he was quested to get?
+     */
+    if (level == 1) {
+        for (item = pack; item != NULL; item = next(item)) {
+            obj = OBJPTR(item);
+            if (obj->o_type == RELIC && obj->o_which == quest_item)
+                total_winner();
+        }
+    }
+    /*
+     * check to see if he trapped a UNIQUE, If he did then put it back
+     * in the monster table for next time
+     */
+    for (item = tlist; item != NULL; item = next(item)) {
+        tp = THINGPTR(item);
+        if (on(*tp, ISUNIQUE)) 
+            monsters[tp->t_index].m_normal = TRUE;
+    }
+    t_free_list(tlist); /* Monsters that fell below are long gone! */
+
+    if (levtype != POSTLEV)
+    level--;
+    if (level > 0) {
+        take_with();
+        new_level(NORMLEV);
+    }
+    else if (cur_max > level) {
+        prev_max = 1000;    /* flag used in n_level.c */
+    level--;
+        if (level <= 0) level = 1;
+        msg("You emerge into the %s. ", daytime ? "eerie light" : "dark night");
+    if (wizard) msg("Going up: cur_max=%d level=%d. ", cur_max, level);
+        take_with();
+        new_level(OUTSIDE);     /* Leaving the dungeon for outside */
+    return;
+ }
+    else {
+        prev_max = 1;   /* flag used in n_level.c */
+        level = -1;     /* Indicate that we are new to the outside */
+        msg("You emerge into the %s. ", daytime ? "eerie light" : "dark night");
+    if (wizard) msg("Going up: cur_max=%d level=%d. ", cur_max, level);
+        take_with();
+        new_level(OUTSIDE); 
+    return;
+    }
+
+    if (no_phase) unphase();
+}
+
+/*
+ * Let him escape for a while
+ */
+
+shell()
+{
+    /*
+     * Set the terminal back to original mode
+     */
+    wclear(hw);
+    wmove(hw, lines-1, 0);
+    draw(hw);
+    endwin();
+    in_shell = TRUE;
+    fflush(stdout);
+
+	md_shellescape();
+	
+    printf(retstr);
+    fflush(stdout);
+    noecho();
+    crmode();
+    in_shell = FALSE;
+    wait_for('\n');
+	restscr(cw);
+}
+
+/*
+ * see what we want to name -- an item or a monster.
+ */
+nameit()
+{
+    char answer;
+
+    msg("Name monster or item (m or i)? ");
+    answer = wgetch(cw);
+    mpos = 0;
+
+    while (answer != 'm' && answer != 'i' && answer != ESC) {
+        mpos = 0;
+        msg("Please specify m or i, for monster or item - ");
+        answer = wgetch(cw);
+    }
+
+    switch (answer) {
+        case 'm': namemonst();
+        when 'i': nameitem((struct linked_list *)NULL, FALSE);
+    }
+}
+
+/*
+ * allow a user to call a potion, scroll, or ring something
+ */
+
+nameitem(item, mark)
+struct linked_list *item;
+bool mark;
+{
+    register struct object *obj;
+    register char **guess = NULL, *elsewise = NULL;
+    register bool *know;
+
+    if (item == NULL) {
+        if (mark) item = get_item(pack, "mark", ALL, FALSE, FALSE);
+        else      item = get_item(pack, "name", CALLABLE, FALSE, FALSE);
+        if (item == NULL) return;
+    }
+    /*
+     * Make certain that it is somethings that we want to wear
+     */
+    obj = OBJPTR(item);
+    switch (obj->o_type)
+    {
+        case RING:
+            guess = r_guess;
+            know = r_know;
+            elsewise = (r_guess[obj->o_which] != NULL ?
+                        r_guess[obj->o_which] : r_stones[obj->o_which]);
+        when POTION:
+            guess = p_guess;
+            know = p_know;
+            elsewise = (p_guess[obj->o_which] != NULL ?
+                        p_guess[obj->o_which] : p_colors[obj->o_which]);
+        when SCROLL:
+            guess = s_guess;
+            know = s_know;
+            elsewise = (s_guess[obj->o_which] != NULL ?
+                        s_guess[obj->o_which] : s_names[obj->o_which]);
+        when STICK:
+            guess = ws_guess;
+            know = ws_know;
+            elsewise = (ws_guess[obj->o_which] != NULL ?
+                        ws_guess[obj->o_which] : ws_made[obj->o_which]);
+        when MM:
+            guess = m_guess;
+            know = m_know;
+            elsewise = (m_guess[obj->o_which] != NULL ?
+                        m_guess[obj->o_which] : "nothing");
+        otherwise:
+            if (!mark) {
+                msg("You can't call that anything.");
+                return;
+            }
+            else know = (bool *) 0;
+    }
+    if ((obj->o_flags & ISPOST) || (know && know[obj->o_which]) && !mark) {
+        msg("That has already been identified.");
+        return;
+    }
+    if (mark) {
+        if (obj->o_mark[0]) {
+            addmsg(terse ? "M" : "Was m");
+            msg("arked \"%s\"", obj->o_mark);
+        }
+        msg(terse ? "Mark it: " : "What do you want to mark it? ");
+        prbuf[0] = '\0';
+    }
+    else {
+        if (elsewise) {
+            addmsg(terse ? "N" : "Was n");
+            msg("amed \"%s\"", elsewise);
+            strcpy(prbuf, elsewise);
+        }
+        else prbuf[0] = '\0';
+        msg(terse ? "Name it: " : "What do you want to name it? ");
+    }
+    if (get_str(prbuf, msgw) == NORM) {
+        if (mark) {
+            strncpy((char *)obj->o_mark, prbuf, MARKLEN-1);
+            obj->o_mark[MARKLEN-1] = '\0';
+        }
+        else if (prbuf[0] != '\0') {
+            if (guess[obj->o_which] != NULL)
+                free(guess[obj->o_which]);
+            guess[obj->o_which] = new((unsigned int) strlen(prbuf) + 1);
+            strcpy(guess[obj->o_which], prbuf);
+        }
+    }
+}
+
+/* Name a monster */
+
+namemonst()
+{
+    register struct thing *tp;
+    struct linked_list *item;
+    coord c;
+
+    /* Find the monster */
+    msg("Choose the monster (* for help)");
+    c = get_coordinates();
+
+    /* Make sure we can see it and that it is a monster. */
+    mpos = 0;
+    if (!cansee(c.y, c.x)) {
+        msg("You can't see what is there.");
+        return;
+    }
+    
+    if (isalpha(mvwinch(cw, c.y, c.x))) {
+        item = find_mons(c.y, c.x);
+        if (item != NULL) {
+            tp = THINGPTR(item);
+            if (tp->t_name == NULL)
+                strcpy(prbuf, monsters[tp->t_index].m_name);
+            else
+                strcpy(prbuf, tp->t_name);
+
+            addmsg(terse ? "N" : "Was n");
+            msg("amed \"%s\"", prbuf);
+            msg(terse ? "Name it: " : "What do you want to name it? ");
+
+            if (get_str(prbuf, msgw) == NORM) {
+                if (prbuf[0] != '\0') {
+                    if (tp->t_name != NULL)
+                        free(tp->t_name);
+                    tp->t_name = new((unsigned int) strlen(prbuf) + 1);
+                    strcpy(tp->t_name, prbuf);
+                }
+            }
+            return;
+        }
+    }
+
+    msg("There is no monster there to name.");
+}
+
+count_gold()
+{
+        if (player.t_action != C_COUNT) {
+            msg("You take a break to count your money.. ");
+            player.t_using = NULL;
+            player.t_action = C_COUNT;  /* We are counting */
+            if (purse > 500000) msg("This may take some time... 10, 20, 30...");
+            player.t_no_move = (purse/75000 + 1) * movement(&player);
+            return;
+        }
+        if (purse > 10000)
+                msg("You have %ld pieces of gold. ", purse);
+        else if (purse == 1)
+                msg("You have 1 piece of gold. ");
+        else
+                msg("You have %ld gold pieces. ", purse);
+        player.t_action = A_NIL;
+}
+
+/* 
+ * Teleport somewhere, anywhere...
+ */
+
+do_teleport()
+{
+    int tlev;
+    prbuf[0] = '\0';
+    msg("To which level do you wish to teleport? ");
+    if(get_str(prbuf,msgw) == NORM) {
+        tlev = atoi(prbuf);
+    if (quest_item == ALTERAN_CARD || wizard) {
+            if (wizard && (tlev < 1 || tlev > LEVEL)) {  /* wizard */
+                mpos = 0;
+                msg("The power of teleportation does have its limitations. ");
+            return;
+            }
+        else if (!wizard && (tlev < 10 || tlev > LEVEL)) {
+                mpos = 0;
+                msg("The power of teleportation does have its limitations. ");
+            return;
+            }
+            else if (tlev >= LEVEL-100 && tlev < LEVEL-50) {
+                levtype = OUTSIDE;
+                level = LEVEL-100;
+            prev_max = 1000; /* a flag for going outside */
+            } 
+            else if (tlev >= LEVEL-150 && tlev < LEVEL-100) {
+                levtype = MAZELEV;
+                level = LEVEL-150;
+            } 
+            else if (tlev >= LEVEL-200 && tlev < LEVEL-150) {
+                levtype = POSTLEV;
+                level = LEVEL-200;
+            }
+            else {
+                levtype = NORMLEV;
+                level = tlev;
+            }
+    }
+    else if (tlev < 40 || tlev > 399) {  /* not quest item or wizard */
+            mpos = 0;
+            msg("The power of teleportation does have its limitations. ");
+        return;
+        }
+    else {
+        levtype = NORMLEV;
+        level = tlev;
+    }
+
+    /* okay, now send him off */
+    cur_max = level;  /* deepest he's been */
+    new_level(levtype);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/daemon.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,258 @@
+/*
+    daemon.c - functions for dealing with things that happen in the future
+ 
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <curses.h>
+#include "rogue.h"
+
+#define EMPTY           0
+#define DAEMON          -1
+
+#define _X_ { EMPTY }
+
+struct delayed_action d_list[MAXDAEMONS] = {
+        _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_
+};
+struct delayed_action f_list[MAXFUSES] = {
+        _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_,
+        _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_
+};
+
+int demoncnt = 0;        /* number of active daemons */
+int fusecnt = 0;
+
+
+/*
+ * d_slot:
+ *      Find an empty slot in the daemon list
+ */
+struct delayed_action *
+d_slot()
+{
+        reg int i;
+        reg struct delayed_action *dev;
+
+        for (i = 0, dev = d_list; i < MAXDAEMONS; i++, dev++)
+                if (dev->d_type == EMPTY)
+                        return dev;
+        return NULL;
+}
+
+/*
+ * f_slot:
+ *      Find an empty slot in the fuses list
+ */
+struct delayed_action *
+f_slot()
+{
+        reg int i;
+        reg struct delayed_action *dev;
+
+        for (i = 0, dev = f_list; i < MAXFUSES; i++, dev++)
+                if (dev->d_type == EMPTY)
+                        return dev;
+        return NULL;
+}
+
+/*
+ * find_slot:
+ *      Find a particular slot in the table
+ */
+
+struct delayed_action *
+find_slot(func)
+reg int (*func)();
+{
+        reg int i;
+        reg struct delayed_action *dev;
+
+        for (i = 0, dev = f_list; i < MAXFUSES; i++, dev++)
+                if (dev->d_type != EMPTY && func == dev->d_func)
+                        return dev;
+        return NULL;
+}
+
+/*
+ * daemon:
+ *      Start a daemon, takes a function.
+ */
+
+daemon(dfunc, arg, type)
+reg VOID  *arg;
+reg int type, (*dfunc)();
+{
+        reg struct delayed_action *dev;
+
+        dev = d_slot();
+        if (dev != NULL) {
+                dev->d_type = type;
+                dev->d_func = dfunc;
+                dev->d_arg.vp = arg;
+                dev->d_time = DAEMON;
+                demoncnt += 1;                  /* update count */
+        }
+}
+
+/*
+ * kill_daemon:
+ *      Remove a daemon from the list
+ */
+
+kill_daemon(dfunc)
+reg int (*dfunc)();
+{
+        reg struct delayed_action *dev;
+        reg int i;
+
+        for (i = 0, dev = d_list; i < MAXDAEMONS; i++, dev++) {
+                if (dev->d_type != EMPTY && dfunc == dev->d_func)
+                        break;
+        }
+        if (i >= MAXDAEMONS) return; /* if not found, forget it */
+        /*
+         * Take it out of the list
+         */
+        dev->d_type = EMPTY;
+		dev->d_arg.vp  = NULL;
+		dev->d_func = NULL;
+		dev->d_time = 0;
+
+        demoncnt -= 1;                  /* update count */
+}
+
+/*
+ * do_daemons:
+ *      Run all the daemons that are active with the current flag,
+ *      passing the argument to the function.
+ */
+
+do_daemons(flag)
+reg int flag;
+{
+        struct delayed_action *dev;
+        int i;
+
+        /*
+         * Loop through the devil list
+         */
+        for (i = 0; i < MAXDAEMONS; i++)
+        {
+            dev = &d_list[i];
+        /*
+         * Executing each one, giving it the proper arguments
+         */
+                if ((dev->d_type == flag) && (dev->d_time == DAEMON) && (dev->d_func != NULL))
+                        (*dev->d_func)(dev->d_arg.vp);
+        }
+}
+
+/*
+ * fuse:
+ *      Start a fuse to go off in a certain number of turns
+ */
+
+fuse(dfunc, arg, time, type)
+VOID *arg;
+reg int (*dfunc)(), time, type;
+{
+        reg struct delayed_action *wire;
+
+        wire = f_slot();
+        if (wire != NULL) {
+                wire->d_type = type;
+                wire->d_func = dfunc;
+                wire->d_arg.vp = arg;
+                wire->d_time = time;
+                fusecnt += 1;                   /* update count */
+        }
+}
+
+/*
+ * lengthen:
+ *      Increase the time until a fuse goes off
+ */
+
+lengthen(dfunc, xtime)
+reg int (*dfunc)(), xtime;
+{
+        reg struct delayed_action *wire;
+
+        if ((wire = find_slot(dfunc)) == NULL)
+                return;
+        wire->d_time += xtime;
+}
+
+/*
+ * extinguish:
+ *      Put out a fuse
+ */
+
+extinguish(dfunc)
+reg int (*dfunc)();
+{
+        reg struct delayed_action *wire;
+
+        if ((wire = find_slot(dfunc)) == NULL)
+                return;
+        wire->d_type = EMPTY;
+		wire->d_func = NULL;
+		wire->d_arg.vp = NULL;
+		wire->d_time = 0;
+        fusecnt -= 1;
+}
+
+/*
+ * do_fuses:
+ *      Decrement counters and start needed fuses
+ */
+
+do_fuses(flag)
+reg int flag;
+{
+        struct delayed_action *wire;
+        int i;
+
+        /*
+         * Step though the list
+         */
+        for (i = 0; i < MAXFUSES; i++) {
+            wire = &f_list[i];
+        /*
+         * Decrementing counters and starting things we want.  We also need
+         * to remove the fuse from the list once it has gone off.
+         */
+            if(flag == wire->d_type && wire->d_time > 0 &&
+              --wire->d_time == 0) {
+                wire->d_type = EMPTY;
+				if (wire->d_func != NULL)
+					(*wire->d_func)(wire->d_arg.vp);
+                fusecnt -= 1;
+            }
+        }
+}
+
+/*
+ * activity:
+ *      Show wizard number of demaons and memory blocks used
+ */
+
+activity()
+{
+        msg("Daemons = %d : Fuses = %d : Memory Items = %d : Memory Used = %d",
+            demoncnt,fusecnt,total,md_memused());
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/daemons.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,731 @@
+/*
+    daemons.c - All the daemon and fuse functions are in here
+  
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <curses.h>
+#include "rogue.h"
+
+/*
+ * doctor:
+ *      A healing daemon that restors hit points after rest
+ */
+
+doctor(tp)
+register struct thing *tp;
+{
+    register int ohp;
+    register int limit, new_points;
+    register struct stats *curp; /* current stats pointer */
+    register struct stats *maxp; /* max stats pointer */
+
+    curp = &(tp->t_stats);
+    maxp = &(tp->maxstats);
+    if (curp->s_hpt == maxp->s_hpt) {
+        tp->t_quiet = 0;
+        return;
+    }
+    tp->t_quiet++;
+    switch (tp->t_ctype) {
+        case C_MAGICIAN:
+            limit = 10 - curp->s_lvl;
+            new_points = curp->s_lvl - 2;
+        when C_CLERIC:
+        case C_DRUID:
+            limit = 12 - curp->s_lvl;
+            new_points = curp->s_lvl - 3;
+        when C_THIEF:
+        case C_ASSASSIN:
+            limit = 14 - curp->s_lvl;
+            new_points = curp->s_lvl - 4;
+        when C_MONK:
+            limit = 16 - curp->s_lvl;
+            new_points = curp->s_lvl - 5;
+        when C_RANGER:
+        case C_PALADIN:
+            limit = 18 - curp->s_lvl;
+            new_points = curp->s_lvl - 6;
+        when C_FIGHTER:
+            limit = 20 - curp->s_lvl;
+            new_points = curp->s_lvl - 7;
+        when C_MONSTER:
+            limit = 15 - curp->s_lvl;
+            new_points = curp->s_lvl - 5;
+        otherwise:
+            debug("what a strange character you are!");
+            return;
+    }
+    ohp = curp->s_hpt;
+    if (off(*tp, HASDISEASE) && off(*tp, DOROT)) {
+        if (curp->s_lvl < 8) {
+            if (tp->t_quiet > limit) {
+                curp->s_hpt++;
+                tp->t_quiet = 0;
+            }
+        }
+        else {
+            if (tp->t_quiet >= 3) {
+                curp->s_hpt += rnd(new_points)+1;
+                tp->t_quiet = 0;
+            }
+        }
+    }
+    if (tp == &player) {
+        if (ISRING(LEFT_1, R_REGEN)) curp->s_hpt++;
+        if (ISRING(LEFT_2, R_REGEN)) curp->s_hpt++;
+        if (ISRING(LEFT_3, R_REGEN)) curp->s_hpt++;
+        if (ISRING(LEFT_4, R_REGEN)) curp->s_hpt++;
+        if (ISRING(RIGHT_1, R_REGEN)) curp->s_hpt++;
+        if (ISRING(RIGHT_2, R_REGEN)) curp->s_hpt++;
+        if (ISRING(RIGHT_3, R_REGEN)) curp->s_hpt++;
+        if (ISRING(RIGHT_4, R_REGEN)) curp->s_hpt++;
+    }
+    if (on(*tp, ISREGEN))
+        curp->s_hpt += curp->s_lvl/10 + 1;
+    if (ohp != curp->s_hpt) {
+        if (curp->s_hpt >= maxp->s_hpt) {
+            curp->s_hpt = maxp->s_hpt;
+            if (off(*tp, WASTURNED) && on(*tp, ISFLEE) && tp != &player) {
+                turn_off(*tp, ISFLEE);
+                tp->t_oldpos = tp->t_pos;       /* Start our trek over */
+            }
+        }
+    }
+}
+
+/*
+ * Swander:
+ *      Called when it is time to start rolling for wandering monsters
+ */
+
+swander()
+{
+    daemon(rollwand, (VOID *)NULL, BEFORE);
+}
+
+/*
+ * rollwand:
+ *      Called to roll to see if a wandering monster starts up
+ */
+
+int between = 0;
+
+rollwand()
+{
+
+    if (++between >= 4)
+    {
+        /* Theives may not awaken a monster */
+        if ((roll(1, 6) == 4) &&
+           ((player.t_ctype != C_THIEF && player.t_ctype != C_ASSASSIN) || 
+            (rnd(30) >= dex_compute()))) {
+            if (levtype != POSTLEV)
+                wanderer();
+            kill_daemon(rollwand);
+            fuse(swander, (VOID *)NULL, WANDERTIME, BEFORE);
+        }
+        between = 0;
+    }
+}
+
+/*
+ * this function is a daemon called each turn when the character is a thief
+ */
+
+trap_look()
+{
+    if (rnd(100) < (2*dex_compute() + 5*pstats.s_lvl))
+        search(TRUE, FALSE);
+}
+
+/*
+ * unconfuse:
+ *      Release the poor player from his confusion
+ */
+
+unconfuse()
+{
+    turn_off(player, ISHUH);
+    msg("You feel less confused now");
+}
+
+/*
+ * unsee:
+ *      He lost his see invisible power
+ */
+
+unsee()
+{
+    if (!ISWEARING(R_SEEINVIS)) {
+        turn_off(player, CANSEE);
+        msg("The tingling feeling leaves your eyes");
+    }
+}
+
+/*
+ * unstink:
+ *      Remove to-hit handicap from player
+ */
+
+unstink()
+{
+    turn_off(player, HASSTINK);
+}
+
+/*
+ * unclrhead:
+ *      Player is no longer immune to confusion
+ */
+
+unclrhead()
+{
+    turn_off(player, ISCLEAR);
+    msg("The blue aura about your head fades away.");
+}
+
+/*
+ * unphase:
+ *      Player can no longer walk through walls
+ */
+
+unphase()
+{
+    turn_off(player, CANINWALL);
+    msg("Your dizzy feeling leaves you.");
+    if (!step_ok(hero.y, hero.x, NOMONST, &player)) 
+        msg("You begin to feel weird.. ");
+}
+
+/*
+ * land:
+ *      Player can no longer fly
+ */
+
+int
+land()
+{
+    turn_off(player, ISFLY);
+    msg("You regain your normal weight");
+    running = FALSE;
+    return(0);
+}
+
+/*
+ * sight:
+ *      He gets his sight back
+ */
+
+sight()
+{
+    if (on(player, ISBLIND))
+    {
+        extinguish(sight);
+        turn_off(player, ISBLIND);
+        light(&hero);
+        msg("The veil of darkness lifts");
+    }
+}
+
+/*
+ * res_strength:
+ *      Restore player's strength
+ */
+
+int
+res_strength(howmuch)
+long howmuch;
+{
+
+    /* If lost_str is non-zero, restore that amount of strength,
+     * else all of it 
+     */
+    if (lost_str) {
+        chg_str(lost_str);
+        lost_str = 0;
+    }
+
+    /* Now, add in the restoral, but no greater than maximum strength */
+    if (howmuch > 0)
+        pstats.s_str =
+            min(pstats.s_str + howmuch, max_stats.s_str + ring_value(R_ADDSTR));
+
+    updpack(TRUE, &player);
+    return(0);
+}
+
+/*
+ * nohaste:
+ *      End the hasting
+ */
+
+nohaste()
+{
+    turn_off(player, ISHASTE);
+    msg("You feel yourself slowing down.");
+}
+
+/*
+ * noslow:
+ *      End the slowing
+ */
+
+noslow()
+{
+    turn_off(player, ISSLOW);
+    msg("You feel yourself speeding up.");
+}
+
+/*
+ * suffocate:
+ *      If this gets called, the player has suffocated
+ */
+
+suffocate()
+{
+    pstats.s_hpt = -1;
+    death(D_SUFFOCATION);
+}
+
+/*
+ * digest the hero's food
+ */
+
+stomach()
+{
+    register int oldfood, old_hunger, food_use, i;
+
+    /* 
+     * avoid problems of fainting while eating by just not saying it
+     * takes food to eat food
+     */
+    if (player.t_action == C_EAT) 
+        return;
+
+    old_hunger = hungry_state;
+    if (food_left <= 0)
+    {
+        /*
+         * the hero is fainting
+         */
+        if (player.t_action == A_FREEZE)
+                return;
+        if (rnd(100) > 12)
+            return;
+        if (hungry_state == F_FAINT && rnd(28) == 7) /*must have fainted once*/
+    {
+        pstats.s_hpt = -1;
+        msg("You starve to death!!  --More-- ");
+        wait_for(' ');
+                death(D_STARVATION);
+    }
+        player.t_action = A_FREEZE;
+        player.t_no_move = movement(&player) * (rnd(8) + 3);
+        if (!terse)
+            addmsg("You feel too weak from the lack of food. ");
+        msg("You faint");
+        running = FALSE;
+        if (fight_flush) flushinp();
+        count = 0;
+        hungry_state = F_FAINT;
+    }
+    else
+    {
+        oldfood = food_left;
+        food_use = 0;
+        for (i=0; i<MAXRELIC; i++) { /* each relic eats an additional food */
+            if (cur_relic[i])
+                food_use++;
+        }
+        /* Charge for wearing rings */
+        food_use +=    (ring_eat(LEFT_1)  + ring_eat(LEFT_2)  +
+                        ring_eat(LEFT_3)  + ring_eat(LEFT_4)  +
+                        ring_eat(RIGHT_1) + ring_eat(RIGHT_2) +
+            ring_eat(RIGHT_3) + ring_eat(RIGHT_4) +
+                        foodlev);
+        if (food_use < 1)
+            food_use = 1;
+        food_left -= food_use;
+        if (food_left < MORETIME && oldfood >= MORETIME) {
+            msg("You are starting to feel weak");
+            running = FALSE;
+            if (fight_flush) flushinp();
+            count = 0;
+            hungry_state = F_WEAK;
+        }
+        else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME)
+        {
+            msg(terse ? "Getting hungry" : "You are starting to get hungry");
+            running = FALSE;
+            hungry_state = F_HUNGRY;
+        }
+        else if(food_left<STOMACHSIZE-MORETIME && oldfood>=STOMACHSIZE-MORETIME)
+        {
+            hungry_state = F_OKAY;
+        }
+    }
+    if (old_hunger != hungry_state)  {
+        updpack(TRUE, &player);
+        status(TRUE);
+    }
+    wghtchk();
+}
+
+/*
+ * daemon for curing the diseased
+ */
+
+cure_disease()
+{
+    turn_off(player, HASDISEASE);
+    if (off (player, HASINFEST))
+        msg(terse ? "You feel yourself improving"
+                : "You begin to feel yourself improving again");
+}
+
+/*
+ * appear:
+ *      Become visible again
+ */
+ 
+appear()
+{
+    turn_off(player, ISINVIS);
+    PLAYER = VPLAYER;
+    msg("The tingling feeling leaves your body");
+    light(&hero);
+}
+
+/*
+ * dust_appear:
+ *      dust of disappearance wears off
+ */
+ 
+dust_appear()
+{
+    turn_off(player, ISINVIS);
+    PLAYER = VPLAYER;
+    msg("You become visible again");
+    light(&hero);
+}
+
+/*
+ * unchoke:
+ *      the effects of "dust of choking and sneezing" wear off
+ */
+ 
+unchoke()
+{
+    if (!find_slot(unconfuse))
+        turn_off(player, ISHUH);
+    if (!find_slot(sight))
+        turn_off(player, ISBLIND);
+    light(&hero);
+    msg("Your throat and eyes return to normal");
+}
+
+/*
+ * make some potion for the guy in the Alchemy jug
+ */
+ 
+alchemy(obj)
+register struct object *obj;
+{
+    register struct object *tobj = NULL;
+    register struct linked_list *item;
+
+    /*
+     * verify that the object pointer we have still points to an alchemy
+     * jug (hopefully the right one!) because the hero could have thrown
+     * it away
+     */
+    for (item = pack; item != NULL; item = next(item)) {
+        tobj = OBJPTR(item);
+        if (tobj         == obj         && 
+            tobj->o_type == MM          && 
+            tobj->o_which== MM_JUG      &&
+            tobj->o_ac   == JUG_EMPTY   )
+                break;
+    }
+    if (item == NULL) {         /* not in the pack, check the level */
+        for (item = lvl_obj; item != NULL; item = next(item)) {
+            tobj = OBJPTR(item);
+            if (tobj         == obj             && 
+                tobj->o_type == MM              && 
+                tobj->o_which== MM_JUG          &&
+                tobj->o_ac   == JUG_EMPTY       )
+                    break;
+        }
+    }
+    if (item == NULL)   /* can't find it.....too bad */
+        return;
+    
+    switch(rnd(11)) {
+        case 0: tobj->o_ac = P_PHASE;
+        when 1: tobj->o_ac = P_CLEAR;
+        when 2: tobj->o_ac = P_SEEINVIS;
+        when 3: tobj->o_ac = P_HEALING;
+        when 4: tobj->o_ac = P_MFIND;
+        when 5: tobj->o_ac = P_TFIND;
+        when 6: tobj->o_ac = P_HASTE;
+        when 7: tobj->o_ac = P_RESTORE;
+        when 8: tobj->o_ac = P_FLY;
+        when 9: tobj->o_ac = P_SKILL;
+        when 10:tobj->o_ac = P_FFIND;
+    }
+}
+
+/*
+ * otto's irresistable dance wears off 
+ */
+ 
+int
+undance()
+{
+    turn_off(player, ISDANCE);
+    msg ("Your feet take a break.....whew!");
+    return(0);
+}
+
+/* 
+ * if he has our favorite necklace of strangulation then take damage every turn
+ */
+ 
+strangle()
+{
+     if ((pstats.s_hpt -= 6) <= 0) {
+     pstats.s_hpt = -1;
+     death(D_STRANGLE);
+     }
+}
+
+/*
+ * if he has on the gauntlets of fumbling he might drop his weapon each turn
+ */
+ 
+fumble()
+{
+    register struct linked_list *item;
+
+    if (cur_weapon!=NULL                        &&
+        !(cur_weapon->o_flags & ISCURSED)       &&
+        cur_weapon->o_type != RELIC             &&
+        rnd(100)<3) {
+        for (item = pack; item != NULL; item = next(item)) {
+            if (OBJPTR(item) == cur_weapon)
+                break;
+        }
+        if (item != NULL) {
+            switch(mvwinch(stdscr, hero.y, hero.x)) {
+            case PASSAGE: 
+            case SCROLL:
+            case POTION:
+            case WEAPON:
+            case FLOOR:
+            case STICK:
+            case ARMOR:
+            case POOL:
+            case RELIC:
+            case GOLD:
+            case FOOD:
+            case RING:
+            case MM:
+                drop(item);
+                running = FALSE;
+                break;
+            default:
+                break;
+            }
+        }
+    }
+}
+
+/*
+ * This is called each turn the hero has the ring of searching on
+ * it's a lot like trap_look() 
+ */
+ 
+ring_search()
+{
+    if (rnd(75) < (2*dex_compute() + 5*pstats.s_lvl)) search(TRUE, FALSE);
+    else search(FALSE, FALSE);
+}
+
+/*
+ * this is called each turn the hero has the ring of teleportation on
+ */
+ 
+ring_teleport()
+{
+    if (rnd(100) < 3) teleport();
+}
+
+/* 
+ * this is called to charge up the quill of Nagrom
+ */
+ 
+quill_charge()
+{
+    register struct object *tobj = NULL;
+    register struct linked_list *item;
+
+    /*
+     * find the Quill of Nagrom in the hero's pack. It should still be there
+     * because it can't be dropped. If its not then don't do anything.
+     */
+    for (item = pack; item != NULL; item = next(item)) {
+        tobj = OBJPTR(item);
+        if (tobj->o_type == RELIC && tobj->o_which == QUILL_NAGROM)
+                break;
+    }
+    if (item == NULL)
+        return;
+    if (tobj->o_charges < QUILLCHARGES)
+        tobj->o_charges++;
+    fuse (quill_charge, (VOID *)NULL, player.t_ctype == C_MAGICIAN ? 4 : 8, AFTER);
+}
+
+/*
+ * take the skills away gained (or lost) by the potion of skills
+ */
+ 
+unskill()
+{
+    if (pstats.s_lvladj != 0) {
+        pstats.s_lvl -= pstats.s_lvladj;
+        pstats.s_lvladj = 0;
+        msg("You feel your normal skill level return.");
+        status(TRUE);
+    }
+}
+
+/*
+ * charge up the cloak of Emori
+ */
+ 
+int
+cloak_charge(obj)
+register struct object *obj;
+{
+    if (obj->o_charges < 1)
+        obj->o_charges = 1;
+    return(0);
+}
+
+/*
+ * nofire:
+ *      He lost his fire resistance
+ */
+ 
+nofire()
+{
+    if (!ISWEARING(R_FIRE)) {
+        turn_off(player, NOFIRE);
+        msg("Your feeling of fire resistance leaves you");
+    }
+}
+
+/*
+ * nocold:
+ *      He lost his cold resistance
+ */
+ 
+nocold()
+{
+    if (!ISWEARING(R_WARMTH)) {
+        turn_off(player, NOCOLD);
+        msg("Your feeling of warmth leaves you");
+    }
+}
+
+/*
+ * nobolt:
+ *      He lost his protection from lightning
+ */
+ 
+nobolt()
+{
+    turn_off(player, NOBOLT);
+    msg("Your skin loses its bluish tint");
+}
+
+/*
+ * eat_gold:
+ *      an artifact eats gold 
+ */
+ 
+eat_gold(obj)
+register struct object *obj;
+{
+    if (purse == 250)
+        msg("%s.. Bids you to find some more gold. ", inv_name(obj, FALSE));
+    if (purse == 100)
+        msg("%s.. Demands that you find more gold! ", inv_name(obj, FALSE));
+    if (purse == 50)
+        msg("%s.. Commands you to find more gold!! ", inv_name(obj, FALSE));
+    if (purse == 0) {
+    if (rnd(10) >= 7)
+        msg("You feel the artifact gnawing away... ");
+        if (--pstats.s_hpt < 1) {
+        pstats.s_hpt = -1;
+            death(D_RELIC);
+    }
+    }
+    else
+        purse--;
+}
+
+/*
+ * give the hero back some spell points
+ */
+ 
+spell_recovery()
+{
+    int time;
+
+    time = SPELLTIME - max(17-pstats.s_intel, 0);
+    time = max(time, 5);
+    if (spell_power > 0) spell_power--;
+    fuse(spell_recovery, (VOID *)NULL, time, AFTER);
+}
+
+/*
+ * give the hero back some prayer points
+ */
+ 
+prayer_recovery()
+{
+    int time;
+
+    time = SPELLTIME - max(17-pstats.s_wisdom, 0);
+    time = max(time, 5);
+    if (pray_time > 0) pray_time--;
+    fuse(prayer_recovery, (VOID *)NULL, time, AFTER);
+}
+
+/*
+ * give the hero back some chant points
+ */
+ 
+chant_recovery()
+{
+    int time;
+
+    time = SPELLTIME - max(17-pstats.s_wisdom, 0);
+    time = max(time, 5);
+    if (chant_time > 0) chant_time--;
+    fuse(chant_recovery, (VOID *)NULL, time, AFTER);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/eat.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,166 @@
+/*
+    eat.c  -  Functions for dealing with digestion
+
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <curses.h>
+#include "rogue.h"
+
+/*
+ * eat:
+ *      He wants to eat something, so let him try
+ */
+
+eat()
+{
+    register struct linked_list *item;
+    int which;
+    unsigned long temp;
+
+    if (player.t_action != C_EAT) {
+        if ((item = get_item(pack, "eat", FOOD, FALSE, FALSE)) == NULL)
+            return;
+
+        player.t_using = item;  /* Remember what it is */
+        player.t_action = C_EAT;        /* We are eating */
+        which = (OBJPTR(item))->o_which;
+        player.t_no_move = max(foods[which].mi_food/100, 1) * movement(&player);
+        return;
+    }
+
+    /* We have waited our time, let's eat the food */
+    item = player.t_using;
+    player.t_using = NULL;
+    player.t_action = A_NIL;
+
+    which = (OBJPTR(item))->o_which;
+    if ((food_left += foods[which].mi_food) > STOMACHSIZE)
+        food_left = STOMACHSIZE;
+    del_pack(item);
+    if (hungry_state == F_SATIATED && food_left == STOMACHSIZE && rnd(4) == 1) {
+        pstats.s_hpt = -1;
+        msg ("Cough!  Ack!  You choke on all that food and die!  --More--");
+        wait_for(' ');
+        death(D_FOOD_CHOKE);
+    }
+    if (food_left >= STOMACHSIZE-MORETIME) {
+        hungry_state = F_SATIATED;
+        msg ("You have trouble getting that food down!");
+        msg ("Your stomach feels like it's about to burst!");
+    }
+    else if (which != E_SLIMEMOLD) {
+        hungry_state = F_OKAY;
+        switch (rnd(10)) {
+        case 0: msg("Yuck, what a foul tasting %s! ", foods[which].mi_name);
+        when 1: msg("Mmmm, what a tasty %s. ", foods[which].mi_name);
+        when 2: msg("Wow, what a scrumptious %s! ", foods[which].mi_name);
+        when 3: msg("Hmmm, %s heaven! ", foods[which].mi_name);
+        when 4: msg("You've eaten better %s. ", foods[which].mi_name);
+        when 5: msg("You smack your lips ");
+        when 6: msg("Yum-yum-yum ");
+        when 7: msg("Gulp! ");
+        when 8: msg("Your tongue flips out! ");
+        when 9: msg("You lick your chin ");
+        }
+    }
+    updpack(TRUE, &player);
+    switch(which) {
+    case E_WHORTLEBERRY:    /* add 1 to intelligence */
+        (*add_abil[A_INTELLIGENCE])(1);
+    when E_SWEETSOP:    /* add 1 to strength */
+    case E_SOURSOP: /* add 1 to strength */
+        (*add_abil[A_STRENGTH])(1);
+    when E_SAPODILLA:   /* add 1 to wisdom */
+        (*add_abil[A_WISDOM])(1);
+    when E_APPLE:   /* add 1 to dexterity */
+        (*add_abil[A_DEXTERITY])(1);
+    when E_PRICKLEY:    /* add 1 to constitution */
+        (*add_abil[A_CONSTITUTION])(1);
+    when E_PEACH:   /* add 1 to charisma */
+        (*add_abil[A_CHARISMA])(1);
+    when E_PITANGA: /* add 1 hit point */
+        max_stats.s_hpt++;
+        pstats.s_hpt = max_stats.s_hpt;
+        msg("You feel a bit tougher now. ");
+    when E_HAGBERRY:    /* armor class */
+    case E_JABOTICABA:  /* armor class */
+        pstats.s_arm--;
+        msg("Your skin feels more resilient now. ");
+    when E_STRAWBERRY:  /* add 10% experience points */
+    case E_RAMBUTAN:    /* add 10% experience points */
+        temp = pstats.s_exp/100 + 10;
+        pstats.s_exp += temp;
+        msg("You feel slightly more experienced now. ");
+        check_level();
+    when E_DEWBERRY:    /* encourage him to do more magic */
+        if (chant_time > 0) {
+            chant_time -= 80;
+            if (chant_time < 0)
+                chant_time = 0;
+            msg("You feel you have more chant ability. ");
+        }
+        if (pray_time > 0) {
+            pray_time -= 80;
+            if (pray_time < 0)
+                pray_time = 0;
+            msg("You feel you have more prayer ability. ");
+        }
+        if (spell_power > 0) {
+            spell_power -= 80;
+            if (spell_power < 0)
+                spell_power = 0;
+            msg("You feel you have more spell casting ability. ");
+        }
+    when E_CANDLEBERRY: /* cure him */
+        if (on(player, HASINFEST) || 
+            on(player, HASDISEASE)|| 
+            on(player, DOROT)) {
+            if (on(player, HASDISEASE)) {
+                extinguish(cure_disease);
+                cure_disease();
+            }
+            if (on(player, HASINFEST)) {
+                msg("You feel yourself improving. ");
+                turn_off(player, HASINFEST);
+                infest_dam = 0;
+            }
+            if (on(player, DOROT)) {
+                msg("You feel your skin returning to normal. ");
+                turn_off(player, DOROT);
+            }
+        }
+    when E_SLIMEMOLD: /* monster food */
+    msg("The slime-mold quivers around in your mouth. ");
+        player.t_no_move = 3*movement(&player);
+        if (off(player, HASDISEASE)) {
+            if (ISWEARING(R_HEALTH) || player.t_ctype == C_PALADIN ||
+                player.t_ctype == C_RANGER) {
+        msg("You feel lousy. ");
+            }
+            else {
+                turn_on(player, HASDISEASE);
+                fuse(cure_disease, (VOID *)NULL, roll(HEALTIME,SICKTIME),AFTER);
+                msg("You become ill. ");
+            }
+    }
+        pstats.s_const -= rnd(2)+1;
+    if (pstats.s_const <= 3) pstats.s_const = 3;
+    
+    otherwise: /* not all the foods have to do something */
+        break;
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/effects.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,722 @@
+/*
+    effects.c  -  functions for dealing with appllying effects to monsters
+
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <string.h>
+#include <curses.h>
+#include "rogue.h"
+
+/*
+ * effect:
+ *      Check for effects of one thing hitting another thing.  Return
+ *      the reason code if the defender is killed.  Otherwise return 0.
+ */
+
+effect(att, def, weap, thrown, see_att, see_def)
+register struct thing *att, *def;
+struct object *weap;
+bool thrown;
+register bool see_att, see_def;
+{
+    register bool att_player, def_player;
+    char attname[LINELEN+1], defname[LINELEN+1];
+
+    /* See if the attacker or defender is the player */
+    att_player = (att == &player);
+    def_player = (def == &player);
+
+    /*
+     * If the player could see the attacker or defender, they can't
+     * surprise anymore (don't bother checking if they could).
+     */
+    if (see_att) turn_off(*att, CANSURPRISE);
+    if (see_def) turn_off(*def, CANSURPRISE);
+
+    /* What are the attacker and defender names? */
+    if (att_player) strcpy(attname, "you");
+    else {
+        if (see_att) strcpy(attname, monster_name(att));
+        else strcpy(attname, "something");
+    }
+
+    if (def_player) strcpy(defname, "you");
+    else {
+        if (see_def) strcpy(defname, monster_name(def));
+        else strcpy(defname, "something");
+    }
+
+    /*
+     * See what happens to the attacker first.  We can skip this
+     * whole section, however, if the defender is the player.
+     * Nothing happens (yet) to anyone just for hitting the player.
+     */
+    if (!def_player) {
+        if (!thrown) {  /* Some things require a direct hit. */
+            /*
+             * If the attacker hits a rusting monster, The weapon
+             * may be damaged
+             */
+            if (on(*def, CANRUST)       && weap                         &&
+                weap->o_type != RELIC   && (weap->o_flags & ISMETAL)    &&
+                !(weap->o_flags & ISPROT)) {
+                    if ((weap->o_hplus < 1 && weap->o_dplus < 1) ||
+                        roll(1,20) < weap->o_hplus+weap->o_dplus+10) {
+                            if (rnd(100) < 50) weap->o_hplus--;
+                            else               weap->o_dplus--;
+                            if (att_player)
+                                msg(terse ? "Your %s weakens!"
+                                          : "Your %s gets weaker!",
+                                    weaps[weap->o_which].w_name);
+                    }
+            }
+        }
+                
+        /* If the attacker hit something that shrieks, wake the dungeon */
+        if (on(*def, CANSHRIEK)) {
+            if (see_def)
+                msg("%s emits an ear piercing shriek! ", prname(defname, TRUE));
+            else
+                msg("You hear an ear piercing shriek!");
+
+            /* Friendly charactors should be immune */
+            if (player.t_ctype == C_PALADIN ||
+                player.t_ctype == C_RANGER  || player.t_ctype == C_MONK)
+                    aggravate(TRUE, FALSE);
+            else
+                aggravate(TRUE, TRUE);
+        }
+
+        /*
+         * does the creature explode when hit?
+         */
+        if (on(*def, CANEXPLODE)) {
+            if (see_def) msg("%s explodes!", prname(defname, TRUE));
+            else msg("You hear a tremendous explosion!");
+            explode(def);
+            if (pstats.s_hpt < 1) {
+        pstats.s_hpt = -1;
+                death(def->t_index);
+        }
+        }
+    }
+
+    /*
+     * Now let's see what happens to the defender.  Start out with
+     * the things that everyone can do.  Then exit if the attacker
+     * is the player.
+     */
+    if (!thrown) {
+        /* 
+         * Can the player confuse? 
+         */
+        if (on(*att, CANHUH) && att_player) {
+            msg("Your hands return to normal. ");
+            if (off(*def, ISCLEAR) && 
+               (off(*def, ISUNIQUE) || !save(VS_MAGIC, def, 0))) {
+                if (see_def) msg("%s appears confused!", prname(defname, TRUE));
+                turn_on(*def, ISHUH);
+            }
+            turn_off(*att, CANHUH);
+        }
+
+        /* Return now if the attacker is the player. */
+        if (att_player) return(0);
+
+        /*
+         * Some monsters may take half your hit points
+         */
+        if (on(*att, CANSUCK) && !save(VS_MAGIC, def, 0)) {
+            if (def->t_stats.s_hpt == 1) return(att->t_index); /* Killed! */
+            else {
+                def->t_stats.s_hpt /= 2;
+                if (def_player)
+                    msg("Your life force is being drained out of you.");
+            }
+        }
+
+        /*
+         * If a hugging monster hits, it may SQUEEEEEEEZE.
+         */
+        if (on(*att, CANHUG)) {
+            if (roll(1,20) >= 18 || roll(1,20) >= 18) {
+                if (def_player)
+                    msg("%s squeezes itself nastily against you!",
+                                prname(attname, TRUE));
+                else if (see_att)
+                    msg("%s squeezes real hard!", prname(attname, TRUE));
+
+                if ((def->t_stats.s_hpt -= roll(2,8)) <= 0)
+                    return(att->t_index);
+            }
+        }
+
+        /*
+         * Some monsters have poisonous bites.
+         */
+        if (on(*att, CANPOISON) && !save(VS_POISON, def, 0)) {
+            if (def_player) {
+                if (ISWEARING(R_SUSABILITY))
+                    msg(terse ? "Sting has no effect."
+                              : "A sting momentarily weakens your arm.");
+                else {
+                    chg_str(-1);
+                    msg(terse ? "A sting has weakened you." :
+                    "You get stung in the arm!  You feel weaker. ");
+                }
+            }
+            else {
+                /* Subtract a strength point and see if it kills it */
+                if (--def->t_stats.s_str <= 0) return(D_STRENGTH);
+            }
+        }
+
+        /*
+         * Turning to stone:
+         */
+        if (on(*att, TOUCHSTONE)) {
+            if (def_player) turn_off(*att, TOUCHSTONE);
+            if (on(*def, CANINWALL)) {
+                if (def_player)
+                    msg("%s's touch has no effect.", prname(attname, TRUE));
+            }
+            else {
+                if (!save(VS_PETRIFICATION, def, 0) && rnd(100) < 10) {
+                    if (def_player) {
+                        msg("Your body begins to solidify.. ");
+                        msg("You are transformed into stone!! --More--");
+                        wait_for(' ');
+                        return(D_PETRIFY);
+                    }
+                    else {
+                        /* The monster got stoned! */
+                        turn_on(*def, ISSTONE);
+                        turn_off(*def, ISRUN);
+                        turn_off(*def, ISINVIS);
+                        turn_off(*def, ISDISGUISE);
+                        if (def->t_stats.s_intel > 15)
+                            msg("%s staggers.. ", prname(defname, TRUE));
+                        else if (see_def)
+                            msg("%s turns to stone! ", prname(defname, TRUE));
+                        else if (cansee(unc(def->t_pos)))
+                            msg("A statue appears out of nowhere! ");
+                    }
+                }
+                else if (def->t_action != A_FREEZE) {
+                    if (def_player)
+                        msg("%s's touch stiffens your limbs.",
+                                        prname(attname, TRUE));
+                    else if (see_def)
+                        msg("%s appears to freeze over.", prname(defname, TRUE));
+
+                    def->t_no_move += movement(def) * STONETIME;
+                    def->t_action = A_FREEZE;
+                }
+            }
+        }
+
+        /*
+         * Wraiths might drain energy levels
+         */
+        if ((on(*att, CANDRAIN) || on(*att, DOUBLEDRAIN)) && 
+            !save(VS_POISON, def, 3-(att->t_stats.s_lvl/5))) {
+            if (def_player) {
+                lower_level(att->t_index);
+                if (on(*att, DOUBLEDRAIN)) lower_level(att->t_index);
+                turn_on(*att, DIDDRAIN);  
+            }
+            else {
+                def->t_stats.s_hpt -= roll(1, 8);
+                def->t_stats.s_lvl--;
+                if (on(*att, DOUBLEDRAIN)) {
+                    def->t_stats.s_hpt -= roll(1, 8);
+                    def->t_stats.s_lvl--;
+                }
+                if (see_def)
+                    msg("%s appears less skillful.", prname(defname, TRUE));
+
+                /* Did it kill it? */
+                if (def->t_stats.s_hpt <= 0 ||
+                    def->t_stats.s_lvl <= 0)
+                    return(att->t_index);
+            }
+        }
+
+        /*
+         * Paralyzation:
+         */
+        if (on(*att, CANPARALYZE) && def->t_action != A_FREEZE) {
+            if (def_player) turn_off(*att, CANPARALYZE);
+            if (!save(VS_PARALYZATION, def, 0)) {
+                if (on(*def, CANINWALL)) {
+                    if (def_player)
+                        msg("%s's touch has no effect.", prname(attname, TRUE));
+                }
+                else {
+                    if (def_player)
+                        msg("%s's touch paralyzes you.", prname(attname, TRUE));
+                    else if (see_def)
+                        msg("%s appears to freeze over!", prname(defname, TRUE));
+
+                    def->t_no_move += movement(def) * FREEZETIME;
+                    def->t_action = A_FREEZE;
+                }
+            }
+        }
+
+        /*
+         * Painful wounds make the defendant faint
+         */
+         if (on(*att, CANPAIN) && def->t_action != A_FREEZE) {
+            if (def_player) turn_off(*att, CANPAIN);
+            if (!ISWEARING(R_ALERT) && !save(VS_POISON, def, 0)) {
+                    if (def_player)
+                        msg("You faint from the painful wound!");
+                    else if (see_def)
+                        msg("%s appears to faint!", prname(defname, TRUE));
+
+                    def->t_no_move += movement(def) * PAINTIME;
+                    def->t_action = A_FREEZE;
+            }
+        }
+
+        /*
+         * Some things currently affect only the player.  Let's make
+         * a check here so we don't have to check for each thing.
+         */
+        if (def_player) {
+        /*
+         * Stinking monsters make the defender weaker (to hit).  For now
+         * this will only affect the player.  We may later add the HASSTINK
+         * effect to monsters, too.
+         */
+            if (on(*att, CANSTINK)) {
+                turn_off(*att, CANSTINK);
+                if (!save(VS_POISON, def, 0)) {
+                    msg("The stench of %s sickens you.  Blech!",
+                                prname(attname, FALSE));
+                    if (on(player, HASSTINK)) lengthen(unstink, STINKTIME);
+                    else {
+                        turn_on(player, HASSTINK);
+                        fuse(unstink, (VOID *)NULL, STINKTIME, AFTER);
+                    }
+                }
+            }
+
+            /*
+             * Chilling monster reduces strength each time.  This only
+             * affects the player for now because of its temporary nature.
+             */
+            if (on(*att, CANCHILL)) {
+                if (!ISWEARING(R_SUSABILITY) && !save(VS_POISON, def, 0)) {
+                    msg("You cringe at %s's chilling touch.",
+                                prname(attname, FALSE));
+                    chg_str(-1);
+                    if (lost_str++ == 0)
+                        fuse(res_strength, (VOID *)NULL, CHILLTIME, AFTER);
+                    else lengthen(res_strength, CHILLTIME);
+                }
+            }
+
+            /*
+             * Itching monsters reduce dexterity (temporarily).  This only
+             * affects the player for now because of its temporary nature.
+             */
+            if (on(*att, CANITCH) && !save(VS_POISON, def, 0)) {
+                msg("The claws of %s scratch you!", prname(attname, FALSE));
+                if (ISWEARING(R_SUSABILITY)) {
+                    msg("The scratch has no effect.");
+                }
+                else {
+                    (*add_abil[A_DEXTERITY])(-1);
+                }
+            }
+
+            /*
+             * If a disease-carrying monster hits, there is a chance the
+             * defender will catch the disease.  This only applies to the
+             * player for now because of the temporary nature. Don't affect
+             * the Ranger or Paladin.
+             */
+            if (on(*att, CANDISEASE) &&
+                (rnd(def->t_stats.s_const) < att->t_stats.s_lvl) &&
+                off(*def, HASDISEASE)) {
+                    if (ISWEARING(R_HEALTH)             ||
+                        player.t_ctype == C_PALADIN     ||
+                        player.t_ctype == C_RANGER) {
+                            msg("The wound heals quickly.");
+                    }
+                    else {
+                        turn_on(*def, HASDISEASE);
+                        fuse(cure_disease, (VOID *)NULL, roll(HEALTIME,SICKTIME), AFTER);
+                        msg(terse ? "You have been diseased!"
+                            : "You have contracted an annoying disease!");
+                    }
+            }
+
+            /*
+             * If a rusting monster hits, you lose armor.  This only applies to
+             * the player because monsters don't wear armor (for now).
+             */
+            if (on(*att, CANRUST)) { 
+                if (cur_armor != NULL                           &&
+                    cur_armor->o_which != LEATHER               &&
+                    cur_armor->o_which != STUDDED_LEATHER       &&
+                    cur_armor->o_which != PADDED_ARMOR          &&
+                    !(cur_armor->o_flags & ISPROT)              &&
+                    cur_armor->o_ac < def->t_stats.s_arm+1) {
+                        msg(terse ? "Your armor weakens."
+                            : "Your armor becomes weaker.");
+                        cur_armor->o_ac++;
+                }
+                if (cur_misc[WEAR_BRACERS] != NULL              &&
+                    cur_misc[WEAR_BRACERS]->o_ac > 0            &&
+                    !(cur_misc[WEAR_BRACERS]->o_flags & ISPROT)) {
+                        cur_misc[WEAR_BRACERS]->o_ac--;
+                        if (cur_misc[WEAR_BRACERS]->o_ac == 0) {
+                            register struct linked_list *item;
+
+                            for (item=pack; item!=NULL; item=next(item)) {
+                                if (OBJPTR(item) == cur_misc[WEAR_BRACERS]) {
+                                    detach(pack, item);
+                                    o_discard(item);
+                                    break;
+                                }
+                            }
+                            msg ("Your bracers crumble apart!");
+                            cur_misc[WEAR_BRACERS] = NULL;
+                            inpack--;
+                        }
+                        else {
+                            msg("Your bracers weaken!");
+                        }
+                }
+            }
+
+            /*
+             * If can dissolve and hero has leather type armor.  This
+             * also only applies to the player for now because of the
+             * armor.
+             */
+            if (on(*att, CANDISSOLVE) && cur_armor != NULL &&
+                (cur_armor->o_which == LEATHER            ||
+                 cur_armor->o_which == STUDDED_LEATHER    ||
+                 cur_armor->o_which == PADDED_ARMOR)      &&
+                !(cur_armor->o_flags & ISPROT) &&
+                cur_armor->o_ac < def->t_stats.s_arm+1) {
+                msg(terse ? "Your armor dissolves!"
+                    : "Your armor appears to have dissolved!");
+                cur_armor->o_ac++;
+            }
+
+            /*
+             * If an infesting monster hits you, you get a parasite or rot.
+             * This will only affect the player until we figure out how to
+             * make it affect monsters.  Don't affect the Monk.
+             */
+            if (on(*att, CANINFEST) &&
+                rnd(def->t_stats.s_const) < att->t_stats.s_lvl) {
+                if (ISWEARING(R_HEALTH) || player.t_ctype == C_MONK) {
+                        msg("The wound heals quickly.");
+                }
+                else {
+                    turn_off(*att, CANINFEST);
+                    msg(terse ? "You have been infested."
+                        : "You have contracted a parasitic infestation!");
+                    infest_dam++;
+                    turn_on(*def, HASINFEST);
+                }
+            }
+
+            /*
+             * Does it take wisdom away?  This currently affects only
+             * the player because of its temporary nature.
+             */
+            if (on(*att, TAKEWISDOM)            && 
+                !save(VS_MAGIC, def, 0) &&
+                !ISWEARING(R_SUSABILITY)) {
+                        (*add_abil[A_WISDOM])(-1);
+            }
+
+            /*
+             * Does it take intelligence away?  This currently affects
+             * only the player because of its temporary nature.
+             */
+            if (on(*att, TAKEINTEL)             && 
+                !save(VS_MAGIC, &player, 0)     &&
+                !ISWEARING(R_SUSABILITY)) {
+                        (*add_abil[A_INTELLIGENCE])(-1);
+            }
+
+            /*
+             * Cause fear by touching.  This currently affects only
+             * the player until we figure out how we want it to
+             * affect monsters.
+             */
+            if (on(*att, TOUCHFEAR)) {
+                turn_off(*att, TOUCHFEAR);
+                if (!ISWEARING(R_HEROISM)       &&
+                    !save(VS_WAND, def, 0)      &&
+                    !(on(*def, ISFLEE) && (def->t_dest == &att->t_pos))) {
+                        turn_on(*def, ISFLEE);
+                        def->t_dest = &att->t_pos;
+                        msg("%s's touch terrifies you!", prname(attname, TRUE));
+
+                        /* It is okay to turn tail */
+                        if (!def_player) def->t_oldpos = def->t_pos;
+                }
+            }
+
+            /*
+             * Make the hero dance (as in otto's irresistable dance)
+             * This should be fairly easy to do to monsters, but
+             * we'll restrict it to players until we decide what to
+             * do about the temporary nature.
+             */
+            if (on(*att, CANDANCE)              && 
+                !on(*def, ISDANCE)              &&
+                def->t_action != A_FREEZE       &&
+                !save(VS_MAGIC, def, -4)) {
+                    turn_off(*att, CANDANCE);
+                    turn_on(*def, ISDANCE);
+                    msg("You begin to dance uncontrollably!");
+                    fuse(undance, (VOID *)NULL, roll(2,4), AFTER);
+            }
+
+            /*
+             * Suffocating our hero.  Monsters don't get suffocated.
+             * That's too hard for now.
+             */
+            if (on(*att, CANSUFFOCATE)          && 
+                !ISWEARING(R_FREEDOM)           && 
+                rnd(100) < 30                   &&
+                (find_slot(suffocate) == 0)) {
+                turn_on(*att, DIDSUFFOCATE);
+                msg("%s is beginning to suffocate you!", prname(attname, TRUE));
+                fuse(suffocate, (VOID *)NULL, roll(9,3), AFTER);
+            }
+
+            /*
+             * some creatures stops the poor guy from moving.
+             * How can we do this to a monster?
+             */
+            if (on(*att,CANHOLD) && off(*att,DIDHOLD) && !ISWEARING(R_FREEDOM)){
+                turn_on(*def, ISHELD);
+                turn_on(*att, DIDHOLD);
+                hold_count++;
+            }
+
+            /*
+             * Sucker will suck blood and run.  This
+             * should be easy to have happen to a monster,
+             * but we have to decide how to handle the fleeing.
+             */
+            if (on(*att, CANDRAW)) {
+                turn_off(*att, CANDRAW);
+                turn_on(*att, ISFLEE);
+                msg("%s sates itself with your blood!", prname(attname, TRUE));
+                if ((def->t_stats.s_hpt -= 12) <= 0) return(att->t_index);
+
+                /* It is okay to turn tail */
+                att->t_oldpos = att->t_pos;
+            }
+
+            /*
+             * Bad smell will force a reduction in strength.
+             * This will happen only to the player because of
+             * the temporary nature.
+             */
+            if (on(*att, CANSMELL)) {
+                turn_off(*att, CANSMELL);
+                if (save(VS_MAGIC, def, 0) || ISWEARING(R_SUSABILITY)) {
+                    if (terse)
+                        msg("Pheww!");
+                    else
+                        msg("You smell an unpleasant odor.  Phew!");
+                    }
+
+                else {
+                    int odor_str = -(rnd(6)+1);
+
+                    msg("You are overcome by a foul odor!");
+                    if (lost_str == 0) {
+                        chg_str(odor_str);
+                        fuse(res_strength, (VOID *)NULL, SMELLTIME, AFTER);
+                        lost_str -= odor_str;
+                    }
+                    else lengthen(res_strength, SMELLTIME);
+                }
+            }
+
+            /*
+             * The monsters touch slows the defendant down.
+             */
+             if (on(*att, TOUCHSLOW)) {
+                turn_off(*att, TOUCHSLOW);
+                if (!save(VS_PARALYZATION, def, 0)) 
+                        add_slow();
+            }
+
+            /*
+             * Rotting only affects the player.  Don't affect the Monk,
+             * Paladin, or Ranger.
+             */
+            if (on(*att, CANROT)) {
+                if (!ISWEARING(R_HEALTH)        && 
+                    player.t_ctype != C_MONK    &&
+                    player.t_ctype != C_RANGER  &&
+                    player.t_ctype != C_PALADIN &&
+                    !save(VS_POISON, def, 0)    && 
+                    off(*def, DOROT)) {
+                    turn_on(*def, DOROT);
+                    msg("You feel your skin starting to rot and peel away!");
+                }
+            }
+
+            /*
+             * Monsters should be able to steal gold from anyone,
+             * but until this is rewritten, they will only steal
+             * from the player (tough break).
+             */
+            if (on(*att, STEALGOLD)) {
+                /*
+                 * steal some gold
+                 */
+                register long lastpurse;
+                register struct linked_list *item;
+                register struct object *obj;
+
+                lastpurse = purse;
+                purse -= (GOLDCALC * 2);
+                if (!save(VS_MAGIC, def, att->t_stats.s_lvl/10)) {
+                    if (on(*att, ISUNIQUE))
+                        purse -= (GOLDCALC * 5);
+                    else
+            purse -= (GOLDCALC * 3);
+                }
+                if (purse < 0)
+                    purse = 0;
+                if (purse != lastpurse) {
+                    msg("You lost some gold! ");
+
+                    /* Give the gold to the thief */
+                    for (item=att->t_pack; item != NULL; item=next(item)) {
+                        obj = OBJPTR(item);
+                        if (obj->o_type == GOLD) {
+                            obj->o_count += lastpurse - purse;
+                            break;
+                        }
+                    }
+
+                    /* Did we do it? */
+                    if (item == NULL) { /* Then make some */
+                        item = new_item(sizeof *obj);
+                        obj = OBJPTR(item);
+                        obj->o_type = GOLD;
+                        obj->o_count = lastpurse - purse;
+                        obj->o_hplus = obj->o_dplus = 0;
+                        strcpy(obj->o_damage,"0d0");
+                        strcpy(obj->o_hurldmg,"0d0");
+                        obj->o_ac = 11;
+                        obj->contents = NULL;
+                        obj->o_group = 0;
+                        obj->o_flags = 0;
+                        obj->o_mark[0] = '\0';
+                        obj->o_pos = att->t_pos;
+
+                        attach(att->t_pack, item);
+                    }
+                }
+
+                turn_on(*att, ISFLEE);
+                turn_on(*att, ISINVIS);
+
+                /* It is okay to turn tail */
+                att->t_oldpos = att->t_pos;
+            }
+        }
+
+        /*
+         * Stealing happens last since the monster disappears
+         * after the act.
+         */
+        if (on(*att, STEALMAGIC)) {
+            register struct linked_list *list, *steal;
+            register struct object *obj;
+            register int nobj;
+
+            /*
+             * steal a magic item, look through the pack
+             * and pick out one we like.
+             */
+            steal = NULL;
+            for (nobj = 0, list = def->t_pack; list != NULL; list = next(list))
+            {
+                obj = OBJPTR(list);
+                if (!is_current(obj)     &&
+                    list != def->t_using &&
+                    obj->o_type != RELIC &&
+                    is_magic(obj)        && 
+                    rnd(++nobj) == 0)
+                        steal = list;
+            }
+            if (steal != NULL)
+            {
+                register struct object *obj;
+                struct linked_list *item;
+
+                obj = OBJPTR(steal);
+                if (on(*att, ISUNIQUE))
+                    monsters[att->t_index].m_normal = TRUE;
+                item = find_mons(att->t_pos.y, att->t_pos.x);
+
+                killed(item, FALSE, FALSE, FALSE); /* Remove the attacker */
+
+                if (obj->o_count > 1 && obj->o_group == 0) {
+                    register int oc;
+
+                    oc = --(obj->o_count);
+                    obj->o_count = 1;
+                    if (def_player)
+                        msg("%s stole %s!", prname(attname, TRUE),
+                                        inv_name(obj, TRUE));
+                    obj->o_count = oc;
+                }
+                else {
+                    if (def_player) {
+                        msg("%s stole %s!", prname(attname, TRUE),
+                                        inv_name(obj, TRUE));
+
+                        /* If this is a relic, clear its holding field */
+                        if (obj->o_type == RELIC)
+                            cur_relic[obj->o_which] = 0;
+
+                        inpack--;
+                    }
+
+                    detach(def->t_pack, steal);
+                    o_discard(steal);
+                }
+
+                updpack(FALSE, def);
+            }
+        }
+    }
+
+    /* Didn't kill the defender */
+    return(0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/encumb.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,202 @@
+/*
+    encumb.c - Stuff to do with encumberance
+    
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <curses.h>
+#include "rogue.h"
+
+/*
+ * updpack:
+ *      Update his pack weight and adjust fooduse accordingly
+ */
+
+updpack(getmax, tp)
+int getmax;
+struct thing *tp;
+{
+
+        reg int topcarry, curcarry;
+
+        if (getmax)
+            tp->t_stats.s_carry = totalenc(tp); /* get total encumb */
+        curcarry = packweight(tp);              /* get pack weight */
+
+        /* Only update food use for the player (for now) */
+        if (tp == &player) {
+            topcarry = tp->t_stats.s_carry / 5; /* 20% of total carry */
+            if(curcarry > 4 * topcarry) {
+                if(rnd(100) < 80)
+                    foodlev = 3;                        /* > 80% of pack */
+            } else if(curcarry > 3 * topcarry) {
+                if(rnd(100) < 60)
+                    foodlev = 2;                        /* > 60% of pack */
+            } else
+                foodlev = 1;                    /* <= 60% of pack */
+        }
+        tp->t_stats.s_pack = curcarry;          /* update pack weight */
+}
+
+
+/*
+ * packweight:
+ *      Get the total weight of the hero's pack
+ */
+
+packweight(tp)
+register struct thing *tp;
+{
+        reg struct object *obj;
+        reg struct linked_list *pc;
+        reg int weight;
+
+        weight = 0;
+        for (pc = tp->t_pack ; pc != NULL ; pc = next(pc)) {
+            obj = OBJPTR(pc);
+            weight += itemweight(obj);
+        }
+        if (weight < 0)         /* in case of amulet */
+             weight = 0;
+
+        /* If this is the player, is he wearing a ring of carrying? */
+        if (tp == &player && ISWEARING(R_CARRY)) {
+            register int temp, i;
+
+            temp = 0;
+            for (i=0; i<NUM_FINGERS; i++) {
+                if (cur_ring[i] != NULL && cur_ring[i]->o_which == R_CARRY) {
+                    if (cur_ring[i]->o_flags & ISCURSED) temp--;
+                    else temp += 2;
+                }
+            }
+            weight -= (temp * weight) / 4;
+        }
+
+        return(weight);
+}
+
+/*
+ * itemweight:
+ *      Get the weight of an object
+ */
+
+itemweight(wh)
+reg struct object *wh;
+{
+        reg int weight;
+        reg int ac;
+
+        weight = wh->o_weight;          /* get base weight */
+        switch(wh->o_type) {
+            case ARMOR:
+                /*
+                 * subtract 10% for each enchantment
+                 * this will add weight for negative items
+                 */
+                ac = armors[wh->o_which].a_class - wh->o_ac;
+                weight = ((weight*10) - (weight*ac)) / 10;
+                if (weight < 0) weight = 0;
+            when WEAPON:
+                if ((wh->o_hplus + wh->o_dplus) > 0)
+                        weight /= 2;
+        }
+        if(wh->o_flags & ISCURSED)
+                weight += weight / 5;   /* 20% more for cursed */
+        weight *= wh->o_count;
+        return(weight);
+}
+
+/*
+ * playenc:
+ *      Get hero's carrying ability above norm
+ */
+
+playenc(tp)
+register struct thing *tp;
+{
+        register int strength;
+
+        if (tp == &player) strength = str_compute();
+        else strength = tp->t_stats.s_str;
+
+        return ((strength-8)*50);
+}
+
+/*
+ * totalenc:
+ *      Get total weight that the hero can carry
+ */
+
+totalenc(tp)
+register struct thing *tp;
+{
+        reg int wtotal;
+
+        wtotal = NORMENCB + playenc(tp);
+        if (tp == &player) switch(hungry_state) {
+                case F_SATIATED:
+                case F_OKAY:
+                case F_HUNGRY:  ;                       /* no change */
+                when F_WEAK:    wtotal -= wtotal / 10;  /* 10% off weak */
+                when F_FAINT:   wtotal /= 2;            /* 50% off faint */
+        }
+        return(wtotal);
+}
+
+/*
+ * whgtchk:
+ *      See if the hero can carry his pack
+ */
+
+wghtchk()
+{
+        reg int dropchk, err = TRUE;
+        reg char ch;
+        int wghtchk();
+
+        inwhgt = TRUE;
+        if (pstats.s_pack > pstats.s_carry) {
+            ch = mvwinch(stdscr, hero.y, hero.x);
+            if((ch != FLOOR && ch != PASSAGE)) {
+                extinguish(wghtchk);
+                fuse(wghtchk, (VOID *)NULL, 1, AFTER);
+                inwhgt = FALSE;
+                return;
+            }
+            extinguish(wghtchk);
+            msg("Your pack is far too heavy for you.. ");
+            do {
+                dropchk = drop((struct linked_list *)NULL);
+                if(dropchk == 0) {
+                    mpos = 0;
+                    msg("You must drop something");
+                }
+                if(dropchk == TRUE)
+                    err = FALSE;
+            } while(err);
+        }
+        inwhgt = FALSE;
+}
+
+/*
+ * hitweight:
+ *      Gets the fighting ability according to current weight
+ *      This returns a  +1 hit for light pack weight
+ *                       0 hit for medium pack weight
+ *                      -1 hit for heavy pack weight
+ */
+
+hitweight()
+{
+        return(2 - foodlev);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/fight.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,1474 @@
+/*
+    fight.c - All the fighting gets done here
+    
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/ 
+
+#include <curses.h>
+#include <ctype.h>
+#include <string.h>
+#include "rogue.h"
+
+#define CONF_DAMAGE     -1
+#define PARAL_DAMAGE    -2
+#define DEST_DAMAGE     -3
+#define DRAIN_DAMAGE    -4
+
+int killed_chance = 0;  /* cumulative chance for goodies to loose it */
+
+/*
+ * returns true if player has a any chance to hit the monster
+ */
+
+player_can_hit(tp, weap)
+register struct thing *tp;
+register struct object *weap;
+{
+    if (off(*tp, CMAGICHIT) && off(*tp, BMAGICHIT) && off(*tp, MAGICHIT))
+        return(TRUE);
+    if (weap && weap->o_type == RELIC)
+        return(TRUE);
+    if (on(*tp, CMAGICHIT) && weap && (weap->o_hplus>2 || weap->o_dplus>2))
+        return(TRUE);
+    if (on(*tp, BMAGICHIT) && weap && (weap->o_hplus>1 || weap->o_dplus>1))
+        return(TRUE);
+    if (on(*tp,  MAGICHIT) && weap && (weap->o_hplus>0 || weap->o_dplus>0))
+        return(TRUE);
+    if (player.t_ctype == C_MONK) {
+        if (on(*tp, CMAGICHIT) && pstats.s_lvl > 15)
+            return(TRUE);
+        if (on(*tp, BMAGICHIT) && pstats.s_lvl > 10)
+            return(TRUE);
+        if (on(*tp,  MAGICHIT) && pstats.s_lvl > 5)
+            return(TRUE);
+    }
+    return(FALSE);
+}
+
+/*
+ * fight:
+ *      The player attacks the monster.
+ */
+
+fight(mp, weap, thrown)
+register coord *mp;
+struct object *weap;
+bool thrown;
+{
+    register struct thing *tp;
+    register struct linked_list *item;
+    register bool did_hit = TRUE;
+    bool see_def, back_stab = FALSE;
+    register char *mname;
+
+    /*
+     * Find the monster we want to fight
+     */
+    if ((item = find_mons(mp->y, mp->x)) == NULL) {
+        return(FALSE); /* must have killed him already */
+    }
+    tp = THINGPTR(item);
+
+    /*
+     * Since we are fighting, things are not quiet so no healing takes
+     * place.  The -1 also tells us that we are in a fight.
+     */
+    player.t_quiet = -1;
+    tp->t_quiet = -1;
+
+    see_def = ((off(*tp, ISINVIS)     || on(player, CANSEE)) &&
+               (off(*tp, ISSHADOW)    || on(player, CANSEE)) &&
+               (!thrown || cansee(unc(tp->t_pos))));
+
+    mname = see_def ? monster_name(tp) : "something";
+
+    /*
+     * if its in the wall, we can't hit it
+     */
+    if (on(*tp, ISINWALL) && off(player, CANINWALL))
+        return(FALSE);
+
+    if (on(*tp, ISSTONE)) {
+        killed(item, FALSE, FALSE, FALSE);
+        if (see_def) 
+            msg("%s shatters into a million pieces!", prname(mname, TRUE));
+        count = 0;
+        return (TRUE);
+    }
+    /*
+     * Let him know it was really a mimic (if it was one).
+     */
+    if (on(*tp, ISDISGUISE) && (tp->t_type != tp->t_disguise) &&
+        off(player, ISBLIND))
+    {
+        if (see_def) {
+            msg("Wait! That's a %s!", mname);
+            turn_off(*tp, ISDISGUISE);
+        }
+        did_hit = thrown;
+    }
+    if (on(*tp, CANSURPRISE) && off(player, ISBLIND) && !ISWEARING(R_ALERT)) {
+        if (see_def) {
+            msg("Wait! There's a %s!", mname);
+            turn_off(*tp, CANSURPRISE);
+        }
+        did_hit = thrown;
+    }
+
+    /*
+     * if he's a thief or assassin and the creature is asleep then he gets 
+     * a chance for a backstab
+     */
+    if ((player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN) &&
+        !thrown          &&
+        !on(*tp, NOSTAB) &&
+        !invisible(tp)   &&
+        (!on(*tp, ISRUN) || on(*tp, ISHELD) || tp->t_action == A_FREEZE))
+            back_stab = TRUE;
+
+    /*
+     * assassins get an assassination chance, if it fails then its normal
+     * damage
+     */
+    if (back_stab && player.t_ctype == C_ASSASSIN) {
+        int chance;
+
+        chance = 50 + (pstats.s_lvl - tp->t_stats.s_lvl) * 5;
+        if (cur_weapon && (cur_weapon->o_flags & ISPOISON))
+            chance += 20;
+        if (roll(1,100) > chance || on(*tp, ISUNIQUE))
+            back_stab = FALSE;
+    }
+
+    runto(tp, &hero);
+
+    /* Let the monster know that the player has missiles! */
+    if (thrown) tp->t_wasshot = TRUE;
+
+    if (did_hit)
+    {
+
+        did_hit = FALSE;
+        if (!can_blink(tp)              && 
+            player_can_hit(tp, weap)    &&
+            roll_em(&player, tp, weap, thrown, cur_weapon, back_stab))
+        {
+            did_hit = TRUE;
+
+            if (on(*tp, NOMETAL) && weap != NULL &&
+                weap->o_type != RELIC && weap->o_flags & ISMETAL) {
+                msg("Your %s passes right through %s!",
+                    weaps[weap->o_which].w_name, prname(mname, FALSE));
+            }
+            else if (weap != NULL && weap->o_type == MISSILE && on(*tp, CARRYBAMULET)) {
+                    msg("The magic missile has no effect on %s. ",
+                        prname(mname, FALSE));
+            }
+            else {
+                hit(thrown ? (struct object *)NULL : weap,
+                    TRUE, see_def,
+                    thrown ? weap_name(weap) : NULL,
+                    mname, back_stab, thrown, terse);
+
+                /* See if there are any special effects */
+                if (effect(&player, tp, weap, thrown, TRUE, see_def) != 0)
+                    killed(item, FALSE, FALSE, TRUE);
+    
+                /* 
+                 * Merchants just disappear if hit 
+                 */
+                else if (on(*tp, CANSELL)) {
+                    if (see_def)
+                        msg("%s disappears with his wares in a flash! ",
+                            prname(mname, FALSE));
+                    killed(item, FALSE, FALSE, FALSE);
+                }
+    
+                else if (tp->t_stats.s_hpt <= 0)
+                    killed(item, TRUE, TRUE, TRUE);
+    
+                else {
+                    /* If the victim was charmed, it now gets a saving throw! */
+                    if (on(*tp, ISCHARMED) && save(VS_MAGIC, tp, 0)) {
+                        msg("The eyes of %s turn clear.", prname(mname, FALSE));
+                        turn_off(*tp, ISCHARMED);
+                    }
+
+                    dsrpt_monster(tp, FALSE, see_def); /* Disrupt a spell? */
+                }
+            }
+        }
+        else {
+            miss(thrown ? (struct object *)NULL : weap,
+                 TRUE, see_def,
+                 thrown ? weap_name(weap) : (char *)NULL,
+                 mname, thrown, terse);
+        }
+    }
+    count = 0;
+    return did_hit;
+}
+
+/*
+ * attack:
+ *      The monster attacks the player
+ */
+
+attack(mp, weapon, thrown)
+register struct thing *mp;
+register struct object *weapon;
+bool thrown;
+{
+    register char *mname;
+    register bool see_att, did_hit = FALSE;
+    register struct object *wielded;    /* The wielded weapon */
+    struct linked_list *get_wield;      /* Linked list header for wielded */
+
+    /*
+     * Since this is an attack, stop running and any healing that was
+     * going on at the time.  The -1 also tells us that we're fighting.
+     */
+    running = FALSE;
+    player.t_quiet = -1;
+    mp->t_quiet = -1;
+
+    if (on(*mp, ISDISGUISE) && off(player, ISBLIND))
+        turn_off(*mp, ISDISGUISE);
+
+    see_att = ((off(*mp, ISINVIS)     || on(player, CANSEE)) &&
+               (off(*mp, ISSHADOW)    || on(player, CANSEE)) &&
+               (!thrown || cansee(unc(mp->t_pos))));
+
+    mname = see_att ? monster_name(mp) : "something";
+
+    /*
+     * Try to find a weapon to wield.  Wield_weap will return a
+     * projector if weapon is a projectile (eg. bow for arrow).
+     * If weapon is NULL, it will try to find a suitable weapon.
+     */
+    get_wield = wield_weap(weapon, mp);
+    if (get_wield) wielded = OBJPTR(get_wield);
+    else wielded = NULL;
+
+    /* If we aren't wielding a weapon, wield what we found (could be NULL) */
+    if (weapon == NULL) weapon = wielded;
+
+    if (roll_em(mp, &player, weapon, thrown, wielded, FALSE)) {
+        int death_type; /* From one of the effects of getting hit */
+
+        did_hit = TRUE;
+
+        if (weapon != NULL && weapon->o_type == MISSILE && cur_relic[STONEBONES_AMULET]) {
+            hit(weapon, see_att, TRUE, mname, (char *)NULL, FALSE, thrown, terse);
+            msg("Your amulet absorbs the magic missile. ");
+        }
+        else {
+            hit(weapon, see_att, TRUE, mname, (char *)NULL, FALSE, thrown, terse);
+            dsrpt_player();     /* see if we disrupted some activity */
+            if (pstats.s_hpt <= 0)
+                death(mp->t_index);     /* Bye bye life ... */
+            death_type = effect(mp, &player, weapon, thrown, see_att, TRUE);
+            if (death_type != 0) {
+        pstats.s_hpt = -1;
+        death(death_type);
+        }
+        }
+
+    }
+    else {
+        /* If the thing was trying to surprise, no good */
+        if (on(*mp, CANSURPRISE)) turn_off(*mp, CANSURPRISE);
+
+        /* If it couldn't surprise, let's tell the player. */
+        else miss(weapon, see_att, TRUE, mname, (char *)NULL, thrown, terse);
+    }
+    if (fight_flush) flushinp();
+    count = 0;
+    status(FALSE);
+    return(did_hit);
+}
+
+/*
+ * swing:
+ *      returns true if the swing hits
+ */
+
+swing(class, at_lvl, op_arm, wplus)
+short class;
+int at_lvl, op_arm, wplus;
+{
+    register int res = rnd(20)+1;
+    register int need;
+
+    need = char_class[class].base -
+           char_class[class].factor *
+           ((min(at_lvl, char_class[class].max_lvl) -
+            char_class[class].offset)/char_class[class].range) +
+           (10 - op_arm);
+    if (need > 20 && need <= 25) need = 20;
+
+    return (res+wplus >= need);
+}
+
+/*
+ * roll_em:
+ *      Roll several attacks
+ */
+
+roll_em(att_er, def_er, weap, hurl, cur_weapon, back_stab)
+struct thing *att_er, *def_er;
+struct object *weap;
+bool hurl;
+struct object *cur_weapon;
+bool back_stab;
+{
+    register struct stats *att, *def;
+    register char *cp = NULL;
+    register int ndice, nsides, nplus, def_arm;
+    char dmgbuf[20];
+    bool did_hit = FALSE;
+    int prop_hplus, prop_dplus;
+    int vampiric_damage;
+
+    /* Get statistics */
+    att = &att_er->t_stats;
+    def = &def_er->t_stats;
+
+    prop_hplus = prop_dplus = 0;
+    if (weap == NULL) {
+        /*
+         * monks damage grows with level
+         */
+        if (att == &pstats && player.t_ctype == C_MONK) {
+            sprintf(dmgbuf, "%dd4", att->s_lvl/3+2);
+            cp = dmgbuf;
+        }
+        else
+            cp = att->s_dmg;
+    }
+    else if (weap->o_type == RELIC) {
+        switch (weap->o_which) {
+            case MUSTY_DAGGER:
+            if (player.t_ctype == C_THIEF) 
+            cp = "4d8+2/4d8+2";
+        else
+                cp = "4d8/4d8";
+            when YEENOGHU_FLAIL:
+            cp = "4d8+3/paralyze/confuse";
+            when HRUGGEK_MSTAR:
+            cp = "4d8+3";
+            when AXE_AKLAD:
+            if (player.t_ctype == C_FIGHTER) {
+            if (hurl)
+            cp = "4d8+6/drain";
+                    else
+            cp = "4d8+4/drain";
+        }
+        else {
+            if (hurl)
+            cp = "4d8+4/drain";
+                    else
+            cp = "4d8+2/drain";
+                }
+            when MING_STAFF:
+                cp = "4d8+4";
+            when ASMO_ROD:
+                cp = "4d8/4d8";
+            when ORCUS_WAND:
+            cp = "4d8/destroy";
+        }
+    }
+    else if (hurl) {
+        if ((weap->o_flags&ISMISL) && cur_weapon != NULL &&
+          cur_weapon->o_which == weap->o_launch)
+        {
+            cp = weap->o_hurldmg;
+            prop_hplus = cur_weapon->o_hplus;
+            prop_dplus = cur_weapon->o_dplus;
+        }
+        else
+            cp = (weap->o_flags&ISMISL ? weap->o_damage : weap->o_hurldmg);
+    }
+    else {
+        cp = weap->o_damage;
+        /*
+         * Drain a staff of striking
+         */
+        if(weap->o_type==STICK && weap->o_which==WS_HIT && weap->o_charges==0)
+        {
+            strcpy(weap->o_damage,"4d8");
+            weap->o_hplus = weap->o_dplus = 0;
+        }
+    }
+    /*
+     * If defender is wearing a cloak of displacement -- no damage
+     * the first time. (unless its a hurled magic missile or the
+     * attacker is very smart and can see thru the illusion)
+     */
+    if ((weap == NULL || weap->o_type != MISSILE)       &&
+        def == &pstats                                  &&      
+        off(*att_er, MISSEDDISP)                        &&
+        att->s_intel < 21                               &&
+        ((cur_misc[WEAR_CLOAK]!=NULL && 
+          cur_misc[WEAR_CLOAK]->o_which==MM_DISP) ||
+          cur_relic[EMORI_CLOAK])) {
+        turn_on(*att_er, MISSEDDISP);
+        if (cansee(att_er->t_pos.y, att_er->t_pos.x) && !invisible(att_er))
+            msg("%s looks amazed! ", prname(monster_name(att_er), TRUE));
+        return (FALSE);
+    }
+    if (on(*def_er, CARRYCLOAK)                         && 
+        def != &pstats                                  && 
+        (weap == NULL || weap->o_type != MISSILE)       && 
+        off (*att_er, MISSEDDISP)                       &&
+        pstats.s_intel < 21) {
+            turn_on(*att_er, MISSEDDISP);
+            msg("You feel amazed! ");
+            return(FALSE);
+    }
+    for (;;)
+    {
+        int damage;
+        int hplus = prop_hplus;
+        int dplus = prop_dplus;
+
+        if (weap != NULL && weap->o_type == RELIC) {
+            switch (weap->o_which) {
+                case MUSTY_DAGGER:
+                    if (att != &pstats || /* Not player or good stats */
+                        (str_compute() > 15 && dex_compute() > 15)) {
+
+                        hplus += 6;
+                        dplus += 6;
+
+                        /* Give an additional strength and dex bonus */
+                        if (att == &pstats) {
+                            hplus += str_plus(str_compute()) +
+                                     dext_plus(dex_compute());
+                            dplus += dext_plus(dex_compute()) +
+                                     add_dam(str_compute());
+                        }
+                        else {
+                            hplus += str_plus(att->s_str) +
+                                     dext_plus(att->s_dext);
+                            dplus += dext_plus(att->s_dext) +
+                                     add_dam(att->s_str);
+                        }
+                    }
+                    else {
+                        hplus -= 3;
+                        dplus -= 3;
+                    }
+                when YEENOGHU_FLAIL:
+                case HRUGGEK_MSTAR:
+                    hplus += 3;
+                    dplus += 3;
+                when MING_STAFF:
+                    hplus += 2;
+                    dplus += 2;
+                when AXE_AKLAD:
+                    hplus += 5;
+                    dplus += 5;
+            }
+        }
+        else if (weap != NULL) {
+            hplus += weap->o_hplus;
+            dplus += weap->o_dplus;
+        }
+
+        /* Is attacker weak? */
+        if (on(*att_er, HASSTINK)) hplus -= 2;
+
+        if (att == &pstats)     /* Is the attacker the player? */
+        {
+            hplus += hitweight();       /* adjust for encumberence */
+            dplus += hung_dam();        /* adjust damage for hungry player */
+            dplus += ring_value(R_ADDDAM);
+        }
+        if (back_stab || (weap && att != &pstats && on(*att_er, CANBSTAB)))
+            hplus += 4; /* add in pluses for backstabbing */
+
+        /* Get the damage */
+        while (isspace(*cp)) cp++;
+        if (!isdigit(*cp)) {
+            if (strncmp(cp, "confuse", 7) == 0) ndice = CONF_DAMAGE;
+            else if (strncmp(cp, "paralyze", 8) == 0) ndice = PARAL_DAMAGE;
+            else if (strncmp(cp, "destroy", 6) == 0) ndice = DEST_DAMAGE;
+            else if (strncmp(cp, "drain", 5) == 0) ndice = DRAIN_DAMAGE;
+            else ndice = 0;
+            nsides = 0;
+            nplus = 0;
+        }
+        else {
+            char *oldcp;
+
+            /* Get the number of damage dice */
+            ndice = atoi(cp);
+            if ((cp = strchr(cp, 'd')) == NULL)
+                break;
+
+            /* Skip the 'd' and get the number of sides per die */
+            nsides = atoi(++cp);
+
+            /* Check for an addition -- save old place in case none is found */
+            oldcp = cp;
+            if ((cp = strchr(cp, '+')) != NULL) nplus = atoi(++cp);
+            else {
+                nplus = 0;
+                cp = oldcp;
+            }
+        }
+
+        if (def == &pstats) { /* Monster attacks player */
+            if (on(*att_er, NOMETAL))
+                def_arm = ac_compute(TRUE) - dext_prot(dex_compute());
+            else
+                def_arm = ac_compute(FALSE) - dext_prot(dex_compute());
+            hplus += str_plus(att->s_str)+dext_plus(att->s_dext);
+        }
+        else if (att == &pstats) {      /* Player attacks monster */
+            def_arm = def->s_arm - dext_prot(def->s_dext);
+            if (player.t_ctype == C_MONK) /* no strength bonus for monk */
+                if (weap == NULL) 
+                    hplus += att->s_lvl/5; /* monks hplus varies with level */
+            else
+                hplus += str_plus(str_compute())+dext_plus(dex_compute());
+        }
+        else {  /* Monster attacks monster */
+            def_arm = def->s_arm - dext_prot(def->s_dext);
+            hplus += str_plus(att->s_str)+dext_plus(att->s_dext);
+        }
+
+        if (swing(att_er->t_ctype, att->s_lvl, def_arm, hplus)) {
+            register int proll;
+
+            /* Take care of special effects */
+            switch (ndice) {
+              case CONF_DAMAGE:
+                if (def == &pstats) { /* Monster attacks player */
+                    if (!save(VS_MAGIC, &player, 0) && off(player, ISCLEAR)) {
+                        msg("You feel disoriented.");
+                        if (find_slot(unconfuse))
+                            lengthen(unconfuse, HUHDURATION);
+                        else
+                            fuse(unconfuse, (VOID *)NULL, HUHDURATION, AFTER);
+                        turn_on(player, ISHUH);
+                    }
+                    else msg("You feel dizzy, but it quickly passes.");
+                }
+                /* Player or monster hits monster */
+                else if (!save(VS_MAGIC, def_er, 0) && off(*def_er, ISCLEAR)) { 
+                    if (att == &pstats) {
+            if (rnd(10) > 6)
+                            msg("The artifact warms you with pleasure! ");
+            }
+                    turn_on(*def_er, ISHUH);
+                }
+                did_hit = TRUE;
+              when PARAL_DAMAGE:
+                if (def == &pstats) { /* Monster attacks player */
+                    if (!save(VS_MAGIC, &player, 0) && off(player, CANINWALL)) {
+                        msg("You stiffen up.");
+                        player.t_no_move += movement(&player) * FREEZETIME;
+                        player.t_action = A_FREEZE;
+                    }
+                }
+                else if (!save(VS_MAGIC, def_er, 0)) { /* Player hits monster */
+                    if (att == &pstats) {
+            if (rnd(10) > 6)
+                msg("The artifact hums happily! ");
+            }
+                    turn_off(*def_er, ISRUN);
+                    turn_on(*def_er, ISHELD);
+                }
+                did_hit = TRUE;
+              when DEST_DAMAGE:
+                if (def == &pstats) {   /* Monster attacks player */
+            if (rnd(10) > 5)
+                        msg("You feel a tug at your life force.");
+                    if (!save(VS_MAGIC, &player, -4)) {
+                        msg("The wand devours your soul!  --More--");
+            wait_for(' ');
+                        def->s_hpt = -1;
+            death(D_RELIC);
+                    }
+                }
+                /* Player hits monster */
+                else if (!save(VS_MAGIC, def_er, -4)) {
+                    if (att == &pstats) {
+            if (rnd(10) > 4)
+                            msg("The artifact draws some energy.");
+                     }
+                    /* The player loses some major hit pts  */
+                    att->s_hpt -= (att->s_hpt/5)+1;
+            if (att->s_hpt <= 0) {
+            msg("The wand has devoured your soul!  --More--");
+            wait_for(' ');
+            att->s_hpt = -1;
+            death(D_RELIC);
+            }
+                    /* Kill the monster */
+                    def->s_hpt = 0;
+                }
+                did_hit = TRUE;
+            when DRAIN_DAMAGE:
+                if (def == &pstats) {       /* Monster attacks player */
+                    if (!save(VS_MAGIC, &player, -4)) {
+                        lower_level(att_er->t_index);
+                    }
+                }
+                /* Player hits monster */
+                else if (!save(VS_MAGIC, def_er, -4)) {
+                    def->s_hpt -= roll(1, 8);
+                    def->s_lvl--;
+                    if (def->s_lvl <= 0)
+                        def->s_hpt = 0;     /* he's dead */
+                    if (att == &pstats) {
+            if (rnd(10) > 7)
+                        msg("The artifact cackles with laughter! ");
+            }
+                }
+                did_hit = TRUE;
+              otherwise:
+                /* Heil's ankh always gives maximum damage */
+                if (att == &pstats && cur_relic[HEIL_ANKH])
+                    proll = ndice * nsides;
+                else proll = roll(ndice, nsides);
+
+                if (ndice + nsides > 0 && proll < 1)
+                    debug("Damage for %dd%d came out %d.",
+                                ndice, nsides, proll);
+                damage = dplus + proll + nplus;
+                if (att == &pstats) {
+                    /*
+                     * Monks do not get strength bonus on damage.  Instead,
+                     * if they are wielding a weapon, they get at extra
+                     * 1/2 point per level of damage.
+                     */
+                    if(player.t_ctype == C_MONK) {
+                        /* Bonus does not apply for hands. */
+                        if (weap != NULL) damage += att->s_lvl / 2;
+                    }
+                    else
+                        damage += add_dam(str_compute());
+                }
+                else
+                    damage += add_dam(att->s_str);
+
+                /* Check for half damage monsters */
+                if (on(*def_er, HALFDAMAGE)) damage /= 2;
+
+                /* add in multipliers for backstabbing */
+                if (back_stab || 
+                    (weap && att != &pstats && on(*att_er, CANBSTAB))) {
+                    int mult = 2 + (att->s_lvl-1)/4; /* Normal multiplier */
+
+                    if (mult > 5)
+                        mult = 5;
+                    if (weap && weap->o_type == RELIC && 
+                        weap->o_which == MUSTY_DAGGER)
+                        mult++;
+                    damage *= mult;
+                }
+                if (att == &pstats) {
+                    if (cur_weapon && (cur_weapon->o_flags & ISPOISON)) {
+                        cur_weapon->o_flags &= ~ISPOISON;
+                        if (save(VS_POISON, def_er, -2))
+                            damage += def->s_hpt/4;
+                        else
+                            damage += def->s_hpt/2;
+                    }
+                    if (back_stab && player.t_ctype == C_ASSASSIN)
+                        damage = def->s_hpt + 1;
+                }
+                /* Check for no-damage and division */
+                if (on(*def_er, BLOWDIVIDE)) {
+                    damage = 0;
+                    creat_mons(def_er, def_er->t_index, FALSE);
+                    if (cansee(unc(def_er->t_pos))) light(&hero);
+                }
+                /* check for immunity to metal -- RELICS are always bad */
+                if (on(*def_er, NOMETAL) && weap != NULL &&
+                    weap->o_type != RELIC && weap->o_flags & ISMETAL) {
+                    damage = 0;
+                }
+                if (weap != NULL && weap->o_type == MISSILE) {
+                    if ((def == &pstats && cur_relic[STONEBONES_AMULET]) ||
+                        (att == &pstats && on(*def_er, CARRYBAMULET))) {
+                        damage = 0;
+                    }
+                }
+                def->s_hpt -= max(0, damage);   /* Do the damage */
+                did_hit = TRUE;
+                vampiric_damage = damage;
+                if (def->s_hpt < 0)     /* only want REAL damage inflicted */
+                    vampiric_damage += def->s_hpt;
+                if (vampiric_damage < 0)
+                    vampiric_damage = 0;
+                if (att == &pstats && ISWEARING(R_VAMPREGEN) && !hurl) {
+                    if ((pstats.s_hpt += vampiric_damage/2) > max_stats.s_hpt)
+                        pstats.s_hpt = max_stats.s_hpt;
+                }
+        if (hplus < 0) hplus = 0;
+        if (damage < 0) damage = 0;
+                debug ("hplus=%d dmg=%d", hplus, damage);
+            }
+        }
+        if ((cp = strchr(cp, '/')) == NULL)
+            break;
+        cp++;
+    }
+    return did_hit;
+}
+
+/*
+ * prname:
+ *      The print name of a combatant
+ */
+
+char *
+prname(who, upper)
+register char *who;
+bool upper;
+{
+    static char tbuf[LINELEN];
+
+    *tbuf = '\0';
+    if (who == 0)
+        strcpy(tbuf, "you"); 
+    else if (on(player, ISBLIND) || strcmp(who, "something") == 0)
+        strcpy(tbuf, "something");
+    else
+    {
+        /* If we have a name (starts with a capital), don't use a "the" */
+        if (islower(*who)) strcpy(tbuf, "the ");
+        strcat(tbuf, who);
+    }
+    if (upper)
+        *tbuf = toupper(*tbuf);
+    return tbuf;
+}
+
+/*
+ * hit:
+ *      Print a message to indicate a succesful hit
+ */
+
+hit(weapon, see_att, see_def, er, ee, back_stab, thrown, short_msg)
+register struct object *weapon;
+bool see_att, see_def;
+register char *er, *ee;
+bool back_stab, thrown, short_msg;
+{
+    register char *s = NULL;
+    char          att_name[LINELEN],    /* Name of attacker */
+                  def_name[LINELEN]; /* Name of defender */
+
+    /* If we can't see either the attacker or defender, don't say anything */
+    if (!see_att && !see_def) return;
+
+    /* What do we call the attacker? */
+    strcpy(att_name, see_att ? prname(er, TRUE) : "Something");
+    if (er) {   /* A monster is attacking */
+
+        /* If the monster is using a weapon and we can see it, report it */
+        if (weapon != NULL && (see_att || thrown)) {
+            strcat(att_name, "'s ");
+            strcat(att_name, weap_name(weapon));
+        }
+    }
+
+    /* What do we call the defender? */
+    strcpy(def_name, see_def ? prname(ee, FALSE) : "something");
+
+    addmsg(att_name);
+    if (short_msg) {
+        if (back_stab) {
+            if (player.t_ctype == C_ASSASSIN)
+                s = (er == 0 ? " assassinate!" : " assassinates!");
+            else
+                s = (er == 0 ? " backstab!" : " backstabs!");
+        }
+        else
+            s = " hit.";
+    }
+    else {
+        if (back_stab) {
+            if (player.t_ctype == C_ASSASSIN)
+                s = (er == 0 ? " have assassinated " : " has assassinated ");
+            else
+                s = (er == 0 ? " have backstabbed " : " has backstabbed ");
+        }
+        else {
+            switch (rnd(thrown ? 2 : 3))
+            {
+                case 0: s = " hit ";
+                when 1: s = " injured ";
+                when 2: s = " smacked ";
+            }
+        }
+    }
+    if (short_msg) addmsg(s);
+    else addmsg("%s%s.", s, def_name);
+    endmsg();
+}
+
+/*
+ * miss:
+ *      Print a message to indicate a poor swing
+ */
+
+miss(weapon, see_att, see_def, er, ee, thrown, short_msg)
+register struct object *weapon;
+bool see_att, see_def;
+register char *er, *ee;
+bool thrown, short_msg;
+{
+    register char *s = NULL;
+    char          att_name[LINELEN],    /* Name of attacker */
+                  def_name[LINELEN];    /* Name of defender */
+
+    /* If we can't see either the attacker or defender, don't say anything */
+    if (!see_att && !see_def) return;
+
+    /* What do we call the attacker? */
+    strcpy(att_name, see_att ? prname(er, TRUE) : "Something");
+    if (er) {   /* A monster is attacking */
+
+        /* If the monster is using a weapon and we can see it, report it */
+        if (weapon != NULL && (see_att || thrown)) {
+            strcat(att_name, "'s ");
+            strcat(att_name, weap_name(weapon));
+        }
+    }
+
+    /* What do we call the defender? */
+    strcpy(def_name, see_def ? prname(ee, FALSE) : "something");
+
+    addmsg(att_name);
+    switch (short_msg ? 0 : rnd(thrown ? 3 : 2))
+    {
+        case 0: s = (er == 0 ? " miss" : " misses");
+        when 1: s = (er == 0 ? " don't hit" : " doesn't hit");
+        when 2: s = (" whizzes by");
+    }
+    if (short_msg) addmsg("%s.", s);
+    else addmsg("%s %s.", s, def_name);
+    endmsg();
+}
+
+/*
+ * dext_plus:
+ *      compute to-hit bonus for dexterity
+ */
+
+dext_plus(dexterity)
+register int dexterity;
+{
+        return (dexterity > 10 ? (dexterity-13)/3 : (dexterity-10)/3);
+}
+
+
+/*
+ * dext_prot:
+ *      compute armor class bonus for dexterity
+ */
+
+dext_prot(dexterity)
+register int dexterity;
+{
+    return ((dexterity-10)/2);
+}
+
+/*
+ * str_plus:
+ *      compute bonus/penalties for strength on the "to hit" roll
+ */
+
+str_plus(str)
+register short str;
+{
+    return((str-10)/3);
+}
+
+/*
+ * add_dam:
+ *      compute additional damage done for exceptionally high or low strength
+ */
+
+add_dam(str)
+register short str;
+{
+    return((str-9)/2);
+}
+
+/*
+ * hung_dam:
+ *      Calculate damage depending on players hungry state
+ */
+
+hung_dam()
+{
+        reg int howmuch = 0;
+
+        switch(hungry_state) {
+                case F_SATIATED:
+                case F_OKAY:
+                case F_HUNGRY:  howmuch = 0;
+                when F_WEAK:    howmuch = -1;
+                when F_FAINT:   howmuch = -2;
+        }
+        return howmuch;
+}
+
+/*
+ * is_magic:
+ *      Returns true if an object radiates magic
+ */
+
+is_magic(obj)
+register struct object *obj;
+{
+    switch (obj->o_type)
+    {
+        case ARMOR:
+            return obj->o_ac != armors[obj->o_which].a_class;
+        when WEAPON:
+            return obj->o_hplus != 0 || obj->o_dplus != 0;
+        when POTION:
+        case SCROLL:
+        case STICK:
+        case RING:
+        case MM:
+        case RELIC:
+            return TRUE;
+    }
+    return FALSE;
+}
+
+/*
+ * killed:
+ *      Called to put a monster to death
+ */
+
+killed(item, pr, points, treasure)
+register struct linked_list *item;
+bool pr, points, treasure;
+{
+    register struct thing *tp, *mp;
+    register struct linked_list *pitem, *nexti, *mitem;
+    char *monst;
+    int adj;    /* used for hit point adj. below. */
+    long temp;
+
+    tp = THINGPTR(item);
+
+    if (pr)
+    {
+        addmsg(terse ? "Defeated " : "You have defeated ");
+        if (on(player, ISBLIND))
+            msg("it.");
+        else
+        {
+            if (cansee(tp->t_pos.y, tp->t_pos.x) && !invisible(tp))
+                monst = monster_name(tp);
+            else {
+                if (terse) monst = "something";
+                else monst = "thing";
+            }
+            if (!terse)
+                addmsg("the ");
+            msg("%s.", monst);
+        }
+    }
+
+    /* Take care of any residual effects of the monster */
+    check_residue(tp);
+
+    /* Make sure that no one is still chasing us */
+    for (mitem = mlist; mitem != NULL; mitem = next(mitem)) {
+        mp = THINGPTR(mitem);
+        if (mp->t_dest == &tp->t_pos) {
+            mp->t_dest = &hero;
+            mp->t_wasshot = FALSE;
+            turn_off(*mp, ISFLEE);      /* Be sure we aren't running away! */
+        }
+    }
+    if (points) {   /* you feel uneasy for a moment */
+        if ((off(*tp, ISMEAN) || on(*tp, ISFRIENDLY)) &&
+            (player.t_ctype == C_RANGER || player.t_ctype == C_PALADIN ||
+             player.t_ctype == C_MONK)) {
+                if (tp->t_stats.s_exp > pstats.s_exp)
+                    pstats.s_exp = 0;
+                else
+                    pstats.s_exp -= tp->t_stats.s_exp;
+                /* Take care of hit points. */
+                if (level <= 12) adj = rnd(2)+1;
+                else if (level <= 25) adj = rnd(3)+2;
+                else if (level <= 50) adj = rnd(4)+3;
+                else if (level <= 80) adj = rnd(5)+4;
+                else adj = rnd(6)+5;
+        /* adjust hit points */
+                max_stats.s_hpt -= adj;
+                pstats.s_hpt -= adj;
+                /* Are hit points now too low? */
+                if (pstats.s_hpt <= 0) {
+            pstats.s_hpt = -1;
+            death(D_STRENGTH);
+        }
+                killed_chance += rnd(3)+1;
+                if (on(*tp, ISUNIQUE)) /* real bad news to kill a diety */
+                    killed_chance += 25;
+                if (roll(1,100) < killed_chance) {
+            msg("You had a feeling this was going to happen... ");
+                    msg("**POOF**  ");
+                    temp = C_ASSASSIN;  /* make him pay */
+                    changeclass(&temp);
+                }
+                else {
+                    switch (rnd(9)) {
+                    case 0:
+            msg("You become solid and stiff for a while. ");
+                        player.t_no_move += (5*movement(&player)*FREEZETIME);
+                        player.t_action = A_FREEZE;
+                    when 1:
+            msg("You collapse, losing it totally. ");
+                        player.t_no_move += (2*movement(&player)*FREEZETIME);
+                        player.t_action = A_FREEZE;
+                    when 2:
+            msg("Your face changes shape!  ARGGHH!!!! ");
+                        pstats.s_charisma -= rnd(8)+3;
+                        if (pstats.s_charisma <= 3) pstats.s_charisma = 3;
+                    when 3:
+            case 4:
+            msg("You cry out, I didn't mean to do that!  Honest!! ");
+                        player.t_no_move += (movement(&player)*FREEZETIME);
+            msg("The Great Old Ones grant you a reprieve. ");
+                    otherwise: msg("You feel uneasy for a moment.. ");
+                    }
+        }
+        }
+        else {
+                unsigned long test;      /* For overflow check */
+                /* 
+                 * Do an overflow check before increasing experience 
+                 */
+                test = pstats.s_exp + tp->t_stats.s_exp;
+                if (test > pstats.s_exp) 
+                        pstats.s_exp = test;
+        }
+
+        /*
+         * Do adjustments if he went up a level
+         */
+        check_level();
+    }
+
+    /*
+     * Empty the monsters pack
+     */
+    pitem = tp->t_pack;
+
+    /*
+     * Get rid of the monster.
+     */
+    mvwaddch(mw, tp->t_pos.y, tp->t_pos.x, ' ');
+    mvwaddch(cw, tp->t_pos.y, tp->t_pos.x, tp->t_oldch);
+    detach(mlist, item);
+    if (on(*tp, AREMANY) && levtype == NORMLEV) /* AREMANYs stick together */
+        wake_room(roomin(&tp->t_pos));
+    /*
+     * empty his pack
+     */
+    while (pitem != NULL)
+    {
+        nexti = next(pitem);
+        (OBJPTR(pitem))->o_pos = tp->t_pos;
+        detach(tp->t_pack, pitem);
+        if (treasure) 
+            fall(pitem, FALSE);
+        else 
+            o_discard(pitem);
+        pitem = nexti;
+    }
+
+    turn_on(*tp,ISDEAD);
+    attach(rlist,item);
+}
+
+/*
+ * Returns a pointer to the weapon the monster is wielding corresponding to
+ * the given thrown weapon.  If no thrown item is given, try to find any
+ * decent weapon.
+ */
+
+struct linked_list *
+wield_weap(thrown, mp)
+struct object *thrown;
+struct thing *mp;
+{
+    int look_for = 0,   /* The projectile weapon we are looking for */
+        new_rate,       /* The rating of a prospective weapon */
+        cand_rate = -1; /* Rating of current candidate -- higher is better */
+    register struct linked_list *pitem, *candidate = NULL;
+    register struct object *obj;
+
+    if (thrown != NULL) {       /* Using a projectile weapon */
+      switch (thrown->o_which) {
+        case BOLT:      look_for = CROSSBOW;    /* Find the crossbow */
+        when ARROW:     look_for = BOW;         /* Find the bow */
+        when ROCK:      look_for = SLING;       /* find the sling */
+        otherwise:      return(NULL);
+      }
+    }
+    else if (off(*mp, ISUNIQUE) && off(*mp, CARRYWEAPON)) return(NULL);
+
+    for (pitem=mp->t_pack; pitem; pitem=next(pitem)) {
+        obj = OBJPTR(pitem);
+
+        /*
+         * If we have a thrown weapon, just return the first match
+         * we come to.
+         */
+        if (thrown != NULL && obj->o_type == WEAPON && obj->o_which == look_for)
+            return(pitem);
+
+        /* If we have a usable RELIC, return it */
+        if (thrown == NULL && obj->o_type == RELIC) {
+            switch (obj->o_which) {
+                case MUSTY_DAGGER:
+                case YEENOGHU_FLAIL:
+                case HRUGGEK_MSTAR:
+                case AXE_AKLAD:
+                case MING_STAFF:
+                case ASMO_ROD:
+                case ORCUS_WAND:
+                    return(pitem);
+            }
+        }
+
+        /* Otherwise if it's a usable weapon, it is a good candidate */
+        else if (thrown == NULL && obj->o_type == WEAPON) {
+            switch (obj->o_which) {
+                case DAGGER:
+                case SPEAR:
+                    new_rate = 0;
+                when BATTLEAXE:
+                    new_rate = 1;
+                when MACE:
+                    new_rate = 2;
+                when SWORD:
+                    new_rate = 3;
+                when PIKE:
+                    new_rate = 4;
+                when HALBERD:
+                case SPETUM:
+                    new_rate = 6;
+                when BARDICHE:
+                    new_rate = 7;
+                when TRIDENT:
+                    new_rate = 8;
+                when BASWORD:
+                    new_rate = 9;
+                when TWOSWORD:
+                    new_rate = 10;
+                otherwise:
+                    new_rate = -1;
+            }
+
+            /* Only switch if this is better than the current candidate */
+            if (new_rate > cand_rate) {
+                cand_rate = new_rate;
+                candidate = pitem;
+            }
+        }
+    }
+
+    return(candidate);
+}
+explode(tp)
+register struct thing *tp;
+{
+
+    register int x,y, damage;
+    struct linked_list *item;
+    struct thing *th;
+
+    /*
+     * check to see if it got the hero
+     */
+     if (off(player, ISINWALL) &&
+         DISTANCE(hero.x, hero.y, tp->t_pos.x, tp->t_pos.y) <= 25) {
+        msg("The explosion hits you! ");
+        damage = roll(6,6);
+        if (save(VS_WAND, &player, 0))
+            damage /= 2;
+        pstats.s_hpt -= damage;
+    }
+
+    /*
+     * now check for monsters in vicinity
+     */
+     for (x = tp->t_pos.x-5; x<=tp->t_pos.x+5; x++) {
+         if (x < 0 || x > cols - 1) 
+             continue;
+         for (y = tp->t_pos.y-5; y<=tp->t_pos.y+5; y++) {
+            if (y < 1 || y > lines - 3)
+                continue;
+            if (isalpha(mvwinch(mw, y, x))) {
+                if ((item = find_mons(y, x)) != NULL) {
+                    th = THINGPTR(item);
+                    if (th == tp || /* don't count gas spore */
+                        on(*th, ISINWALL)) /* Don't count monsters in wall */
+                        continue;
+                    damage = roll(6, 6);
+                    if (save(VS_WAND, th, 0))
+                        damage /= 2;
+                    runto(th, &hero);
+                    if ((th->t_stats.s_hpt -= damage) <= 0) {
+                        msg("The explosion kills %s! ", 
+                            prname(monster_name(th), FALSE));
+                        killed(item, FALSE, FALSE, TRUE);
+                    }
+                }
+            }
+        }
+    }
+}
+
+/*
+ * skirmish:
+ *      Called when one monster attacks another monster.
+ */
+
+skirmish(attacker, mp, weap, thrown)
+register struct thing *attacker;
+register coord *mp;
+struct object *weap;
+bool thrown;
+{
+    register struct thing *defender;
+    register struct linked_list *item;
+    register bool did_hit = TRUE, see_att, see_def;
+    char attname[LINELEN+1], defname[LINELEN+1];
+    struct object *wielded;     /* The wielded weapon */
+    struct linked_list *get_wield;      /* Linked list header for wielded */
+
+    /*
+     * Find the monster we want to fight
+     */
+    if ((item = find_mons(mp->y, mp->x)) == NULL) {
+        return(FALSE); /* must have killed him already */
+    }
+    defender = THINGPTR(item);
+
+    /* Can the player see either of the fighters? */
+    see_att = (cansee(unc(attacker->t_pos)) &&
+               (off(*attacker, ISINVIS)     || on(player, CANSEE)) &&
+               (off(*attacker, ISSHADOW)    || on(player, CANSEE)));
+    see_def = (cansee(unc(defender->t_pos)) &&
+               (off(*defender, ISINVIS)     || on(player, CANSEE)) &&
+               (off(*defender, ISSHADOW)    || on(player, CANSEE)));
+
+    /*
+     * Since we are fighting, things are not quiet so no healing takes
+     * place.  The -1 also tells us that we are in a fight.
+     */
+    attacker->t_quiet = -1;
+    defender->t_quiet = -1;
+
+    if (see_att) strcpy(attname, monster_name(attacker));
+    else strcpy(attname, "something");
+
+    if (see_def) strcpy(defname, monster_name(defender));
+    else strcpy(defname, "something");
+
+    /*
+     * if its in the wall, we can't hit it
+     */
+    if (on(*defender, ISINWALL) && off(*attacker, CANINWALL))
+        return(FALSE);
+
+    if (on(*defender, ISSTONE)) {
+        killed(item, FALSE, FALSE, FALSE);
+        if (see_def)
+            msg("%s shatters into a million pieces!", prname(defname, TRUE));
+        return (TRUE);
+    }
+
+    /*
+     * Let him know it was really a mimic (if it was one).
+     */
+    if (see_def && on(*defender, ISDISGUISE) &&
+        (defender->t_type != defender->t_disguise)) {
+        msg("Wait!  There's a %s!", defname);
+        turn_off(*defender, ISDISGUISE);
+        did_hit = thrown;
+    }
+
+    if (see_def && on(*defender, CANSURPRISE) && !ISWEARING(R_ALERT)) {
+        msg("Wait!  There's a %s!", defname);
+        turn_off(*defender, CANSURPRISE);
+        did_hit = thrown;
+    }
+
+    if (did_hit) {
+
+        did_hit = FALSE;
+
+        /*
+         * Try to find a weapon to wield.  Wield_weap will return a
+         * projector if weapon is a projectile (eg. bow for arrow).
+         * If weapon is NULL, it will try to find a suitable weapon.
+         */
+        get_wield = wield_weap(weap, attacker);
+        if (get_wield) wielded = OBJPTR(get_wield);
+        else wielded = NULL;
+
+#ifdef DOBLINK
+        /*
+         * For now Blink Dogs will not blink away from monsters.  We
+         * have to fix can_blink so it isn't dependant on the player
+         * before we can add it.
+         */
+        if (!can_blink(defender) &&
+#endif
+        if (((weap && weap->o_type == RELIC) ||
+             ((off(*defender, MAGICHIT) ||
+               attacker->t_stats.s_lvl > 4 ||
+               (weap && (weap->o_hplus > 0 || weap->o_dplus > 0))) &&
+              (off(*defender, BMAGICHIT) ||
+               attacker->t_stats.s_lvl > 6 ||
+               (weap && (weap->o_hplus > 1 || weap->o_dplus > 1))) &&
+              (off(*defender, CMAGICHIT) ||
+               attacker->t_stats.s_lvl > 8 ||
+               (weap && (weap->o_hplus > 2 || weap->o_dplus > 2)))))
+            && roll_em(attacker, defender, weap, thrown, wielded, FALSE))
+        {
+            did_hit = TRUE;
+
+            /* Should we start to chase this creature? */
+            if (attacker->t_index != defender->t_index  &&
+                (off(*defender, ISRUN) || rnd(100) < 50)) {
+                /*
+                 * If we're intelligent enough to realize that this
+                 * is a friendly monster, we will attack the hero instead.
+                 */
+                if (on(*attacker, ISFRIENDLY) &&
+                    roll(3,6) < defender->t_stats.s_intel) {
+                    runto(defender, &hero);
+                    debug("%s attacking %s's hero", defname, attname);
+                }
+
+                /* Otherwise, let's chase the monster */
+                else {
+                    runto(defender, &attacker->t_pos);
+                    debug("%s now attacking %s", defname, attname);
+                }
+            }
+            else if (off(*defender, ISRUN)) runto(defender, &hero);
+
+            /* Let the defender know that the attacker has missiles! */
+            if ((defender->t_dest == &attacker->t_pos) && thrown)
+                defender->t_wasshot = TRUE;
+
+            if (on(*defender, NOMETAL) && weap != NULL &&
+                weap->o_type != RELIC && weap->o_flags & ISMETAL) {
+                if (see_def && see_att)
+                    msg("The %s passes right through %s!",
+                        weaps[weap->o_which].w_name, prname(defname, FALSE));
+            }
+            else {
+                hit(weap, see_att, see_def,
+                    attname, defname, FALSE, thrown, FALSE);
+            }
+
+            /* See if there are any special effects */
+            if (effect(attacker, defender,
+                       weap, thrown, see_att, see_def) != 0) {
+                killed(item, FALSE, FALSE, TRUE);
+                if (see_def) msg("%s dies.", prname(defname, TRUE));
+                else msg("You hear a blood-curdling scream! ");
+            }
+
+            /* 
+             * Merchants just disappear if hit 
+             */
+            else if (on(*defender, CANSELL)) {
+                if (see_def)
+                    msg("%s disappears with his wares in a flash! ",
+                            prname(defname, TRUE));
+                killed(item, FALSE, FALSE, FALSE);
+            }
+
+            else if (defender->t_stats.s_hpt <= 0) {
+                killed(item, FALSE, FALSE, TRUE);
+                if (see_def) msg("%s dies.", prname(defname, TRUE));
+                else msg("You hear a blood-curdling scream! ");
+            }
+
+            else {
+                /* Did we disrupt a spell?                              */
+                /* Don't turn on WASDISRUPTED since player didn't do it */
+                if (defender->t_action == A_SUMMON ||
+                    defender->t_action == A_MISSILE) {
+                    /* Just make the old fellow start over again */
+                    defender->t_action = A_NIL;
+                    defender->t_no_move = movement(defender);
+                    defender->t_using = NULL;
+
+                    if (see_def)
+                        msg("%s was disrupted.", prname(defname, TRUE));
+                }
+
+#ifdef FLEEMONST
+                /*
+                 * If the monster is fairly intelligent and about to die,
+                 * it may turn tail and run.
+                 */
+                if ((tp->t_stats.s_hpt < max(10, tp->maxstats.s_hpt/10)) &&
+                    (rnd(21) < tp->t_stats.s_intel)) {
+                        turn_on(*tp, ISFLEE);
+
+                    /* If monster was suffocating, stop it */
+                    if (on(*tp, DIDSUFFOCATE)) {
+                        turn_off(*tp, DIDSUFFOCATE);
+                        extinguish(suffocate);
+                    }
+
+                    /* If monster held us, stop it */
+                    if (on(*tp, DIDHOLD) && (--hold_count == 0))
+                            turn_off(player, ISHELD);
+                    turn_off(*tp, DIDHOLD);
+
+                    /* It is okay to turn tail */
+                    tp->t_oldpos = tp->t_pos;
+                }
+#endif
+            }
+        }
+        else {
+            /* If the thing was trying to surprise, no good */
+            if (on(*attacker, CANSURPRISE)) {
+                /* If we can't see it, it keeps surprise (from us) */
+                if (see_att) turn_off(*attacker, CANSURPRISE);
+            }
+
+            miss(weap, see_att, see_def, attname, defname, thrown, FALSE);
+        }
+    }
+    return did_hit;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/help.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,651 @@
+/*
+    help.c  -  Routines having to do with help
+    
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/
+
+#include <curses.h>
+#include <ctype.h>
+#include "mach_dep.h"
+#include "rogue.h"
+
+/*
+ * Give character descripts
+ */
+
+static char *game_fighter = "Strength is the main attribute of the Fighter.  \
+He can wield any weapon and the two-handed sword is his weapon of choice.  He \
+can also wear any type of armor.  Plate armor being the best choice and \
+leather armor the worst.  The Fighter is  able to sense both traps and gold \
+at higher experience levels.  His natural     quest item is the Axe of Aklad.  \
+Due to his superior form, the Fighter usually  receives more hit-points per \
+new experience level than the other characters.    The Fighter is neither good \
+or evil; he is a neutral character.  The default    attribute values of the \
+Fighter are: Int=7, Str=16, Wis=7, Dxt=16, Con=17, and  Chr=11.  Default gold \
+amount is 2000 pieces and default hit-points are 24.";
+
+static char *game_thief = "Dexterity is the main attribute of the Thief.  His \
+stealth allows him to move   quietly, thus disturbing less monsters.  He can \
+sense traps and gold and can    take (steal) things from the monsters.  The \
+Thief can not wield the two-handed  sword so the bastard sword is his weapon \
+of choice.  He can only wear studded   leather armor.  The Thief's natural \
+quest item is the Daggers of Musty Doit.    With higher dexterity the Thief \
+is able to \"backstab\" monsters, thereby killing them with a single blow.  \
+His character type fluctuates between that of good,   neutral, and evil.  The \
+default attribute values of the Thief are:  Int=7,      Str=14, Wis=7, Dxt=18, \
+Con=17, and Chr=11.  Default gold amount is 2000 pieces  and default \
+hit-points are 23.";
+
+static char *game_assassin = "Dexterity is the main attribute of the \
+Assassin.  Like the Thief, he moves with an extra degree of stealth.  He can \
+sense gold and steal things from monsters.  The ability to sense traps comes \
+at higher experience levels.  The Assassin can not wield the two-handed sword \
+and he can only wear studded leather armor.  The natural quest item of the \
+Assassin is the Eye of Vecna.  He is also skilled in  the use of poison.  \
+Higher dexterity enables him to \"assassinate\" monsters with a single blow.  \
+The Assassin is aligned with the powers of evil.  The default   attribute \
+values of the Assassin are: Int=7, Str=14, Wis=7, Dxt=18, Con=17, and \
+Chr=11.  Default gold amount is 2000 pieces and default hit-points are 23.";
+
+static char *game_ranger = "Charisma is the main attribute of the Ranger who \
+also has a secondary attribute of Intelligence.  Like the Magician, this \
+gives him the ability to cast spells  which increases as he attains higher \
+experience levels.  Like the Fighter, he   can wield any weapon and wear any \
+armor.  The Ranger's natural quest item is    the Mandolin of Brian.  He is \
+aligned with the powers of good.  Therefore, he   can be made to suffer and \
+even become cursed by the very powers that allow him  to cast spells if he \
+happens to cause the demise of a likewise good creature.   The default \
+attribute values of the Ranger are: Int=11, Str=11, Wis=7, Dxt=16,  Con=16, \
+and Chr=13.  Default gold amount is 2000 pieces and default hit-points  \
+are 22.";
+
+static char *game_paladin = "Charisma is the main attribute of the Paladin \
+who has a secondary attribute of  Wisdom.  Like the Cleric, this gives him \
+the ability to offer prayers, receive  what his heart desires, and an ability \
+to turn the undead.  This ability will   increase as he gains higher \
+experience levels.  Like the Fighter, he can wield  any weapon and wear any \
+armor.  The Ankh of Heil is the Paladin's natural quest item.  Like the \
+Ranger, the Paladin is aligned with the powers of good.  This   can cause \
+him to suffer and become cursed if he brings ruin to a likewise good  \
+creature.  The default attribute values of the Paladin are:  Int=7, \
+Str=11,     Wis=11, Dxt=16, Con=16, and Chr=13.  Default gold amount is \
+2000 pieces and     default hit-points are 22.";
+
+static char *game_druid = "Wisdom is the main attribute of the Druid.  This \
+gives him the ability to chant secret words and mantras, which is much \
+greater than that of the Monk.  The     Druid can not wield the two-handed or \
+bastard swords but he can wear any armor. His natural quest item is the Quill \
+of Nagrom.  Like the Magician and Cleric,   the Druid is aligned neutral.  He \
+therefore, must rely upon his Wisdom and his  chanting ability in order to \
+remain alive.  Likewise, he does not receive as    many new hit-points per \
+new experience level.  The default attribute values of  the Druid are: Int=7, \
+Str=10, Wis=14, Dxt=16, Con=15, and Chr=12.  Default gold amount is 2000 \
+pieces and default hit-points are 21.";
+
+static char *game_monk = "Constitution is the main attribute of the Monk who \
+has a secondary aspect of    Wisdom.  Like the Druid, this gives him the \
+ability to chant mantras which will increase as he gains higher experience.  \
+The Monk can not wield the two-handed  sword and he can not wear any armor.  \
+The Cloak of Emori is the Monk's natural  quest item.  The Monk can also \
+sense traps, though much less than the Thief or  Assassin.  He is the most \
+healthy character.  Like the Ranger and Paladin, he   is aligned with the \
+powers of good.  Therefore, he is made to suffer and can    become cursed if \
+he kills a likewise good creature.  The default attribute      values of the \
+Monk are: Int=7, Str=11, Wis=11, Dxt=16, Con=18, and Chr=11.      Default \
+gold amount is 2000 pieces and default hit-points are 22.";
+
+static char *game_magician = "Intelligence is the main attribute of the \
+Magician.  The Magician's ability to  cast spells is much greater than that \
+of the Ranger.  He can not wield the two- handed or bastard swords, but he \
+can wear any kind of armor.  His natural quest item is the Amulet of \
+Stonebones.  The Magician is aligned neutral.  He must    rely upon his \
+Intelligence and spell casting abilities to remain alive.  There- fore, he \
+does not receive as many new hit-points per new experience level.  The \
+default attribute values of the Magician are: Int=14, Str=10, Wis=7, \
+Dxt=16,    Con=15, and Chr=12.  Default gold amount is 2000 pieces and \
+default hit-points  are 21.";
+
+static char *game_cleric = "Wisdom is the main attribute of the Cleric.  The \
+Cleric's ability to give or    offer prayers, receive their due, and affect \
+the undead are much greater than   that of the Paladin.  Like the Magician, \
+the Cleric can not wield the two-      handed or bastard swords, but he can \
+wear any armor.  His natural quest item is the Horn of Geryon.  The Cleric \
+is aligned neutral  and he must rely upon his   Wisdom and prayer ability to \
+remain alive.  He therefore, does not receive as   many new hit-points per \
+new experience level.  The default attribute values of  the Cleric are: Int=7, \
+Str=10, Wis=14, Dxt=16, Con=15, and Chr=12.  The default gold amount is 2000 \
+pieces and default hit-points are 21.";
+
+
+static char *game_food ="There are three types of food, regular food rations, \
+various fruits, and slime- molds.  Eating regular food will add 750 points to \
+your current food level      [see the CTRL(E) command].  Eating fruit adds \
+300 points.  Certain fruits also  cure you, add an attribute point, add a \
+hit-point, increase your armor, give    you additional prayer, chant, or spell \
+casting abilities, or add experience     points.  Eating slime-mold (monster \
+food) can make you ill, but they will add   100 points to your current food \
+level.  If your food level points drop below    100 you will become weak.  You \
+will faint and might die if they drop to 0 or    below.  At the other extreme, \
+if your food level points reach 2000 (and above)  you will become satiated.  \
+Risk eating more and you could choke to death.";
+
+/*
+static char *game_monst ="To be updated.";
+static char *game_potion ="To be updated...";
+static char *game_scroll ="To be updated...";
+static char *game_ring ="To be updated...";
+static char *game_stick ="To be updated...";
+static char *game_weapon ="To be updated...";
+static char *game_armor ="To be updated...";
+static char *game_miscm ="To be updated...";
+static char *game_qitems ="To be updated...";
+static char *game_dungeon ="To be updated...";
+static char *game_traps ="To be updated...";
+static char *game_mazes ="To be updated...";
+static char *game_option ="To be updated...";
+static char *game_begin ="To be updated...";
+*/
+
+/* help list */
+static struct h_list helpstr[] = {
+    '?',     "    Print help",
+    '/',     "    Identify object",
+    '=',     "    Identify a screen character",
+    ' ',     "",
+    'h',     "    Move left",
+    'j',     "    Move down",
+    'k',     "    Move up",
+    'l',     "    Move right",
+    'y',      "    Move up and left",
+    'u',        "    Move up and right",
+    'b',        "    Move down and left",
+    'n',        "    Move down and right",
+    'H',        "    Run left",
+    'J',        "    Run down",
+    'K',        "    Run up",
+    'L',        "    Run right",
+    'Y',        "    Run up & left",
+    'U',        "    Run up & right",
+    'B',        "    Run down & left",
+    'N',        "    Run down & right",
+    ' ',        "",
+    '>',        "    Go down a staircase",
+    '<',        "    Go up a staircase",
+    '\\',        "  Game descriptions",
+    '.',        "   Rest for a while",
+    '*',        "   Count gold pieces",
+    'a',        "   Affect the undead",
+    'A',        "   Choose artifact (equipage)",
+    'c',        "   Chant a mantra",
+    'C',        "   Cast a spell",
+    'd',        "   Drop something",
+    'D',        "   Dip something (into a pool)",
+    'e',        "   Eat food or fruit",
+    'f',        "<dir>  Forward until find something",
+    'F',        "   Frighten a monster",
+    'g',        "   Give food to monster",
+    'G',        "   Sense for gold",
+    'i',        "   Inventory",
+    'I',        "   Inventory (single item)",
+    'm',        "   Mark an object (specific)",
+    'o',        "   Examine and/or set options",
+    'O',        "   Character type and quest item",
+    'p',        "   Pray to the powers that be",
+    'P',        "   Pick up object(s)",
+    'q',        "   Quaff a potion",
+    'Q',        "   Quit the game",
+    'r',        "   Read a scroll",
+    's',        "   Search for a trap/secret door",
+    'S',        "   Save your game",
+    't',        "<dir>  Throw something",
+    'T',        "   Take off something",
+    'v',        "   Print program version",
+    'w',        "   Wield a weapon",
+    'W',        "   Wear something",
+    'X',        "   Sense for traps",
+    'z',        "<dir>  Zap a wand or staff",
+    ' ',        "",
+    '^',        "   Set a trap",
+    '$',        "   Price an item (trading post)",
+    '#',        "   Buy an item   (trading post)",
+    '%',        "   Sell an item  (trading post)",
+    '!',        "   Shell escape",
+    ESC,        "   Cancel command (Esc)",
+    ' ',        "",
+    CTRL('B'),    " Current score (if you win)",
+    CTRL('E'),    " Current food level",
+    CTRL('L'),    " Redraw the screen",
+    CTRL('N'),    " Name an object or a monster",
+    CTRL('O'),    " Character affect status",
+    CTRL('R'),    " Repeat last message",
+    CTRL('T'),    "<dir>    Take (steal) from (direction)",
+    CTRL('U'),    " Use a magic item",
+    0, 0
+} ;
+
+/* wizard help list */
+static struct h_list wiz_help[] = {
+    ' ',        "",
+    '+',        "   Random fortunes",
+    'M',        "   Make an object",
+    'V',        "   Display vlevel and turns",
+    CTRL('A'),    " System activity",
+    CTRL('C'),    " Move to another dungeon level",
+    CTRL('D'),    " Go down 1 dungeon level",
+    CTRL('F'),    " Display the entire level",
+    CTRL('G'),    " Charge wands and staffs",
+    CTRL('H'),    " Jump 9 experience levels",
+    CTRL('I'),    " Inventory of level",
+    CTRL('J'),    " Teleport somewhere",
+    CTRL('K'),    " Identify an object",
+    CTRL('M'),    " Recharge wand or staff",
+    CTRL('P'),    " Toggle wizard status",
+    CTRL('X'),    " Detect monsters",
+    CTRL('Y'),    " Display food levels",
+    0, 0
+};
+
+/* item help list */
+static struct item_list item_help[] = {
+    '@',   "   You (visible)",
+    '_',   "   You (invisible)",
+    ' ',   "",
+    ':',   "   Food ration or fruit (eat)",
+    '!',   "   Potion (quaff)",
+    '?',   "   Scroll (read)",
+    '=',   "   Ring (wear)",
+    ')',   "   Weapon (wield)",
+    ']',   "   Armor (wear)",
+    '/',   "   Wand or staff (zap)",
+    ';',   "   Magic item (use)",
+    ',',   "   Artifact (quest item)",
+    '*',   "   Gold or zapped missile",
+    ' ',   "",
+    '$',   "   Magical item in room",
+    '>',   "   Blessed magical item",
+    '<',   "   Cursed magical item",
+    ' ',   " ",
+    '`',   "   Dart trap",
+    '{',   "   Arrow trap",
+    '}',   "   Bear trap",
+    '~',   "   Teleport trap",
+    '$',   "   Sleeping gas trap",
+    '>',   "   Trap door",
+    '<',   "   Outer region entrance",
+    '\'',   "   Maze entrance",
+    '^',   "   Trading post entrance",
+    '"',   "   Magic pool or lake",
+    ' ',   "   Solid rock or mountain",
+    '.',   "   Floor of a room or meadow",
+    '%',   "   Stairs (up or down)",
+    '+',   "   Doorway",
+    '&',   "   Secret doorway",
+    '#',   "   Passage between rooms",
+    '\\',   "   Forest",
+    HORZWALL,   "   Horizontal wall of a room",
+    VERTWALL,   "   Vertical wall of a room",
+    0, 0
+};
+
+ident_hero()
+{
+    bool doit = TRUE;
+
+    wclear(hw);
+    wprintw(hw, "Characters, Items, and Game Descriptions:\n");
+    wprintw(hw, "-----------------------------------------\n");
+    wprintw(hw, "a) Fighter        m) Scrolls\n");
+    wprintw(hw, "b) Thief          n) Rings\n");
+    wprintw(hw, "c) Assassin       o) Wands and Staffs\n");
+    wprintw(hw, "d) Ranger         p) Weapons\n");
+    wprintw(hw, "e) Paladin        q) Armors\n");
+    wprintw(hw, "f) Monk           r) Miscellaneous Magic Items\n");
+    wprintw(hw, "g) Magician       s) Quest Items (Artifacts and Relics)\n");
+    wprintw(hw, "h) Cleric         t) The Dungeon\n");
+    wprintw(hw, "i) Druid          u) Traps\n");
+    wprintw(hw, "j) Monsters       v) Mazes and Outer Regions\n");
+    wprintw(hw, "k) Foods          w) Setting game options\n");
+    wprintw(hw, "l) Potions        x) Starting out\n");
+    wprintw(hw, "\nEnter a letter: ");
+    draw(hw);
+    while (doit) {
+    switch (wgetch(cw)) {
+       case EOF:
+       case ESC:
+        doit = FALSE;
+       when 'a':
+            wclear(hw);
+            wprintw(hw, "Fighter Characteristics:");
+            mvwaddstr(hw, 2, 0, game_fighter);
+        draw(hw);
+        doit = FALSE;
+       when 'b':
+            wclear(hw);
+            wprintw(hw, "Thief Characteristics:");
+            mvwaddstr(hw, 2, 0, game_thief);
+        draw(hw);
+        doit = FALSE;
+       when 'c':
+            wclear(hw);
+            wprintw(hw, "Assassin Characteristics:");
+            mvwaddstr(hw, 2, 0, game_assassin);
+            draw(hw);
+        doit = FALSE;
+        when 'd':
+            wclear(hw);
+            wprintw(hw, "Ranger Characteristics:");
+            mvwaddstr(hw, 2, 0, game_ranger);
+            draw(hw);
+        doit = FALSE;
+        when 'e':
+            wclear(hw);
+            wprintw(hw, "Paladin Characteristics:");
+            mvwaddstr(hw, 2, 0, game_paladin);
+            draw(hw);
+        doit = FALSE;
+        when 'f':
+            wclear(hw);
+            wprintw(hw, "Monk Characteristics:");
+            mvwaddstr(hw, 2, 0, game_monk);
+            draw(hw);
+        doit = FALSE;
+        when 'g':
+            wclear(hw);
+            wprintw(hw, "Magician Characteristics:");
+            mvwaddstr(hw, 2, 0, game_magician);
+            draw(hw);
+        doit = FALSE;
+        when 'h':
+            wclear(hw);
+            wprintw(hw, "Cleric Characteristics:");
+            mvwaddstr(hw, 2, 0, game_cleric);
+            draw(hw);
+        doit = FALSE;
+        when 'i':
+            wclear(hw);
+            wprintw(hw, "Druid Characteristics:");
+            mvwaddstr(hw, 2, 0, game_druid);
+            draw(hw);
+        doit = FALSE;
+        when 'j':
+            wclear(hw);
+            wprintw(hw, "Monster Characteristics:");
+            draw(hw);
+        doit = FALSE;
+        when 'k':
+            wclear(hw);
+            wprintw(hw, "Foods:");
+            mvwaddstr(hw, 2, 0, game_food);
+            draw(hw);
+        doit = FALSE;
+        when 'l':
+            wclear(hw);
+            wprintw(hw, "Potions:");
+            draw(hw);
+        doit = FALSE;
+        when 'm':
+            wclear(hw);
+            wprintw(hw, "Scrolls:");
+            draw(hw);
+        doit = FALSE;
+        when 'n':
+            wclear(hw);
+            wprintw(hw, "Rings:");
+            draw(hw);
+        doit = FALSE;
+        when 'o':
+            wclear(hw);
+            wprintw(hw, "Wands and Staffs:");
+            draw(hw);
+        doit = FALSE;
+        when 'p':
+            wclear(hw);
+            wprintw(hw, "Weapons:");
+            draw(hw);
+        doit = FALSE;
+        when 'q':
+            wclear(hw);
+            wprintw(hw, "Armors:");
+            draw(hw);
+        doit = FALSE;
+        when 'r':
+            wclear(hw);
+            wprintw(hw, "Miscellaneous Magic Items:");
+            draw(hw);
+        doit = FALSE;
+        when 's':
+            wclear(hw);
+            wprintw(hw, "Quest Items (Artifacts and Relics):");
+            draw(hw);
+        doit = FALSE;
+        when 't':
+            wclear(hw);
+            wprintw(hw, "The Dungeon:");
+            draw(hw);
+        doit = FALSE;
+        when 'u':
+            wclear(hw);
+            wprintw(hw, "Traps:");
+            draw(hw);
+        doit = FALSE;
+        when 'v':
+            wclear(hw);
+            wprintw(hw, "Mazes and Outer Regions:");
+            draw(hw);
+        doit = FALSE;
+        when 'w':
+            wclear(hw);
+            wprintw(hw, "Setting game options:");
+            draw(hw);
+        doit = FALSE;
+        when 'x':
+            wclear(hw);
+            wprintw(hw, "Starting out:");
+            draw(hw);
+        doit = FALSE;
+        otherwise:
+        doit = TRUE;
+    }
+    }
+    wmove(hw, lines-1, 0);
+    wprintw(hw, spacemsg);
+    draw(hw);
+    wait_for(' ');
+    wclear(hw);
+    draw(hw);
+    wmove(cw, 0, 0);
+    wclrtoeol(cw);
+    status(FALSE);
+    touchwin(cw);
+}
+
+/*
+ * Real Help
+ */
+
+help()
+{
+    register struct h_list *strp = helpstr;
+    register struct item_list *itemp = item_help;
+    struct h_list *wizp = wiz_help;
+    register char helpch;
+    register int cnt;
+
+    msg("Character you want help for (* for commands, @ for items): ");
+    helpch = wgetch(cw);
+    mpos = 0;
+    /*
+     * If it's not a *, @, or +, then just print help string
+     * for the character entered.  
+     */
+    if (helpch != '*' && helpch != '@' && helpch != '+') {
+        wmove(msgw, 0, 0);
+        while (strp->h_ch) {
+            if (strp->h_ch == helpch) {
+                msg("%s%s", unctrl(strp->h_ch), strp->h_desc);
+                return;
+            }
+            strp++;
+        }
+        if (wizard) {
+            while (wizp->h_ch) {
+                if (wizp->h_ch == helpch) {
+                    msg("%s%s", unctrl(wizp->h_ch), wizp->h_desc);
+                    return;
+                }
+                wizp++;
+            }
+        }
+        msg("Unknown command '%s'", unctrl(helpch));
+        return;
+    }
+
+    /* fortunes - but let's not say so - explicitly */
+    if (helpch == '+') {
+    msg("Meaningless command '+'");
+    return;
+    }
+
+    /*
+     * Print help for everything else
+     */
+    if (helpch == '*') {
+        wclear(hw);
+        cnt = 0;
+        while (strp->h_ch) {
+            mvwaddstr(hw, cnt % 23, cnt > 22 ? 40 : 0, unctrl(strp->h_ch));
+            waddstr(hw, strp->h_desc);
+            strp++;
+            if (++cnt >= 46 && strp->h_ch) {
+                wmove(hw, lines-1, 0);
+                wprintw(hw, morestr);
+                draw(hw);
+                wait_for(' ');
+                wclear(hw);
+                cnt = 0;
+            }
+        }
+        if (wizard) {
+            while (wizp->h_ch) {
+                mvwaddstr(hw, cnt % 23, cnt > 22 ? 40 : 0, unctrl(wizp->h_ch));
+                waddstr(hw, wizp->h_desc);
+                wizp++;
+                if (++cnt >= 46 && wizp->h_ch) {
+                    wmove(hw, lines-1, 0);
+                    wprintw(hw, morestr);
+                    draw(hw);
+                    wait_for(' ');
+                    wclear(hw);
+                    cnt = 0;
+                }
+            }
+        }
+    }
+    if (helpch == '@') {
+        wclear(hw);
+        cnt = 0;
+        while (itemp->item_ch) {
+            mvwaddstr(hw, cnt % 23, cnt > 22 ? 40 : 0, unctrl(itemp->item_ch));
+            waddstr(hw, itemp->item_desc);
+            itemp++;
+            if (++cnt >= 46 && itemp->item_ch) {
+                wmove(hw, lines-1, 0);
+                wprintw(hw, morestr);
+                draw(hw);
+                wait_for(' ');
+                wclear(hw);
+                cnt = 0;
+            }
+        }
+    }
+    wmove(hw, lines-1, 0);
+    wprintw(hw, spacemsg);
+    draw(hw);
+    wait_for(' ');
+    wclear(hw);
+    draw(hw);
+    wmove(cw, 0, 0);
+    wclrtoeol(cw);
+    status(FALSE);
+    touchwin(cw);
+}
+
+/*
+ * identify:
+ *      Tell the player what a certain thing is.
+ */
+
+identify(ch)
+register unsigned char ch;
+{
+    register char *str = NULL;
+
+    if (ch == 0) {
+        msg("What do you want identified? ");
+        ch = wgetch(cw);
+        mpos = 0;
+        if (ch == ESC)
+        {
+            msg("");
+            return;
+        }
+    }
+    if (isalpha(ch))
+        msg("Use the \"=\" command to identify monsters. ");
+    else switch(ch)
+    {
+        case VPLAYER:   str = "You (visibly)";
+        when IPLAYER:   str = "You (invisibly)";
+        when GOLD:      str = "Gold";
+        when STAIRS:    str = (levtype == OUTSIDE) ? "Entrance to the dungeon"
+                                                   : "Stairway";
+        when DOOR:      str = "Doorway";
+        when SECRETDOOR:str = "Secret door";
+        when FLOOR:     str = (levtype == OUTSIDE) ? "Meadow" : "Room floor";
+        when PASSAGE:   str = "Passage";
+        when VERTWALL:
+        case HORZWALL:
+            str = (levtype == OUTSIDE) ? "Boundary of sector"
+                                       : "Wall of a room";
+        when POST:      str = "Trading post";
+        when POOL:      str = (levtype == OUTSIDE) ? "Lake"
+                                                   : "A shimmering pool";
+        when TRAPDOOR:  str = "Trap door";
+        when ARROWTRAP: str = "Arrow trap";
+        when SLEEPTRAP: str = "Sleeping gas trap";
+        when BEARTRAP:  str = "Bear trap";
+        when TELTRAP:   str = "Teleport trap";
+        when DARTTRAP:  str = "Dart trap";
+        when MAZETRAP:  str = "Entrance to a maze";
+        when WORMHOLE:  str = "Entrance to a worm hole";
+        when FOREST:    str = "Forest";
+        when ' ' :      str = (levtype == OUTSIDE) ? "Mountain"
+                                                   : "Solid rock";
+        when FOOD:      str = "Food";
+        when POTION:    str = "Potion";
+        when SCROLL:    str = "Scroll";
+        when RING:      str = "Ring";
+        when WEAPON:    str = "Weapon";
+        when ARMOR:     str = "Armor";
+        when MM:        str = "Miscellaneous magic";
+        when STICK:     str = "Wand or staff";
+        when RELIC:     str = "Artifact";
+        otherwise:      str = "Unknown character";
+    }
+    if (!isalpha(ch))
+        msg("%s     %s", unctrl(ch), str);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/init.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,826 @@
+/*
+    init.c - global variable initializaton
+ 
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/ 
+
+#include <curses.h>
+#include <ctype.h>
+#include <string.h>
+#include "rogue.h"
+#include "mach_dep.h"
+
+/*
+ * If there is any news, put it in a character string and assign it to
+ * rogue_news.  Otherwise, assign NULL to rogue_news.
+ */
+
+static char *rogue_news = "Enter a number within the minimum and maximum \
+range.  When satisfied with your  choices, enter a 'y'.  For help at any \
+other time enter a '?' or a '='.";
+
+/* replace the above line with this when descriptions are done  */
+/* other time enter a '?' or a '='.         For character and item descriptions \
+enter a '\\' on any other screen.";
+*/
+
+struct words rainbow[NCOLORS] = {
+"Amber",                "Aquamarine",           "Beige",
+"Black",                "Blue",                 "Brown",
+"Clear",                "Crimson",              "Ecru",
+"Gold",                 "Green",                "Grey",
+"Indigo",               "Khaki",                "Lavender",
+"Magenta",              "Orange",               "Pink",
+"Plaid",                "Purple",               "Red",
+"Silver",               "Saffron",              "Scarlet",
+"Tan",                  "Tangerine",            "Topaz",
+"Turquoise",            "Vermilion",            "Violet",
+"White",                "Yellow",
+};
+
+struct words sylls[NSYLLS] = {
+    "a",   "ae",  "ak",  "an",  "ax",  "ach", "ano", "ars", "bha", "bar", "bre",
+    "cha", "cre", "cum", "cow", "duh", "dha", "e",   "ea",  "em",  "et",  "ey",
+    "eck", "etk", "egg", "exl", "fu",  "fen", "fid", "gan", "gle", "h",   "ha",
+    "hr",  "ht",  "how", "hex", "hip", "hoc", "i",   "ia",  "ig",  "it",  "iz",
+    "ion", "ink", "ivi", "iss", "je",  "jin", "jha", "jyr", "ka",  "kho", "kal",
+    "kli", "lu",  "lre", "lta", "lri", "m",   "ma",  "mh",  "mi",  "mr",  "mar",
+    "myr", "moh", "mul", "nep", "nes", "o",   "oc",  "om",  "oq",  "ox",  "orn",
+    "oxy", "olm", "ode", "po",  "pie", "pod", "pot", "qar", "que", "ran", "rah",
+    "rok", "sa",  "sat", "sha", "sol", "sri", "ti",  "tem", "tar", "tki", "tch",
+    "tox", "u",   "ub",  "uh",  "ur",  "uv",  "unk", "uwh", "ugh", "uyr", "va",
+    "vil", "vit", "vom", "vux", "wah", "wex", "xu",  "xed", "xen", "ya",  "yep",
+    "yih", "zef", "zen", "zil", "zym", "-"
+};
+
+struct words stones[NSTONES] = {
+        "Agate",                "Alexandrite",          "Amethyst",
+        "Azurite",              "Bloodstone",           "Cairngorm",
+        "Carnelian",            "Chalcedony",           "Chrysoberyl",
+        "Chrysolite",           "Chrysoprase",          "Citrine",
+        "Coral",                "Diamond",              "Emerald",
+        "Garnet",               "Heliotrope",           "Hematite",
+        "Hyacinth",             "Jacinth",              "Jade",
+        "Jargoon",              "Jasper",               "Kryptonite",
+        "Lapis lazuli",         "Malachite",            "Mocca stone",
+        "Moonstone",            "Obsidian",             "Olivine",
+        "Onyx",                 "Opal",                 "Pearl",
+        "Peridot",              "Quartz",               "Rhodochrosite",
+        "Rhodolite",            "Ruby",                 "Sapphire",
+        "Sardonyx",             "Serpentine",           "Spinel",
+        "Tiger eye",            "Topaz",                "Tourmaline",
+        "Turquoise",            "Zircon",
+};
+
+struct words wood[NWOOD] = {
+        "Avocado wood", "Balsa",        "Banyan",       "Birch",
+        "Cedar",        "Cherry",       "Cinnabar",     "Dogwood",
+        "Driftwood",    "Ebony",        "Eucalyptus",   "Hemlock",
+        "Ironwood",     "Mahogany",     "Manzanita",    "Maple",
+        "Oak",          "Pine",         "Redwood",      "Rosewood",
+        "Teak",         "Walnut",       "Aloe",         "Sandalwood",
+};
+
+struct words metal[NMETAL] = {
+        "Aluminium",    "Bone",         "Brass",        "Bronze",
+        "Copper",       "Chromium",     "Iron",         "Lead",
+        "Magnesium",    "Pewter",       "Platinum",     "Silver",
+        "Steel",        "Tin",          "Titanium",     "Zinc",
+};
+
+/*
+ * make sure all the percentages specified in the tables add up to the
+ * right amounts
+ */
+
+badcheck(name, magic, bound)
+char *name;
+register struct magic_item *magic;
+register int bound;
+{
+    register struct magic_item *end;
+
+    if (magic[bound - 1].mi_prob == 1000)
+        return;
+    printf("\nBad percentages for %s:\n", name);
+    for (end = &magic[bound] ; magic < end ; magic++)
+        printf("%4d%% %s\n", magic->mi_prob, magic->mi_name);
+    printf(retstr);
+    fflush(stdout);
+    while (getchar() != '\n')
+        continue;
+}
+
+/*
+ * init_colors:
+ *      Initialize the potion color scheme for this time
+ */
+
+init_colors()
+{
+    register int i;
+    register char *str;
+
+    for (i = 0 ; i < MAXPOTIONS ; i++)
+    {
+        do
+            str = rainbow[rnd(NCOLORS)].w_string;
+        until (isupper(*str));
+        *str = tolower(*str);
+        p_colors[i] = str;
+        p_know[i] = FALSE;
+        p_guess[i] = NULL;
+        if (i > 0)
+                p_magic[i].mi_prob += p_magic[i-1].mi_prob;
+    }
+    badcheck("potions", p_magic, MAXPOTIONS);
+}
+
+/*
+ * do any initialization for food
+ */
+
+init_foods()
+{
+    register int i;
+
+    for (i=0; i < MAXFOODS; i++) {
+        if (i > 0)
+            foods[i].mi_prob += foods[i-1].mi_prob;
+    }
+    badcheck("foods", foods, MAXFOODS);
+}
+
+/*
+ * init_materials:
+ *      Initialize the construction materials for wands and staffs
+ */
+
+init_materials()
+{
+    register int i;
+    register char *str;
+
+    for (i = 0 ; i < MAXSTICKS ; i++)
+    {
+        do
+            if (rnd(100) > 50)
+            {
+                str = metal[rnd(NMETAL)].w_string;
+                if (isupper(*str))
+                        ws_type[i] = "wand";
+            }
+            else
+            {
+                str = wood[rnd(NWOOD)].w_string;
+                if (isupper(*str))
+                        ws_type[i] = "staff";
+            }
+        until (isupper(*str));
+        *str = tolower(*str);
+        ws_made[i] = str;
+        ws_know[i] = FALSE;
+        ws_guess[i] = NULL;
+        if (i > 0)
+                ws_magic[i].mi_prob += ws_magic[i-1].mi_prob;
+    }
+    badcheck("sticks", ws_magic, MAXSTICKS);
+}
+
+/*
+ * do any initialization for miscellaneous magic
+ */
+
+init_misc()
+{
+    register int i;
+
+    for (i=0; i < MAXMM; i++) {
+        m_know[i] = FALSE;
+        m_guess[i] = NULL;
+        if (i > 0)
+            m_magic[i].mi_prob += m_magic[i-1].mi_prob;
+    }
+    badcheck("miscellaneous magic", m_magic, MAXMM);
+}
+
+/*
+ * init_names:
+ *      Generate the names of the various scrolls
+ */
+
+init_names()
+{
+    register int nsyl;
+    register char *cp, *sp;
+    register int i, nwords;
+
+    for (i = 0 ; i < MAXSCROLLS ; i++)
+    {
+        cp = prbuf;
+        nwords = rnd(cols/20) + 1 + (cols > 40 ? 1 : 0);
+        while(nwords--)
+        {
+            nsyl = rnd(5)+1;
+            while(nsyl--)
+            {
+                sp = sylls[rnd(NSYLLS)].w_string;
+                while(*sp)
+                    *cp++ = *sp++;
+            }
+            *cp++ = ' ';
+        }
+        *--cp = '\0';
+        s_names[i] = (char *) new(strlen(prbuf)+1);
+        s_know[i] = FALSE;
+        s_guess[i] = NULL;
+        strcpy(s_names[i], prbuf);
+        if (i > 0)
+                s_magic[i].mi_prob += s_magic[i-1].mi_prob;
+    }
+    badcheck("scrolls", s_magic, MAXSCROLLS);
+}
+
+/*
+ * init_player:
+ *      roll up the rogue
+ */
+
+init_player()
+{
+    int stat_total, round = 0, minimum, maximum, ch, i, j = 0;
+    short do_escape, *our_stats[NUMABILITIES-1];
+    struct linked_list  *weap_item, *armor_item, *food_item;
+    struct object *obj;
+
+    weap_item = armor_item = food_item = NULL;
+
+    if (char_type == -1) {  /* not set via options */
+        /* See what type character will be */
+        wclear(hw);
+        touchwin(hw);
+        wmove(hw,2,0);
+        for(i=1; i<=NUM_CHARTYPES-1; i++) {
+            wprintw(hw,"[%d] %s\n",i,char_class[i-1].name);
+        }
+        mvwaddstr(hw, 0, 0, "What character class do you desire? ");
+        draw(hw);
+        char_type = (wgetch(hw) - '0');
+        while (char_type < 1 || char_type > NUM_CHARTYPES-1) {
+            wmove(hw,0,0);
+            wprintw(hw,"Please enter a character type between 1 and %d: ",
+                    NUM_CHARTYPES-1);
+            draw(hw);
+            char_type = (wgetch(hw) - '0');
+        }
+        char_type--;
+    }
+    player.t_ctype = char_type;
+    player.t_quiet = 0;
+    pack = NULL;
+
+    /* Select the gold */
+    purse = 3000;
+    switch (player.t_ctype) {
+        case C_FIGHTER:
+            purse += 200;
+        when C_MAGICIAN:
+        case C_CLERIC:
+        case C_DRUID:
+            purse += 100;
+        when C_THIEF:
+        case C_ASSASSIN:
+        purse += 0;
+        when C_RANGER:
+        case C_PALADIN:
+            purse -= 100;
+        when C_MONK:
+            purse -= 200;
+    }
+    /* 
+     * allow me to describe a super character 
+     */
+        /* let's lessen the restrictions on this okay? */
+    if (wizard && strcmp(getenv("SUPER"),"YES") == 0) {
+        pstats.s_str = MAXATT;
+        pstats.s_intel = MAXATT;
+        pstats.s_wisdom = MAXATT;
+        pstats.s_dext = MAXATT;
+        pstats.s_const = MAXATT;
+        pstats.s_charisma = MAXATT;
+        pstats.s_exp = 10000000L;
+        pstats.s_lvl = 1;
+        pstats.s_lvladj = 0;
+        pstats.s_hpt = 500;
+        pstats.s_carry = totalenc(&player);
+        strcpy(pstats.s_dmg,"4d8");
+        check_level();
+        wmove(hw,0,0);
+        wclrtoeol(hw);
+        draw(hw);
+        mpos = 0;
+
+    /* set quest item */
+    if(player.t_ctype == C_FIGHTER)  quest_item = AXE_AKLAD;
+    if(player.t_ctype == C_RANGER)   quest_item = BRIAN_MANDOLIN;
+    if(player.t_ctype == C_PALADIN)  quest_item = HEIL_ANKH;
+    if(player.t_ctype == C_MAGICIAN) quest_item = STONEBONES_AMULET;
+    if(player.t_ctype == C_CLERIC)   quest_item = GERYON_HORN;
+    if(player.t_ctype == C_THIEF)    quest_item = MUSTY_DAGGER;
+    if(player.t_ctype == C_ASSASSIN) quest_item = EYE_VECNA;
+    if(player.t_ctype == C_DRUID)    quest_item = QUILL_NAGROM;
+    if(player.t_ctype == C_MONK)     quest_item = EMORI_CLOAK;
+
+    /* armor */
+        if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN)
+            j = STUDDED_LEATHER;
+        else if (player.t_ctype == C_MONK) {
+        armor_item = spec_item(MM, MM_BRACERS, 20, 0);
+        obj = OBJPTR(armor_item);
+            obj->o_weight = things[TYP_MM].mi_wght;
+        whatis (armor_item);  /* identify it */
+            obj->o_flags |= (ISKNOW | ISPROT);
+            add_pack(armor_item, TRUE);
+            cur_misc[WEAR_BRACERS] = obj;
+        goto w_armorjmp; 
+    }
+        else j =  PLATE_ARMOR;
+
+        armor_item = spec_item(ARMOR, j, 20, 0);
+        obj = OBJPTR(armor_item);
+        obj->o_weight = armors[j].a_wght;
+        obj->o_flags |= (ISKNOW | ISPROT);
+        add_pack(armor_item, TRUE);
+        cur_armor = obj;
+
+    w_armorjmp:  /* monk doesn't wear armor */
+
+        /* weapons */
+        if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN ||
+            player.t_ctype == C_MONK) 
+        j = BASWORD;
+        else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
+        player.t_ctype == C_PALADIN)
+        j = TWOSWORD;
+    else j = TRIDENT;
+
+        weap_item = spec_item(WEAPON, j, 20, 20);
+        obj = OBJPTR(weap_item);
+        obj->o_flags |= (ISKNOW | ISPROT);
+        obj->o_weight = weaps[j].w_wght;
+        add_pack(weap_item, TRUE);
+        cur_weapon = obj;
+
+    /* food */
+        food_item = spec_item(FOOD, E_RATION, 0, 0);
+        obj = OBJPTR(food_item);
+        obj->o_flags |= ISKNOW;
+        obj->o_weight = foods[TYP_FOOD].mi_wght;
+        add_pack(food_item, TRUE); /* just one */
+
+    /* give wizard plenty gold */
+        purse = 50000;
+    }
+    else 
+    /* default attributes checked */
+    {
+    if (def_attr == TRUE) {  /* "default" option used in ROGUEOPTS */
+    switch(player.t_ctype) {
+        /* set "default attributes" option and quest items here */
+        case C_FIGHTER:
+        case C_MONK:
+                pstats.s_intel = 7;
+                pstats.s_dext = 16;
+                pstats.s_charisma = 11;
+            if (player.t_ctype == C_FIGHTER) {
+                    pstats.s_str = 16;
+                    pstats.s_wisdom = 7;
+                    pstats.s_const = 17;
+                quest_item = AXE_AKLAD;
+        }
+        else {
+                    pstats.s_str = 11;
+                    pstats.s_wisdom = 11;
+                    pstats.s_const = 18;
+                quest_item = EMORI_CLOAK;
+        }
+        when C_RANGER:
+        case C_PALADIN:
+                pstats.s_str = 11;
+                pstats.s_dext = 16;
+                pstats.s_const = 16;
+                pstats.s_charisma = 13;
+            /* intelligence or wisdom */
+            if (player.t_ctype == C_RANGER) {
+                    pstats.s_intel = 11;
+                    pstats.s_wisdom = 7;
+                quest_item = BRIAN_MANDOLIN;
+            }
+            else {
+                    pstats.s_intel = 7;
+                    pstats.s_wisdom = 11;
+                quest_item = HEIL_ANKH;
+            }
+        when C_THIEF:
+        case C_ASSASSIN:
+                pstats.s_intel = 7;
+                pstats.s_str = 14;
+                pstats.s_wisdom = 7;
+                pstats.s_dext = 18;
+                pstats.s_const = 17;
+                pstats.s_charisma = 11;
+            if (player.t_ctype == C_THIEF) 
+                quest_item = MUSTY_DAGGER;
+            else
+                quest_item = EYE_VECNA;
+        when C_MAGICIAN:
+        case C_CLERIC:
+        case C_DRUID:
+                pstats.s_str = 10;
+                pstats.s_dext = 16;
+                pstats.s_const = 15;
+                pstats.s_charisma = 12;
+            /* intelligence & wisdom */
+            if (player.t_ctype == C_MAGICIAN) {
+                    pstats.s_intel = 14;
+                    pstats.s_wisdom = 7;
+            }
+            else {
+                    pstats.s_intel = 7;
+                    pstats.s_wisdom = 14;
+            }
+            if (player.t_ctype == C_MAGICIAN) 
+                quest_item = STONEBONES_AMULET;
+            else if (player.t_ctype == C_CLERIC) 
+                quest_item = GERYON_HORN;
+            else
+                quest_item = QUILL_NAGROM;
+    }
+        /* Intialize */
+        pstats.s_exp = 0L;
+        pstats.s_lvl = 1;
+        pstats.s_lvladj = 0;
+        pstats.s_exp = 0L;
+        strcpy(pstats.s_dmg,"2d4");
+        pstats.s_carry = totalenc(&player);
+        check_level();
+        wmove(hw,0,0);
+        wclrtoeol(hw);
+        draw(hw);
+        mpos = 0;
+
+        /* Get the hit points. */
+        pstats.s_hpt = 12 + const_bonus();  /* Base plus bonus */
+
+        /* Add in the component that varies according to class */
+        pstats.s_hpt += char_class[player.t_ctype].hit_pts;
+
+        /* dole out some armor */
+        if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN)
+        j = STUDDED_LEATHER;
+        else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
+             player.t_ctype == C_PALADIN) {
+         switch (rnd(4)) {
+             case 0:         j = PLATE_ARMOR;
+             when 1:         j = PLATE_MAIL;
+             when 2: case 3: j = BANDED_MAIL;
+        }
+    }
+        else if (player.t_ctype == C_MONK) {
+        if (rnd(3) == 0) j = MM_PROTECT;
+        else j = MM_BRACERS;
+        armor_item = spec_item(MM, j, rnd(125)/60+3, 0);
+        obj = OBJPTR(armor_item);
+            obj->o_weight = things[TYP_MM].mi_wght;
+        whatis (armor_item);  /* identify it */
+            obj->o_flags |= ISKNOW;
+            add_pack(armor_item, TRUE);
+        goto p_armorjmp;
+    }
+    else {  /* other characters */
+        switch (rnd(7)) {
+        case 0:         j = PLATE_MAIL;
+        when 1: case 2: j = BANDED_MAIL;
+        when 3: case 4: j = SPLINT_MAIL;
+        when 5: case 6: j = PADDED_ARMOR;
+        }
+    }
+        armor_item = spec_item(ARMOR, j, rnd(100)/85, 0);
+        obj = OBJPTR(armor_item);
+        obj->o_weight = armors[j].a_wght;
+        obj->o_flags |= ISKNOW;
+        add_pack(armor_item, TRUE);
+
+    p_armorjmp:  /* monk doesn't wear armor */
+
+        /* give him a weapon */
+        if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN ||
+            player.t_ctype == C_MONK) {
+        switch (rnd(5)) {
+        case 0:         j = BASWORD;
+        when 1: case 2: j = TRIDENT;
+        when 3: case 4: j = BARDICHE;
+        }
+    }
+        else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
+        player.t_ctype == C_PALADIN) {
+        switch (rnd(5)) {
+        case 0:         j= TWOSWORD;
+        when 1: case 2: j= TRIDENT;
+        when 3: case 4: j= SWORD;
+        }
+    }
+        else {
+        switch (rnd(7)) {
+        case 0:         j = TRIDENT;
+        when 1: case 2: j = SWORD;
+        when 3: case 4: j = BARDICHE;
+        when 5:         j = MACE;
+        when 6:         j = SPETUM;
+        }
+    }
+        weap_item = spec_item(WEAPON, j, rnd(155)/75, rnd(165)/80);
+        obj = OBJPTR(weap_item);
+        obj->o_weight = weaps[j].w_wght;
+        obj->o_flags |= ISKNOW;
+        add_pack(weap_item, TRUE);
+
+        /* food rations */
+        food_item = spec_item(FOOD, E_RATION, 0, 0);
+        obj = OBJPTR(food_item);
+        obj->o_weight = foods[TYP_FOOD].mi_wght;
+        obj->o_flags |= ISKNOW;
+        add_pack(food_item, TRUE);
+
+    /* give him some fruit - coose from those w/o special effects */
+    switch (rnd(6)) {
+        case 0: j = E_BANANA;
+        when 1: j = E_BLUEBERRY;
+        when 2: j = E_ELDERBERRY;
+        when 3: j = E_GUANABANA;
+        when 4: j = E_CAPRIFIG;
+        when 5: j = E_GOOSEBERRY;
+    }
+        food_item = spec_item(FOOD, j, 0, 0);
+        obj = OBJPTR(food_item);
+        obj->o_weight = foods[TYP_FOOD].mi_wght;
+        obj->o_flags |= ISKNOW;
+        add_pack(food_item, TRUE);
+
+    /* adjust purse */
+    purse = 2000;
+    }
+    else {  /* select attibutes */
+        switch(player.t_ctype) {
+            case C_FIGHTER:     round = A_STRENGTH;
+            when C_RANGER:      round = A_CHARISMA;
+            when C_PALADIN:     round = A_CHARISMA;
+            when C_MAGICIAN:    round = A_INTELLIGENCE;
+            when C_CLERIC:      round = A_WISDOM;
+            when C_THIEF:       round = A_DEXTERITY;
+            when C_ASSASSIN:    round = A_DEXTERITY;
+            when C_DRUID:       round = A_WISDOM;
+            when C_MONK:        round = A_CONSTITUTION;
+        }
+
+        do {
+            wclear(hw);
+
+            /* If there is any news, display it */
+            if (rogue_news) {
+                register int i;
+
+                /* Print a separator line */
+                wmove(hw, 12, 0);
+                for (i=0; i<cols; i++) waddch(hw, '-');
+
+                /* Print the news */
+                mvwaddstr(hw, 14, 0, rogue_news);
+            }
+
+            stat_total = MAXSTATS;
+            do_escape = FALSE;  /* No escape seen yet */
+
+            /* Initialize abilities */
+            pstats.s_intel = 0;
+            pstats.s_str = 0;
+            pstats.s_wisdom = 0;
+            pstats.s_dext = 0;
+            pstats.s_const = 0;
+            pstats.s_charisma = 0;
+
+            /* Initialize pointer into abilities */
+            our_stats[A_INTELLIGENCE] = &pstats.s_intel;
+            our_stats[A_STRENGTH] = &pstats.s_str;
+            our_stats[A_WISDOM] = &pstats.s_wisdom;
+            our_stats[A_DEXTERITY] = &pstats.s_dext;
+            our_stats[A_CONSTITUTION] = &pstats.s_const;
+
+            /* Let player distribute attributes */
+            for (i=0; i<NUMABILITIES-1; i++) {
+                wmove(hw, 2, 0);
+                wprintw(hw, "You are creating a %s with %2d attribute points.",
+                                char_class[player.t_ctype].name, stat_total);
+
+                /*
+                 * Player must have a minimum of 7 in any attribute and 11 in
+                 * the player's primary attribute.
+                 */
+                minimum = (round == i ? 11 : 7);
+
+                /* Subtract out remaining minimums */
+                maximum = stat_total - (7 * (NUMABILITIES-1 - i));
+
+                /* Subtract out remainder of profession minimum (11 - 7) */
+                if (round > i) maximum -= 4;
+
+                /* Maximum can't be greater than 18 */
+                if (maximum > 18) maximum = 18;
+
+                wmove(hw, 4, 0);
+                wprintw(hw,
+                   "Minimum: %2d;  Maximum: %2d  (%s corrects previous entry)",
+                   minimum, maximum, unctrl('\b'));
+
+                wmove(hw, 6, 0);
+                wprintw(hw, "    Int: %-2d", pstats.s_intel);
+                wprintw(hw, "    Str: %-2d", pstats.s_str);
+                wprintw(hw, "    Wis: %-2d", pstats.s_wisdom); 
+                wprintw(hw, "    Dex: %-2d", pstats.s_dext);
+                wprintw(hw, "    Con: %-2d", pstats.s_const);
+                wprintw(hw, "    Cha: %-2d", pstats.s_charisma);
+                wclrtoeol(hw);
+                wmove(hw, 6, 11*i + 9);
+                if (do_escape == FALSE) draw(hw);
+
+                /* Get player's input */
+                if (do_escape || maximum == minimum) {
+                    *our_stats[i] = maximum;
+                    stat_total -= maximum;
+                }
+                else for (;;) {
+                    ch = wgetch(hw);
+                    if (ch == '\b') {   /* Backspace */
+                        if (i == 0) continue;   /* Can't move back */
+                        else {
+                            stat_total += *our_stats[i-1];
+                            *our_stats[i] = 0;
+                            *our_stats[i-1] = 0;
+                            i -= 2;     /* Back out */
+                            break;
+                        }
+                    }
+                    if (ch == '\033') { /* Escape */
+                        /*
+                         * Escape will result in using all maximums for
+                         * remaining abilities.
+                         */
+                        do_escape = TRUE;
+                        *our_stats[i] = maximum;
+                        stat_total -= maximum;
+                        break;
+                    }
+
+                    /* Do we have a legal digit? */
+                    if (ch >= '0' && ch <= '9') {
+                        ch -= '0';      /* Convert it to a number */
+                        *our_stats[i] = 10 * *our_stats[i] + ch;
+
+                        /* Is the number in range? */
+                        if (*our_stats[i] >= minimum &&
+                            *our_stats[i] <= maximum) {
+                            stat_total -= *our_stats[i];
+                            break;
+                        }
+
+                        /*
+                         * If it's too small, get more - 1x is the only
+                         * allowable case.
+                         */
+                        if (*our_stats[i] < minimum && *our_stats[i] == 1) {
+                            /* Print the player's one */
+                            waddch(hw, '1');
+                            draw(hw);
+                            continue;
+                        }
+                    }
+
+                    /* Error condition */
+                    putchar('\007');
+                    *our_stats[i] = 0;
+                    i--;        /* Rewind */
+                    break;
+                }
+            }
+
+            /* Discard extra points over 18 */
+            if (stat_total > 18) stat_total = 18;
+
+            /* Charisma gets what's left */
+            pstats.s_charisma = stat_total;
+
+            /* Intialize constants */
+            pstats.s_lvl = 1;
+            pstats.s_lvladj = 0;
+            pstats.s_exp = 0L;
+            strcpy(pstats.s_dmg,"2d4");
+            pstats.s_carry = totalenc(&player);
+
+            /* Get the hit points. */
+            pstats.s_hpt = 12 + const_bonus();  /* Base plus bonus */
+
+            /* Add in the component that varies according to class */
+            pstats.s_hpt += char_class[player.t_ctype].hit_pts;
+
+            /* Display the character */
+            wmove(hw, 2, 0);
+            wprintw(hw,"You are creating a %s.",
+                        char_class[player.t_ctype].name);
+            wclrtoeol(hw);
+
+            /* Get rid of max/min line */
+            wmove(hw, 4, 0);
+            wclrtoeol(hw);
+
+            wmove(hw, 6, 0);
+            wprintw(hw, "    Int: %2d", pstats.s_intel);
+            wprintw(hw, "    Str: %2d", pstats.s_str);
+            wprintw(hw, "    Wis: %2d", pstats.s_wisdom); 
+            wprintw(hw, "    Dex: %2d", pstats.s_dext);
+            wprintw(hw, "    Con: %2d", pstats.s_const);
+            wprintw(hw, "    Cha: %2d", pstats.s_charisma);
+            wclrtoeol(hw);
+
+            wmove(hw, 8, 0);
+            wprintw(hw, "    Hp: %2d", pstats.s_hpt);
+            wclrtoeol(hw);
+
+            wmove(hw, 10, 0);
+            wprintw(hw, "    Gold: %ld", purse);
+
+            mvwaddstr(hw, 0, 0, "Is this character okay? ");
+            draw(hw);
+        } while(wgetch(hw) != 'y');
+      }
+    }
+    pstats.s_arm = 10;
+    max_stats = pstats;
+    /* Set up initial movement rate */
+    player.t_action = A_NIL;
+    player.t_movement = 6;
+    player.t_no_move = 0;
+    player.t_using = NULL;
+    wclear(hw);
+}
+
+/*
+ * init_stones:
+ *      Initialize the ring stone setting scheme for this time
+ */
+
+init_stones()
+{
+    register int i;
+    register char *str;
+
+    for (i = 0 ; i < MAXRINGS ; i++)
+    {
+        do
+            str = stones[rnd(NSTONES)].w_string;
+        until (isupper(*str));
+        *str = tolower(*str);
+        r_stones[i] = str;
+        r_know[i] = FALSE;
+        r_guess[i] = NULL;
+        if (i > 0)
+                r_magic[i].mi_prob += r_magic[i-1].mi_prob;
+    }
+    badcheck("rings", r_magic, MAXRINGS);
+}
+
+/*
+ * init_things
+ *      Initialize the probabilities for types of things
+ */
+
+init_things()
+{
+    register struct magic_item *mp;
+
+    for (mp = &things[1] ; mp < &things[NUMTHINGS] ; mp++)
+        mp->mi_prob += (mp-1)->mi_prob;
+    badcheck("things", things, NUMTHINGS);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xrogue/io.c	Tue May 12 21:39:39 2015 -0400
@@ -0,0 +1,564 @@
+/*
+    io.c - Various input/output functions
+
+    XRogue: Expeditions into the Dungeons of Doom
+    Copyright (C) 1991 Robert Pietkivitch
+    All rights reserved.
+    
+    Based on "Advanced Rogue"
+    Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
+    All rights reserved.
+
+    Based on "Rogue: Exploring the Dungeons of Doom"
+    Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
+    All rights reserved.
+    
+    See the file LICENSE.TXT for full copyright and licensing information.
+*/  
+
+#include <curses.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <string.h>
+#include "rogue.h"
+
+/*
+ * msg:
+ *      Display a message at the top of the screen.
+ */
+
+static char msgbuf[BUFSIZ];
+static int newpos = 0;
+
+/* VARARGS */
+void
+msg(char *fmt, ...)
+{
+    va_list ap;
+    /*
+     * if the string is "", just clear the line
+     */
+    if (*fmt == '\0')
+    {
+        wclear(msgw);
+        overwrite(cw, msgw);
+        wmove(msgw, 0, 0);
+        clearok(msgw, FALSE);
+        draw(msgw);
+        mpos = 0;
+        return;
+    }
+    /*
+     * otherwise add to the message and flush it out
+     */
+    va_start(ap, fmt);
+    doadd(fmt, ap);
+    va_end(ap);
+    endmsg();
+}
+
+/*
+ * add things to the current message
+ */
+
+/* VARARGS */
+void
+addmsg(char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    doadd(fmt, ap);
+    va_end(ap);
+}
+
+/*
+ * If there is no current message, do nothing.  Otherwise, prompt the
+ * player with the --More-- string.  Then erase the message.
+ */
+
+rmmsg()
+{
+    if (mpos) {
+        wclear(msgw);
+        overwrite(cw, msgw);
+        mvwaddstr(msgw, 0, 0, huh);
+        waddstr(msgw, morestr);
+        clearok(msgw, FALSE);
+        draw(msgw);
+        wait_for(' ');
+        msg("");
+    }
+}
+
+/*
+ * Display a new msg (giving him a chance to see the previous one if it
+ * is up there with the --More--)
+ */
+
+endmsg()
+{
+    /* Needed to track where we are for 5.0 (PC) curses */
+    register int x, y;
+
+    if (mpos) {
+        /*
+         * If this message will fit on the line (plus space for --More--)
+         * then just add it (only during combat).
+         */
+        if (player.t_quiet < 0 && mpos + newpos + strlen(morestr) + 5 < cols) {
+            wmove(msgw, 0, mpos + 5);
+            newpos += mpos + 5;
+            strcat(huh, "  ");
+        }
+        else {
+            wclear(msgw);
+            overwrite(cw, msgw);
+            mvwaddstr(msgw, 0, 0, huh);
+            waddstr(msgw, morestr);
+            clearok(msgw, FALSE);
+            draw(msgw);
+            wait_for(' ');
+            wclear(msgw);
+            overwrite(cw, msgw);
+            wmove(msgw, 0, 0);
+            huh[0] = '\0';
+        }
+    }
+    else {
+        wclear(msgw);
+        overwrite(cw, msgw);
+        wmove(msgw, 0, 0);
+        huh[0] = '\0';
+    }
+    strcat(huh, msgbuf);
+    mvwaddstr(msgw, 0, 0, huh);
+    getyx(msgw, y, x);
+    mpos = newpos;
+    newpos = 0;
+    wmove(msgw, y, x);
+    clearok(msgw, FALSE);
+    draw(msgw);
+}
+
+doadd(char *fmt, va_list ap)
+{
+    vsprintf((char *) &msgbuf[newpos], fmt, ap);
+    newpos = strlen(msgbuf);
+}
+
+/*
+ * step_ok:
+ *      returns true if it is ok for type to step on ch
+ *      flgptr will be NULL if we don't know what the monster is yet!
+ */
+
+step_ok(y, x, can_on_monst, flgptr)
+register int y, x, can_on_monst;
+register struct thing *flgptr;
+{
+    /* can_on_monst = MONSTOK if all we care about are physical obstacles */
+    register struct linked_list *item;
+    register struct thing *tp;
+    unsigned char ch;
+
+    /* What is here?  Don't check monster window if MONSTOK is set */
+    if (can_on_monst == MONSTOK) ch = mvinch(y, x);
+    else ch = winat(y, x);
+
+    if (can_on_monst == FIGHTOK && isalpha(ch) &&
+        (item = find_mons(y, x)) != NULL) {
+        tp = THINGPTR(item);    /* What monster is here? */
+
+        /* We can hit it if we're after it */
+        if (flgptr->t_dest == &tp->t_pos) return TRUE;
+
+        /*
+         * Otherwise, if we're friendly we'll hit it unless it is also
+         * friendly or is our race.
+         */
+        if (off(*flgptr, ISFRIENDLY)    ||
+            on(*tp, ISFRIENDLY)         ||
+            flgptr->t_index == tp->t_index) return FALSE;
+        else return TRUE;
+    }
+    else switch (ch)
+    {
+        case ' ':
+        case VERTWALL:
+        case HORZWALL:
+        case SECRETDOOR:
+            if (flgptr && on(*flgptr, CANINWALL)) return(TRUE);
+            return FALSE;
+        when SCROLL:
+            if (can_on_monst == MONSTOK) {      /* Not a real obstacle */
+                move_free = 0;                  /* check free movement */
+                return(TRUE);
+            }
+            /*
+             * If it is a scroll, it might be a scare monster scroll
+             * so we need to look it up to see what type it is.
+             */
+            if (flgptr && flgptr->t_ctype == C_MONSTER) {
+                move_free = 1;
+                item = find_obj(y, x);
+                if (item != NULL &&
+                    (OBJPTR(item))->o_which==S_SCARE &&
+                    (flgptr == NULL || flgptr->t_stats.s_intel < 17)) {
+                        move_free = 2;
+                        return(FALSE); /* All but smart ones are scared */
+                }
+            }
+            return(TRUE);
+        otherwise:
+            return (!isalpha(ch));
+    }
+    /* return(FALSE); */
+    /*NOTREACHED*/
+}
+
+/*
+ * shoot_ok:
+ *      returns true if it is ok for type to shoot over ch
+ */
+
+shoot_ok(int ch)
+{
+    switch (ch)
+    {
+        case ' ':
+        case VERTWALL:
+        case HORZWALL:
+        case SECRETDOOR:
+        case FOREST:
+            return FALSE;
+        default:
+            return (!isalpha(ch));
+    }
+}
+
+/*
+ * status:
+ *      Display the important stats line.  Keep the cursor where it was.
+ */
+
+status(display)
+bool display;   /* is TRUE, display unconditionally */
+{
+    register struct stats *stat_ptr, *max_ptr;
+    register int oy = 0, ox = 0, temp;
+    register char *pb;
+    char buf[LINELEN];
+    static int hpwidth = 0, s_hungry = -1;
+    static int s_lvl = -1, s_hp = -1, s_str, maxs_str, 
+                s_ac = 0;
+    static short s_intel, s_dext, s_wisdom, s_const, s_charisma;
+    static short maxs_intel, maxs_dext, maxs_wisdom, maxs_const, maxs_charisma;
+    static unsigned long s_exp = 0;
+    static int s_carry, s_pack;
+    bool first_line=FALSE;
+
+    /* Go to English mode */
+    nofont(cw);
+
+    stat_ptr = &pstats;
+    max_ptr  = &max_stats;
+
+    /*
+     * If nothing has changed in the first line, then skip it
+     */
+    if (!display                                &&
+        s_lvl == level                          && 
+        s_intel == stat_ptr->s_intel            &&
+        s_wisdom == stat_ptr->s_wisdom          &&
+        s_dext == dex_compute()                 && 
+        s_const == stat_ptr->s_const            &&
+        s_charisma == stat_ptr->s_charisma      &&
+        s_str == str_compute()                  && 
+        s_hungry == hungry_state                &&
+        maxs_intel == max_ptr->s_intel          && 
+        maxs_wisdom == max_ptr->s_wisdom        &&
+        maxs_dext == max_ptr->s_dext            && 
+        maxs_const == max_ptr->s_const          &&
+        maxs_charisma == max_ptr->s_charisma    &&
+        maxs_str == max_ptr->s_str              ) goto line_two;
+
+    /* Display the first line */
+    first_line = TRUE;
+    getyx(cw, oy, ox);
+    sprintf(buf, "Int:%d(%d)  Str:%d", stat_ptr->s_intel,
+        max_ptr->s_intel, str_compute());
+
+    /* Maximum strength */
+    pb = &buf[strlen(buf)];
+    sprintf(pb, "(%d)", max_ptr->s_str);
+
+    pb = &buf[strlen(buf)];
+    sprintf(pb, "  Wis:%d(%d)  Dxt:%d(%d)  Con:%d(%d)  Cha:%d(%d)",
+        stat_ptr->s_wisdom,max_ptr->s_wisdom,dex_compute(),max_ptr->s_dext,
+        stat_ptr->s_const,max_ptr->s_const,stat_ptr->s_charisma,
+        max_ptr->s_charisma);
+
+    /* Update first line status */
+    s_intel = stat_ptr->s_intel;
+    s_wisdom = stat_ptr->s_wisdom;
+    s_dext = dex_compute();
+    s_const = stat_ptr->s_const;
+    s_charisma = stat_ptr->s_charisma;
+    s_str = str_compute();
+    maxs_intel = max_ptr->s_intel;
+    maxs_wisdom = max_ptr->s_wisdom;
+    maxs_dext = max_ptr->s_dext;
+    maxs_const = max_ptr->s_const;
+    maxs_charisma = max_ptr->s_charisma;
+    maxs_str = max_ptr->s_str;
+
+    /* Print the line */
+    mvwaddstr(cw, lines-2, 0, buf);
+    switch (hungry_state) {
+        case F_SATIATED:
+            waddstr(cw, "  Satiated");
+        when F_OKAY: ;
+        when F_HUNGRY:
+            waddstr(cw, "  Hungry");
+        when F_WEAK:
+            waddstr(cw, "  Weak");
+        when F_FAINT:
+            waddstr(cw, "  Fa