(This is the "Dungeon Designs" column from the March 1993 issue of the Eamon Adventurer's Guild newsletter. Copyright 1993 Eamon Adventurer's Guild, 7625 Hawkhaven Dr., Clemmons, NC 27012-9408. You may reproduce this freely as long as this credit remains attached to the article.) Adding a New Command by Tom Zuchowski While the version 7.0 MAIN PGM has a fairly complete basic command set, sometimes you need to add extra commands to get the play that you desire. Let's set up a simple example and then step through the procedure. Let's say that part of the quest requires that the player be able to TALK to a certain denizen of the dungeon. This scenario needs to have the command TALK added to the command list. For the sake of simplicity in this example, let's say that only one monster actually has something to say, and that this is monster #12. Let's make this monster's comments Effect #6. The required syntax for this command will be TALK (MONSTER). First, let's write the code for the new command: 35000 REM TALK 35010 GOSUB 4900: GOSUB 4700: IF NOT F THEN 96 35020 IF M = 12 THEN R = 406: GOSUB 45: GOTO 98 35030 PRINT: PRINT "YOU EXCHANGE "; 35040 IF M%(M,11) = 1 THEN PRINT "INSULTS." 35050 IF M%(M,11) > 1 THEN PRINT "PLEASANTRIES." 35060 GOTO 98 Let's examine this, statement by statement: 35010: GOSUB 4900 (Check to make sure that a specific object has been named in the command.) GOSUB 4700 (Find out if the Monster named is in the room, and what his number is in the monster database.) IF NOT F THEN 96 (If the routine at 4700 cannot find a match between the object and the name of any monster present in the room, it returns with F = 0. If no match was found, jump to line 96, which prints NOBODY HERE BY THAT NAME!) 35020: IF M = 12 THEN R = 406 (If the routine at 4700 finds a match, it returns with M = the monster number. In our example, the only monster that has anything to say is monster #12. Effects are stored in EAMON.DESC at records 401-600. Effect #6 is record #406.) GOSUB 45 (This is the routine that gets text from EAMON.DESC and prints it.) GOTO 98 (Exit the routine. This exit prints a blank line and updates the screen pause line counter.) 35030: PRINT: PRINT "YOU EXCHANGE "; (Print this text when M does not equal 12 so that the player gets a response to his command.) 35040: IF M%(M,11) = 1 THEN PRINT "INSULTS." (If the monster is an enemy.) 35050: IF M%(M,11) > 1 THEN PRINT "PLEASANTRIES." (If the monster is not an enemy.) 35060: GOTO 98 (Exit the routine. This exit prints a blank line and updates the screen pause line counter.) OK, that is our new command. Now we have to integrate it into the command list. The number of basic commands (32) is stored at line 31910, and the commands are listed at line 31920. To add TALK, we must increase the number at 31910 by one and add the command at line 31930: 31910 DATA 33 31930 DATA TALK TALK will now be listed as the very last command in the command list and will be recognized by the command parsing routine at line 200. The only thing left to do is to add the line number of the routine to line 290 so that the command parser will know where it is: 290 ON C GOTO 3000,3000,3000,3000,3000,3000, 4000,5000,6500,6000,7000,8000,9000,10000, 11000,12000,13000,14000,15000,16000,23000, 17000,18000,19000,20000,21000,22000,24000, 25000,26000,27000,28000,35000 Note that the numbers in line 290 must be in exactly the same order as the commands in lines 31920-31930! That's it! We now have a working TALK command! _____ OK, that covers new commands involving monsters. The code for commands involving artifacts is much the same, except that the artifact search routine is at 4800 instead of 4700, and the routine at 4800 has several entry points. Let's look at the differences from the above code. It's identical except for the GOSUB 4700. The artifact search routine compares to three "locations": HA, WH, and EM. The defaults are: HA = - 1 (held by player) WH = RO (visible in room) EM = RO + 200 (embedded in room) GOSUB 4801 if the player must be holding the artifact for the command to work. (eg: DROP). GOSUB 4804 if the command works whether the artifact is being held, is in the room, or is still embedded in the room (eg: EXAMINE). HA = RO: GOSUB 4805 if the artifact must be in the room or embedded in the room but not held by the player (eg: GET). HA = - 999: EM = HA: WH = HA: GOSUB 4810 You can also define your own special "locations" to be checked. The example above is from the REMOVE command, which requires that the artifact to be acted on be worn by the player (- 999). This can be any number that you choose to use. _____ There are several optional exits from your routine. The two main ones are: GOTO 98 prints a line, increments the line counter by three, and proceeds to the monster melee code at 300. GOTO 99 is the same as GOTO 98 except that it proceeds to the YOU SEE code at 100 instead of the monster melee code. If the routines at 4700 and 4800 do not find a match to the object and return with F = 0, you have several optional exits: GOTO 91 "YOU AREN'T CARRYING IT." GOTO 92 "YOU MUST FIRST OPEN IT." GOTO 94 "YOU CAN'T (player's command) (eg: YOU CAN'T WEAR TABLE) GOTO 96 "NOBODY HERE BY THAT NAME!" If none of these four error messages quite fit your new command, you can use your own error message and exit through a GOTO 98 or GOTO 99. Let's recap by looking at some examples from the regular commands: Drop: 5010 GOSUB 4900: IF S$ = "ALL" THEN 5100 5030 GOSUB 4801: IF NOT F THEN 91 Examine: 6010 GOSUB 4900: GOSUB 4804: IF NOT F THEN 6040 6040 GOSUB 4700: IF NOT F THEN PRINT "YOU SEE NOTHING SPECIAL": GOTO 98 Get: 4010 GOSUB 4900: IF S$ = "ALL THEN 4200 4020 HA = RO: GOSUB 4805: IF NOT F THEN 94 Remove: 26010 GOSUB 4900: HA = -1: WH = RO: EM = - 999: GOSUB 4810: IF NOT F THEN 94 Attack: 7020 GOSUB 4900: GOSUB 4700: IF F THEN 7300 7030 HA = RO: GOSUB 4805: IF NOT F THEN 94