Scripted Recovery From Death

Recover a character’s equipment after death.

Again using CMUD as the client and Nukefire as the MUD for our example, we explore the fastest way to get the character back up and its equipment recovered after a death.

The game provides a convenient ‘retrieve’ command which must be executed in a specific place.

The sequence of events occuring between Nukefire and our bot component are:

  1. Notification of death
  2. Presentation of the list of options as for login (quit, reenter the game, etc.)
  3. Reenter the game
  4. Execute a series of moves for east, south, west, down, and south
  5. Execute the retrieve command
  6. Depending on whether the character is a cyborg type or not, execute a command to get everything out of the ‘corpse’ or ‘remains’
  7. Wear the equipment
  8. Retrieve miscellaneous equipment from the ‘pouch’
  9. (ready to go- we could sacrifice the corpse/remains but some edge cases make that better done as a human choice once the script runs)

Steps one and two are handled simply with a #COND (multistate trigger). We ask CMUD to catch two things within 20 lines of each other:

  • A line saying “You are dead…” and only that- not “Bozo gossips ‘You are dead…’
  • A prompt saying “Make your choice: ” and only that. This text being a prompt (not a full line with a carriage return at the end: the server waits)

The “Make your choice: ” text being a prompt makes our trigger much more secure: prompt lines are not included in user communications such as mud mail.

Once we’re satisfied that the death is genuine, there would be little advantage to further checking at each command step. Instead, we simply send all of the required commands in a block.

The result is the character standing in the morgue wearing whatever gear is left (in the event of looting after death) and awaiting further action. Generally, next steps might involve rebuilding the group if all characters died or starting to summon either this character or others to group up.

Actually making all of that happen is much more concise than the explanation was:

#TRIGGER {^You are dead!  Sorry[.][.][.]$} {#PRINT Dead} "" "regex"
#COND {Make your choice[:] $} {#PRINT COND MATCHED;1;e;s;w;d;s;retrieve;get all remains;wear all;get all pouch} {Within|Param=20|regex|prompt|nocr}

NOTE THAT THIS EXAMPLE USES ‘remains’ AS OUR TEST CHARACTER SO FAR HAS BEEN A CYBORG. Substitute the word ‘corpse’ for characters which leave a corpse instead of remains. You could also do both in the script, but that would risk emptying another corpse/remains in the room which doesn’t belong to you.

Discover more from OutGamer

Subscribe now to keep reading and get access to the full archive.

Continue reading