I may need some help with combat filters

chown

Member
I can't get my combat filter to work. I've copied an example almost verbatim from http://wiki.kolmafia.us/index.php?title=Adventure

I set my ccs to contain just "abort", in order to test the following snippet. What I expect to happen is for run_combat to use the filter. The combat filter should initially return "skill CLEESH". I'm running this after starting a combat with a non-cleeshed opponent. The filter does indeed appear to be detecting this & returning "skill CLEESH". But I'm not CLEESHing.... Instead, Mafia appears to be ignoring the return value, and consulting my ccs directly. (I think. It's not getting the contents through whm_combat_cleesh, at least. I can do some more investigation on my end.)

How can I get this to work? Is there something I'm missing?

Code:
string whm_combat_cleesh(int actionIndex, string opp, string text) {
        print("whm_combat_cleesh", "(" + actionIndex + "," + opp + ",...)");
        if (
                opp == $monster[frog].to_string() || opp == $monster[newt].to_string()
                || opp == $monster[salamander].to_string()
        ) {
                // (not sure if this is right.  at the moment, it doesn't ever get executed.)
                print("returning '" + get_ccs_action(actionIndex) + "'");
                return get_ccs_action(actionIndex);
        }
        print("returning 'skill CLEESH'");
        return "skill CLEESH";
}
void whm_test() {
        buffer combatResult = run_combat("whm_combat_cleesh");
        print("okay, run_combat(\"whm_combat_cleesh\") returned.  buffer has length " + length(to_string(combatResult)));
        print_html(combatResult);
}
 

chown

Member
Hmm. Further investigation leads me to believe that it is not the case that Mafia is consulting my CCS, as I had thought above. It seems to be returning a page that Mafia generated originally, when I first started the combat & aborted it. (using my CCS)

Edit: I seem to be having slightly better luck with adv1:

scratch.ccs:
Code:
[ default ]
abort

whm_test.ash:
Code:
static boolean xxxxxxx= true;
string whm_combat_cleesh(int actionIndex, string opp, string text) {
        print("whm_combat_cleesh" + "(" + actionIndex + "," + opp + ",...)");
        if (100 < actionIndex) abort("some kind of loop");
        string reply = "skill CLEESH";
        if (xxxxxxx) {
                reply = "use dictionary";
                xxxxxxx = false;
        }
        print("returning " + reply);
        return reply;
}
void whm_test() {
        boolean combatResult = adv1($location[the smut orc logging camp], -1, "whm_combat_cleesh");
        print("okay, adv1 returned " + combatResult + ".");
}

the result:
Code:
> ash import <whm_test.ash> whm_test()

Visit to Mountain: The Smut Orc Logging Camp in progress...

[1004] The Smut Orc Logging Camp
Encounter: hot smut orc jacker
Strategy: /media/weston/A4D3-141C/kol/kolmafia/ccs/scratch.ccs [default]
Round 0: grep wins initiative!
whm_combat_cleesh(0,smut orc jacker,...)
returning use dictionary
Round 1: grep attacks!
Round 2: smut orc jacker takes 47 damage.
Round 2: You lose 18 hit points
whm_combat_cleesh(1,smut orc jacker,...)
returning skill CLEESH
Round 2: grep casts CLEESH!
Round 3: your opponent becomes a frog!
whm_combat_cleesh(2,frog,...)
returning skill CLEESH
Round 3: grep attacks!
Round 4: frog takes 5 damage.
Round 4: grep wins the fight!
You gain 12 Meat
After Battle: Waginald does a couple of karate moves, then swivels his hips and gyrates his pelvis.
You acquire an item: squashed frog
After Battle: You gain 1 Beefiness
After Battle: You gain 2 Cheek

okay, adv1 returned true.
Returned: void

But, where did the attacks come from? My battle action is set to "custom combat script". My ccs only ever aborts.
 
Last edited:

xKiv

Active member
Do you have a native kol /autoattack ?
Are you sure you have the dictionary?
Does the dictionary cause spelling damage only in the valley, or does that also happen to orcs?

Can you turn on enough debug to see the actual combat text?
 
Last edited:

heeheehee

Developer
Staff member
My guess is that you should be using "item dictionary", not "use dictionary"; Mafia is getting confused because it doesn't know what "use" means, and so it's defaulting to attacking.
 

chown

Member
So, heeheehee is exactly right about "use dictionary". Is this correct behavior, though? (In CCS's, "use" is a synonym for "item".) I'm still not sure if I understand how combat filters are supposed to work. And I've now given up trying to use run_combat; visit_url works fine for everything I want to do right now. Regardless, it seems to be hopelessly broken, AFAICT.

Oh, also, I wasn't aware of the debugging options in KoL. I turned them on, but I don't see any additional output in my session log, or any additional logs created....
 

Veracity

Developer
Staff member
I can't get my combat filter to work. I've copied an example almost verbatim from http://wiki.kolmafia.us/index.php?title=Adventure
That shows you how to use a combat filter with adventure() or adv1().

I set my ccs to contain just "abort", in order to test the following snippet. What I expect to happen is for run_combat to use the filter. The combat filter should initially return "skill CLEESH". I'm running this after starting a combat with a non-cleeshed opponent. The filter does indeed appear to be detecting this & returning "skill CLEESH". But I'm not CLEESHing.... Instead, Mafia appears to be ignoring the return value, and consulting my ccs directly. (I think. It's not getting the contents through whm_combat_cleesh, at least. I can do some more investigation on my end.)
Ha ha.

Well, I discovered today that run_combat() with a combat filter calls your filter once but never actually submits a request to fight. Instead, it returns immediately, leaving you in the middle of the fight. When I came to see f there was an open bug report on this, I found that there does not seem to be, but I found this thread.

Revision 17463 fixes run_combat() with a combat filter.
 

Veracity

Developer
Staff member
I was ignoring combat script stuff back then since I never ran scripts, in or out of combat. I am actually doing a but of scripting now, including adventuring with combat filters, so I am newly inspired.

I remember when you deleted your posts. I was sorry that you had done so - since I think it was because I offended you - but I am glad to see you are back.
 
I'm glad for the new inspiration! I've since moved on from the whole thing so I'll leave it that :D

I'm not actually sure if run_combat() triggers postadventure scripts normally (EDIT: Unless I CCSed wrong, it does not). After reading the documentation on the wiki and thinking about it a little:

1) It returns text from the encounter; I assume, and perhaps wrongly, that we might want to act based on that text rather than use our standard postadventure handling.
2) I'm not sure what a typical user expects, my default expectation was that it would trigger postadventure. But since I wasn't able to use it until r17463, I hadn't considered the implications of it. Now, in any combat that I start in a "roundabout way" (visit_url), I may want to respond to it differently based on the outcome - which probably means to manually trigger postadventure but can allow for special handling on both sides of the "roundabout" combat.

EDIT: It appears that run_combat() never invokes postadventure. That makes sense to me after thinking about it.
 
Last edited:
Top