Results 1 to 4 of 4

Thread: Checking the round number in CCS

  1. #1
    Senior Member
    Join Date
    Jun 2011
    Posts
    365

    Default 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:

    Code:
    [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 by PaladinWhite; 05-03-2016 at 11:27 PM.

  2. #2

    Default

    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
    Code:
    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.

  3. #3
    Senior Member
    Join Date
    Jun 2011
    Posts
    365

    Default

    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 by PaladinWhite; 05-04-2016 at 12:57 AM.

  4. #4
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,370

    Default

    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());
    enqueue(attack_action());
    macro();


    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 by zarqon; 07-18-2016 at 05:54 AM.
    Sig by JakAtk
    My scripts: One-Click Wossname | Om******* (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mer******** (?!) | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | CanAdv | Script Registry | Map Manager | About Bats
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •