'===========================================================================
' Subject: TUJURE RPG (TEXT-ONLY) GAME        Date: 04-04-99 (16:10)       
'  Author: Richard Peacock                    Code: QB, QBasic, PDS        
'  Origin: rjp1@bayou.com                   Packet: DEMOS.ABC
'===========================================================================
DECLARE SUB DoSpell ()
DECLARE SUB HexINV (k$)
DECLARE SUB DoINV (K1$, k2$)
DECLARE SUB DoClass ()
DECLARE SUB Fini ()
DECLARE SUB Waita ()
DECLARE FUNCTION DoWait7! (WTill7!)
DECLARE FUNCTION DoWait6! (WTill6!)
DECLARE SUB DoNPC ()
DECLARE FUNCTION DoWait4! (WTill4!)
DECLARE SUB DoMap ()
DECLARE SUB Hexit (k$)
DECLARE FUNCTION DoWait3 (WTill3!)
DECLARE FUNCTION PerOf (N1, N2)
DECLARE SUB DoHelp ()
DECLARE FUNCTION DoWait2 (WTill2!)
DECLARE FUNCTION DoWait (WTill!)
DECLARE SUB DoRandom ()
DECLARE SUB DoKill ()
DECLARE SUB PlaceNouns ()
DECLARE SUB DoNouns ()
4 DECLARE FUNCTION Words (Text$, WS$)
DECLARE SUB WordWrap (Text$, x1, x2, y1)
DECLARE SUB DoRoom ()
DECLARE SUB DoCommand ()

'  Here's the basic idea:its something of a local Moongate ( a MUD)... except
'  you don't have to wait days to work your way up into the social ladder...
'  And there are no other human players but you (yet).  I want to be able
'  to join with animals... and YOU choose when you want to attack an animal
'  Not the other way around!

'  I want nearly everything to be done by variables...
'  This game is done by a data file...  I want this to automaticly make
'  a new data file if it can't find one.

'  The name of this game is:
'  Tujure  (until I can think of something better)

'  IMPORTANT:  IF THIS IS YOUR FIRST TIME TO PLAY, ALWAYS START A NEW GAME.
'  Please send me your comments!!  This game is far from finished!!
'  rjp1@bayou.com


DECLARE FUNCTION InputLine$ (Text$, ViewWidth%, KeyCode%)
DECLARE FUNCTION Lesser% (Var1%, Var2%)
DIM SHARED CursSize%, CAM$, work$, EHP, WEP$, STRi$, Bang, AKILL
DIM SHARED WORD$(100), Enemy$, WTill!, TFlag3, TFlag4, WTill2!, TFlag5, WTill3!, TFlag6, WTill4!

           'stat/name  |what room
DIM SHARED NPC$(50), NPCr(50), NPCn, Player.Class$, Player.mScroll, Player.Kill

DIM SHARED Player.HpRate, Player.SpRate, Player.Ag, Player.Scroll, Magic$(10)
DIM SHARED OldArm, Armcount, Cary

COMMON SHARED LCol%, RCol%, View$, LnLen%, CCol%, AChar%, IsSleep, IsFight
'Where it does the rooms

DIM SHARED Player.Code$
DIM SHARED INV$(40), HeyHey$(100)



COMMON SHARED Enemy.Hp, Enemy.Attack$, Enemy.Gold, Enemy.Exp, Enemy.Att, LCMD$
LCMD$ = "Tujure!"
'ON ERROR GOTO ErrHandle


DIM SHARED Room.num(100), Room.N(100), Room.S(100)
DIM SHARED Room.W(100), Room.E(100), Room.Des$(100), R

RANDOMIZE TIMER

READ R
FOR t = 1 TO R
READ Room.num(t)
     IF Room.num(t) = 999 THEN Room.num(t) = 0: EXIT FOR
READ Room.N(t)
READ Room.S(t)
READ Room.W(t)
READ Room.E(t)
READ Room.Des$(t)
NEXT t





DIM SHARED InRoom(R, 50) 'The codes of the objects in the room
DIM SHARED NounDesc$(500), BOP$, BOP2$, Pet.Att$, Pet.Str, Pet.Xhp, Pet.MHp
DIM SHARED NounStat$(500), Enemyno

CALL DoNouns

CONST ColLimit = 60        'Chars per line

'All the player.* variables
DIM SHARED Player.Arm$, Player.Hp, Player.Gold, Player.Exp, Player.Level, Player.Needed
DIM SHARED Player.Attack, Player.Wep$, Player.Room, Player.MaxHp, Player.Sp, Player.MaxSp
DIM SHARED Player.pet$, Tempx2, TempQQQ, Dely, Pet, TFlag7, WTill6!, WTill7!, TFlag8
DIM SHARED Waitam, Waitamt!, WORK2$, NPCf(50), Maper$(21)

Dely = 1.5


TYPE Header                  'File header
  Verify AS STRING * 4
  Filename AS STRING * 12
END TYPE



DIM SHARED Byte AS STRING * 1       '1 byte
DIM SHARED Hex AS STRING * 2        '2 bytes
DIM SHARED Hdr AS Header            'Header
DIM SHARED SeekS AS STRING * 4      'Seek buffer
Player.Arm$ = "TEE-SHIRT;a tee-shirt;3"
Player.pet$ = "MOUSE;a mouse;Your pet mouse is here.;bite;8;30"
Pet.MHp = 30



RANDOMIZE TIMER


'Do NPC shuffle & pick names...

' NPC names & stats
NPC$(1) = "Quark;The warrior"
NPC$(2) = "Kirk;The maniac"
NPC$(3) = "Yon;The ogre"
NPC$(4) = "Gwen;The Xena fan"
NPC$(5) = "Jarek;The archer"
NPC$(6) = "James;The ninja"
NPC$(7) = "Ylla;The martian"
NPC$(8) = "Mozart;The rock-star"
NPC$(9) = "Hojo;The explorer"
NPC$(10) = "Oliver;The tall guy"
NPC$(11) = "McDunn;The psychic"
NPC$(12) = "Henry;The author"
NPC$(13) = "Ray;The deejay"
NPC$(14) = "Marry;The gypsy"
NPC$(15) = "Cathy;The home owner"
NPC$(16) = "Sfven;The dutch guy"
NPC$(17) = "Barbie;The doll"
NPC$(18) = "Kenith;The nice mutant"
NPC$(19) = "Richard;The programmer"
NPC$(20) = "Magnavox;The tv set"







CursSize% = 7


CLS
















'  [COLORS]
'0 = black      4 = red          8 = grey            12 = light red
'1 = blue       5 = magenta      9 = light blue      13 = light magenta
'2 = green      6 = brown       10 = light green     14 = yellow
'3 = cyan       7 = white       11 = light cyan      15 = bright white
'This normally would be read from the data file

CONST BCLR = 0   'Background color
CONST YCOM = 2   'Text color of your commands
DIM SHARED GENC    'General text color
GENC = 7

CONST SPEC = 15  'Special color
CONST STAT = 14  'Status color
CONST CBTX = 15  'The text color of the command bar
CONST CBBA = 1   'The background of the command bar
CONST ACTI = 9   'The color of actions (get/drop/wear status)

CONST CAMBAR = 25 'Location of the command bar
CONST BOUNDRY = 23 'Location of southern most boundry of screen

'[KEYS]

CONST false = 0, true = NOT false
CONST ESC = 27, ENTER = 13, BkSpc = 8, TabKey = 9
CONST InsertKey = -82, DeleteKey = -83
CONST HomeKey = -71, CtrlHome = -119
CONST EndKey = -79, CtrlEnd = -117
CONST PgUpKey = -73, PgDnKey = -81
CONST UpArrow = -72, DnArrow = -80, LArrow = -75, RArrow = -77




' [SCREEN]
' This is basicly setting up the screen and fixing the way it scroll, etc.

SCREEN 0
WIDTH 80

VIEW PRINT 2 TO BOUNDRY

ReStartDraw:
CLS
LOCATE BOUNDRY, 1
COLOR 15, 0


PRINT "                                                             ^"
PRINT "         ____________________________                  ^   _|.|_   ^"
PRINT " _______|                            |_______        _|I|  |I .|  |.|_"
PRINT " \      |           Tujure           |      /        \II||~~| |~~||  /"
PRINT "  \     |   The legend of Kelnore!   |     /          ~\~|~~~~~~~|~/~"
PRINT "  /     |____________________________|     \            \|II I ..|/"
PRINT " /________)                        (________\      /\    |II.    |    /\"
PRINT "                                                  /  \  _|III .  |_  /  \"
PRINT "    Tujure (c) 1998 Richard Peacock               |-~| /(|I.I I  |)\ |~-|"
PRINT "    http://www.bayou.com/~rjp1/qbasic.html      _/(I | +-----------+ |. )\_"
PRINT "    rjp1@bayou.com                              \~-----/____-~-____\-----~/"
PRINT "                                                 |I.III|  /(===)\  |  .. |"
PRINT "                                                 /~~~-----_________---~~~\"
PRINT "    1) Start Tujure                             `##########!\-#####%!!!!!| |\"
PRINT "    2) Start new game                          _/###########!!\~~-_##%!!!\_/|"
PRINT "    3) Quit                                    \##############!!!!!/~~-_%!!!!\"
PRINT "                                    "
PRINT " Press the key of your selection."
nothing = 0
TempNot$ = INPUT$(1)
SELECT CASE TempNot$
CASE "0": CALL Hexit("1"): END
CASE "3": CLS : END
CASE "2"
      PRINT "This will create a new data file, thus erasing any old saved game."
      PRINT "Are you sure you want to continue (Y/N)?"
      TempTT$ = INPUT$(1)
      TempTT$ = UCASE$(TempTT$)
      IF TempTT$ = "N" THEN GOTO ReStartDraw


Reask:
COLOR SPEC, BCLR
PRINT
PRINT " You are about enter the strange and magical world of Tujure."
PRINT "You are in The Great Library of Knowledge."
PRINT "Choose one profession to follow..."
PRINT
COLOR STAT, BCLR
PRINT "A) Paladin       A man of the cloth gifted in healing."
PRINT "B) Barbarian     Enhanced strength and a keen knowledge of weapons."
PRINT "C) Sorcerer      Trusts words of magic more than swords of steel."
PRINT "D) Ninja         Agile masters of martial arts."
PRINT "E) Monk          A student of magic and weapons."
COLOR SPEC, BCLR
xx$ = INPUT$(1)
xx$ = UCASE$(xx$)
IF xx$ <> "A" AND xx$ <> "B" AND xx$ <> "C" AND xx$ <> "D" AND xx$ <> "E" THEN GOTO Reask
SELECT CASE xx$
   CASE "A"
      Player.Class$ = "Paladin"
      nmSp$ = "19": nSp$ = "17": nmHp$ = "20": nHp$ = "20"
      nArm$ = "leather;shield;a leather shield;2;50;X;1;4"
      nWep$ = "Practice;knife;slash;8;50;X;1;5"
      Player.Scroll = 2
      
   CASE "B"
      Player.Class$ = "Barbarian"
      nmSp$ = "5": nSp$ = "5": nmHp$ = "50": nHp$ = "50"
      nArm$ = "iron;shield;a shield of iron;14;50;X;1;4"
      nWep$ = "Practice;mace;whack;17;50;PSMN;1;6"
      Player.Scroll = 1
    
   CASE "C"
      Player.Class$ = "Sorcerer"
      nmSp$ = "30": nSp$ = "30": nmHp$ = "10": nHp$ = "10"
      nArm$ = "simple;cloak;a cloak of protection;5;50;X;1;3"
      nWep$ = "Practice;staff;shock;8;50;BMN;1;3"
      Player.Scroll = 4
      
   CASE "D"
      Player.Class$ = "Ninja"
      nmSp$ = "12": nSp$ = "12": nmHp$ = "35": nHp$ = "35"
      nArm$ = "leather;shield;a shield of leather;2;35;X;1;3"
      nWep$ = "Practice;sword;slash;8;50;S;1;3"
      Player.Scroll = 2
      
   CASE "E"
      Player.Class$ = "Monk"
      nmSp$ = "16": nSp$ = "16": nmHp$ = "25": nHp$ = "25"
      nArm$ = "brown;robe;a brown robe;3;35;X;1;3"
      nWep$ = "Practice;dagger;pierce;8;45;B;1;2"
      Player.Scroll = 3
      
END SELECT

'Make a Temp Data file

F = FREEFILE
OPEN "data.da1" FOR OUTPUT AS #F
PRINT #F, "1"
PRINT #F, nHp$
PRINT #F, nArm$
PRINT #F, nmHp$
PRINT #F, nmSp$
PRINT #F, nSp$
PRINT #F, nWep$
PRINT #F, "1"
PRINT #F, "500"
PRINT #F, "1"
PRINT #F, "1"
PRINT #F, "MOUSE;a mouse;Your pet mouse is here.;bite;8;30"
PRINT #F, "30"

PRINT #F, "2"

PRINT #F, "dummy"
PRINT #F, Player.Class$ + ";0"
PRINT #F, Player.Scroll

CLOSE #F

'Read from data file

F = FREEFILE
OPEN "data.da1" FOR INPUT AS #F
INPUT #F, Player.Room
INPUT #F, Player.Hp
LINE INPUT #F, Player.Arm$
INPUT #F, Player.MaxHp
INPUT #F, Player.MaxSp
INPUT #F, Player.Sp
LINE INPUT #F, Player.Wep$
INPUT #F, Player.Exp
INPUT #F, Player.Needed
INPUT #F, Player.Level
INPUT #F, Player.Gold
INPUT #F, Player.pet$
INPUT #F, Pet.MHp

INPUT #F, Dely
    IF Dely < .5 THEN Dely = 2

INPUT #F, NPCn
   
    IF NPCn < 1 THEN NPCn = 1

INPUT #F, Player.Class$
nottyboy = Words(Player.Class$, ";")
Player.Kill = VAL(WORD$(2))
Player.Class$ = WORD$(1)

INPUT #F, Player.Scroll
CLOSE #F

'Show Temp Status

LOCATE BOUNDRY, 1
COLOR SPEC, BCLR
PRINT
PRINT "Status for: "; Player.Class$; "."
   

PRINT "Hp : "; LTRIM$(RTRIM$(STR$(Player.Hp)));
PRINT "/"; LTRIM$(RTRIM$(STR$(Player.MaxHp)))

PRINT "Sp : "; LTRIM$(RTRIM$(STR$(Player.Sp)));
PRINT "/"; LTRIM$(RTRIM$(STR$(Player.MaxSp)))
   
TempX = Words(Player.Wep$, ";")
PRINT "Your weapon is a "; WORD$(2); ", with an attack power ~ "; WORD$(4); "."
TempX = Words(Player.Arm$, ";")
PRINT "Your armour is "; WORD$(2); ", with a protective power ~ "; WORD$(4); "."









PRINT
PRINT "Are you sure you want "; Player.Class$; " (Y/N)?"
TempTT$ = INPUT$(1)
TempTT$ = UCASE$(TempTT$)
IF TempTT$ <> "Y" THEN GOTO Reask
KILL "Data.da1"

F = FREEFILE


OPEN "inv.dat" FOR OUTPUT AS #F
PRINT #F, nWep$
PRINT #F, nArm$
CLOSE #F



COLOR SPEC, BCLR
PRINT
PRINT "      You pick up a book about "; Player.Class$; "s, and are fascinated.  You"
PRINT "decide to make it your profession.  But before you enter the world of Tujure,"
PRINT "you must know a few things..."
PRINT
COLOR STAT, BCLR
PRINT "Learning magic is always important, no matter what profession you are.  You"
PRINT "begin with a few spells, but, as you fight, you learn new ones."
PRINT
COLOR SPEC, BCLR
PRINT "When refering to an enemy (KILL LADY) or a noun (READ NOTE) use the"
PRINT "adjective to be more specific.  EX: KILL OLD LADY     READ SMALL NOTE."
PRINT
COLOR STAT, BCLR
PRINT "The enemys of the forest are unlike those in town.  Be sure to always type"
PRINT "CON enemy to see how strong they are."
PRINT
COLOR SPEC, BCLR
PRINT "Many things are possible in Tujure.  You can change the general delay speed, and"
PRINT "the number of NPC's  (Non-Player Characters or Computer Controlled Characters)."
PRINT "So be sure to type HELP when you first start the game, to see what you can do."
PRINT
PRINT "With these tips in mind, press ENTER to begin your journey into Tujure."
a$ = INPUT$(1)



'Make New Data FIle
F = FREEFILE
OPEN "data.dat" FOR OUTPUT AS #F
PRINT #F, "1"
PRINT #F, nHp$
PRINT #F, nArm$
PRINT #F, nmHp$
PRINT #F, nmSp$
PRINT #F, nSp$
PRINT #F, nWep$
PRINT #F, "1"
PRINT #F, "500"
PRINT #F, "1"
PRINT #F, "1"
PRINT #F, "MOUSE;a mouse;Your pet mouse is here.;bite;8;30"
PRINT #F, "30"

PRINT #F, "1"

PRINT #F, "dummy"
PRINT #F, Player.Class$ + ";0"
PRINT #F, Player.Scroll

CLOSE #F

'Read from data file

F = FREEFILE
OPEN "data.dat" FOR INPUT AS #F
INPUT #F, Player.Room
INPUT #F, Player.Hp
LINE INPUT #F, Player.Arm$
INPUT #F, Player.MaxHp
INPUT #F, Player.MaxSp
INPUT #F, Player.Sp
LINE INPUT #F, Player.Wep$
INPUT #F, Player.Exp
INPUT #F, Player.Needed
INPUT #F, Player.Level
INPUT #F, Player.Gold
INPUT #F, Player.pet$
INPUT #F, Pet.MHp

INPUT #F, Dely
    IF Dely < .5 THEN Dely = 1

INPUT #F, NPCn
    
    IF NPCn < 1 THEN NPCn = 1

INPUT #F, Player.Class$
nottyboy = Words(Player.Class$, ";")
Player.Kill = VAL(WORD$(2))
Player.Class$ = WORD$(1)

INPUT #F, Player.Scroll
CLOSE #F
nothing = 1



CASE ELSE

CALL Hexit("2")


F = FREEFILE
OPEN "data.dat" FOR INPUT AS #F
INPUT #F, Player.Room
INPUT #F, Player.Hp
LINE INPUT #F, Player.Arm$
INPUT #F, Player.MaxHp
INPUT #F, Player.MaxSp
INPUT #F, Player.Sp
LINE INPUT #F, Player.Wep$
INPUT #F, Player.Exp
INPUT #F, Player.Needed
INPUT #F, Player.Level
INPUT #F, Player.Gold
INPUT #F, Player.pet$
INPUT #F, Pet.MHp

INPUT #F, Dely

    IF Dely < .5 THEN Dely = 1

INPUT #F, NPCn

    IF NPCn < 1 THEN NPCn = 1

INPUT #F, Player.Class$

nottyboy = Words(Player.Class$, ";")
Player.Kill = VAL(WORD$(2))
Player.Class$ = WORD$(1)



INPUT #F, Player.Scroll

CLOSE #F
END SELECT




CALL DoClass

CALL DoINV("LOAD", "x")






CLS
LOCATE BOUNDRY, 1
PRINT : PRINT : PRINT
PRINT "Type HELP for help."
IF nothing = 0 THEN
PRINT "Picking up where you left off. . ."
PRINT
END IF


  IF Player.Hp < 50 THEN GENC = 7
  IF Player.Hp < 40 THEN GENC = 14
  IF Player.Hp < 30 THEN GENC = 12
  IF Player.Hp < 20 THEN GENC = 4
  TempX = PerOf(Player.Hp, Player.MaxHp)
  IF TempX > 90 THEN GENC = 9


CALL DoRoom

' [MAIN GAME LOOP]


FOR t = 1 TO 20
x = INT(RND * 20) + 1
SWAP NPC$(t), NPC$(x)
NEXT t



NPCr(1) = INT(RND * 20) + 1  'What room #1 (Quark) is in

FOR t = 2 TO NPCn
NPCr(t) = INT(RND * R) + 1
NEXT t





MainGameLoop:

LOCATE CAMBAR, 1
CAM$ = LTRIM$(RTRIM$(InputLine$("", 78, KeyCode%)))
LCMD$ = CAM$
    CALL DoCommand

GOTO MainGameLoop



ErrHandle:
IF ERR = 53 THEN
   'Make a new data file

LOCATE BOUNDRY, 1
COLOR SPEC, BCLR
PRINT "No data file exists, or there are errors in it.  Rerun the program,"
PRINT "and select the option to create a new game.  You will be asked if you"
PRINT "are sure.  Answer the yes option.  If this error continues, delete the"
PRINT "data file, data.dat and the program, tujure.exe and re-install it."
PRINT "If the error continues, please inform the author, Richard Peacock."
PRINT "rjp1@bayou.com"


ELSE LOCATE BOUNDRY, 1: COLOR SPEC, BCLR: PRINT "Error#"; ERR; "!  Rerun the program.  If error continues, delete data.dat."
END IF
END
' [DATA STATEMENTS]

'

'                      |                                                                               |
                                                                                           
'    #, n, s, w, e,    descrip
DATA 87

DATA 1, 2, 3, 4, 5,   "You are in the middle of town.  You can go in all directions."
DATA 2, 11,1,13, 0,   "You are on city street.  People of all types are wondering about."
DATA 3, 1,18, 0, 0,   "You are on a city street.  People and animals are wondering about.": REM        |
DATA 4, 0, 6, 7, 1,   "You are on a buzy city street.  Merchants are selling their goods, while        theives are stealing them."
DATA 5, 8, 9, 1, 21,  "You are on a buzy city street.  People from all over are wondering about,       buying and selling.  To the east is the Tujure forest."
DATA 6, 4, 0, 0, 0,   "You are in the town pet shop.  Here, you can buy animals that will help you on  your journey.  Type BUY for a list/order form."
DATA 7,14, 0,17, 4,   "You are on a buzy city street.  People wonder by you, casualy greeting you.     The city park is to the north."
DATA 8,16, 5, 0,15,   "You are in an alley way.  Cats lazyly lounge in the street as you walk by.": REM|
DATA 9, 5, 10,0, 0,   "You are in an alley way.  An acrid smell of garbage wrinkles your nose.  It     seems to be comming from the south."
DATA 10,9, 0, 0,19,   "This is the city dump.  Piles of garbage collect flys, while animals fight for  scraps of food."
DATA 11,0, 2,12, 0,   "You are in the city's park.  The smell of freshly cut grass and the colorful    flowers fills your senses."
DATA 12,0, 13,0,11,   "You are in the city's park.  Bees buzz by as a light wind plays with your hair."
'    #, n, s, w, e
DATA 13,12, 0,14,2,   "You are in the city's park.  As you admire the selection of flowers, you wonder how anything could be more breath-taking."
DATA 14,0, 7, 0, 13,  "This is the city park.  The green grass and friendly animals give you a feeling of safty here."
DATA 15,0, 0, 8, 0,   "You are in a weapon's shop.  Type LIST for a list of things you can buy.  When  you are ready to make a purchase, type BUY."
DATA 16,0, 8, 0, 0,   "You are at the end of an alley way.  The surrounding buildings cast huge        shadows into the street, preventing you from seeing fine details."
DATA 17,0, 0, 0, 7,   "You are in an armour shop.  Type LIST for a list of armour to buy.  Type BUY to make a purchase."
DATA 18,3, 0,20, 0,   "You are on a city street.  Buildings and street lamps and sidewalks...yep, it's a city street."
DATA 19,0, 0,10, 0,   "This is the city dump.  You can feel vomit in the back of your throat as you    look at the piles of decaying trash."
DATA 20,0, 0, 0,18,   "This is a vacant building.  People say that it is some sort of shop, but you    don't know for sure."

'The Forest!
'    #, n, s, w, e

DATA 21,0 ,0 ,5 ,22,  "To the east is the forest.  To the west is the town.  Be careful!  strange      animals dwell in the forest!"
DATA 22,0 ,23,21,0,   "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 23,22,24, 0 ,0,  "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 24,23,28, 0 ,25, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 25,0 ,26, 24,0,  "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 26,25,27, 35,0,  "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 27,26,0 , 28,0,  "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 28,24,29, 0,27,  "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 29,28,0 , 30,0,  "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 30,0 ,0 ,31 ,29, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 31,32,0 , 0 ,30, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 32,33,31, 36,0 , "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 33,0,32 , 0 ,34, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 34,0 ,0 , 33,35, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 35,0 ,0 , 34,26, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
'The Forest!
'    #, n, s, w, e
DATA 36,0 ,0 , 37,32, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 37,39,38, 0 ,36, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 38,37,0 , 0, 0,  "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 39,0 ,37, 40, 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 40,0 ,0 , 41,39, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 41,48,42, 0 ,40, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 42,41,43, 0 ,0 , "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 43,42,0 , 0 ,44, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 44,0 ,45 , 43,0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 45,44,46, 0 ,0 , "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 46,45 ,0 , 0,47, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 47,0 ,0 , 46,0 , "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 48,49,41, 50,0 , "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 49,0 ,48, 0 ,0 , "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 50,51,0 , 0 ,48, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
'The Forest!
'    #, n, s, w, e
DATA 51,52,50, 0 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 52,53,51, 0 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 53,0 ,52, 0 ,54, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 54,55,0 , 53, 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 55,0 ,54, 0 ,56, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 56,57,0 ,55 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 57,0 ,56, 0 ,58, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 58,0 ,0 , 57,59, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 59,0 ,0 , 58,60, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 60,0 ,0 , 59,61, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."

'The Forest!
'    #, n, s, w, e
DATA 61,0 ,62, 60, 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 62,61, 0, 0 ,63, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 63,0 , 0, 62,64, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 64,0 ,65,63 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 65,64,66, 0 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 66,65,67, 0 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 67,66,68, 0 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 68,67,0 ,69 , 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 69,0 ,70,  0,68, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 70,69,71,  0, 0, "This is like any other forest.  Towering trees and tall grass.  Small animals   scury about under your feet."
DATA 71,70,0 ,  0, 72,"You are just beyond the gates to the lost city of Kelnore.  A sign reads: You   must be level 10 to enter."

'Kelnore!
'    #, n, s, w, e
DATA 72, 0,0 ,71, 73, "You are in the lost city of Kelnore.  What buildings are still standing are     of an odd design.  Mutants are everywhere."
DATA 73, 0,0 ,72, 74, "You are standing in an alley, from what you can tell.  The mutants that exist   don't seem to notice you."
DATA 74,77,0 ,73, 75, "You are standing in an alley, from what you can tell."
DATA 75, 0,76 ,74, 0, "You are standing in an alley, from what you can tell."
DATA 76,75,0 ,  0, 0, "You think this may have been a shop, but you aren't sure."
DATA 77,80,74 ,78, 0, "This must be the center of Kelnore, you think.  There are poor mutant beggars   asking you for food."
DATA 78, 0,0 ,79,77 , "You are on a nameless street.  There are deformed skeletons strewn about."
DATA 79, 0,0 , 0, 78, "You are in a graveyard.  The stench of the open graves is almost unbearable."
DATA 80, 81,77, 0,83, "You see a dried up fountain here, and dead trees."
DATA 81, 0,80,82, 0 , "At one time, this may have been a church for the ancient Christian God."
DATA 82, 0,0 , 0, 81, "You are outside of the `church.'  The tall, dead trees cast eerie shadows."
DATA 83,84,0 ,80, 0 , "You are on a long coblestone road."
DATA 84,85,83, 0, 0 , "You are on a long coblestone road."
DATA 85,86,84, 0, 0 , "You are on a long coblestone road."
DATA 86, 0,85,87, 0 , "You are on a long coblestone road."
DATA 87, 0,0 ,0, 86 , "This is a strange place... You feel a great evil is here."




DATA 999

SUB DoClass
'H, heal   D, Damage  A,Armour P,heal pet
'Magic$(x) = "NAME;H/D/A/P;descrip;SP needed;Damage/Heal points;Descrip of result"





SELECT CASE Player.Class$
 CASE "Paladin"
   Player.SpRate = 4
   Player.HpPate = 0
   Player.Ag = 2
   Player.mScroll = 10
   Player.Code$ = "P"
   Cary = 12

   Magic$(1) = "HEAL;H; spell of Heal;10;10;Clouds of life envelope you.  You feel better.;This heals you."
   Magic$(2) = "HEALPET;P; spell of HealPet;10;10;Your pet fades out of reality.  It is more healthy when it returns.;This heals your pet."
   Magic$(3) = "HEALMORE;H; spell of HealMore;15;20;Clouds form all around you.  When they pass, you feel much better.;This heals you."
   Magic$(4) = "LIGHTNING;D; spell of Lightning;21;25;A blast of lightning strikes your foe!;This hurts your enemy."
   Magic$(5) = "HEALFULL;H; spell of HealFull;31;9999;You are covered with a blue mist.  Your health is restored!;This heals you."
   Magic$(6) = "ICE;D; spell of Ice;34;51;An blizzard descends on your enemy!;This hurts your enemy."
   Magic$(7) = "ARMOUR;A; spell of Armour;50;15;Your armour glows bright white!;This adds armour for a while."
   Magic$(8) = "MOREARMOUR;A; spell of MoreArmour;58;22;Lighning strikes your armour!  It glows bright green!.;This adds armour for a while."
   Magic$(9) = "DEATH;D; spell of Death;60;9999;Death appears, and touches your enemy!;This kills your enemy."
   Magic$(10) = "FULLARMOUR;A; spell of FullArmour;70;9999;Your armour becomes indestructible!  It glows red!;This makes you invincible."


 CASE "Barbarian"
   Player.SpRate = 0
   Player.HpRate = 6
   Player.Ag = 0
   Player.mScroll = 2
   Player.Code$ = "B"
   Cary = 17

   Magic$(1) = "HEAL;H; spell of Heal;6;7;Clouds of life envelope you.  You feel better.;This heals you."
   Magic$(2) = "ARMOUR;A; spell of Armour;7;7;Your armour glows bright white!;This adds armour for a while."
  

 CASE "Sorcerer"
   Player.SpRate = 6
   Player.HpRate = 0
   Player.Ag = 1
   Player.mScroll = 10
   Player.Code$ = "S"
   Cary = 7

   Magic$(1) = "HEAL;H; spell of Heal;10;10;Clouds of life envelope you.  You feel better.;This heals you."
   Magic$(2) = "HEALPET;P; spell of HealPet;10;10;Your pet fades out of reality.  It is more healthy when it returns.;This heals your pet."
   Magic$(3) = "SOULSTRIKE;D; spell of SoulStrike;21;25;A blast of energy from your eyes strikes the enemy's soul!;This hurts your enemy."
   Magic$(4) = "HEALMORE;H; spell of HealMore;15;20;Clouds form all around you.  When they pass, you feel much better.;This heals you."
   Magic$(5) = "CATSCRATCH;D; spell of CatScratch;34;51;You reach out and slice open your victom!;This hurts your enemy."
   Magic$(6) = "HEALFULL;H; spell of HealFull;31;9999;You are covered with a blue mist.  Your health is restored!;This heals you."
   Magic$(7) = "PROTECTION;A; spell of Protection;50;15;Your armour glows bright white!;This adds armour for a while."
   Magic$(8) = "MOREPROTECTION;A; spell of MoreProtection;58;22;Lighning strikes your armour!  It glows bright green!.;This adds armour for a while."
   Magic$(9) = "DEATH;D; spell of Death;60;9999;Death appears, and touches your enemy!;This kills your enemy."
   Magic$(10) = "IRON;A; spell of Iron;70;9999;Your armour becomes indestructible!  It glows red!;This makes you invincible for a while."





 CASE "Ninja"
   Player.SpRate = 1
   Player.HpRate = 4
   Player.Ag = 6
   Player.mScroll = 5
   Player.Code$ = "N"
   Cary = 12
  
   Magic$(1) = "HEAL;H; spell of Heal;10;10;Clouds of life envelope you.  You feel better.;This heals you."
   Magic$(2) = "HEALPET;P; spell of HealPet;10;6;Your pet fades out of reality.  It is more healthy when it returns.;This heals your pet."
   Magic$(3) = "SHADOW;D; spell of Shadow;21;25;Your shadow envelops the foe, and attacks!;This hurts your enemy."
   Magic$(4) = "SLASH;D; spell of Slash;30;35;You leap and slash through your enemy with just your hands!;This hurts your enemy."
   Magic$(5) = "TORNADOE;D; spell of Tornadoe;38;40;Lighning strikes!  Wind and rain envelop your enemy!;This hurts your enemy."


 CASE "Monk"
   Player.SpRate = 3
   Player.HpRate = 3
   Player.Ag = 2
   Player.mScroll = 7
   Player.Code$ = "M"
   Cary = 10
  
   Magic$(1) = "HEAL;H; spell of Heal;10;10;Clouds of life envelope you.  You feel better.;This heals you."
   Magic$(2) = "HEALPET;P; spell of HealPet;10;10;Your pet fades out of reality.  It is more healthy when it returns.;This heals your pet."
   Magic$(3) = "HEALMORE;H; spell of HealMore;15;20;Clouds form all around you.  When they pass, you feel much better.;This heals you."
   Magic$(4) = "LIGHTNING;D; spell of Lightning;21;25;A blast of lightning strikes your foe!;This hurts your enemy."
   Magic$(5) = "HEALFULL;H; spell of HealFull;31;9999;You are covered with a blue mist.  Your health is restored!;This heals you."
   Magic$(6) = "ICE;D; spell of Ice;34;51;An blizzard descends on your enemy!;This hurts your enemy."
   Magic$(7) = "ARMOUR;A; spell of Armour;50;15;Your armour glows bright white!;This adds armour for a while."





END SELECT






END SUB

SUB DoCommand

COLOR GENC, BCLR
LOCATE BOUNDRY, 1
PRINT "<Hp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Hp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxHp)));
PRINT " Exp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Exp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.Needed)));
PRINT " Sp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Sp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxSp)));
PRINT ">";
 COLOR YCOM, BCLR
 PRINT CAM$



' TRYS TO FIGURE OUT WHAT THE COMMAND IS
TempFlag = 0

W = Words(CAM$, " ")
IF CAM$ = "" THEN TempFlag = 1: GOTO ExitSelect


IF W = 1 THEN
SELECT CASE UCASE$(CAM$)
CASE "Q", "QUIT", "END"
      TempFlag = 1
      LOCATE BOUNDRY, 1
      COLOR SPEC, BCLR
      PRINT "About to quit.  Ok? (y/n)"
      LOCATE CAMBAR, 1
      C$ = LTRIM$(RTRIM$(InputLine$("", 78, KeyCode%)))
 COLOR YCOM, BCLR
 LOCATE BOUNDRY, 1
 PRINT C$
      IF UCASE$(C$) = "Y" THEN
F = FREEFILE
OPEN "data.dat" FOR OUTPUT AS #F
PRINT #F, STR$(Player.Room)
PRINT #F, STR$(Player.Hp)
PRINT #F, Player.Arm$
PRINT #F, STR$(Player.MaxHp)
PRINT #F, STR$(Player.MaxSp)
PRINT #F, STR$(Player.Sp)
PRINT #F, Player.Wep$
PRINT #F, STR$(Player.Exp)
PRINT #F, STR$(Player.Needed)
PRINT #F, STR$(Player.Level)
PRINT #F, STR$(Player.Gold)
PRINT #F, Player.pet$
PRINT #F, Pet.MHp
PRINT #F, STR$(Dely)

PRINT #F, STR$(NPCn)

PRINT #F, Player.Class$ + ";" + STR$(Player.Kill)
PRINT #F, STR$(Player.Scroll)
CLOSE #F
    
CALL Hexit("1")


F = FREEFILE
OPEN "inv.dat" FOR OUTPUT AS #F
FOR t = 1 TO Cary
PRINT #F, INV$(t)
'PRINT INV$(t)
NEXT t
CLS
    
CLOSE #F

END
      END IF
     
      LOCATE BOUNDRY, 1
      COLOR SPEC, BCLR
      PRINT "Quit aborted."
CASE "N", "NORTH"
      TempFlag = 1
      IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
      IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
      IF Room.N(Player.Room) = 0 THEN
      LOCATE BOUNDRY, 1
      COLOR SPEC, BCLR
      PRINT "You can't go that way!"
      GOTO ExitSelect
      END IF
      Player.Room = Room.N(Player.Room)
      CALL DoRoom
CASE "S", "SOUTH"
      TempFlag = 1
      IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
      IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
      IF Room.S(Player.Room) = 0 THEN
      LOCATE BOUNDRY, 1
      COLOR SPEC, BCLR
      PRINT "You can't go that way!"
      GOTO ExitSelect
      END IF
      Player.Room = Room.S(Player.Room)
      CALL DoRoom
