Results 1 to 6 of 6

Thread: Advice on consult-script

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

    Default Advice on consult-script

    I'm making a script in which I want to get the various drops from the boots, medium etc. In order to achieve this I've incorporated two consult scripts into the script:
    PHP Code:
    string siphonAt="red";

    // Need some special combat handling, if we want the boots to stomp for us.
    string stompOpponent(int roundstring oppstring combatText) {
        if (
    combatText.contains_text("ache for some quality")) {
            return 
    "skill release the boots";
        } else {
            return 
    get_ccs_action(round);
        }
        return 
    get_ccs_action(round 1);
    }

    // Special combat handling for getting the right booze with the medium
    string siphonOpponent(int roundstring oppstring combatText) {
        switch (
    siphonAt) {
            case 
    "red":
                if (
    $familiar[happy medium].image == "medium_3.gif") { return "skill siphon spirit"; }
                return 
    get_ccs_action(round);
            case 
    "orange":
                if (
    $familiar[happy medium].image == "medium_2.gif") { return "skill siphon spirit"; }
                return 
    get_ccs_action(round);
            case 
    "blue":
                if (
    $familiar[happy medium].image == "medium_1.gif") { return "skill siphon spirit"; }
                return 
    get_ccs_action(round);
            default:
                return 
    get_ccs_action(round);
        }

    Are they going to do what I want them to do, and if they are, are there better ways to achieve that goal than what I'm currently doing?

    - edit - Well, after having tested it, I see that it works, but is there a better way to approach the problem? As it is this creates quite a few server hits, so baking it all together in a macro would probably be better. Is that possible at all?

    Oh, and is there currently anything tracking how many carrotnose-drops you've got from the snow suit? Couldn't find anything obvious in the kolmafia properties.

    - edit 2 - Nevermind.
    Last edited by ereinion; 02-18-2013 at 06:56 AM. Reason: Tested to find the answer to the original question

  2. #2
    Senior Member
    Join Date
    Nov 2007
    Posts
    225

    Default

    Familiars proxy records have a charges property... It's there so you don't have to check the familiar image, or the boots text... and presumably future similar mechanics for familiars.
    $familiar[...].charges

    Cool trick, enter ash ${familiar/item/etc}[none] will show the properties available from that type of proxy record.

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

    Default

    Thanks for the tip, I'll see about changing the script to use those fields as triggers instead. As far as I can see it won't lead to a big boost in efficiency though. Well, it's probably a bit faster, but I would guess it would be quicker if I got the script to return a combat macro instead of a round by round account of how combat should be handled... Any suggestions on how to implement that?

  4. #4
    Developer
    Join Date
    Nov 2008
    Location
    Paris, France
    Posts
    4,510

    Default

    Here is an example of a consult script I use when automating mime fights:
    PHP Code:
    boolean funk have_skill$skillAmbidextrous Funkslinging ] );
    boolean putty item_amount$itemSpooky Putty monster ] ) == && item_amount$itemSpooky Putty sheet ] ) > && get_property"spookyPuttyCopiesMade" ).to_int() < 5;
    boolean raindoh item_amount$itemRain-Doh box full of monster ] ) == && item_amount$itemRain-Doh black box ] ) > && get_property"_raindohCopiesMade" ).to_int() == 0;
    boolean camera item_amount$itemshaking 4-d camera ] ) == && item_amount$item4-d camera ] ) > && !get_property"_cameraUsed" ).to_boolean();
    boolean arrow my_familiar() == $familiarObtuse Angel ] && get_property"_badlyRomanticArrows" ).to_int() == 0;

    void mainint initroundstring foestring page )
    {
        if ( 
    arrow visit_url"fight.php?action=skill&whichskill=7108" );

        
    string macro;
        if ( 
    putty && camera && funk macro += "use 3665, 4169;";
        else
        {
            if ( 
    putty macro += "use 3665;";
            if ( 
    camera macro += "use 4169;";
        }
        if ( 
    raindoh macro += "use 5563;";

        if ( 
    macro != "" visit_url"fight.php?action=macro&macrotext=" url_encodemacro ), truetrue );

    I hardcoded the skill and item numbers, but you can try using the actual names, or using $skill[].to_int() or $item[].to_int() instead.

    Don't forget you can also use Macro predicates like "happymediumglow" or whatever the exact name is, and "hasskill release the boots".
    Try the Nemesis Quest Script or the FamiliarFeeder interface.
    *shakes KoLMafia tech support magic 8-ball* Update mafia to the latest daily .JAR!
    NEW Dad ASCENSION STARTED 20120730
    ------------------------------
    Welcome to Parenthood, Noob

  5. #5
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    slyz, I loved what you did and decided to steal it for my own use, except that your implementation of funkslinging is a special case and I certainly couldn't use it if I was to make it more general purpose, so I hope you'll appreciate my improvement to the funkslinging:

    PHP Code:
    boolean funk have_skill$skillAmbidextrous Funkslinging ] );
    boolean putty item_amount$itemSpooky Putty monster ] ) == && item_amount$itemSpooky Putty sheet ] ) > && get_property"spookyPuttyCopiesMade" ).to_int() < 5;
    boolean raindoh item_amount$itemRain-Doh box full of monster ] ) == && item_amount$itemRain-Doh black box ] ) > && get_property"_raindohCopiesMade" ).to_int() == 0;
    boolean camera item_amount$itemshaking 4-d camera ] ) == && item_amount$item4-d camera ] ) > && !get_property"_cameraUsed" ).to_boolean();
    boolean arrow my_familiar() == $familiarObtuse Angel ] && get_property"_badlyRomanticArrows" ).to_int() == 0;

    string funk(string macro)
    {
        
    matcher multi create_matcher"use +(([^;,]+); *use +([^;,]+))"macro );
        while ( 
    find(multi) )
            
    macro replace_stringmulti.group(1), multi.group(2) +", "multi.group(3) );
        return 
    macro;
    }

    void mainint initroundstring foestring page 
    {
        if ( 
    arrow visit_url"fight.php?action=skill&whichskill=7108" );

        
    string macro;
        if ( 
    putty macro += "use 3665;";
        if ( 
    camera macro += "use 4169;";
        if ( 
    raindoh macro += "use 5563;";

        if ( 
    funk macro funk(macro);

        if ( 
    macro != "" visit_url"fight.php?action=macro&macrotext=" url_encodemacro ), truetrue );

    That way, if you have putty and raindoh, but not a camera, it will still funksling properly. I think.
    Last edited by Bale; 02-22-2013 at 07:39 AM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  6. #6

    Default

    I updated the script to include all the new coping options (I just added the new skills/items for people that have trouble with code). I didn't have a chance to test it today
    Code:
    boolean funk = have_skill( $skill[ Ambidextrous Funkslinging ] );
    boolean putty = item_amount( $item[ Spooky Putty monster ] ) == 0 && item_amount( $item[ Spooky Putty sheet ] ) > 0 && get_property( "spookyPuttyCopiesMade" ).to_int() < 5;
    boolean raindoh = item_amount( $item[ Rain-Doh box full of monster ] ) == 0 && item_amount( $item[ Rain-Doh black box ] ) > 0 && get_property( "_raindohCopiesMade" ).to_int() == 0;
    boolean camera = item_amount( $item[ shaking 4-d camera ] ) == 0 && item_amount( $item[ 4-d camera ] ) > 0 && !get_property( "_cameraUsed" ).to_boolean();
    boolean arrow = my_familiar() == $familiar[ Obtuse Angel ] && get_property( "_badlyRomanticArrows" ).to_int() == 0;
    boolean wink = my_familiar() == $familiar[ Reanimated Reanimator ] && get_property( "_badlyRomanticArrows" ).to_int() == 0;
    boolean ice = item_amount( $item[ ice sculpture ] ) == 0 && item_amount( $item[ unfinished ice sculpture ] ) > 0 && get_property( "_iceSculptureUsed" ).to_boolean();
    boolean print = item_amount( $item[ screencapped monster ] ) == 0 && item_amount( $item[ print screen button ] ) > 0 && get_property( "screencappedMonster" ).to_boolean();
    boolean digitize = have_skill( $skill[ Digitize ] ) && get_property(_sourceTerminalDigitizeUses) < 3;
    boolean paint = item_amount( $item[ alpine watercolor set ] ) == 1 && get_property( "chateauAvailable" ).to_boolean(); 
    boolean crappy = item_amount( $item[ shaking crappy camera ] ) == 0 && item_amount( $item[ crappy camera ] ) > 0 && !get_property( "_crappyCameraUsed" ).to_boolean();
    
    string funk(string macro)
    {
        matcher multi = create_matcher( "use +(([^;,]+); *use +([^;,]+))", macro );
        while ( find(multi) )
            macro = replace_string( multi.group(1), multi.group(2) +", "+ multi.group(3) );
        return macro;
    }
    
    void main( int initround, string foe, string page ) 
    {
        if ( arrow ) visit_url( "fight.php?action=skill&whichskill=7108" );
        if ( wink ) visit_url( "fight.php?action=skill&whichskill=7168" );
        if ( digitize ) visit_url( "fight.php?action=skill&whichskill=7274" );
    	
        string macro;
        if ( putty ) macro += "use 3665;";
        if ( camera ) macro += "use 4169;";
        if ( raindoh ) macro += "use 5563;";
        if ( ice ) macro += "use 7079;";
        if ( print ) macro += "use 9022;";
        if ( paint ) macro += "use 8033;";
        if ( crappy ) macro += "use 7173;";
    	
        if ( funk ) macro = funk(macro);
    
        if ( macro != "" ) visit_url( "fight.php?action=macro&macrotext=" + url_encode( macro ), true, true );
    }
    I had to remove the Funkslinging section as it was giving the following error:

    Function 'replace_string( string, string )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (fullmonstercopy.ash, line 19)

    Once that was removed through it worked
    Last edited by dapanda; 10-21-2017 at 02:10 AM. Reason: formatting

Similar Threads

  1. Advice on getting started with this script idead I have?
    By JohnnyRamrod in forum Scripting Discussion
    Replies: 7
    Last Post: 03-02-2010, 05:09 PM
  2. Bag o' Tricks consult script
    By psly4mne in forum Custom Combat Settings
    Replies: 0
    Last Post: 11-20-2009, 09:49 PM
  3. Call consult script from another consult script.
    By asturia in forum Custom Combat Settings
    Replies: 4
    Last Post: 01-28-2009, 01:22 PM
  4. Any advice on runnig a vacation script on a Mac OS 10.5
    By jalapenojoe in forum Scripting Discussion
    Replies: 6
    Last Post: 05-05-2008, 05:04 AM
  5. Chow mein creation script, advice needed please
    By Bishy in forum Scripting Discussion
    Replies: 16
    Last Post: 07-03-2006, 05:16 AM

Posting Permissions

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