02 Body parts and wearing/wielding objects
Tells you how to make new body parts for characters, and allow objects to be worn or wielded by characters.
Body parts and wearing/wielding objects
All RPGs allow characters to wield swords, don shields, and wear
armor of various sorts. This requires the RPG library to know
about body parts (such as legs, arms, torso, and head), and
where items are worn on the body.
In the RPG library, all characters have a list of body parts; the
default human body parts are oBodyPartHead, oBodyPartTorso,
oBodyPartArmLeft, oBodyPartArmRight, oBodyPartLegLeft,
and oBodyPartLegRitht. Monsters or other races might have
different body parts, including tails.
Each body part has one or more body part locations.
For example: The head has a location for a hat (or helmet),
glasses, earrings, and necklace. Objects that are worn attach
themselves to these body parts.
Objects that can be worn maintain a list of body part locations
that they can attach to. Usually this is only one location (such
as the necklace), but some objects will connect to several
locations (such as a jumpsuit, which covers the character's torso,
arms, and legs).
Creating body part locations
The list of body part locations that are building into the RPG
library are quite extensive. However, you may need to add your
own body part locations. Here's how:
-
Create a new object, called "oBodyPartLocXXX", where XXX
is replaced with your location's name, such as "horn".
-
Base the body part location off the super-class, cBodyPartLoc. The
cBodyPartLoc class is a sub-class of cObject.
-
Check the Automatically create as an
object button. All body part locations are instantiated objects.
-
Fill in the pNLPNounName and pNLPParseName for
the skill with an appropriate name.
-
Fill in pBodyPartLocDisplay with a string displayed
when the object is equipped. This will normally be "Worn" or "Held",
although you could always be more creative.
-
Fill in pBodyPartLocEquipName with a list of command
strings that can be used to equip the an item to the body part.
Normally this is ["`wear"], allowing a user to type in "wear OBJECT", or
"put on OBJECT". If you use ["`hold"] the user can type in
"wield OBJECT" or "hold OBJECT". Right now, `wear and `hold are
the only two strings accepted, but you can add more.
-
Add the body part location object, oBodyPartLocXXX, to
the appropriate body parts. See below.
The chances are that you'll have to add new body parts, especially
for monsters. The standard RPG library comes with humanoid body
parts (heads, arms, legs, torsos), but doesn't include tails, wings,
etc.
To create a new body part:
-
Create a new object, called "oBodyPartXXX", where XXX
is replaced with your body part's name, such as "WingLeft".
-
Base the body part off the super-class, cBodyPart. The
cBodyPart class is a sub-class of cObject.
-
Check the Automatically create as an
object button. All body parts are instantiated objects.
-
Fill in the pNLPNounName and pNLPParseName for
the skill with an appropriate name.
-
If the body part is on the left side of the creature,
set pBodyPartRCL to -1. Use 0 if it's centered,
or 1 if it's on the right side.
-
Likewise, set pBodyPartTCB to 1 if the body
part is on the top of the create, 0 for mid-level, and
-1 for bottom.
-
Set pBodyPartFCB to 1 if the body part is on
the front of the create, 0 for mid, and -1 for back. Humanoids
will use 0, but a centaur might have its human torso marked
as being on the front, while the horse's torso mid, and the
rear legs and tail as back.
-
pBodyPartLocations is a list containing the
locations in the body part. Each location is a sub-list
beginning with the body-part location object, followed by
the shape string, and the weight scaling.
The "body-part location object" is the oBodyPartLocXXX object.
The shape string is a string that identifies the overall
shape of the body part, such as "human". If you wanted an orc's
head to be a different shape than a human's, so that orcs could
not wear human helmets, then the shape would be "orc". Set
the scale to 1.0, unless you have a combination creature like
a centaur.
For example: The pBodyPartLocations for the head might
be: [[oBodyPartLocHat, "human", 1],
[oBodyPartLocGlasses, "human", 1],
[oBodyPartNecklace, "human", 1]].
-
You will need to write a BodyPartStatus function if
the body part affects any the ability for the character to
perform an action, such as legs affecting walking ability.
For more information, see the next tutorial about damage.
-
There are still more properties for body parts, but they
deal with the damage model (which is the next tutorial).
You will need to modify the class that defines the race (or
creature) to include the body parts:
-
In the race's class definition,
set pBodyParts to a list of the body parts
associated with the race. Each body part is a oBodyPartXXX
object.
Example: pBodyParts could be set to [oBodyPartHead,
oBodyPartTorso, oBodyPartArmLeft,
oBodyPartArmRight, oBodyPartLegLeft,
oBodyPartLegRight] .
Adding an extra oBodyPartArmLeft will make a 3-armed character,
etc.
Objects that can be equipped
Making an object than can be equipped (worn, held, wielded, etc.)
is easy:
-
Set pEquipLoc to an oBodyPartLocXXX object if
the object is equipped in only one body part (such as a helmet
using oBodyPartLocHat), or provide a list of oBodyPartLocXXX
for objects using several body parts. For example: A two
handed sword would have [oBodyPartLocHeld, oBodyPartLocHeld],
ensuring that it's held in two hands.
-
If your object is normally equipped in the character's off hand,
such as a shield, then set pEquipOffhand to FALSE.
Otherwise, leave it blank.
-
If you want your object to be equipped in body part locations
of a specific shape, such as a helment that only fits orcs,
then set pEquipShape to the shape string,
such as "orc".
-
To make the object only fit certain sized characters,
set pEquipWeightMin and pEquipWeightMax to
the character's minimum and maximum weights. This way
you can make clothes that only fit small characters, etc.
-
You can add futher restrictions to what characters can equip
your item by providing your
own EquipCanBeEquipped() method. For example: You
might have a sword that can only be carried by character's
named "Arthur".
-
Whenever the object is equipped or unequipped, a
call to MoveNotify() will be made. You can
add a MoveNotify() method to your object so that its magic
abilities will only activate when it's equipped.
That's it, your object can be held or worn.
-
Equip(), supported by cCharacter objects, will cause
a character to equip an item.
-
EquipCanBeEquipped(), supported by cObject objects, will
indicate whether or not a character can equip the item.
-
EquipUnEquip(), supported by cCharacter objects, will cause
a character to unequip an item.
Share with your friends: |