Need a way to get one choice adventure without using goals.

StormCrow42

Member
My Worm Wood handling counter script seems to be reasonably stable. Unfortunately, I currently am decending to using goals to get the choice adventures in the Worm Wood. This has the very annoying side effect of nuking whatever legitimate goals you might have set. I'm looking for a better way to manage this so I can play nicely with said goals.

Any suggestions?
 

Alhifar

Member
Something like:
Code:
string page_text;
while( !contains_text( page_text , "choice.php" ) )
{
    visit_url( "adventure.php?snarfblat=" + to_int( $location[Pleasure Dome] ) )
}
// Rest of code
 

StormCrow42

Member
Something like:
Code:
string page_text;
while( !contains_text( page_text , "choice.php" ) )
{
    visit_url( "adventure.php?snarfblat=" + to_int( $location[Pleasure Dome] ) )
}
// Rest of code

visit_url feels like a hack. In addition, that doesn't look like it would handle the combats I'm likely to encounter.

An alternate to working without goals would be a way to save and restore the original goals.
 

Alhifar

Member
Code:
string page_text;
while( !contains_text( page_text , "choice.php" ) )
{
     page_text = visit_url( "adventure.php?snarfblat=" + to_int( $location[Pleasure Dome] ) )
     if( contains_text( page_text , "Combat" ) ) run_combat();
}
// Rest of code

Here includes running combats. In any case, it's just example code. If you want to find the goals, look through your charname_prefs.txt file in settings. It should be in there somewhere.
 

zarqon

Well-known member
If you're hard-coding a specific wormwood goal (such as not-a-pipes) it would also be easy to test for the effects you gain from the appropriate choiceadvs.

I think that your current conditions should be accessible within ASH. Something like int[string] active_conditions() would do nicely.
 

zarqon

Well-known member
Here's the top portion of my counter script, which works pretty transparently. It's not all-purpose (note that it does not even set choiceadvs), but I pretty much only use the wormwood for !pipes, anyway. If I want one of the other goals I just run the actual wormwood script.

Code:
   if (name == "Dance Card") {
      if (adventure(1,$location[haunted ballroom]) && item_amount($item[dance card]) > 0 && my_adventures() > 3)
         use(1,$item[dance card]);
      return true;
   }
   if (name == "Wormwood") {
      if (have_effect($effect[absinthe-minded]) == 0) return true;
      if (have_effect($effect[absinthe-minded]) == 9)
         while (adventure(1,$location[stately pleasure dome]) && have_effect($effect[spirit of alph]) == 0) {}
      if (have_effect($effect[absinthe-minded]) == 5)
         while (adventure(1,$location[mouldering mansion]) && have_effect($effect[feelin' philosophical]) == 0) {}
      if (have_effect($effect[absinthe-minded]) == 1 && adventure(1,$location[rogue windmill]) &&
          item_amount($item[not-a-pipe]) > 0 && my_spleen_use() < spleen_limit() - 3)
         use(1,$item[not-a-pipe]);
      return true;
   }

Might give you some ideas anyway.
 

StormCrow42

Member
I was hoping to be generic enough to not hardcode effect names (as well as being lazy and not rewrite more code than I have to), but I may just have to do that. I'll just have to add additional variables to the routine that configures the choice adventures and picks the proper zones.

Thanks for the idea Zarqon (and the reminder to stick a dance card handler into the script too).

Edit: Argh. That might work for all the various wormwood items, but IIRC the stat gain adventures don't give effects.
 
Last edited:

zarqon

Well-known member
So then you would have to compare my_stat($stat[submuscle]) before and after (in the case of the muscle stat gain adventure), testing for a large change (bigger than fighting a monster).

It would make for quite a lot of code to actually write an all-purpose wormwood script without setting any conditions. Being able to just set conditions in the script and then reset them to what they were before on exit would be much nicer. But that would require a mafia change. Perhaps you could submit a feature request.
 

StormCrow42

Member
I've tried the following code, from getadventure.ash, but now I'm running afoul of the aborts from not accomplishing the previously set goals.

Code:
boolean getChoiceAdv(int count, location l)
{
	string last_adventure = "";
	int n=0;
	while((n < count) && (my_adventures()>0)) {
		n = n + 1;
		last_adventure = visit_url(to_url(l));
		last_adventure = to_lower_case(last_adventure);
		if (contains_text(last_adventure, "choice.php")){
//			print("non combat");
			adventure(1,l);
			return true;
		} else {
			run_combat();
		}
		# here, either combat is over, or you hit a noncombat
		# now, lets restore HP and MP, as well as maintaining our mood
		restore_hp(0);
		restore_mp(0);
		cli_execute("mood execute");
	}
	return false;
}

Edit: any idea what the string is for in adventure(int count, location loc, string s)?

Edit2: Apparently if I capture the return value of adventure it doesn't abort (although it still prints the red goals not found message)
 
Last edited:

Bale

Minion
Edit: any idea what the string is for in adventure(int count, location loc, string s)?
In adventure(int count, location loc, string s), s is the name of an combat consulting subroutine to call instead of mafia's usual ccs. Jason first proposed it here:

There would be a version of adventure() that takes a third string argument, naming a function.

That function should have a signature like this:
string my_consult_function(int round, monster opponent, string pageText)

'round' starts at zero, and is incremented by one on each successive call to your function. It's not exactly the same as the combat round number, since there are actions that take no rounds (such as "steal" when that's unavailable or inappropriate), and actions that take more than one round (skill use with insufficient MP, thus requiring a restorative to be used first).

The normal consult-related functions could probably be used, but there's a better way - just return a string in the form of a CCS command. (Actually, I'm surprised that this isn't the way consult scripts worked from the beginning - seems like it would have been a lot easier to implement.) It will be executed, and then, assuming that the combat hasn't been finished or aborted, your function will be called again to produce the next action. Note that, unlike existing consult scripts, your script isn't being reloaded each time, so you've got continuity of global variables between each call.
 
Last edited:

zarqon

Well-known member
Presently in counter scripts it is essential to capture the results of adventure, since you can't clear the existing conditions. You can easily capture the results with an empty command block:

if (adventure(1,l)) {}

You can note above that I liberally employ this technique in my counter script.
 
Top