xwear.i (eXtended wear.i) Library for ALAN

Important note!

This library file is intended to be used with the ALAN standard library 'std.i' (version 0.3 onwards) and should be used to replace the provided 'wear.i' file entirely. Attempting to include both 'xwear.i' and 'wear.i' files will generate compiler errors.


The concept of "xwear.i"

The basic idea behind this library is that clothing is worn in 'layers' and it is rather silly to allow players to (say) take off or put on a shirt if they are wearing a jacket. To simulate this in ALAN I've chosen to apply a numeric based layering system, and divide the body into five zones of coverage.

The zones are 'head', 'hands', 'feet', 'top' (for top half of torso) and 'bot' (for bottom half of torso). All objects have these five zones defined as default attributes (set to 0), for the head zone the attribute is headcover for the hands zone handscover and so on.

Every clothing object will thus need one or more of its 'zonecover' attributes set to reflect the zone(s) it covers and its relative position in the layers of clothing worn. A simple example would be a shirt, this covers only the 'top' zone and so needs its topcover attribute to be set (to 8, just why it's 8 will become clear shortly).

The principle used is that the closer to the skin an item is normally worn, the lower its 'cover' attribute is. The library operates on the assumption that items with higher value cover attributes for a particular zone are worn over items with lower value attributes. When a player attempts to put on an article of clothing, each zone it would affect is checked and compared to the related zonal total of any clothes already worn. If the value of the new clothing is not greater that the total(s) of clothing already worn (on a zone by zone basis) then the library will not allow the wearing of that item. There are a few notable exceptions to this rule, but I'll come back to those a little later


How it works in practice

This library might sound complex, but it is actually very simple to use, here's an example of how it works.

Assume our hero starts the game wearing just vest and shorts and the player issues the command 'put on shirt'. A quick check of the chart below should reveal that a shirt has only its topcover attribute set to non-zero, (all the other zones are zero, which means they are irrelevant for this item). The library totals the topcover attributes of all the clothes currently worn, like so:-

Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, so total topcover is 0 + 2 = 2.
Next the library checks the shorts, these have a topcover attribute of 0, so total topcover is 2 + 0 = 2.

As there are no other clothes to consider, the library now compares the topcover attribute of the item we are attempting to put on, (a shirt with a topcover attribute of 8 in this case) to the total value of items already worn (2).

Because the topcover attribute of the shirt (8) is greater than the calculated total (2), this is evaluated as being a 'legal' instruction and the library allows the shirt to be put on.

Now consider the situation had the player started the game wearing vest, shorts and a jacket, this is what happens should he try to 'put on the shirt.'

Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, so total topcover is 0 + 2 = 2.
Next the library checks the shorts, these have a topcover attribute of 0, so total topcover is 2 + 0 = 2.
Finally the library checks the jacket, this has a topcover attribute of 32, so total topcover is 2 + 32 = 34.

Because the topcover attribute of the shirt (8) is now not greater than the calculated total (34), this is evaluated as being an 'illegal' instruction and the library won't allow the shirt to be put on.

That demonstrates the basic principle of the library, removing clothes uses a variation of the 'compare to total' equation to allow / disallow removal of clothing, an example would be that our vest, shorts and jacket wearing player would NOT be allowed to remove the vest while he still had the jacket on.


Exceptions to the rule...

Now I'll confuse the issue. Firstly the numbers in my chart are not born of some sort of weird fixation with multiples, there is a very good reason why the numbers are set as they are, computer/maths types will recognise the sequence and realise it is all 'binary' based and know it makes it possible to calculate exactly what the player is wearing in terms of layers.

Some female clothing breaks the rules defined above and is not so easy to deal with. An example, although pantyhose is worn under a skirt, dress or coat it can actually be put on or removed with the garment worn over it still on. The library recognises this capability and deals with it properly by assigning the dress/skirt and coat items particular properties in that they don't affect the ability to wear or remove lower layer clothing that covers the bottom of the torso only.

Although it's physically possible to put on/remove trousers while wearing a skirt or dress, this (and a few other neat dressing/undressing tricks) is considered illegal here.


The clothing 'table'

Here then is my chart showing a selection of fairly typical clothing items and the values to set to obtain appropriate behaviour. Should you wish to create an article of clothing not listed, usually a bit of lateral thought as to what it is most like and where it fits into the scheme of things will suggest a workable set of values, but be aware that you MUST use values in this chart, simply adding things with intermediate values is probably going to create nasty bugs.

object headcover topcover botcover footcover handscover
hat
vest/bra
undies/panties
teddy
blouse/shirt/T-shirt
dress/coveralls
skirt
trousers/shorts
sweater/pullover
jacket
coat
socks/stockings
tights/pantiehose
shoes/boots
gloves
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
4
8
8
0
0
16
32
64
0
0
0
0
0
0
2
4
0
32
32
16
0
0
64
0
8
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2

Default attributes etc.

By simply including 'xwear.i' all objects get the required five zonecover attributes by default and all are set to 0. The library also sets default object attributes of NOT wearable and NOT plural, and a global default attribute of sex 0.

The concept is simple, an object is set as 'wearable' to make it clothing. If we set it as 'sex 0.' (the default - so we need not include it) then the library will allow it to be worn by a 'hero' who has 'sex 1' (a male) or 'sex 2' (a female).. set the object to either 'sex 1' or 'sex 2' and it'll be restricted to a hero with a matching 'sex' attribute.

The NOT plural is merely a presentation nicety. The player can pick up an item of clothing in one command, and then put it on with another :- this looks like so.

pick up the shirt
Taken

put on the shirt
You put on the shirt.

On the other hand (assuming the item is present, but not being held of course) he can simply issue a put on the shirt command, in which case the library builds a more complex response like this.

put on the shirt
You pick up the shirt and put it on.

Nicer, except if the object is a pair of trousers when that would give;

put on the trousers
You pick up the trousers and put it on.

OUCH! That is a bit painful on the eyes, to get around it we set the trousers object to plural, that gives the following (much better) response.

put on the trousers
You pick up the trousers and put them on.


How to create clothes that use 'xwear.i'

That covers the way the library works, here's how to define objects to actually make use of it. As an example, this is how to define a dress and restrict it to being worn by a female.

OBJECT dress IN changingroom

	NAME little black dress
	MENTIONED "little black dress"
	IS
		botcover 32.
		topcover 8.
		wearable.
		sex 2.

END OBJECT dress.

Notice that it is only necessary to mention the attributes that are non-zero, this minimises the amount of coding required. Apart from making sure the hero is set as 'sex 2.' if we wish her to be able to wear this dress, this is all the author needs to do, the library will police what is wearable and keep track of things without any further work.

I expect most authors would prefer to start their games with a player at least partially dressed. This is just a matter of defining the required clothes object as being in the 'worn' container. Here's how to define underwear that our female hero(ine?) starts the game wearing.

OBJECT bra IN worn

	NAME white bra
	MENTIONED "white bra"
	IS
		topcover 2.
		wearable.
		sex 2.

END OBJECT bra.

OBJECT panties IN worn

	NAME white panties
	MENTIONED "white panties"
	IS
		botcover 2.
		wearable.
		plural.
		sex 2.

END OBJECT panties.

The library as it stands also prevents wearing of duplicate clothes, or things that are logically mutually exclusive - e.g. the player can wear a dress or a skirt, but not both.


Suggestions

I recommend you put "xwear.i" into the same folder you use for the rest of the ALAN standard library. You must then either amend the library's default "std.i" so that it includes "xwear.i" instead of "wear.i", or (and I recommend this approach) put a copy of "std.i" in your game's working folder and amend the local copy to include "xwear.i" instead of "wear.i". The latter course of action means that your ALAN core library files are never changed - a Good Thing!

Any constructive comments are welcome, please address them to Al Bampton.