Custom Actions: Our Version of Scripting

Some MUDs, including Basternae 2 and those derived from the Envy family tree, support MobProgs.

Some MUDs, inlcluding Basternae 2 and those derived from the Diku/Envy family tree, used custom C code (“spec_fun” code) to add special abilities to mobs and objects.

MobProgs are useful, but they can be a pain to edit because they’re pretty “scripty” and most editors don’t have any data validation.

Special functions require the direct attention of a programmer for things that aren’t necessarily complex enough that they should require code.

What I’ve come up with for Basternae 3 is something I call “Custom Actions”. They can be applied to mobs, objects, races files, and class files. It’s sort of an action template definition that will be easy to edit using the Basternae Editor’s GUI (when I finish it). The general idea is that there are triggers with one or more actions that can be associated with them.

Editing will be done using a sort of “Mad Libs” style interface. You’ll build descriptions of triggers and actions using buttons and drop-downs. For instance:

“When the mobile is attacked”:

“Say” “Tough luck, buddy, I brought my posse with me.”
“Wait” “two seconds”
“Create mob” “8192”
“Create mob” “8193”
“Create mob” “8194”
“Wait” “one second”
“Say” “Now you’re gonna get it!”

“When in combat”:

“Cast spell” “fireball” “4% chance”

“When a player tries to leave the room in direction” “north”:

“Prevent action”
“Say” “You’re not invited to this party.”

“When room contains object” “23” (a corpse):

“Destroy object” “23”
“Echo” “The ravenous bugblatter beast devours another corpse.”
“Wait” “3 seconds”
“Interpret command” “burp”

Here’s a list of the triggers and actions I’ve come up with for the first version:

———-

Each trigger has a percent chance of executing.  Each trigger also has a data field that may or may not be used depending on the type.

Trigger Types

Action: When someone uses the command

Value contains the command name.

Combat: When in combat

Value is not used.

Death: When killled or destroyed

Value is not used.

Engage: When combat is initiated

Value is not used.

Entry: When entering a room

Value is not used.

Exit: When exiting a room

Value is not used.

ObjectInRoom: When room contains the object

Value is the index number of the object to react to.

PlayerEntry: When a player enters the room

Value is not used.

PlayerExit: When a player leaves the room

Value is optional and is the direction to pay attention to.  Blank means watch all directions.

Random: A random chance

Value is not used.

ReceiveItem: When receiving an item

Value is optional and is the index number of the object to react to.

ReceiveMoney: When receiving money

Value is optional and is the minimum amount of money needed.

Speech: When someone says

Value is the word or phrase to react to.

Action Types

Each action has a data field that may or may not be used depending on the type.

Attack: Attack the player who caused the trigger to fire.

Value is not used.

CastSpell: Cast the spell

Value is the name of the spell to cast.

CreateMobile: Creates a mobile

Value is the index number of the mobile to create.

CreateObject: Creates an object

Value is the index number of the object to create.

DestroyObject: Destroys the object

Value is the index number of the object to destroy.  First the room is checked, then the mobile’s inventory.

Delay: Wait for this many seconds

Value is the number of seconds to wait.

Echo: Echo text to the room

Value is the message to be printed to the room.

GiveObject: Give player an object

Value is the object index number to give to the player who caused the trigger to fire.

InterpretCommand: Interpret the command

Value is the command line to be interpreted, i.e. “kick troll” or “jump”.

Move: Move in direction

Value is the direction to move in.

PreventAction: Prevent the action (only works with action and player exit triggers).

Value is not used.

Say: Say something.

Value is the phrase to be said.

Teleport: Teleport to another room

Value is the room index number to teleport to.

TeleportPlayer: Teleport the player who activated the trigger to another room

Value is the room index number to teleport the player to.

TeleportAll: Teleport all players in the room to another room

Value is the room index number to teleport the player to.

UseSkill: Use the skill

Value is the skill specified, i.e. “hide” or “kick”.

ZoneEcho: Echo text to the zone

Value is the text to be shown to everyone in the zone.

Destroy: Destroy self

Value is not used.

———-

One of the good things about the way it’s been coded is that triggers and action types can be added very easily.  The actual in-game implementation of it has yet to be done, but that should be easy enough.

If you think of anything that you could imagine doing in a zone that these commands won’t allow you do do, let me know, either as a comment on this post, or email me if you want to chat in more detail.  My name is xangis and I use Yahoo for my email.