Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14

Thread: How to automate combat with tentacles from Dr. Stuart's tent or Evoke Eldritch Horror

  1. #11
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    260

    Default

    I have multiple characters. Every character has one of the two options. No character has two options at the same time.

    The code I posted works with all of my characters, as opposed to the code you posted, which works only for characters who have passed a certain point.
    Originally Posted by Veracity View Post
    I understand. I didn't realize there were multiple options. I think your way is better, in the case of having items today, and not having them tomorrow.

    I was thinking before this, that you might be able to use
    if (my_name() == "PazSox") ... choice1
    if (my_name() == "Veracity") ... choice2

    But this wouldn't work either... It would still force the particular choice number, which as I know now, CAN change based on items/equipment.

    I'm still learning. A little bit each day.

  2. #12
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,142

    Default

    Thanks for your replies, Linknoid and Pazleysocks. Getting through the choice adventure, and starting the fight, wasn't giving me any trouble. I was just struggling to figure out how to automate the fight itself (other than with run_combat).

    Here's what I ended up doing:
    Code:
    visit_url("place.php?whichplace=forestvillage&action=fv_scientist");
    run_choice(2);
    adv1(my_location(), -1, "[my combat strategy]");
    That works well, for defining my strategy in the script.
    Originally Posted by PaladinWhite View Post
    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.

    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:

    Code:
    		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 );
    		}
    processChoiceAdventure with "false" means "do not try to automate".

    Code:
    	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 );
    		request.run();
    
    		if ( tryToAutomate )
    		{
    			ChoiceManager.processChoiceAdventure( request, "choice.php", request.responseText );
    			return "";
    		}
    		
    		return request.responseText;
    	}
    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?

    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:

    Code:
    	    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" );
    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.

    6) VeracityMeatFarm does this for the Science Tent:

    Code:
    	string page = visit_url( "place.php?whichplace=forestvillage&action=fv_scientist" );
    	...
    	    run_choice( fight );
    and I see the following in my session log:

    Code:
    > 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?
    choice.php?whichchoice=1201&option=1&pwd
    
    [20795] Dr. Gordon Stuart's Science Tent
    Encounter: Eldritch Tentacle named Shhhhhblrgglblllrrgggh
    Round 0: Veracity wins initiative!
    ...
    And I'm not sure where the fighting happens! It used my CCS, as you commented.

    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.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  3. #13
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,142

    Default

    I think I get it.

    - GenericRequesthandleServerRedirect WILL follow the redirect if the base class is a GenericRequest
    - visit_url uses a GenericRequest -> which means it will follow the redirect and start the fight.
    - visit_choice calls ChoiceManager.processChoiceAdventure, which uses ChoiceManager.CHOICE_HANDLER (which is a GenericRequest, so it would follow the redirect) - except it is also a "special" request which does not follow the redirect and automatically runs the fight.

    I am considering making another version of run_choice which will let you say to craft a new GenericRequest rather than using CHOICE_HANDLER, which will allow you take over the combat, as you desire.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  4. #14
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,142

    Default

    Try revision 18246.

    string run_choice( int option, boolean handle_fights )

    If "handle_fights" is false, will follow the redirect to set up for the fight and return. run_combat() should work.
    If it is true - the backward compatible default for run_choice( option) - we will run the fight using your CCS.

    Untested, since I am out of turns for the day.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •