Sorry that I ignored this; I plead my new job (six months now, so is it still new?) which sucks away all my attention during the week - and I'm less inclined to dive into coding on the weekend. My brain is full.
Originally Posted by PaladinWhite
This thread is full of interesting things. Some observations:
1) visit_url() will follow a redirect for you. So, when you visit_url() to fight a Witchess Piece or to follow a choice in the Science Tent, KoL redirects to fight.php and visit_url() itself will follow that redirect, which will set up KoLmafia to know that you are inside a fight. At that point, you can use run_combat() and it will carry on as directed. In particular, if you give it a combat filter, it will use it.
2) I don't think run_choice follows a redirect. Given an option > 0, I see this:
processChoiceAdventure with "false" means "do not try to automate".
else if ( option > 0 )
// Submit the option chosen
String message = "Submitting option " + option + " for choice " + ChoiceManager.getLastChoice();
RequestLogger.printLine( message );
response = ChoiceManager.processChoiceAdventure( option, false );
Which is to say, it should simply submit the choice.php URL and return the page text. However, choice.php redirected to fight.php. So, what does it return?
public static final String processChoiceAdventure( final int decision, final boolean tryToAutomate )
GenericRequest request = ChoiceManager.CHOICE_HANDLER;
request.constructURLString( "choice.php" );
request.addFormField( "whichchoice", String.valueOf( ChoiceManager.lastChoice ) );
request.addFormField( "option", String.valueOf( decision ) );
request.addFormField( "pwd", GenericRequest.passwordHash );
if ( tryToAutomate )
ChoiceManager.processChoiceAdventure( request, "choice.php", request.responseText );
I'm wondering where - if ever - it follows the redirect to fight.php to let KoLmafia know you are in a fight. Apparently, it does not (although I have not finished tracing the code in GenericRequest to understand that, yet) in which case, run_combat() would not know you are already in a combat.
3) run_combat() when called and we think you are not in a fight will return "" (if given a filter function) or whatever the last combat round returns. I'm not sure why the difference.
4) adv1 will try to adventure, will get redirected to a fight, and will do it. That is why your solution is working - at the expense of an extra server hit.
5) VeracityMeatFarm does this for Witchess pieces:
It does visit_url to choose the monster - because you need to specify the "piece" parameter in addition to the option - which redirects to the fight, and run_combat() works well.
visit_url( "campground.php?action=witchess" );
run_choice( 1 );
visit_url( "choice.php?whichchoice=1182&option=1&piece=" + fight.id + "&pwd=" + my_hash(), false );
combat_filter_setup( NO_LOCATION );
run_combat( "hobo_monkey_filter" );
6) VeracityMeatFarm does this for the Science Tent:
and I see the following in my session log:
string page = visit_url( "place.php?whichplace=forestvillage&action=fv_scientist" );
run_choice( fight );
And I'm not sure where the fighting happens! It used my CCS, as you commented.
> Fighting Eldritch Tentacles
Visiting a Science Tent
Encounter: Dr. Gordon Stuart, a Scientist
Took choice 1201/1: Can I fight that tentacle you saved for science?
 Dr. Gordon Stuart's Science Tent
Encounter: Eldritch Tentacle named Shhhhhblrgglblllrrgggh
Round 0: Veracity wins initiative!
I need to track down how GenericRequest processes a choice.php -> fight.php.
For me, it seems to automate the fight, in this case.
For you, it seems to leave the fight un-started.