Welcome to Planewalker Games! We are the home of The Broken Hourglass, a new CRPG in development for Windows, Macintosh, and Linux computers.
Inside the Engine: Creatures PDF Print
As promised last month, in this special Boxing Day edition of Inside the Engine, we take a deeper look inside creature definition files.

Broadly speaking, any living being on the screen is a "creature", whether it is the player character, a joinable NPC, a shopkeeper, or a bloodthirsty beast. Like most other WeiNGINE resources, creatures are defined by one or more XML data files.

There are actually three different types of file which can be used to define a creature. The first is the "character" file, a special resource which defines objects which a console player (the person sitting at the computer) can select to start a game session with. Character files are most commonly created using the game's built-in character creation interface, although they may be tweaked or edited once generated, or constructed from scratch if truly desired.

The second is the "creaturetemplate" file. Don't be fooled by the presence of "template" in the name--these resources can be fully-defined humanoids, animals or monsters, rather than just a fragmentary template. But they do not appear in the gameworld unless specifically called by a scripting command, such as _create_creature. A creaturetemplate may be modified as it is brought into the gameworld, and may be called multiple times. For instance, a party of four guards may be created through script. Each guard may use the "guard.CREATURETEMPLATE" resource as it is created, but have a different resource name assigned to it ("guard-1" through "guard-4"), so that further script actions may act individually on the guards by unique name.

The third is the "creature" file. The crucial difference between a creaturetemplate and a creature is that a creature has attributes in Area, X, and Y--that is, it is specifically defined to appear on a game map, in a predetermined position, and will "always be there" unless it moves around or is killed. Because they appear in one place and in one place only, and are not dynamically created by script, we sometimes refer to these as "static creatures."

There are more than 100 legal attributes in a character, creature or creaturetemplate file, and we will not list them all here. They include values for all WRPG statistics and skills, sprite coloration, equipment and inventory, as well as special designations for creatures who have special meaning or behave differently than other creatures.

Consider Harika, a seller of scarves and other fine silks. We will create a .CREATURE file for Harika, meaning that we always expect to find her in one specific place in the game. We will use template inheritance to speed things along.

Note that the entries in a creature file (or indeed, in any game resource) may be specified in any order. Content creators may use whatever top-to-bottom flow they find easiest to read or manage.

Harika.CREATURE could be created as follows:

<xml>
<Name    value=~Harika~/>
<Female    value="1"/>
<Race value="human"/>

<Appearance value="female-human-2"/>
<Skin_Color    value="LightYellow4"/>
<Hair_Color    value="RosyBrown4"/>
<Major_Color    value="SlateBlue1"/>
<Minor_Color    value="Bisque3"/>

<Haggling                        bonus="+10"/>
<Damage_Resistance_Water        bonus="+15"/>
<Carrying    bonus="-5"/>
<Hafted_Precision    bonus="+10"/>
<Starting_Item    value="club"/>

<X    value="500"/>
<Y    value="675"/>
<Area    value="scarf-store"/>

<Store        value="harika-store"/>
<Party        value="harika-party"/>
<Dialogue    value="harika-dialogue"/>

<Template    value="basic-storekeep.CREATURETEMPLATE"/>
</xml>


We will explain these attributes from top to bottom.

Name: We give Harika a name in a text field here. Note that literal text is enclosed in tildes ~~ rather than in quotation marks. We could also create a "translation" resource and call it

<Name    value="Harika-name"/>

thus allowing ~Harika~ to be translated into other languages and alphabets if need be, but for clarity ~Harika~ will do nicely here.

Female: This attribute is set to 1, so Harika will be recognized as female by the engine. Male or neuter creatures do not have a corresponding attribute, so technically the engine supports "female" creatures (those with the Female attribute set to 1) and "non-female" creatures (all others.)

Race: We have made Harika a human. If she were a feyborn or an assimilated elf or an Illuminated, we would change this value.

Appearance: This field selects the sprite we will use to represent Harika on the screen. We have chosen one called "female-human-2" here.

Skin_Color and Hair_Color: Some sprites may be recolored for variety. All player character sprites, and many scenery/enemy sprites, are recolorable. Generally, any humanoid sprite which can be recolored will have customizable skin and hair color. There are multiple ways to define colors in WeiNGINE, but here we have chosen an easy route and picked the color names off of a documented table of several hundred available colors. As an alternative we could have described her hair and skin color as a raw RGB hexadecimal or decimal value.

Major_Color and Minor_Color: In addition to having customizable hair and skin colors, recolorable sprites are typically recolorable on two, three, or four clothing color regions. The female-human-2 sprite has two clothing color regions we may change, dubbed the "major" and "minor" layers. We set those colors here.

Haggling: Harika is more shrewd than the average shopkeeper, so we give her a +10 bonus to her Haggling skill here. This means that, all else being equal, Harika will charge more and offer less for goods in trade than a shopkeeper with a lower Haggling score.

