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: Introduction to items PDF Print
On the fourth Monday of the month, we discuss content development and modding topics in The Broken Hourglass. This month we introduce item creation.

In keeping with last week's discussion of itemsets, we will use the engine mechanics column this month to discuss the basics of item creation.

There is an old joke which goes like this:

What is the best way to make one million dollars?
Start with two!

The best way to make most WeiNGINE items is, in fact, to start with an existing item. The power of template inheritance means that there are really very few cases when a good base will not already exist for an item you wish to make.

We will dive right in and make a simple magical longsword. We want our magical longsword to differ from a standard longsword (already part of the game) in the following ways:

- It should be lighter, and therefore easier to wield without penalty
- It should do more damage
- It should give us an increased chance to hit-the blade magically helps steer itself towards the target

These traits also imply a couple of other things:

- This sword is more valuable than a standard longsword
- This sword has magical abilities. Under WRPG rules one typically must devote some mana to controlling magic whether it comes from within or from an item.

A standard longsword has the following attributes: 

Cost: 60. This means that it costs 60 game units of money (in The Broken Hourglass, the major denomination is the sanguil) in order to buy a longsword from a merchant who is not charging any sort of markup. In a real interaction with a storekeeper, haggling and buy/sell price biases will change this figure, but 60 represents the "base" cost in a pure transaction.

Base_Damage: 20. Recall from earlier discussions of combat rules that the actual damage inflicted is computed with this formula:

((Attack roll - Defense roll) /100) * Base_Damage = Damage inflicted

Therefore, Base_Damage can be thought of as the result of a perfect attack roll (100 out of a possible 100) and a failure to defend on the part of the target: (100 - 0) / 100 * Base_Damage = 20. In real combat, there are a number of other modifiers on both the attack and defense roll, but Base_Damage provides ground rules for comparison.

Bulk_Weight: 15. Bulk weight is a composite statistic that considers the volume as well as the mass of an object simultaneously. Trivially small objects such as rings and keys have 0 bulk weight, while suits of armor have bulk weights in the hundreds.

Here, then, is the simplest way to make an enhanced, magical longsword. Most of our goals can be accomplished using simple XML attributes. The goal of having the magic sword "hit more often", however, requires that we give a Sword_Precision bonus to the wielder of the sword while it is equipped, and that requires a separate effect file, which we will explain.

<<<<<<<< item/magic-longsword.xml

<xml>
<template value="longsword.ITEM"/> // Inherit the regular longsword as a template. This saves us from having to worry about a lot of things-like what item category our new sword is in, what range it will have, and so forth. All of those attributes are already defined in a standard longsword.
<Name value=~Magic Longsword~/> // Through the template, we would inherit the name of ~Longsword~, but we want our new item to have a unique name.
<Desc value=~This longsword feels lighter and keener than any you have ever laid eyes upon before.~/> // Through the template we would inherit the standard longsword description, but again, we want a unique description to suit our fancy sword.
<Bulk_Weight bonus="-3"/> // We want our new sword to be lighter than a regular longsword, so we reduce the inherited bulk_weight by 3. Using "bonus" rather than "value" in an attribute reflects that we wish to add (or subtract) from an inherited value, rather than override it.
<Base_Damage bonus="+5"/> // We want our new sword to do more damage than a regular longsword, so we provide a bonus of 5 to the inherited base_damage.
<Cost bonus="+300"/> // We want our sword to be more valuable than a regular longsword, so we increase the cost.
<Equipped_Mana_Cost value="5"/> // Because this is a magic item, we want to charge the wielder a portion of his or her mana in order to be able to control it. Equipping this sword will occupy 5 points of the wielder's mana pool.
<Equipped_Effect value="magic-sword-precision-bonus"/> // For the sword to increase Sword_Precision on the wielder, we must use a separate effect. This line tells the item that the effect should be associated with the sword, and that it should only be applied when the item is equipped.
</xml>

<<<<<<<< effect/magic-sword-precision-bonus.xml // This file creates a Sword_Precision bonus for the wielder of our magic longsword.

<xml>
<grant_bonus attribute="sword_precision" value="10"/> // This effect boosts the owner's Sword_Precision skill by 10.
</xml>

