Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Scripting a "flee/steal" routine

Scripting a "flee/steal" routine

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Pez   (6 posts)  Bio
Date Wed 22 Sep 2004 09:56 PM (UTC)
Message
I am new to vbscript, and I am attempting to script a flee steal routine. I have done extensive research and I haven't yet seen the problem I am having addressed here.

Any help would be appreciated.

Here is a general description of the problem.

I have a targeting system, similar to a pk targeting system. I have a victim, and a list of items to steal from the person put in an array via a variety of aliases.

What I am trying to do is execute an alias command that calls a script which in turn will do a variety of things:
1. execute a flee from battle
2. check to see if the victim is in the target list
3. check to see if the items to be stolen list has been populated
4. If yes to both, attempt to steal.
5. Continue trying to steal up to 5 times unless successful. If successful, stop trying to steal.

I am successful in doing all of this so far, except the last item. Right now, I have the steal command set up in a LOOP UNTIL routine, like so:


v_trigok = world.gettriggerinfo ("successfulsteal", 21) -- this gets the successful steal trigger matched option value before the loop

DO
world.sendimmediate v_string -- "this string is the steal item from victim string"
v_count = v_count + 1
v_trig1 = world.gettriggerinfo ("successfulsteal", 21) -- This gets the successful trigger matched option value during the loop

IF v_trig1 > v_trigok THEN
v_stop = 1
ELSE v_stop = 0
END IF

LOOP UNTIL v_count = 7 OR v_stop = 1 -- this is the evaluation phrase to end the loop.


This doesn't work, of course, because the client parses and sends all of the steal commands before the trigger ever gets matched. So, even if the trigger gets matched, the loop has already completed its interations and stop at 7.

Hopefully this is enough information. I really am stumped with this.

Thanks,
Pez
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Wed 22 Sep 2004 10:06 PM (UTC)
Message
You cant use loops, of any kind, (well, I guess if you wanted to send something 10 times, you could loop it) because the client passes off control to the script engine, and then waits for it to get control back, before it does anything else (read: it freezes until your script gets finished).

So, you need to do it a bit differently. Instead of a script driven thing with a continuous loop and if statements, you need a trigger driven system.

Youll end up sending the alias, which 'turns on' your triggers (enables them).

So instead of checking whether the trigger has matched, you'd have the trigger matching do the next thing (and have a trigger for success and another for failure, success moves on, failure tries again, and increments a counter, then checks to see if it should move on anyway).

You also dont need to use sendimmediate (thats for speedwalk stuff) you just use send.


~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Pez   (6 posts)  Bio
Date Reply #2 on Fri 24 Sep 2004 05:30 PM (UTC)
Message
Thanks, that was the problem. I have it all working now using a combination vbscript and triggers.


Pez
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,146 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.