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
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Thu Aug 23, 2007 1:23 pm   

Linked List instead of Sequential Master file
 
Thank you to everyone who helped me with my last problem!

OK, I am trying to create a sentry mob. I have created an alias for each area that I would like to go to. In between going to each area, I have the mob spell up. I control this mob today with a sequential master file that looks like this...

grotto
spellup
windy
spellup
icepeak
spellup
...

The problem is, when someone attacks that mob or my connection bounces, it throws off the whole script. I can't disable it and start over because it still has to fall through the entire list of places. (FYI... our mud as diffferent planes, so when you die or disconnect, you change planes). It can take 10-15 minutes before I can get this mob back on track. What I'd like to do is to use a linked list so that if I detect that I am on a different plane, I can clear the list and start over from the beginning. I don't need to go through the list in any order, except for the spellup, which means that I need to invoke an area, then spellup, an area, then spellup. Any help someone can give me on this would be much appreciated.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Aug 23, 2007 2:02 pm   
 
Well there are many ways to handle this I'll start with a few simple pointers.

You need a string list of course.
#var locations grotto|windy|icepeak

Then you can pick a random location to go to.
#var goingTo %random(1,%numitems(@locations))
#var goingTo %item(@locations,@goingTo)

Do whatever it is that you need to do to go there.
go to @goingTo

spellup

Then move to the next location on the list.

#var goingTo %eval(%ismember(@goingTo,@locations)+1)
#var goingTo %item(@locations,((@goingTo-1) \ %numitems(@locations))+1)

Do whatever it is that you need to do to go there.
go to @goingTo

spellup

If you die do the random thing again and repeat.

Sorry this is untested as I am in a hurry...
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Thu Aug 23, 2007 3:55 pm   
 
I'm not quite sure what to do with all of this. Is any of this supposed to be looped? I have put the spellups in each of the area aliases that I described above, so all i am looking to do now is to just go to each of the areas... begining with one called homebase and ending with one called homefromnexus. All of the others can be random, but random is not necessary.
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Thu Aug 23, 2007 4:14 pm   
 
Here is what I have now. I keep getting 'homebase' is not a recognized command, even though it is a defined alias.

#var bot_running 1
#var numitems 0
#additem arealist homebase;#add numitems 1
#additem arealist grotto;#add numitems 1
#additem arealist windy;#add numitems 1
#additem arealist ettin;#add numitems 1
#additem arealist stormguard;#add numitems 1
#additem arealist icepeak;#add numitems 1
#additem arealist blackmire;#add numitems 1
#additem arealist nstormguard;#add numitems 1
#additem arealist whitecliff;#add numitems 1
#additem arealist teardrop;#add numitems 1
#additem arealist homefromnexus;#add numitems 1
#loop @numitems {@arealist.1;#delitem arealist @arealist.1;#del numitems 1}

Any suggestions as to what I'm doing wrong?

Here is an example of one of my aliases

this one is titled whitecliff
target 34499 12623;rw;rc;rp;#wait 15000;#var location "Whitecliff Point";#var xcoord 34499;#var ycoord 12623;rc;rw;rw;rc;#wait 10000;target 37000 66000;rw;rc;rp;#wait 11000;invis;20sec
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Aug 23, 2007 4:59 pm   
 
You're looping through the commands, and regardless if zMUD is connected or not, or if you die, zMUD still thinks it needs to loop through the entire list. You may want to handle it by adding the next area in each alias. For instance:

#ALIAS homebase {blah;blah;blah;blah;grotto}
#ALIAS grotto {blah;blah;blah;blah;windy}

Then, when you want to restart the script, just type "homebase" again. Or you can create an alias to restart the script for you, although that's a bit redundant, using an alias to name an alias with no other arguments.

Another thing - #wait commands can be dangerous to scripts. It's better to use #alarm instead. For instance, in your whitecliff alias:

#ALIAS whitecliff {target 34499 12623;rw;rc;rp;#alarm +15 {#var location "Whitecliff Point";#var xcoord 34499;#var ycoord 12623;rc;rw;rw;rc};#alarm +10 {target 37000 66000;rw;rc;rp};#alarm +11 {invis;20sec}}

I believe that should work. As usual, I don't have zMUD in front of me to test it. You may need to make the alarms +15, +25, and +36 respectively. Just an idea.

Charneus
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Aug 23, 2007 5:46 pm   
 
You'll need to make the alarms +15, +25 and +36 unless you define the alarms within the previous alarm (which is easier to cancel - only one alarm is active at a time).

But I don't think your suggestion solves the fundamental problem, charneus, which is that xantharus needs a way to exit the loop and force it to stop sending commands. I think the easiest way to do this would be with the #loop command example you've already got - add an #if to each iteration that checks an @Aborted variable - if the variable is 1, use #abort 1 to cancel the script.

If you extended this looping-through-list logic to your area-specific aliases as well, you could add the abort command to their loops as well, and cut out the commands as soon as you die or whatever, rather than when you reach the end of the list and try to move to the next area.

Also, as an aside, you don't need to keep the number of items in the list as a separate variable - just use %numitems.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Aug 23, 2007 5:57 pm   
 
Charneus's comments aside your issue with the undefined command is that you need to use the #execute command to expand strings into aliases.

#loop @numitems {@arealist.1;#delitem arealist @arealist.1;#del numitems 1}

should be

#loop @numitems {#exec @arealist.1;#delitem arealist @arealist.1;#del numitems 1}


Now, as for my script yes you could place it into a loop but I would suggest using a stateful engine or something of the sort.

First you need to create a string list of locations as before. For a test you could just type this into the command line.

#var locations grotto|windy|icepeak

Then we make the starting alias. You could also use this as the beginning of the bot for when you die. It picks a random starting point from your locations.

#alias randomPick {#var goingTo %random(1,%numitems(@locations));#var goingTo %item(@locations,@goingTo)}

Then you would want to go to the other locations without repeating them until you have done them all I would think.

#alias NextPick {#var goingTo %eval(%ismember(@goingTo,@locations)+1);#var goingTo %item(@locations,((@goingTo-1) \ %numitems(@locations))+1)}

After running either of these aliases you have picked a destination. Now you need to actually go there.

So you would need to create an alias for actually moving to each location somehow.

Once you have arrived you will then need to do your spellup script.

Then if you die you can do random pick and start again.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Thu Aug 23, 2007 7:01 pm   
 
The only question I still have is... I have 11 aliases defined, all with their travel commands embedded. I don't mind randomizing the middle 9 areas, but I have specific one I want to go to first, and one specific one to end it. The logic goes something like this (remember, we have 3 planes - home plane, realms and nexus - you have to go from home plane to realms before you can shift to nexus. All of this script, except for the 1st place and last place will be in the nexus.)

-spell up, travel from home plane to realm, shift into the nexus, travel to first location
- travel to 2nd, possibly random location, then travel back to first location (the travel from 1st location, which is home base, to 2nd location, back to home base is all self contained in the alias)
- travel to 3rd location and back, etc
- at the end, shift back from the nexus to the realm and go back to my homeplane.

So, the first one where I travel to my homebase in the nexus needs to go first, the last one where I travel from the nexus back to my homeplane needs to be last and the rest can be random.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Aug 23, 2007 7:09 pm   
 