With the item and effect in place, we have created a fully-functional magic longsword. Now all that remains is to introduce it into the game.

A developer/modder can quickly add any item to a running game using a script console command

_ci "magic-longsword"

This will create one copy of the magic-longsword in the player's inventory.

To put it somewhere with more permanence and in-game presence, it can be added as a Starting_Item attribute to any container, store, or creature inventory, or created as part of a quest reward.

When referring to items as a thing in a script, the format is "itemname"::"ITEM". So in this case, our new item is "magic-longsword"::"ITEM".

More About Items

All items must belong to an item category. Item categories (itemcat for short) classify items under broad headings, such as "weapon", "shield", "armor", or "general." Itemcats are used to enforce exclusivity and can be used in scripting as well, to provide special bonuses or penalties based on the use or lack of use of a certain kind of item. For instance, a trait could grant someone an agility bonus only if they do not have any kind of armor equipped. A person might believe that wearing headgear indoors is impolite, and so will refuse to speak to anyone with anything equipped in the "helmet" item category.

 


(Incomplete list of) Important attributes of items:

Display_Equipanim: This value is used in conjunction with character and creature sprite definitions to determine how the item should affect the sprite. For instance, a longsword and a dagger have different Display_Equipanim values, because for most creatures which can wield them, they should have a different appearance in the sprite's hand. Tiny items such as keys do not have a Display_equipanim value because equipping them does not change a sprite's appearance.

Icon and Portrait: These two values specify the small (icon) and large (portrait) representation of the item in inventory screens and itemsets. Any valid JPG or PNG known to the engine may be defined here, but by convention they measure 32x32 and 64x64, respectively.

Equipped_Spellcount: If an item grants the ability to cast a spell or perform a spell-like ability, that spell is given here. This can include anything from "a ring which shoots fireballs" to "a potion which allows you to heal yourself."

Precision_Skill: Used for weapons. This value tells the engine which weapon precision skill (sword, hafted, polearm, etc.) to use when calculating attack rolls.

Speed_Skill: Used for weapons. This value tells the engine which weapon speed skill (Combat, Bow, Magic) to use when calculating attack frequency.

Requires_Two_Hands: Typically used for weapons. This value tells the engine that the item must be wielded two-handed and, therefore, may not be equipped with a shield.

Stackable: Indicates that multiple copies of an item should be combined together in a single itemcount (inventory line.) Typically used for consumables such as potions. Stacks may be divided up by the player later.

Undroppable: Indicates that the item cannot be dropped by any normal means. Undroppable items may not be pickpocketed, lost, dropped upon death, etc. Fists and claws, for instance, are undroppable.

Unswappable: Indicates that equipping this item forces it to be equipped in all itemsets. Typically used for armors and anything else which cannot easily or quickly be changed in and out of. Note that being undroppable and/or unswappable does not mean that a creature is required to have that item equipped--you may choose never to fight with your fist, but you can't drop it.

Exclusive: When this attribute is set to 1, it means that this item may not be equipped with any other Exclusive member of the same item category. This is the attribute which prevents you from equipping, say, two sets of armor or two shields or two pairs of sandals.

Just because one or more members of an item category are exclusive does not mean that all members of the item category must be exclusive. Consider this example of four items which can be worn on the head. As headgear, all four would belong to the "helmet" item category, but not all are exclusive.

Football helmet: Exclusive helmet
Fireman's helmet: Exclusive helmet
Pete Rozelle headband: Non-exclusive helmet
Toupee: Non-exclusive helmet

The football helmet and fireman's helmet are both exclusive. That means no one can wear both the football helmet and fireman's helmet at the same time-they are physically incompatible, so the two items cannot appear in the same itemset.

The headband and toupee are both non-exclusive-they are relatively compact and do not physically interfere either with each other, or with a larger helmet. This means that a character can wear not only the headband and toupee together, but can wear them together in conjunction with one of the Exclusive helmets.

Headband + toupee + football helmet = legal (only one item is Exclusive)
Headband + toupee + fireman's helmet = legal (only one item is Exclusive)
Headband + toupee = legal (neither item is Exclusive)
Football helmet + fireman's helmet = illegal (both items are Exclusive)

Last Updated ( Monday, 26 February 2007 )
< Previous   Next >