An Introduction To AberMud5 Universe Generation and Table code -------------------------------------------------------------- Written by David Beynon at about 1:30 am (i gave up at about 3) The abermud 5 universe consists of items and database tables. The items can have the properties of room, object, player etc but they can all be treated in the same way by database code which i will discuss in more detail later. Basic Object Creation All objects in abermud 5 are basically defined by an adjective and a noun. If for example i want to create an object called "the blue anorak" (for sad types) i would do it like this. >addadj blue >addnoun anorak >create blue anorak >beobject anorak When you enter the object editor use it to enter long and short descriptions for the item, you can also set its size and weight. Ignore the flags option and leave the item in state 0 as i will explain those later. It is often usefull to give your own name as the objects location. >setoflag blue anorak canget >setoflag anorak canwear Bitflags There are a number of types of bitflags that can be set and unset, these are described as follows. Pflags describe the properties of player items, Rflags control rooms, Oflags control objects and Cflags control containers. In general a flag is set using something like this where the command can be setoflag, setrflag, setcflag or setpflag. A flag is unset by using the command with -. The uses of all the flags are described in detail in the reference guide. Basic Player Creation Creating a player is slightly more complicated. In the next example i will show you how to create a player capable of fighting if attacked. The player object is a pogo stick. >addadj pogo >addnoun stick >create pogo stick >beplayer stick >place stick me and to set its in/out/here messages >msetin pogo stick bounces in springily >msetout pogo stick bounces away >msethere pogo stick hops up and down in the corner >setaction pogo stick 2 The setaction command informs the pogo stick that it is to behave like a player. Now your average pogo stick is made of metal so it quite likely to be hard to kill i have decided to reflect this by giving it a high level. >setplevel pogo stick 15 >heal pogo stick >drop pogo stick Basic Room Creation One of the most important parts of mud creation is the generation of rooms. This can be done in much the same way as the creation of any object. I will give an example anyway. >addadj sad >addnoun room >create sad room >setshort sad room The Sad Room >setlong sad room You are standing in a room that appears to be a shrine to all things sad. A huge Mr Blobby poster covers one wall and the floor is covered with old Bros albums. You sense that whoever lives here is in desparate need of a life. And just to complete the atmosphere.... >place pogo stick room >place anorak room It is an idea to always leave two blank spaces at the end of a room description so that if you have an object flagged as flannel then it sticks neatly onto the end of the room desc as it is not always possible to put spaces at the start of an objects description. One absolutely vital item is the exit. In abermud 5 they come in 3 types. The standard exit, the message exit and the conditional exit. A standard exit is just that. A message exit displays a message to anyone who walks through it and a conditional exit runs a database table to decide whether you should be permitted to pass or not and what will happen to you. Standard exits are created with the command newexit A message exit is created with the command msgexit NB the message appears before the description of the new room. Conditional exits are created with the command condexit the table controlling the exit should be terminated with DONE if you are to be permitted past or NOTDONE if it deems you unworthy (see table code section) Database Table Code Nearly everything in the abermud 5 universe is controlled by a set of database tables. A number of commands for the editing of tables is given below. listtables - lists existing database tables edittable
- edit a table newtable - create a new table finditem - find references to item in tables Table Editor commands: f [noun] [noun] - find all occurences of the given combination d - delete a line from the table e - edit a line i - insert a line l - list lines between start and end q - exit editor Consider a line in the main command table. Suppose we have one that runs along the lines of this. ROB ANY ANY IF1 ISPLAYER $1 NOT CHANCELEV 5 MESSAGE {Your Attempt Failed} DOESTO $ME {attempts to steal some money from} $1 4 DONE The first part of this statement (ROB ANY ANY) is split into 3 parts, the verb (ROB), item 1 and item 2. The line will be processed if the verb entered is rob. The any any means it will accept anything for the rest. The next command (IF1) checks that item 1 is in fact a genuine item in your presence. The NOT statement is simply a boolean command that inverts the logic of the following command. The only other command of interest in the line is DONE. This causes the processing of the table to cease immediately, returning to the execution of the previous table if applicable. If any database command returns logical FALSE (ie fails) then the following commands in the statement will not be executed. The most useful item references for table coding are $ME $AC $1 $2 and $. $1 is the first item mentioned after the verb, $2 is the second and $ is the text string. $ME is the current player and $AC is best left until i get onto DAEMONS. Example 1: I want a command for wizards called tohand. It will place an item in the hands of a wizard. This is a very basic version of the command - it can be done far more cleverly. >addverb tohand >edittable 0 I would find a suitable place in the table and add the following TOHAND ANY ANY NOT LEVEL 16 message {Begone small person!} DONE TOHAND ANY ANY WHATO 1 NOT IF1 message {No Such Item!} DONE TOHAND ANY ANY PLACE $1 $ME PNAME $1 MESSAGE { appears in your hand.} DONE The command WHATO searches the entire game universe for an item matching the adjective, noun pair given to the games parser, this is used if you want a command to work with an item that is not in the vicinity of the player. A very common error made by most coders at some point results in a message being sent to everyone on the mud informing them of an INVALID ITEM REFERENCE as it so subtly describes it. This simply means that the server has no idea what you are trying to perform a database action on and so decides to do it on $ME - ie the current player instead, errors of this type can invariably be traced to a missing IF1 or IF2 in a table. Creation of Mobiles and Other Nasties A mobile is a player that is controlled by the database tables. This requires a table to run and control the mobiles actions. In this section i will give basic instructions for the creation of your first mobiles. The first thing to do is create a new table for the mobile. I think that a mobile that stands still and attacks people would be nice. >newtable 1000 NastyBeast >edittable nastybeast Then add the lines... COMMENT ANY ANY COMMENT {Table for the control of stationary nasties - 90 % chance of them attacking every 3 seconds} ANY ANY ANY ISUSER $ME WHEN 3 NastyBeast done ANY ANY ANY CHANCE 90 HDAEMON $ME SMASH PROVOKE ANY ANY ANY ANY WHEN 3 NastyBeast done The table first decides if $me is a game user - not a totally silly question as archwizards can attatch to mobiles. If the user is a human then the table is called again 3 seconds later and terminated. If the user is not human then there is a 90 % chance of the daemon SMASH PROVOKE running on all the people in the vicinity of the mobile. To make a mobile table for things that wander around and attack people you would want something like this... >newtable 1001 wanderkill ANY ANY ANY ISUSER $ME WHEN 3 wanderkill DONE ANY ANY ANY RANDOM @TEMP 4 ANY ANY ANY CHANCE 50 HDAEMON $ME SMASH PROVOKE ANY WHEN 3 WANDERKILL DONE ANY ANY ANY MOVE @TEMP WHEN 3 wanderkill DONE To use one of these tables you would put a line in table 0 (init) like this. ANY ANY ANY SETME pogo stick PLACE $ME sad room when 2 Nastybeast the setme action sets $ME to be the pogo stick. WHEN 3 simply waits for 3 seconds before executing the table. Daemon Actions Abermud 5 tables make extensive use of a feature called daemon actions. Put simply a daemon action is an action carried out by the item it acts on. so if i have something like this.. SPOD ANY ANY IF1 ISUSER $1 DAEMON $1 SPOD ANY ANY OK DONE then it would set $AC to $ME - ie $AC is the object that called the daemon and it would set $ME to equal $1. Then it would run the daemon control table (table 2). So if there was an entry in the daemon control table like this... SPOD ANY ANY MSG {You are surprised when } PCNAME $AC MESSAGE { says "You are a spod!"} DONE This would appear on 2 peoples screens like this. On freds screen >spod bob OK > And on bobs screen You are surprised when Fred says "You are a spod!" A far more interesting (and useful) example is the daemon called by the attacking mobiles tables - SMASH PROVOKE ANY. if memory serves it goes something like this. SMASH PROVOKE ANY ISCLASS $ME MOBILE DONE COMMENT {do not attack mobiles} SMASH PROVOKE ANY ARCH DONE COMMENT {Do not attack arches} SMASH PROVOKE ANY DAEMON $AC SMASH START ANY DONE I give this example merely to illustrate that a daemon action can itself call a daemon of its own. The mud server will remember who sent what action and reset $ME and $AC to their original values when a daemon terminates. Daemons come in several distinct types: DAEMON simply causes the item to perform the stated daemon action. HDAEMON causes everything in the presence of the item to perform the action. TREEDAEMON acts on anything contained within the item. ALLDAEMON affects everyone, mobiles and users are effected so some sort of test should be carried out if you intend to use it to send a message to everyone. ALLDAEMON is quite slow. PROCDAEMON is one that i have never had to use. All i can remember about it is that it does not set $AC. TYPES OF FLAGS There are numerous flag types floating around in abermud, in addition to the oflags, rflags, cflags and pflags i have mentioned there are also class flags that can be applied to items and 16 numerical flags that can be set on each item. Userflags are set by using the command setuflag. For instance to make the blue anorak worth 300 points i would type >setuflag blue anorak 1 30 this sets userflag 1 on the anorak to 30. The number of points displayed is 10 * the actual score/value the most important userflags for game building are. 0 - point value 1 - weapon value 2 - food value it is possible to list the userflag values of an item using the command showuser The game also has up to 512 numerical flags. These can have any integer value between -29999 and 29999. These flags all have names in the form @ It is possible to list these flags by using the listflag command. new flags are created by using the command nameflag. eg >listflag 1 Reset 2 Temp 3 Hours 4 Locked 5 TempReset 6 AllFlag 7 NoShout 8 Temp1 9 Temp2 10 NoBeg 11 Forced 12 Temp3 13 StopMon 14 CombatMsg >nameflag 15 @Bollox Flag 15 is now called @Bollox >listflag 1 Reset 2 Temp 3 Hours 4 Locked 5 TempReset 6 AllFlag 7 NoShout 8 Temp1 9 Temp2 10 NoBeg 11 Forced 12 Temp3 13 StopMon 14 CombatMsg 15 Bollox The only way to use an items userflags in the tables is to convert them into numerical flags. This task is carried out by the commands copyof and copyfo. This example is a line from part of my code - a mobile that eats valuable objects and increases in value itself. ANY ANY ANY COPYOF $ME 0 @TEMP COPYOF $1 0 @TEMP1 ADDF @TEMP @TEMP2 COPYOF @TEMP $ME 0 This line copies the value of $me to @temp and the value of $1 to @temp1 and then adds @temp1 to @temp, storing the result in @temp. Then it copies the value of @temp back into userflag 0 of $me. useful flag commands. for complete list see reference manual ADD add number to flag SUB subtract number from flag ADDF add flag1 to flag2, store result in flag1 SUBF Guess! i bet you cant get it! MUL multiply flag by number DIV divide flag by number MULF multiply flag1 by flag2 DIVF divide flag1 by flag2 EQ returns true if flag = number NOTEQ inverse of EQ EQF true if flag1 = flag2 NOTEQF inverse of EQF GT true if flag > number LT true if flag < number GTF true if flag1 > flag2 LTF true if flag1 < flag2 there are others but they are the most useful. ItemFlags One class of flags that can be very useful are item flags. Each object has 16 of these. Put simply an itemflag points to another item in the game universe. These are used to decide such things as what weapon you are wielding today and exactly who the rabid penguin has decided to chase to the ends of the universe. (and im not joking about a mud having rabid penguins in so shut up :) If an itemflag is unset or it points to a player who has logged of or an item that has been destroyed then the flag points to nothing. For this reason a getiflag statement should always use IF1 or IF2 before any processing starts. Example: I want a mobile called the huge assassin to chase and attack a victim until one of them is dead. The table i have used for this is to be called MoveAssassin in the command table VICTIMISE ANY ANY ARCH WHATO 1 IF1 ISUSER $1 SETIFLAG Huge Assassin 5 $1 OK DONE and the moveassassin table ANY ANY ANY GETIFLAG $ME 5 1 NOT IF1 CLEARIFLAG $ME 5 WHEN 1 MoveAssassin DONE ANY ANY ANY ISUSER $ME WHEN 1 MoveAssassin DONE ANY ANY ANY NOT ISBY $ME $1 DOESACTION $ME {Stomps off.} 4 PUTBY $ME $1 DOESACTION $ME {Stomps in.} 4 ANY ANY ANY ISBY $ME $1 DAEMON $1 Smash Start ANY ANY ANY ANY WHEN 1 MoveAssassin DONE Conditional Exits These are exits controlled by a table. If you can pass the table terminates with DONE. If you cant it uses NOTDONE. Example: There is an exit up to a window ledge. If you are carrying too much then you cannot climb up. I have decided to call the table climbledge. >condexit filthy yard up window ledge climbledge and in the table... ANY ANY ANY ARCH DONE COMMENT {Arches can do anything} ANY ANY ANY WEIGH $ME @TEMP ANY ANY ANY GT @TEMP 200 message {You are unable to climb up to the ledge} DOESACTION $ME {scrabbles at the window ledge but is unable to climb up.} 4 NOTDONE ANY ANY ANY DONE The first line of the table simply allows any arch through the exit. The second line puts the weight of the player including possessions into @temp. The third line prints a message if you are too heavy and terminates the table with a NOTDONE. The third line simply returns a DONE and makes the exit succeed if it dosent fail. This may sound silly but everything has to be taken into account. The end. written by Flagg. If you spot any obvious errors mail Flagg@jumper.mcc.ac.uk No Really! I simply can not be arsed with writing any more. Go Away!