Feature - Implemented run_combat() with a combat filter.

Sometimes a fight will get interrupted or commence after a visit_url() call. If that happens, I have found no way to continue the fight with a combat filter. It would be great if it were possible to start the combat again using a combat filter.

Something like buffer run_combat( string filter )

What do you think?
 

jasonharper

Developer
I don't know; I'm kind of regretting the combat filter function at this point, since in its original form it's impossible to macrofy.

If you're using the newer form which takes a raw macro, you don't need to use run_combat(): if the fight has already started, you can submit the macro yourself.
visit_url("fight.php?action=macro&macrotext=" + url_encode(yourMacro));
 
visit_url("fight.php?action=macro&macrotext=" + url_encode(yourMacro));

I can work with that, I think. I haven't even looked at macros yet. Would "yourMacro" in that example just be a string containing macro commands? Would the commands in the string need to be separated by spaces?
 
I can't seem to get this to work. I'm just trying to execute a couple of macro commands to make sure it's functioning as intended, but I'm not having any success.

First I start a fight manually in the mini-browser, then I try to use visit url to run a macro.

I've tried several dozen different things now, but the most intuitive to me are the following:

Code:
string my_macro = "attack;skill suckerpunch;attack;";
//string my_macro = "attack;skillsuckerpunch;attack;";
//string my_macro = "attack; skill suckerpunch; attack;";

visit_url("fight.php?action=macro&macrotext=" + url_encode(my_macro));
None of those are doing anything in combat. I think I'm just twiddling my thumbs. What am I missing?

Also, back to the feature request. Given your original response, what are your future plans, or are there any, for the current combat filter functionality? Are you going to try to change them to work with macros, or remove them entirely, or...?
 
Last edited:

jasonharper

Developer
I'm not at home where my development system is, so can't look into this deeply at the moment. What you could do is turn on debug logging for the duration of one macro usage, and see what's different in the URL being requested - maybe I've misremembered one of the parameter names, maybe it needs a "&pwd", or something like that.
 

bumcheekcity

Active member
Could we get an argument for run_combat()?

Basically I just want to be able to use run_combat() with a filter function like the third argument in adventure(). Is this a possibility?
 

Bale

Minion
So that you can use run_combat() to run a macro instead of using visit_url() in a consult script?

That does sound like a good idea!
 

StDoodle

Minion
Since you can finish combats that are "paused" by typing ashq run_combat() in the cli, this would make it much easier to alias a couple of quick macro-building routines.
 

slyz

Developer
I looked a little at FightRequest.java when I reported this problem, and even though that specific problem won't occur if you submit a KoL Macro after the combat has started, it seems like some code needs to be moved around for a macro override to work when requested after round 0 (see lines 493-511 of FightRequest.java).

If Jason decides to take a further look at this, it would be great to also take into considerations the issue I linked to above (it's a KoL bug which needs to be worked around I suppose).
 
Last edited:

ereinion

Member
I'll fourth, fifth, or whatever this request, since I want to run a function similar to what's in the code sample on run_combat's wiki-page, except with a consult-script/filter used instead of this function... It might be I could do this with visit_url instead, but I can't get it to work, and from what The FN Ninja writes a bit up this page, I am not tempted to try too hard :p
 

Winterbay

Active member
You could always run the function as an alias. The function in that wiki-page can be run with the following alias:
Code:
alias run_adv => ashq int run_adv(location place) { string page_text = to_url(place).visit_url(); string choiceAdventure = "-1"; matcher m_choice = create_matcher("whichchoice value=(\\d+)", page_text); while(page_text.contains_text("choice.php")) { m_choice.reset(page_text); m_choice.find(); choiceAdventure = m_choice.group(1); string choice_num = get_property("choiceAdventure"+ choiceAdventure); if(choice_num == "0") abort("Manual Control for "+ choiceAdventure); if(choice_num == "") abort("Unsupported Choice Adventure!"); page_text = visit_url("choice.php?pwd&whichchoice="+ choiceAdventure + "&option="+ choice_num); } if(page_text.contains_text("Combat")) run_combat(); return choiceAdventure.to_int();}

Also, I use the following short alias to specify a skill to use in a stopped fight:
Code:
alias use_skill => ashq buffer dump = visit_url("fight.php?action=macro&macrotext=skill " + to_int(to_skill($string[%%])))
 

ereinion

Member
But I don't want to run the function from the cli-window, I want to run it from a script, to detect if I've run into any of the boss-combats in Hobopolis (in order to switch area to adventure in). Currently I'm fixing this by doing this after every combat:
Code:
boolean checkLocation(location test) {
    string locationHtml;
    
    switch (test) {
        case $location[Burnbarrel Blvd.]:
            locationHtml = visit_url("clan_hobopolis.php?place=4");
            break;
        case $location[Exposure Esplanade]:
            locationHtml = visit_url("clan_hobopolis.php?place=5");
            break;
        case $location[The Heap]:
            locationHtml = visit_url("clan_hobopolis.php?place=6");
            break;
        case $location[The Ancient Hobo Burial Ground]:
            locationHtml = visit_url("clan_hobopolis.php?place=7");
            break;
        case $location[The Purple Light District]:
            locationHtml = visit_url("clan_hobopolis.php?place=8");
            break;
        case $location[Hobopolis Town Square]:
            locationHtml = visit_url("clan_hobopolis.php?place=2");
            if (townsquareNumber(locationHtml) < 25) {
                return true;
            }
        default:
            print("Something went wrong with figuring out which areas are open", "red");
            return false;
    }
    
    if (!(locationHtml.contains_text("11.gif") || locationHtml.contains_text("10.gif"))) {
        return true;
    }
    return false;
}
But I figured I could save a server hit/adventure by getting the last non-combat number from the custom adventuring function on the wiki-page instead (though I'm uncertain if the method it uses for combat will actually increase server-hits?)

And I don't think the alias you posted will actually consider a filter/consult script anyway, unless it's included in your current CCS?
 

randombk

New member
Using combat filters with monsters spawning from items

I need a way to use combat filters in fights with puttied and photocopied monsters. I asked about this earlier in Scripting Discussion, and Bale suggested

I think you need a feature request for buffer run_combat( string filterFunc ) to run the combat after you use the faxed monster using visit_url().

I guess that this would also help with automating BRICKO monsters...
 

Bale

Minion
Just for a clarification, hopefully someone knows the answer to this question. Since I've never actually automated such a thing.

In a script if a fax is used with use(1, $item[photocopied monster]) it automatically run combat, so you cannot make use of this run_combat()?

If so, then visit_url( "inv_use.php?&pwd&ajax=1&whichitem=" + to_int($item[photocopied monster]) ) would wait for run_combat() so that this feature could be used, correct?
 

Catch-22

Active member
Is there a particular reason you'd need to use combat filters to accomplish this?

What's wrong with just using the item that spawns the monster and having your CCS take care of it? Can you provide a little more context?
 

Bale

Minion
I was assuming he was doing something like bumcheekascend which makes extensive use of in-script combat filters to kill monsters instead of using a combat consult script. Personally, I do prefer the approach of a consult script, but since filters functions can be used with adv1() and adventure() it seems only appropriate to extend that mafia feature to the use of combat spawning items as well. It's weird that there is a way you can get into combat that does not make use of a combat feature which is otherwise available.

In other words, extending the combat filter feature to run_combat() merely seems to be a matter of consistency.
 
Last edited:
Top