Checking the round number in CCS

Is there a way to check the current round number in a combat script?

There's been a bunch of discussion on the game forums about motives for delaying a fight. In particular, this month's IoTM intergnat familiar makes it profitable to extend fights to 5 rounds in some cases. So I'd like to do this:

[do some STUFF]
while(roundnumber < 5) {
    delay (eg. by using a seal tooth)
[finish the fight]

Obviously, if that initial STUFF takes a predetermined number of rounds, this is trivial. But if that STUFF takes a variable number of turns, then I need to be able to see the current round number. Can I?

EDIT: Oh, I guess I can parse the page for "Combat: Round X!" So I'll go ahead and do that, but I'm still interested in hearing if there's a simpler (prebuilt) way.
Last edited:


Staff member
The "Round X" stuff is added by mafia, and wouldn't be there for a script (at least a non-relay script). There is a javascript variable on the page, but only for the first round of combat displayed on the page (relevant for a combat macro that runs multiple rounds, where mafia extrapolates to display the other round numbers).

In a CCS, you can use something like
1: item seal tooth
6: attack
to use a seal tooth for the first 5 rounds, and then start attacking. That doesn't work perfectly, mostly for actions that don't take a round like Saucy Salve.

With combat macros being a thing, you can use the pastround predicate to let KoL change your action once you've passed that round number. I'm not sure what can go in a CCS as far as macro language goes (my CCS is now just the word "abort" to make sure I never accidentally run it), but any line in double quotes in your CCS will be sent unmodified by mafia as part of its combat macro generation.
Sorry, I asked the wrong question. I'm actually trying to this in a consult script, not the Custom Combat tab. And I'm dumb, because the main() function required in consult scripts takes int round as a parameter already. I'd forgotten about that, since I've never used it.

So, I can use the round variable directly within main() {}. Is there a clever way to get to that information in a different function? I've got a separate function that runs multiple rounds of combat, so main() won't be called again during that execution time, and although I can easily tell on what round the function started, I can't tell the current round on-the-fly using this main() parameter.
Last edited:


Well-known member
Getting the current round number is a non-trivial task. Even accessing the round variable in main() may not always be accurate, as mafia's understanding of the round number can sometimes be thrown off by non-actions such as attempting to throw an item you don't have or somesuch.

The easiest way is probably to grab the JavaScript variable from the page and then add to it for each macro action performed afterwards. I'm not at home at the moment but I believe that code still exists in BatBrain.

Optionally, you could simply import BatBrain to your consult script, at which point the global variable "round" would contain your current round, and then you could just do this:

while (round < 5) enqueue(stasis_action());

Which would prolong the combat up to round 5 using your best low-damage option before performing your most cost-effective attack option, in a single macro. If you want to use specific actions instead of BatBrain's selections you can use get_action(), which accepts an item, skill, or string as a parameter. The risk there is that your script will fail if you don't have that action available.
Last edited: