Bug - Waiting for Info Infnite loop created by macro restarting (continuing?) after failing.

Yvain

Member
I had a CCS which if my mp was too low used a particular mp restorer. When I ran out of the item mafia got stuck in combat as shown below. (Also for some reason it was updating round number by 2.) Also as a thought it would be good if mafia stopped and reported an error if it went past round 30 (or maybe 35 to account for a little unsyncronising with KoL round numbers).

In the CLI window I have:
....
KoLmafia thinks it is round 1776 but KoL thinks it is round 2
Round 1776: yvain tries to steal an item!
Round 1777: yvain executes a macro!
Round 1777: yvain tries to steal an item!
KoLmafia thinks it is round 1778 but KoL thinks it is round 2
Round 1778: yvain tries to steal an item!
Round 1779: yvain executes a macro!
Round 1779: yvain tries to steal an item!
KoLmafia thinks it is round 1780 but KoL thinks it is round 2
Round 1780: yvain tries to steal an item!
Round 1781: yvain executes a macro!
KoLmafia declares world peace.
Round 1781: yvain tries to steal an item!
KoLmafia thinks it is round 1782 but KoL thinks it is round 2
Round 1782: yvain tries to steal an item!
Click here to continue in the relay browser.

Going to the relay browser was what allowed me to figure out the source of the problem:

Combat: Round 2!
You're fighting a Goth Giant
HP: 150, Atk: 130, Def: 117
Drops: awful poetry journal (30), thin black candle (30), Warm Subject gift certificate (30)
You can't steal anything right now.
Round 3!
You can't steal anything right now.
Could not match item(s) for use: use 1965

The actual CCS is:
[ goth giant ]
try to steal an item
try to steal an item
if mpbelow 40
item bottle of Monsieur Bubble
endif
skill transcendent olfaction
if !mpbelow 6
skill run like the wind
skill pop and lock it
skill break it on down
endif
if !mpbelow 12
skill disco dance of doom
skill disco dance ii: electric boogaloo
endif
attack with weapon
 

slyz

Developer
I think the correct behavior for Mafia would be to stop if when a Macro aborts for whatever reason.

Also as a thought it would be good if mafia stopped and reported an error if it went past round 30 (or maybe 35 to account for a little unsyncronising with KoL round numbers).
What Mafia calls a combat round is unrelated with KoL combat rounds.
 

Theraze

Active member
Also, certain items and skills raise the mafia combat round, while the KoL combat round doesn't change... getting errors due to using high quantities of saucy salve, massage oil, and other such would be odd behaviour. Though I don't know why you'd want to use up that many items, but... eh, it's still 'valid' behaviour, even if it isn't logical.
 

Winterbay

Active member
I'd say setting the Mafia abort-round to 100+ or something like that would probably catch all errors in that regard. I don't think you can do enough free actions to get over 100, so if you end up there there is probably a problem somewhere. But detecting if a macro is aborting and why is probably a better solution.
 

holatuwol

Developer
Because I'm in the middle of completely rewriting combat to not report that anymore. >_>

Edit: Well, the more serious answer is that prior to macros, the two should have been identical. As for why a tiny patch hasn't been made to stop reporting errors, I want to rewrite custom combat to no longer use those internal round counters. If you commit code that makes merging hard, I will foon you!
 
Last edited:

slyz

Developer
Then why does mafia find it necessary to inform me of a de-sync EVERY ROUND?
This was added in r8399 by JasonHarper (apparently to help implement the parsing of fights where Combat Macros where used).

What Mafia calls a round number used to be the order in which CCS actions where executed, but this was made meaningless with macrofication.

To return to the original report, I have a castle farming CCS with a macro to putty Goth Giants. When it tries to putty for the 6th time, Mafia simply aborts with the "Click here to continue in the relay browser." message. I wonder why it didn't abort with this message in your case.

Could you tybe "set macroDebug = true" in the gCLI, and start again with less than 40 MP and without any bottle of Monsieur Bubble in your inventory? Escape after the start of combat so you can copy the Macro that Mafia is submitting and post it here.

Meanwhile, to avoid the issue, you should probably replace the line
Code:
item bottle of Monsieur Bubble
by
Code:
"use bottle of Monsieur Bubble"


EDIT: apparently your macro aborts without the string "Macro Abort" anywhere in the page. Adding your error message "Could not match item(s) for use" to lines 1701-1703 of FightRequest.java should solve that particular problem.
 
Last edited:

Yvain

