Feature - Rejected run_combat(string) Request

bumcheekcity

Active member
Basically, could we get a function
Code:
run_combat(string filter)
which runs the combat, but uses the specified filter function, like the 3-parameter version of
Code:
adventure(int, location, string)?
It would be helpful for the myst ascensions. Thanks.
 

slyz

Developer
If you have already started the combat, wouldn't using the 3 parameter version of adventure() or maybe adv1() basically achieve the same thing ?

EDIT

This:
PHP:
string my_filter(int round, string opp, string text)
{
	return "skill shieldbutt";
}

location loc = $location[ goatlet ];
string page = visit_url( loc.to_url() );
if( page.contains_text( "Combat" ) ) print( "Combat started", "green" );
adv1( loc, 0, "my_filter" );
results in:
Code:
> call test.ash

[1804] Goatlet
Encounter: drunk goat
Round 0: slyz wins initiative!
Round 0: slyz attacks! (auto-attack)
You lose 3 hit points
[COLOR=green]Combat started[/COLOR]

KoLmafia thinks it is round 3 but KoL thinks it is round 1
Round 3: slyz casts SHIELDBUTT!

[1804] Goatlet
KoLmafia thinks it is round 4 but KoL thinks it is round 2
Round 4: drunk goat takes 164 damage.
Round 4: drunk goat takes 35 damage.
Round 4: drunk goat drops 5 attack power.
Round 4: slyz wins the fight!
You gain 66 Meat
You acquire an item: bottle of whiskey
After Battle: Ieva gorges himself on candy from his bag.
You gain 11 Strongness
You gain 1 Enchantedness
You gain 5 Smarm
I had forgotten about my auto-attack, but fortunately I fumbled ^^
 
Last edited:

bumcheekcity

Active member
Oh, if adv1() will do this, then there's no need. That should sort it, thanks!

Feature rejected by original poster. -lost
 
Last edited by a moderator:

bumcheekcity

Active member
Re-opening this due to it not being quite right. run_combat() returns a buffer of the last combat page. Adv1() returns a boolean. This means that you can't do, for example:

Code:
if (index_of(adv1(whatever), "WINWINWIN") == -1) abort("Something bad happened. ");

What I'd tried to do is replace all run_combats() with a bumRunCombat() that basically did an adv1() if you were myst, and just returned run_combat() if you weren't.

But doing adv1() means I can't get the html of the final page, so I can't get the information I need about whether I won the fight.
 

Bale

Minion
Not a problem. You can get the final page load with page = run_combat()

Yes, that honestly works. If you're not in a fight it will simply return the end of the previous fight.
 

Bale

Minion
Though it does seem weird to use adv1() to run combat and run_combat as post adv1 cleanup. ;)
 

bumcheekcity

Active member
True. It would make more sense to be able to use a combat filter, but if there's a perfectly workable workaround, I'd much rather the mafia devs didn't spend time on this, particularly now as Veracity is away. I mean, if it's small and someone wants to update it, that would be awesome, but it's no big issue.
 
Top