How to add delays to conditional adventuring?

I am wondering how to write or modify a script to add delays inbetween fights so things dont fly by so fast.

Lets say I have a script that does this:

// Sets up some condition.
// Sets up some location.

adventure(my_adventures(), location);
// Do the next thing.


When the condition is hit, I presume the 'adventure' call completes and the rest of the code gets executed. Either this happens or your run out of turns.


What I want is something like this:

// Same stuff as above.
while (true == adventure(1, location))
{
wait(1);
}

The question is: Does this work? Ashref says that adventure returns a boolean, but I am wondering what it returns. If you have a condition that is met, does it return TRUE? If you adventured for the 1 turn without meeting the condition, does it return false?

If so, the above code ought to work. If this doesn't work, then can anyone make suggestions?


I wanted to slow down several scripts, such as macGuffin. But during actual adventuring, most of them use a code block like previously where there call Obtain(x,y,z) or adventure(my_adv, loc), where Obtain in zlib basically boils down to adventure(my_adv,loc) if you dont have the item or cant buy it.

Thanks for the assistance!
 

StDoodle

Minion
adventure() returns false if, for any reason, the specified number of adventures isn't used. This includes not only errors, such as being unable to access a location, but also having your conditions met before all adventures are used. If you call adventure() as above, 1 adventure at a time, it should only return false if there is a problem. Also, since while operates with a boolean, you could simply type:
Code:
while (adventure(1, location) { wait(1); )
I imagine the easiest thing to do would be a find-and-replace on all calls to "adventure(" in the script you're using, replacing it with a custom designed "my_adv(" function that takes the same parameters. Probably:
Code:
boolean my_adv(int adv, location place) {
   int count = 0;
   while (adventure(1, place) && count < adv) {
      wait(1);
      count += 1;
   }
   if (count < adv) return false;
   return true;
}

Edit to add:

1 major caveat; adventure() tries to USE the specified number of adventures, not to make the specified number of attempts. If, for example, you are able to get a non-combat adventure that takes no adventures AND satisfies your goals, even the above function would return false. I'm not sure if there are any such conditions that could occur off the top of my head, but it's something to keep in mind. As an alternative, you could use adv(), which is similar but different.
 
Last edited:
Ok, so how would that code work then?

On the 5th adventure, my condition gets met.

On the 6th loop, it would try to do an adventure for 1 turn, but then it would return false because the condition was already met?

I thought that when a condition was met when auto-adventuring, that it would reset that condition. For example, if you bounty-hunt for 6 whatevers, on the 6th one, it returns false, resets the counter to 6. So if you hit start again, it would start trying to find 6 more whatevers.

Wouldn't that hose the code here? The condition was met on the 5th loop but it still returns true because it used all 1 adventure. On the 6th loop, the condition would have reset itself and would then try to re-accomplish the original condition. Or is that just for the GUI auto-adventure?

Sorry for the noob questions. Maybe my best answer is: Run Mafia on a 486 :)
 

lostcalpolydude

Developer
Staff member
Could the while loop check for the condition being met (or the existence of a condition value or something) rather than trying to rely on the results of adventure() ?
 
You could do that for some code, such as if you are trying to get 5 doodads then you can check your inventory after every adventure to see if you got them or not. It wouldnt work as a generic solution though.

For example, I was hoping to modify my ZLib's "obtain" function to include the delay, as well as a generic replace for code that uses 'adventure(x,y);

Still, maybe there is some way to check current conditions or something. I'm still not sure about the resetting of conditions upon meeting them thing though. That might still screw stuff up. Ill see what St or Bale have to say about it. Its a good idea.
 

StDoodle

Minion
Well, you could put condition checks in that function, but I think you'd have a hard time getting such a function to play well with other scripts.

I think the function I outlined above should return the same value as adventure() would in any given circumstance that I can think of. After all, adventure() itself should return true if you get the last item you need on your last adventure specified, just as that code above would. Likewise, as soon as you call adventure() or my_adv() with all of your conditions satisfied, those conditions will be cleared and the function will return false; that final adventure shouldn't get spent.

I'm not 100% sure I'm analyzing this correctly, but I'm currently level 6 in hardcore, so I can't test it out at the moment.
 

zarqon

Well-known member
Super easy way:

set betweenBattleScript = wait 5

If you're already using a betweenBattleScript, just add wait(5); to the main() somewhere.

EDIT: If you want that to be encapsulated in the script, use get_property() and set_property() before and after calls to adventure(). Ideally you would restore the setting to its previous value when finished.
 
Last edited:
Top