Scripting Issue involving Custom Combat

Stardock

Member
Hey,

I've been working on a turn burning script for using drum machines. Right now it's really simplistic but here it is:

Code:
//drum machine turn burning script

set_property("battleAction","custom combat script");
set_property("customCombatScript","steal_and_kill.ccs");

int drums = item_amount($item[drum machine]);
int i = 1;

while(i <= drums)
{
	use(1, $item[drum machine]);
	i = i + 1;
}

print("Done!");

Here's the contents of the steal_and_kill.ccs:

Code:
[ default ]
1: skill pickpocket
2: attack

However when I try to run it I get an error and it dumps to the log. The log basically contains the following:
Code:
Unexpected error, debug log printed.
class java.lang.StackOverflowError: null
java.lang.StackOverflowError
	at net.sourceforge.kolmafia.session.CustomCombatManager.getSettingKey(CustomCombatManager.java:478)
	at net.sourceforge.kolmafia.request.FightRequest.updateCurrentAction(FightRequest.java:404)
	at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:346)
	at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:261)
	at net.sourceforge.kolmafia.request.FightRequest.updateCurrentAction(FightRequest.java:417)
	at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:346)
	at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:261)

Those last 3 lines are repeated several times...

Any clue what's going on here?
 

Stardock

Member
Ok...after thinking about it and experimenting a bit I think what is happening is that the:

Code:
use(1, $item[drum machine]);

line is entering an infinite loop that doesn't ever get resolved...how do I fix this?
 

Stardock

Member
Ugh...never mind. This script doesn't work either...

Code:
set_property("battleAction","custom combat script");
set_property("customCombatScript","default.ccs");
adventure(1, $location[Haunted Ballroom]);
 

EEPiccolo

New member
I've been having issues with the set_property function while trying to make a semi-rare script. Try doing get_property statements before and after the set_property statements to see if it looks like they're changing properly. After doing that, try removing the adventure statement and just spend an adventure manually in Mafia, then run the script with the get_property statements to see if the property change you made in the script actually stuck, which is the problem I've been having.

I have no idea if this will help at all, but at least it's something for you to try.
 

zarqon

Well-known member
If I had to hazard a guess, I'd say that using drum machines breaks mafia's item-use code since it enters a combat. A possible solution might be to use visit_url() to use the drum machine, then run_combat() to fight the sandworm. run_combat() will still use your ccs if you have it selected.
 

halfvoid

Member
nevermind. that just seems to make it adventure every other time by using a drum machine. hm. maybe if i use a disco combo and set it to use a drum machine after that effect wears off....
 

halfvoid

Member
aha! breakthrough with using only CLI commands.

type "use 1 drum machine" into the CLI and you fight one sandworm.
followed by "repeat X" into the CLI, where X should be the number of drum machines you want to use.

result: mafia will run through X iterations of using 1 drum machine at a time.

might be useful for other circumstances, though i'm not sure what of. just happy i figured that out since i want to run drum machines until i get a melange.
 
Top