|
|
|
|
|
|
|
1/29/2007: Instead of writing about a power.dat management program, I'll write a
bit about the latest EmlenMud game engine release. There are several things you
will notice:
- I've put in a few functions in a "DB" module in anticipation of storing game data
in a database - MySQL or MSSQL.
- The engine has been split up into more logical components. For instance, a communication
library now handles sending and receiving raw data from users (in any form -- via
telnet or the web), and a DataClasses project defines the basic data structures
used to create the game world. The game engine handles all the coordination tasks:
Placing characters in a room, appropriately handling all user commands, and coordinating
the interaction between characters, rooms, objects, mobiles, actions, timing and
combat, and so on...
- The DataClasses project can load and store data (including entire areas with mob
prototypes, object prototypes, rooms, shops, etc). The game engine is no longer
needed to create an editor of any kind.
- The separation of Data and Function, along with loading and (now) SAVING areas
in the "old format" are two huge leaps towards creating offline editors (and eventually,
letting users or teams design their own cool graphical UI's that interface with
the basic game engine).
I will finish off this short entry with the code for the "attack" command. Note
how it doesn't need to know much about anything - each component handles its own
"rules" and enforces them. I hope some of you will appreciate the simplicity of
the code below (especially when compared to the original attack function!)
public static string do_attack(ICharacterData ch, string presetFirstArgument, string
szUserArguments)
{
ICharacterData chToAttack = FindCharInRoomUsingDigitNameKeywordOrPrefix((ICharacterData)ch,
szUserArguments);
if (chToAttack == null) return "Attack what or whom?";
if (ch.CanAttackChar(chToAttack) == false) return ch.ReasonCantAttackChar(chToAttack);
ch.AttackingCharacter = chToAttack;
return "You begin attacking " + chToAttack.MudInstance.ShortName(ch, chToAttack)
+ "!";
}
|
|
|
The first coding journey we will embark upon is going through how to build a slick-looking
power.dat manager. Test out formulas, create characters and view how powerful they
would be, while playing around with different power.dat settings.
The first thing to note is the sheer number of variables we have to deal with in
the power.dat file. There is NO WAY we are going to code up a pretty form and manually
set textboxes for each value, check their values, and arrange it all so it looks
nice. There is an easier way using .NET reflection and attributes, which I will
cover her when I get a chance. Here is a list of the variables associated with the
power.dat file (!):
The first step is to expose and mark these as PROPERTIES of the class, and not simply
just as variables. Turning these into properties is very easy using Visual
Studio 2005. There is a "refactor" option which auto-creates the code for
you. (Or, you can just use the code I have generated with VS2005). Below
is an example property. You can also set attributes for properties, which
describe the property (refferred to as metadata):
Property with no metadeta: |
|
Property with metadata added: |
Public bool AllowRecall {
get { return allowRecall; }
set { allowRecall = value; }
}
|
|
[Category("Global Options"),
DescriptionAttribute("If false, players will be
unable to recall")]
public bool AllowRecall {
get { return allowRecall; }
set { allowRecall = value; }
}
|
|
|
|
Eventually this page (or subsite) will contain sign-ups for specific projects, a
brainstorming section where ideas you would like to see implemented can be shared
and discussed (and possibly even a couple of offers for paid contract work). Also,
if anybody here has graphic design skills and some spare time, I always thought
it would be cool to have a custom designed T-shirt that reflected the (insanity?)
of playing or working on text-based games for 10+ years. I'll try to think of clever
slogans, etc... If you are interested,
).
|
|