Older Version
Newer Version
ChrisIverson
Jan 30, 2008
- "The tags hate me."
This is actually Noble D. Bell's Text Adventure Engine, with slight modifications by me. I am posting it here for accessibility purposes. [[codeformat="vb"]]' ********************************************************************************************************************** 'format="vb"]] **' * TEXT ADVENTURE ENGINE* '* ' * RELEASE 1.0.0-- FREEWARE* '* ' * BY NOBLE D. BELL(http://www.noblebell.com) * '([[http://www.noblebell.com%29|http://www.noblebell.com)]] ** '' * * ' * NOTICE:* '* ' * You are free to use this text game engine for any use. The author, Noble D. Bell, is not responsible in any way* '* ' * for the use or misuse of this engine. If you do make changes or modifications to the code I require that you email *'' * me the revised code.* ' *********************************************************************************************************************** '**'' REVISIONS:' *' * February 5, 2006 - OFFICIAL RELEASE 1.0.0'' TO DO:' *' * Add: LIGHT / EXTINGUISH commands for using a light source' *' * Program: LEARN / CAST for magic spells' ====================================================================================================================== '' ======= =============================================================================================================== ' PROGRAM STARTS HERE' ====================================================================================================================== '' ======= =============================================================================================================== ' Every LB'er should know what this is for.NOMAINWINNOMAINWIN'' Setup the Window that will be used to play the game.GOSUBGOSUB [Setup.GUI]'' Setup global variables for True/FalseGLOBALGLOBAL TRUE,FALSETRUETRUE = 1FALSEFALSE = 0'' Setup global variables that will be used throughout the game.'' score - the current score for the player, turns - the number of turns the player has taken'' rm - the current room the player is in, maxinventory - the total number of items the player can pack'' inventorycount - the total number of items the player is carrying, OK - used as a flag'' maxhits - the max number of damage a player can take, hits - the total points of damage the player has taken'' defense - the number needed to hit a player, offense - the amount of damage a player can inflict'' gold - the amount of money the player has, maxmp - the total amount of magic the player can wield'' mp - the total amount of magic the player has left, armor$ - the type of armor the player is wearing'' weapon$ - the type of weapon the player is wielding, encounter - flag indicating a current battle'' lantern - a flag indicating if the lantern is on or off, needlight - a flag indicating if an area is dark or not'' noun - the number of the selected noun, verb - the number of the selected verb'' gametitle$ - the title of your game, gamedescription - the description of your game, crlf$ - carriage return/linefeedGLOBALGLOBAL score,turns,maxscore,rm,maxinventory,inventorycount,OKGLOBALGLOBAL maxhits,hits,defense,offense,gold,maxmp,mp,armor$,weapon$GLOBALGLOBAL encounter,lantern,needlight,noun,verbGLOBALGLOBAL gametitle$,gamedescription$,crlf$'' Special game variables and arrays'' rooms$(100) - This contains the description for each room in the game upto 100 rooms.'' roomProperties(100, 2) - Determines if the room is available for teleporting.'' exits(100,15) - This contains the visible exits in each room'' help$(100) - This contains some help or a clue for a particular room in the game.'' objects$(100) - Contains a list of objects the player can interact with in the game upto 100.'' objectproperties(100,7) - Contains a list of different properties about an object in the game.'' commands$(24) - Contains a list of commands (verbs) that are used in the game.'' objectdescriptions$(100) - Contains a list of descriptions about each object in the game.' '' ' exits parameters:' 1' 1 - North, 2 - East, 3 - South, 4 - West, 5 - Up, 6 - Down : Holds connecting room number. Has 0 if not an exit.' 7' 7 - 12 are flags for each exit. (See example for use)' 13' 13 - 15 are not used at present time' '' ' object properties parameters:' 1' 1 - the room location the object resides in.' 2' 2 - tells if the object is takeable (TRUE,FALSE)' 3' 3 - if the object is a monster tells how many hitpoints it has' 4' 4 - if the object is a monster tells how hard it is to hit it (1-20)' 5' 5 - if the object is a monster tells how much damage it can inflict (4,6,8,10,12,20)' 6' 6 - special flag' 7' 7 - Object is a source of Light(lantern, e.g.)'' room properties:' 1' 1 - Room can be teleported to. Values: 0 - Not Visited 1 - Visted, able to TP 2 - Never TP' 2' 2 - Room needs lightDIMDIM rooms$(100),exits(100,15),help$(100),commands$(27)DIMDIM objects$(100),objectproperties(100,7),objectdescriptions$(100)DIMDIM roomProperties(100, 2)'' Assign the crlf$ with the ascii characters that represent a carriage return and a linefeed.crlf$crlf$ = chr$(13)+chr$(10)'' Initialize everything and beginGOSUBGOSUB [Setup.General]GOSUBGOSUB [Setup.Rooms]GOSUBGOSUB [Setup.Objects]GOSUBGOSUB [Begin]GOSUBGOSUB [FleshRoom]GOTOGOTO [Display]' ********************************************************************************************************************** '' **' * WAIT FOR THE USER TO DO SOMETHING.* ' ********************************************************************************************************************** [EventLoop] #m.txtCommand,* '** [EventLoop] #m.txtCommand, ""#m.txtCommand,#m.txtCommand, "!setfocus"WaitWait' ********************************************************************************************************************** '' **' * THE PARSER - BREAKS DOWN THE COMMAND INTO A VERB + NOUN COMBINATION.* ' ********************************************************************************************************************** [Parser] turns* '** [Parser] turns = turns + 1'' add one to the turns variable.#m.txtCommand,#m.txtCommand, "!contents? command$";'' get what the user typed into the command text box.command$command$ = upper$(command$)'' convert what the user typed to upper case text.verb$verb$ = ""'' clear the noun and verb strings to nil.noun$noun$ = ""verb$verb$ = WORD$(command$,1)'' using lb's word$ get the verb part of the command and put it in verb$.noun$noun$ = WORD$(command$,2)'' using lb's word$ get the noun part of the command and put it in noun$.verb =verb = 0'' set the verb and noun id's to 0.noun =noun = 0GosubGosub [Parser.Verb]'' check to see if the verb the user typed is one that we understand.Return 'Return ' return to calling module.[Parser.Verb] '[Parser.Verb] ' see if the verb the user typed is one that we understand and if it isforfor x = 1 to 27'' then assign it it's action value (place in the array). if it is not thenifif verb$ = commands$(x) then'' set the verb id to 0 meaning not known.verb=x exitverb=x exit forendend ifnextnext xifif verb = 0 then'' the verb is not known so tell the user to try again.txt$txt$ = "I don't understand that command. Try saying it a different way please."Return endReturn end ifselectselect case verb'' the verb is known so let's act on it and see what we need to do with it.casecase 1'' Northifif exits(rm,1)<>0 thenGOSUBGOSUB [Logic]ifif OK=TRUE thenrm=exits(rm,1) GOSUBrm=exits(rm,1) GOSUB [FleshRoom]endend ifelse txt$else txt$ = "You cannot go that direction."endend ifcasecase 2'' Eastifif exits(rm,2)<>0 thenGOSUBGOSUB [Logic]ifif OK=TRUE thenrm=exits(rm,2) GOSUBrm=exits(rm,2) GOSUB [FleshRoom]endend ifelse txt$else txt$ = "You cannot go that direction."endend ifcasecase 3'' Southifif exits(rm,3)<>0 thenGOSUBGOSUB [Logic]ifif OK=TRUE thenrm=exits(rm,3) GOSUBrm=exits(rm,3) GOSUB [FleshRoom]endend ifelse txt$else txt$ = "You cannot go that direction."endend ifcasecase 4'' Westifif exits(rm,4)<>0 thenGOSUBGOSUB [Logic]ifif OK=TRUE thenrm=exits(rm,4) GOSUBrm=exits(rm,4) GOSUB [FleshRoom]endend ifelse txt$else txt$ = "You cannot go that direction."endend ifcasecase 5'' Upifif exits(rm,5)<>0 thenGOSUBGOSUB [Logic]ifif OK=TRUE thenrm=exits(rm,5) GOSUBrm=exits(rm,5) GOSUB [FleshRoom]endend ifelse txt$else txt$ = "You cannot go that direction."endend ifcasecase 6'' Downifif exits(rm,6)<>0 thenGOSUBGOSUB [Logic]ifif OK=TRUE thenrm=exits(rm,6) GOSUBrm=exits(rm,6) GOSUB [FleshRoom]endend ifelse txt$else txt$ = "You cannot go that direction."endend ifcasecase 7'' Saveifif encounter = TRUE thentxt$txt$ = "You cannot save a game during an encounter."else openelse open "gamedata.dat" for output as #1forfor x=1 to 100forfor y=1 to 7nextnext ynextnext xforfor x=1 to 100forfor y=1 to 15nextnext ynextnext xforfor x=1 to 100forfor y = 1 to 2nextnext ynextnext xcloseclose #1txt$txt$ = "Game saved."endend ifcasecase 8'' Loadifif encounter = TRUE thentxt$txt$ = "You cannot load a game during an encounter."else dimelse dim info$(10, 10)ifif fileExists(DefaultDir$, "gamedata.dat") thenopenopen "gamedata.dat" for input as #1inputinput #1,scoreinputinput #1,turnsinputinput #1,rminputinput #1,inventorycountinputinput #1,hitsinputinput #1,defenseinputinput #1,offenseinputinput #1,goldinputinput #1,mpinputinput #1,armor$inputinput #1,weapon$forfor x=1 to 100forfor y=1 to 7inputinput #1,objectproperties(x,y)nextnext ynextnext xforfor x=1 to 100forfor y=1 to 15inputinput #1,exits(x,y)nextnext ynextnext xforfor x=1 to 100forfor y = 1 to 2inputinput #1, roomProperties(x, y)nextnext ynextnext xinputinput #1,lanterncloseclose #1txt$txt$ = "Game loaded."else txt$else txt$ = "You don't have a game saved. Save one first."endend ifendend ifcasecase 9'' Look#m.txtView,#m.txtView, ""GOSUBGOSUB [FleshRoom]casecase 10'' Inventorytxt$txt$ = "You are carrying the following items:"+chr$(13)+chr$(10)tmptmp = 0forfor x = 1 to 100ifif objectproperties(x,1)=0 thenifif objects$(x)<>"" thentxt$txt$ = txt$ + objects$(x)+chr$(13)+chr$(10)tmptmp = 1endend ifendend ifnextnext xifif tmp= 0=0 thentxt$ = txt$txt$= txt$ + "Nothing."casecase 11'' Scoretxt$txt$ = "Your score is " + str$(score) + " out of " + str$(maxscore) + " in " + str$(turns) + " turns."+chr$(13)+chr$(10)txt$txt$ = txt$ + "You have " + str$(hits) + "/" + str$(maxhits) + " hit points." + chr$(13)+chr$(10)txt$txt$ = txt$ + "You have " + str$(mp) + "/" + str$(maxmp) + " magic points." + chr$(13)+chr$(10)txt$txt$ = txt$ + "You can inflict upto " + str$(offense) + " points of damage."+chr$(13)+chr$(10)txt$txt$ = txt$ + "Your defense is " + str$(defense) + "."+chr$(13)+chr$(10)txt$txt$ = txt$ + "You have " + str$(gold) + " gold."+chr$(13)+chr$(10)txt$txt$ = txt$ + "You are wearing " + armor$ + " armor."+chr$(13)+chr$(10)txt$txt$ = txt$ + "You are wielding " + weapon$ + "."casecase 12'' InspectGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)=0 or objectproperties(noun,1)=rm thentxt$txt$ = objectdescriptions$(noun)GOSUBGOSUB [Logic]else txt$else txt$ = "You don't see that here."endend ifendend ifcasecase 13'' UseGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)<>0 thentxt$txt$ = "You don't have that."else GOSUBelse GOSUB [Logic]endend ifendend ifcasecase 14'' TakeGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)<>rm thentxt$txt$ = "You don't see that here."return endreturn end ififif objectproperties(noun,1)=0 thentxt$txt$ = "You already have that."return endreturn end ififif objectproperties(noun,2)=FALSE thentxt$txt$ = "You cannot take that."return endreturn end ififif inventorycount+1 > maxinventory thentxt$txt$ = "You cannot carry that, you are too heavy."return endreturn end ifobjectproperties(noun,1)=0 txt$objectproperties(noun,1)=0 txt$ = "Taken."inventorycountinventorycount = inventorycount + 1endend ifcasecase 15'' DropGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)=0 thenobjectproperties(noun,1)=rm txt$objectproperties(noun,1)=rm txt$ = "Dropped."inventorycountinventorycount = inventorycount - 1else txt$else txt$ = "You don't have that."endend ifendend ifcasecase 16'' FightGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)=rm thenifif objectproperties(noun,3)=0 thentxt$txt$ = "That is harmless. Why would you want to fight that?"else GOSUBelse GOSUB [Battle]endend ifelse txt$else txt$ = "You don't see that here."endend ifendend ifcasecase 17'' QuitGOTOGOTO [Quit]casecase 18'' Helptxt$txt$ = help$(rm)casecase 19'' ArmGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)<>0 thentxt$="Youtxt$="You don't have that."return endreturn end ififif objects$(noun)=weapon$ thentxt$="Youtxt$="You are already wielding that."return endreturn end ifweapon$weapon$ = objects$(noun)offenseoffense = objectproperties(noun,5)txt$txt$ = "You are now wielding a " + weapon$ + "."endend ifcasecase 20'' UnArmGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)<>0 thentxt$="Youtxt$="You don't have that."return endreturn end ififif objects$(noun)<>weapon$ thentxt$="Youtxt$="You are not wielding that."return endreturn end ifweapon$weapon$ = "hands"offense=4 txt$offense=4 txt$ = "You are now wielding " + weapon$ + "."endend ifcasecase 21'' WearGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)<>0 thentxt$="Youtxt$="You don't have that."return endreturn end ififif objects$(noun)=armor$ thentxt$="Youtxt$="You are already wearing that."return endreturn end ifarmor$armor$ = objects$(noun)defensedefense = objectproperties(noun,4)txt$txt$ = "You are now wearing " + armor$ + " armor."endend ifcasecase 22'' RemoveGOSUBGOSUB [Parser.Noun]ifif noun <> 0 thenifif objectproperties(noun,1)<>0 thentxt$="Youtxt$="You don't have that."return endreturn end ififif objects$(noun)<>armor$ thentxt$="Youtxt$="You are not wearing that."return endreturn end ifarmor$armor$ = "Cloth"defensedefense = 9txt$txt$ = "You are now wearing " + armor$ + " armor."endend ifcasecase 23'' Learntxt$txt$ = "Not used in this adventure."casecase 24'' Casttxt$txt$ = "Not used in this adventure."casecase 25'Teleport GOSUB'Teleport GOSUB [Logic]IfIf OK=TRUE and TOK = TRUE thenrmrm = val(noun$)gosubgosub [FleshRoom]Else txt$Else txt$ = "Cannot TELEPORT there."EndEnd Ifcasecase 26'Light GOSUB'Light GOSUB [Parser.Noun]IfIf objectproperties(x, 7) = 1 thenIfIf lantern thentxt$txt$ = "You already have something lit!"Else lanternElse lantern = 1txt$txt$ = "You have lit the ";objects$(x)EndEnd IfElse txt$Else txt$ = "That cannot be lit."EndEnd Ifcasecase 27'Extinguish GOSUB'Extinguish GOSUB [Parser.Noun]IfIf objectproperties(x, 7) = 1 thenIfIf lantern thenlanternlantern = 0txt$txt$ = "The ";objects$(x);" was put out."Else txt$Else txt$ = "The ";objects$(x);" is not lit."EndEnd IfElse txt$Else txt$ = "That cannot be extinguished."EndEnd IfEndEnd SelectReturnReturn[Parser.Noun] '[Parser.Noun] ' look to see if we understand what the object or noun is that theforfor x = 1 to 18'' user entered. if we do understand it then assign it it's actionifif noun$ = objects$(x) then'' id (place in the array) otherwise assign the noun id a 0 meaningnoun=x 'noun=x ' we did not know that object.exitexit forendend ifnextnext xifif noun = 0 thentxt$txt$ = "I don't know what that is."Return endReturn end ifReturnReturn' ********************************************************************************************************************** '' **' * USER TAPS OK OR HITS ENTER, ACT ON THEIR COMMANDS.* ' ********************************************************************************************************************** [Okay] GOSUB* '** [Okay] GOSUB [Parser]GOTOGOTO [Display]' ********************************************************************************************************************** '' **' * DISPLAY ACTION* ' ********************************************************************************************************************** [Display] #m.txtView,* '** [Display] #m.txtView, "!contents? tmpTxt$";#m.txtView,#m.txtView, ""'tmpTxt$="" tmpTxt$'tmpTxt$="" tmpTxt$ = tmpTxt$ + chr$(13) + chr$(10)tmpTxt$tmpTxt$ = tmpTxt$ + "> " + command$ + chr$(13) + chr$(10) + chr$(13) + chr$(10)tmpTxt$tmpTxt$ = tmpTxt$ + txt$ + chr$(13) + chr$(10)ifif needlight= TRUE=TRUE andlantern = FALSElantern= FALSE thentmpTxt$tmpTxt$ = "You cannot see anything. It is pitch black here."+chr$(13)+chr$(10)endend if#m.txtView,#m.txtView, "!setfocus"#m.txtView,#m.txtView, tmpTxt$CallCall VerticalScroll hWnd(#m.txtView), _SB_BOTTOM'' Thanks Janet!!!'' Call VerticalScroll hWnd(#main.textbox), _SB_TOP'' Call VerticalScroll hWnd(#main.textbox), _SB_PAGEDOWN'' Call VerticalScroll hWnd(#main.textbox), _SB_PAGEUPGOTOGOTO [EventLoop]' ********************************************************************************************************************** '' **' * DESCRIBE ROOM FOR DISPLAY ROUTINE* ' ********************************************************************************************************************** [FleshRoom] If* '** [FleshRoom] If roomProperties(rm, 1)= 0=0 then roomProperties(rm,1) = 1 '1)= 1 ' Allows TELEPORTINGIfIf not(lantern) AND roomProperties(rm, 2) thentxt$txt$ = "The darkness is so blinding you can't see your hand in front of your face."txt$txt$ = txt$ + chr$(13) + chr$(10) + "If only you had a light source..." + chr$(13)+chr$(10)+chr$(13)+chr$(10)Else txt$=rooms$(rm)+chr$(13)+chr$(10)+chr$(13)+chr$(10) 'Else txt$=rooms$(rm)+chr$(13)+chr$(10)+chr$(13)+chr$(10) ' Let the program display the room's contents and it'sEndEnd Iftxt$txt$ = txt$ + "Exits: "'' visible exits along with the description.tmptmp = 0ifif exits(rm,1)<>0 thentxt$txt$ = txt$ + "North,"tmp=1 endtmp=1 end ififif exits(rm,2)<>0 thentxt$txt$ = txt$ + "East,"tmp=1 endtmp=1 end ififif exits(rm,3)<>0 thentxt$txt$ = txt$ + "South,"tmp=1 endtmp=1 end ififif exits(rm,4)<>0 thentxt$txt$ = txt$ + "West,"tmp=1 endtmp=1 end ififif exits(rm,5)<>0 thentxt$txt$ = txt$ + "Up,"tmp=1 endtmp=1 end ififif exits(rm,6)<>0 thentxt$txt$ = txt$ + "Down,"tmp=1 endtmp=1 end ififif right$(txt$,1)="," thentxt$txt$ = left$(txt$,len(txt$)-1)endend ififif tmp= 0=0 thentxt$ = txt$txt$= txt$ + "None"txt$txt$ = txt$ + chr$(13)+chr$(10)+chr$(13)+chr$(10)txt$txt$ = txt$ + "You also see: " +chr$(13)+chr$(10)tmptmp = 0forfor x=1 to 100ifif objectproperties(x,1)=rm thentxt$txt$ = txt$ + objects$(x)+chr$(13)+chr$(10)tmp=1 endtmp=1 end ifnextnext xifif tmp= 0=0 thentxt$=txt$+"Nothing" txt$txt$= txt$+"Nothing" txt$ = txt$+chr$(13)+chr$(10)ReturnReturn' ********************************************************************************************************************** '' **' * QUIT THE GAME* ' ********************************************************************************************************************** [Quit] CONFIRM* '** [Quit] CONFIRM gametitle$+chr$(13)+"Are you sure you really want to quit?";answer$ifif answer$="no" then GOTO [EventLoop]txt$txt$ = "Thank you for playing. I really hope that you had a wonderful and entertaining experience."+chr$(13)+chr$(10)txt$txt$ = txt$ + "If you have any comments or questions then please visit my website at the following"+chr$(13)+chr$(10)txt$txt$ = txt$ + "location:http://www.noblebell.com"+chr$(13)+chr$(10)+chr$(13)+chr$(10)http://www.noblebell.com"+chr$(13)+chr$(10)+chr$(13)+chr$(10)NOTICENOTICE gametitle$+chr$(13)+txt$CloseClose #mENDEND' ********************************************************************************************************************** '' **' * FUNCTIONS* ' *********************************************************************************************************************** '**'' Specify the number of sides on the die and the number of times to roll and the result will be returned.FUNCTIONFUNCTION RollDice(sides,times)tmptmp = 0FORFOR x = 1 to timestmptmp = tmp + int(rnd(1)*sides)+1NEXTNEXT xRollDiceRollDice = tmpENDEND FUNCTION'' Checks to see if a file that is passed actually exists on the users directory path specified.FUNCTIONFUNCTION fileExists(path$, filename$)filesfiles path$, filename$, info$()fileExistsfileExists = val(info$(0, 0))'non'non zero is trueENDEND FUNCTION'' Used to scroll to the bottom of the screen in the textbox.SUBSUB VerticalScroll handle, ScrollAmountCalldllCalldll #user32, "SendMessageA", _handlehandle as Ulong, __WM_VSCROLL_WM_VSCROLL as Long, _ScrollAmountScrollAmount as Long, _00 as Long, _resultresult as LongENDEND SUB' ********************************************************************************************************************** '' **' * GUI SETUP* ' ********************************************************************************************************************** [Setup.GUI] ForegroundColor$* '** [Setup.GUI] ForegroundColor$ = "black"BackgroundColor$BackgroundColor$ = "buttonface"TextboxColor$TextboxColor$ = "white"TexteditorColor$TexteditorColor$ = "white"ComboboxColor$ComboboxColor$ = "white"ListboxColor$ListboxColor$ = "white"WindowWidth = 792WindowWidth =792 :WindowHeight = 595 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)WindowHeight= 595 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)textboxtextbox #m.txtView, 8, 10, 768, 515textboxtextbox #m.txtCommand, 8, 530, 672, 25stylebitsstylebits #m.btnGo, _BS_MULTILINE, 0, 0, 0buttonbutton #m.default, "GO", [Okay], UL, 688, 530, 88, 25stylebitsstylebits #m.txtView, _ES_MULTILINE or _ES_READONLY or _WS_VSCROLL, _ES_AUTOHSCROLL , 0, 0openopen "TEXT ADVENTURE" for dialog as #m#m.txtView#m.txtView "!font arial 11"#m.txtCommand#m.txtCommand "!font arial 11 bold"#m.default#m.default "!font arial 11 bold"#m#m "trapclose [Quit]"#m.txtCommand,#m.txtCommand, "!setfocus"ReturnReturn' ********************************************************************************************************************** '' **' * GENERAL* ' ********************************************************************************************************************** [Setup.General] '* '** [Setup.General] ' assign starting values to certain variablesscore = 0score =0 :maxscore = 500 'maxscore= 500 ' current score is 0 and the maximim score can be only 500turns = 0turns =0 :rm = 1 'rm= 1 ' total turns taken is 0 and the starting room location is 1maxinventory = 10maxinventory =10 :inventorycount = 0 'inventorycount= 0 ' total items that can be carried at once is 10 and they are carrying 0maxhitsmaxhits = 25'' the total number of hits you can take before you die.hitshits = 25'' you have 25 hits left before you die.defensedefense = 9'' (1-20) : 20-Easy to hit, 1-Near impossible to hit, 0-Can't hit!offenseoffense = 4'' the amount of damage that can be caused (4,8,10,12,20)goldgold = 50'' starting about of money the player hasmaxmpmaxmp = 15'' total magic points the player can spendmpmp = 15'' total magic points the player has left to spendencounterencounter = FALSE'' tells if the player is engaged in a battle (TRUE/FALSE)lanternlantern = FALSE'' tells if the player's lantern is lit or not (TRUE/FALSE)needlightneedlight = FALSE'' tells if the room needs to have a light or not (TRUE/FALSE)nounnoun = 0'' noun action idverbverb = 0'' verb action idOKOK = FALSE'' flag (TRUE/FALSE)'' Using anything different from the items below they must be listed as a game object that the user can interact with.'' If the object is to be armor then you need to set the objectproperties defense parameter to the value you want.'' If the object is to be a weapon then you need to set the objectproperties damage parameter to the value you want.armor$="CLOTH" 'armor$="CLOTH" ' Starting armor the player is wearing.weapon$="HANDS" 'weapon$="HANDS" ' Starting weapon the player is using.'' Add the known commands to the commands$ array. Currently there are 24 known commands. The commands must be'' in UPPER case and only one word. You can add new commands by adding another element to the commands$ array'' with the command and then you will have to add the new element to the [Parser.Verb] module and also to the'' [Logic] module if needed.commands$(1)="NORTH":commands$(2)="EAST":commands$(3)="SOUTH":commands$(4)="WEST":commands$(5)="UP":commands$(6)="DOWN" commands$(7)="SAVE":commands$(8)="LOAD":commands$(9)="LOOK":commands$(10)="INVENTORY":commands$(11)="SCORE" commands$(12)="INSPECT":commands$(13)="USE":commands$(14)="TAKE":commands$(15)="DROP":commands$(16)="FIGHT" commands$(17)="QUIT":commands$(18)="HELP":commands$(19)="ARM":commands$(20)="UNARM":commands$(21)="WEAR":commands$(22)="REMOVE" commands$(23)="LEARN":commands$(24)="CAST":commands$(25)="TELEPORT":commands$(26)="LIGHT":commands$(27)="EXTINGUISH"commands$(1)="NORTH":commands$(2)="EAST":commands$(3)="SOUTH":commands$(4)="WEST":commands$(5)="UP":commands$(6)="DOWN" commands$(7)="SAVE":commands$(8)="LOAD":commands$(9)="LOOK":commands$(10)="INVENTORY":commands$(11)="SCORE" commands$(12)="INSPECT":commands$(13)="USE":commands$(14)="TAKE":commands$(15)="DROP":commands$(16)="FIGHT" commands$(17)="QUIT":commands$(18)="HELP":commands$(19)="ARM":commands$(20)="UNARM":commands$(21)="WEAR":commands$(22)="REMOVE" commands$(23)="LEARN":commands$(24)="CAST":commands$(25)="TELEPORT":commands$(26)="LIGHT":commands$(27)="EXTINGUISH"ReturnReturn' ********************************************************************************************************************** '' **' * ROOM DESCRIPTIONS, EXITS, ETC.* ' ********************************************************************************************************************** [Setup.Rooms] for* '** [Setup.Rooms] for x=1 to 100help$(x)help$(x) = "Try working it out yourself a little longer."nextnext xforfor x=1 to 100forfor y = 1 to 15exits(x,y)=0 nextexits(x,y)=0 next ynextnext xforfor x=1 to 100rooms$(x)="" nextrooms$(x)="" next xrooms$(1)rooms$(1) = "BOTTOM OF MOUNTAIN"+crlf$+crlf$rooms$(1)rooms$(1) = rooms$(1) + "You are standing at the foot of what appears to be a really large mountain."+crlf$rooms$(1)rooms$(1) = rooms$(1) + "The rocks are to steep and slimey to climb. There is however a little winding trail"+crlf$rooms$(1)rooms$(1) = rooms$(1) + "that appears to be leading up into the mountain. There is a heavy mist in the air."rooms$(2)rooms$(2) = "GAP IN THE PATH"+crlf$+crlf$rooms$(2)rooms$(2) = rooms$(2) + "There is a small gap in the pathway here. It appears to be man-made. The air is starting"+crlf$rooms$(2)rooms$(2) = rooms$(2) + "to become more chilled and thin. The mist from earlier has all but disapated."rooms$(3)rooms$(3) = "MOUNTAIN PASS"+crlf$+crlf$rooms$(3)rooms$(3) = rooms$(3) + "This is a leveled out area that looks to be a simple camp site. There is nothing useful here though."rooms$(4)rooms$(4) = "HOLE IN MOUNTAIN SIDE"+crlf$+crlf$rooms$(4)rooms$(4) = rooms$(4) + "There is an opening inside one of the large rocks here. It appears to be large enough"+crlf$rooms$(4)rooms$(4) = rooms$(4) + "for a person to get inside. It is aweful dark looking in there and you can hear faint"+crlf$rooms$(4)rooms$(4) = rooms$(4) + "sounds of dripping water in the distance."rooms$(5)rooms$(5) = "SPLIT IN THE PATH"+crlf$+crlf$rooms$(5)rooms$(5) = rooms$(5) + "The cavern that you are in seems to split into two different directions here."+crlf$rooms$(5)rooms$(5) = rooms$(5) + "There is a strange wooden door on the north side of this passage and an opening"+crlf$rooms$(5)rooms$(5) = rooms$(5) + "leading off into darkness toward the south."rooms$(6)rooms$(6) = "LOST TOMB"+crlf$+crlf$rooms$(6)rooms$(6) = rooms$(6) + "This is an oblong chamber where someone or something burries others. Everything is a mess"+crlf$rooms$(6)rooms$(6) = rooms$(6) + "and all the tombs are open with nothing inside. Almost as if the contents were stolen."rooms$(7)rooms$(7) = "WEST TOMB CHAMBER"+crlf$+crlf$rooms$(7)rooms$(7) = rooms$(7) + "This area of the tomb is scattered with shrouds and busted open tombs."rooms$(8)rooms$(8) = "EAST TOMB CHAMBER"+crlf$+crlf$rooms$(8)rooms$(8) = rooms$(8) + "This area of the elongated tomb is covered with busted open tombs."rooms$(9)rooms$(9) = "WEST OF RAVINE"+crlf$+crlf$rooms$(9)rooms$(9) = rooms$(9) + "You are standing just to the west of a very large and deep ravine carved into the mountain"+crlf$rooms$(9)rooms$(9) = rooms$(9) + "surface. It kind of looks like this is where bad things have taken place in the past."rooms$(10)rooms$(10) = "EAST OF RAVINE"+crlf$+crlf$rooms$(10)rooms$(10) = rooms$(10) + "The ravine is to the west of you. Things seem oddly different here. More so than normal."rooms$(11)rooms$(11) = "BONE CHAMBER"+crlf$+crlf$rooms$(11)rooms$(11) = rooms$(11) + "The floor in this area is completely covered in unidentifiable bones of all shapes and sizes."rooms$(12)rooms$(12) = "SWIRLING POOL"+crlf$+crlf$rooms$(12)rooms$(12) = rooms$(12) + "Standing in the center of this odd and fowl-smelling pool of liquid stands a very unique"+crlf$rooms$(12)rooms$(12) = rooms$(12) + "statue.ThereThere is a magical disturbance in the air.SomeSome spells may be affected."exits(1,1)exits(1,1) = 2exits(2,1)exits(2,1) = 3exits(2,3)exits(2,3) = 1exits(2,2)exits(2,2) = 4exits(3,3)exits(3,3) = 2exits(4,4)exits(4,4) = 2exits(4,2)exits(4,2) = 5exits(5,4)exits(5,4) = 4exits(5,3)exits(5,3) = 6exits(5,1)exits(5,1) = 9exits(5,7)exits(5,7) = 1'locked exits(6,1)'locked exits(6,1) = 5exits(6,2)exits(6,2) = 8exits(6,4)exits(6,4) = 7exits(7,2)exits(7,2) = 6exits(8,4)exits(8,4) = 6exits(9,2)exits(9,2) = 10exits(9,3)exits(9,3) = 5exits(9,8)exits(9,8) = 1'' ravineexits(10,1)exits(10,1) = 12exits(10,3)exits(10,3) = 11exits(10,4)exits(10,4) = 9exits(11,1)exits(11,1) = 10exits(12,3)exits(12,3) = 10roomProperties(12,roomProperties(12, 1) = 2'Can't'Can't TP to or from room 12roomProperties(12,roomProperties(12, 2) = 1'Need'Need lightReturnReturn' ********************************************************************************************************************** '' **' * OBJECTS, OBJECT PROPERTIES, OBJECT DESCRIPTIONS* ' ********************************************************************************************************************** [Setup.Objects] for* '** [Setup.Objects] for x = 1 to 100objects$(x)="" nextobjects$(x)="" next xobjects$(1)objects$(1) = "ORC"objectproperties(1,1)=3 objectproperties(1,2)=FALSE objectproperties(1,3)=6 objectproperties(1,4)=8 objectproperties(1,5)=4 objectdescriptions$(1)objectproperties(1,1)=3 objectproperties(1,2)=FALSE objectproperties(1,3)=6 objectproperties(1,4)=8 objectproperties(1,5)=4 objectdescriptions$(1) = "A massive frame, pig-like head, pale green. Very unfriendly looking."objects$(2)objects$(2) = "SKELETON"objectproperties(2,1)=6 objectproperties(2,2)=FALSE objectproperties(2,3)=4 objectproperties(2,4)=9 objectproperties(2,5)=4 objectdescriptions$(2)objectproperties(2,1)=6 objectproperties(2,2)=FALSE objectproperties(2,3)=4 objectproperties(2,4)=9 objectproperties(2,5)=4 objectdescriptions$(2) = "An animated corpse of bones wielding a dagger."objects$(3)objects$(3) = "SWORD"objectproperties(3,1)=7 objectproperties(3,2)=TRUE objectproperties(3,5)=objectproperties(3,1)=7 objectproperties(3,2)=TRUE objectproperties(3,5)= 8objectdescriptions$(3)objectdescriptions$(3) = "A short sword made of finely crafted steel with a jewel-enlaid hilt."objects$(4)objects$(4) = "ROPE"objectproperties(4,1)=7 objectproperties(4,2)=TRUE objectdescriptions$(4)objectproperties(4,1)=7 objectproperties(4,2)=TRUE objectdescriptions$(4) = "50' of coiled rope"objects$(5)objects$(5) = "KEY"objectproperties(5,1)=8 objectproperties(5,2)=TRUE objectdescriptions$(5)objectproperties(5,1)=8 objectproperties(5,2)=TRUE objectdescriptions$(5) = "A rusted-metal skeleton key. It might be used to unlock more than one door."objects$(6)objects$(6) = "STATUE"objectproperties(6,1)=12 objectproperties(6,2)=FALSE objectdescriptions$(6)objectproperties(6,1)=12 objectproperties(6,2)=FALSE objectdescriptions$(6) = "This is just a simple stone statue .. Wait!YouYou feel funny and appear to be feeling better."objects$(7)objects$(7) = "LANTERN"objectproperties(7,objectproperties(7, 1) = 1objectproperties(7,objectproperties(7, 2) = TRUEobjectproperties(7,objectproperties(7, 7) = TRUEobjectdescriptions$(7)objectdescriptions$(7) = "A rather old lantern, but appears to work."' ********************************************************************************************************************** '' **' * GAME LOGIC BELOW* ' ********************************************************************************************************************** [Logic] OK* '** [Logic] OK = TRUETOKTOK = TRUE'' Once a fight starts you cannot run from it. You must finish it.ifif encounter = TRUE thenifif verb=1 or verb=2 or verb=3 or verb=4 or verb=5 or verb=6 thentxt$txt$ = "You cannot run!"OKOK = FALSEreturn endreturn end ifendend if'Checks'Checks if you can TELEPORT to a roomroomnumroomnum = val(noun$)IfIf roomnum > 12 or roomnum < 1 then TOK = FALSEIfIf roomProperties(roomnum, 1)= 0=0 or roomProperties(roomnum,1) = 21)= 2 then TOK = FALSEIfIf roomProperties(rm, 1)= 2=2 thenTOK = FALSETOK= FALSE'' Special things that happen in selected rooms.selectselect case rmcasecase 12ifif verb= 12=12 andnoun = 6noun= 6 thentxt$txt$ = objectdescriptions$(6)+crlf$txt$txt$ = txt$ + "Poof! All your damage has been healed, and your magic restored."hitshits = maxhitsmpmp = maxmpendend ifcasecase 5ifif verb= 1=1 andexits(5,7)=1exits(5,7)= 1 thentxt$txt$ = "That doorway appears to be locked or something."OK=FALSE endOK=FALSE end ififif verb= 1=1 andexits(5,7)=0exits(5,7)= 0 thenOK=TRUE endOK=TRUE end ififif verb= 13=13 andnoun = 5noun= 5 thenexits(5,7)=0 txt$exits(5,7)=0 txt$ = "The door has been unlocked."else txt$else txt$ = "The door is locked."endend ifcasecase 9ifif verb= 2=2 andexits(9,8)=1exits(9,8)= 1 thentxt$txt$ = "You can't jump that ravine. It is too wide."OK=FALSE endOK=FALSE end ififif verb= 2=2 andexits(9,8)=0exits(9,8)= 0 thenOK=TRUE endOK=TRUE end ififif verb=13 and noun=4 thentxt$txt$ = "You string the rope through a hole in the ceiling so that you can swing across."exits(9,8)=0 else txt$exits(9,8)=0 else txt$ = "You can't get across that way."endend ifendend selectReturnReturn' ********************************************************************************************************************** '' **' * THE BATTLE ENGINE* ' ********************************************************************************************************************** [Battle] '* '** [Battle] ' We are in a battle so we cannot load or save a game.encounterencounter = TRUEtxt$txt$ = ""txt$txt$ = txt$ + "You attack the " + objects$(noun) + " using your " + weapon$ + "..."+crlf$'' Player attacks the monstertoHittoHit = RollDice(20,1)ifif toHit <= objectproperties(noun,4) thentoDamagetoDamage = RollDice(offense,1)txt$txt$ = txt$ + "You inflict " + str$(toDamage) + " points of damage on the " + objects$(noun)+"."+crlf$objectproperties(noun,3)=objectproperties(noun,3)-toDamage ifobjectproperties(noun,3)=objectproperties(noun,3)-toDamage if objectproperties(noun,3) <= 0 thentxt$txt$ = txt$ + "You have slain the " + objects$(noun)+crlf$objectproperties(noun,1)objectproperties(noun,1) = -1gpgp = RollDice(6,1) * 10txt$txt$ = txt$ + "You have found " + str$(gp) + " gold coins."+crlf$+crlf$gold=gold+gp scoregold=gold+gp score = score + 5encounterencounter = FALSEReturn endReturn end ifelse txt$else txt$ = txt$ + "You miss the " + objects$(noun)+"!!"+crlf$endend if'' Monster attacks the playertxt$txt$ = txt$ + "The " + objects$(noun) + " attacks you..."+crlf$toHittoHit = RollDice(20,1)ifif toHit <= defense thentoDamagetoDamage = RollDice(objectproperties(noun,5),1)txt$=txt$+"Thetxt$=txt$+"The " + objects$(noun)+" inflicts " + str$(toDamage) + " points of damage on you."+crlf$hits=hits-toDamage ifhits=hits-toDamage if hits <=0 thentxt$txt$ = txt$ + "You have been slain!"+crlf$closeclose #mend endend end ifelse txt$else txt$ = txt$ + "The " + objects$(noun) + ", misses you."+crlf$endend ifReturnReturn' ********************************************************************************************************************** '' **' * DISPLAY TITLE, INTRODUCTION, INSTRUCTIONS* ' ********************************************************************************************************************** [Begin] gametitle$* '** [Begin] gametitle$ = "Mysterious Caverns 1.00"gamedescription$gamedescription$ = ""txt$="" txt$txt$="" txt$ = txt$ + gametitle$+crlf$txt$txt$ = txt$ + "By: Noble D. Bell"+crlf$+crlf$txt$txt$ = txt$ + gamedescription$+crlf$+crlf$txt$txt$ = txt$ + "To play this game you use text commands. The commands must be in the form of [verb][noun]. The"+crlf$txt$txt$ = txt$ + "game understands 24 different commands and quite possibly several different nouns."+crlf$+crlf$txt$txt$ = txt$ + "Here are the commands that can be used in this game:"+crlf$+crlf$forfor x=1 to 24txt$=txt$+commands$(x)+"," nexttxt$=txt$+commands$(x)+"," next xtxt$=left$(txt$,len(txt$)-1) txt$txt$=left$(txt$,len(txt$)-1) txt$ = txt$+crlf$+crlf$txt$txt$ = txt$ + "Just press [ENTER] to begin."'notice'notice gametitle$+crlf$+txt$#m.txtView#m.txtView txt$#m.txtCommand#m.txtCommand "LOOK"waitwaitReturnReturn' ====================================================================================================================== '' ======= =============================================================================================================== ' PROGRAM ENDS HERE' ======================================================================================================================' ======= =============================================================================================================== [[code]] [[user:thedarkfreak|1201499698]](Chris Iverson)