CASE "E", "EAST"
      TempFlag = 1
      IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
      IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
      IF Room.E(Player.Room) = 0 THEN
      LOCATE BOUNDRY, 1
      COLOR SPEC, BCLR
      PRINT "You can't go that way!"
      GOTO ExitSelect
      END IF
      IF Room.E(Player.Room) = 72 THEN
        IF Player.Level < 10 THEN
      LOCATE BOUNDRY, 1
      COLOR SPEC, BCLR
      PRINT "You must be level 10 to enter Kelnore!"
      GOTO ExitSelect
      END IF
      END IF
      Player.Room = Room.E(Player.Room)
      CALL DoRoom
CASE "W", "WEST"
      TempFlag = 1
      IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
      IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
      IF Room.W(Player.Room) = 0 THEN
      LOCATE BOUNDRY, 1
      COLOR SPEC, BCLR
      PRINT "You can't go that way!"
      GOTO ExitSelect
      END IF
      Player.Room = Room.W(Player.Room)
      CALL DoRoom
CASE "L", "LOOK"
      TempFlag = 1
      IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
     
      CALL DoRoom
CASE "SPELL", "SPELLS"
      TempFlag = 1
      COLOR STAT, BCLR
      PRINT "You have studied the scrolls of the following:"
      COLOR SPEC, BCLR
      FOR t = 1 TO Player.Scroll
      nottyboy = Words(Magic$(t), ";")
      PRINT "  The " + WORD$(3) + ".  It costs "; WORD$(4); " Sp.  " + WORD$(7)
      NEXT t

CASE "HELP", "?"
      TempFlag = 1
      CALL DoHelp

CASE "INV", "INVENTORY"
      TempFlag = 1
      CALL DoINV("LIST", "x")


CASE "RS232"
      TempFlag = 1
      Player.Sp = 100
      Player.Hp = 100



CASE "RECALL"
      TempFlag = 1
      IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
      IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
      Player.Room = 1
      COLOR STAT, BCLR: LOCATE BOUNDRY, 1
      PRINT "A huge cloud of green smoke closes around you.  You feel dizzy, and pass out."
      COLOR STAT, BCLR: LOCATE BOUNDRY, 1
      PRINT "When you awake, you find that you are now in the center of town..."
      CALL DoRoom
CASE "SLEEP"
     TempFlag = 1
     IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
     COLOR STAT, BCLR
     LOCATE BOUNDRY, 1
     IF IsSleep <> 1 THEN PRINT "You fall asleep."
     IsSleep = 1
CASE "WAKE"
     TempFlag = 1
     LOCATE BOUNDRY, 1
     COLOR STAT, BCLR
     IF IsSleep <> 0 THEN PRINT "You wake up."
     IsSleep = 0
CASE "DELAY"
     TempFlag = 1
     LOCATE BOUNDRY, 1
     COLOR STAT, BCLR
     PRINT "Battle delay is set to"; STR$(Dely); " seconds."
CASE "NPC"
     TempFlag = 1
     LOCATE BOUNDRY, 1
     COLOR STAT, BCLR
     FOR t = 1 TO NPCn
     Temp = Words(NPC$(t), ";")
     PRINT WORD$(1); ", "; WORD$(2); ", is in area:"; NPCr(t);
     IF NPCf(t) <> 0 THEN PRINT "... is fighting." ELSE PRINT " "
     NEXT t
     GOTO ExitSelect
CASE "CALL"
     TempFlag = 1
     Temp = INT(RND * NPCn) + 1
     NPCr(Temp) = Player.Room
     CALL DoRoom
     GOTO ExitSelect
CASE "FLEE", "RUN"
     TempFlag = 1
     LOCATE BOUNDRY, 1
     COLOR STAT, BCLR
     IF IsFight = 0 THEN PRINT "Flee from what?": GOTO ExitSelect
     IsFight = 0
     PRINT "You flee like the coward you are!"
     PRINT "You loose 100 exp!"
     Player.Exp = Player.Exp - 100
     IF Player.Exp < 0 THEN Player.Exp = 0
     AKILL = 0
     CALL DoRoom
CASE "CASH", "$", "MONEY", "GOLD"
     TempFlag = 1
     LOCATE BOUNDRY, 1
     COLOR STAT, BCLR
     PRINT "You have "; LTRIM$(RTRIM$(STR$(Player.Gold))); " gold in your pocket."
CASE "ST", "STATUS", "STAT"
     TempFlag = 1
     LOCATE BOUNDRY, 1
     COLOR STAT, BCLR
     PRINT "You are a "; Player.Class$; "."
    
     PRINT "You have "; LTRIM$(RTRIM$(STR$(Player.Gold))); " gold in your pocket."
PRINT "Hp : "; LTRIM$(RTRIM$(STR$(Player.Hp)));
PRINT "/"; LTRIM$(RTRIM$(STR$(Player.MaxHp)))

PRINT "Exp : "; LTRIM$(RTRIM$(STR$(Player.Exp)));
PRINT "/"; LTRIM$(RTRIM$(STR$(Player.Needed)))

PRINT "Sp : "; LTRIM$(RTRIM$(STR$(Player.Sp)));
PRINT "/"; LTRIM$(RTRIM$(STR$(Player.MaxSp)))
    
TempX = Words(Player.Wep$, ";")
PRINT "Your weapon is a "; WORD$(1); " "; WORD$(2); ", with an attack power ~ "; WORD$(3); "."
TempX = Words(Player.Arm$, ";")
PRINT "Your armour is "; WORD$(3); ", with a protective power ~ "; WORD$(3); "."
PRINT "You are on level : "; Player.Level


CASE "LIST"
   TempFlag = 1
   IF Player.Room <> 15 AND Player.Room <> 17 AND Player.Room <> 6 THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "Not in a shop!": GOTO ExitSelect
   IF Player.Room = 15 THEN
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      PRINT "[#] --- [Item] ---------- [Cost] -- [~Power]"
      PRINT "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
      PRINT "[1] --- [Short sword] --- [$100] -- [ 9]"
      PRINT "[2] --- [Long sword] ---- [$150] -- [11]"
      PRINT "[3] --- [Mace] ---------- [$200] -- [13]"
      PRINT "[4] --- [Whip of Fire] -- [$300] -- [15]"
      PRINT "[5] --- [Whip of Acid] -- [$400] -- [18]"
      PRINT "[6] --- [Sword of Fire] - [$700] -- [25]"
      PRINT "[7] --- [Sword of Acid] - [$890] -- [29]"
      PRINT "[8] --- [Whip of Death] - [$999] -- [35]"
      PRINT
      PRINT "You have"; STR$(Player.Gold); " gold on hand."
   END IF
   IF Player.Room = 17 THEN
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      PRINT "[#] --- [Item] ---------- [Cost] -- [~Power]"
      PRINT "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
      PRINT "[1] --- [Leather vest] -- [$100] -- [ 5]"
      PRINT "[2] --- [Leather shield]  [$125] -- [ 6]"
      PRINT "[3] --- [Iron vest] ----- [$200] -- [ 8]"
      PRINT "[4] --- [Magic shield] -- [$300] -- [10]"
      PRINT "[5] --- [Shield of Fire]  [$400] -- [12]"
      PRINT
      PRINT "You have"; STR$(Player.Gold); " gold on hand."
   END IF
  
   IF Player.Room = 6 THEN
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      PRINT "Just type BUY for a list/order form."
   END IF


CASE "BUY"
   TempFlag = 1
   IF Player.Room <> 15 AND Player.Room <> 17 AND Player.Room <> 6 THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "Not in a shop!": GOTO ExitSelect
   IF Player.Room = 15 THEN
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      PRINT "[#] --- [Item] ---------- [Cost] -- [~Power]"
      PRINT "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
      PRINT "[1] --- [Short sword] --- [$100] -- [ 9]"
      PRINT "[2] --- [Long sword] ---- [$150] -- [11]"
      PRINT "[3] --- [Mace] ---------- [$200] -- [13]"
      PRINT "[4] --- [Whip of Fire] -- [$300] -- [15]"
      PRINT "[5] --- [Whip of Acid] -- [$400] -- [18]"
      PRINT "[6] --- [Sword of Fire] - [$700] -- [25]"
      PRINT "[7] --- [Sword of Acid] - [$890] -- [29]"
      PRINT "[8] --- [Whip of Death] - [$999] -- [35]"
      PRINT "[9] --- CANCEL"
      PRINT
      PRINT "You have"; STR$(Player.Gold); " gold on hand."
      PRINT "What is the number of the weapon you wish to buy?"
      LOCATE CAMBAR, 1
      C$ = LTRIM$(RTRIM$(InputLine$("", 78, KeyCode%)))
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      SELECT CASE C$
      CASE "9": PRINT "You cancel.": GOTO ExitSelect
      CASE "1"
           IF Player.Gold >= 100 THEN
           PRINT "You bought the Short sword!"
           Player.Gold = Player.Gold - 100
           Player.Wep$ = "Short sword;slash;9"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "2"
           IF Player.Gold >= 150 THEN
           PRINT "You bought the Long sword!"
           Player.Gold = Player.Gold - 150
           Player.Wep$ = "Long sword;slash;11"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "3"
           IF Player.Gold >= 200 THEN
           PRINT "You bought the Mace!"
           Player.Gold = Player.Gold - 200
           Player.Wep$ = "Mace;whack;13"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "4"
           IF Player.Gold >= 300 THEN
           PRINT "You bought the Whip of Fire!"
           Player.Gold = Player.Gold - 300
           Player.Wep$ = "Whip of Fire;burn;15"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "5"
           IF Player.Gold >= 400 THEN
           PRINT "You bought the Whip of Acid!"
           Player.Gold = Player.Gold - 400
           Player.Wep$ = "Whip of Acid;chemical burn;18"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "6"
           IF Player.Gold >= 700 THEN
           PRINT "You bought the Sword of Fire!"
           Player.Gold = Player.Gold - 700
           Player.Wep$ = "Sword of Fire;blazing slash;25"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "7"
           IF Player.Gold >= 890 THEN
           PRINT "You bought the Sword of Acid!"
           Player.Gold = Player.Gold - 890
           Player.Wep$ = "Sword of Acid;chemical slash;29"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "8"
           IF Player.Gold >= 999 THEN
           PRINT "You bought the Whip of Death!"
           Player.Gold = Player.Gold - 999
           Player.Wep$ = "Whip of Death;deadly sting;35"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
          
           END SELECT
   END IF
   
   IF Player.Room = 17 THEN
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      PRINT "[#] --- [Item] ---------- [Cost] -- [~Power]"
      PRINT "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
      PRINT "[1] --- [Leather vest] -- [$100] -- [ 5]"
      PRINT "[2] --- [Leather shield]  [$125] -- [ 6]"
      PRINT "[3] --- [Iron vest] ----- [$200] -- [ 8]"
      PRINT "[4] --- [Magic shield] -- [$300] -- [10]"
      PRINT "[5] --- [Shield of Fire]  [$400] -- [12]"
      PRINT "[6] --- [Cancel]"
      PRINT
      PRINT "You have"; STR$(Player.Gold); " gold on hand."
      PRINT "What is the number of the armour you wish to buy?"
      LOCATE CAMBAR, 1
      C$ = LTRIM$(RTRIM$(InputLine$("", 78, KeyCode%)))
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      SELECT CASE C$
      CASE "6": PRINT "You cancel.": GOTO ExitSelect
      CASE "1"
           IF Player.Gold >= 100 THEN
           PRINT "You bought the Leather vest!"
           Player.Gold = Player.Gold - 100
           Player.Arm$ = "LEATHER VEST;a leather vest;5"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "2"
           IF Player.Gold >= 125 THEN
           PRINT "You bought the Leather shield!"
           Player.Gold = Player.Gold - 125
           Player.Arm$ = "LEATHER SHIELD;a leather shield;6"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "3"
           IF Player.Gold >= 200 THEN
           PRINT "You bought the Iron vest"
           Player.Gold = Player.Gold - 200
           Player.Arm$ = "IRON VEST;an Iron vest;8"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "4"
           IF Player.Gold >= 300 THEN
           PRINT "You bought the Magic Shield!"
           Player.Gold = Player.Gold - 300
           Player.Arm$ = "MAGIC SHIELD;a Magic shield;10"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "5"
           IF Player.Gold >= 400 THEN
           PRINT "You bought the Shield of Fire!"
           Player.Gold = Player.Gold - 400
           Player.Arm$ = "SHIELD OF FIRE;a Shield of Fire;12"
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
   END SELECT
   END IF

   IF Player.Room = 6 THEN
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      PRINT "[#] --- [Item] ---------- [Cost] -- [~Power] - [ Hp]"
      PRINT "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
      PRINT "[1] --- [Mouse] --------- [$ 75] -- [ 8] ----- [ 30]"
      PRINT "[2] --- [Rat] ----------- [$125] -- [13] ----- [ 40]"
      PRINT "[3] --- [Snake] --------- [$200] -- [15] ----- [ 55]"
      PRINT "[4] --- [Falcon] -------- [$300] -- [17] ----- [ 70]"
      PRINT "[5] --- [Wolf] ---------- [$400] -- [19] ----- [ 80]"
      PRINT "[6] --- [Tiger] --------- [$510] -- [23] ----- [ 95]"
      PRINT "[7] --- [Lion] ---------- [$620] -- [25] ----- [120]"
      PRINT "[8] --- [Martian] ------- [$830] -- [29] ----- [150]"
      PRINT "[9] --- [Cancel]"
      PRINT
      PRINT "You have"; STR$(Player.Gold); " gold on hand."
      PRINT "What is the number of the animal you wish to buy?"
      LOCATE CAMBAR, 1
      C$ = LTRIM$(RTRIM$(InputLine$("", 78, KeyCode%)))
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      SELECT CASE C$
      CASE "9": PRINT "You cancel.": GOTO ExitSelect
      CASE "1"
           IF Player.Gold >= 75 THEN
           PRINT "You bought the mouse.  It is now your pet."
           Player.Gold = Player.Gold - 75
           Player.pet$ = "MOUSE;a mouse;Your pet mouse is here.;bite;8;30"
           Pet.MHp = 30
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "2"
           IF Player.Gold >= 125 THEN
           PRINT "You bought the rat.  It is now your pet."
           Player.Gold = Player.Gold - 125
           Player.pet$ = "RAT;a rat;Your pet rat is here.;bite;13;40"
           Pet.MHp = 40
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "3"
           IF Player.Gold >= 200 THEN
           PRINT "You bought the snake.  It is now your pet."
           Player.Gold = Player.Gold - 200
           Player.pet$ = "SNAKE;a snake;Your pet snake is here.;strike;15;55"
           Pet.MHp = 55
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "4"
           IF Player.Gold >= 300 THEN
           PRINT "You bought the falcon.  It is now your pet."
           Player.Gold = Player.Gold - 300
           Player.pet$ = "FALCON;a falcon;Your pet falcon is here.;peck;17;70"
           Pet.MHp = 70
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "5"
           IF Player.Gold >= 400 THEN
           PRINT "You bought the wolf.  It is now your pet."
           Player.Gold = Player.Gold - 400
           Player.pet$ = "WOLF;a wolf;Your pet wolf is here.;bite;19;80"
           Pet.MHp = 80
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "6"
           IF Player.Gold >= 510 THEN
           PRINT "You bought the tiger.  It is now your pet."
           Player.Gold = Player.Gold - 510
           Player.pet$ = "TIGER;a tiger;Your pet tiger is here.;bite;23;95"
           Pet.MHp = 95
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "7"
           IF Player.Gold >= 620 THEN
           PRINT "You bought the lion.  It is now your pet."
           Player.Gold = Player.Gold - 620
           Player.pet$ = "LION;a lion;Your pet lion is here.;slash;25;120"
           Pet.MHp = 120
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
      CASE "8"
           IF Player.Gold >= 830 THEN
           PRINT "You bought the Martian.  It is now your pet."
           Player.Gold = Player.Gold - 830
           Player.pet$ = "MARTIAN;a martian;Your pet Martian is here.;ray gun;29;150"
           Pet.MHp = 150
           GOTO ExitSelect
           END IF
           PRINT "Not enough gold!"
           GOTO ExitSelect
           END SELECT
 
   END IF









CASE "MAP"
   TempFlag = 1
   CALL DoMap


END SELECT
END IF



IF W >= 2 THEN
TCAM$ = WORD$(1)
  TTCAM$ = ""
  IF W > 2 THEN TTCAM$ = WORD$(3)
SELECT CASE UCASE$(TCAM$)


