CCS/Macro in consult script

Banana Lord

Member
I made those changes, and did as you suggested and pasted the macro sections into a new macro to check their syntax, but it still seems to be failing. Same error, same result.
 

slyz

Developer
EDIT - TL>DR - use visit_url("fight.php?action=macro&macrotext="+url_encode(mac), true, true);

Maybe there is a problem with the escaped " then? Or with skill names that have a space in them?
Try this:
PHP:
buffer mac;  // macro in progress 

string macro(string mac) // ASH function for submitting a macro 
    {
    return visit_url("fight.php?action=macro&macrotext="+url_encode(mac)); 
    } 

// Stasis with scepter if using hobo monkey -- doesn't need to be called because it's inserted already in the correct place 
if(my_familiar() == $familiar[hobo monkey])
   mac.append('while !match "climbs up and sits" && !pastround 24; use 2678; endwhile;'); 

// Use summon hobo if you can
if(have_equipped($item[hodgman's porkpie hat]) && have_equipped($item[hodgman's lobsterskin pants]) && have_equipped($item[hodgman's bow tie]))
    mac.append(" if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; while !pastround 25; attack; endwhile; "); 

// finally, submit the macro 
macro(mac);

Or you can create this macro and test it in a combat manually, so you can at least see the error message:
Code:
while !match "climbs up and sits" && !pastround 24; use 2678; endwhile;
if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; while !pastround 25; attack; endwhile;

EDIT: oh, and check if you have a specter scepter too?

EDIT2: I tested the macro manually with a hobo monkey and the hodg outfit on, it works like a charm.

EDIT3:

Here is the consult script I used to test it:
PHP:
void main( int rnd, string opp, string text )
{
	buffer mac;  // macro in progress  

	string macro(string mac) // ASH function for submitting a macro  
	{ 
		print( mac );
		print( "" );
		print( url_encode(mac) );
		
		return visit_url("fight.php?action=macro&macrotext="+url_encode(mac));  
	}  

	// Stasis with scepter if using hobo monkey -- doesn't need to be called because it's inserted already in the correct place  
	if(my_familiar() == $familiar[hobo monkey]) 
	   mac.append('while !match "climbs up and sits" && !pastround 24; use 2678; endwhile;');  

	// Use summon hobo if you can 
	if(have_equipped($item[hodgman's porkpie hat]) && have_equipped($item[hodgman's lobsterskin pants]) && have_equipped($item[hodgman's bow tie])) 
		mac.append(" if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; while !pastround 25; attack; endwhile; ");  

	// finally, submit the macro  
	macro(mac);
}

and the result:
Code:
Visit to Beanstalk: Giant's Castle in progress...

[13026] Giant's Castle
Encounter: Furry Giant
Strategy: D:\dloads\KoLMafia\ccs\test.ccs [default]
Round 0: slyz wins initiative!
while !match "climbs up and sits" && !pastround 24; use 2678; endwhile; if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; while !pastround 25; attack; endwhile;

while+%21match+%22climbs+up+and+sits%22+%26%26+%21pastround+24%3B+use+2678%3B+endwhile%3B+if+hasskill+7052%3B+skill+7052%3B+endif%3B+if+hasskill+7047%3B+skill+7047%3B+endif%3B+if+hasskill+7050%3B+skill+7050%3B+endif%3B+while+%21pastround+25%3B+attack%3B+endwhile%3B+
Round 1: slyz executes a macro!
KoLmafia thinks it is round 2 but KoL thinks it is round 1
while !match "climbs up and sits" && !pastround 24; use 2678; endwhile; if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; while !pastround 25; attack; endwhile;

while+%21match+%22climbs+up+and+sits%22+%26%26+%21pastround+24%3B+use+2678%3B+endwhile%3B+if+hasskill+7052%3B+skill+7052%3B+endif%3B+if+hasskill+7047%3B+skill+7047%3B+endif%3B+if+hasskill+7050%3B+skill+7050%3B+endif%3B+while+%21pastround+25%3B+attack%3B+endwhile%3B+
Round 2: slyz executes a macro!
KoLmafia thinks it is round 3 but KoL thinks it is round 1
while !match "climbs up and sits" && !pastround 24; use 2678; endwhile; if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; while !pastround 25; attack; endwhile;

while+%21match+%22climbs+up+and+sits%22+%26%26+%21pastround+24%3B+use+2678%3B+endwhile%3B+if+hasskill+7052%3B+skill+7052%3B+endif%3B+if+hasskill+7047%3B+skill+7047%3B+endif%3B+if+hasskill+7050%3B+skill+7050%3B+endif%3B+while+%21pastround+25%3B+attack%3B+endwhile%3B+
Round 3: slyz executes a macro!
[COLOR="#ff0000"]KoLmafia declares world peace.[/COLOR]
KoLmafia thinks it is round 4 but KoL thinks it is round 1
[COLOR="#ff0000"]You're on your own, partner.
[U]Click here to continue in the relay browser.[/U][/COLOR]

I think the problem is when you actually submit the macro.

EDIT N+1: I finally figured it out. If you already url_encode() yourself, you need to tell visit_url() that it doesn't need to. This problem had been identified a long time ago, I had completely forgotten =)

Simply change
PHP:
visit_url("fight.php?action=macro&macrotext="+url_encode(mac));
to
PHP:
visit_url("fight.php?action=macro&macrotext="+url_encode(mac), true, true);
 
Last edited:

Banana Lord

Member
I wondered that so I swapped the inner set for single quotes. No luck.
If it's useful, here's the error (returned from the relay browser, and nabbed with lightning-fast cmd+a/cmd+c)
Code:
Invalid macro command encountered:
"+while+%21match+%27climbs+up+and+sits%27+%26%26+%21pastround+24%3B+use+spectre+scepter%3B+endwhile%3B++if+hasskill+summon+hobo+underling%3B+skill+summon+hobo+underling%3B+endif%3B+if+hasskill+ask+the+hobo+for+a+drink%3B+skill+ask+the+hobo+for+a+drink%3B+endif%3B+if+hasskill+ask+the+hobo+to+tell+you+a+joke%3B+skill+ask+the+hobo+to+tell+you+a+joke%3B+endif%3B+while+%21pastround+25%3B+attack%3B+endwhile%3B+"
 

slyz

Developer
I edited the post above: all you need to do is use the 3 parameter version of visit_url() to specify that your URL is already encoded.
 

Banana Lord

Member
Huh. It works, but only sort of. The first time I run the CCS which calls that consult script in a combat mafia aborts. The second time it runs perfectly.
Code:
[19444] Giant's Castle
Encounter: Furry Giant
Strategy: /Users/andrewcurtisblack/Library/Application Support/KoLmafia/ccs/meatfarm.ccs [default]
Round 0: banana lord wins initiative!
You're on your own, partner.
Click here to continue in the relay browser.

while !match "climbs up and sits" && !pastround 24; use 2678; endwhile; if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; while !pastround 25; attack; endwhile;

while+%21match+%22climbs+up+and+sits%22+%26%26+%21pastround+24%3B+use+2678%3B+endwhile%3B+if+hasskill+7052%3B+skill+7052%3B+endif%3B+if+hasskill+7047%3B+skill+7047%3B+endif%3B+if+hasskill+7050%3B+skill+7050%3B+endif%3B+while+%21pastround+25%3B+attack%3B+endwhile%3B+
Round 1: banana lord executes a macro!
Round 1: banana lord uses the spectre scepter!
Round 2: furry giant drops 3 attack power.
Round 2: furry giant drops 1 defense.
Round 2: Mr. Joe climbs up and sits on your shoulder, and hands you some Meat. Huh, where did he find that?
You gain 57 Meat.
Round 2: banana lord casts SUMMON HOBO UNDERLING!
Round 3: banana lord casts ASK THE HOBO FOR A DRINK!
You acquire an item: white lightning
Round 4: banana lord casts ASK THE HOBO TO TELL YOU A JOKE!
Round 5: banana lord attacks!
Round 6: furry giant takes 717 damage.
Round 6: banana lord wins the fight!
After Battle: Mr. Joe sits on your fallen opponent's body, blows a smoke ring, and winks at you.
You gain 874 Meat
You gain 5 Strengthliness
You gain 28 Wizardliness
You gain 8 Chutzpah
 

Banana Lord

Member
I also tried to shift everything that was in my CCS into the consult script, but it's giving me: Invalid macro command encountered: "if !monstername *giant" (and still aborting the first time).

Code:
void main( int rnd, string opp, string text ) 
	{ 
    buffer mac;  // macro in progress   

    string macro(string mac) // ASH function for submitting a macro   
    	{  
        print( mac ); 
        print( "" ); 
        print( url_encode(mac) ); 
         
        return visit_url("fight.php?action=macro&macrotext="+url_encode(mac), true, true);   
    	}   

   // Make sure you're fighting a giant
   mac.append(' if !monstername *giant; abort; endif ');
   
   // Stasis with scepter if using hobo monkey - Pickpocket safety-netted in case of meat steal on the first round
    if(my_familiar() == $familiar[hobo monkey])  
       mac.append(' if !match "climbs up and sits"; pickpocket; endif; while !match "climbs up and sits" && !pastround 24; use 2678; endwhile; ');   

    // Use summon hobo if you can  
    if(have_equipped($item[hodgman's porkpie hat]) && have_equipped($item[hodgman's lobsterskin pants]) && have_equipped($item[hodgman's bow tie]))  
        mac.append(" if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; ");   
	
	// Finish the fight
	mac.append(" while !pastround 25; attack; endwhile; ");

    // finally, submit the macro   
    macro(mac); 
	}
 

zarqon

Well-known member
Moving abort checks to ASH will save server hits, as I mentioned before.

PHP:
if (!last_monster().to_string().contains_text(" Giant")) abort("It's not a giant!");

Note that I included a space. That's because a case-insensitive check for "giant" gives you this list:

  • Alphabet Giant
  • Booze Giant
  • Furry Giant
  • Giant Bee
  • Giant Bird-Creature
  • Giant Desktop Globe
  • Giant Fried Egg
  • Giant Giant Giant Centipede
  • Giant Giant Moth
  • Giant Jungle Python
  • Giant Octopus
  • Giant Pair of Tweezers
  • Giant Sandworm
  • Giant Skeelton
  • Giant Spider
  • Giant Squid
  • Giant Zombie Goldfish
  • Goth Giant
  • Possibility Giant
  • Procrastination Giant
  • Raver Giant
  • reanimated giant spider skeleton

but checking for " Giant" gives you this list:

  • Alphabet Giant
  • Booze Giant
  • Furry Giant
  • Giant Giant Giant Centipede
  • Giant Giant Moth
  • Goth Giant
  • Possibility Giant
  • Procrastination Giant
  • Raver Giant

Closer to what you had in mind, methinks. :)
 

Banana Lord

Member
Ah brilliant! THAT bit works perfectly. But now I'm getting: Invalid macro command encountered: "if !match "climbs up and sits""
Code:
void main( int rnd, string opp, string text ) 
	{ 
    buffer mac;  // macro in progress   

    string macro(string mac) // ASH function for submitting a macro   
    	{  
        print( mac ); 
        print( "" ); 
        print( url_encode(mac) ); 
         
        return visit_url("fight.php?action=macro&macrotext="+url_encode(mac), true, true);   
    	}   

	// Make sure you're fighting a giant
	if (!last_monster().to_string().contains_text(" Giant"))
		abort("It's not a giant!"); 
   
   // Stasis with scepter if using hobo monkey - Pickpocket safety-netted in case of meat steal on the first round
    if(my_familiar() == $familiar[hobo monkey])  
       mac.append(' if !match "climbs up and sits"; pickpocket; endif; while !match "climbs up and sits" && !pastround 24; use 2678; endwhile; ');   

    // Use summon hobo if you can  
    if(have_equipped($item[hodgman's porkpie hat]) && have_equipped($item[hodgman's lobsterskin pants]) && have_equipped($item[hodgman's bow tie]))  
        mac.append(" if hasskill 7052; skill 7052; endif; if hasskill 7047; skill 7047; endif; if hasskill 7050; skill 7050; endif; ");   
	
	// Finish the fight
	mac.append(" while !pastround 25; attack; endwhile; ");

    // finally, submit the macro   
    macro(mac); 
	}
 

Banana Lord

Member
Temporarily changed back to doing it the pre-Zarqon, server-unfriendly way to test that. No luck. I'm going to sleep on it. Let's hope a singing choir of angels tells me what's wrong.
 

Banana Lord

Member
Well, I didn't SEE a choir of angels, but one must have visited in the night because inexplicably it's working perfectly. Haven't touched a thing since last night, and now it's fine.
 
Last edited:
Top