You are looking at a material called leadquest

This material can be used to manage a 'leadquest'. This is a quest that involves finding and escorting the object to some destination, protecting it along the way, and receiving its treasure.

There are two ways this quest can end:
Failure- The leadquest object dies along the way and is left to rot away.
Success- The leadquest object is escorted safely to the destination.

Consider putting this material on a weak object, so that protecting it becomes a challenge. Also, since the successful escort will receive all items that are given to your object, be sure to give the leadquest object something as treasure that is worth the quest.

Setting up the quest requires the following steps:
1. Bring the object to the destination, then use it. The object will record the destination and begin following you.
2. Lead the object down a path that leads to the starting location. You must stop in each room and wait for the object to memorize it.
3. Once you are at the destination, use the object one more time and it will finish the set-up.
4. Now the fun part. Sprinkle some dangers along the path. For example: spawn a few passive creatures, forcing them to guard exits. Then put a couple of spawned aggro creatures in the same room. If you are a coder, then consider exploding or mechanical trap objects along the way, or perhaps something that triggers ambush.

Reactions:
first use: This does a couple of things:
- records the location as the destination in the material's leadquest values
- begins following you
second use: This does a number of things:
- a newsflash is created and published in the daily cow
- a rumour is created and recorded in the book of rumours
- additional leadquest values (qname, rumour, and lastloc) are set
Note: be sure you've gendered your object before using it the second time.

examine: This simply gives a hint that the leadquest object wants to talk (only shown if they are not hosted).

talk: This does a few things:
- records the player as the leader
- issues a conversation to start the quest with the player
- points at the 1st exit
- follows the player
However, talking to a dead leadquest object won't get you anywhere.

tickloc: This depends on whether the object is alive or dead, and whether set-up is complete or not:

tickloc during set-up (record path):
- determines if the location has changed since last recording
- if location is new, then search exits for one that leads back to the previous location
- If exit found then record the location and exit
- If exit not found, then transport you and it back to the last recorded location.

tickloc while alive (play path):
- determines if the location has changed since last recording
- if location is new, see if we are at the destination and complete the quest successfully
- else read it from the path memory
- if the location is in path memory, then point at the correct exit
- if the location is not in path memory, then abandon the escort and run back to the last known location

success:
- give the escort whatever is in the inventory
- issue a news article declaring the successful end of the quest
- remove the rumour from the rumour book
- remove leadquest from the object's materials

Note: for now, the quest object is just left at the destination, unable to do much from that point on. Thorn is contemplating it committing suicide once the winning player leaves the room.

tickloc while dead
- check and see if _decaymeat_ is in the material list
- if not then put it there and make a death throe

The decaymeat material will cause a deathbydecay message just before erasing the leadquest object that was left for dead. Players can avoid this by reviving it with the cpr command.

deathbydecay
- The initial rumour is removed from the book of rumours and erased.
- An obituary is created and published in the daily cow, indicating the escort being sought for questioning by the authorities.

Customizing the quest name and story
We tried to make the default name and story work well enough, but you may want something better. Some simple scripting can be used to customize the setup of your quest. Just script the object that has _leadquest_ material on it, add a block named leadquestdata. This will override the leadquestdata block defined in the material object. The purpose of this block is to set up $questname which becomes part of some rumour and news object names, as well as $queststory which becomes the info of those objects. Don't put things like [$init_obj] in $queststory since it is not sent as a message but put in the info.

Note: you must do this before you use your leadquest object the 2nd time, since this sets up the news and rumour.

Some variables are already available:
$myclass = The class of the leadquest object.
$locclass = The class of the leadquest object's location.
$heshe, $himher, $hisher = Make sure you gender {object} so these will hold something besides 'it'.
$destclass = the class of the destination (probably best not to reveal this, though).

Example:
##leadquestdata:
$questname = "the frightened merchant";
$queststory = "A merchant is waiting at $locclass for someone to escort $himher on a dangerous journey. if taken safely, $heshe is prepared to award you with a reward.";

note: double quotes appear as " when you examine this, so you will need to fix the above example in your code

Customizing conversation
You can also use simple scripting to add something to the object's behavior when the player talks to it, before it follows the player. Just script the leadquest object and make a block called explanation where you can have it say something before following, and even set a delay (in seconds) before it strikes.

Some variables available:
$init_obj = the object id of the player that just arrived.
$actor = the object id of the leadquest object.

Example:

##explanation:
print "[$init_obj] recognizes [$actor] and says, 'I heard you are looking for escort. How can I help?'";
print "[$actor] grins at [$initobj] and replies, 'Ah yes, I would truly appreciate it. Now I shall show you which way to go as I follow.'";
$followdelay = 10;

note: double quotes appear as " when you examine this, so you will need to fix the above example in your code
Code