Member
With "set macroDebug = true" in the gCLI (and not yet changing "item" to "use" I get the following:
[2120] Giant's Castle
Encounter: Goth Giant
Strategy: G:\new usb\kol\ccs\Yvain meat.ccs [goth giant]
Round 0: yvain wins initiative!
Generated macro:
sub mafiaround
endsub#mafiaround
sub mafiamp
****call mafiaround; use 518
****mark mafiampexit
endsub#mafiamp
#mafiaheader
pickpocket
pickpocket
if mpbelow 40
****call mafiaround; use 1965
endif
if !mpbelow 6
****if hasskill 52
********call mafiaround; skill 52
****endif
****if hasskill 51
********call mafiaround; skill 51
****endif
****if hasskill 50
********call mafiaround; skill 50
****endif
endif
if !mpbelow 12
****if hasskill 5005
********call mafiaround; skill 5005
****endif
****if hasskill 5008
********call mafiaround; skill 5008
****endif
endif
mark mafiafinal
call mafiaround; attack
goto mafiafinal

Round 1: yvain executes a macro!
Round 1: yvain tries to steal an item!
Round 2: yvain tries to steal an item!
Round 3: Honkey Mobo climbs up and sits on your shoulder, and hands you some Meat. Huh, where did he find that?
You gain 96 Meat.
Generated macro:
sub mafiaround
endsub#mafiaround
sub mafiamp
****call mafiaround; use 518
****mark mafiampexit
endsub#mafiamp
#mafiaheader
pickpocket
pickpocket
if mpbelow 40
****call mafiaround; use 1965
endif
if !mpbelow 6
****if hasskill 52
********call mafiaround; skill 52
****endif
****if hasskill 51
********call mafiaround; skill 51
****endif
****if hasskill 50
********call mafiaround; skill 50
****endif
endif
if !mpbelow 12
****if hasskill 5005
********call mafiaround; skill 5005
****endif
****if hasskill 5008
********call mafiaround; skill 5008
****endif
endif
mark mafiafinal
call mafiaround; attack
goto mafiafinal

Round 3: yvain executes a macro!
Round 3: yvain tries to steal an item!
KoLmafia thinks it is round 4 but KoL thinks it is round 3
Round 4: yvain tries to steal an item!
Generated macro:
....
etc for ever...

Changing
Code:
item bottle of Monsieur Bubble
to
Code:
"use bottle of Monsieur Bubble"
still results in an infinite loop:

[2124] Giant's Castle
Encounter: Goth Giant
Strategy: G:\new usb\kol\ccs\Yvain meat.ccs [goth giant]
Round 0: yvain wins initiative!
Round 1: Honkey Mobo takes a pull on the hookah, and immediately goes into a coughing fit, blowing a cloud of smoke in your face. Since this is magic smoke, instead of giving you cancer (or, perhaps in addition to giving you cancer), it gives you an effect:
You acquire an effect: You Can Really Taste the Dormouse (duration: 6 Adventures)
Generated macro:
sub mafiaround
endsub#mafiaround
sub mafiamp
****call mafiaround; use 518
****mark mafiampexit
endsub#mafiamp
#mafiaheader
pickpocket
pickpocket
if mpbelow 40
****use bottle of Monsieur Bubble
endif
if !mpbelow 6
****if hasskill 52
********call mafiaround; skill 52
****endif
****if hasskill 51
********call mafiaround; skill 51
****endif
****if hasskill 50
********call mafiaround; skill 50
****endif
endif
if !mpbelow 12
****if hasskill 5005
********call mafiaround; skill 5005
****endif
****if hasskill 5008
********call mafiaround; skill 5008
****endif
endif
mark mafiafinal
call mafiaround; attack
goto mafiafinal

Round 1: yvain executes a macro!
Round 1: yvain tries to steal an item!
You acquire an item: Warm Subject gift certificate
Round 2: Honkey Mobo climbs up and sits on your shoulder, and hands you some Meat. Huh, where did he find that?
You gain 91 Meat.
Round 2: yvain tries to steal an item!
Generated macro:
sub mafiaround
endsub#mafiaround
sub mafiamp
****call mafiaround; use 518
****mark mafiampexit
endsub#mafiamp
#mafiaheader
pickpocket
pickpocket
if mpbelow 40
****use bottle of Monsieur Bubble
endif
if !mpbelow 6
****if hasskill 52
********call mafiaround; skill 52
****endif
****if hasskill 51
********call mafiaround; skill 51
****endif
****if hasskill 50
********call mafiaround; skill 50
****endif
endif
if !mpbelow 12
****if hasskill 5005
********call mafiaround; skill 5005
****endif
****if hasskill 5008
********call mafiaround; skill 5008
****endif
endif
mark mafiafinal
call mafiaround; attack
goto mafiafinal

Round 3: yvain executes a macro!
Round 3: yvain tries to steal an item!
KoLmafia thinks it is round 4 but KoL thinks it is round 2
Round 4: yvain tries to steal an item!
Generated macro:

EDIT: I haven't figured it out myself despite what I original typed in this post and have now deleted.
 
Last edited:

slyz

Developer
Did you have bottles of Monsieur Bubble on hand? If not, try replacing
Code:
"use bottle of Monsieur Bubble"
by
Code:
if hascombatitem 1965
   "use 1965"
endif

I don't really understand the Macro error message "Could not match item(s) for use: use 1965". If the macro had aborted because you didn't have any on hand, the message would have been different, right?

In the two cases above, what where the error messages shown by KoL in the relay browser?

EDIT: in any case, regarding the problem of Mafia not aborting when the Macro aborts, I think adding
PHP:
responseText.indexOf( "Could not match item" ) != -1 ||
on line 1698 of FightRequest.java should do the trick.
 
Last edited:

zarqon

Well-known member
I had this same problem -- and same error message -- slinging love songs in the basement, and it was because I was out of that particular love song.
 

Yvain

Member
I only got the problem when I didn't have any Monsieur Bubbles left (and didn't check if I had any).
If I run it in the relay browser by clicking the script button I get:
Combat: Round 3!
You're fighting a Goth Giant
HP: 54, Atk: 130, Def: 117
Drops: awful poetry journal (30), thin black candle (30), Warm Subject gift certificate (30)
You can't steal anything right now.

Round 4!
You can't steal anything right now.
Could not match item(s) for use: use bottle of Monsieur Bubble
This continually reloads and in the CLI window it is repeating this indefinately.

(The different error message is because I'd changed it from "item bottle of Monsieur Bubble" to "item bottle of Monsieur Bubble".)


Once I add in the check if I have any 1695 it doesn't get stuck in a loop but it also means that olfaction couldn''t fire. I'd prefer it to abort in that case and I've added a if !hascombatitem to catch that and abort. I thought it should abort automatically there as an infinite loop is not a good thing.
 

slyz

Developer
Mafia aborts if it sees one of these strings in the page:
Code:
Macro Abort
Macro abort
macro abort

It's just a matter of adding a check for the "Could not match item(s) for use" message (or a part of it).
 
Top