Actions on objects

Often on a mud players and objects perform an action such as a dog farting. The mud client can convey the action to the player. The mud specifies an action has occurred in the 3dtags eg {odog,afart} or if a player farts {uafart}. The mud client then looks up the config file actions element and then peforms the action. For example in the actions element is might specify that a fart sound should be played.

<ACTION action="afart" sound="fart"/>

Actions are either peformed by other object's on the mud (eg a dog) or by the player (you). Different objects can perform different actions. For example the sound of a dog farting can be different to the sound of a human farting.

This differentiation is specified in the 'actiontype' attribute of an object. For example:


<OBJECT name="human"><ACTOR filename="human.ms3d" actiontype="human"/></OBJECT>
<OBJECT name="dog"> <ACTOR filename="dog.ms3d" actiontype="dog"/></OBJECT>

These action types then link to ACTIONTYPE in actions. For example:


<ACTIONS>

<ACTIONTYPE name="human">
<ACTION action="afart" sound="fart"/>
<ACTION action="ajump" animation="jump" sound="jump"/>
</ACTIONTYPE>
<ACTIONTYPE name="dog">
<ACTION action="afart" sound="dogfart"/>
<ACTION action="ajump" animation="dogjump" sound="dogjump"/>
</ACTIONTYPE>

</ACTIONS>

Note that there are other ways an action can be triggered. These include if an object moves over certain speed. Thus if an knight starts moving it will trigger a walking animation. This is discussed at the end of this document. Also when an object is created it can trigger an event if the 'initaction' attribute is set. For example when a demon is created it makes a spawn sound.

When an action is triggered the mud client can perform a single or multiple tasks. For example the action can involve doing an animation and playing a sound at the same time. Thus you can swing a sword and play the sound of the sword clanging in the same action. These tasks specified in the ACTION element attributes of actions. This is a brief description of each of them:

Sound
Plays a sound. The sound can be delayed using the 'wait' attribute of sounds. Thus if a player jumps up in the air you can play the sound half a second later when the player hits the ground.

Animation
If an actor performs an action eg 'odog,ajump' it is possible for the actor to perform an animation. The attribute 'animation' can link to an animation in actoranimations. The 'animations' attribute of an actor defines the set of animations to use. Thus different actors can have different sets of animations.

Effects
Displays an effect such as an explosion. The 'effect' attribute should match an effect in the effects list.

Object
This displays an object if the action occurs. For example you could display an explosion sprite on top of an item that has exploded. You can use the 'life' property of object to make it disappear after a certain time.

You can also replace an existing object if a certain action is perform. An example might be if you have chopped a piece of wood and want to replace the unchopped model with a chopped model. You would use the 'objectreplace' attribute of actions instead of 'object' to do this.

Turn
You can turn an object so it faces a certain direction. An example might be to if you want a door to open or close.

<ACTION action="aopen" turn="90" sound="door"/>

This will turn the object 90o giving the appearance of a door opening.

Time based actions
The previous tasks mentioned do not take place in a fixed amount of time. For example the 'sound' will play in its entirety. Other tasks complete in a fixed amount of time. For example you can make an object sink down 0.25 units in 12 seconds. For example using the 'positiontoz' attribute and 'time' attribute:

<ACTION action="asink" positionfromz="0.0" positiontoz="-0.25" time="12"/>

Likewise for scaling. In the following example the object will grow in size by a factor of 2 within 1 second:

<ACTION action="aspawn" scale="2" time="1" animation="awrithe" sound="demonbirth"/>

Speed Triggering Actions
As mentioned an action can be triggered by an object moving over certain speed. For example you might want to a player a walk animation if a knight starts moving around. Using speed triggered events it saves the mud having to tell the mud client directly that an object should start playing a walk animation. Instead the client decides to do it.

A speed triggered action is specified by leaving the 'action' attribute blank and using the 'speedover' attribute instead. When an object has a speed greater than 'speedover' (mud units per second) then the action is triggered. For example:

<ACTION speedover="0.1" sound="walk" animation="aw"/>

If the object moves below speedover the default animation (eg idle) is switched back on. It is possible to have multiple speed overs. For example if the object moves over 0.3 mud units per second a run animation could be played:

<ACTION speedover="0.3" sound="run" animation="arun"/>