Running a series of commands repeatedly until something happens

Posted by Elvaago on Wed 11 Apr 2007 05:18 PM — 7 posts, 27,620 views.

Netherlands #0
Hello all.

I play in a game that has a certain level that goes 19 times south, 19 times east, 19 times north and 19 times west and then all over again. I am hunting for a specific type of monster. What I would like is to be able to continuously keep on walking through the grid indefinitely, but when a certain monster shows up, I want to stop walking and send a beeping signal or something or other.

Is this very complicated?
Australia Forum Administrator #1
If you are just starting in scripting I would use Lua, instead of VBscript. :)

It isn't that complicated. I think in your case I would maintain in a script my current location (or at least, how far I had to go in a direction). For example, if I had gone 10 east, then I have 9 east to go. Then when I have 0 east to go, I switch to north with 19 to go, and so on.

Then for each location I would send a direction (eg. east) and wait for a trigger to fire, the trigger being based off something you expect to see when you reach a new room (eg. Exits: *).

When that trigger fires you are in your new room, and either the mob is there, in which case you fight it, or it isn't, in which case you go back to doing the next movement. It is hard to be more specific without seeing a sample of MUD output, but that is the general idea.
Netherlands #2
OK, I have quite a bit of experience in Visual Basic for Applications. Would this help at all with VBScripting?

And to be more specific, a generic room in this game would look like this:

You walk down the tunnel.
You can see exits to the: south west
1. Transparent stone
2. Springgun (Shock Tox) Dart weapon
3. Green stone

And when a monster arrives it looks like this:

You walk down the tunnel.
You can see exits to the: east west
1. Vibroaxe
2. Laser Mineral Composition Analyzer
A Deadhead emerges from the shadows!

So I need to walk 19 times south, 19 times east, 19 times north and 19 times west (and then repeat from the beginning) until I see the line 'A <specific monster> emerges from the shadows! (I don't want to actually fight it automatically, cause it can kill me quite easily. I need to be careful.)

Could you give me some pointers as to how to start?
Australia Forum Administrator #3
Well, I would make a trigger matching on:


Match: You can see exits to the: *


That would catch the arrival in a new room. The trouble is the monster message appears after that. So you probably want to fire up a timer that goes off in about a second, that moves you to the next room.

Meanwhile if you get a message (this would be another trigger):


Match: A * emerges from the shadows!


Then you could decide, based on the mob name, whether to cancel the timer or let it fire and keep you moving.

You will have to try to work this out yourself a bit. Writing what sounds a lot like a bot script is not something I am really prepared to do.

If you have a specific query, you could post what you have tried, what you got from the MUD, and what went wrong.

See this post for how to copy any triggers etc. you might have written and put them into the forum:

http://www.gammon.com.au/forum/?id=4776
Amended on Thu 12 Apr 2007 06:30 AM by Nick Gammon
Netherlands #4
print(currentdirection)
print(targetacquired)
if currentdirection=="south" and targetacquired~=1 then
Send ("south")
end
if currentdirection=="east" and targetacquired~=1 then
Send ("east")
end
if currentdirection=="west" and targetacquired~=1 then
Send ("west")
end
if currentdirection=="north" and targetacquired~=1 then
Send ("north")
end

This results in the following. I walk one more room than the one the monster is at:

You walk down the tunnel.
You can see exits to the: east west
west
0
You walk down the tunnel.
You can see exits to the: east south west
west
0
A Russell Rowan emerges from the shadows!
1
You walk down the tunnel.
You can see exits to the: east west
west
1
Australia Forum Administrator #5
As I said in the earlier post, when you get the Exits match, you don't know if the monster is there yet, so you really need to make a timer (say for half a second), and move, when the timer fires, if the monster has not shown up.
Netherlands #6
Thank you.
I put the moving around command on a 2 second timer and it works perfectly.

Now I'm turning it on and let's hope I'll find my monster soon. :-)