The standard library "wear" command allows the player to wear any dynamic objects that have the "Object is Wearable" property set.
If there are two hats in the game then the player can pick them up and wear both of them at the same time.
In this tutorial we will create clothing "slots", which are specific locations on the body, each of which can wear only one item of clothing at a time.
The Worn-On Property
We need to be able to specify which part of the body a particular object is worn on.
There are many ways you could do this. Here i have created an object property so i can simply select the bodypart from a drop-down list as i create each item of clothing.
- The "Type" is set to "State List" and the bodyparts are listed at the bottom. I have used 4, but you might want to split "Body" into "Torso" and "Hips" or add separate arms and legs, or wrists, finger and neck (for jewelry).
- If you tick the "Mandatory box then you must specify where every item of clothing will be worn. If you dont make this property Mandatory then you can also create items of clothing which can always be put on regardless of what else is being worn, by not selecting the worn-on property.
- Specify that this property will only appear if "Object is wearable" is selected. This hides this option for objects that are not clothing, and also ensures that these two properties will appear together on the object property list.
The Clothing Slots
To be able to prevent the player from wearing more than one item on each bodypart, we need to create a clothing slot for each bodypart that records the fact that something is being worn there.
The obvious solution would be to create each bodypart as a separate bodypart object (Location of the object="Part of character") which keeps track of which object it is currently wearing. This would allow the command "Examine my head" to describe the hat that is currently on it. However:
The current version of ADRIFT (5.0.22) does not have any way to write an %object% reference to a property. (Enhancement Request 18322)
So instead we create a character property for each clothing slot that indicates whether or not something is being worn there at the current time.
You probably dont want all of these extra properties on every characters' property list, so first create a Character property called "Playable Character" of type "Selection only". We will use this to hide the clothing properties on characters that dont need them.
Now create a "Selection only" character property for every one of the clothing slots that you listed in the "Worn On" state list.
Set them all to only be displayed if the "Playable Character" property is selected.
Wear %object% tasks
We need to override the "Wear" command to update the clothing slot properties and to perform the extra checks to determine if the player can wear the referenced object.
Future enhancements to ADRIFT should allow this to be done with a couple of tasks, but for now we need to create a separate "Wear" specific task for every one of our clothing slots.
It overrides the general task, but not for a specific object, so leave the objects reference as it is. We will make each task specific to a clothing slot using restrictions.
In the message field put a description of what happens when the player is able to wear the referenced object on this body part.
Now add the specific restrictions for this clothing slot. The general task checks that the object is wearable and that the player is holding it, so we just need:
- If the "worn on" property was not made mandatory then we need a restriction to check that is selected for the referenced object.
- The task is made specific to a clothing slot by checking the objects "Worn on" property.
- Finally we check if the clothing slot is already occupied by something else.
The first two restrictions must NOT have a failure message, so that ADRIFT will continue to check the other wear tasks for a match.
For the final restriction we print a failure message:
If the restrictions pass we need to do two things, select the clothing slot property so we know that it is occupied, and move the object to "being worn by character"
- Create a similar task for each of the clothing slots in the "Worn on" state list.
Remove %object% Tasks
Now we need to do the same for the "remove" command, so that we can reset the appropriate clothing slot to the empty state.
This time we check that the player IS wearing an object in this clothing slot.
Note that we dont need to add a failure message to any of these restrictions, because the general task will fail with a "Your not wearing it" message if none of the tasks pass.
And we perform the opposite actions, removing the clothing object and clearing the clothing slot.
Repeat for each clothing slot.
The one problem is that "wear all" will give the message "There is nothing worth wearing here" if all of the wearable objects being held cant be worn because their slots are already occupied.
The only way to fix this is to go to the advanced tab of the WEAR general task and change the message in the text box to "You are not holding anything that you can put on at the moment"
This is a simple demo game for clothing slots with 2 clothing objects per slot:
Note that "wear all" will try to put on everything you are holding, succeeding for the first object for each slot and failing for the second.
"Remove all" will correctly remove the clothing in each slot.
"wear shirts", if you are holding both the chainmail and silk shirt, will put one of them on and fail for the second.
|<<< A lock with TWO keys||Main Page||Multiple Page Maps >>>|