CASE "K", "KILL", "ATTACK"
    TempFlag = 1
    IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
    IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
    Enemy$ = WORD$(2)
    
    TempFlag2 = 0
    Temp = 1
   
   
    FOR Temp = 1 TO NPCn
    TempX = Words(NPC$(Temp), ";")
    IF LCASE$(Enemy$) = LCASE$(WORD$(1)) THEN TempFlag2 = 2
    NEXT Temp
   
    Temp = 1


    FOR Temp = 1 TO 100
    TempX = Words(NounDesc$(Temp), ";")
      
       IF WORD$(1) = UCASE$(TTCAM$) THEN
          IF WORD$(2) = UCASE$(Enemy$) THEN
               SWAP Enemy$, TTCAM$
           END IF
        END IF


       IF WORD$(1) = UCASE$(Enemy$) AND Temp < 20 THEN
       LOCATE BOUNDRY, 1
       COLOR SPEC, BCLR
       PRINT "You can't attack that!"
       GOTO ExitSelect
       END IF


       IF WORD$(1) = UCASE$(Enemy$) AND Temp = 90 AND Player.Level < 13 THEN
       LOCATE BOUNDRY, 1
       COLOR SPEC, BCLR
       PRINT "The dark being looks at you and laughs.  You must be level 13 to attack it."
       GOTO ExitSelect
       END IF

       IF WORD$(1) = UCASE$(Enemy$) AND Temp > 19 THEN
       FOR TempN = 1 TO 50
          IF InRoom(Player.Room, TempN) = Temp THEN TempFlag2 = 1: Enemyno = Temp
          NEXT TempN
       END IF
    NEXT Temp
   
   
    IF TempFlag2 = 2 THEN
    LOCATE BOUNDRY, 1
    COLOR SPEC, BCLR
    PRINT "You can't attack an NPC!  They are your friends!  Shame on you!"
    GOTO ExitSelect
    END IF
   
   
   
    IF TempFlag2 = 1 THEN
    TempX = Words(NounStat$(Enemyno), ";")
    Enemy.Hp = VAL(WORD$(1))
   
    IF Player.Level > 3 THEN
    Enemy.Hp = Enemy.Hp + (Player.Level + 2)
    END IF

    EHP = Enemy.Hp '' (Enemy's max Hp is starting Hp)
    TFlag = 1: IsFight = 1: GOTO ExitSelect
    END IF
   
   
    IF TempFlag2 = 0 THEN
       COLOR SPEC, BCLR
       LOCATE BOUNDRY, 1
       IF W > 2 THEN SWAP TTCAM$, Enemy$: TTCAM$ = TTCAM$ + " "
       PRINT "There is no "; TTCAM$; Enemy$; " here."
    END IF
CASE "CAST", "C"
    TempFlag = 1
    IF IsSleep = 1 THEN LOCATE BOUNDRY, 1: COLOR STAT, BCLR: PRINT "Zzzz Zzzz": GOTO ExitSelect
    Spell$ = UCASE$(WORD$(2))
    'Check is Spell is Valid...
         IsValid = 0
         FOR t = 1 TO Player.Scroll
         nottyboy = Words(Magic$(t), ";")
         IF Spell$ = WORD$(1) THEN IsValid = t
         NEXT t
         IF IsValid = 0 THEN COLOR STAT, BCLR: PRINT "You do not know that spell.": GOTO ExitSelect
   
    'What is the spell?  (Hurt, Damage, etc)
         nottyboy = Words(Magic$(IsValid), ";")
         WK$ = WORD$(2)
         nSp = VAL(WORD$(4))
         Hdm = VAL(WORD$(5))
   COLOR STAT, BCLR
   LOCATE BOUNDRY, 1
   SELECT CASE WK$
CASE "H"
   IF Player.Sp < nSp THEN PRINT "You don't have enough Sp!  You need:"; STR$(nSp); "!": GOTO ExitSelect
   Player.Sp = Player.Sp - nSp
   Player.Hp = Player.Hp + Hdm
     IF Player.Hp > Player.MaxHp THEN Player.Hp = Player.MaxHp
     COLOR SPEC, BCLR
     PRINT "You cast the "; WORD$(3); "!  "; WORD$(6)
     CALL Waita
     GOTO ExitSelect
CASE "D"
   IF IsFight = 0 THEN PRINT "You are not in a fight!": GOTO ExitSelect
   IF Player.Sp < nSp THEN PRINT "You don't have enough Sp!  You need:"; STR$(nSp); "!": GOTO ExitSelect
   Player.Sp = Player.Sp - nSp
   Enemy.Hp = Enemy.Hp - Hdm
     IF Enemy.Hp < 1 THEN IsFight = 99
     COLOR SPEC, BCLR
     PRINT "You cast the "; WORD$(3); "!  "; WORD$(6)
     CALL Waita
     GOTO ExitSelect
CASE "P"
   IF Player.Sp < nSp THEN PRINT "You don't have enough Sp!  You need:"; STR$(nSp); "!": GOTO ExitSelect
   Player.Sp = Player.Sp - nSp
   Pet.MHp = Pet.MHp + Hdm
     COLOR SPEC, BCLR
     PRINT "You cast the "; WORD$(3); "!  "; WORD$(6)
     CALL Waita
     GOTO ExitSelect
CASE "A"
   IF Player.Sp < nSp THEN PRINT "You don't have enough Sp!  You need:"; STR$(nSp); "!": GOTO ExitSelect
   Player.Sp = Player.Sp - nSp
   OldArm = Hdm
   Armcount = 24
     COLOR SPEC, BCLR
     PRINT "You cast the "; WORD$(3); "!  "; WORD$(6)
     CALL Waita
     GOTO ExitSelect

END SELECT


CASE "L", "LOOK", "CON", "CONTRAST"
    TempFlag = 1
    IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
    IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
    Enemy$ = WORD$(2)
    TempFlag2 = 0
    Temp = 1
  
    FOR Temp = 1 TO 100
    TempX = Words(NounDesc$(Temp), ";")
     
       IF WORD$(1) = UCASE$(TTCAM$) THEN
          IF WORD$(2) = UCASE$(Enemy$) THEN
                 SWAP Enemy$, TTCAM$
           END IF
        END IF
      
      
      
      
       IF WORD$(1) = UCASE$(Enemy$) AND Temp < 20 THEN
       LOCATE BOUNDRY, 1
       COLOR SPEC, BCLR
       PRINT "You can't attack that!"
       GOTO ExitSelect
       END IF

       IF WORD$(1) = UCASE$(Enemy$) AND Temp > 19 THEN
       FOR TempN = 1 TO 50
          IF InRoom(Player.Room, TempN) = Temp THEN TempFlag2 = 1: Enemyno = Temp
          NEXT TempN
       END IF
    NEXT Temp
  
   
   
    IF TempFlag2 = 1 THEN
    TempX = Words(NounStat$(Enemyno), ";")
    Enemy.Hp = VAL(WORD$(1))
   
    IF Player.Level > 3 THEN
    Enemy.Hp = Enemy.Hp + Player.Level + 2
    END IF
    Enemy.Att = VAL(WORD$(5))

    IF Player.Level > 3 THEN
    Enemy.Att = Enemy.Att + Player.Level + 2
    END IF



    TempX = Words(NounDesc$(Enemyno), ";")
    DE$ = LCASE$(WORD$(2))
    COLOR STAT, BCLR
    LOCATE BOUNDRY, 1
    PRINT "The "; DE$; " "; Enemy$; " has ~"; STR$(Enemy.Hp); "hp and ~"; STR$(Enemy.Att); " attack strength."

TempX = Words(Player.Wep$, ";")
Bang = VAL(WORD$(3))
   
    PRINT "You have"; STR$(Player.Hp); "hp and ~"; STR$(Bang); " attack strength."
    END IF
  
  

    IF TempFlag2 = 0 THEN
       COLOR SPEC, BCLR
       LOCATE BOUNDRY, 1
       IF W > 2 THEN SWAP TTCAM$, Enemy$: TTCAM$ = TTCAM$ + " "
       PRINT "There is no "; TTCAM$; Enemy$; " here."
    END IF
   
CASE "READ"
    TempFlag = 1
    IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
    IF IsFight <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Ugg!  Ouch!  You are in a fight!": GOTO ExitSelect
    Item$ = WORD$(2)
    TempFlag2 = 0
    Temp = 1
 
    IF UCASE$(Item$) = "TOWN" AND UCASE$(TTCAM$) = "MAP" THEN CALL DoMap: GOTO ExitSelect
    IF UCASE$(Item$) = "SPELL" AND UCASE$(TTCAM$) = "BOOK" THEN CALL DoSpell: GOTO ExitSelect
    IF UCASE$(Item$) = "MAP" THEN CALL DoMap: GOTO ExitSelect
    IF UCASE$(Item$) = "BOOK" THEN CALL DoSpell: GOTO ExitSelect
   
    FOR Temp = 1 TO Cary
    TempX = Words(INV$(Temp), ";")

      
       IF UCASE$(WORD$(1)) = UCASE$(Item$) THEN
          IF UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN
               'SWAP Item$, TTCAM$
               TempFlag2 = 1
               nottyboy = Temp
           END IF
        END IF
   
    IF UCASE$(Item$) = UCASE$(WORD$(2)) THEN TempFlag2 = 1: nottyboy = Temp
   
    NEXT Temp
    TempX = Words(INV$(nottyboy), ";")
    IF TempFlag2 = 1 THEN
       IF WORD$(3) <> "READ" THEN COLOR STAT, BCLR: PRINT "Not readable!": GOTO ExitSelect
       COLOR SPEC, BCLR
       PRINT "The "; WORD$(1); " "; WORD$(2); " reads as follows:"
       PRINT : PRINT WORD$(9)
    END IF

   
   
   
    IF TempFlag2 = 0 THEN
       COLOR SPEC, BCLR
       LOCATE BOUNDRY, 1
       IF W > 2 THEN Item$ = Item$ + " "
       PRINT "There is no "; Item$; TTCAM$; " in your inventory."
    END IF
  





CASE "DROP"
    TempFlag = 1
    IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
    Item$ = WORD$(2)
   
    'Can't drop some items
   
    IF UCASE$(Item$) = "TOWN" AND UCASE$(TTCAM$) = "MAP" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't drop your town map!": GOTO ExitSelect
    IF UCASE$(Item$) = "SPELL" AND UCASE$(TTCAM$) = "BOOK" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't drop your spell book!": GOTO ExitSelect
    IF UCASE$(Item$) = "MAP" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't drop your town map!": GOTO ExitSelect
    IF UCASE$(Item$) = "BOOK" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't drop your spell book!": GOTO ExitSelect
   
    TempFlag2 = 0


    Temp = 1


    FOR Temp = 1 TO Cary
    TempX = Words(INV$(Temp), ";")
     
       IF UCASE$(WORD$(1)) = UCASE$(Item$) THEN
          IF UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN
               'SWAP Item$, TTCAM$
               TempFlag2 = 1
               nottyboy = Temp
           END IF
        END IF


    IF UCASE$(Item$) = UCASE$(WORD$(2)) THEN TempFlag2 = 1: nottyboy = Temp
  


    NEXT Temp
  
    TempX = Words(INV$(nottyboy), ";")
   
    IF TempFlag2 = 1 THEN
    COLOR ACTI, BCLR
    LOCATE BOUNDRY, 1
    Tw1$ = WORD$(1): Tw2$ = WORD$(2)
    PRINT "You drop the "; WORD$(1); " "; WORD$(2); "."
    CALL DoINV("SORT", "x")
       
    FOR TempN = 1 TO 500
    IF TempN > 19 AND TempN < 100 THEN GOTO BlaCycl
    IF UCASE$(INV$(nottyboy)) = UCASE$(NounDesc$(TempN)) THEN heHaw = TempN: EXIT FOR
BlaCycl:
    NEXT TempN
    INV$(nottyboy) = ""
   
    FOR TempN = 1 TO 50
       IF InRoom(Player.Room, TempN) = 0 THEN Rroomy = TempN: EXIT FOR
    NEXT TempN
      
    InRoom(Player.Room, Rroomy) = heHaw
   
    'Are you dropping your weapon?
    nottyboy = Words(Player.Wep$, ";")
    IF UCASE$(Tw1$) = UCASE$(WORD$(1)) AND UCASE$(Tw2$) = UCASE$(WORD$(2)) THEN
    COLOR 4, BCLR
    PRINT "You have no weapon!"
    Player.Wep$ = "Your;hand;punch;2"
    END IF
   
    'Are you dropping your armour?
   
    nottyboy = Words(Player.Arm$, ";")
    IF UCASE$(Tw1$) = UCASE$(WORD$(1)) AND UCASE$(Tw2$) = UCASE$(WORD$(2)) THEN
    COLOR 4, BCLR
    PRINT "You have no armour!"
    Player.Arm$ = "Tee;shirt;a tee shirt;1"
    END IF
  
   END IF

  
    IF TempFlag2 = 0 THEN
       COLOR SPEC, BCLR
       LOCATE BOUNDRY, 1
       IF W > 2 THEN SWAP TTCAM$, Item$: TTCAM$ = TTCAM$ + " "
       PRINT "There is no "; TTCAM$; Item$; " in your inventory."
    END IF
CASE "GET", "TAKE"
    TempFlag = 1
    IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
    Item$ = WORD$(2)
    TempFlag2 = 0
    Temp = 1
 
    FOR Temp = 1 TO 500
    
   
    TempX = Words(NounDesc$(Temp), ";")
    

   
       IF UCASE$(WORD$(2)) = UCASE$(Item$) THEN
       IF Temp > 19 AND Temp < 100 THEN
       LOCATE BOUNDRY, 1
       COLOR SPEC, BCLR
       TempFlag2 = 3
       'GOTO HeyGirl2
       END IF
       END IF

       IF UCASE$(WORD$(1)) = UCASE$(Item$) THEN
       IF Temp > 19 AND Temp < 100 THEN
       LOCATE BOUNDRY, 1
       COLOR SPEC, BCLR
       TempFlag2 = 3
       'GOTO HeyGirl2
       END IF
       END IF

       IF UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN
       IF Temp > 19 AND Temp < 100 THEN
       LOCATE BOUNDRY, 1
       COLOR SPEC, BCLR
       TempFlag2 = 3
       'GOTO HeyGirl2
       END IF
       END IF



IF UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN
   IF UCASE$(WORD$(1)) = UCASE$(Item$) THEN
       FOR TempN = 1 TO 50
       IF InRoom(Player.Room, TempN) = Temp THEN TempFlag2 = 1: Iitem = Temp: Eitem = TempN: GOTO HeyGirl2
       NEXT TempN
     END IF
END IF



       IF UCASE$(WORD$(2)) = UCASE$(Item$) THEN 'AND UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN
          FOR TempN = 1 TO 50
          IF InRoom(Player.Room, TempN) = Temp THEN TempFlag2 = 1: Iitem = Temp: Eitem = TempN: GOTO HeyGirl2
          NEXT TempN
          END IF
       
   
HeyGirl:
    NEXT Temp
HeyGirl2:
  
  
    IF TempFlag2 = 1 THEN
    BillyBill = 0
    FOR t = 1 TO Cary
    IF INV$(t) = "" THEN INV$(t) = NounDesc$(Iitem): BillyBill = 1: EXIT FOR
    NEXT t
    TempX = Words(NounDesc$(Iitem), ";")
    IF BillyBill = 0 THEN
    COLOR STAT, BCLR
    LOCATE BOUNDRY, 1
    PRINT "You can't carry anymore!"
    GOTO ExitSelect
    END IF

    IF Iitem > 19 AND Iitem < 100 THEN
       COLOR STAT, BCLR
       LOCATE BOUNDRY, 1
       PRINT "You can't get that!"
       GOTO ExitSelect
    END IF

   
    COLOR ACTI, BCLR
    LOCATE BOUNDRY, 1
    PRINT "You now carry the "; WORD$(1); " "; WORD$(2); "."
    InRoom(Player.Room, Eitem) = 0
    END IF


    IF TempFlag2 = 0 THEN
       COLOR SPEC, BCLR
       LOCATE BOUNDRY, 1
       IF W > 2 THEN Item$ = Item$ + " "
       PRINT "There is no "; Item$; TTCAM$; " here."
    END IF

    IF TempFlag2 = 3 THEN
       COLOR STAT, BCLR
       LOCATE BOUNDRY, 1
       PRINT "You can't get that!"
       END IF
CASE "WEAR", "WIELD"
    TempFlag = 1
    IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
    Item$ = WORD$(2)
  
    'Can't wear some items
  
    IF UCASE$(Item$) = "TOWN" AND UCASE$(TTCAM$) = "MAP" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't wear your town map!": GOTO ExitSelect
    IF UCASE$(Item$) = "SPELL" AND UCASE$(TTCAM$) = "BOOK" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't wear your spell book!": GOTO ExitSelect
    IF UCASE$(Item$) = "MAP" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't wear your town map!": GOTO ExitSelect
    IF UCASE$(Item$) = "BOOK" THEN COLOR SPEC, BCLR: LOCATE BOUNDRY, 1: PRINT "You can't wear your spell book!": GOTO ExitSelect
  
   
   
   
    TempFlag2 = 0


    Temp = 1


    FOR Temp = 1 TO Cary
    TempX = Words(INV$(Temp), ";")
    
       IF UCASE$(WORD$(1)) = UCASE$(Item$) THEN
          IF UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN
               'SWAP Item$, TTCAM$
               TempFlag2 = 1
               nottyboy = Temp
           END IF
        END IF


    IF UCASE$(Item$) = UCASE$(WORD$(2)) THEN TempFlag2 = 1: nottyboy = Temp
 


    NEXT Temp
 
    TempX = Words(INV$(nottyboy), ";")
  
    IF TempFlag2 = 1 THEN
    COLOR ACTI, BCLR
    LOCATE BOUNDRY, 1
    Tw1$ = WORD$(1): Tw2$ = WORD$(2)
    PRINT "You wear the "; WORD$(1); " "; WORD$(2); "."
    CALL DoINV("SORT", "x")
      
    FOR TempN = 1 TO 500
    IF TempN > 19 AND TempN < 100 THEN GOTO BlaCycl3
    IF UCASE$(INV$(nottyboy)) = UCASE$(NounDesc$(TempN)) THEN heHaw = TempN: EXIT FOR
BlaCycl3:
    NEXT TempN
   
    'INV$(Nottyboy) = ""
  
   
    'FOR TempN = 1 TO 50
    '   IF InRoom(Player.Room, TempN) = 0 THEN Rroomy = TempN: EXIT FOR
    'NEXT TempN
     
    'InRoom(Player.Room, Rroomy) = heHaw
  
   
   
    'Are you wearing a weapon or armour?

    IF heHaw < 200 THEN
       Player.Wep$ = NounDesc$(heHaw)
       COLOR STAT, BCLR
       LOCATE BOUNDRY, 1
       PRINT "You now wear the "; WORD$(1); " "; WORD$(2); " as a weapon."
       ELSE
       Player.Arm$ = NounDesc$(heHaw)
       COLOR STAT, BCLR
       LOCATE BOUNDRY, 1
       PRINT "You now wear the "; WORD$(1); " "; WORD$(2); " as armour."
    END IF





 

   END IF

 
    IF TempFlag2 = 0 THEN
       COLOR SPEC, BCLR
       LOCATE BOUNDRY, 1
       IF W > 2 THEN SWAP TTCAM$, Item$: TTCAM$ = TTCAM$ + " "
       PRINT "There is no "; TTCAM$; Item$; " in your inventory."
    END IF

CASE "REMOVE", "REM", "UNWEAR", "DISROBE", "UNWIELD"
    TempFlag = 1
    IF IsSleep <> 0 THEN COLOR STAT, BCLR: LOCATE BOUNDRY, 1: PRINT "Zzzz Zzzz You are asleep Zzzz": GOTO ExitSelect
    Item$ = WORD$(2)
    TempFlag2 = 0
   
    
    nottyboy = Words(Player.Wep$, ";")
    IF UCASE$(WORD$(2)) = UCASE$(Item$) THEN TempFlag2 = 1 'Weapon
    IF UCASE$(WORD$(1)) = UCASE$(Item$) AND UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN TempFlag2 = 1

    nottyboy = Words(Player.Arm$, ";")
    IF UCASE$(WORD$(2)) = UCASE$(Item$) THEN TempFlag2 = 2 'Armour
    IF UCASE$(WORD$(1)) = UCASE$(Item$) AND UCASE$(WORD$(2)) = UCASE$(TTCAM$) THEN TempFlag2 = 2


    IF TempFlag2 = 1 THEN nottyboy = Words(Player.Wep$, ";") ELSE nottyboy = Words(Player.Arm$, ";")

       LOCATE BOUNDRY, 1
   
    'If Weapon...
    IF TempFlag2 = 1 THEN
       IF UCASE$(WORD$(2)) = "HAND" AND UCASE$(WORD$(1)) = "YOUR" THEN
         COLOR STAT, BCLR
         PRINT "You can't remove your hand!"
         GOTO ExitSelect
       END IF
       COLOR ACTI, BCLR
       PRINT "You stop using the "; WORD$(1); " "; WORD$(2); " as your weapon."
       COLOR STAT, BCLR
       PRINT "Your weapon is now your hand."
       Player.Wep$ = "Your;hand;punch;2"
       GOTO ExitSelect
    END IF

    'If Armour...
    IF TempFlag2 = 2 THEN
       IF UCASE$(WORD$(2)) = "SHIRT" AND UCASE$(WORD$(1)) = "TEE" THEN
         COLOR STAT, BCLR
         PRINT "You can't remove the tee shirt!  (You'll be... naked!)"
         GOTO ExitSelect
       END IF
       COLOR ACTI, BCLR
       PRINT "You stop using the "; WORD$(1); " "; WORD$(2); " as your armour."
       COLOR STAT, BCLR
       PRINT "Your armour is now a tee shirt."
       Player.Arm$ = "Tee;shirt;a tee shirt;1"
       GOTO ExitSelect
     END IF

     IF TempFlag2 = 0 THEN
        COLOR STAT, BCLR
        IF W > 2 THEN Item$ = Item$ + " "
        PRINT "You aren't wearing a "; Item$; TTCAM$; "."
        GOTO ExitSelect
     END IF



END SELECT
END IF



IF W = 3 THEN
TCAM$ = WORD$(1)

SELECT CASE UCASE$(TCAM$)
CASE "SET"
    TempFlag = 1
    Funct$ = UCASE$(LTRIM$(RTRIM$(WORD$(2))))
   
    IF Funct$ = "DELAY" THEN
       COLOR STAT, BCLR
      
       FunT$ = WORD$(3)
       Dely = VAL(FunT$)
          IF Dely < .5 THEN
          Dely = .5
          PRINT "Delay set to .5 seconds (can't be less than .5 seconds)"
          GOTO ExitSelect
          END IF
          IF Dely > 5 THEN
          Dely = 5
          PRINT "Delay set to  5 seconds (can't be more than 5 seconds)"
          GOTO ExitSelect
          END IF
       PRINT "Battle delay set to"; STR$(Dely); " seconds."
       GOTO ExitSelect
     END IF

    IF Funct$ = "NPC" THEN
       ONPCn = NPCn
       COLOR STAT, BCLR
     
       FunT$ = WORD$(3)
       NPCn = VAL(FunT$)
          IF NPCn < 1 THEN
          NPCn = 1
          PRINT "(must have at least one NPC)"
          
          END IF
          IF NPCn > 10 THEN
          NPCn = 10
          PRINT "(Can have no more than 10 NPCs)"
          
          END IF
       PRINT "# of NPCs set to"; STR$(NPCn); "."
      
       IF ONPCn < NPCn THEN
          FOR t = (ONPCn + 1) TO NPCn
          NPCr(t) = INT(RND * R) + 1
             Temp = Words(NPC$(t), ";")
             WORD$(2) = LCASE$(WORD$(2))
             LOCATE BOUNDRY, 1
             COLOR SPEC, BCLR

             PRINT WORD$(1); ", "; WORD$(2); ", enters the game in area:"; STR$(NPCr(t)); "."

          NEXT t
       END IF



       GOTO ExitSelect
    
    
     END IF


END SELECT
END IF

ExitSelect:

IF TempFlag = 0 THEN
   LOCATE BOUNDRY, 1
   COLOR SPEC, BCLR
   PRINT "Command not understood!"
END IF


END SUB

SUB DoHelp
COLOR SPEC, BCLR
LOCATE BOUNDRY, 1
PRINT
PRINT "Online Help for a "; Player.Class$; ":"
COLOR GENC, BCLR
PRINT "LOOK,L; LOOK,CON monster      Shows the area's info; Shows monster's info."
PRINT "N, S, E, W                    Go north, south, east, west."
PRINT "KILL,K monster                Attacks the monster."
PRINT "SLEEP, WAKE                   Go to sleep, wake up."
PRINT "RECALL                        Transport to the center of town."
PRINT "FLEE,RUN                      Flee from battle.  It'll cost you 100 exp."
PRINT "CASH,$,MONEY,GOLD             Shows how much money you have on hand."
PRINT "ST,STATUS; MAP                Shows your status; Shows a map of the town."
PRINT "SET DELAY n, NPC n            Set the # of seconds in a delay, the # NPC's."
PRINT "DELAY, NPC                    Shows the battle delay, Shows stats of NPCs."
PRINT "SPELL, CAST spell             List of spells you know, Cast a spell."
PRINT "QUIT,Q,END                    Quits the game"
COLOR SPEC, BCLR
PRINT "Sp and Hp recharge faster when asleep.  Your status is auto-saved when you quit."
PRINT "Read the TUJURE.TXT file for more help & tips.  NPC's are the computer players."
PRINT
PRINT "Notes on "; Player.Class$; "s:"
IF Player.Class$ = "Paladin" THEN PRINT "  You are best at healing spells.  Sp recharges faster than most."
IF Player.Class$ = "Barbarian" THEN PRINT "  You are best at weapons.  You have quick Hp recharge, but few spells."
IF Player.Class$ = "Sorcerer" THEN PRINT "  You have more spells.  Sp recharge is the fastest, but slow Hp recharge."
IF Player.Class$ = "Ninja" THEN PRINT "  You are agile with moderate spells.  You can dodge attacks better than most."
IF Player.Class$ = "Monk" THEN PRINT "  You have a moderate combination of magical and physical abilities."







COLOR GENC, BCLR
PRINT "<Hp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Hp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxHp)));

PRINT " Exp";

 PRINT LTRIM$(RTRIM$(STR$(Player.Exp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.Needed)));
PRINT " Sp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Sp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxSp)));


PRINT ">"


END SUB

SUB DoINV (K1$, k2$)

SELECT CASE K1$
CASE "LOAD"
   t = 1
   OPEN "inv.dat" FOR INPUT AS #1
   DO WHILE NOT EOF(1)
   INPUT #1, INV$(t)
   PRINT t; "  "; INV$(t)
   t = t + 1
   LOOP
   CLOSE #1
   'CALL Hexit("1")
   'END
CASE "LIST"
   COLOR STAT, BCLR
   LOCATE BOUNDRY, 1
   PRINT "You are carrying the following:"
   COLOR SPEC, BCLR
   PRINT "A town map"
   PRINT "A spell book"
   Tpound = 0
   FOR t = 1 TO Cary
  
   IF INV$(t) = "" THEN EXIT FOR
   nottyboy = Words(INV$(t), ";")
   Nadj$ = WORD$(1)
   Nnam$ = WORD$(2)
   Tpound = Tpound + VAL(WORD$(8))

   PRINT "A "; Nadj$; " "; Nnam$

NextSpaceAh:
   NEXT t
   COLOR STAT, BCLR
   PRINT "You are carrying"; t + 1; "/"; Cary + 1; " items and"; Tpound + 2; "/"; (Cary * 7) + 2; " pounds."
CASE "SORT"
   FOR t = 1 TO 40
   HeyHey$(t) = ""
   SWAP INV$(t), HeyHey$(t)
   NEXT t
   agy = 1
   FOR t = 1 TO 40
   IF HeyHey$(t) = "" THEN GOTO gWizzy
   SWAP INV$(agy), HeyHey$(t)
   agy = agy + 1
gWizzy:
   NEXT t



END SELECT

END SUB

SUB DoKill

COLOR SPEC, BCLR
LOCATE BOUNDRY, 1

Pet = 0
Tempzz = Words(Player.pet$, ";")

IF Tempzz > 1 THEN
   Pet = 1
   Pet.Name$ = LCASE$(WORD$(1))
   Pet.Att$ = WORD$(4)
   Pet.Str = VAL(WORD$(5))
   Pet.Xhp = VAL(WORD$(6))
END IF





TempX = Words(NounStat$(Enemyno), ";")

Enemy.Attack$ = WORD$(2)
Enemy.Gold = VAL(WORD$(3))
Enemy.Exp = VAL(WORD$(4))

TempX = INT(RND * 100) + 20
Enemy.Exp = Enemy.Exp + TempX
TempX = INT(RND * 10) + 1
IF Player.Level > 3 THEN Enemy.Gold = Enemy.Gold + Player.Level + 4
Enemy.Gold = Enemy.Gold + TempX

Enemy.Att = VAL(WORD$(5))

IF Player.Level > 3 THEN
Enemy.Att = Enemy.Att + Player.Level + 2
END IF



TempX = Words(Player.Wep$, ";")
WEP$ = WORD$(2)
STRi$ = WORD$(3)
Bang = VAL(WORD$(4))

TempX = Words(Player.Arm$, ";")
AHelp = VAL(WORD$(4))
IF Armcount > 0 THEN AHelp = AHelp + OldArm

BGS = INT(AHelp / 2)
AHelp = INT(RND * AHelp) + BGS
'ETE = Enemy.Att - 5
'IF AHelp >= ETE THEN Enemy.Att = Enemy.Att + 5


SELECT CASE IsFight
CASE 2: GOTO NextStep0
CASE 2.5: GOTO Ok2.5
CASE 3: GOTO NextStep1
CASE 3.5: GOTO Ok3.5
CASE 4: GOTO NextStepB
CASE 4.5: GOTO Ok4.5
CASE 5: GOTO NextStep2
CASE 5.5: GOTO Ok5.5
CASE 6: GOTO NextStepC
CASE 6.5: GOTO Ok6.5
CASE 7: GOTO NextStep3
CASE 7.5: GOTO Ok7.5
CASE 8: GOTO NextStepE

CASE 99: Enemy.Hp = 0: AKILL = 1: GOTO 4567654
CASE 0: EXIT SUB
END SELECT

IF IsFight = 0 THEN EXIT SUB



PRINT "You attack the "; Enemy$; "!"
RANDOMIZE TIMER


LOCATE BOUNDRY

CALL Waita
IF IsFight = 0 THEN EXIT SUB


'IF TFlag6 = 0 THEN WTill4! = TIMER + dely: TFlag6 = 1
'   TempY2 = DoWait4(WTill4!)
'   IF TempY2 <> 1 THEN IsFight = 2: GOTO EndDaSub
'   IF TempY2 = 1 THEN
'   TFlag6 = 0
'END IF

NextStep0:



LOCATE BOUNDRY, 1
   RANDOMIZE TIMER
   BGS = INT(Bang / 2)
TempX = INT(RND * Bang) + BGS
BOP$ = "misses"
IF TempX > 0 THEN BOP$ = "hits"
IF TempX > 2 THEN BOP$ = "nails"
IF TempX > 4 THEN BOP$ = "demolishes"
IF TempX > 6 THEN BOP$ = "destroys"
IF TempX > 8 THEN BOP$ = "anihalates"
IF TempX > 10 THEN BOP$ = "disembowls"
IF TempX > 15 THEN BOP$ = "chops up"
IF TempX > 20 THEN BOP$ = "slices up"
IF TempX > 30 THEN BOP$ = "knocks bits of brain out of"

TempQQQ = TempX

IF Pet = 1 THEN
   RANDOMIZE TIMER
Tempx2 = INT(RND * Pet.Str)
BOP2$ = "misses"
IF Tempx2 > 0 THEN BOP2$ = "hits"
IF Tempx2 > 2 THEN BOP2$ = "nails"
IF Tempx2 > 4 THEN BOP2$ = "demolishes"
IF Tempx2 > 6 THEN BOP2$ = "destroys"
IF Tempx2 > 8 THEN BOP2$ = "anihalates"
IF Tempx2 > 10 THEN BOP2$ = "disembowls"
IF Tempx2 > 15 THEN BOP$ = "chops up"
IF Tempx2 > 20 THEN BOP$ = "slices up"
IF Tempx2 > 30 THEN BOP$ = "knocks bits of brain out of"

TempQQQ = TempQQQ + Tempx2
END IF


COLOR 14, BCLR
PRINT "  Your "; STRi$; " "; BOP$; " the "; Enemy$; "!"


Ok2.5:

'LOCATE BOUNDRY, 1

CALL Waita
IF IsFight = 0 THEN EXIT SUB

'IF TFlag8 = 0 THEN WTill7! = TIMER + dely: TFlag8 = 1
'   TempY2 = DoWait7(WTill7!)
'   IF TempY2 <> 1 THEN IsFight = 2.5: GOTO EndDaSub
'   IF TempY2 = 1 THEN
'   IsFight = 3
'   TFlag8 = 0
'END IF

NextStep1:


COLOR STAT, BCLR
LOCATE BOUNDRY, 1

IF Pet = 1 THEN
PRINT "    Your "; Pet.Name$; "'s "; Pet.Att$; " "; BOP2$; " the "; Enemy$; "!"



Ok3.5:

CALL Waita
IF IsFight = 0 THEN EXIT SUB
LOCATE BOUNDRY, 1
COLOR 12, BCLR


'IF TFlag6 = 0 THEN WTill4! = TIMER + dely: TFlag6 = 1
'   TempY2 = DoWait4(WTill4!)
'   IF TempY2 <> 1 THEN IsFight = 3.5: GOTO EndDaSub
'   IF TempY2 = 1 THEN
'   IsFight = 4
'   TFlag6 = 0
'END IF


END IF

NextStepB:




'PRINT TempQQQ

Enemy.Hp = Enemy.Hp - TempQQQ
IF Enemy.Hp < 1 THEN AKILL = 1: GOTO 4567654

TempX = INT(RND * Enemy.Att)
BOP$ = "misses"
TempX = TempX - AHelp
IF TempX < 1 THEN BOP$ = "(via your armour) doesn't hurt": TempX = 0

TempX = TempX - (INT(RND * Player.Ag))
IF TempX < 1 THEN BOP$ = "AGILE": TempX = 0


IF TempX > 0 THEN BOP$ = "hits"
IF TempX > 2 THEN BOP$ = "nails"
IF TempX > 4 THEN BOP$ = "demolishes"
IF TempX > 6 THEN BOP$ = "destroys"
IF TempX > 8 THEN BOP$ = "anihalates"
IF TempX > 10 THEN BOP$ = "disembowls"
IF TempX > 15 THEN BOP$ = "chops up"
IF TempX > 20 THEN BOP$ = "slices up"
IF TempX > 30 THEN BOP$ = "knocks bits of brain out of"






IF Pet = 1 AND Player.Level > 3 THEN
ETEMPY = (Enemy.Att - 5) - Player.Level - 5
IF ETEMPY < 5 THEN ETEMPY = 5
Tempx2 = INT(RND * ETEMPY)
BOP2$ = "misses"
IF Tempx2 > 0 THEN BOP2$ = "hits"
IF Tempx2 > 2 THEN BOP2$ = "nails"
IF Tempx2 > 4 THEN BOP2$ = "demolishes"
IF Tempx2 > 6 THEN BOP2$ = "destroys"
IF Tempx2 > 8 THEN BOP2$ = "anihalates"
IF Tempx2 > 10 THEN BOP2$ = "disembowls"
IF Tempx2 > 15 THEN BOP$ = "chops up"
IF Tempx2 > 20 THEN BOP$ = "slices up"
IF Tempx2 > 30 THEN BOP$ = "knocks bits of brain out of"

END IF


LOCATE BOUNDRY, 1
COLOR 12, BCLR

IF BOP$ = "AGILE" THEN
   COLOR SPEC, BCLR
   xx3 = INT(RND * 3) + 1
   IF xx3 = 1 THEN PRINT "You nimbly backflip out of the way of the attack!"
   IF xx3 = 2 THEN PRINT "You duck beneath the "; Enemy$; "'s "; Enemy.Attack$; "!"
   IF xx3 = 3 THEN PRINT "You execute a perfect cartwheel, narrowly dodging harm!"
GOTO AfterTheThang
END IF

PRINT "The "; Enemy$; "'s "; Enemy.Attack$; " "; BOP$; " you!"
Player.Hp = Player.Hp - TempX

AfterTheThang:

IF Player.Hp < 1 THEN AKILL = 2: GOTO 4567654


Ok4.5:
LOCATE BOUNDRY, 1

CALL Waita
IF IsFight = 0 THEN EXIT SUB

'IF TFlag6 = 0 THEN WTill4! = TIMER + dely: TFlag6 = 1
'   TempY2 = DoWait4(WTill4!)
'   IF TempY2 <> 1 THEN IsFight = 4.5: GOTO EndDaSub
'   IF TempY2 = 1 THEN
'   IsFight = 5
'   TFlag6 = 0
'END IF

NextStep2:





LOCATE BOUNDRY, 1
IF Pet = 1 THEN
COLOR 12, BCLR
PRINT "The "; Enemy$; "'s "; Enemy.Attack$; " "; BOP2$; " your pet "; Pet.Name$; "!"
Pet.MHp = Pet.MHp - Tempx2
IF Pet.MHp < 1 AND Pet = 1 THEN
   COLOR 4, BCLR
   LOCATE BOUNDRY, 1
   PRINT "   The "; Enemy$; " has killed your pet "; Pet.Name$; "!!"
   Pet = 0
   Player.pet$ = "none"
   Pet.MHp = 0
   Pet.Name$ = "none"
 
Ok5.5:

CALL Waita
IF IsFight = 0 THEN EXIT SUB

'IF TFlag6 = 0 THEN WTill4! = TIMER + dely: TFlag6 = 1
'   TempY2 = DoWait4(WTill4!)
'   IF TempY2 <> 1 THEN IsFight = 5.5: GOTO EndDaSub
'   IF TempY2 = 1 THEN
'   IsFight = 6
'   TFlag6 = 0
'   GOTO NextStepC
'END IF

END IF
END IF
NextStepC:




BOP$ = "is in perfect health."

TempX = PerOf(Enemy.Hp, EHP)

IF TempX < 90 THEN BOP$ = "is in great health."
IF TempX < 80 THEN BOP$ = "has minor cuts and bruises."
IF TempX < 70 THEN BOP$ = "has large cuts and bruises."
IF TempX < 60 THEN BOP$ = "is bleeding bad!"
IF TempX < 50 THEN BOP$ = "is in awful shape!"
IF TempX < 40 THEN BOP$ = "is bleeding terribly!"
IF TempX < 30 THEN BOP$ = "is vomiting blood!"
IF TempX < 20 THEN BOP$ = "pales as he nears death!"
IF TempX < 10 THEN BOP$ = "is almost gone!"


LOCATE BOUNDRY, 1
COLOR SPEC, BCLR
PRINT "<Hp"; LTRIM$(STR$(Enemy.Hp)); ">";
PRINT " The "; Enemy$; " "; BOP$


Ok6.5:

CALL Waita
IF IsFight = 0 THEN EXIT SUB

'IF TFlag6 = 0 THEN WTill4! = TIMER + dely: TFlag6 = 1
'   TempY2 = DoWait4(WTill4!)
'   IF TempY2 <> 1 THEN IsFight = 6.5: GOTO EndDaSub
'   IF TempY2 = 1 THEN
'   IsFight = 7
'   TFlag6 = 0
'END IF

NextStep3:


COLOR SPEC, BCLR
LOCATE BOUNDRY, 1
IF Pet = 1 THEN
BOP$ = "is in perfect health."
TempX = PerOf(Pet.MHp, Pet.Xhp)
IF TempX < 90 THEN BOP$ = "is in great health."
IF TempX < 80 THEN BOP$ = "has tiny cuts and bruises."
IF TempX < 70 THEN BOP$ = "has fair sized cuts and bruises."
IF TempX < 60 THEN BOP$ = "is bleeding a bit."
IF TempX < 50 THEN BOP$ = "is not in good shape."
IF TempX < 40 THEN BOP$ = "is bleeding quite a lot!"
IF TempX < 30 THEN BOP$ = "is vomiting blood!"
IF TempX < 20 THEN BOP$ = "pales as he nears death!"
IF TempX < 10 THEN BOP$ = "is almost gone!"

COLOR SPEC, BCLR
PRINT "<Hp"; LTRIM$(STR$(Pet.MHp)); ">";
PRINT " Your pet "; Pet.Name$; " "; BOP$



Ok7.5:

CALL Waita
IF IsFight = 0 THEN EXIT SUB

'IF TFlag6 = 0 THEN WTill4! = TIMER + dely: TFlag6 = 1
'   TempY2 = DoWait4(WTill4!)
'   IF TempY2 <> 1 THEN IsFight = 7.5: GOTO EndDaSub
'   IF TempY2 = 1 THEN
'   IsFight = 8
'   TFlag6 = 0
'   EXIT SUB
'END IF

END IF
NextStepE:
IsFight = 1

TempX = PerOf(Player.Hp, Player.MaxHp)

BOP$ = "are in perfect health."
IF TempX < 90 THEN BOP$ = "are in great health."
IF TempX < 80 THEN BOP$ = "have tiny cuts and bruises."
IF TempX < 70 THEN BOP$ = "have fair sized cuts and bruises."
IF TempX < 60 THEN BOP$ = "are bleeding a bit."
IF TempX < 50 THEN BOP$ = "are not feeling so good..."
IF TempX < 40 THEN BOP$ = "are bleeding a lot, actually."
IF TempX < 35 THEN BOP$ = "are coughing and choking."
IF TempX < 30 THEN BOP$ = "are feeling quite ill!"
IF TempX < 25 THEN BOP$ = "are vomiting!"
IF TempX < 20 THEN BOP$ = "are vomiting blood!"
IF TempX < 15 THEN BOP$ = "pale as you near death..."
IF TempX < 10 THEN BOP$ = "turning a nice shade of red."
IF TempX < 5 THEN BOP$ = "are almost gone.  Better use a spell soon!"
IF TempX < 3 THEN BOP$ = "are just about dead.  I would flee if I were you!"



LOCATE BOUNDRY, 1
COLOR GENC, BCLR
PRINT "<Hp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Hp)));

PRINT " Sp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Sp)));

PRINT ">";
PRINT "You "; BOP$


'CALL Waita

'IF TFlag5 = 0 THEN WTill3! = TIMER + 1: TFlag5 = 1
'   TempY2 = DoWait3(WTill3!)
'   IF TempY2 = 1 THEN
'   TFlag5 = 0
'END IF


PRINT

4567654


COLOR SPEC, BCLR
LOCATE BOUNDRY, 1
IF AKILL = 1 THEN
   
   IF Enemyno = 90 THEN CALL Fini
  
   PRINT "You killed the "; Enemy$; "!"
CALL Waita
   TempX = Words(NounDesc$(Enemyno), ";")
   IF WORD$(5) <> "0" THEN
      TempX = INT(RND * 50) + 1
      IF TempX > 0 THEN
         TempX = INT(RND * 3) + 1
         TempX = TempX + 4
         nottyboy = Words(NounDesc$(VAL(WORD$(TempX))), ";")
         IF WORD$(TempX) = "0" THEN GOTO Isa0dude
         COLOR SPEC, BCLR
         PRINT "As the "; Enemy$; " falls, it drops a ";
         COLOR STAT, BCLR
         PRINT WORD$(1); " "; WORD$(2); "";
         COLOR SPEC, BLCR
         PRINT "!"
         FOR t = 1 TO 100
         IF InRoom(Player.Room, t) = 0 THEN nottyboy = t: EXIT FOR
         NEXT t
        
         InRoom(Player.Room, nottyboy) = VAL(WORD$(TempX))
         CALL Waita
     
      END IF
    END IF
Isa0dude:


COLOR SPEC, BCLR
LOCATE BOUNDRY, 1
   Player.Kill = Player.Kill + 1
   Player.Gold = Player.Gold + Enemy.Gold
   Player.Exp = Player.Exp + Enemy.Exp
   PRINT "You gain"; Enemy.Exp; " experience."
   PRINT "You gain"; Enemy.Gold; " gold."

CALL Waita
   nottyboy = Player.Level
   IF Playerl.Level < 6 THEN nottyboy = nottyboy + 6
   IF Player.Kill > 10 + nottyboy THEN
   Player.Kill = 0
   Player.Scroll = Player.Scroll + 1
   IF Player.Scroll > Player.mScroll THEN Player.Scroll = Player.mScroll: GOTO NoScrollDo
   COLOR SPEC, BCLR
   LOCATE BOUNDRY, 1
   nottyboy = Words(Magic$(Player.Scroll), ";")
   PRINT "You have learned a new spell!  It is the "; WORD$(3); "."
   CALL Waita
   END IF
   



NoScrollDo:
COLOR SPEC, BCLR
LOCATE BOUNDRY, 1

  
   IsFight = 0
   AKILL = 0
   FOR t = 1 TO 50
   IF InRoom(Player.Room, t) = Enemyno THEN InRoom(Player.Room, t) = 0: EXIT FOR
   NEXT t
  
   IF Player.Exp >= Player.Needed THEN
      Player.Needed = Player.Needed + 500
      TempX = INT(RND * 300) + 100
      Player.Needed = Player.Needed + TempX
      Player.Exp = 1
      Player.MaxHp = Player.MaxHp + 4
      Player.Level = Player.Level + 1
      Player.Gold = Player.Gold + 50
      Player.MaxSp = Player.MaxSp + 2
      COLOR SPEC, BCLR
      LOCATE BOUNDRY, 1
      PRINT "You have raised a level!"
    
CALL Waita
     
      COLOR STAT, BCLR
      PRINT "Max Hp raises by 4!"
      PRINT "Gold raises by 50!"
      PRINT "Max spell power raises by 2!"
  
CALL Waita

    END IF
   CALL DoRoom
  
END IF

IF AKILL = 2 THEN
   
   COLOR SPEC, BCLR
   PRINT "You have been killed!  Your gold drops by 1/2, and your EXP drops by 300."
CALL Waita
   LOCATE CAMBAR, CCol%
   COLOR CBTX, CBBA
  
   IsFight = 0
   AKILL = 0
   Ti! = TIMER + 2
   WHILE Ti! > TIMER: WEND

   Player.Gold = INT(Player.Gold / 2)
   Player.Exp = Player.Exp - 300
   IF Player.Exp < 0 THEN Player.Exp = 0
   Player.Hp = Player.MaxHp
   CALL DoRoom
END IF







EndDaSub:
LOCATE CAMBAR, CCol%
COLOR CBTX, CBBA

END SUB

SUB DoMap

LOCATE BOUNDRY, 1
COLOR SPEC, BCLR
PRINT "Map of Tujure:"
COLOR GENC, BCLR
PRINT
PRINT "                    [ 12] - [11]   [16]"
PRINT "                      |      |      |"
PRINT "             [14] - [13] - [ 2]   [ 8] - [15]*"
PRINT "      *        |             |      |"
PRINT "      [ 17] - [ 7] - [ 4] - [ 1] - [ 5] - To the forest ->"
PRINT "                      |      |      |"
PRINT "                   *[ 6]   [ 3]   [ 9]"
PRINT "                             |      |"
PRINT "                    [20] - [18]   [10] - [19]"
PRINT
PRINT " * = Shops"
COLOR STAT, BCLR
PRINT " You're in area:"; Player.Room

COLOR GENC, BCLR
PRINT "<Hp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Hp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxHp)));

PRINT " Exp";

 PRINT LTRIM$(RTRIM$(STR$(Player.Exp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.Needed)));
PRINT " Sp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Sp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxSp)));


PRINT ">"






END SUB

SUB DoNouns

'This assigns the code and description to the InRoom and NounDesc$ vars.
'CODES:
'0 = nothing
'1 - 19 = Simple Nouns.  (Probably won't use most...)
'20 - 29 = City dwelling enemys
'30 - 39 = Forest dwelling enemys
'100-199 = weapons
'200-299 = Armour



