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
symposes
Novice


Joined: 26 Apr 2006
Posts: 34

PostPosted: Sat Jun 16, 2007 6:40 pm   

Interesting problem with a script setup
 
Im having an interesting problem with a script ive setup.

Long story short, my script walks me around an area.
i broke the path up as segments in a list, using %pop and #exec each segment.
it works great that way
When i enter a room, i send one command, that checks the number of targets i have my triggers watch for.
if there are 0 targets, it starts the next path segment, otherwise it will start the kill script that sets up my combat, kills all the mobs, 1 by 1, then when everything is dead, all corpses buried, and all loot grabbed, it starts me on the next segment.

By manually sending this command everything, I keep an aspect of human intereaction with the mud, this prevents kill stealing, for example.

I decided to see if i could automate it. If figured adding a #wa 2000 at the end of each segment and then having it drop the command i send, automatically, would do the trick.

However instead of attacking each mob 1 at a time, it tries to attack them ALL.
ie i can flag a mob, so that everyone knows i intend to fight it.
Well my script will send kill script command 1 time for every mob, but all at once. so it spams with 3 kills, basicly.
It looks like this on my screen

kill mob
kill mob
kill mob
kill

But I have a feeling if i didnt kill the script, once it killed 1, it would move me through the next path segment.

so i change the special command to pause itself, then do all the checking and then move or kill, same problem.

I tweeked it a little more, and one time it just ran the whole loop, because it wasnt getting targets assigned.

to get targets, i have it setup so when i enter a room, it does a %push for each mob in the room. then it counts that list, and if its greater then 0, it will pop them back out 1 at a time and kill them off, ecetera.

Has anyone ever had this problem, or have any ideas what could be causing it?

I know this is kind of vague, and i do appologize.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sat Jun 16, 2007 7:37 pm   
 
Indeed more info is perhaps needed but few things can be said based on some you gave already.

Whatever you do, don't use #wait. #alarm {+2} or #alarm {*2} is better.

I can't really understand the usage of %push and %countlist though, easier would be to add mobs via %additem to a string list with info you get when you enter the room and then clear the list by using kill %pop(moblist). Once the list is 0, turn 2 second alarm on, hence wait for 2 seconds and then move on.

Don't know if thats what you meant, though.


EDIT: For the sake of not having "kill" firing all at once, you can do something like #if moblist isn't 0 and variable fighting is 0, kill %pop(moblist), set a variable called say fighting to 1. Then you'll need second line which shows that you've killed the mob which would set variable back to 0. I hope it made sense.

Prog
Reply with quote
symposes
Novice


Joined: 26 Apr 2006
Posts: 34

PostPosted: Sat Jun 16, 2007 7:57 pm   
 
progonoi wrote:

EDIT: For the sake of not having "kill" firing all at once, you can do something like #if moblist isn't 0 and variable fighting is 0, kill %pop(moblist), set a variable called say fighting to 1. Then you'll need second line which shows that you've killed the mob which would set variable back to 0. I hope it made sense.

Prog


Basicly disable the kill script until the kill is finished. Hadnt thought of that.

As for using push and all that, I just got the hangs of lists and arrays

I walk into the room and see

Obvious exits:
Mob
Mob
Mob
>

I have a trigger for #tr { ^ Mob$ } {#var targets %push( "mob", @targets)}
then #alias sk {#var killcount %numitems( @targets)
#var target %pop( targets)
tag @target
start}

tag being the command to alert others that the mob is mine. (ingame command)

i have another command called mk which contains this setup
#var killcount %numitems( @targets)
#if (@killcount=0) {
#var next %pop( paths)
#exec @next
}
#if (@killcount>=1) {sk}


if i enter mk manually when the path segment is walked, this setup works perfectly, and trying to automate it with wait was causing it to crash and burn horrificly.

Ill try alarm and see if that does it.
Reply with quote
symposes
Novice


Joined: 26 Apr 2006
Posts: 34

PostPosted: Sat Jun 16, 2007 8:08 pm   
 
Woot, alarm apparently has done the trick... not to mention changing how i threw the pauses in.

instead of doing
#var killcount %numitems( @targets)
#wait 2000 or even #alarm {+2}
#if (@killcount=0) {
#var next %pop( paths)
#exec @next
mk
}
#if (@killcount>=1) {sk}

i went
#var next %pop( paths)
#exec @next
#alarm {+2} {mk}
}

that did the trick, even fixed all the problems i had with it.
Im glad that this little ordeal is done. Now to remove it so i dont have to worry about getting introuble for botting Embarassed


Last edited by symposes on Sat Jun 16, 2007 8:15 pm; edited 1 time in total
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sat Jun 16, 2007 8:10 pm   
 
I'd still say that most of the first part is needless.

#trigger {^(*)$} {targets=%additem(%1, @targets)}

#alias sk {#if (@targets>0) and (@fighting=0)) {fighting=1;tag %pop(targets);start} {#show No mobs to kill in this room, Advancing to part II}}

..Should do the work with less code.

#alias mk {#if (@targets=0)) {#exec %pop(paths)};#if (@targets>=1) {sk}}

Perhaps I misunderstood, though.

EDIT: Blah, you beat me to the bunch :P Cool you got it as you needed, though :)

Prog
Reply with quote
symposes
Novice


Joined: 26 Apr 2006
Posts: 34

PostPosted: Sat Jun 16, 2007 8:18 pm   
 
To use skills like bash, kick, backstab, i have to provide targets, so i pop it into a variable that i can call on during the fight.
I understand what you are getting at though. And again I thank you for the help.

Slimming the code would be cool... but, debugging is twice as hard as coding. so if i code as cleverly as possible, ill never debug it... hehe
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