SCRIPTS.DOC Page 1 ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸ ³ The Magic Gate version 1.08 ³ ³ Documentation May/June '97 ³ ³ (C) Copyright 1995 - 1997 All Rights Reserved ³ ³ Joseph O'Connor ³ ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ; This game may be distributed in its original, unmodified form as long as no money is made off of it. Please do not include the contents of this archive in any CD, collection, or whatever without express written permission of ME! This file was written for all you gamers out there who want to have a custom game going on on your system. Contained within are the secrets of the universe.... No wait, that was the other document, this one has all the information you will need to write areas for Magic Gate. What you will find will shock, will stun, will even AMAZE you, so true believers, sit back and enjoy the ride. ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Introduction: As you may, or may not know, The Magic Gate supports EXternal MODuleS which can be written by anyone in any language whatsoever and you get to mess with drop files and writing your own routines for things I've already done. Don't get me wrong, that is the best route to go if you want to do something totally slick and new. But if you don't need all the bells, whistles and power of say, Turbo Pascal, C++ etc, you can still add something 100% unique to your game. The answer lies within the power of ASCII scripts which can be written with any word processor or text editor. This is new as of version 1.02, but I have written several test scripts to test it as thorough as possible. First I will go through the pre-defined variables and what they reference, then a list of predefined commands, using examples if I feel like it ;) etc... hopefully by the end you will understand enough of the language to write a script. (I need to have more programmer friends, all of the friends I had look at this had their head explode... ) SCRIPTS.DOC Page 2 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ All about Variables: Variables are EVERYWHERE. (Don't make me give examples..) TMG Scripting Language (TMGSL?? whatever) has a bunch of variables, and a bunch of funny looking strings that represent variables. There are 20 variables each, of 80 bytes (characters) in length which can be used to store both numerical and textual data (Don't ask me how it works, it just does). As well as 29 variables which are either 1 (On) or 0 (Off) or 2 (Maybe) (nevermind)... These variables, and their contents can be accessed via escape codes in the ASCII script file. It's example time kiddies! Okay, say you wanted to print how much gold the character currently had on him/her. You would write a line in the script file that looked just like this: Writeln "Gold on Hand : ^CS18" Say the character had 386 gold on had, the line would look like this: Gold on Hand : 386 Amazing, isn't it? Don't worry about each command just yet, the variables are what is going to make the program go... You can check the contents of variables conditionally as well. You could check to see if the player had any creature fights and then perform a certain action easily by doing something like this: If ^CS26 > 0 Writeln "You Have ^CS26 creature fights left today." Endif If the player doesn't have any forest fights left, then the Writeln statement will not be executed, and neither would enything before the Endif. Hopefully the fog is starting to lift from your brain and things have become much clearer. No? Well, this is only Page 2 SCRIPTS.DOC Page 3 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Variables of Gender : ^CA Character Name ^CB male/female, based on sex of character ^CC son/daughter, based on sex of character ^CD his/her, based on sex of character ^CE he/she, based on sex of character ^CF him/her, based on sex of character ^CG sir/ma'am, based on sex of character ^DA Name of Character's master ^DB male/female, based on sex of characters master ^DC son/daughter, based on sex of characters master ^DD his/her, based on sex of characters master ^DE he/she, based on sex of characters master ^DF him/her, based on sex of characters master ^DG sir/ma'am, based on sex of characters master Using just these variables, you can make menus look gramatically correct for EVERY character. Say you wanted to have a few lines of text, whether its in a menu, or in Write/Writeln statements, that gives the person the idea that they are going up to their master and kneeling at his/her feet. Do something Just like this: Writeln " You go up to ^DA and kneel at ^DD feet." Writeln " ^DA acknowledges you and says :" Writeln " 'What can I do for you my ^CC?'" Lets use Martissa as your master, mastissa is female. You are Bob, you are male. These 3 lines would look like this: You go up to Martissa and kneel at her feet. Martissa acknowledges you and says : 'What can I do for you my son?' The pronouns will change based on gender and all that good gramatically correct stuff. That's some pretty nifty stuff, but it doesn't just stop there... I am sure you will need to do a few more things with characters information aside from what their gender is. SCRIPTS.DOC Page 4 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ About Character Related Variables: All of the following commands will give you some sort of information about the character. This all can be used just as has been described before. These can also be modified using the commands in the script. (Like ADD and SET). Obviously, string variables cannot be added to, but can still be SET, (using SETSTR). I don't allow scripts to change : A.)Characters Real Name, or B.)Characters Level in any way shape or form. Some of these variables I don't allow a SET command to be used on simply because I'd rather you just Added to and subtracted from. There are only three (Attack,Defense, and Damage Reduction) so when you go to Set ^CS03 4500 and it doesn't do anything, you'll know why. The following is legal, though Add ^CS03 4500 It will add 4500 to attack, so I'm relying on you script writers not to make the game too easy. Some of the variables work differently whether you are modifying it or just displaying it. The variable for guild is a good example. ^CS09 Will give you the name of the guild when used in a Write/Writeln but the guild number is used everywhere else ^CS09 is found. Refer to the next page for details on all the variables. SCRIPTS.DOC Page 5 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ ^CS Variables : Their Numbers and their Meanings ^CS01 Name (same as ^CA) ^CS02 *Real Name* You cannot modify this variable at all. Can only use in a Write type command or comparison. ^CS03 Attack Value You cannot use the Set command on this variable ^CS04 Defense Value You cannot use the Set command on this variable ^CS05 Damage Reduction Value You cannot use the Set command on this variable ^CS06 Charm ^CS07 Shame ^CS08 Luck ^CS09 * Guild* When used in a Writeln, it will display the name of the guild. You cannot use the Add command on this variable When used in a Set, it is the guild # (Included in case you want your script to say kick a character out of their guild, or only allow guilded characters into a certain area) ^CS10 Hit Points (Curr) ^CS11 Hit Points (Max) ^CS12 Current attack value of Equipped Weapon (See ^CS29 for max) Note : Increasing Weapon Value does not increase Attack Value ^CS13 Name of currently Equipped Weapon ^CS14 Current defense value of Equipped Armor (See ^CS30 for max) Note : Increasing Armor Value does not increase Defense Value ^CS15 Name of currently Equipped Weapon ^CS16 Current resistance value of Equipped Shield (See ^CS31 for max) Note : Increasing Shield Value does not increase Damage Reduction ^CS17 Name of currently Equipped Weapon ^CS18 Gold on Hand ^CS19 Gold in Bank ^CS20 Gems ^CS21 Experience ^CS22 *Characters Level* You cannot modify this variable at all. Can only use in a Write type command or comparison. ^CS23 # of Skill Uses Curr ^CS24 # of Skill Uses Max ^CS25 *Characters Current location* When used in a Writeln, the first character is ignored as it is used to denote what type of zone the character is in. You cannot use the Add or Set command on this variable When used in a Location command, you must include the zone type character (i.e. you would have Location "gGraveyard of Souls" as opposed to Location "Graveyard", it just wouldn't display right) ^CS26 # of Creature Fights Left ^CS27 # of Player Fights Left ^CS28 Class Only gives the current class of the character (Thief, Ranger etc) ^CS29 Maximum attack value of Equipped Weapon (See ^CS12 for curr) Note : Increasing Weapon Value does not increase Attack Value ^CS30 Maximum defense value of Equipped Armor (See ^CS30 for curr) Note : Increasing Armor Value does not increase Defense Value ^CS31 Maximum resistance value of Equipped Shield (See ^CS31 for curr) Note : Increasing Shield Value does not increase Damage Reduction SCRIPTS.DOC Page 6 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ About Script Related Variables: What is a program that doesn't communicate with itself? If it doesn't know if you've opened the door, how is it supposed to know whether or not you can go through it? Script Related variables fill this gap quite nicely. You should have more than enough variables to do whatever you need to do in a script. There are 20 variables that can be displayed/set/setstr/add/mult whatever you want to do til your heart's content. Each variable can contain up to 80 bytes, which is more than plenty for any number you may want to store, or just right if it is going to be used for output to the player. There are 29 more variables that are either 0 or 1 (False or True) (boolean if that means anything to you) that can be used as flags to let the script know that something has been performed (without having to waste a ton of variable space on it). The script related variables are accessed just like character based variables except they all start with ^VR. ^VR01 Script Variable #1 ^VR02 Script Variable #2 .... .... ^VR19 Script Variable #19 ^VR20 Script Variable #20 Note again that you must have a leading 0 for 01-09. Well, those aren't the only variables that start with ^VR.... there are really more variables that have the prefix ^VR... They are special in that you cannot use them in the Set/Setstr/Add/Mult command. They contain certain parameters about the game that have been set. As you will learn, script files can read in external creature files. The script knows which file to read by reading the command : CreatureFile NAME.EXT somewhere in the script file (I would suggest putting it in the @#Define section (which you will learn about later). That creature file-name is stored as ^VR22. There is a command called DefaultCommand that is used to set up what input defaults to when a prompt comes up. Say you perfrom a DefaultCommand L. Anytime thereafter a prompt comes up, if the player just hits enter, the input will actually be L. This will be the case until the DefaultCommand is called again. The default command is stored in ^VR21. To sum it up, the "special" variables are : ^VR21 The current default command. This command is set using the DefaultCommand command ^VR22 The current creature file to read creatures from. This command is set using the CreatureFile command ^VR23 Stores the Character Boolean flags. (See the ^GF variables) ^VR24 The current menu file to read menus from. This command is set using the MenuFile command ^VR25 The current item file to read items from. This command is set using the ItemFile command Note : These commands can only be used in a Write/Writeln/ or comparison. (See the corresponding command in the commands section for more details) SCRIPTS.DOC Page 7 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ About Boolean Variables: Remember I talked about those variables that could be 0 or 1? Well, I call those Game Flags, hence the reason they are accessed using the ^GF prefix. There are currently 29 of those available (believe it or not, that is not just an arbitrary number). These can be used for numerous things. I use them to tell the script whether the player has performed a certain action or not. Like for instance, whether they have examined the door in the room or not (hint if you need it in The Crypt of Lord Hamilton)... This type of variable cannot be used in Add/Setstr, but can be used in Set/Write/Writeln/or comparisons. Note, that it can only be set to 0 or 1. Note again that you must have a leading 0 for 01-09. ^GF01 Game Flag #1 ^GF02 Game Flag #2 .... .... ^GF28 Game Flag #28 ^GF29 Game Flag #29 Any ^GF variable can only be 0 or 1 (maybe 2, but I wouldn't push it, the computer may decide it doesn't want to compute anymore ;) ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ About Boolean Variables - The Character Flags : Each character has a series of flags that the game keeps track of (29 to be exact... hmmm, haven't I seen 29 of something before? hint : 29 is the limit of booleans available in a longint :) Anyway, these are alot like the Game Flags I just talked about, except that these are used by the main portion of the game as well, and stored in the character file. There really isn't a need to be setting these, but it is okay to look at them (to see if say, the character is drunk ;) and use them in a script. They are accessed using the ^CX prefix. This variable will be either a 0 or a 1. Note, a leading zero is necessary for 01-09. ^CX01 Character Flag #1 ^CX02 Character Flag #2 .... .... ^CX28 Character Flag #28 ^CX29 Character Flag #29 SCRIPTS.DOC Page 8 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Construction of a script: Scripts are pretty easy-going as far as layout goes. The sections do not need to be in a particular order, upper/lowercase is ignored for section names and variables etc. Sections are defined in the script file by putting the characters @# at the start of a line and the section name of the script immediately following. If I wanted a section for fighting creatures in my script, I might call it Fight and would therefore have a section in my script defined as the following : @#Fight To designate the end of the file, put a @# as the last line in the script. While the physical order of the sections in the script file has no bearing on its functionality, there is a certain order of execution that is built into the interpretter. The script begins execution by looking for the @#DEFINE section. It is not necessary to have a define section, but this section is special in that it is only looked at once, and therefore, any variables that are to be used to keep track of something important should be initialized here. Also, using the Location command in the define section is a good idea so that the character doesn't appear to be stuck at the town square . I would also set the inital CreatureFile here so you don't forget to do it. There are some section names that have a special meaning to the script language. I've already mentioned the define section. The Define section is the first section the game looks at in a script. After it reads and executes all the commands in the Define section, it jumps to the section in the script with the name "Main" (without the quotes) and begins the main section of the game. NOTE : Every section in the script file that is to be executed can be thought of as a never-ending loop, and without a return or a halt command somewhere within the section, you will never leave it. (exception @#DEFINE) *** NEW 1.07 *** As of version 1.07, the MagiCfg program contains a new section used for ExMod additions and removals and modifications. It is possible to add any program under the TMG directory to the 'Other Realms' menu using this feature. In addition, built in is the ability to read either the script or a special description file to retrieve both the name of the ExMod and the description and add those to the Other Realms menu. To accomplish this within a script is simple. Add a section to the script that looks like the following example: @#INSTALL <...> <...> @#OTHER_SECTIONS SCRIPTS.DOC Page 9 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ It is nearly as easy to do this for programs that do not end in .SCR which include compiled scripts, Executable programs and/or batch files. Create a file with the same name as your program but use a .DSC extension. Within that file include the following: @#INSTALL <...> <...> @# Looks just like the example for the scripts because it actually reads it the exact same way. If this method was not included with a ExMod then it installs the ExMod with a generic name and no description. These can then be easily modified. ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ @#MONSTER Another section name the game could look into is @#MONSTER which is where you define any monsters internal to the script. NOTE : Using internal creatures is the only way to guarantee exactly which creature a character will fight at any given time, so if you have a "boss" at the end of your script, make him/her an internal creature. The following is how you would define an internal creature. The second word on any of the lines must be the creatures internal number (The number you pass to Combat when you want the player to fight an internal monster. STATS NAME "" WNAME "" ANAME "" DEATH "" Those lines do not have to be in any particular order (I just remember them that way ;) But you must have all 5 lines present to get a complete monster. ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ @#ITEMS As of Version 1.07, there is another "special" section in a script file : @#ITEMS This is where you will define all the items that are going to be given away in your script. The following is how you would define an item. The second word on any of the lines must be the items number (The number you pass to Item when you want to give that item to the player). These numbers have no meaning at all outside the script, it is just for internal reference. NAME "" SCRID "" STAT1 attack maxattack cost charges wear_location STAT2 required_level item_flags identified? SCRIPTS.DOC Page 10 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Item Definitions: Okay, and so you know what those values should be, here are their definitions. Item Name - This is the name the character sees in his inventory and is used for all display purposes. Item ScriptID - This is a unique code that you (the creator) assign to the item you create. This is what it will be referenced with in the database file. The standard formula for this should be as follows: LLLL-MMDDYYYY-LL-L LLLL is 4 characters to identify the item MM is the 2 digit month the item was created DD is the 2 digit day of the month the item was created YYYY is the 4 digit year the item was created LL are the creators initials L is either Y or N - Y allows other items to access your items scripts as if they were its own. N means nothing else can use the scripts for this item. Attack - The value the item adds to your combat value. This is the attack value for weapons, defense for armor, and damage resistance for shields. This should be 0 for all non weapon/armor/shields. MaxAttack - The maximum value the item can add to your combat value. (see Attack above for more information as well.) Cost - What you would pay for this item if you were to buy it in one of the shops. (also what selling it is based upon) Charges - This is how many times the item can be used. Charges are subtracted from the item on any "USE", "ONDEATH", or "USECOMBAT" When the last charge is used, that fires the "LASTUSE" script if the item has one Wear_Location - What type of item is this, and where can I equip it? This will be a number that corresponds to one of the following: 1 - Head 6 - Feet 2 - Neck 7 - Weapon 3 - Armor 8 - Shield 4 - Hands 9 - Treasure 5 - Ring 10 - Other Required_Level - The level the character must be to use this item. Item_Flags - These are miscellaneous special effects that the object can have, and can be used to make the item unique 1 - Item Disappers on its final use (potions etc...) 2 - Silver (useful against werewolves etc) 4 - Magic +1 (certain monsters require at least a magical 8 - Magic +2 item to be hit. Monsters will have the 16 - Magic +3 same flags for to be hit.) (more to come) Identified - Does the character recognize this item for what it is as soon as he/she gets it, or do they need to Identify it? Values for this are: 0 - Not Identified 1 - Identified SCRIPTS.DOC Page 11 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Setting up Item Scripts: There are currently 10 different actions you can apply to your items. They are in their own section of the script denoted with the following syntax @#ITEM_ ...... ...... @#ITEM_ etc.. Where NUM is the item number as it is defined in the @#ITEMS section (NAME 1 "Sword of Killing" would be designated as @#ITEM1_) and where is on what type of event the script for that section goes off. The list of Actions is as follows : WEAR *ONATTACK USECOMBAT USE *ONDAMAGE IDENTIFY REMOVE **ONDEATH LASTUSE DROP *This command is not yet implemented, but here to show how much can be done with the system **This command currently only triggers on death in a creature fight (not a master level up fight or a player fight) Example of a Potion of Healing: @#ITEMS NAME 1 "`2Potion of Healing" SCRID 1 "PofH-04111997-JO-N" STAT1 1 0 0 2500 1 10 STAT2 1 1 1 0 @#ITEM1_USE Writeln "`3 You take a drink of the Potion of Healing and a warm fire" Writeln "shoots through your body. It magically heals your wounds and" Writeln "completely heals you." Set ^CS10 ^CS11 @#ITEM1_USECOMBAT Gosub USE @#ITEM1_IDENTIFY Writeln "`3 The Potion of Healing will restore your Hit Points to Maximum when" Writeln " the potion is used." Writeln "`9 (`%Heals all wounds`9)" @#ITEM1_LASTUSE Writeln "`9 (`%The vial is now empty`9)" This item would have the following information: Name : (Green)Potion of Healing(Green) Script ID : PofH-04111997-JO-N Attack : 0 Max Attack: 0 Cost : 2500 # Charges : 1 Worn at : Other Req. Level: 1 Flags : Disappears after its last use Ifentified: No Scripts : USE USECOMBAT IDENTIFY LASTUSE SCRIPTS.DOC Page 12 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Example of a script: @#Define CreatureFile MYGRAVE.DAT Set ^VR19 0 Set ^VR20 0 Location "gMt. Dead Graveyard" @#MAIN_MENU EGL `c `%Gates of Mt. Dead : `#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- `9 You stand before the looming gates of Mt. Dead, the notorious place to `9 find all manner of creature living or dead. Can you handle what this `9 place will throw at you? `3 `3 (`#E`3)xamine the Gates. `3 (`#G`3)o Boldly In. `3 (`#L`3)eave this scary place. @#MAIN Menu MAIN_MENU Writeln "" Writeln " `%Mount Dead :" DefaultCommand G ReadMenuCommands ^VR01 Writeln "^VR01" If ^VR01 == E Writeln "`! You see nothing unusual about the gates." Endif If ^VR01 == G Gosub DEAD1 Endif If ^VR01 == L Halt Endif If ^VR01 == R DisplayRanks Endif If ^VR01 == V DisplayStats Endif If ^VR01 == F FindPlayers Endif @# Note : The section that contains the menu and the section that contains executable code are defined the exact same way. The only difference is the way they are accessed. A Menu is brought to the user and displayed through use of the Menu command, a sub-section is made current with the Gosub/Return Command. SCRIPTS.DOC Page 13 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Index: Command Page Add................................................................ 14 Combat............................................................. 14 CreatureFile....................................................... 15 DefaultCommand..................................................... 15 DisplayCreatures................................................... 15 DisplayGameStats................................................... 16 DisplayMenu........................................................ 16 DisplayRanks....................................................... 16 DisplayScriptInfo.................................................. 17 DisplayScriptText.................................................. 17 DisplayStats....................................................... 17 FindPlayers........................................................ 18 Gosub.............................................................. 18 GotoXY............................................................. 18 Halt............................................................... 19 Healer............................................................. 19 If/Endif........................................................... 19 Inventory.......................................................... 20 Item............................................................... 21 ItemFile........................................................... 21 Location........................................................... 22 Mail/MailCommands/EndMail.......................................... 22 Menu............................................................... 23 MenuFile........................................................... 23 MessageBoard....................................................... 23 MonsterAvailable................................................... 24 Mult............................................................... 24 Pause.............................................................. 24 Random............................................................. 25 ReadChar........................................................... 25 ReadLine........................................................... 25 ReadMenuCommands................................................... 26 ReDispMenu......................................................... 26 Return............................................................. 27 Set................................................................ 27 SetStr............................................................. 27 SharedEvent........................................................ 28 Write.............................................................. 28 Writeln............................................................ 29 WriteBlock/EndBlock................................................ 29 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Flag Related Commands AddFlag............................................................ 30 RemoveFlag......................................................... 31 FlagValue.......................................................... 32 SCRIPTS.DOC Page 14 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : Add ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Add Description : Adds the amount specified in the second parameter to the variable specified in the first parameter. Notes : can be any type of variable from the ^VR or ^CS fields that contains an integer value. There are also a few other fields which are excluded. can be a literal (i.e. 2, 8, 32000 etc.) or it can be a variable from the ^VR or ^CS or ^GF fields that contains an integer value. A negative sign in front of the literal, or variable will tell the routine to SUBTRACT the amount from the variable. Exclusions : cannot be : ^CS01 ^CS02 ^CS09 ^CS13 ^CS15 ^CS17 ^CS22 ^CS25 Examples : Add ^CS18 320 Add ^CS10 -5 Add ^CS10 -^VR03 (Assuming ^VR03 has an integer in it) Add ^VR18 ^CS26 Combat ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Combat Int/Ext | Description : Puts the player into combat versus a creature. Saves the result of the combat in . Variable will be : 0 : Character ran away from creature. 1 : Character defeated creature. 2 : No creature was available (level/ error) Notes : This is the one routine where you can have a ^GF variable equal to 2. I would not suggest doing it on a frequent basis, but, it does the job. Int/Ext, set to Int and include the to have the creature the player fights to be a specific creature in the @#MONSTERS section of the script file. Set to Ext to have the script pick a random monster of the players level from the filename stored using CreatureFile. Exclusions : Don't use any of the ^CS variables as the That's just asking for trouble. Examples : Combat ^VR19 Ext Combat ^GF26 Ext Combat ^GF29 Int 1 Combat ^VR14 Int 8 SCRIPTS.DOC Page 15 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : CreatureFile ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : CreatureFile Description : Assigns the external file to read creatures from when a Combat Ext command is executed. Notes : Usually this will not change throughout the course of the script. I recommend putting this command in the @#Define section of the script to avoid executing it every loop. Examples : CreatureFile FOREST.DAT CreatureFile CRYPT.DAT DefaultCommand ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DefaultCommand Description : Assigns what command is chosen when the player strikes enter at the input lines thereafter. Notes : can be any variable, including menu commands ^MC##, ^GF##, ^CS##, ^VR##. If the default command is set to more than one character and a ReadChar is encountered, only the first character in will be executed. Examples : DefaultCommand L DefaultCommand ^MC02 DefaultCommand ^CS18 (Will make the default command the amount of gold they have on them (good for donations)) DefaultCommand ^VR12 DisplayCreatures ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DisplayCreatures Description : This command will bring up a display of all the creatures currently loaded into the script. Notes : This command is here for test purposes really. Use it when you want to see what creatures are available for the combat routine (Currently only works with EXTernal creatures) SCRIPTS.DOC Page 16 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : DisplayGameStats ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DisplayGameStats Description : This command will bring up a display of all the statistics of the game, saved in the MAGISTAT.DAT file. Notes : This command includes most any stat about the game you would want or need to know, including how many characters are in the game, deletion period etc. DisplayMenu ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DisplayMenu Description : This command will display the menu loaded into into the current section of the script to the player. Notes : This command is best used after the ReadMenuCommands command in an If statement. I have always used ? as the command to redisplay the menu Example : Menu Main_menu ReadMenuCommands ^VR01 If ^VR01 == ? DisplayMenu Endif DisplayRanks ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DisplayRanks Description : This command is used to display the rankings of the players to the player. Notes : This is a call to the same command the main part of the game calls. I would use an R as the command to display the ranks. Example : Menu Main_menu ReadMenuCommands ^VR01 If ^VR01 == R DisplayRanks Endif SCRIPTS.DOC Page 17 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : DisplayScriptInfo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DisplayScriptInfo Description : This command should be used for debugging a script. It will display the section of the script it is currently running, the creature file, the current default command and the contents of the 49 variables. Note : Do not include this in the final version of the script as it could give a player quite a bit of insight into the script (which it does give) DisplayScriptText ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DisplayScriptText Description : This command should be used for debugging a script. It will display the actual text in that section of the script. Note : Do not include this in the final version of the script as it could give a player a look at all of the commands in the current section. This is good for figuring out if something is out of place in the script. Example : Menu Main_menu ReadMenuCommands ^VR01 If ^VR01 == - DisplayScriptText Endif DisplayStats ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : DisplayStats Description : This command is used to display the statistics of the character to the player. Notes : This is a call to the same command the main part of the game calls. I would use a V as the command to display the stats. Example : Menu Main_menu ReadMenuCommands ^VR01 If ^VR01 == V DisplayStats Endif SCRIPTS.DOC Page 18 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : FindPlayers ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : FindPlayers Description : This command is used to display the current location of all players currently in the game. Notes : This is a call to the same command the main part of the game calls. I would use a F as the command to display the stats. Example : Menu Main_menu ReadMenuCommands ^VR01 If ^VR01 == F FindPlayers Endif Gosub ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Gosub Description : This command is used to jump from one section in the script file to another. Notes : This is a great way to seperate "rooms" in the game, or put a commonly used set of commands in its own section and have whatever needs to access it call it with a Gosub/Return (see the corresponding section on Return as well). Be sure not to gosub to a section you have written as a menu section. Example : Menu Main_menu ReadMenuCommands ^VR01 If ^VR01 == D Gosub DoSomething Endif If ^VR01 == K Gosub KillSomething Endif GotoXY ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : GotoXY Description : This command jumps the cursor to the screen coordinates specified in the X and Y coords. Note : This can be used to make screens with text placed anywhere necessary without using a ton of Writeln "" 's. Example : GotoXY 1 1 This will take the cursor to the home position. SCRIPTS.DOC Page 19 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : Halt ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Halt Description : This command is used to stop the execution of the script. Notes : Halt can be placed anywhere in the script as well as as many occurances of it as are necessary. Healer ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Healer Description : This command will take the character to the healers hut and return them exactly where they were when they entered. Notes : This is a call to the same command the main part of the game calls. If/EndIf ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : If Description : These commands are used to make a decision within the script. Notes : This command is a major portion of what a script does. It can determine what letter is stored within a certain variable, whether a characters hit points/level/luck is equal to or less than, or greater than a certain number/variable. Variables of all types are allowed on BOTH sides of the operator. Operater is one of the following If a == b a is equal to b If a <> b a is not equal to b If a >= b a is greater than or equal to b If a <= b a is less than or equal to b If a > b a is greater than b If a < b a is less than b Note that there must be 3 seperate "words" on the line (A space must exist between the variables and the operator) If a statement is found to be true, everything until the next EndIf is executed. If it is false, the script finds the command immediately following the next EndIf and begins executing from that point onward. SCRIPTS.DOC Page 20 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : If/EndIf continued. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Notes : If can be used to compare all manners of variables, whether they contain numbers or strings, it will work with it. Be warned though, the only operators that you should used with string are the == and the <>. You can use the other operators with strings, but if you are not sure of what you are doing, you may get unexepected results. Example : Menu MainMenu ReadMenuCommands ^VR01 Writeln "^VR01" If ^VR01 == A Writeln "Hey, you hit A" Endif If ^VR01 == L Writeln "Hey, you hit L" Endif If ^VR01 >= 1 If ^VR01 <=9 Write "^VR01 squared = " Mult ^VR01 ^VR01 Writeln "^VR01" Endif Endif Inventory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Inventory Description : This command brings up the (Y)our Inventory screen that is accessible from the main menu and allows you to identify, equip, remove, and drop items. Notes : This command should be accessible from any main menu within a script file. SCRIPTS.DOC Page 21 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : Item ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Item [NODISPLAY] Description : This command gives the character the item in the script that is specified by . Notes : This item must exist in the @#ITEMS section of the script or the @#ITEMS section of the file specified in the ItemFile command (see ItemFile). If the item has never been given out before, the game will create an Item Registry entry for it in ITEMS.DAT and will create the script to go along with the item in the items/ subdirectory. See the section on Item Definition for full details on how to create the item definition a script file. If you put a NODISPLAY as the second parameter (after the item number), TMG will _NOT_ output anything to the user, but will let your script do all of that. Example : Item 1 Item ^VR04 Item 3 NODISPLAY ItemFile ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : ItemFile Description : Assigns the external file to read item from when an Item command is issued (see Item) Notes : Usually this will not change throughout the course of the script. I recommend putting this command in the @#Define section of the script to avoid executing it every loop. Examples : ItemFile FOREST.ITM ItemFile CRYPT.ITM SCRIPTS.DOC Page 22 ÄÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ Command Descriptions : Location ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Syntax : Location "" Description : This command sets the characters location to whatever is contained within the quotation marks. Notes : The area type character must be included in this command. The available area type characters are : B -Generic Building C -Cave D -Dungeon F -Forest G -Graveyard H -Guild Hall K -Castle M -Mountains R -Road S -Shop T -Town I -Inventory The Location of the character can change as often as you need it to. This can be useful in case you are writing a script as say a forest, and you have a main boss that you want the all character to fight without the special ranger power for the forest, set the location (temporarily) to "T