Advice on consult-script

ereinion

Member
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:
string siphonAt="red";

// Need some special combat handling, if we want the boots to stomp for us.
string stompOpponent(int round, string opp, string 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 round, string opp, string 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:
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.
 
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?
 
Here is an example of a consult script I use when automating mime fights:
PHP:
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;

void main( int initround, string foe, string 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_encode( macro ), true, true );
}
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".
 
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:
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;

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" );

	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_encode( macro ), true, true );
}

That way, if you have putty and raindoh, but not a camera, it will still funksling properly. I think.
 
Last edited:
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:
Back
Top