Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Mon Apr 25, 2011 5:13 pm   

Running Back to a Set Coordinate
 
Ok, I'm making a bot. I'm new to scripting and it's by far the most complicated thing I've done to date, but so far it's worked. Even the part I'm having problems with now worked up until about an hour ago, and I can't see what I'm doing wrong.

The aim of the bot is to kill things on a lake for leveling purposes. It scans and when I see another applicable mob on scan, it runs to it and kills it. Pretty standard. When I can't find one on scan, I walk in a random direction and scan again. This process repeats until I find one. It works great so far. An unfotunate side-effect of running in a random direction, which happens more frequently as I deplete the population of denizens on the lake, is that I tend to wander off of the lake to areas where there are no mobs I want to kill. Enless wandering is bad, so I made a thingy to set a point using my sextant, then walk back to that point if I run ashore. It was working, not it's not, and I can't see the reason. All it's doing now is looking at my sextant and reporting my relative postion via the alarm/echo I have at the end of the big trigger.

Fresh eyes or a more knowlagable perspective would be a great help.

Here's my script:
Code:

#CLASS {Leveling|Lake|Shore Return}
#ALIAS goback {#VAR longrun {%eval(@curlongitude-@setlongitude)};#VAR latrun {%eval(@curlatitude-@setlatitude)};#IF (@longrun>0) {#LOO %abs(@longrun) {north}} {#LOO %abs(@longrun) {south}};#IF (@latrun>0) {#LOO %abs(@latrun) {west}} {#LOO %abs(@latrun) {east}}}
#VAR gorunback {2} {2}
#VAR longrun {0}
#VAR latrun {0}
#VAR setlongitude {0}
#VAR setlatitude {0}
#VAR setcoords {2}
#VAR curlatitude {}
#VAR curlongitude {}
#TRIGGER {^You are currently at position %1, %2 in *.} {#IF (@setcoords=1) {#VAR setlatitude %1;#VAR setlongitude %2;#VAR setcoords {2}} {};#VAR curlatitude %1;#VAR curlongitude %2;#echo Current Coordinates are: @curlatitude,@curlongitude.;#echo Current Return-To Coordinates are: @setlatitude,@setlongitude.}
#TRIGGER {^ Snowy Peaks of Krayos Mountain} {#IF (@gorunback=1) {look sextant;#VAR longrun {%eval(@curlongitude-@setlongitude)};#VAR latrun {%eval(@curlatitude-@setlatitude)};#IF (@longrun>0) {#LOO %abs(@longrun) {north};#VAR looking {1};#VAR searching {2};#VAR gorunback {2};#alarm +4 {gogo}} {#LOO %abs(@longrun) {south};#VAR looking {1};#VAR searching {2};#VAR gorunback {2};#alarm +4 {gogo}};#IF (@latrun>0) {#LOO %abs(@latrun) {west};#VAR looking {1};#VAR searching {2};#VAR gorunback {2}} {#LOO %abs(@latrun) {east};#VAR looking {1};#VAR searching {2};#VAR gorunback {2}};#alarm +1 {#echo Relative Longitude: @longrun Relative Latitude: @latrun}} {}}
#CLASS 0


The echo on the end of the ^ Snowy Peaks of Krayos Mountain part are reading Relative Latitude and Longitude of 0 right now.

If you're wondering what 'gogo' is, it's just my on switch alias for the bot. It gets things going. Also, I have about 9 more triggers that look exactly like Snowy Peaks, but have different names. They all used to work.

If there's anything I left out, let me know. I'm sure this isn't the prettiest script ever, either, so I apologize.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Mon Apr 25, 2011 8:03 pm   
 
Are you sure the patterns still match?
Sometimes admin will change them to throw off suspected botters.
Also I noticed some of your anchored triggers have a leading space.

Check for duplicate variables.

If all the similar triggers run the same code, you may want to convert that to an alias, and just have the trigger call the alias, to avoid having one still using old, bad code.

