Looking to write a "chase" script.

Posted by English Lad on Tue 29 Jan 2008 12:32 PM — 2 posts, 13,897 views.

#0
Hi all

First off massive props to Mr Gammon - I've mudded on and off for years, and only recent been pointed in the direction of MUSHclient, and its certainly enhanced my experience.

I've been playing around with the scripting options, mainly for simple things like disarm triggers and hunger/thirst triggers. My knowledge of scripting is therefore, pretty limited but I'm getting there.

The "chase" script i've been thinking off would work like this.

I'd use an alias ctarget *
to set a variable as chasetarget

This would be the person I'd like to go after.

I'd use an alias chaseaction *

which would set a variable for an action to do @ the target.

I'd then have an alias ct, which ideally would perform a few actions.

First off it would scan - returning what is in rooms nearby, if it saw the variable chasetarget in any of those rooms it would then send the appropriate movement commands to go to that room, followed by chaseaction @ chasetarget.

An example of the what the MUD returns for a scan would look like this.

Scan

You scan all around.
You scan north.
You scan east.
*** Range 2 (east) ***
(White Aura) BADGUY the Nastyperson is here, sitting astride a warhorse.
You scan south.
You scan west.
You scan up.
You scan down.

In this example I would want the script to enter east;east;chaseaction @ chasetarget (or whatever the syntax is).

One thing that would be fairly important also would be that the trigger to move to the target and attack it should only trigger when using the alias ct. I'd like to be able to use scan in normal situations without the trigger firing.

Might anybody have any tips on how to go about putting something like this together?
Amended on Tue 29 Jan 2008 12:34 PM by English Lad
Australia Forum Administrator #1
I would start by looking at the FAQ: http://www.mushclient.com/faq , point 21.

That shows how you can make aliases that set variables, that would handle your ctarget and chaseaction aliases.

Then for the actual chase, the ct alias would need to do something like this:

  • Send "scan" (in Lua you would literally do that)
  • Enable the triggers that reacts to the scan results (you do this so that it doesn't happen all the time)


Finally you need a couple of triggers to handle the scan results. Something matching "You scan (north|south|east|west)" (and so on) could be used to remember the last direction.

Then if you get "*** Range 2 (east) ***" (or similar) you could remember the direction and count - this could be used to build up a speedwalk (eg. this could turn into 2E).

The last trigger would match the message about "X is sitting here" where X could be a variable in the trigger match (or simply test it in a script).

If that fires you now know the direction, the person, and the attack method, so you put that all together.

Last thing to do is disable these triggers so they don't fire when you don't want them to. If there is a line like "scan over" you could match that to disable the triggers, otherwise maybe a timer that fires a few seconds later could do it.

I think you will learn more if you try to write them yourself, if you are having problems post what you have achieved so far, and explain what is going wrong.