'How Inventory nouns work: '999 shows it's a regular noun.
' noun adj;noun name;xxx;999;xxx;NONaplicable class;level;pounds;message(optional)

NounDesc$(1) = "beer;bottle;READ;999;xxx;X;1;1;Brewed cold, to taste bold!  $1.23"
NounDesc$(2) = "wine;bottle;READ;999;xxx;X;1;1;Tujure's best, for you and your love nest.  $1.50"

NounDesc$(3) = "flea;collar;xxx;999;xxx;X;1;1;Flea-B-Gone"











NounDesc$(20) = "CAT;ALLEY;There is a small alley cat here, purring loudly.;An;205;111;3"
NounDesc$(21) = "RAT;STREET;You see a street rat here, gnawing on some food.;A;111;3"
NounDesc$(22) = "DOG;STRAY;You see a stray dog that is scratching itself.;A;205;111;3"
NounDesc$(23) = "ROACH;BIG;You see a big roach.  Ewww!;A;114"
NounDesc$(24) = "DRUNK;CRAZY;A crazy drunk is here, saying something about green beans.;A;1;2;0"
NounDesc$(25) = "CHILD;EVIL;There is an evil child here, playing quietly...;An;0"
NounDesc$(26) = "LADY;OLD;There is an old lady here, trying to cross the street.;An;0"
NounDesc$(27) = "FLY;HUGE;You see a huge fly buzzing around.  Ewww!;A;114"
NounDesc$(28) = "MAN;YOUNG;A young man is here, pretending not to be afraid of you.;A;0"
NounDesc$(29) = "THIEF;SHIFTY; A shifty thief is here, trying to pick your pocket...;A;0"



