Sunday, March 28, 2010

Useful wizard commands

Here are a number of useful wizard commands.

Emotes without moving
At [yourWizardName] [command] - do something in someone's environment

Give yourself money
(we know it is only for testing purposes;)
money [copper] [silver] [gold] [plat]

Execute some LPC code on the fly
execr find_player("bendis")->command("say Hi");

Tracer tool
    At        Perform a command in the environment of a player
    Call        Call a function in an object
    Cat        Cat the file linked to an object
    Clean        Destruct all non-interactive objects in an object
    Destruct    Destruct a specific object
    Dump        Print various information about an object
    Ed        Ed the file linked to an object
    Goto        Enter the inventory of an object
    In        Perform a command in another object
    More        More the file linked to an object
    Move        Move an object to a destination
    Reload        Update, load, clone and replace an object
    Set        Set a tracer variable
    Tail        Tail the file linked to an object
    Top        Show top cpu statistics


Control
      control [target]

Shops

The mudlib offers support for commerce. A shop is a place or person who can buy or sell items.

The diagram below shows the objects used for the alchemist shop. The alchemist_shop sells athly, streyroot and strim. These herbs are kept in a  store belonging to the alchemist_shop.

Diagrams

The diagrams on this blog are produced using the DIA diagram editor. It is like Visio and it is free software.

In many Linux distributions (e.g. Ubuntu) you can install DIA via the system update.

You can download the source xml files for the diagrams to edit with DIA below.
Please let me know if you find discrepancies, mistakes or if you have an improved diagram. I will post it here with all the due credit.

Saturday, March 27, 2010

Craft guilds

The mudlib provides support for four types of guilds:
  1. occupational guild
  2. layman guild
  3. racial guild
  4. craft guild
This post explains the structure of a craft guild, the services provided and sample code.

In essence a craft guild allows the members to combine a set of objects in their inventory to "produce" another object of some utility to the player. For example potions and buffs.

The example in this post will create an alchemist guild and it will be based on the standard distribution. To create your own sandbox and experiment with the code in this article refer to the Getting Started with LPMud article.

Craft guild services

A craft guild provides the following services:
    1. join services: join and leave the guild
    2. train services: train the special skill of the guild, in our case alchemy
    3. start services: the user can set its start location in a room in the guild
    4. special abilities, for example mix potion or elixir; in our case the guild will mix a potion

Optional a guild could provide an emblem, a shop, a post office or other related services.

Class structure
The classes participating in the guild implementation are shwon in the figure below. The classes in the packages in red are part of the mudlib while the classes in the packages in blue are part of the alchemist guild implementation.

The class diagram is given for reference, helping in understanding the workings of the guild. Click on the image to see a larger version.




Join services
The join/leave services are provided by a game room, joinroom.c , to which 2 actions are added: alcjoin and alcleave.

The diagram below shows what happens when a player joins the craft guild. after the player issues the command, a clone of the craft_shadow class is installed as a shadow for the player if the user is allowed to join the guild. Then the guild emblem and the guild soul and the guild specific player description are added. The guild soul hosts the guild specific abilities.


Train services
The guild allows the player to train the special skills defined by the guild, in this case alchemy. The train services are provided by a game room, train.c. The room inherits the skill trainer behavior from skill_train mudlib component.

Start services
[TODO]

Special abilities
The special ability provided by the alchemist guild is to carve a mortar which knows how to mix a potion. One could argue that the ability itself might be mix potion. In this case, the mortar class is already defined on Genesis and it is a good opportunity to reuse the code.

Friday, March 26, 2010

Getting started with LP Mud

If you are here probably you know what a mud is, and even more what an LP Mud is. If you don't, check the Genesis Mud website and you will get an idea.

If you decided LP coding is for you, this article will explain how to get started. Of course, you can always join Genesis at telnet genesismud.org:3011 and apply for a wizard position.

I believe that learning by doing is the fastest way to learn coding so here are how you start up your own sandbox.

I published a virtual machine on the Amazon EC2 cloud that has anything that you need to get you started. The mud driver and mudlib build are credited to the Genesis Interest Association.

Amazon EC2 is a Amazon service that allows you to run virtual machines ( a kind of computer :)) on demand. You don't need to buy a new computer and install Linux for several hundred dollars and a lot of sweat and time. Here is how to get your own computer or instance on Amazon for about 3 cents per hour.

You can get your mud sandbox up and running in one hour. Here are the steps.

1. Get an Amazon EC2 account.
Go to the Amazon EC2 page and sign up for an account.
Click the “Sign up for This Web Service” button on the Amazon EC2 detail page. You must have an Amazon Web Services account to access this service; if you do not already have one, you will be prompted to create one when you begin the Amazon EC2 sign-up process.
2. Login in the Amazon EC2 administration console.
Go to the Amazon ECS Administration Console login page and enter your credentials.




3. Create a spot request

Click the spot requests menu item. Choose the Community AMI tab. Enter ami-a147a8c8 in the search box to search for the Genesis AMI. Click the Select button.



Enter 0.04 as spot request. This will allow you to obtain an instance faster, in about 30 minutes.



Click continue. On the next screen accept the default values and click continue too.

The next screen asks to create a new key pair. This is an important file that you need to keep securely on your hard disk, as it allows the connection to the server via the root account.



Make sure you click the "Create & Download your Key Pair" and record the location where you saved it.

Click Continue to advance to the security group page. As your computer will be accessible from the Internet, it needs to be locked down for security.

From the bottom drop down select SSH and click the Add Rule button. This will allow only SSH connections to your computer for now. Click Continue.



The next and last screen is the summary screen and it should look like this:



Click submit to create your spot request. The request should be fulfilled in about 30 minutes. Go and drink a coffee and keep a tab on your instances. When your instance is started go to the next steps.

4. Download, install and set up PUTTY.

If you are using Linux you already have all you need. If you are on Windows, you can use PUTTY to establish and SSH connection to your server. You opened the SSH port earlier when you created the security group.

Download PUTTY. Download the whole installation kit for Windows as it has several utilities that will be needed. Run the installer.

5. Log in the "mud" account
Your instance comes pre-configured non-privileged account where you can run your mud. The password for this account is tom!bombadil.

As I posted the password for you to log in here on the blog, the first thing you will do is to change it.

In your AWS console click on the instances menu item. Click on your instance and on the bottom page copy the Public DNS value. It should look like this:
ec2-[yourIP].compute-1.amazonaws.com
Here is how you log in:

PUTTY (Windows)
putty -ssh -2 mud@ec2-[yourIP].compute-1.amazonaws.com
SSH (Linux or Mac)

ssh mud@ec2-[yourIP].compute-1.amazonaws.com

Enter the password: tom!bombadil

6. Change the password for the "mud" user

After login type this command at the prompt:


> passwd
Follow the prompts and change the password.

7. Start the mud driver

The mud driver is in the "bin" folder. Type the following commands to start it:


> cd bin
> nohup driver &
The second command starts the driver in such a way that it will not be shut down after you log off.

8. Open the port 3011

Your mud runs on the port 3011. Our security group configuration blocks everything except ssh. To open the port 3011 go to the AWS console and click on the Security Groups menu. Choose the security group genesis on the right pane.



Leave the select on "Custom" as we are adding a custom rule. Fill in the rest of the fields as in the image above and click Add Rule. The port is not open and you can connect to the mud.

9. Connect to the mud
Use your favorite mud client to connect to the mud. The host name is the public DNS name that you gathered above and the port is 3011. Create a character and look around.

Enjoy.