custom_equipment_location

Response Typescript
EntitiesObjects
Parameters-

    For a long time equipment has followed a very standard list of possible
wear locations. With the introduction of this trigger, it is now possible
for builders to create arbitrary equipment locations. These custom
locations for the most part work exactly like the standard locations, with
the exception that the builder must defined a series of handlers to
facilitate the custom location.

Only one "custom_equipment_location" trigger should be defined for any
given item. This single trigger will enable the creation of one or more
locations where the item can be worn. When a mobile attempts to wear the
item, if the target location is empty, or not one of the standard
locations, then the handler script will be fired for various parts of the
event. The @mode variable will be set to a value indicating what kind of
event is occuring. This should be used to route the script to a specifci
handler for the event. The following are possible values for the @mode
variable:

checkValidLocation - is the target wear location valid?
getLocationRank - ordering rank with respect to other locations
checkCanWear - can the item be worn by the mobile?
performWear - custom output for wearing the item
getEquipmentView - what it looks like in the equipment listing

Each of these event handlers should be defined. The example at the end
shows a very concise way of handling the actual request so that the script
is clear and easy to enhance. A detailed description of each mode follows:

checkValidLocation:

This handler is responsible for checking the user's requested
location to wear the item. The requested location is stored in the
variable @locationName. The handler should be able to handle an
empty name (default location when none specific), and partial
location names. The script should return the actual location
corresponding to the request. For instance, if a mobile issues the
following:

wear horseshoes

Then the script might return "hooves". Similarly, if the mobile
issues the following command:

wear horseshoes hoo

Then the script should still be able to return "hooves".

getLocationRank

Standard equipment locations are ordered internall so that
equipment is presented in a particular order. Since custom
equipment may want ot be displayed anywhere within that ordering,
this handler's job is to indicate where the item should be
presented. All standard equipment has a preset order that is a
multiple of 1000. The following list shows the standard equipment
ranks:

Light source - 1000
Worn as ring - 2000
Worn as ring - 3000
Worn on neck - 4000
Worn on neck - 5000
Worn on head - 6000
Worn on body - 7000
Worn on arms - 8000
Worn on hands - 9000
Worn as belt - 10000
Worn on legs - 11000
Worn on feet - 12000
Worn as shield - 13000
About the body - 14000
Worn on lWrist - 15000
Worn on rWrist - 16000
Wielded weapon - 17000
Held offhand - 18000

So let's say we wanted to display our custom location of "hooves"
after the "feet" location but before the "shield" location. To do
so we would need to return a value greater than 12000 and less
than 13000. So we might return 12001. Note that, although many
items will probably just support one location, if more than one
location is supported, then the @loctionName variable can be
checked to determine what location is being ranked.

checkCanWear

This handler deals with any checking to determine if the mobile is
allowed to wear the item on the given location. If more than one
location is supported than the @locationName variable can be
examined to determine of the item is allowed in the specific
location. If the mobile can wear the item, then the handler should
return 1; otherwise 0 should be returned.

performWear

This handler is used to inform the player and observer of the wear
action. It should be used to output information to the wearer and
any observers in the room that can see the wearer. The following is
a simple example:

%nact( "You nail the horseshoes to your hooves.",
\ 0, @actor, null, null, actorOnly )

%nact( "$n nails a set of horseshoes to $s hooves.",
\ 1, @actor, null, null, skipActor )

As for all of the handlers, the @locationName variable can be
checked to determine the exact output in the event there are
multiple supported locations.

getEquipmentView

This is used to display the item to any one examining the mobile's
equipment list. It should follow the default format for equipment
locations. To provide the greatest flexibility, the script allows
complete control of the entire equipment location line. A variable
called @labelWidth is set tot he maximum width of any equipment
location label. This enables the scripter to ensure their label
vertically aligns with the rest of the equipment list labels. By
using this variable, builders ensure that the label will always
align properly in the future regardless of any changes to standard
equipment locations. In addition to the @locationName and
@labelWidth variables, this script also sets the following
variables:

@target - the mobile whose equipment is being viewed

@viewer - the mobile viewing the @target

@canSee - whether or not the @viewer can see the item.

This is a very powerful trigger. The example below was used during the
testing phase when the trigger was created. It shows a very concise way to
route the @mode variable and handle each request:

Example:

protect
{
%jumpTo( @mode )

label checkValidLocation
{
if( @locationName === null
\ ||
\ %stringIsPrefixI( @locationName, "hooves" ) )
{
return "hooves"
}
endif

return 0
}

label getLocationRank
{
return 12001
}

label checkCanWear
{
if( @actor->realRace != "centaur"
\ &&
\ !%isImmortal( @actor ) )
{
%echoTo(
\ "You don't seem to have the right kind of feet for "
\ "horseshoes.", @actor )

return 0
}
endif

if( @locationName == "hooves" )
{
return 1
}
endif

%echoTo( "You cannot wear the horseshoes.", @actor )

return 0
}

label performWear
{
%nact( "You nail the horseshoes to your hooves.",
\ 0, @actor, null, null, actorOnly )

%nact( "$n nails a set of horseshoes to $s hooves.",
\ 1, @actor, null, null, skipActor )

return
}

label getEquipmentView
{
@name = %stringPad( "Worn on hooves", @labelWidth )

@desc =
\ "[" @name "] "
\ "a set of sweet-ass horseshoes"

return @desc
}
}
endprotect