NounDesc$(30) = "DEER;BROWN;A brown deer is grazing quietly.;A;205;0;0"
NounDesc$(31) = "MOUSE;FIELD;A field mouse is searching for food here.;A;0"
NounDesc$(32) = "BEAR;LARGE;You see a large bear here, who is growling at you!;A;205;0;0"
NounDesc$(33) = "CHILD;LOST;There is a lost child here.;A;0"
NounDesc$(34) = "SNAKE;GREEN;There is a green snake here, slithering around.;A;0"
NounDesc$(35) = "BIRD;SONG;You see a friendly song bird hopping to and fro.;A;0"
NounDesc$(36) = "WIND;STRONG;A strong wind is here, playing with some leaves.;A;0"
NounDesc$(37) = "ANT;TINY;There is a tiny ant here, carrying some food on it's back.;A;0"
NounDesc$(38) = "GRASS;BLADE OF;You see a blade of grass, flapping in the wind.;A;0"
NounDesc$(39) = "WOLF;FIERCE;There is a fierce wolf here, about to attack!;A;0"
NounDesc$(40) = "OGRE;HUGE;A huge ogre is grunting at you.;A;0"
NounDesc$(41) = "FLAME;BRIGHT;A bright flame glows here.;A;0"
NounDesc$(42) = "VINE;FLESH-EATING;You see a flesh-eating vine here!;A;0"
NounDesc$(43) = "FORM;INVISIBLE;You sense an invisible form here.;An;0"
NounDesc$(44) = "SHADOW;EVIL;There is an evil shadow on the trees here.;An;0"
NounDesc$(45) = "SQUIRE;SMALL;A small squire is practicing here.;A;0"
NounDesc$(46) = "KNIGHT;WEAK;A week knight glares at you.;A;0"
NounDesc$(47) = "GUARD;ROYAL;You see a royal guard here, smelling flowers.;A;0"
NounDesc$(48) = "MONK;ANGRY;There is an angry monk here, being angry.;An;0"
NounDesc$(49) = "PRINCE;YOUNG;There is a young prince here.;A;0"

'More monsters
'50-59
NounDesc$(50) = "TOAD;HUGE;A huge toad is grunting at you.;A;0"
NounDesc$(51) = "GYPSY;MUTANT;A mutant gypsy dances here.;A;0"
NounDesc$(52) = "TURTLE;MUTANT;You see a mutant turtle here!;A;0"
NounDesc$(53) = "TOE;SEVERED;You see a severed toe here.;A;0"
NounDesc$(54) = "TREE;EVIL;There is an evil tree here.;An;0"
NounDesc$(55) = "QUEEN;MUTANT;A mutant queen is belching here.;A;0"
NounDesc$(56) = "BEETLE;STRONG;A strong beetle glares at you.;A;0"





'Big Boss in Kelnore
NounDesc$(90) = "BEING;DARK;The dark being glares at you.;The;0"



'Does the stats on the monsters
'NounStat$(xx)= "Hp;attack;gold;exp;attack strength"

NounStat$(20) = "10;scratch;7;100;4"
NounStat$(21) = "5;bite;8;50;2"
NounStat$(22) = "13;bite;7;110;6"
NounStat$(23) = "15;ability to gross you out;9;120;6"
NounStat$(24) = "10;stinky breath;10;100;7"
NounStat$(25) = "15;evil eye;9;110;5"
NounStat$(26) = "14;kick;10;115;8"
NounStat$(27) = "10;slap;7;100;5"
NounStat$(28) = "20;punch;12;130;9"
NounStat$(29) = "21;slap;19;135;8"



NounStat$(30) = "27;bite;17;150;11"
NounStat$(31) = "21;slap;14;130;9"
NounStat$(32) = "35;bite;23;170;16"
NounStat$(33) = "18;bad attitude;20;120;9"
NounStat$(34) = "20;strike;22;163;13"
NounStat$(35) = "26;happy chirpping;20;145;12"
NounStat$(36) = "21;gust;13;115;11"
NounStat$(37) = "30;sting;15;180;15"
NounStat$(38) = "40;slap;29;230;20"
NounStat$(39) = "38;slash;29;225;19"
NounStat$(40) = "43;punch;25;240;22"
NounStat$(41) = "41;burn;33;253;25"
NounStat$(42) = "46;bite;33;270;28"
NounStat$(43) = "48;sucker-punch;30;290;31"
NounStat$(44) = "47;unseen force;32;263;29"
NounStat$(45) = "47;slash;25;280;30"
NounStat$(46) = "49;slash;37;293;35"
NounStat$(47) = "52;whack;39;299;39"
NounStat$(48) = "55;stab;40;310;42"
NounStat$(49) = "57;kick;45;313;45"

NounStat$(50) = "60;lick;48;340;49"
NounStat$(51) = "62;shifty feet;50;353;51"
NounStat$(52) = "63;bite;52;370;58"
NounStat$(53) = "65;sucker-punch;55;390;61"
NounStat$(54) = "66;whack;59;393;63"
NounStat$(55) = "69;slash;65;410;68"
NounStat$(56) = "72;slash;73;423;70"


NounStat$(90) = "200;piercing eyes;150;1000;80"






'weap adj;weap noun;action;damage;$;NONaplicable class;level;pounds

NounDesc$(100) = "Practice;staff;shock;8;50;BMN;1;3"
NounDesc$(101) = "Practice;mace;whack;17;50;PSMN;1;6"
NounDesc$(102) = "Practice;knife;slash;8;50;X;1;5"
NounDesc$(103) = "Practice;sword;slash;8;50;S;1;3"
NounDesc$(104) = "Practice;dagger;pierce;8;45;B;1;2"
NounDesc$(105) = "Short;sword;slash;9;100;S;1;10"
NounDesc$(106) = "Iron;mace;bash;13;200;S;3;10"
NounDesc$(107) = "Leather;whip;lash;13;200;X;3;3"
NounDesc$(108) = "Devil's;dagger;pierce;50;800;B;15;4"
NounDesc$(109) = "Thorned;whip;lash;15;400;B;3;3"
NounDesc$(110) = "Hellfire;sword;slash;30;600;X;9;5"

NounDesc$(111) = "Silver;claw;slash;10;45;X;1;1"
NounDesc$(112) = "Brown;cain;whack;9;25;X;1;1"
NounDesc$(113) = "Silver;horn;stab;15;50;X;1;1"
NounDesc$(114) = "Sharp;antenna;pierce;15;45;X;1;1"



'Armour:

NounDesc$(200) = "brown;robe;a brown robe;3;35;X;1;3"
NounDesc$(201) = "leather;shield;a shield of leather;2;35;X;1;3"
NounDesc$(202) = "leather;shield;a leather shield;2;50;X;1;4"
NounDesc$(203) = "iron;shield;a shield of iron;14;50;X;1;4"
NounDesc$(204) = "simple;cloak;a cloak of protection;5;50;X;1;3"


NounDesc$(205) = "fur;coat;a fur coat;4;35;X;1;3"