Use the @locations variable that Arminas has given you to store only the locations that you want to go to randomly. Then hardcode the first part (use an #if to check if you've gone anywhere yet), and use randompick after that. Once you've exhausted all the possible destinations, @goingTo should be empty and you can use an #if to check for that too, and go to the final place.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Thu Aug 23, 2007 8:30 pm   
 
OK... So here's where I am...

I typed: display spybot_start
Spybot_start (trigger fires)
Unrecognised command '#' (type 'commands' to list those available).

Here is the actual Trigger:

#TRIGGER {^spybot_start$}
#var bot_active 1
#addi locations grotto
#addi locations blackmire
#addi locations stormguard
#addi locations windy
#addi locations whitecliff
#addi locations ettin
#addi locations icepeak
#addi locations nstormguard
#addi locations teardrop

#if (@bot_active = 0) {say Aborting Bot...;#abort 1;#exec @homefromnexusstop} {say Giving 60 seconds to make sure at home plane...;#wait 60000;#exec @homebase}

#alias randomPick {#var goingTo %random(1,%numitems(@locations));#var goingTo %item(@locations,@goingTo)};#alias NextPick {#var goingTo %eval(%ismember(@goingTo,@locations)+1)
#var goingTo %item(@locations,((@goingTo-1) / %numitems(@locations))+1)}

#UNTIL (@goingTo = "") {#if (@bot_active = 0) {say Aborting Bot...;#abort 1;#exec @homefromnexusstop} {#exec @randomPick;#alias randomPick {#var goingTo %random(1,%numitems(@locations));#var goingTo %item(@locations,@goingTo)};#alias NextPick {#var goingTo %eval(%ismember(@goingTo,@locations)+1);#var goingTo %item(@locations,((@goingTo-1) / %numitems(@locations))+1)}}};#if (bot_active = 0) {say Aborting Bot...;#abort 1;#exec @homefromnexusstop} {#exec @homefromnexus}}


Is this what you were talking about? Did I do this right? Why the error? I broke it apart to make it easier to read... if you question the syntax, here is the raw export.

#TRIGGER {^spybot_start$} {#var bot_active 1;#addi locations grotto;#addi locations blackmire;#addi locations stormguard;#addi locations windy;#addi locations whitecliff;#addi locations ettin;#addi locations icepeak;#addi locations nstormguard;#addi locations teardrop;#if (@bot_active = 0) {say Aborting Bot...;#abort 1;#exec @homefromnexusstop} {say Giving 60 seconds to make sure at home plane...;#wait 60000;#exec @homebase};#alias randomPick {#var goingTo %random(1,%numitems(@locations));#var goingTo %item(@locations,@goingTo)};#alias NextPick {#var goingTo %eval(%ismember(@goingTo,@locations)+1);#var goingTo %item(@locations,((@goingTo-1) / %numitems(@locations))+1)};#UNTIL (@goingTo = "") {#if (@bot_active = 0) {say Aborting Bot...;#abort 1;#exec @homefromnexusstop} {#exec @randomPick;#alias randomPick {#var goingTo %random(1,%numitems(@locations));#var goingTo %item(@locations,@goingTo)};#alias NextPick {#var goingTo %eval(%ismember(@goingTo,@locations)+1);#var goingTo %item(@locations,((@goingTo-1) / %numitems(@locations))+1)}}};#if (bot_active = 0) {say Aborting Bot...;#abort 1;#exec @homefromnexusstop} {#exec @homefromnexus}}
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Aug 23, 2007 9:27 pm   
 
Code:
#alias randomPick {#var goingTo %random(1,%numitems(@locations));#var goingTo %item(@locations,@goingTo)}
#alias NextPick {#var goingTo %eval(%ismember(@goingTo,@locations)+1);#var goingTo %item(@locations,((@goingTo-1) / %numitems(@locations))+1)}


These are create alias commands that you type into the command line.
They don't belong in the trigger.
To run them you simply place the word in the script where you have these commands.

* @goingTo will never show NULL or be empty. The whole point was to make a list that wraps around. So the bot could run indefinitely if you wanted/needed it to.

* You do not need to make spybot_start as a trigger you could make it as an alias.

* I was unable to see anything that would cause the error that you recieved. In fact I ran this script as is and I did NOT receive the same error. So it appears that there is an error inside @homeFromNexuxstop or one of the other variables you are trying to execute.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Aug 24, 2007 3:04 pm   
 
Doh! Fang and Arminas, you're right - I didn't address the overall issue. I was hurried and didn't pay much attention to that. :\ Ugh. Glad you two are always around, though!

Charneus
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