Results 1 to 6 of 6

Thread: Farming FunPoints in PirateRealm (work in progress)

  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    593

    Default Farming FunPoints in PirateRealm (work in progress)

    So I wrote a script to farm fun in PirateRealm, and it seems to be working ok. Haven't tested it too much, but from what I can tell it seems to finish the zone the way I thought it should. It follows the strategy for maximizing FunPoints which is detailed on the wiki. It requires you to have an autoattack set which can handle combats on the various islands, as well as an outfit called "PirateRealm" (which needs to have the eyepatch in it). Apart from that it shouldn't need much input.

    Now, while it does work (I believe), it also feels a bit clunky to me, and I haven't gotten the calculation of FunPoints earned during the trip to work - it ends up printing your FunPoint total when it finishes running. I also feel that there ought to be a better way to detect that you have finished the PirateRealm, but some cursory searches using prefref and ashref did not seem to give me any way for mafia to directly tell me this. And there's other stuff, like its handling of travelling the seas and so on.

    Anyway, now that I have something which works, and which I have done some quick testing of, I would very much appreciate it if the community here could give me some pointers on what I could improve in my script or if I've made any mistakes. Please be gentle!
    Attached Files
    Last edited by ereinion; 07-11-2019 at 06:23 PM.

  2. #2
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,474

    Default

    Not sure I'll get a chance to try until after the weekend but...

    How do you handle outfits? Do you use the Maximizer or expect something predefined? Are there things you expect to be unlocked?

  3. #3
    Senior Member
    Join Date
    Dec 2008
    Posts
    593

    Default

    Ah, I have set up a predefined outfit - I'll edit that into the first post. I suppose I could set up a maximizer-string instead.
    Last edited by ereinion; 07-11-2019 at 06:23 PM.

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,093

    Default

    A few suggestions:

    Code:
    int[string] currencies;
    currencies["Guns"] = 0;
    currencies["Grub"] = 0;
    currencies["Grog"] = 0;
    currencies["Glue"] = 0;
    currencies["Gold"] = 0;
    currencies["Fun"] = 0;
    could be

    Code:
    int[string] currencies {
        "Guns" : 0,
        "Grub" : 0,
        "Grog" : 0,
        "Glue" : 0,
        "Gold" : 0,
        "Fun" : 0,
    };
    My personal preference is to use "m.group(1)" rather than "group(m, 1 )", but they are exactly the equivalent.
    So, for example, rather than
    Code:
    			currencies[group(m, 1)] = to_int(group(m, 2));
    I prefer:

    Code:
    			currencies[m.group(1)] = m.group(2).to_int();

    Code:
    	string s = visit_url("adventure.php?snarfblat=530");
    would be better as

    Code:
    	string s = visit_url($location[Sailing the PirateRealm Seas].to_url());
    (Strategy: I tend to buy guns, if I can afford them, since even the Menacing Man-o-War can lose battles, and it's less fun to lose...)

    Code:
    		print_html("</br><font color=0000FF>Our island adventure is complete!</font>");
    		print_html("</br><font color=FF0000>Couldn't finish our island adventure!</font>");
    could be:

    Code:
    		print("" ); print( "Our island adventure is complete!", "0000FF" );
    		print("" ); print( "Couldn't finish our island adventure!", "FF0000" );
    Code:
    	foreach key in $ints[1368, 1370, 1375, 1377, 1381, 1382, 1384] { # Possible choices at the end of islands
    		if (get_property("choiceAdventure" + to_string(key)) != 1) {
    			previous_choices["choiceAdventure" + to_string(key)] = to_int(get_property("choiceAdventure" + to_string(key)));
    			set_property("choiceAdventure" + to_string(key), 1);
    		}
    	}
    ...
    	print_html("</br><font color=0000FF>Cleaning up our settings...</font>");
    	foreach key in previous_choices {
    		set_property(key, previous_choices[key]);
    	}
    Personally, I would do this:

    Code:
        try {
    	foreach key in $ints[1368, 1370, 1375, 1377, 1381, 1382, 1384] { # Possible choices at the end of islands
    		if (get_property("choiceAdventure" + to_string(key)) != 1) {
    			previous_choices["choiceAdventure" + to_string(key)] = to_int(get_property("choiceAdventure" + to_string(key)));
    			set_property("choiceAdventure" + to_string(key), 1);
    		}
    	}
    ...
        } finally {
    	print_html("</br><font color=0000FF>Cleaning up our settings...</font>");
    	foreach key in previous_choices {
    		set_property(key, previous_choices[key]);
    	}
        }
    Which will restore your settings even if you abourt out of the loop.

    I think this is clunky:

    Code:
    	while (!island_complete && i < 50 && my_adventures() > 0) {
    		while (handle_sea_advs() && j < 100) {
    			print_html("</br><font color=0000FF>Exploring the PirateRealm seas...</font>");
    			update_currencies();
    			j = j + 1;
    		}
    		j = 0;
    		while (adventure(1, $location[PirateRealm Island]) && j < 100) {
    			print_html("</br><font color=0000FF>Adventuring on the islands...</font>");
    			j = j + 1;
    		}
    		update_currencies();
    		if (last_choice() >= 1381 && last_choice() <= 1384) {
    			island_complete = true;
    		}
    		j = 0;
    		i = i + 1;
    	}
    You are using a variable to break the loop when you are done (rather than just breaking out of the loop when it is complete ).
    You are trying to prevent infinite adventure loops with i and j. But, if you spend more than 50 turns at sea, you just assume you are on an island now.

    Code:
    	boolean[int] final_choice = $ints[ 1381, 1382, 1384 ];
    	while (my_adventures() > 0) {
    		boolean at_sea = true;
    		while (at_sea) {
    			print_html("</br><font color=0000FF>Exploring the PirateRealm seas...</font>");
    			at_sea = handle_sea_advs();
    			update_currencies();
    		}
    		while (!at_sea) {
    			print_html("</br><font color=0000FF>Adventuring on the islands...</font>");
    			at_sea = !adventure(1, $location[PirateRealm Island])
    		}
    		update_currencies();
    		if (final_choice[ last_choice() ] ) {
    			break;
    		}
    	}
    You say "it ends up printing your FunPoint total when it finishes running". It prints starting_fun when it starts Does it print the expected value? I seem to recall that the charpane doesn't update until I actually head to sea, or something. You force a charpane refresh, but if KoL doesn't show the "currencies" on it, they will all end up at 0, and "starting_fun" will be 0.

  5. #5
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,474

    Default

    Finally got a chance to try it.

    My CCS was not succeeding but that is not the script's fault. Next time I will abort on Beaten Up and not just uneffect and continue.

    I was pleased at its ability to "restart" after I did a couple things manually.

    I have to use a potion or spell to boost HP before I can survive Red Roger long enough to beat him. It would be nice if the script assisted me with that but if I get Beaten Up, abort and fix the issue, that is just one lost combat so...

    Thank you.

  6. #6
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,474

    Default

    Works fine, except...

    It gets to the fight with Red Roger. WHAM says I can't win (and that is basically correct) so it aborts. I manually run away, increase my HP with Super Weight Gain.

    If I then manually do the fight I win.

    If I restart the script (before the fight) I get an unhandled choice adventure in a loop that shows no signs of ending.

    If I manually do the fight, finish it and then restart I also get an unhandled choice.

    This is minor except I never get to see the accounting - what I gained as opposed to what I now have in FunPoints.

    I could take charge and use a mood or a BBS to make sure I had enough HP for Roger but it doesn't bother me enough to figure out how to know Roger is the next combat but...

Posting Permissions

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