[net.sources.games] Phantasia 3.3.1+ Part 1 of 4

nonh@utzoo.UUCP (Chris Robertson) (10/09/85)

: This is a shell archive.  Remove everything up to this line, save the rest
# in a file and then type "/bin/sh file" to extract the following files:
# README phant.nr func0.c
if test -s "README"
	then
	echo Will not overwrite existing 'README'
else
	sed -e "s/^X//" > README << 'TiDDleYwiNKs'
XThis version of Phantasia has been heavily hacked by Chris Robertson,
XSeptember 1985.  Changes include:
X
X- lots of cosmetics in the display (alignment, words not numbers, etc.)
X- added a shell escape 
X- added HJKL keys for movement (== WSNE) for rogue, vi fans
X- timeout may be temporarily suspended with ^P (for answering phone etc.)
X- only SPACE BAR == melee in fighting so you aren't killed by typeahead
X- M == magic and B == luckout when fighting (commonest answers now
X     easier to type)
X- speeded response by keeping the peoplefile and monsterfile always open
X- "more" accepts a RETURN as well as SPACE BAR
X- added "is in <wherever>" for non-visible or non-playing characters
X- neatened up the source code (set up indents, etc. for 4-char tabstop)
X- threw away RAND because it bombed on at least 2 systems, redid algorithm
X- characters are purged less frequently (3 weeks)
X- limited resurrections for characters higher than level 10 (IF you're good)
X- updated help file appropriately
X *
XAll complaints and suggestions to {decvax, linus, ihnp4}!utzoo!nonh
X   and DON'T BUG Ted Estes for things I did, please.
X
XThe rest of this is the original README file from Ted.
X
XThis is the latest version of Phantasia.  It incorporates all the reported
Xbug fixes to date.  The only problem that may arise is the test for
XRAND in 'setup.c'.  If you have problems with it complaining, even
Xthough the correct RAND is specified, simply delete it.
X
XPlease send me any bugs you may find, but PLEASE be specific.  I cannot
Xcorrect a bug which is described as:
X
X    "When I choose a character type, it blows up."
X    (What blows up?  What exactly was printed at the terminal?
X    Which character type was chosen?  Etc. . . ?)
X
XAlso, please tell me which version of UN*X you are running, and upon
Xwhich type of hardware.
X
XI will also do my best to help anyone with problems just trying to
Xget the game running.  Again, I need to know which flavor of UN*X
Xand what type of CPU.  Also, a copy of the output from 'make'
Xwould be extremely useful.
X
XAny and all ideas/suggestions/additions are more than welcome.  If
Xyou feel strongly enough about it, write the change and send it to me,
Xand I will do my best to incorporate it in the next version of Phantasia.
XOtherwise, I will give serious thought to adding it myself.
X
XFollow the directions in the Makefile carefully to set up the game.
XRead the comments at the beginning of 'main.c', if you haven't already.
X
XEnjoy.
X
XTed Estes
XAT&T Computer Systems Division
XSkokie, IL  60077
X
X...!ihnp4!ttrdc!ttrda!estes
TiDDleYwiNKs
	size="`wc -c README`"
	size=`set - $size;echo $1`
echo "x - README, $size characters"

	if test "$size" != "2542"
		then
		echo "Warning: error in transmitting 'README';  should have 2542 characters."
	fi
fi
if test -s "phant.nr"
	then
	echo Will not overwrite existing 'phant.nr'
else
	sed -e "s/^X//" > phant.nr << 'TiDDleYwiNKs'
X.de sh
X.ne 6
X.sp
X.PP
X\s12\fB\\$1\fR\s10
X.sp
X.PP
X..
X.TH PHANTASIA 6 GAMES
X.UC 4
X.SH NAME
Xphantasia \- an interterminal fantasy game
X.SH SYNOPSIS
X\fBphantasia\fR [\fB\-s\fR] [\fB\-m\fR] [\fB\-a\fR] [\fB\-x\fR] [\fB\-h\fR]
X[\fB\-H\fR] [\fB\-p\fR] [\fB\-b\fR]
X.SH DESCRIPTION
X.I Phantasia
Xis a role playing game which allows players to roll up characters of
Xvarious types to fight monsters and other players.
XProgression of characters is based upon gaining experience from fighting
Xmonsters (and other players).
X.PP
XMost of the game is menu driven and self-explanatory (more or less).
XThe screen is cursor updated, so be sure to set up the \fB\s8TERM\s10\fR
Xvariable in your environment.
X.PP
XThe options provide for a variety of functions to support the game.
XThey are:
X.PP
X.TP .5i
X.B \-s
XInvokes \fIphantasia\fR without header information.
X.TP .5i
X.B \-m
XGet a monster listing.
X.TP .5i
X.B \-a
XGet a listing of all character names on file.
X.TP .5i
X.B \-x
XExamine/change a particular character on file.
X.TP .5i
X.B \-h
XGet a help listing (this message).
X.TP .5i
X.B \-H
XGet header listing only.
X.TP .5i
X.B \-p
XPurge old characters.
X.TP .5i
X.B \-b
XShow scoreboard of top characters per login.
X.PP
XThe characters are saved on a common file, in order to make the game
Xinteractive between players.  The characters are given a password
Xin order to retrieve them later.  Only characters above
X\fRlevel\fR zero are saved.
XCharacters unused for more than three weeks will be purged.
XCharacters are only placed on the scoreboard when they die.
X.SH AUTHOR
XEdward Estes, AT&T Teletype Corporation.
X.br
XModified by Chris Robertson, September 1985 ({linus, decvax, ihnp4} !
Xutzoo! ! nonh).
X.SH PARTICULARS
X.sp
X.sh "Playing in General"
XCertain of the player's more important statistics are almost always
Xdisplayed on the screen, with maximum values (where applicable) in
Xparentheses.
X.PP
XThe character is placed randomly near the center of a cartesian system.
XMost commands are selected with a single letter or digit.
XFor example, one may move by hitting \fBE, W, N,\fR or \fBS\fR
X(lower case may also be used;  at no time is the game case-dependent).
XThe \fBH, J, K,\fR and \fBL\fR keys may also be used to move
X(equivalent to W, S, N, and E, respectively).
XTo move to a particular (x,y) coordinate, use the
X\fBmove\fR (`1') command.  The distance a character can move is calculated by
X1 plus 1.5 per \fBlevel\fR.
XMoving in a particular compass direction will move the player the maximum
Xallowed distance in that direction.
X.PP
XA player may at any time see who else is playing with a \fBplayers\fR
X(`2') option.  One may see only those who are the same distance or closer
Xto the origin as he/she.
XA \fBpalantir\fR removes these retrictions.
X\fBKings\fR and \fBcouncil of the wise\fR can see and can be seen by everyone.
X.PP
XOne can talk to other players with the \fBtalk\fR
X(`3') option.  In general, this is a line or so of text.  To remove a current
Xmessage, just press \s8RETURN\s10 when prompted for a message.
X.PP
XThe \fBstats\fR (`4') option shows additional characteristics of a player.
X.PP
XOne may leave the game either with the \fBquit\fR
X(`5') option, or by hitting interrupt.  Quitting during battle results
Xin death, for obvious reasons.
X.PP
XOne may rest by default (any key except the menu ones).
XResting lets one regain maximum \fBenergy level\fR, and also lets one find
X\fBmana\fR (more is found for larger levels and further distances from
Xthe origin).
X.PP
XOne may call a monster by hitting `9' or `C'.
X.PP
XSeveral other options become available as the player progresses in \fBlevel\fR
Xand \fBmagic\fR, or to other stations in the game (\fBvalar, council of the
Xwise, king\fR).
XThese are described elsewhere.
XIn general, a control-L will force the redrawing of the screen.
X.PP
XOn most versions, `!' gives a shell escape;  if followed by a command, just
Xthat command is executed.
XThe environment variable \s8SHELL\s10 is used for a subshell if it is set;  the
Xdefault is \fI/bin/sh\fR.
X.PP
XOther things which may happen are more or less self-explanatory.
X.sh "Fighting Monsters"
XA player has several options while fighting monsters.  They are as follows:
X.TP 1.5i
X.I melee
X(`1' or `\ ')  Inflicts damage on the monster, based upon \fBstrength\fR.
XAlso decreases the monster's \fBstrength\fR some.
X.TP 1.5i
X.I skirmish
X(`2')  Inflicts a little less damage than \fBmelee\fR,
Xbut decreases the monster's \fBquickness\fR instead.
X.TP 1.5i
X.I evade
X(`3')  Attempt to run away.  Success is based upon both the player's and
Xthe monster's \fBbrains\fR and \fBquickness\fR.
X.TP 1.5i
X.I spell
X(`4' or `M')  Several options for throwing spells (described elsewhere).
X.TP 1.5i
X.I nick
X(`5')  Hits the monster one plus the player's \fBsword\fR,
Xand gives the player 10% of the monster's \fBexperience\fR.
XDecreases the monster's \fBexperience\fR
Xan amount proportional to the amount granted.
XThis also increases the monster's quickness.
XParalyzed monsters wake up very fast when nicked.
X.TP 1.5i
X.I luckout
X(`6' or `B')  This is essentially a battle of wits with the monster.  Success
Xis based upon the player's and the monster's \fBbrains\fR.
XThe player gets credit for slaying the monster if he/she succeeds.
XOtherwise, nothing happens, and the chance to \fBluckout\fR is lost.
X.sh "Character Statistics"
X.TP 1.5i
X.I strength
Xdetermines how much damage a character can inflict.
X.TP 1.5i
X.I quickness
Xdetermines how many chances a character gets to make decisions while
Xfighting.
X.TP 1.5i
X.I energy level
Xspecifies how much damage a character may endure before dying.
X.TP 1.5i
X.I magic level
Xdetermines which spells a character may throw, and how effective those
Xspells will be.
X.TP 1.5i
X.I brains
Xare basically the character's intelligence;  used for various
Xfighting options and spells.
X.TP 1.5i
X.I mana
Xis used as a power source for throwing spells.
X.TP 1.5i
X.I experience
Xis gained by fighting monsters and other characters.
X.TP 1.5i
X.I level
Xindicates how much experience a character has accumulated;  it progresses
Xgeometrically as \fBexperience\fR increases.
X.TP 1.5i
X.I poison
Xis sickness which degrades a character's performance (affects
X\fBenergy level\fR and \fBstrength\fR).
X.TP 1.5i
X.I sin
Xis accumulated as a character does certain nasty things;  used only rarely
Xin normal play of the game.
X.TP 1.5i
X.I age
Xnumber of seconds of playing time for the character.
XAs \fBage\fR increases, many personal statistics degenerate.
X.sh "Character Types"
XCharacter statistics are rolled randomly from the above list, according
Xto character type.  The types are as follows:
X.TP 1.5i
X.I magic user
Xstrong in \fBmagic level\fR and \fBbrains\fR, weak in other areas.
XMust rely on wits and magic to survive.
X.TP 1.5i
X.I fighter
Xgood in \fBstrength\fR and \fBenergy level\fR, fairly good in other areas.
XThis adds up to a well-equipped fighter.
X.TP 1.5i
X.I elf
Xvery high \fBquickness\fR and above average \fBmagic level\fR are
X\fBelves'\fR selling points.
X.TP 1.5i
X.I dwarf
Xvery high \fBstrength\fR and \fBenergy level\fR, but with a tendency to
Xbe rather slow and not too bright.
X.TP 1.5i
X.I halfling
Xrather quick and smart, with high \fBenergy level\fR, but poor in
X\fBmagic\fR and \fBstrength\fR.
XBorn with some \fBexperience\fR.
X.TP 1.5i
X.I experimento
Xvery mediocre in all areas.  However, the \fBexperimento\fR
Xmay be placed almost anywhere within the playing grid.
X.PP
XThe possible ranges for starting statistics are summarized in
Xthe following table.
X.sp
X.PP
X.TS
Xcenter, box;
Xl | c c c c c c
Xl | c c c c c c.
X\fBType	Strength	Quickness	Mana	Energy	Brains	Magic\fR
X_
X\fBMagic User\fR	20-25	30-35	50-100	30-45	60-85	5-9
X\fBFighter\fR	40-55	30-35	30-50	45-70	25-45	3-6
X\fBElf\fR	35-45	28-38	45-90	30-50	40-65	4-7
X\fBDwarf\fR	50-70	25-30	25-45	60-100	20-40	2-5
X\fBHalfling\fR	20-25	34	25-45	55-90	40-75	1-4
X\fBExperimento\fR	25	27	100	35	25	2
X.TE
X.sp
X.PP
XNot only are the starting characteristics different for the different
Xcharacter types, the characteristics progress at different rates for the
Xdifferent types as the character goes up in \fBlevel\fR.  Experimentoes'
Xcharacteristics progress randomly as one of the other types.
XThe progression as characters increase in
X\fBlevel\fR is summarized in the following table.
X.PP
X.TS
Xcenter, box;
Xl | c c c c c
Xl | n n n n n.
X\fBType	Strength	Mana	Energy	Brains	Magic\fR
X_
X\fBMagic User\fR	2.0	75	20	6	2.75
X\fBFighter\fR	3.0	40	30	3.0	1.5
X\fBElf\fR	2.5	65	25	4.0	2.0
X\fBDwarf\fR	5	30	35	2.5	1
X\fBHalfling\fR	2.0	30	30	4.5	1
X.TE
X.sp
X.PP
XCharacter types are identified by numeric values as follows:
X.sp
X1:  \fBMagic User\fR    2:  \fBFighter\fR    3:  \fBElf\fR    4:  \fBDwarf\fR\ \ \ \ 
X5:  \fBHalfling\fR    6:  \fBExperimento\fR
X.PP
XCharacters with one or more \fBcrowns\fR
Xare designated as higher types.
X\fBKings\fR have ten added to their type;  members of the
X\fBcouncil of the wise\fR have twenty added to their type.
X\fBValar\fR are type 99, and \fBex-valar\fR are type 90.
X.sh "Spells"
XDuring the course of the game, the player may exercise his/her particular
Xmagic powers.  These cases are described below.
X.TP 1.5i
X.I cloak
X.I Magic level necessary:
X20 (plus level 7)
X.br
X.I Mana used:
X35 plus 3 per rest period
X.br
XUsed during normal play.  Prevents monsters from finding the character,
Xas well as hiding the player from other players.  His/her coordinates
Xshow up as `?' in the \fBplayers\fR option.  Players cannot collect
X\fBmana\fR, find trading posts, or discover the \fBgrail\fR while cloaked.
XCalling a monster uncloaks, as well as choosing this option while cloaked.
X.br
X.TP 1.5i
X.I teleport
X.I Magic level necessary:
X40 (plus level 12)
X.br
X.I Mana used:
X30 per 75 moved
X.br
XUsed during normal play.  Allows the player too move with much more freedom
Xthan with the \fBmove\fR option, at the price of expending mana.
XThe maximum distance possible to move is based upon \fBlevel\fR
Xand \fBmagic level\fR.
X.TP 1.5i
X.I power blast
X.I Magic level necessary:
Xnone
X.br
X.I Mana used:
X5 times \fBlevel\fR
X.br
XUsed during inter-terminal battle.  Damage is based upon \fBmagic level\fR
Xand \fBstrength\fR.
XHits much harder than a normal hit.
X.TP 1.5i
X.I all or nothing
X.I Magic level necessary:
Xnone
X.br
X.I Mana used:
X1
X.br
XUsed while combatting monsters.
XHas a 25% chance of working.  If it works it hits the monster just enough
Xto kill it.  If it fails, it doesn't hit the monster, and doubles the
Xmonster's \fBquickness\fR and \fBstrength\fR.
XParalyzed monsters wake up much quicker as a result of this spell.
X.TP 1.5i
X.I magic bolt
X.I Magic level necessary:
X5
X.br
X.I Mana used:
Xvariable
X.br
XUsed while combatting monsters.  Hits the monster based upon the amount
Xof \fBmana\fR expended and \fBmagic level\fR.
XGuaranteed to hit at least 10 per \fBmana\fR.
X.TP 1.5i
X.I force field
X.I Magic level necessary:
X15
X.br
X.I Mana used:
X30
X.br
XUsed during monster combat.  Throws up a shield to protect from damage.
XThe shield is added to actual energy level, and is a fixed number, based
Xupon maximum energy.  Normally, damage occurs first to the shield, and
Xthen to the players actual \fBenergy level\fR.
X.TP 1.5i
X.I transform
X.I Magic level necessary:
X25
X.br
X.I Mana used:
X50
X.br
XUsed during monster combat.  Transforms the monster randomly into one
Xof the other 100 monsters from the monster file.
X.TP 1.5i
X.I increase might
X.I Magic level necessary:
X35
X.br
X.I Mana used:
X75
X.br
XUsed during combat with monsters.  Increases strength up to a certain maximum.
X.TP 1.5i
X.I invisibility
X.I Magic level necessary:
X45
X.br
X.I Mana used:
X90
X.br
XUsed while fighting monsters.  Makes it harder for the monster to hit,
Xby temporarily increasing the player's \fBquickness\fR.
XThis spell may be thrown several times, but a maximum level will be reached.
X.TP 1.5i
X.I transport
X.I Magic level necessary:
X60
X.br
X.I Mana used:
X125
X.br
XUsed during monster combat.  Transports the monster away from the
Xplayer.  Success is based upon player's \fBmagic\fR and \fBbrains\fR,
Xand the monster's \fBexperience\fR.
XIf it fails the player is transported instead.  60% of the time, the monster
Xwill drop any treasure it was carrying.
X.TP 1.5i
X.I paralyze
X.I Magic level necessary:
X75
X.br
X.I Mana used:
X150
X.br
XUsed during monster combat.  ``Freezes'' the monster by putting its
X\fBquickness\fR slightly negative.  The monster will slowly wake up.
XSuccess is based upon player's \fBmagic\fR and the monster's \fBexperience\fR.
XIf it fails, nothing happens.
X.TP 1.5i
X.I specify
X.I Magic level necessary:
Xnone
X.br
X.I Mana used:
X1000
X.br
XUsed during monster combat only by \fBvalar\fR or \fBcouncil of the wise\fR.
XAllows the player to pick which monster to fight.
X.sh "Monsters"
XMonsters get bigger as one moves farther from the origin (0,0).  Rings of
Xdistance 125 from the origin determine the size.  A monster's
X\fBexperience, energy level\fR, and \fBbrains\fR are multiplied by the size.
X\fBStrength\fR is increased 50% per size over one, and \fBquickness\fR
Xremains the same, regardless of size.
X.PP
XAlso, meaner monsters are to be found as one progress farther out
Xfrom the origin.  Monsters also may flock.  The percent chance of that
Xhappening is designated as \fIflock%\fR in the monster listing.
XMonsters outside the first ring
Xmay carry treasure, as determined by their treasure type.
XFlocking monsters and bigger monsters increase the chances of treasure.
X.PP
XCertain monsters have special abilities;  they are as follows:
X.TP 1.5i
X.I Unicorn
Xcan only be subdued if the player is in possession of a \fBvirgin\fR.
X.TP 1.5i
X.I Modnar
Xhas random characteristics, including treasure type.
X.TP 1.5i
X.I Mimic
Xwill pick another name from the list of monsters in order to confuse.
X.TP 1.5i
X.I Dark Lord
Xvery nasty person.  Does not like to be hit (especially nicked),
Xand many spells do not work well against him.
XOne can always \fBevade\fR from the \fBDark Lord\fR.
X.TP 1.5i
X.I Leanan-Sidhe
Xalso a very nasty person.  She will permanently sap \fBstrength\fR from someone.
X.TP 1.5i
X.I Saruman
Xwanders around with \fBWormtongue\fR, who can steal a \fBpalantir\fR.
XAlso, \fBSaruman\fR may turn a player's gems into gold pieces,
Xor scramble her/his stats.
X.TP 1.5i
X.I Thaumaturgist
Xcan transport a player.
X.TP 1.5i
X.I Balrog
Xinflicts damage by taking away \fBexperience\fR, not \fBenergy\fR.
X.TP 1.5i
X.I Vortex
Xmay take some \fBmana\fR.
X.TP 1.5i
X.I Nazgul
Xmay try to steal a \fBring\fR or neutralize part of one's \fBbrains\fR.
X.TP 1.5i
X.I Tiamat
Xmay take half a players \fBgold\fR and \fBgems\fR and escape.
X.TP 1.5i
X.I Kobold
Xmay get nasty and steal one gold piece and run away.
X.TP 1.5i
X.I Shelob
Xmay bite, inflicting the equivalent of one \fBpoison\fR.
X.TP 1.5i
X.I Assorted Faeries
XThese are killed if attacking someone carrying \fBholy water\fR.
XThese are \fBCluricaun, Fir Darrig, Fachan, Ghille Dhu, Bogle, Killmoulis\fR,
Xand \fBBwca\fR.
X.TP 1.5i
X.I Lamprey
Xmay bite, inflicting 1/2 of a \fBpoison\fR.
X.TP 1.5i
X.I Shrieker
Xwill call one of its (much bigger) buddies if picked upon.
X.TP 1.5i
X.I Bonnacon
Xwill become bored with battle, fart devastatingly, and run off.
X.TP 1.5i
X.I Smeagol
Xwill try to steal a \fBring\fR from a player, if given the chance.
X.TP 1.5i
X.I Succubus
Xmay inflict damage through a \fBforce field\fR.
XThis subtracts from \fBenergy level\fR instead of any shield the player
Xmay have thrown up.
XThis is a very easy way to die.
X.TP 1.5i
X.I Cerberus
Xloves metal and will steal all the metal treasures from a player if able.
X.TP 1.5i
X.I Ungoliant
Xcan bite and poison.  This inflicts five \fBpoisons\fR, and also takes
Xone from the player's \fBquickness\fR.
X.TP 1.5i
X.I Jabberwock
Xmay tire of battle, and leave after calling one of his bigger friends
X(\fBJubjub Bird\fR or \fBBandersnatch\fR).
X.TP 1.5i
X.I Morgoth
Xactually \fBModnar\fR, but reserved for \fBcouncil of the wise, valar\fR,
Xand \fBex-valar\fR.
XFights with \fBMorgoth\fR end when either he or the player dies.
XHis characteristics are calculated based upon the player's.
XThe player is given the chance to ally with him.  No magic, except
X\fBforce field\fR works when battling \fBMorgoth\fR.
X.TP 1.5i
X.I Troll
Xmay regenerate its \fBenergy\fR and \fBstrength\fR while in battle.
X.TP 1.5i
X.I Wraith
Xmay make a player blind.
X.sh "Treasures"
XVarious treasure types are as follows:
X.TP 1.5i
X\fBType zero\fR
X.I none
X.TP 1.5i
X\fBType one\fR
X.I power booster
X\- adds mana.
X.br
X.I druid
X\- adds experience.
X.br
X.I holy orb
X\- subtracts 0.25 sin.
X.TP 1.5i
X\fBType two\fR
X.I amulet
X\- protects from cursed treasure.
X.br
X.I holy water
X\- kills \fBassorted faeries\fR.
X.br
X.I hermit
X\- reduces \fBsin\fR by 25% and adds some \fBmana\fR.
X.TP 1.5i
X\fBType three\fR
X.I shield
X\- adds to maximum \fBenergy level\fR
X.br
X.I virgin
X\- used to subdue a \fBunicorn\fR, or to give much \fBexperience\fR
X(and some \fBsin\fR).
X.br
X.I athelas
X\- subtracts one \fBpoison\fR.
X.TP 1.5i
X.B Type four (scrolls)
X.I shield
X* \- throws a bigger than normal \fBforce field\fR.
X.br
X.I invisible
X* \- puts the finder's \fBquickness\fR to one million.
X.br
X.I ten fold strength
X* \- multiplies finder's strength by ten.
X.br
X.I pick monster
X\- allows finder to pick next monster to battle.
X.br
X.I general knowledge
X\- adds to finder's \fBbrains\fR and \fBmagic level\fR.
X.PP
XAll the scrolls except \fBgeneral knowledge\fR
Xautomatically call a monster.  Those that are marked with a * preserve any
Xspells that were already in effect.  Those that call monsters are only in
Xeffect while in battle.
X.TP 1.5i
X.B Type five
X.I dagger
X\- adds to \fBstrength\fR.
X.br
X.I armour
X\- same as a \fBshield\fR, but bigger.
X.br
X.I tablet
X\- adds brains.
X.TP 1.5i
X.B Type six
X.I priest
X\- rests to maximum; adds 
X\fBmana, brains\fR;  and halves \fBsin\fR.
X.br
X.I Robin Hood
X\- increases \fBshield\fR and adds permanently to \fBstrength\fR.
X.br
X.I axe
X\- like \fBdagger\fR, but bigger.
X.TP 1.5i
X.B Type seven
X.I charm
X\- protects from cursed treasure (used before \fBamulet\fR);  used in
Xconjunction with \fBblessing\fR to battle \fBDark Lord\fR.
X.br
X.I Merlyn
X\- adds \fBbrains, magic\fR, and \fBmana\fR.
X.br
X.I war hammer
X\- like an \fBaxe\fR, but bigger.
X.TP 1.5i
X.B Type eight
X.I healing potion
X\- sets \fBpoison\fR to -2, or subtracts two from \fBpoison\fR,
Xwhichever is better.
X.br
X.I transporter
X\- allows finder to move anywhere.
X.br
X.I sword
X\- like a \fBwar hammer\fR, but bigger.
X.TP 1.5i
X.B Type nine
X.I golden crown
X\- allows the player to become \fBking\fR, by going to (0,0).
X.br
X.I blessing
X\- cuts \fBsin\fR to 1/3, adds \fBmana\fR, rests to maximum, kills
X\fBDark Lord\fR with a \fBcharm\fR, and gives bearer first hit on all monsters.
X.br
X.I quicksilver
X\- adds to \fBquickness\fR.
X.TP 1.5i
X.B Type ten
X.I elven boots
X\- adds permanently to \fBquickness\fR.
X.TP 1.5i
X.B Type eleven
X.I palantir
X\- allows one to see all the other players;  used by
X\fBcouncil of the wise\fR to seek the \fBgrail\fR.
X.TP 1.5i
X.B Type twelve/thirteen
X.I ring
X\- allows one to hit much harder in battle, etc.
X.PP
XAny treasure type 10-13 monsters may carry a type nine treasure instead.
X.PP
XA monster may also be carrying \fBgold\fR or \fBgems\fR.
XThese are used at \fBtrading posts\fR to buy things.  A \fBgem\fR
Xis worth 1000 gold pieces.  Too much \fBgold\fR
Xwill slow a player down.  One may carry 1000 plus 200 per
X\fBlevel\fR of \fBgold\fR.
XA \fBgem\fR weighs one half a gold piece.
XMonsters of treasure type 7 or higher may carry \fBgems\fR.
X.PP
XThe chance of a cursed treasure is based upon treasure type.
XThe more valuable treasures have a greater chance of being cursed.
XA cursed treasure knocks \fBenergy level\fR very low, and adds 0.25
X\fBpoison\fR.
X.sh "Rings"
X\fBRings\fR are only carried by \fBnazguls\fR and \fBDark Lord\fR.
XThey come in four different flavors.
XAll \fBrings\fR rest the player to maximum and cause him/her to hit much harder
Xin battle with monsters (assuming one has chosen to use the
X\fBring\fR for battle.)
X.PP
XTwo types of \fBrings\fR are cursed and come either from \fBnazguls\fR
Xor \fBDark Lord\fR.
XAfter a few times of using these types, the player falls
Xunder the control of the \fBring\fR, and strange, random things will occur.
XEventually, the player dies, and gives his/her name to a monster
Xon the file.
XDying before the \fBring\fR is used up also renames the monster.
X.PP
XThe two remaining types of \fBrings\fR are much more benign.
XThe one from a \fBnazgul\fR
Xis good for a limited number of battle rounds, and will save
Xthe player from death if it was being used when he/she died.
XThe one from \fBDark Lord\fR is the same, except that it never is used up.
X\fBRings\fR disappear after saving someone from death.
XIn general, cursed \fBrings\fR occur much more often than normal ones.
XIt is usually not a good idea to pick one up.
XThe only way to get rid of a \fBring\fR is to have a monster steal it.
X.sh "King"
XA player may become \fBking\fR by finding a \fIcrown\fR
Xand going to (0,0).  Players must have a \fBlevel\fR
Xin the range of 10 to 1000 to be able to find a \fIcrown\fR.
X.PP
XOnce a player is king, he/she may do certain things while in 
Xthe Lord's Chamber (0,0).  These fall under the \fBdecree\fR (`0') option.
X.TP 1.5i
X.I census
XLists all players on file, whether playing or not.
X.TP 1.5i
X.I transport
XThis is done to another player.  It randomly moves the affected
Xplayer about.  A \fBcharm\fR protects from transports.
X.TP 1.5i
X.I curse
XThis is done to another player.  It is analogous to cursed treasure,
Xbut worse.  It inflicts two \fBpoison\fR, knocks \fBenergy level\fR
Xvery low, and degrades the maximum energy.  It also removes a \fBcloak\fR.
XA \fBblessing\fR protects from king's curses.
X.TP 1.5i
X.I energy void
XThe king may put as many of these (within reason) scattered about
Xhis/her kingdom as he/she pleases.
XIf a player hits one, he/she loses \fBmana, energy\fR, and \fBgold\fR.
XThe energy void disappears after being hit.
X.TP 1.5i
X.I bestow
XThis is also done to another player.  The king may
Xwish to reward one or more loyal subjects by sharing his/her
Xriches (\fBgold\fR).  Or it is a convenient way to dispose of some unwanted
Xdeadweight.
X.TP 1.5i
X.I collect taxes
XEveryone pays 10% tax on all \fBgold\fR collected, regardless of the
Xexistence of a \fBking\fR.
XThe king may collect this amount with this option.
X.PP
XThe \fBking\fR may also \fBteleport\fR
Xanywhere for free by using the origin as a starting place.
X.sh "Special Places"
XCertain regions of the playing grid have different names.
XIn general, this is only to give the player some idea of
Xhis/her present location.  Some special places do exist.
X.TP 1.5i
X.I Trading Posts
XThese are located at |x| == |y| == n*n*100 for n = 1, 2...1000.
XTrading posts farther out have more things for sale.
XBe careful about cheating merchants there, as they have short
Xtempers.
XMerchants are dishonest about 5% of the time.
X.TP 1.5i
X.I Lord's Chamber
XThis is located at (0,0).  Only players with
X\fIcrowns\fR may enter.
X.TP 1.5i
X.I Point of No Return
XThis is located beyond 1.2e+6 in any direction.
XThe only way to return from here is a \fItransporter\fR or to have a
X\fBvalar\fR relocate the player.
X.TP 1.5i
X.I Dead Marshes
XThis is a band located fairly distant from the origin.  The first
Xfourteen monsters (water monsters) can normally only be found here.
X.TP 1.5i
X.I Valhala
XThis place is where the \fBvalar\fR resides.
XIt is associated with no particular coordinate on the playing grid.
X.TP 1.5i
X.I Wormholes
XAt fixed locations on the grid are several holes to underground
Xdefects in the playing area.
XSixty-four chambers exist;  sixteen of which open to the outside world.
XWhile in the wormholes, one move by going forward, backward,
Xleft, or right.
XOne can always undo a move by going in the opposite direction.
XThe wormholes are mappable.
XFor example, to move from the first wormhole (at (-400,0)) to
Xthe second wormhole, type `LL'.
X.sh "Miscellaneous"
XThere are several bits of trivial knowledge which fall under this category.
X.PP
XOnce a player reaches \fBlevel\fR 5, the game will start to time out
Xwaiting for input.
XThis is to try to keep the game a bit faster paced.
XThe game may be temporarily suspended (when not fighting) by typing
XControl-S;  any normal command re-starts it.
X.PP
XA \fIguru\fR will never be disgusted with your \fBsins\fR
Xif they are less than one.
X.PP
XA \fIphysician\fR wants half of a player's \fBgold\fR
Xto be happy.  Offering more than one has, or a negative amount
Xwill anger the \fIphysician\fR, who will make the player worse (add one
X\fBpoison\fR).
X.PP
XThe \fBHoly Grail\fR does little for those who are not ready to behold it.
XWhenever anyone finds it, it moves.
XIt is always located within 1e+6 in any compass direction of the origin.
X.PP
XThere is a maximum amount of \fBmana\fR and \fBcharms\fR
Xa player may posses, based upon \fBlevel\fR.
X.I Quicksilver
Xis always limited to to a maximum of 99.
X.PP
X.I Books
Xbought at a \fBtrading post\fR increase \fBbrains\fR,
Xbased upon the number bought.
XIt is unwise, however to buy more than 1/10 of one's \fBlevel\fR
Xin books at a time.
X.PP
XPlayers over level 10000 are automatically retired.
X.PP
XA \fIblindness\fR goes away in random time.
X.sh "Inter-terminal Battle"
XWhen two player's coordinates correspond, they may engage in battle.
XIn general, the player with the highest \fBquickness\fR
Xgets the first hit.
XIf the two players are severely mis-matched, the stronger player
Xis drastically handicapped for the battle.
XIn order to protect from being stuck in an infinite loop,
Xthe player waiting for response may time out.  Options for battle are:
X.TP 1.5i
X.I fight
XInflicts damage upon other person.
X.TP 1.5i
X.I run away
XEscape from battle.  Has a 75% chance of working.
X.TP 1.5i
X.I power blast
XBattle spell.
X.TP 1.5i
X.I luckout
XOne-time chance to try to win against the foe.  Has a 10% chance of working.
X.PP
XSometimes waits for the other player may be excessive, because
Xhe/she may be battling a monster.  Upon slaying a player in battle
Xthe winner gets the other's \fBexperience\fR and treasures.
X\fBRings\fR do not work for inter-terminal battle.
X.sh "Council of the Wise, Valar"
XA player automatically becomes a member of the \fBcouncil of the wise\fR
Xupon reaching level 3000.  Members of the council cannot have \fBrings\fR.
XMembers of the council have a few extra options which they can exercise.
XThese fall under the \fBintervention\fR (`8') option.
XOne is to \fIheal\fR another player.  This is just a quick way for
Xthat player to be rested to maximum and lose a little \fBpoison\fR.
XThe main purpose in life for members of the council is to seek the
X\fBHoly Grail\fR.
XThis is done with a \fBpalantir\fR under the
X.I seek grail
Xoption.  The distance cited by the seek is accurate within 10%, in order
Xnot to make it too easy to find the grail.  Seeking costs 1000 \fBmana\fR.
XA player must have infintesimally small
X\fBsin\fR, or else it's all over upon finding the grail.
XIn order to help members of the council on their quest, they may
X.I teleport
Xwith greater ease.
X.PP
XUpon finding the grail, the player advance to position of \fBvalar\fR.
XHe/she may then exercise more and niftier options under
X.I intervention.
XThese include all of the council members' options plus the
Xability to move other players about, bless them, and throw monsters at them.
X\fBValar\fR are essentially immortal, but are actually given five lives.
XIf these are used up, the player is left to die, and becomes an
X\fBex-valar\fR.
X\fBValar\fR cannot
X.I move, teleport,
Xor call monsters.
XAny monsters which a \fBvalar\fR encounters are based upon his/her size.
XOnly one valar may exists at a time.
XA player replaces the exiting valar upon finding the grail.
XThe valar is then bumped back to the council of the wise.
X.SH BUGS
XThe handling of incorrectly exited characters is a kludge.
XThe screen is set up assuming a 24 by 80
Xcharacter screen;  no attempt was made to provide otherwise.
XIf any of the data items get too big for the allotted space on the screen,
Xno guarantees are made about what will happen.
TiDDleYwiNKs
	size="`wc -c phant.nr`"
	size=`set - $size;echo $1`
echo "x - phant.nr, $size characters"

	if test "$size" != "27833"
		then
		echo "Warning: error in transmitting 'phant.nr';  should have 27833 characters."
	fi
fi
if test -s "func0.c"
	then
	echo Will not overwrite existing 'func0.c'
else
	sed -e "s/^X//" > func0.c << 'TiDDleYwiNKs'
X/*
X * func0.c  Phantasia support routines
X */
X
X#include "phant.h"
X
Xvoid
Xtreasure(stat,treastyp,size)	    /* select a treasure */
Xreg 	struct  stats   *stat;
Xshort	treastyp;
Xreg 	int 	size;
X{
Xreg 	int 	which;
X		int 	ch;
X		double	temp, temp2;
X		char	aline[35];
X		FILE	*fp;
X
X	which = roll(1,3);
X	move(4,0);
X	clrtobot();
X	move(6,0);
X	if (rnd() > 0.65)	/* gold and gems */
X		if (treastyp > 7)   /* gems */
X		{
X			temp = roll(1,(treastyp - 7)*(treastyp - 7)*(size - 1)/4);
X			printw("You have discovered %.0f gems!  Will you pick them up? ",
X					temp);
X			ch = getans("NY", FALSE);
X			addstr("\n\n");
X			if (ch == 'Y')
X				if (rnd() < treastyp/40 + 0.05) /* cursed */
X				{
X					addstr("They were cursed!\n");
X					goto CURSE;
X				}
X				else
X				{
X					stat->gem += temp;
X					goto EXIT;
X				}
X			else
X				return;
X		}
X		else	/* gold */
X		{
X			temp = roll(treastyp*10,treastyp*treastyp*10*(size - 1));
X			printw("You have found %.0f gold pieces.  Do you want to pick them up? ",temp);
X			ch = getans("NY", FALSE);
X			addstr("\n\n");
X			if (ch == 'Y')
X				if (rnd() < treastyp/35 + 0.04) /* cursed */
X				{
X					addstr("They were cursed!\n");
X					goto CURSE;
X				}
X				else
X				{
X					stat->gld += floor(0.9 * temp);
X					if ((fp = fopen(goldfile,"r")) == NULL)
X					{
X						error(goldfile);
X						/*NOTREACHED*/
X					}
X					fread((char *) &temp2,sizeof(double),1,fp);
X					fclose(fp);
X					fp = fopen(goldfile,"w");
X					temp2 += floor(temp/10);
X					fwrite((char *) &temp2,sizeof(double),1,fp);
X					fclose(fp);
X					goto EXIT;
X				}
X			else
X				return;
X		}
X	else    /* other treasures */
X	{
X		addstr("You have found some treasure.  Do you want to inspect it? ");
X		ch = getans("NY", FALSE);
X		addstr("\n\n");
X		if (ch != 'Y')
X			return;
X		else
X			if (rnd() < 0.08 && treastyp != 4)
X			{
X				addstr("It was cursed!\n");
X				goto CURSE;
X			}
X			else
X				switch(treastyp)
X				{
X					case 1:
X						switch(which)
X						{
X							case 1:
X								addstr("You've discovered a power booster!\n");
X								stat->man += roll(size*4,size*30);
X								break;
X							case 2:
X								addstr("You have encountered a druid.\n");
X								stat->exp += roll(0,2000 + size*400);
X								break;
X							case 3:
X								addstr("You have found a holy orb.\n");
X								stat->sin = max(0,stat->sin - 0.25);
X								break;
X						}
X						break;
X					case 2:
X						switch (which)
X						{
X							case 1:
X								addstr("You have found an amulet.\n");
X								++stat->amu;
X								break;
X							case 2:
X								addstr("You've found some holy water!\n");
X								++stat->hw;
X								break;
X							case 3:
X								addstr("You've met a hermit!\n");
X								stat->sin *= 0.75;
X								stat->man += 12*size;
X								break;
X						}
X						break;
X					case 3:
X						switch (which)
X						{
X							case 1:
X								temp = roll(7,30 + size/10);
X								printw("You've found a +%.0f shield!\n",temp);
X								if (temp >= stat->shd)
X									stat->shd = temp;
X								else
X									somebetter();
X								break;
X							case 2:
X								addstr("You have rescued a virgin.  Will you be honorable? ");
X								ch = getans("NY", FALSE);
X								addstr("\n\n");
X								if (ch == 'Y')
X									stat->vrg = TRUE;
X								else
X								{
X									stat->exp += 2000*size;
X									++stat->sin;
X								}
X								break;
X							case 3:
X								addstr("You've discovered some athelas!\n");
X								--stat->psn;
X								break;
X						}
X						break;
X					case 4:
X						addstr("You've found a scroll. Will you read it? ");
X						ch = getans("NY", FALSE);
X						addstr("\n\n");
X						if (ch == 'Y')
X							switch ((int) roll(1,6))
X							{
X								case 1:
X									addstr("It throws up a shield against your next monster.\n");
X									getyx(stdscr, which, ch);
X									more(which);
X									longjmp(fightenv,2);
X									/*NOTREACHED*/
X								case 2:
X									addstr("It makes you invisible to your next monster.\n");
X									getyx(stdscr, which, ch);
X									more(which);
X									speed = 1e6;
X									longjmp(fightenv,0);
X									/*NOTREACHED*/
X								case 3:
X									addstr("It increases your strength ten fold to fight your next monster.\n");
X									getyx(stdscr, which, ch);
X									more(which);
X									strength *= 10;
X									longjmp(fightenv,0);
X									/*NOTREACHED*/
X								case 4:
X									addstr("It is a general knowledge scroll.\n");
X									stat->brn += roll(2,size);
X									stat->mag += roll(1,size/2);
X									break;
X								case 5:
X									addstr("It tells you how to pick your next monster.\n");
X									addstr("Which monster do you want [0-99]? ");
X									which = inflt();
X									which = min(99,max(0,which));
X									fight(stat,which);
X									return;
X								case 6:
X									addstr("It was cursed!\n");
X									goto CURSE;
X							}
X							break;
X						case 5:
X							switch (which)
X							{
X								case 1:
X									temp = roll(size/4+5,size/2 + 9);
X									printw("You've discovered a +%.0f dagger.\n",temp);
X									if (temp >= stat->swd)
X										stat->swd = temp;
X									else
X										somebetter();
X									break;
X								case 2:
X									temp = roll(7.5 + size*3,size*2 + 160);
X									printw("You have found some +%.0f armour!\n",temp);
X									if (temp >= stat->shd)
X										stat->shd = temp;
X									else
X										somebetter();
X									break;
X								case 3:
X									addstr("You've found a tablet.\n");
X									stat->brn += 4.5*size;
X									break;
X							}
X							break;
X						case 6:
X							switch (which)
X							{
X								case 1:
X									addstr("You've found a priest.\n");
X									stat->energy = stat->mxn + stat->shd;
X									stat->sin /= 2;
X									stat->man += 24*size;
X									stat->brn += size;
X									break;
X								case 2:
X									addstr("You have come upon Robin Hood!\n");
X									stat->shd += size*2;
X									stat->str += size/2.5 + 1;
X									break;
X								case 3:
X									temp = roll(2 + size/4,size/1.2 + 10);
X									printw("You have found a +%.0f axe!\n",temp);
X									if (temp >= stat->swd)
X										stat->swd = temp;
X									else
X										somebetter();
X									break;
X							}
X							break;
X						case 7:
X							switch (which)
X							{
X								case 1:
X									addstr("You've discovered a charm!\n");
X									++stat->chm;
X									break;
X								case 2:
X									addstr("You've encountered Merlyn!\n");
X									stat->brn += size + 5;
X									stat->mag += size/3 + 5;
X									stat->man += size*10;
X									break;
X								case 3:
X									temp = roll(5+size/3,size/1.5 + 20);
X									printw("You have found a +%.0f war hammer!\n",temp);
X									if (temp >= stat->swd)
X										stat->swd = temp;
X									else
X										somebetter();
X									break;
X							}
X							break;
X						case 8:
X							switch (which)
X							{
X								case 1:
X									addstr("You have found a healing potion.\n");
X									stat->psn = min(-2,stat->psn-2);
X									break;
X								case 2:
X									addstr("You have discovered a transporter.  Do you wish to go anywhere? ");
X									ch = getans("NY", FALSE);
X									addstr("\n\n");
X									if (ch == 'Y')
X									{
X										addstr("X Y Coordinates? ");
X										getstring(aline,80);
X										sscanf(aline,"%F %F",&stat->x,&stat->y);
X										stat->x = floor(stat->x);
X										stat->y = floor(stat->y);
X									}
X									break;
X								case 3:
X									temp = roll(10 + size/1.2,size*3 + 30);
X									printw("You've found a +%.0f sword!\n",temp);
X									if (temp >= stat->swd)
X										stat->swd = temp;
X									else
X										somebetter();
X									break;
X							}
X							break;
X						case 10:
X						case 11:
X						case 12:
X						case 13:
X							if (rnd() < 0.33)
X							{
X								if (treastyp == 10)
X								{
X									addstr("You've found a pair of elven boots!\n");
X									stat->quk += 2;
X									break;
X								}
X								else if (treastyp == 11 && !stat->pal)
X								{
X									addstr("You've acquired Saruman's palantir.\n");
X									stat->pal = TRUE;
X									break;
X								}
X								else if (!stat->rng.type && stat->typ < 20 
X									& (treastyp == 12 || treastyp == 13))
X								{
X									if (rnd() < 0.8)
X									{
X										which = NAZREG;
X										temp = 15;
X									}
X									else
X									{
X										which = NAZBAD;
X										temp = 10 + rngcalc(stat->typ) +
X													roll(0,5);
X									}
X								}
X								else
X									if (rnd() > 0.9)
X									{
X										which = DLREG;
X										temp = 0;
X									}
X									else
X									{
X										which = DLBAD;
X										temp = 15 + rngcalc(stat->typ) +
X													roll(0,5);
X									}
X								addstr("You've discovered a ring.  Will you pick it up? ");
X								ch = getans("NY", FALSE);
X								addstr("\n\n");
X								if (ch == 'Y')
X								{
X									stat->rng.type = which;
X									stat->rng.duration = temp;
X								}
X								break;
X						}
X					case 9:
X						switch (which)
X						{
X							case 1:
X								if (!(stat->lvl > 1000 || stat->crn >
X									floor((double) stat->lvl/100)
X									|| stat->lvl < 10))
X								{
X									addstr("You have found a golden crown!\n");
X									++stat->crn;
X									break;
X								}
X								/*FALLTHROUGH*/
X							case 2:
X								addstr("You've been blessed!\n");
X								stat->bls = TRUE;
X								stat->sin /= 3;
X								stat->energy = stat->mxn + stat->shd;
X								stat->man += 100*size;
X								stat->lives--;
X								break;
X							case 3:
X								temp = roll(1,size/5+5);
X								temp = min(temp,99);
X								printw("You have discovered some +%.0f quicksilver!\n",temp);
X								if (temp >= stat->quks)
X									stat->quks = temp;
X								else
X									somebetter();
X								break;
X						}
X				}
X	}
X	goto EXIT;
XCURSE:
X	if (stat->chm)
X	{
X		addstr("But your charm saved you!\n");
X		--stat->chm;
X	}
X	else if (stat->amu)
X	{
X		addstr("But your amulet saved you!\n");
X		--stat->amu;
X	}
X	else
X	{
X		stat->energy = (stat->mxn + stat->shd)/10;
X		stat->psn += 0.25;
X	}
XEXIT:
X	getyx(stdscr, which, ch);
X	more(which);
X}
X
Xvoid
Xcallmonster(which,size,mons)
X					/* fill a structure with monster 'which' of size 'size' */
Xreg int which, size;
Xreg struct  mstats  *mons;
X{
X	char	instr[100];
X
X	which = min(which,99);
X	fseek(mfile,0L,0);
X	for (++which; which; --which)
X		fgets(instr,100,mfile);
X	strncpy(mons->mname,instr,18);
X	mons->mname[18] = '\0';
X	sscanf(instr + 18,"%F%F%F%F%F%d%d%d",&mons->mstr,&mons->mbrn,&mons->mspd,
X			&mons->mhit, &mons->mexp,&mons->mtrs,&mons->mtyp,&mons->mflk);
X	if (mons->mtyp == 2) /* Modnar */
X	{
X		mons->mstr *= rnd() + 0.5;
X		mons->mbrn *= rnd() + 0.5;
X		mons->mspd *= rnd() + 0.5;
X		mons->mhit *= rnd() + 0.5;
X		mons->mexp *= rnd() + 0.5;
X		mons->mtrs *= rnd();
X	}
X	else if (mons->mtyp == 3)	/* mimic */
X	{
X		fseek(mfile,0L,0);
X		for (which = roll(0,100); which; --which)
X			fgets(instr,100,mfile);
X		strncpy(mons->mname,instr,18);
X	}
X	trunc(mons->mname);
X	mons->mstr += (size-1)*mons->mstr/2;
X	mons->mbrn *= size;
X	mons->mspd += size * 1.e-9;
X	mons->mhit *= size;
X	mons->mexp *= size;
X}
X
X/* lookup table for rolling stats and making increases upon gaining levels */
Xstruct
X{
X	struct
X	{
X		int		base;
X		int		interval;
X		float	increase;
X	} quick,      strength,      mana,	Energy,    brains,    magic;
X	} table[7] =
X	{
X/* mag. usr */
X30, 6, 0.0,  20, 6, 2.0,   50,51,75.0,   30,16,20.0,   60,26, 6.0,  5, 5,2.75,
X/* fighter  */
X30, 6, 0.0,  40,16, 3.0,   30,21,40.0,   45,26,30.0,   25,21, 3.0,  3, 4, 1.5,
X/* elf    */
X32, 7, 0.0,  35,11, 2.5,   45,46,65.0,   30,21,25.0,   40,26, 4.0,  4, 4, 2.0,
X/* dwarf   */
X25, 6, 0.0,  45,21, 5.0,   25,21,30.0,   60,41,35.0,   20,21, 2.5,  2, 4, 1.0,
X/* halfling */
X34, 0, 0.0,  20, 6, 2.0,   25,21,30.0,   55,36,30.0,   40,36, 4.5,  1, 4, 1.0,
X/* exprmnto */
X27, 0, 0.0,  25, 0, 0.0,   100,0, 0.0,   35, 0, 0.0,   25, 0, 0.0,  2, 0, 0.0,
X/* super   */
X38, 0, 0.0,  65, 0, 0.0,   100,0, 0.0,   80, 0, 0.0,   85, 0, 0.0,  9, 0, 0.0
X	};
X
Xvoid
Xgenchar(res,type)		/* init a charac struct */
Xint		type;
Xreg struct  stats   *res;
X{
X	register int	i;
X
X	if (type < '1' || type > '6')
X		if (type != '7' || !su)
X			type = '2'; /* fighter is default */
X	i = type - '1';
X	res->quk = roll(table[i].quick.base,table[i].quick.interval);
X	res->str = roll(table[i].strength.base,table[i].strength.interval);
X	res->man = roll(table[i].mana.base,table[i].mana.interval);
X	res->mxn = res->energy = roll(table[i].Energy.base,table[i].Energy.interval);
X	res->brn = roll(table[i].brains.base,table[i].brains.interval);
X	res->mag = roll(table[i].magic.base,table[i].magic.interval);
X	res->typ = i;
X	if (i < 6)
X		++res->typ;
X	if (type == '5')
X		res->exp = roll(600,200);   /* give halfling some exp. */
X	res->lives = 0;
X}
X
Xvoid
Xmovelvl(stat)		    /* update stats for new level */
Xreg struct  stats   *stat;
X{
X	reg int			type;
X	reg unsigned	new;
X	double			inc;
X
X	changed = TRUE;
X	type = abs(stat->typ);
X	if (type < 6)
X		;   /* normal */
X	else if (type < 10)
X		type = roll(1,5);   /* experimento */
X	else if (type < 20)
X	{
X		type -= 10; /* king */
X		if (type > 5)
X			type = roll(1,5);	/* experimento */
X	}
X	else if (type < 26)
X		type -= 20; /* council of wise */
X	else
X		type = roll(1,5);   /* everything else */
X	new = level(stat->exp);
X	inc = new - stat->lvl;
X	--type;	    /* set up for subscripting into table */
X	stat->str += table[type].strength.increase * inc;
X	stat->man += table[type].mana.increase * inc;
X	stat->brn += table[type].brains.increase * inc;
X	stat->mag += table[type].magic.increase * inc;
X	stat->mxn += table[type].Energy.increase * inc;
X	stat->energy = stat->mxn + stat->shd;
X	if ((stat->lvl = min(10000,new)) >= 1000)
X	{   /* no longer able to be king */
X		stat->gld += stat->crn * 5000;
X		stat->crn = 0;
X		stat->typ = abs(stat->typ);
X	}
X	if (stat->lvl >= 3000 && stat->typ < 20)
X	{   /* make a member of the council */
X		mvaddstr(6,0,"You have made it to the Council of the Wise.\nGood Luck on your search for the Holy Grail.\n");
X		stat->rng.type = 0;
X		stat->rng.duration = 3;
X		stat->typ = abs(stat->typ) + (stat->typ > 10 ? 10 :20);
X	}
X}
X
Xchar	*
Xprintloc(type,x,y)		/* return a pointer to a string specifying location */
Xchar	type;
Xdouble	x,y;	    /* also, set some global flags */
X{
X	reg int		size, loc;
X	reg char    *label;
X	static	char	res[80],
X	*nametable[4][4] =   /* names of places */
X	{
X	"Anorien",	"Ithilien",	"Rohan",	"Lorien",
X	"Gondor",	"Mordor",	"Dunland",	"Rovanion",
X	"South Gondor", "Khand",	"Eriador",	"The Iron Hills",
X	"Far Harad",	"Near Harad",	"The Northern Waste", "Rhun"
X	};
X
X	throne = beyond = marsh = FALSE;
X	if (wmhl)
X		return (strcpy(res," is in the Wormholes"));
X	else if (valhala)
X		return (strcpy(res," is in Valhala"));
X	else if ((size = circ(x,y)) >= 1000)
X	{
X		if (max(abs(x),abs(y)) > 1100000)
X		{
X			label = "The Point of No Return";
X			beyond = TRUE;
X		}
X		else
X			label = "The Ashen Mountains";
X	}
X	else if (size >= 55)
X		label = "Morannon";
X	else if (size >= 35)
X		label = "Kennaquahair";
X	else if (size >= 20)
X	{
X		label = "The Dead Marshes";
X		marsh = TRUE;
X	}
X	else if (size >= 9)
X		label = "The Outer Waste";
X	else if (size >= 5)
X		label = "The Moors Adventurous";
X	else
X	{
X		if (x == 0.0 && y == 0.0)
X		{
X			label = "The Lord's Chamber";
X			throne = TRUE;
X		}
X		else
X		{
X	/* this expression is split to prevent compiler loop with some compilers */
X			loc = ((x > 0.0) ? 1 : 0);
X			loc += ((y >= 0.0) ? 2 : 0);
X			label = nametable[size-1][loc];
X		}
X	}
X	if (type == 's')
X		sprintf(res,"is in %.22s",label);
X	else
X		sprintf(res," is in %s  (%.0f,%.0f)",label,x,y);
X	return (res);
X}
X
Xvoid
Xinitchar(stat)		    /* put in some default values */
Xreg struct  stats   *stat;
X{
X	stat->x = roll(-125,251);
X	stat->y = roll(-125,251);
X	stat->exp = stat->lvl = stat->sin = 0;
X	stat->crn = stat->psn = 0;
X	stat->rng.type = NONE;
X	stat->rng.duration = 0;
X	stat->blind = stat->vrg = stat->pal = FALSE;
X	stat->hw = stat->amu = stat->bls = 0;
X	stat->chm = 0;
X	stat->gem = 0.1;
X	stat->gld = roll(25,50) + roll(0,25) + 0.1;
X	stat->quks = stat->swd = stat->shd = 0;
X	stat->typ = 0;
X	stat->status = stat->tampered = OFF;
X	stat->scratch1 = stat->scratch2 = 0.0;
X	stat->wormhole = 0;
X	stat->age = 0;
X	stat->degen = 1;
X	stat->istat = 0;
X	stat->lives = 0;
X}
X
Xvoid
Xtrade(stat)		/* trading post */
Xreg struct  stats   *stat;
X{
X	static	struct
X	{
X		char	*item;
X		long	cost;
X	}   menu[] =
X		{
X		"Mana",1,
X		"Energy Shields",5,
X		"Books",200,
X		"Weapon Enchantments",500,
X		"Charms",1000,
X		"Quicksilver",2500,
X		"Blessings",1000,
X		"Gems",1000	/* this is only to ease changing the value of gems */
X		};
X	double	temp;
X	int		ch;
X	reg int size, loop;
X	bool	cheat = FALSE;
X
X	changed = TRUE;
X	clear();
X	addstr("You are at a trading post. All purchases must be made with gold.");
X	size = sqrt(abs(stat->x/100)) + 1;
X	size = min(8,size);
X	/* set up cost of blessing */
X	menu[6].cost = 1000 * (stat->lvl + 5);
X	mvprintw(5,0,"L: Leave  P: Purchase  S: Sell Gems?  ");
X	move(7,0);
X	for (loop = 0; loop < size; ++loop)
X		printw("(%d) %-30.30s: %6d\n",loop+1,menu[loop].item,menu[loop].cost);
XPROMPT:	adjuststats(stat);
X	mvprintw(1,0,"Gold:   %9.0f  Gems:  %9.0f  Level:    %6u  Charms: %6d\n",
X				stat->gld,stat->gem,stat->lvl,stat->chm);
X	printw("Shield: %9.0f  Sword: %9.0f  Quicksilver: %3d  Blessed: %s\n",
X	stat->shd,stat->swd,stat->quks,(stat->bls? " True" : "False"));
X	printw("Mana:  %9.0f",stat->man);
X	move(5,37);
X	ch = getans("LPS", FALSE);
X	move(15,0);
X	clrtobot();
X	switch(ch)
X	{
X		case 'L':
X		case '\n':
X			stat->x -= roll(-25, 50);
X			stat->y -= roll(-25, 50);
X			return;
X		case 'P':
X			mvaddstr(15,0,"What what would you like to buy? ");
X			ch = getans(" 12345678", FALSE);
X			move(15,0);
X			clrtoeol();
X			if (ch - '0' > size)
X				addstr("Sorry, this merchant doesn't have that.");
X			else
X				switch (ch)
X				{
X					case '1':
X					printw("Mana is one per %d gold piece.  How much do you want (%.0f max)? ",menu[0].cost,floor(stat->gld/menu[0].cost));
X					temp = inflt();
X					if (temp * menu[0].cost > stat->gld || temp < 0)
X						goto CHEAT;
X					else
X					{
X						stat->gld -= floor(temp) * menu[0].cost;
X						if (rnd() < 0.02)
X							goto DISHON;
X						else
X							stat->man += floor(temp);
X					}
X					break;
X				case '2':
X					printw("Shields are %d per +1.  How many do you want (%.0f max)? ",menu[1].cost,floor(stat->gld/menu[1].cost));
X					temp = inflt();
X					if (!temp)
X						break;
X					if (temp * menu[1].cost > stat->gld || temp < 0)
X						goto CHEAT;
X					else
X					{
X						stat->gld -= floor(temp) * menu[1].cost;
X						if (rnd() < 0.02)
X							goto DISHON;
X						else
X							stat->shd += floor(temp);
X					}
X					break;
X				case '3':
X					printw("A book costs %d gp.  How many do you want (%.0f max)? ",menu[2].cost,floor(stat->gld/menu[2].cost));
X					temp = inflt();
X					if (temp * menu[2].cost > stat->gld || temp < 0)
X						goto CHEAT;
X					else
X					{
X						stat->gld -= floor(temp) * menu[2].cost;
X						if (rnd() < 0.02)
X							goto DISHON;
X						else
X							if (rnd()*temp > stat->lvl/10 && temp != 1)
X							{
X								printw("\nYou blew your mind!\n");
X								stat->brn /= 5;
X							}
X							else
X								stat->brn += floor(temp)*roll(20,8);
X					}
X					break;
X				case '4':
X					printw("Weapon enchantments are %d gp per +1.  How many + do you want (%.0f max)? ",menu[3].cost,floor(stat->gld/menu[3].cost));
X					temp = inflt();
X					if (!temp)
X						break;
X					if (temp * menu[3].cost > stat->gld || temp < 0)
X						goto CHEAT;
X					else
X					{
X						stat->gld -= floor(temp) * menu[3].cost;
X						if (rnd() < 0.02)
X							goto DISHON;
X						else
X							stat->swd += floor(temp);
X					}
X					break;
X				case '5':
X					printw("A charm costs %d gp.  How many do you want (%.0f max)? ",menu[4].cost,floor(stat->gld/menu[4].cost));
X					temp = inflt();
X					if (temp * menu[4].cost > stat->gld || temp < 0)
X						goto CHEAT;
X					else
X					{
X						stat->gld -= floor(temp) * menu[4].cost;
X						if (rnd() < 0.02)
X							goto DISHON;
X						else
X							stat->chm += floor(temp);
X					}
X					break;
X				case '6':
X					printw("Quicksilver is %d gp per +1.  How many + do you want (%.0f max)? ",menu[5].cost,floor(stat->gld/menu[5].cost));
X					temp = inflt();
X					if (!temp)
X						break;
X					if (temp * menu[5].cost > stat->gld || temp < 0)
X						goto CHEAT;
X					else
X					{
X						stat->gld -= floor(temp) * menu[5].cost;
X						if (rnd() < 0.02)
X							goto DISHON;
X						else
X							stat->quks = min(99,stat->quks+floor(temp));
X					}
X					break;
X				case '7':
X					printw("A blessing requires a %d gp donation.  Still want one? ",menu[6].cost);
X					ch = getans("NY", FALSE);
X					if (ch == 'Y')
X						if (stat->gld < menu[6].cost)
X							goto CHEAT;
X						else
X						{
X							stat->gld -= menu[6].cost;
X							if (rnd() < 0.02)
X								goto DISHON;
X							else
X							{
X								stat->bls = TRUE;
X								stat->lives--;
X							}
X						}
X					break;
X				case '8':
X					mvprintw(15,0,"A gem costs 1000 gp.  How many do you want to buy (%.0f max)? ",floor(stat->gld/1000));
X					temp = inflt();
X					if (temp * 1000 > stat->gld)
X						goto CHEAT;
X					else
X					{
X						stat->gem += floor(temp);
X						stat->gld -= floor(temp) * 1000;
X					}
X					break;
X			}
X			break;
X		case 'S':
X			mvprintw(15,0,"A gem is worth %d gp.  How many do you want to sell (%.0f max)? ",menu[7].cost,stat->gem);
X			temp = inflt();
X			if (temp > stat->gem || temp < 0)
X				goto CHEAT;
X			else
X			{
X				stat->gem -= floor(temp);
X				stat->gld += floor(temp) * menu[7].cost;
X			}
X	}
X	goto PROMPT;
X
XCHEAT:	move(17,0);
X	if (!cheat)
X	{
X		addstr("Come on, merchants aren't stupid.  Stop cheating.\n");
X		cheat = TRUE;
X		goto PROMPT;
X	}
X	else
X	{
X		addstr("You had your chance.  This merchant happens to be\n");
X		printw("a %.0f level magic user, and you made %s mad!\n",
X			roll(size*10,size*20),(rnd() < 0.5)? "him" : "her");
X		stat->x += roll(-250,500)*size;
X		stat->y += roll(-250,500)*size;
X		stat->energy = min(size*20,stat->mxn);
X		++stat->sin;
X		more(23);
X	}
X	return;
X
XDISHON: mvaddstr(17,0,"The merchant stole your money!");
X	refresh();
X	stat->x -= floor(stat->x/10);
X	stat->y -= floor(stat->y/10);
X	sleep(2);
X}
X
Xchar	*
Xptype (length, type)				/* name of player type */
X
Xchar	length;
Xint		type;
X{
X	switch (type)
X	{
X		case 1:
X		case 11:
X		case 21:
X			if (length == 'l')
X				return("Magic User");
X			else
X				return (" MU");
X		case 2:
X		case 12:
X		case 22:
X			if (length == 'l')
X				return("Fighter");
X			else
X				return (" F ");
X		case 3:
X		case 13:
X		case 23:
X			if (length == 'l')
X				return("Elf");
X			else
X				return (" E ");
X		case 4:
X		case 14:
X		case 24:
X			if (length == 'l')
X				return("Dwarf");
X			else
X				return (" D ");
X		case 5:
X		case 15:
X		case 25:
X			if (length == 'l')
X				return("Halfling");
X			else
X				return (" H ");
X		case 6:
X		case 7:
X		case 16:
X		case 17:
X		case 26:
X		case 27:
X			if (length == 'l')
X				return("Experimento");
X			else
X				return (" EX");
X		case 90:
X			if (length == 'l')
X				return("Ex-Valar");
X			else
X				return (" EV");
X		case 99:
X			if (length == 'l')
X				return("Valar");
X			else
X				return (" V ");
X		default:
X			return (" ? ");
X	}
X}
X
Xvoid
Xprintstats(stat)		/* show characteristics */
X
Xreg struct  stats   *stat;
X{
X	mvprintw(0,0,"%s%s                  ",stat->name,
X			printloc('l',stat->x,stat->y));
X	mvprintw(0,65,"%s",ptype('l', stat->typ));
X	mvprintw(1,0,"Level :%7u   Energy  :%9.0f(%9.0f)  Mana :%9.0f  Users:%3d\n",
X	stat->lvl,stat->energy,stat->mxn + stat->shd,stat->man,users);
X	mvprintw(2,0,"Quick :%3.0f(%3d)  Strength:%9.0f(%9.0f)  Gold :%9.0f  ",
X	speed,stat->quk + stat->quks,strength,stat->str + stat->swd,stat->gld);
X	switch (stat->status)
X	{
X		case PLAYING:
X			if (stat->energy < 0.2 * (stat->mxn + stat->shd))
X				addstr("Low Energy\n");
X			else if (stat->blind)
X				addstr("Blind\n");
X			else
X				clrtoeol();
X			break;
X		case CLOAKED:
X			addstr("Cloaked\n");
X			break;
X		case INBATTLE:
X			addstr("In Battle\n");
X			break;
X		case OFF:
X			addstr("Off\n");
X	}
X}
X
Xvoid
Xshowall(stat)		    /* show special items */
X
Xreg struct  stats   *stat;
X{
X	static	char	*flags[] = {
X		"False",
X		" True" };
X
X	mvprintw(6,0,"Type: %3d  --  ",stat->typ);
X	addstr (ptype('l', stat->typ));
X	if (stat->typ > 10 && stat->typ < 90)
X		if (stat->typ > 20)
X			addstr(" (Council of Wise)");
X		else
X			addstr(" (King)");
X	addch('\n');
X	mvprintw(8,0,"Experience : %9.0f",stat->exp);
X	mvprintw(9,0,"Brains     : %9.0f",stat->brn);
X	mvprintw(10,0,"Magic Level: %9.0f",stat->mag);
X	mvprintw(11,0,"Sin        : %9.5f",stat->sin);
X	mvprintw(12,0,"Poison     : %9.5f",stat->psn);
X	mvprintw(13,0,"Gems       : %9.0f",stat->gem);
X	mvprintw(14,0,"Age        : %9ld",stat->age);
X	mvprintw(8,40,"Holy Water : %9d",stat->hw);
X	mvprintw(9,40,"Amulets    : %9d",stat->amu);
X	mvprintw(10,40,"Charms     : %9d",stat->chm);
X	mvprintw(11,40,"Crowns     : %9d",stat->crn);
X	mvprintw(12,40,"Shield     : %9.0f",stat->shd);
X	mvprintw(13,40,"Sword      : %9.0f",stat->swd);
X	mvprintw(14,40,"Quicksilver: %9d",stat->quks);
X
X	mvprintw(16,0,"Blessing: %s   Ring: %s   Virgin: %s   Palantir: %s",
X	flags[stat->bls],flags[stat->rng.type != 0],flags[stat->vrg],
X					flags[stat->pal]);
X}
X
Xvoid
Xneatstuff(stat) 	    /* random things */
X
Xreg struct  stats   *stat;
X{
X	double	temp;
X	int 	ch;
X
X	switch ((int) roll(0,150))
X	{
X		case 1:
X		case 2:
X			if (stat->psn > 0)
X			{
X				mvaddstr(4,0,"You've found a physician!  How much will you offer to be cured? ");
X				temp = inflt();
X				if (temp < 0 || temp > stat->gld)
X				{
X					mvaddstr(6,0,"He was not amused, and made you worse.\n");
X					++stat->psn;
X				}
X				else if (temp == 0 || rnd()/2.0 > (temp + 1)/max(stat->gld,1))
X					mvaddstr(5,0,"Sorry, he wasn't interested.\n");
X				else
X				{
X					mvaddstr(5,0,"He accepted.");
X					stat->psn = max(0,stat->psn-1);
X					stat->gld -= floor(temp);
X				}
X			}
X			break;
X		case 3:
X			if (stat->sin >= 1)	/* good folks don't rape and pillage --CMR */
X			{
X				mvaddstr(4,0,"You've been caught raping and pillaging!\n");
X				stat->exp += 4000;
X				stat->sin += 0.5;
X			}
X			break;
X		case 4:
X			temp = roll(6,50);
X			mvprintw(4,0,"You've found %.0f gold pieces, want them? ",temp);
X			clrtoeol();
X			ch = getans("NY", FALSE);
X			if (ch == 'Y')
X				stat->gld += temp;
X			break;
X		case 5:
X			if (stat->sin > 1)
X			{
X				mvaddstr(4,0,"You've found a Holy Orb!\n");
X				stat->sin -= 0.25;
X			}
X			break;
X		case 6:
X			if (stat->psn < 1)
X			{
X				mvaddstr(4,0,"You've been hit with a plague!\n");
X				++stat->psn;
X			}
X			break;
X		case 7:
X			mvaddstr(4,0,"You've found some holy water.\n");
X			++stat->hw;
X			break;
X		case 8:
X			mvaddstr(4,0,"You've met a Guru...");
X			if (rnd()*stat->sin > 1)
X				addstr("You disgusted him with your sins!\n");
X			else if (stat->psn > 0)
X			{
X				addstr("He looked kindly upon you, and cured you.\n");
X				stat->psn = 0;
X			}
X			else
X			{
X				addstr("He rewarded you for your virtue.\n");
X				stat->man += 50;
X				stat->shd += 2;
X			}
X			break;
X		case 9:
X			mvaddstr(4,0,"You've found an amulet.\n");
X			++stat->amu;
X			break;
X		case 10:
X			if (stat->blind)
X			{
X				mvaddstr(4,0,"You've regained your sight!\n");
X				stat->blind = FALSE;
X			}
X			break;
X		default:
X			if (stat->psn > 0)
X				stat->energy -= min(stat->psn*stat->mxn/45,0.9*stat->mxn);
X			stat->energy = max(stat->energy,floor(stat->mxn/11));
X	}
X}
X#ifdef SMALL
X
X/* these functions are all #defines (for speed) on larger systems, but 
X/* they save one hell of a lot of space on little systems */
X
Xdouble
Xrnd()		/* roll a random number between 0 and .999 */
X{
X	return ((rand () % 1000)/1000.0);
X}
X
Xvoid
Xillcmd()
X{
X	mvaddstr(5,0,"Illegal command.\n");
X}
X
Xvoid
Xillmove()
X{
X	mvaddstr(5,0,"Too far.\n");
X}
X
Xvoid
Xnomana()
X{
X	mvaddstr(5,0,"Not enough mana for that spell.\n");
X}
X
Xvoid
Xsomebetter()
X{
X	addstr("But you already have something better.\n");
X}
X
Xvoid
Xillspell()
X{
Xmvaddstr(5,0,"Illegal spell.\n");
X}
X#endif
TiDDleYwiNKs
	size="`wc -c func0.c`"
	size=`set - $size;echo $1`
echo "x - func0.c, $size characters"

	if test "$size" != "27506"
		then
		echo "Warning: error in transmitting 'func0.c';  should have 27506 characters."
	fi
fi