CALL PlaceNouns
END SUB

SUB DoNPC
RANDOMIZE TIMER



'Select an NPC
SelNPC:
Temp = INT(RND * NPCn) + 1
IF NPC$(Temp) = "" THEN GOTO SelNPC
NPCno = Temp
NPCt = NPCr(NPCno)





'Do what with NPC?
TempX = Words(NPC$(NPCno), ";")
NPCde$ = WORD$(2)
NPCna$ = WORD$(1)


Temp = INT(RND * 6) + 1
LOCATE BOUNDRY, 1
COLOR STAT, BCLR

Tempxx = 0
SELECT CASE Temp
   CASE 1, 2    'Move
   IF NPCf(NPCno) <> 0 THEN GOTO Exitit
MovNPC:
   Tempxx = Tempxx + 1
   IF Tempxx > 50 THEN PRINT "No NPC move for:"; NPCna$: EXIT SUB

   Temped = INT(RND * 4) + 1
   IF Room.N(NPCt) = 0 AND Temped = 1 THEN GOTO MovNPC 'Go north?
   IF Room.S(NPCt) = 0 AND Temped = 2 THEN GOTO MovNPC 'Go south?
   IF Room.W(NPCt) = 0 AND Temped = 3 THEN GOTO MovNPC 'Go west?
   IF Room.E(NPCt) = 0 AND Temped = 4 THEN GOTO MovNPC 'Go east?
   IF Temped = 1 THEN
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", goes north."
      NPCr(NPCno) = Room.N(NPCt)
      NPCt = NPCr(NPCno)
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", enters from the south."
   END IF

   IF Temped = 2 THEN
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", goes south."
      NPCr(NPCno) = Room.S(NPCt)
      NPCt = NPCr(NPCno)
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", enters from the north."
   END IF

   IF Temped = 3 THEN
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", goes west."
      NPCr(NPCno) = Room.W(NPCt)
      NPCt = NPCr(NPCno)
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", enters from the east."
   END IF

   IF Temped = 4 THEN
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", goes east."
      NPCr(NPCno) = Room.E(NPCt)
      NPCt = NPCr(NPCno)
      IF Player.Room = NPCt AND IsSleep = 0 THEN PRINT NPCde$; ", "; NPCna$; ", enters from the west."
   END IF


CASE 3, 4, 5, 6'Attack monster
    
    IF NPCf(NPCno) <> 0 THEN
    Temp = Words(NounDesc$(NPCf(NPCno)), ";")
    LOCATE BOUNDRY, 1
    COLOR SPEC, BCLR
    WORD$(1) = LCASE$(WORD$(1))
    WORD$(2) = LCASE$(WORD$(2))
    WORD$(4) = LCASE$(WORD$(4))
   
    IF Player.Room = NPCt THEN PRINT NPCna$; ", "; LCASE$(NPCde$); ", just killed "; WORD$(4); " "; WORD$(2); " "; WORD$(1); "!"
    NPCf(NPCno) = 0
    GOTO Exitit
    END IF

    IF NPCf(NPCno) = 0 THEN
       ttt = 0
       KKK = 0
       FOR t = 1 TO 50
       IF InRoom(NPCt, t) <> 0 THEN KKK = InRoom(NPCt, t): ttt = t: EXIT FOR
       NEXT t
       IF KKK = 0 THEN GOTO MovNPC
       IF KKK > 99 THEN GOTO MovNPC
       IF KKK < 20 THEN GOTO MovNPC
       IF KKK = 90 THEN GOTO MovNPC
      
       IF Player.Room = NPCt AND IsFight <> 0 THEN GOTO Exitit

       Temp = Words(NounDesc$(KKK), ";")
       WORD$(1) = LCASE$(WORD$(1))
       WORD$(2) = LCASE$(WORD$(2))
       WORD$(4) = LCASE$(WORD$(4))
       LOCATE BOUNDRY, 1
       COLOR SPEC, BCLR
      
       IF Player.Room = NPCt THEN PRINT NPCna$; ", "; LCASE$(NPCde$); ", attacks "; WORD$(4); " "; WORD$(2); " "; WORD$(1); "!"
       NPCf(NPCno) = KKK
       InRoom(NPCt, ttt) = 0
       GOTO Exitit
       END IF

END SELECT



Exitit:
END SUB

SUB DoRandom
RANDOMIZE TIMER

'Do Hp restore
TTYUU = 10
TTYMM = 5
TempZ = INT(RND * 2) + 1
TempZ = TempZ + Player.HpRate
IF IsSleep = 1 THEN TempZ = TempZ + 3: TTYUU = 5: TTYMM = 3


IF TFlag3 = 0 THEN WTill! = TIMER + TTYUU: TFlag3 = 1
TempYq = DoWait(WTill!)

IF TempYq = 1 THEN
Player.Hp = Player.Hp + TempZ
IF Armcount <> 0 THEN
Armcount = Armcount - 1
  IF Armcount = 0 THEN
  COLOR STAT, BCLR
  LOCATE BOUNDRY, 1
  PRINT "The spell wears off, and your armour returns to normal."
  END IF
END IF


IF IsSleep = 1 THEN Player.Sp = Player.Sp + 2
Player.Sp = Player.Sp + 1 + Player.SpRate
 IF Player.Sp > Player.MaxSp THEN Player.Sp = Player.MaxSp
IF Player.Hp > Player.MaxHp THEN Player.Hp = Player.MaxHp
TFlag3 = 0
END IF





IF TFlag7 = 0 THEN WTill6! = TIMER + 7: TFlag7 = 1
TempYq6 = DoWait6(WTill6!)
IF TempYq6 = 1 THEN
CALL DoNPC
TFlag7 = 0
END IF









'Do when monsters enter the room


TempX = INT(RND * 25) + 1
TempZ = INT(RND * 4) + 1

89087



Tpl = INT(RND * R) + 1

IF Tpl < 21 THEN Tp1 = 29: Tp2 = 20
IF Tpl < 72 AND Tpl > 20 THEN Tp1 = 49: Tp2 = 30   'Forest
IF Tpl < 88 AND Tpl > 71 THEN Tp1 = 49: Tp2 = 30   'Kelnore

Tx = Tpl
'Tx = INT(RND * 20) + 1
Tz = INT(RND * 50) + 1
IF InRoom(Tx, Tz) < 19 THEN EXIT SUB'InRoom(1, 1) = 20'GOTO 89087

TDir$ = "a hole in the ground"
IF TempZ = 1 AND Room.N(Tx) <> 0 THEN TDir$ = "the north"
IF TempZ = 2 AND Room.S(Tx) <> 0 THEN TDir$ = "the south"
IF TempZ = 3 AND Room.E(Tx) <> 0 THEN TDir$ = "the east"
IF TempZ = 4 AND Room.W(Tx) <> 0 THEN TDir$ = "the west"
          

Crap = Words(NounDesc$(InRoom(Tx, Tz)), ";")
Enemy$ = LCASE$(WORD$(2)) + " " + LCASE$(WORD$(1))
TU$ = WORD$(4)


Enemy2$ = "creature of some sort"


89187
Tempityo = INT(RND * 3) + 1
IF Tempityo = 1 OR Tempityo = 3 THEN Tx2 = Tpl
IF Tempityo = 2 THEN Tx2 = INT(RND * 20) + 1: Tp2 = 2: Tp1 = 29
Tz2 = INT(RND * 50) + 1
IF InRoom(Tx2, Tz2) <> 0 THEN GOTO 89187

44322
Enemyno = INT(RND * 50) + 1
IF Enemyno < Tp2 OR Enemyno > Tp1 THEN GOTO 44322 'an in town animal

Crap = Words(NounDesc$(Enemyno), ";")
Enemy2$ = LCASE$(WORD$(2)) + " " + LCASE$(WORD$(1))


'Tx = Player.Room
'Tx2 = Tx

Enemy2$ = LTRIM$(RTRIM$(Enemy2$))
IF Enemy2$ = "" THEN GOTO 44322

TU2$ = WORD$(4)



IF IsSleep = 1 THEN TTYMM = 4

IF TFlag4 = 0 THEN WTill2! = TIMER + TTYMM: TFlag4 = 1
TempY = DoWait2(WTill2!)
    IF TempY = 1 THEN
      


    SELECT CASE TempX

    CASE 4, 8, 12
         IF Player.Room = Tx THEN
         COLOR SPEC, BCLR
         LOCATE BOUNDRY, 1
         PRINT TU$; " "; Enemy$; " just commited suiside!"
         InRoom(Tx, Tz) = 0
         END IF
         InRoom(Tx, Tz) = 0
    CASE 1, 3, 5, 6, 7, 9, 10, 11, 13, 15, 20, 21, 22, 25
        
         'Debug:
         'LOCATE BOUNDRY, 1
         'COLOR 2, 0
         'PRINT "A "; Enemy2$; " entered room"; STR$(Tx2)
         'Fini
         
         IF Player.Room = Tx2 AND Enemy2$ <> " " THEN
         COLOR SPEC, BCLR
         LOCATE BOUNDRY, 1
         PRINT TU2$; " "; Enemy2$; " enters from "; TDir$; "."
         InRoom(Tx2, Tz2) = Enemyno
         END IF
         InRoom(Tx2, Tz2) = Enemyno
   
    END SELECT
    TFlag4 = 0
   
    END IF






LOCATE CAMBAR, CCol%
COLOR CBTX, CBBA

END SUB

SUB DoRoom
Endy$ = "."
LOCATE BOUNDRY, 1
PRINT
COLOR SPEC, BCLR
PRINT "You can go:  ";

COLOR STAT, BCLR

'IF LEN(Room.Des$(Player.Room)) > 80 THEN
'        WordWrap Room.Des$(Player.Room), 1, I, BOUNDRY

IF Room.W(Player.Room) <> 0 THEN
   PRINT "  W -";
ELSE PRINT "    -";
END IF

IF Room.N(Player.Room) <> 0 THEN
   PRINT " N/";
ELSE PRINT "  /";
END IF

IF Room.S(Player.Room) <> 0 THEN
   PRINT "S -";
ELSE PRINT "  -";
END IF

IF Room.E(Player.Room) <> 0 THEN
   PRINT " E";
ELSE PRINT "  ";
END IF



COLOR SPEC, BCLR
PRINT "      Area#:"; LTRIM$(RTRIM$(STR$(Player.Room)))
COLOR GENC, BCLR
PRINT Room.Des$(Player.Room)
'END IF

LOCATE BOUNDRY, 1
COLOR STAT, BCLR
TempX = Words(Player.pet$, ";")
IF TempX > 1 THEN
   PRINT "<Hp"; LTRIM$(STR$(Pet.MHp)); "  Str"; LTRIM$(WORD$(5)); ">";
   PRINT " " + WORD$(3)
END IF

LOCATE BOUNDRY, 1
COLOR SPEC, BCLR
FOR t = 1 TO 50
IF NPCr(t) = Player.Room THEN

    IF NPCf(t) <> 0 THEN
    Temp = Words(NounDesc$(NPCf(t)), ";")
    LOCATE BOUNDRY, 1
    COLOR SPEC, BCLR
    WORD$(1) = LCASE$(WORD$(1))
    WORD$(2) = LCASE$(WORD$(2))
    WORD$(4) = LCASE$(WORD$(4))
    Endy$ = ", fighting " + WORD$(4) + " " + WORD$(2) + " " + WORD$(1) + "!"
    END IF

TempX = Words(NPC$(t), ";")
COLOR SPEC, BCLR
IF TempX > 1 THEN PRINT ">>"; : COLOR YCOM, BCLR: PRINT WORD$(1); ", "; LCASE$(WORD$(2)); ", is here"; Endy$
Endy$ = "."
END IF
NEXT t


LOCATE BOUNDRY, 1
COLOR SPEC, BCLR
FOR t = 1 TO 50
IF InRoom(Player.Room, t) <> 0 THEN
     Temp = Words(NounDesc$(InRoom(Player.Room, t)), ";")
    
     IF VAL(WORD$(4)) <> 0 THEN
        PRINT "A "; WORD$(1); " "; WORD$(2); " has been left here."
     ELSE PRINT "    "; WORD$(3)
     END IF

END IF
NEXT t
PRINT


COLOR GENC, BCLR
PRINT "<Hp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Hp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxHp)));

PRINT " Exp";

 PRINT LTRIM$(RTRIM$(STR$(Player.Exp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.Needed)));
PRINT " Sp";
 PRINT LTRIM$(RTRIM$(STR$(Player.Sp)));
PRINT "/";
 PRINT LTRIM$(RTRIM$(STR$(Player.MaxSp)));


PRINT ">"


END SUB

SUB DoSpell
      COLOR STAT, BCLR
      PRINT "You have studied the scrolls of the following:"
      COLOR SPEC, BCLR
      FOR t = 1 TO Player.Scroll
      nottyboy = Words(Magic$(t), ";")
      PRINT "  The " + WORD$(3) + ".  It costs "; WORD$(4); " Sp.  " + WORD$(7)
      NEXT t
END SUB

FUNCTION DoWait (WTill!)
TempW! = TIMER
IF TempW! > WTill! THEN DoWait = 1
END FUNCTION

FUNCTION DoWait2 (WTill2!)
TempW! = TIMER
IF TempW! > WTill2! THEN DoWait2 = 1
END FUNCTION

FUNCTION DoWait3 (WTill3!)
TempW! = TIMER
IF TempW! > WTill3! THEN DoWait3 = 1

END FUNCTION

FUNCTION DoWait4 (WTill4!)

TempW! = TIMER
IF TempW! > WTill4! THEN DoWait4 = 1

END FUNCTION

FUNCTION DoWait6 (WTill6!)

TempW! = TIMER
IF TempW! > WTill6! THEN DoWait6 = 1

END FUNCTION

FUNCTION DoWait7 (WTill7!)
TempW! = TIMER
IF TempW! > WTill7! THEN DoWait7 = 1

END FUNCTION

SUB Fini
CLS
TDely = Dely
Dely = 2

LOCATE BOUNDRY, 1
COLOR SPEC, BCLR
PRINT
PRINT "The Dark Being, in a last attempt effort, tryes to lunge toward you."
CALL Waita
PRINT
CALL Waita
COLOR 14, BCLR
PRINT "You jump to the left, and attack it from behind."
CALL Waita
PRINT
CALL Waita
COLOR SPEC, BCLR
PRINT "It's back snaps, and fragments of bone scatter through Kelnore."
CALL Waita
PRINT
CALL Waita
COLOR SPEC, BCLR
PRINT "As it dies, the mutants morph into humans, the monsters vanish, and the"
PRINT "darkness is lifted from Kelnore, the forest, and Tujure."
CALL Waita
PRINT
CALL Waita
COLOR STAT, BCLR
PRINT "You have won the battle!  You are the champion!  You are the victor of..."
CALL Waita
COLOR SPEC, BCLR
PRINT "Tujure: The Legend of Kelnore!"
PRINT
PRINT "Press any key to end the game."
SLEEP
x$ = INKEY$

KILL "data.dat"

PRINT
PRINT
PRINT "Thankyou for playing this game!  "
PRINT "rjp1@bayou.com"
PRINT "http://www.bayou.com/~rjp1/qbasic.html"
PRINT "-- Watch for a Tujure 2!"

END


Dely = TDely
END SUB

SUB HexINV (k$)


IF k$ = "1" THEN GOTO Encode1
IF k$ = "2" THEN GOTO Decode1
'PRINT "Quit"
'END


Encode1:
COLOR 7, 0
PRINT
Inp$ = "inv.dat"
IF Inp$ = "" THEN END
'INPUT " Output file: ", Out$
'IF Out$ = "" THEN END

OPEN Inp$ FOR BINARY AS #1
OPEN "tt.z" FOR OUTPUT AS #2

FOR I = LEN(Inp$) TO 1 STEP -1        'Remove path
  IF MID$(Inp$, I, 1) = "Ö" THEN
    Inp$ = MID$(Inp$, I + 1, 255)
  END IF
NEXT

Inp$ = UCASE$(Inp$)
Inp$ = LEFT$(Inp$, 12)
Inp$ = Inp$ + STRING$(12 - LEN(Inp$), "<")

'PRINT " Encoding..."
'PRINT " - Writing header..."
Hdr.Verify = "Code"                  'Write header
Hdr.Filename = Inp$

PRINT #2, Hdr.Verify;
PRINT #2, Hdr.Filename

'PRINT " - Encoding"; LOF(1); "bytes..."
Col = 0                              'Encode
Avg& = 0
lines& = 0
FOR I& = 1 TO LOF(1)
  GET #1, , Byte
  Avg& = Avg& + ASC(Byte)
  Hx$ = HEX$(ASC(Byte))

  IF LEN(Hx$) = 1 THEN Hx$ = "0" + Hx$
  PRINT #2, Hx$;
  Col = Col + 2
  IF Col = ColLimit THEN
    Col = 0
    Chk$ = HEX$(Avg& MOD 255)
    IF LEN(Chk$) = 1 THEN Chk$ = "0" + Chk$
    PRINT #2, "::"; Chk$
    lines& = lines& + 1
    Avg& = 0
  END IF
NEXT
PRINT #2, "XX"


'PRINT " - Output file size: "; LOF(2); "bytes -";
'PRINT lines&; "lines"

CLOSE #1
CLOSE #2

Inp$ = LEFT$(Inp$, LEN(Inp$) - 3)
'KILL Inp$
KILL "inv.dat"
NAME "tt.z" AS "inv.dat"
'NAME "t.z" AS Inp$
'PRINT "Hi willy!"

EXIT SUB

Decode1:
COLOR 7, 0
PRINT

F = FREEFILE
OPEN "tt.z" FOR OUTPUT AS F
CLOSE F

Inp$ = "inv.dat"

'PRINT " Decoding..."
'PRINT " - Seeking..."

OPEN Inp$ FOR BINARY AS #1
IF LOF(1) = 0 THEN                   'Check if file
'  PRINT " File not found!"           'exists
  CLOSE
  KILL Inp$
  EXIT SUB
END IF

Start& = -1
FOR I& = 1 TO LOF(1)                 'Seek start of
  GET #1, I&, SeekS                  'file data
  IF SeekS = "Code" THEN
    Start& = I&
    EXIT FOR
  END IF
NEXT
IF Start& = -1 THEN
'  PRINT " - File data not found!"
  END
END IF
                                     'Read header
'PRINT " - Reading header..."
SEEK #1, Start&

