Actions, Zonequests and Resets
How mob and object actions fire, how a zonequest moves from step to step, and how resets load a zone.
Sections
Mob Actions
Actions Overview
Mob actions exist to allow builders to personalize mobs, giving them things to do besides sit around waiting to be killed by money hungry players.
Mobs can use most commands that players can, although making a mob do something like ‘who’ just doesn’t get you anywhere. The few commands mob’s can’t use are safeguarded so that they won’t crash the system, although you may spend some time trying to figure out why this mob is not doing anything.
There are 6 parts to a mob action. These are:
- The trigger: What event triggers the mob to act.
- The conditions: Which people, and at what time the mob reacts.
- The phrase: Set with some triggers, it is the text the mob will react to
- The action: What the mob will do.
- The chance: What % of the time the mob will react with this action.
- The state: What state a mob must be in to do this action.
What does this mean. At certain points in the game, in reaction to certain events, the game checks to see if any mobiles are set to react to that event. For the most part, mobiles only ever react if there is someone in the room to see them reacting. Certain triggers (Init, zone reset) do not require a player to be in the room however.
If the appropriate trigger is set, it then checks to see if the person who acted should be reacted to. The phrase is checked with some phrases, to see if the command typed matches when the mob should react. If all these conditions are met, the chance is checked. If it is successful the mob performs the action, if the mob is in the appropriate state to react to this action.
Mobs can perform actions in one of 2 ways. They can either act directly (the default most of the time) or can react ‘delayed’. If they react delayed, it means the next time the mob is checked for movement, etc. Rather than do a generic mob thing, it will perform the next action in its list of delayed actions. Mobs reacting to themselves or other mobs are ALWAYS set to delay, so as not to risk causing infinite mob reaction loops.
Some mob events are targeted. They are directed at a ‘victim’. Others are not targeted, as the mob won’t know whom in the room to target when the action is performed.
Any given mob can have as many actions defined as you want, but each additional action does cost CPU cycles. Moderation is the key, use what is necessary but don’t be frivolous.
Mob Triggers
Each trigger is a flag set in the action. The trigger is activated when the mob does something, or someone in the room does something that the mob can see.
Mob Conditions
Conditions are requirements for the action to execute. They give more control over the circumstances which cause the trigger to happen. Many conditions work as groups. For instance, Day and Night are grouped. If None of the group members are set, then that group is ignored. If any of the group members are set, then all the conditions of that group are active. At least one entry of NPC/PC/IMM/criminal group must be selected for triggers with a target.
Phrase
The phrases were defined under their respective triggers. If you leave phrase blank with one of those triggers, the mob will react to ALL instances of that trigger. If the trigger flag ‘specific phrase’ is set then the mob will only react if the phrase matches the input exactly.
Chance
This is a % chance that the action will be performed. Only one action is ever performed on a given trigger. Having 2 actions at 50% both keying on a trigger will give a 50% chance of the first action going off, if it doesn’t go off, a 50% chance of the other action going off, and an overall 25% chance of no actions going off.
State
The state of an action allows complex paths of action to be possible. An action with state of 0 will always be performed, and will set the mob’s state to 0. An action with state of 9999 will always be performed, but not alter the mob’s state. If the state of an action is set to any other number, the mob will only react when the mob is in that state. A mob’s state is set with the ‘mobact state’ action. This allows a mob to react to one trigger, changing its state.
Action
This is what the mob will do. For the most part, you write this field as if you were the mob, executing one command at a time. Each line of the action field is processed separately, as a separate command. In addition, multiple commands can be specified on the same line by separating them with semicolons. Any line ending with a / will be continued on the next line - in this way, you can enter commands longer than the text wrapper allows.
LML tags can be used withing the body of an action, but, there are definate problems with this. First, the first and last lines of the action have to be <LML> and </LML>. Secondly, LML auto-wraps the resulting text. As mob action processing uses line breaks to designate different commands, you will have to work very hard to make sure that the wrapped line breaks fall where needed. Finally, tags only work in actions where there is a character triggering the action. Update, Init, Enter, Leave, and Zone Reset actions won’t process LML tags.
Within the action text, three characters will be replaced if possible.
$- Replaced with the target’s name (or disguise, as appropriate).%- Replaced with the target’s name (no disguise)._- Replaced with whatever is in the mob’s memory.+- Replaced with the phrase of the action.\(expression)\- Replaced with the processing of an expression. See Help IF
Mobact Command
This is a command a mob can use with a trigger to accomplish something it couldn’t normally do. Used in the right situations, this enables a mob to kill someone who surrenders to it, to create items in reaction to an event, or to do a restore effect. Mobact uses ‘subcommands’ which allow the mob to do many things with just one command. Charmed mobs lose their access to this command.
Samples
---
Action: say hi $ ; poke $
If a player 'testbob' triggers this action, the mob will respond with 2
actions:
say hi testbob
poke testbob
---
To clear existing items during a fight:
Trigger: fight
Conditions: PC, IMM, CRIMINAL
Chance: 100
State: 0, unless you've got more complex states
Action: mobact clear
This will clear the mob's action cue when the mob starts fighting, and
abort any previously queue'd actions.
---
Object Actions
These are similar to mob actions, but, as you might expect, objects can’t exactly use commands. Therefore, everything an object script contains is an object command, and doesn’t need to be prefixed with object.
With one exception (TRIGGER) - the target of the action is the person doing to command that triggered the action. Some objactions don’t have an actor, and are unable to use actor-based commands.
Tech notes: Object actions are more risky than mobactions, as, objects don’t normally do anything. There is no pre-defined flow control with them. For this reason:
- There is no delay setting in object actions.
- There is no re-entrance possible (i.e. if you wear a hat, and that triggers you to have to wear a scarf, any actions related to wearing the scarf wont’ happen)
- Some actions are deemed ‘risky’ - those that move or destroy items or characters. These will short-circuit any remaining actions. (if you’re going to echo something and extract the object, you better do the echo first.)
- Object’s don’t have states. With over 20,000 in the game at a time, I am not sure there is any merit in giving them states.
Object Conditions
Like with mob conditions, these are grouped. If no items in a group are selected, the actions assume that group is irrelevant and treat it as if all are selected. The groupings are separated with a space below.
Action
This is just like with a mob action. The set of possible commands is listed below. Any line ending with a / will be continued on the next line; in this way, commands longer than the line-wrapper allows can be entered.
LML tags can be used withing the body of an action, but, there are definate problems with this. First, the first and last lines of the action have to be <LML> and </LML>. Secondly, LML auto-wraps the resulting text. As object action processing uses line breaks to designate different commands, you will have to work very hard to make sure that the wrapped line breaks fall where needed. Finally, tags only work in actions where there is a character triggering the action. Update, Init, Zone Reset, and other non-actor actions won’t process LML tags.
IF
If is extremely similiar to mobact if for mobactions, with the following differences.
- You have an object, not a mob. Object’s don’t receive text, this can be a lot harder to debug.
- Object’s don’t have eyes.
The best way to get data about the ‘actor’ (if there is one) is to use the [N] expression, which is set up to be the actor. @$.name is less likely to give you what you want. Likewise, [p] for the item is your best bet to get the info you need on the object.
So, if the sword only turns to a snake for bob, your action would be:
if ([N].name == "bob") loadmob 14001
if ([N].name == "bob") roomecho $p turns into a snake.
if ([N].name == "bob") charecho $p turns into a snake.
if ([N].name == "bob") extract
Yes, you have to put the IF on each line, you can’t nest object triggers, so there is no way to get a whole block.
Zonequests
The zonequests are initiated by a mob or object action and should leave clues to what the quest is and how to complete the next step of the quest.
The quest can be as long and complicated as you want it to be, the only limit is your imagination and the amount of work you want to put in it.
Example:
Mob 8600 has a Greet Trigger for PC/Criminal/IMM
Action :
Mobact state 1
say Greetings $ I am in need of finding my master, will you please help me?
Chance: 100%
State: 0
React Phrase Trigger PC/Criminal/IMM
Phrase : yes
Action :
say Thank you $, I really appreciate your help - he was last seen in the
say secret garden, maybe the gardener know something - please hurry it is
say important that I find him fast
Mobact zonequest $ 0 1
Note here that since this is the beginning of the quest the PC is in quest
state 0, and is moved further on to quest state 1.
Mob 8601 is the next mob (the gardener)
He will have a phrase trigger set off if someone asks for whomever the
master of mob 8600 is, and move the PC further with :
Mobact zonequest $ 1 2
Note here that if the player isn't in quest state 1 when the trigger goes
off the player will not change quest state.
This quest might lead on for a long time depending on how many clues and states you put in. The final mob will use :
Mobact zonequest $ n done
This tells the mud that the quest is complete and the PC will be awarded
500 XP and 20 quest points.
Resets
Adding resets is the most conceptual part of building. After you have your prototypes all defined, you need resets to get them into the game.
A reset consists of a room vnum, an instruction, and 4 parameters. The prompts you get when adding resets are pretty self explaning but will be explained below. Not all resets use all four parameters. When a reset command doesn’t need a parameter, it will let you know by using a unused prompt.
The order that resets appear in is important. Therefore it’s easiest to do a little bit at a time, when you’ve got everything for a particular group of resets ready to go. As invalid resets prevent the mud from rebooting, they do not get entered if they contain invalid data.