Macroified combat using the 3 variable version of adventure()

slyz

Developer
TLDR - You need to add a dummy "attack;" at the beginning of a macro that is passed to the 3 variable version of adventure().

I know there are many things happening in KoL at the moment, so I'm not posting this as a Feature Request, nor as a complaint - I just wanted to write this down in case a dev or anyone who knows better than me could look at this, and to help others using macros with adventure(). I know a few scripters are interested in macrofying combats instead of using more server-heavy consult scripts, so it seems like a good subject to poke at.

I have been working on automating unlocking the Nemesis Lair as a DB for my Nemesis script, and I have stumbled across some difficulty to use macroified Rave combos.

Since I want to keep the script's configuration to a minimum for the user, I didn't want to rely on a CCS. In other parts of the script, I build a macro and use the 3 variable version of adventure() to run adventures. Something strange is happening when I try to use a Rave combo though.

The macro itself is simple. This is what I used to test this - it uses Rave Steal:
PHP:
string macro = "skill 52; skill 51; skill 50; attack; repeat;" ;
print("Macro: " + macro);
adventure( 1 ,$location[ Hippy Camp (Stone Age) ], macro );
What happens is that apparently the first move is not used, although it is logged by Mafia:
Code:
> call test.ash

Macro: skill 52; skill 51; skill 50; attack; repeat;

Visit to Island: Hippy Camp (Stone Age) in progress...

[1183] Hippy Camp (Stone Age)
Encounter: sabre-toothed ferret
Strategy: attack with weapon
Round 0: slyz wins initiative!
Round 0: slyz casts RUN LIKE THE WIND!
Round 1: slyz casts POP AND LOCK IT!
Round 2: sabre-toothed ferret takes 6 damage.
Round 2: slyz casts BREAK IT ON DOWN!
Round 3: sabre-toothed ferret takes 15 damage.
Round 3: slyz attacks!
Round 4: sabre-toothed ferret takes 30 damage.

(...)

Round 10: slyz attacks!
Round 11: sabre-toothed ferret takes 29 damage.
You gain 309 Meat
You acquire an item: sabre teeth
After Battle: Dusty smiles a three-lipped smile from beneath the shade of his little sombrero.
You gain 18 Fortitude
You gain 19 Enchantedness
You gain 35 Cheek
When I look at the combat's HTML (using run_combat() immediately after), this is what I see:
Code:
(...)

  <td>
	<!-- macroaction: skill 52 -->
	<center>
	  <table>
		<tr>
		  <td>
			<img id='monpic' src=
			"http://images.kingdomofloathing.com/adventureimages/cavehippy.gif"
			width="100" height="100">
		  </td>
		  <td valign="center">
			You're fighting <span id='monname'>a caveman
			hippy</span>
		  </td>
		</tr>
	  </table><br>
	</center>
	<blockquote>
	  Unlike modern hippies, this one subsists on a
	  primitive diet of nuts, berries, and twigs. Huh.
	  <p>
		Unlike modern hippies, this one exudes the funk of
		not having discovered bathing yet. Huh.
	  </p>
	  <p>
		Unlike modern hippies, this one's hair is a snarl
		of mud and ... okay, never mind. You can tell he's
		a caveman because of the protruding brow and the
		low-cost car insurance.
	  </p>
	</blockquote>
	<center>
	  <p>
		You get the jump on him.
	  </p>
	  <p>
		<!-- macroaction: skill 51 -->
	  </p>

(...)
Apparently skill 52 is used before the first round (before the "You get the jump on him." message). The rest is normal, although of course the combo isn't happening because the first move wasn't actually used.

Using the same Macro in a CCS, though, works 100% as expected. The only difference I could see is by generating debug logs :

  • When using adventure(), this URL is requested by Mafia:
Code:
(...)
Requesting: http://www6.kingdomofloathing.com/fight.php?ireallymeanit=*SNIP*&action=macro&macrotext=skill+52%3B+skill+51%3B+skill+50%3B+attack%3B+repeat%3B
(...)

  • When adventuring through the Mafia interface with the CCS, Mafia requests two URLs:
Code:
(...)
Requesting: http://www6.kingdomofloathing.com/fight.php?ireallymeanit=*SNIP*
(...)
Requesting: http://www6.kingdomofloathing.com/fight.php?action=macro&macrotext=%0A%0A%0Askill+52%0Askill+51%0Askill+50%0Amark+mafiafinal%0Aattack%0Agoto+mafiafinal
(...)

I guess there is something happening with adventure() that doesn't look like an easy fix, or probably this is a KoL bug, I don't really know how things work well enough to point any accusing finger.

Happily, a very simple workaround is to simply add a dummy "attack" action at the beginning of the macro passed to adventure(). Adding a non action macro command like "scrollwhendone" or "icon" doesn't cut it, and keep in mind that Mafia will think it happened. "attack" works nicely because nothing is changed in mafia if you attack and there isn't any damage.
PHP:
macro = "attack; skill 52; skill 51; skill 50; attack; repeat;";
print("Macro: " + macro);
adventure( 1 ,$location[ Hippy Camp (Stone Age) ], macro );
results in:
Code:
> call test.ash

Macro: attack; skill 52; skill 51; skill 50; attack; repeat;

Visit to Island: Hippy Camp (Stone Age) in progress...

[1191] Hippy Camp (Stone Age)
Encounter: cavewomyn hippy
Strategy: D:\dloads\KoLMafia\ccs\nemesis_DB.ccs [default]
Round 0: slyz wins initiative!
Round 0: slyz attacks!
Round 1: slyz casts RUN LIKE THE WIND!
Round 2: cavewomyn hippy takes 5 damage.
Round 2: slyz casts POP AND LOCK IT!
Round 3: cavewomyn hippy takes 12 damage.
Round 3: slyz casts BREAK IT ON DOWN!
You acquire an item: handful of nuts and berries
Round 4: slyz attacks!
Round 5: cavewomyn hippy takes 21 damage.

(...)

Round 13: slyz attacks!
Round 14: cavewomyn hippy takes 33 damage.
After Battle: Dusty smiles a three-lipped smile from beneath the shade of his little sombrero.
You gain 18 Muscleboundness
You gain 20 Magicalness
You gain 34 Sarcasm

Requests complete.

Another fun fact: don't start your string with a space when using the 3 form version of adventure(), it will default to the combat strategy configured in Mafia.
 
Last edited:
Top