home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Educate / Educate.zip / radf100.zip / REXXADV.DOC < prev    next >
Text File  |  1995-11-05  |  19KB  |  418 lines

  1. Table of Contents
  2.  
  3. Introduction
  4.         Features
  5.         Planned Features
  6. Playing Rexx-Adventure
  7.         Game source files (.RAD) and Game Command Files (.CMD)
  8.         Loading a Game Source File
  9.         Loading a Saved Game
  10.         Saving a game in progress
  11.         Exiting Rexx-Adventure
  12. Creating Rexx-Adventure games
  13.         The Source File Layout
  14.                 A) Overview
  15.                         Variable Definition
  16.                 B) Comments
  17.                 C) Header lines
  18.                         Line 1 Title
  19.                         Line 2 PlayerNum
  20.                         Line 3 GlobalNum
  21.                 D) Object Definitions
  22.                         Intro Lines
  23.                         Object Lines
  24.                         Flag Lines
  25.                         Content Lines
  26.                         Verb Lines
  27.                         IVerb Lines
  28.                         Test Lines
  29.                         Desc Lines
  30.                         Code Lines
  31.         Debug Mode
  32. Appendices
  33.         1) Data Structure
  34.         2) Sample Object
  35.         3) Built in Functions and Procedures
  36.  
  37. Introduction:
  38.  
  39.         Thank you for trying Rexx-Adventure.  This project began about 2 years ago when I decided to write a text adventure.  I began looking around for a development system, and found Adventure Game Toolkit (AGT), which is a good system, but requires multiple files to create a single advnture.
  40.  
  41.         I got bogged down in the text entry, and trying to keep track of things.  The project sat for a long time.  Then I got OS/2, and discovered REXX, and VX-REXX.  I realized that I had never seen a text adventure engine for OS/2 on any FTP sites.
  42.  
  43.         This package is released as Freeware.  While you do not have to pay for it, it remains my 
  44. property.  It may only be reporduced in its entirety and without modification.  I do not limit the nethod of distribution, as long as there is no charge beyond the cost of the sotrage media.
  45.  
  46.         If you like this pacakge, or even if you don't, please contact me at desantom@io.com and give your opinion.
  47.  
  48. Features:
  49.  
  50. Easy to use point-and-click interface.
  51. An Engine, not a single game.  Lets you write your own games.
  52. Simple source creation for easy to write games.
  53. Very little programming expertese required.
  54. Object based source design.  (Not Object Oriented because it does not suport Inheritance)
  55. Absloutely Free!
  56.  
  57.  
  58.  
  59. Planned Features:
  60.  
  61. Indirect Object Support.
  62. Re-sizable windows.
  63. Sound support.  Make your adventure talk.
  64. Visiual source creation software. (Tentative)
  65. A Compass Rose window.
  66.  
  67. Playing Rexx-Adventure:
  68.  
  69. Game source files (.RAD) and Game Command Files (.CMD):
  70.  
  71.         Rexx-Adventure source files have the extension .RAD.  These files hold every object and action possible within the game.  
  72.  
  73.         An adventure may also have an optional Command file, with the extension .CMD.  This is used to hold functions that the programmer added to the basic set.  Command files are limited in that they can not access the entire database.  They are useful, however, for pot-up windows and the like.
  74.  
  75.         Both of these files should have the same name.  
  76.  
  77. Loading a Game Source File:
  78.  
  79.         To load a source file, click on the "File Commands" menu, and the "Begin New Adventure" 
  80. option.  Choose the desired file in the file dialog, and the game is loaded.  While the game is loading, a dot is shown for each object loaded.  This will give you a impression of the overall size of the game, and it makes me more comfortable to know that the program is running properly.
  81.  
  82. Loading a Saved Game:
  83.  
  84.         Before you can load a saved game, you must first load the Source File for that game.  I suggest keeping each Source File in its own sub-folder, so the save games and source files do not get confused.
  85.  
  86.         Once the Source File is loaded, choose "Load Game" from the "File Commands" menu.  Saved 
  87. games have the extension .RAS.  Choose the saved game to load, and click OK.
  88.  
  89. Saving a game in progress:
  90.  
  91.         Simply choose "Save Game" from the "File Commands" menu.  Enter the file name to save in the file dialog, and the game will be saved.  If a file already exists with the given name, you will be prompted whether to erase it or not.
  92.  
  93. Exiting Rexx-Adventure
  94.  
  95.         Simply choose "Quit" from the "File Commands" Menu
  96.  
  97. Creating Rexx-Adventure games
  98.  
  99. The Source File Layout
  100.  
  101. Overview:
  102.  
  103.         The entire data structure is contained in a single Compound Variable, named "Obj.". 
  104.  
  105.         There are five system variables.  'Title' identifies the game so that the save files will match the source files.  'PlayerNum' identifies which object is the player.  This can allow multiple 'Player' objects, which the user can switch between.  'GlobalNum' defines the object whose Implied Verb takes care of tests to be performed every move.  This includes incrementing the Move number, decrementing the number of moves for a light, and the appearance of Dwarves with nasty knives. 'ScrollBack' holds the current page number of the scrollback buffer that is in use.  'ScrollBack.' contains the scrollback buffer.  
  106.  
  107.         The data after these first 3 is made up of objects.  An object can have 4 properties.  Flags: variables specific to that object. (Note, flags are case sensitive).  Contents: The Object numbers of any objects contained within the given object.  Implied Verbs (IVerb), verbs that are automatic whenever the object is selected, usually used for exits, such as "North" and "up".  And Verbs: actions that may be performed with or on the given object.  
  108.  
  109.         When the player clicks on an object, either in the Inventory, or in the Nouns box, One of 2 thing happens.  If the object has an Implied Verb, the verb is executed.  If it has normal Verbs, the list of Verbs is displayed in the Actions box.  When a Verb is selected from the Actions box, that verb is executed.
  110.  
  111.         When a verb is executed, its Tests are checked in succession.  As soon as the conditions given are met, the Description lines for that test are shown, and the Code lines interpreted.
  112.  
  113.         The source file is defined by individual lines.  Each line has a header and a body, seperated by a colon.  Lines must be in a certain order, using the following chart:
  114.  
  115. Header                  May Follow
  116. ; (comment)             Anything ( Is ignored )
  117. Intro                   Anything
  118. Object                  Anything
  119. Flag                    Object, Flag
  120. Content                 Object, Flag, Content
  121. IVerb                   Object, Flag, Content
  122. Verb                    Object, Flag, Content, Desc, Code
  123. Test                    Verb, IVerb, Desc, Code
  124. Desc                    Test, Desc
  125. Code                    Test, Desc, Code
  126.  
  127. Line Type Definitions:
  128.  
  129. Comments
  130.  
  131.         Any line beginning with a semi-colon, ";", is ignored by Rexx-Adventure.  These are used as comments, to describe in more detail the working of an object.
  132.  
  133.  
  134. Header lines
  135.  
  136.         The first three non-comment lines are very important.  
  137.  
  138. Line 1, the Title
  139.  
  140.         This line gives the adventure a name.  This name is displayed in the title field of the window, along with the current room name of the player object.  The title is also used the match saved games with source files.
  141.  
  142. Line 2 PlayerNum
  143.  
  144.         This variable lets the engine know which of the objects in the game is the player.  If you set the wrong value here, you could end up with a sofa that walks around pinking things up.
  145.  
  146. Line 3 GlobalNum
  147.  
  148.         This variable holds the object number of a very special object.  The object specified is expected to have an implied verb.  Whenever any verb is executed, the IVerb of object # GlobalNum is executed as well, and ALL matching tests are performed.  (Normally only the first is done.)  This is useful for taking care of tedious tasks which would cause code to be repeated many times.  For example, keeping track of the number ov moves.  Without GlobalNum, every Test of every Verb in the entire game would have to increment the Move counter individually.
  149.  
  150. Object Definitions:
  151.  
  152. Intro Lines
  153.  
  154. Syntax: Intro: <Text>
  155.  
  156.         Used to show the opening introduction, printed while the source file is loading.
  157.  
  158. Object Lines
  159.  
  160. Syntax: Object: <Obj Number> <Obj Name>
  161.  
  162.         Defines the name and internal number of the object.  More than one object may have the same name, but no two objects with the same name may be contained within the same third object.
  163.  
  164.  
  165. Flag Lines:
  166.  
  167. Syntax: Flag: <Flag Name> <Value>
  168.  
  169.         Set the starting value of a flag.  Flags are like variables which are attached to objects, and are manipulated with the function GetFlag and the procedure SetFlag.  There are a few pre-defined flags you need to know about.
  170.  
  171.         Location - This flag tells where an object is located.  For example if a Chair (#2) is in the Living Room (#1), then the 'Location' flag of Object 2 will equal 1.
  172.  
  173.         Holds and Weight - Weight management is built into Rexx-Adventure, but is not required.  To use the weight management feature, all objects which can contain other objects must have a 'Holds' flag, and all objects which can be moved must have a 'Weight' flag.  The function WeightCheck will return 1 if an object will hold the added weight of a specified object.
  174.  
  175.         For example, the Player object (#1) has a 'Holds' of 10.  The player is carrying a Flashlight (Weight = 1) and a Bowling Ball (Weight 7).  If the player tries to pick up a Lead Pipe (Weight = 4), the WeightCheck function will return a 0 (total weight 12), but will return 1 if he tries to pick up a Newspaper (Weight 1, total weight 9).  
  176.  
  177. Content Lines:
  178.  
  179. Syntax: Content: <Object Number>
  180.  
  181.         The Content list specifies what objects are contained within the current object.  It is very important that the Content list of a container matches the 'Location' flags of the objects within it.  The "DB Check" button which appears in Debug Mode tests all objects for such errors.  If these pointers do not match, objects will not move around properly.
  182.  
  183. Verb Lines and IVerb Lines
  184.  
  185.         These lines define what appears in the "Actions" box.  An object can have an IVerb, one or more Verbs, or neither.  Verbs and IVerbs can not coexist within the same object.
  186.  
  187.         An IVerb is a verb that is automatic.  When there is a door to the north, it makes no sense to click on "North" then have to click on the action "Go".  Go is the only action that can be performed!  Therefore, as soon as the Object "North" is selected, the IVerb is executed, without waiting for input from the "Actions" box.
  188.  
  189.         Verbs are listed in the "Actions" box when an objec is selected.
  190.  
  191. Test Lines:
  192.  
  193. Syntax: Test: <Condition>
  194.  
  195.         Test lines seperate different possibilities of a certain Verb.  For example, an axe can be used to chop wood, but only when there is wood in the room.  The test is a simple comparison, for example "PlayerNum=3", or "GetFlag(1,'LampOn')=1".  If there is only one outcome of a verb, it still must have a test.  Use a condition which is certain to be true, such as "1=1".
  196.  
  197.  
  198. Desc Lines:
  199.  
  200. Syntax: Desc: <Descriptive Text>
  201.  
  202.         Description text is entered as one line per paragraph.  The "Text" box automatically wwraps the text for you.  The text is displayed in the "Text" box.
  203.  
  204. Code Lines:
  205.  
  206. Syntax: Code: <Rexx Instructions>
  207.  
  208.         The body of these lines is executed using the Rexx INTERPRET command.  You use 
  209. Rexx-Adventure functions to move objects, change score, edit flags, and so forth.
  210.  
  211. Debug Mode
  212.  
  213.         The "Options" menu lets you enter Debug Mode.  In debug mode, 3 new items appear on the 
  214. Rexx-Adventure window.  The DB-Check button checks to assure that the database structure is correct.  That is, Object names and Object numbers are properly linked, Flag names and Flag numbers are properly linked, and Content lists match the Location flags of the contents.  The results are displayed in the text window.
  215.  
  216.         Above the "Actions" box is an entry field and a button.  Rexx instructions are entered in the entry field, and Interpreted when the button is pressed.  Note that a syntax error here will crash the enttire Rexx-Adventure program.  This is a feature i put in to debug the data structure, and I thought it may come in handy for others too.  It is not a feature to be used all the time, and I'm not going to put any time into making it bullet proof.
  217.  
  218.  
  219. Appendix 1: Variable Structure.
  220.  
  221.     Obj.0 = the highest object number defined
  222.     Obj.# = Object Name;Object comment
  223.     Obj.ObjectName = #
  224.     Obj.#.!Flags.0 = # of flags
  225.     Obj.#.!Flags.# = Value;Name
  226.     Obj.#.!Flags.Name = #
  227.     Obj.#.!Contents.0 = # of contents
  228.     Obj.#.!Contents.# = Object # of contained object
  229.  
  230.         Either
  231.  
  232.     Obj.#.!IVerb = Implied Verb Name (not really used, but handy)
  233.     Obj.#.!IVerb.!Test.0 = # of tests
  234.     Obj.#.!IVerb.!Test.# = Test Code
  235.     Obj.#.!IVerb.!Test.#.!Desc.0 = # of description lines
  236.     Obj.#.!IVerb.!Test.#.!Desc.# = Descrition Text
  237.     Obj.#.!IVerb.!Test.#.!Code.0 = # of code lines
  238.     Obj.#.!IVerb.!Test.#.!Code.# = code text
  239.  
  240.         Or
  241.  
  242.     Obj.#.!Verb.0 = # of Verbs
  243.     Obj.#.!Verb.# = Verb Name
  244.     Obj.#.!Verb.VerbName = #
  245.     Obj.#.!Verb.#.!Test.0 = # of tests
  246.     Obj.#.!Verb.#.!Test.# = Test Code
  247.     Obj.#.!Verb.#.!Test.#.!Desc.0 = # of description lines
  248.     Obj.#.!Verb.#.!Test.#.!Desc.# = Descrition Text
  249.     Obj.#.!Verb.#.!Test.#.!Code.0 = # of code lines
  250.     Obj.#.!Verb.#.!Test.#.!Code.# = code text
  251.  
  252. Appendix 2: Sample Object, the Steak.
  253.  
  254.         The following is a sample object with extra comments added to explain its setup.
  255. This is part of the 2 room sample adventure 'SAMPLE.RAD'.
  256. ;
  257. ; Object 7, the yummy raw steak
  258. ;
  259. Object:7 Raw Steak
  260. ;
  261. ; Weight checking is in use, and the steak has a weight of 1.
  262. ;
  263. Flag:Weight 1
  264. ;
  265. ; The steak is in the kitchen which is object #2.
  266. ;
  267. Flag:Location 2
  268. ;
  269. ; Note that the steak can not contain anything, and therefore has no Content: lines.
  270. ;
  271. ;
  272. ; Nearly all objects will have a Look verb if they do not have IVerbs instead.
  273. ;
  274. Verb:Look
  275. ;
  276. ; the outcome of a Look is always the same.
  277. ;
  278. Test:1=1
  279. Desc:   The steak is big and juicy.  It is also quite raw.  You wonder how it could be so fresh without any refrigeration.
  280. ;
  281. ; this verb defines the object as pick-up-able.  If an object is stationary, just don't define a
  282. ;"Get" verb.
  283. ;
  284. Verb:Get
  285. ;
  286. ; the function IsHolding(<Object#>) returns True if Object# is contained within object PlayerNum.
  287. ;
  288. Test:IsHolding(7)
  289. Desc:   You already have the steak, silly!
  290. ;
  291. ; IsPresent returns True if the specified object is in the same location as the ObjectNum.
  292. ; Actually, '1=1' would do the same thing, because only objects contained in PlayerNum, and in
  293. ; the same container as PlayerNum are listed, and only listed objects can be selected.
  294. ;
  295. Test:IsPresent(7)
  296. Desc:   You pick up the raw steak.
  297. Code:Call MoveObject 7, PlayerNum
  298. Code:Call AddScore(5)
  299. ;
  300. ; This will never happen.
  301. ;
  302. Test:1=1
  303. Desc:Error, Error will robinson.
  304. Verb:Drop
  305. Test:IsHolding(7) & (GetFlag(1, 'Location') \= 3)
  306. Desc:   You put the raw steak on the nearest suitable surface.
  307. Code:Call MoveObject 7, GetFlag(1,'Location')
  308. Test:IsHolding(7) & (GetFlag(1, 'Location') = 3)
  309. Desc:   You toss the steak to the slavering dog.  He leaps on it like he has not eaten in weeks.  Once he has eaten, the dog seems much friendlier toward you.
  310. Code:Call MoveObject 8, 10 /* send the mean dog to nowhere */
  311. Code:Call MoveObject 9, 3  /* get the happy dog from nowhere */
  312. Code:Call MoveObject 7, 10 /* send the steak to nowhere */
  313. Code:Call AddScore(5)
  314.  
  315.  
  316. Appendix 3: Built in Functions and Procedures
  317.  
  318. Functions: [Syntax: <Variable> = <Function Name>( <Parameters> )
  319.  
  320. GetFlag( <Object#>, <Flag name>)
  321.     Returns the value of the given flag
  322.  
  323. InLocation(<Location #>, <Item Number>)
  324.         Returns a 1 if the <Item> is in the specified <Location>, 
  325.         Returns 0 otherwise.
  326.  
  327. IsHolding( <Object Number> )
  328.     Returns 1 if Object is in the player's inventory.
  329.     Returns 0 otherwise
  330.  
  331. IsPresent( <Object number> )
  332.     Returns 1 of Object is in the same location as the player 
  333.     Returns 0 otherwise
  334.  
  335. ObjectNum( <Object Name> )
  336.     Return the internal number given the object name
  337.  
  338.     NOTE: This only works on unique object names, before the ';'
  339.  
  340. VerbNum(<Object Number>, <Verb Name>)
  341.     Returns the index number of verb <verb name> in object <Object Number>, 
  342.     or 0 if not found.
  343.  
  344. WeightCheck(<Object # to Move>, <Object # of New Location>)
  345.     1) add up the 'Weight' flags of the new location.
  346.     2) if the current weight plus the new object is greater than the 'Holds' flag
  347.         of the new location, return 0, otherwise return 1.
  348.  
  349. Procedures:  [Syntax: Call <Procedure Name> <Parameters>]
  350.  
  351. AddFlag <Object Number>, <Flag Name>, <value to add>
  352.         Adds the <value> to the current value of the specified flag
  353.         and saves the result in the flag.
  354.  
  355. AddScore <number>
  356.     Adds <number> to the 'Score' flag of object PlayerNum.
  357.  
  358. DoIVerb <Object #>
  359.     Checks the !Test level, if a match is found, the !Desc level for
  360.     that !Test is displayed, and the !Code executed
  361.  
  362. DoVerb <Object #>, <Verb #>
  363.     Checks the !Test level, if a match is found, the !Desc level for
  364.     that !Test is displayed, and the !Code executed
  365.  
  366.  
  367. EndGame
  368.     Turns off all windows, and displays 'use file menu to load, restore or quit'
  369.  
  370. FillInventoryBox
  371.     Fills the inventory box with the items contained in object PlayerNum
  372.  
  373. FillObjBox
  374.     Clears the Objects box, and then fills it with the objects in the Location flag of
  375.         Object PlayerNum.
  376.  
  377. FillVerbBox <Object Number>
  378.     Fills the Verb box with the verbs associated with the object <Object Number> 
  379.  
  380. MovePlayer <Destination Object>
  381.     Moves the object PlayerNum to <Destination Object>.
  382.  
  383. MoveObject <Object # moved>, <Object # of New Location>
  384.     1) Add the object moved to the Content level of the new location
  385.     2) Change the 'Location' Flag of the object moved
  386.     3) Remove the Object Moved from the old location
  387.     4) Compress the remaining objects in the Content level of the old
  388.         Location, so that there are no gaps.
  389.  
  390. SetFlag <Object#>, <Flag Name>, <Value>
  391.     Sets <Value> into flag <Flag Name> of object <Object#>.
  392.  
  393. TextDisp <Text to display>, <New page flag>
  394.     This routine places the given text in the display box.  
  395.         If the New Page Flag is 1, a new page is created, otherwise, 
  396.         text is appended onto the existing page.
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.