Also, using %1 in a pattern is not the most efficient way to do things.
You should use the pattern matching symbols wrapped in parenthesis to define %1 and %2 in the script section of the trigger.
#TR {^You are currently at position (%d), (%d) in *.}

Have you mapped the area you are botting in? So long as it keeps your location up to date, you could tell the mapper to speedwalk to a specific room.
_________________
Discord: Shalimarwildcat
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Mon Apr 25, 2011 10:46 pm   
 
Yeah, I've tried using the mapper before for something similar. It hated me. I was mapping out a big island and I took a look at the mapper afterwards to see how it was keeping up and it was a jumbled mess of rooms on top of rooms and pathways cross-crossing other pathways instead of a nice, flat, laid out map. So I gave up on it and decided using my sextant and the game's own coordinates was the best idea.

I'm a newb to all of this, still. What do you mean "(%d), (%d)"?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Mon Apr 25, 2011 11:40 pm   
 
%d will take the place of any positive number for the purpose of trigger pattern matching
_________________
Discord: Shalimarwildcat
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Tue Apr 26, 2011 1:49 pm   
 
When working with two of them, for (x, y), how does the script differentiate between the two?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Tue Apr 26, 2011 3:07 pm   
 
Its the order they come in, when pattern matching the first group of text surrounded in () is %1 second is %2 and so on.

So long as the string from the mud is patched my your pattern, they should already be differentiated...
I saw nothing wrong with the body of your trigger above, just this quirk of the pattern (though I only skimmed it)
_________________
Discord: Shalimarwildcat
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Tue Apr 26, 2011 3:22 pm   
 
Code:

#CLASS {Leveling|Lake|Shore Return}
#ALIAS goback {botstop;look sextant;#alarm +1.5 {#VAR longrun {%eval(@curlongitude-@setlongitude)};#VAR latrun {%eval(@curlatitude-@setlatitude)};#IF (@longrun>0) {#LOO %abs(@longrun) {north}} {#LOO %abs(@longrun) {south}};#IF (@latrun>0) {#LOO %abs(@latrun) {west}} {#LOO %abs(@latrun) {east}}};#VAR gorunback {2};#VAR looking {1};#VAR searching {2};#alarm +3 {gogo}}
#ALIAS setitup {#VAR setcoords {1};look sextant;#VAR gorunback {1}}
#VAR gorunback {1} {2}
#VAR longrun {19}
#VAR latrun {4}
#VAR setlongitude {644}
#VAR setlatitude {715}
#VAR setcoords {2}
#VAR curlatitude {}
#VAR curlongitude {}
#TRIGGER {^You are currently at position %1, %2 in *.} {#IF (@setcoords=1) {#VAR setlatitude %1;#VAR setlongitude %2;#VAR setcoords {2}} {};#VAR curlatitude %1;#VAR curlongitude %2;#echo Current Coordinates are: @curlatitude,@curlongitude.;#echo Current Return-To Coordinates are: @setlatitude,@setlongitude.}
#TRIGGER {^ Snowy Peaks of Krayos Mountain} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Trees of Krayos Mountain} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Krayos Mountain} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ High Mountain Trees of Krayos Mountain} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Mohaa River } {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ A Small Trail} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Foothills of The Callias Mountain Range} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Callias Mountain Trees } {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Tantaa Stream} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Rolling Hills of Fraou Forest} {#if (@gorunback=1) {goback} {}}
#TRIGGER {^ Fraou Forest} {#if (@gorunback=1) {goback} {}}
#CLASS 0




I changed the bulk into an alias like you suggested and added an alarm because, while testing for the problem, I noticed that if I did it twice, it worked the second time. I figured that meant it had something to do with processing the info fast enough to trigger right or something, so I put the alarm in there and now it works. Seems odd, but it worked, so I won't question it. I stil use %1 and %2, though, because I didn't quite get it when you suggested it in the beginning. >.>

Anywho, it all works like a dream now. :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net