Damage_Resistance_Water: As a little girl, Harika received a special blessing which gives her a keen resistance to water-related damage. We might also have chosen to give Harika a scripting effect that accomplishes the same goal, but we can just as easily define it for illustrative purposes directly in her .CREATURE file.

Carrying: Harika isn't very good at juggling lots of heavy items, so we have dinged her ability to carry extra inventory without an encumbrance penalty.

Hafted_Precision: Harika swings a mean cudgel. We have given her a modest bonus to her hafted weapon skill.

Starting_Item: Harika carries a club for self-defense. Listing it here will automatically populate it in her inventory when she is created.

X/Y/Area: These fields define exactly where we will find Harika in the game: She will be in the "scarf-score" area at coordinates 500x675, and she will be placed there as soon as the game begins.

The final four attributes all depend on other resources.

Store: A store is basically just a collection of items and a pricing bias. We would create a .STORE XML resource called "harika-store" which lists all of the items Harika has available for sale. By referring to it here, Harika now has the ability to sell items out of harika-store.

Party: All creatures must belong to a party. Although a unique, one-member will automatically be assigned if need be, specifying one here makes it easier for us to add affiliates for Harika later on. For instance, if we add her brother Josef to the store to dye silks, Josef can also belong to the "harika-party" party, and they will share in-game perception, inventory, and aid one another in battle if need be.

Dialogue: Without a dialogue resource, we cannot talk to Harika, and if we cannot talk to Harika we cannot access her store, so we will need to create a dialogue resource called "harika-dialogue." Referring to it here gives Harika access to the "harika-dialogue" dialogue resource, meaning it will be associated with her when we click on her and try to initiate a conversation.

The last item is a template. To avoid reinventing the wheel every time we need a storekeeper, we have created a basic-storekeep creaturetemplate. This creaturetemplate grants bonuses to someone who has the characteristics a storekeeper needs in order to be successful.

basic-storekeep.CREATURETEMPLATE
<xml>
<template        value="basic-person.CREATURETEMPLATE"/>
<Toughness                      bonus="+5"/>
<Judgment                        bonus="+5"/>
<Carrying                        bonus="+20"/>
<Perception                        bonus="+20"/>
<Dodge                            bonus="+5"/>
<Haggling                        bonus="+15"/>
<Diplomacy                        bonus="+15"/>
<Manipulation                    bonus="+15"/>
</xml>

Note that Harika has bonuses to Haggling coming from two different places--one from her creature file and another from her basic-storekeep creaturetemplate. They will stack (that is, add together.) Similarly, the Carrying penalty in her creature file will eat into the bonus she gets to Carrying from her basic-storekeep creaturetemplate, so she will still end up being less good at Carrying than a basic-storekeep would be.

But wait! There's yet another template being called in there! We won't list the basic-person.CREATURETEMPLATE here, but its job is to set up all of the relevant attributes and skills for an intelligent humanoid. Almost all are set to 0, providing a base to build bonuses on (and making it a boring creaturetemplate to read.) That's why we have yet to say anything about Harika's Strength score or her Luck or her Health, and don't need to--she will get all of those values from the basic-person creaturetemplate.

With this creature file properly created and saved, when the player visits the scarf store, they will find Harika waiting to take her order. We have done all we can on the creature side to set her up in-game.

Other special creature attributes not mentioned here include:

Cannot_Loot and Cannot_Manipulate: These attributes are typically used for non-intelligent creatures, or those which should have certain restrictions for storytelling purposes. When set to 1, Cannot_Loot prevents the creature from picking up items from containers or lootpiles. A rat and a zombie cannot loot. Cannot_Manipulate prevents the creature from opening doors or activating switches.

Is_Visual_Effect: If set to 1, the creature in question turns into a visual effect. Visual effects have certain special exemptions. They cannot be targeted or damaged and they do not display foot circles. They instead are considered "part of the scenery." Typically a visual effect will be used for something which is either not actually alive (such as an animated bonfire) or for something which is alive but should not be affected by normal in-game physics and events, such as a bird flying far overhead.

Random_Walking: If set to 1, the creature in question will randomly walk, or "mill about", instead of staying in one place. There are also a number of controls on Random_Walking, such as Random_Walk_Turn_Chance, which can be used to override the normal biases associated with random walking.

Shares_Perception_With_Party: If set to 1, this creature will provide vision to the player's party as though it were a member of the player party, but otherwise has no affiliation. Usually this attribute is only affected indirectly by a scripting command, _make_cutspy_, and is used to temporarily clear out unexplored or fogged areas outside the party's usual range of vision.

Next month, we will continue working with Harika, and make it possible to interact with her by discussing dialogue creation.

Last Updated ( Tuesday, 26 December 2006 )
< Previous   Next >