GET #1, , Hdr
IF Hdr.Verify <> "Code" THEN
'  PRINT " First 4 bytes must be Code"
  CLOSE
  END
END IF

Out$ = LEFT$(Hdr.Filename, INSTR(Hdr.Filename, "<") - 1)
Out$ = "inv.dat"
F = FREEFILE
OPEN "tt.z" FOR OUTPUT AS F
CLOSE F
OPEN "tt.z" FOR BINARY AS #2
'PRINT " - Writing output file "; Out$; "..."

IF LOF(2) > 0 THEN
'  PRINT " Output file exists!"
  CLOSE
  END
END IF

Col = 0                              'Decode
Avg& = 0
FOR I& = 1 TO LOF(1)
  DO
    GET #1, , Hex
    IF Hex = "XX" THEN EXIT FOR
    IF Hex = "::" THEN
      GET #1, , Hex
      IF VAL("&H" + Hex) <> Avg& MOD 255 THEN
'        COLOR 12
'        PRINT " Checksum error at"; SEEK(1)
'        PRINT VAL("&H" + Hex); "<>"; Avg& MOD 255
'        COLOR 7
        CLOSE
        END
      END IF
      Avg& = 0
      Hex = CHR$(13) + CHR$(0)
    END IF
  LOOP UNTIL INSTR(Hex, CHR$(13)) = 0
  Byte = CHR$(VAL("&H" + Hex))
  Avg& = Avg& + ASC(Byte)
  PUT #2, , Byte
NEXT


'PRINT " - Input file size: ", LOF(1)
'PRINT " - Output file size: ", LOF(2)

CLOSE #1
CLOSE #2

KILL "inv.dat"
NAME "tt.z" AS "inv.dat"

EXIT SUB





END SUB

SUB Hexit (k$)




'CLS
'COLOR 15, 4
'PRINT "                    ";
'PRINT "Hex Encoder/Decoder for QBasic - Sami Ky";
'PRINT CHR$(148); "stil";
'PRINT CHR$(132);
'PRINT "              "

'VIEW PRINT 2 TO 25
'PRINT
'COLOR 10, 0
'PRINT "          1 - Encode"
'PRINT "          2 - Decode"
'COLOR 2
'PRINT
'PRINT " Choose one: ";
'k$ = INPUT$(1)
'COLOR 9
'k$ = LTRIM$(RTRIM$(COMMAND$))

IF k$ = "1" THEN GOTO Encode
IF k$ = "2" THEN GOTO Decode
'PRINT "Quit"
'END


Encode:
COLOR 7, 0
PRINT
Inp$ = "data.dat"
IF Inp$ = "" THEN END
'INPUT " Output file: ", Out$
'IF Out$ = "" THEN END

OPEN Inp$ FOR BINARY AS #1
OPEN "t.z" FOR OUTPUT AS #2

FOR I = LEN(Inp$) TO 1 STEP -1        'Remove path
  IF MID$(Inp$, I, 1) = "Ö" THEN
    Inp$ = MID$(Inp$, I + 1, 255)
  END IF
NEXT

Inp$ = UCASE$(Inp$)
Inp$ = LEFT$(Inp$, 12)
Inp$ = Inp$ + STRING$(12 - LEN(Inp$), "<")

'PRINT " Encoding..."
'PRINT " - Writing header..."
Hdr.Verify = "Code"                  'Write header
Hdr.Filename = Inp$

PRINT #2, Hdr.Verify;
PRINT #2, Hdr.Filename

'PRINT " - Encoding"; LOF(1); "bytes..."
Col = 0                              'Encode
Avg& = 0
lines& = 0
FOR I& = 1 TO LOF(1)
  GET #1, , Byte
  Avg& = Avg& + ASC(Byte)
  Hx$ = HEX$(ASC(Byte))

  IF LEN(Hx$) = 1 THEN Hx$ = "0" + Hx$
  PRINT #2, Hx$;
  Col = Col + 2
  IF Col = ColLimit THEN
    Col = 0
    Chk$ = HEX$(Avg& MOD 255)
    IF LEN(Chk$) = 1 THEN Chk$ = "0" + Chk$
    PRINT #2, "::"; Chk$
    lines& = lines& + 1
    Avg& = 0
  END IF
NEXT
PRINT #2, "XX"


'PRINT " - Output file size: "; LOF(2); "bytes -";
'PRINT lines&; "lines"

CLOSE #1
CLOSE #2

Inp$ = LEFT$(Inp$, LEN(Inp$) - 3)
'KILL Inp$
KILL "data.dat"
NAME "t.z" AS "data.dat"
'NAME "t.z" AS Inp$
'PRINT "Hi willy!"

EXIT SUB

Decode:
COLOR 7, 0
PRINT

F = FREEFILE
OPEN "t.z" FOR OUTPUT AS F
CLOSE F

Inp$ = "data.dat"

'PRINT " Decoding..."
'PRINT " - Seeking..."

OPEN Inp$ FOR BINARY AS #1
IF LOF(1) = 0 THEN                   'Check if file
'  PRINT " File not found!"           'exists
  CLOSE
  KILL Inp$
  EXIT SUB
END IF

Start& = -1
FOR I& = 1 TO LOF(1)                 'Seek start of
  GET #1, I&, SeekS                  'file data
  IF SeekS = "Code" THEN
    Start& = I&
    EXIT FOR
  END IF
NEXT
IF Start& = -1 THEN
'  PRINT " - File data not found!"
  END
END IF
                                     'Read header
'PRINT " - Reading header..."
SEEK #1, Start&

GET #1, , Hdr
IF Hdr.Verify <> "Code" THEN
'  PRINT " First 4 bytes must be Code"
  CLOSE
  END
END IF

Out$ = LEFT$(Hdr.Filename, INSTR(Hdr.Filename, "<") - 1)
F = FREEFILE
OPEN "t.z" FOR OUTPUT AS F
CLOSE F
OPEN "t.z" FOR BINARY AS #2
'PRINT " - Writing output file "; Out$; "..."

IF LOF(2) > 0 THEN
'  PRINT " Output file exists!"
  CLOSE
  END
END IF

Col = 0                              'Decode
Avg& = 0
FOR I& = 1 TO LOF(1)
  DO
    GET #1, , Hex
    IF Hex = "XX" THEN EXIT FOR
    IF Hex = "::" THEN
      GET #1, , Hex
      IF VAL("&H" + Hex) <> Avg& MOD 255 THEN
'        COLOR 12
'        PRINT " Checksum error at"; SEEK(1)
'        PRINT VAL("&H" + Hex); "<>"; Avg& MOD 255
'        COLOR 7
        CLOSE
        END
      END IF
      Avg& = 0
      Hex = CHR$(13) + CHR$(0)
    END IF
  LOOP UNTIL INSTR(Hex, CHR$(13)) = 0
  Byte = CHR$(VAL("&H" + Hex))
  Avg& = Avg& + ASC(Byte)
  PUT #2, , Byte
NEXT


'PRINT " - Input file size: ", LOF(1)
'PRINT " - Output file size: ", LOF(2)

CLOSE #1
CLOSE #2

KILL Out$
NAME "t.z" AS Out$

EXIT SUB


END SUB

FUNCTION InputLine$ (Text$, ViewWidth%, KeyCode%)

COLOR CBTX, CBBA

IF Waitam = 1 THEN Waitamt! = TIMER + Dely



MaxLnLen% = 128
LCol% = POS(0)
RCol% = LCol% + ViewWidth% - 1
View$ = SPACE$(ViewWidth%)
work$ = LEFT$(Text$, MaxLnLen%)
LnLen% = LEN(work$)
CCol% = Lesser(LCol% + LnLen%, RCol%)
AChar% = LnLen% + 1

'LOCATE , , 0, CursSize% - 1, CursSize%
Insert% = true
DO
 
  GENC = 9

  IF Player.Hp < 50 THEN GENC = 7
  IF Player.Hp < 40 THEN GENC = 14
  IF Player.Hp < 30 THEN GENC = 12
  IF Player.Hp < 20 THEN GENC = 4
 
  TempX = PerOf(Player.Hp, Player.MaxHp)
  IF TempX > 90 THEN GENC = 9
 
  


 
 
  LOCATE , LCol%
  LSET View$ = MID$(work$, AChar% - (CCol% - LCol%), ViewWidth%)
  PRINT View$;
  LOCATE , CCol%, 1
  LnLen% = LEN(work$)
  DO
   
   
    DO: Ky$ = INKEY$
   
   IF Waitam = 1 THEN
      IF TIMER > Waitamt! THEN KeyCode% = 999: EXIT FUNCTION
   END IF
   IF Waitam = 1 THEN GOTO Loopy


  
   IF IsFight >= 1 AND AKILL = 0 AND TFlag5 = 0 THEN
       CALL DoKill
   END IF

   IF TFlag5 = 0 THEN WTill3! = TIMER + Dely: TFlag5 = 1
   TempY2 = DoWait3(WTill3!)
 
   IF TempY2 = 1 THEN
   TFlag5 = 0
   END IF
  
  
  
   IF TFlag6 = 0 THEN WTill4! = TIMER + Dely: TFlag6 = 1
   TempY2 = DoWait4(WTill4!)
   IF TempY2 = 1 THEN
   TFlag6 = 0
   IF IsFight > 1 THEN
   IsFight = INT(IsFight + 1)
   IF IsFight > 8 THEN IsFight = 1
   END IF
   END IF


   IF TFlag8 = 0 THEN WTill7! = TIMER + Dely: TFlag8 = 1
   TempY2 = DoWait7(WTill7!)
   IF TempY2 = 1 THEN
   TFlag8 = 0
   IF IsFight > 1 THEN
   IsFight = INT(IsFight + 1)
   IF IsFight > 8 THEN IsFight = 1
   END IF
   END IF


   IF IsFight > 1 AND AKILL = 0 AND TFlag6 = 0 THEN
       CALL DoKill
   END IF



   IF IsFight = 0 THEN CALL DoRandom
   
 
Loopy:
LOCATE CAMBAR, CCol%
COLOR CBTX, CBBA
LOOP UNTIL LEN(Ky$)
   



    KeyCode% = ASC(Ky$): IF KeyCode% = 0 THEN KeyCode% = -ASC(MID$(Ky$, 2))
  LOOP UNTIL KeyCode% <> BadKey%: BadKey% = 0
  LOCATE , , 0
  SELECT CASE KeyCode%
    CASE BkSpc
         IF AChar% = 1 THEN
           BEEP: BadKey% = KeyCode%
         ELSE
           IF AChar% <= LnLen% + 1 THEN
                work$ = LEFT$(work$, AChar% - 2) + MID$(work$, AChar%)
           END IF
           AChar% = AChar% - 1
           IF CCol% <> LCol% THEN CCol% = CCol% - 1
         END IF
     
    CASE ENTER
         Text$ = work$
         EXIT DO
    CASE ESC
         EXIT DO
    CASE 32 TO 255      ' letter keys
         IF AChar% > MaxLnLen% THEN
           BEEP: BadKey% = KeyCode%
         ELSE
           IF AChar% <= LnLen% THEN
                IF Insert% THEN
                  IF LnLen% = MaxLnLen% THEN
                    BEEP: BadKey% = KeyCode%
                  ELSE
                    work$ = LEFT$(work$, AChar% - 1) + Ky$ + MID$(work$, AChar%)
                    AChar% = AChar% + 1
                    IF CCol% <> RCol% THEN CCol% = CCol% + 1
                  END IF
                ELSE 'IF NOT Insert% THEN (in overstrike mode)
                  MID$(work$, AChar%, 1) = Ky$
                  AChar% = AChar% + 1
                  IF CCol% <> RCol% THEN CCol% = CCol% + 1
                END IF
           ELSE 'IF AChar% > LnLen% THEN
                work$ = work$ + SPACE$(AChar% - LnLen% - 1) + Ky$
                AChar% = AChar% + 1
                IF CCol% <> RCol% THEN CCol% = CCol% + 1
           END IF
         END IF
     
    CASE LArrow
         IF AChar% = 1 THEN
           BEEP: BadKey% = KeyCode%
         ELSE 'IF AChar% > 1 THEN
           AChar% = AChar% - 1
           IF CCol% <> LCol% THEN CCol% = CCol% - 1
         END IF
    CASE RArrow
         IF AChar% > MaxLnLen% THEN
           BEEP: BadKey% = KeyCode%
         ELSE
           AChar% = AChar% + 1
           IF CCol% <> RCol% THEN CCol% = CCol% + 1
         END IF
    CASE HomeKey
         AChar% = 1
         CCol% = LCol%
    CASE UpArrow
         work$ = LCMD$
    CASE DnArrow
         work$ = ""
    CASE EndKey
         AChar% = LnLen% + 1
         CCol% = Lesser(LCol% + LnLen%, RCol%)
     
    CASE InsertKey
         Insert% = NOT Insert%
         IF Insert% THEN
         LOCATE , , , CursSize% - 1, CursSize%
         ELSE
         LOCATE , , , CursSize% / 2, CursSize%
         END IF
     
    CASE DeleteKey
         IF AChar% <= LnLen% THEN
           work$ = LEFT$(work$, AChar% - 1) + MID$(work$, AChar% + 1)
         END IF
     
    CASE ELSE
         BEEP: BadKey% = KeyCode%
  END SELECT
 LOOP
 LOCATE , , , CursSize% - 1, CursSize%

InputLine$ = Text$

END FUNCTION

 FUNCTION Lesser% (Var1%, Var2%) STATIC


 ' This simply finds the lesser or 2 variables.

 Lesser% = Var1%: IF Var2% < Var1% THEN Lesser% = Var2%
END FUNCTION

FUNCTION PerOf (N1, N2)

'5 = x*10      x=.5;  x * 100 is 50
'devide both sides by 10....

TempX = N1 / N2
TempX = TempX * 100

PerOf = TempX
END FUNCTION

SUB PlaceNouns
RANDOMIZE TIMER


InRoom(87, 1) = 90
InRoom(1, 1) = 1



FOR t = 1 TO 25

887766                      'find a room in TOWN
TempX = INT(RND * R) + 1
IF TempX > 20 THEN GOTO 887766


  FOR Temp = 1 TO 100
  IF InRoom(TempX, Temp) = 0 THEN TEMPR = Temp: EXIT FOR
  NEXT Temp


32123        'Find an in TOWN monster
  TempY = INT(RND * 50) + 1
IF TempY > 29 OR TempY < 19 THEN GOTO 32123
IF NounDesc$(TempY) = "" THEN GOTO 32123


InRoom(TempX, TEMPR) = TempY

NEXT t



FOR t = 1 TO 50
667788                        ' Find a room out of TOWN
  TempX = INT(RND * R) + 1
IF TempX < 21 THEN GOTO 667788

  FOR Temp = 1 TO 100
  IF InRoom(TempX, Temp) = 0 THEN TEMPR = Temp: EXIT FOR
  NEXT Temp
321230                              'Find an out of town monster
  TempY = INT(RND * 50) + 1
IF TempY < 30 THEN GOTO 321230
IF NounDesc$(TempY) = "" THEN GOTO 321230


InRoom(TempX, TEMPR) = TempY

NEXT t



FOR t = 1 TO 10
6677881                        ' Find a room in Kelnore
  TempX = INT(RND * R) + 1
IF TempX < 72 THEN GOTO 6677881

  FOR Temp = 1 TO 100
  IF InRoom(TempX, Temp) = 0 THEN TEMPR = Temp: EXIT FOR
  NEXT Temp
3212301                       'Find a Kelnore  monster
  TempY = INT(RND * 56) + 1
IF TempY < 50 THEN GOTO 3212301
IF NounDesc$(TempY) = "" THEN GOTO 3212301
IF TempY >= 90 THEN GOTO 3212301

InRoom(TempX, TEMPR) = TempY

NEXT t





END SUB

SUB Waita
Waitam = 1
KeyCode% = 0
DO
LOCATE CAMBAR, 1
COLOR CBTX, CBBA
CAM$ = LTRIM$(RTRIM$(InputLine$(work$, 78, KeyCode%)))

IF KeyCode% = ENTER THEN
CCol% = 1
LCMD$ = CAM$
work$ = ""
    CALL DoCommand
END IF


LOOP UNTIL KeyCode% = 999
Waitam = 0

LOCATE BOUNDRY, 1
COLOR STAT, BCLR
END SUB

FUNCTION Words (Text$, WS$)

Wrds = 1

Text$ = LTRIM$(RTRIM$(Text$))
FOR t = 1 TO LEN(Text$)
IF MID$(Text$, t, 1) = WS$ THEN Wrds = Wrds + 1
NEXT t

FOR t = 1 TO 100
WORD$(t) = ""
NEXT t

TempFlag2 = 1
FOR t = 1 TO LEN(Text$)
IF MID$(Text$, t, 1) = WS$ THEN TempFlag2 = TempFlag2 + 1: GOTO 11223344
WORD$(TempFlag2) = WORD$(TempFlag2) + MID$(Text$, t, 1)
11223344
NEXT t

FOR t = 1 TO Wrds
WORD$(t) = LTRIM$(RTRIM$(WORD$(t)))
NEXT t


Words = Wrds
END FUNCTION

SUB WordWrap (Text$, x1, x2, y1)
    savetext$ = Text$
    s = x2 - x1
    y = y1
    'LOCATE y, x1
    IF LEN(Text$) > s THEN
       DO
         IF LEN(Text$) = 0 THEN EXIT DO
         Text$ = LTRIM$(Text$)
         IF LEN(Text$) >= s THEN
            tmp$ = LEFT$(Text$, s)
         ELSE
            tmp$ = Text$
         END IF
         stmp$ = tmp$
         GOSUB ReverseTmp
         IF MID$(Text$, s + 1, 1) = " " THEN
            PRINT stmp$
            Text$ = MID$(Text$, s + 1)
         ELSE
         a = INSTR(tmp$, " ")
         IF a = 0 THEN
            PRINT stmp$
            Text$ = MID$(Text$, s + 1)
         ELSE
            PRINT LEFT$(Text$, s - a)
            Text$ = MID$(Text$, s - a + 1)
         END IF
         END IF
         y = y + 1
         LOCATE 1, BOUNDRY
       LOOP
    ELSE
       PRINT s
    END IF
    Text$ = savetext$
    EXIT SUB

ReverseTmp:
    t$ = ""
    FOR I = LEN(tmp$) TO 1 STEP -1
        t$ = t$ + MID$(tmp$, I, 1)
    NEXT I
    tmp$ = t$
    RETURN
END SUB
