after run_combat() ends

I'm having some problems with using run_combat to finish a fight started by a choice adv/visit url.

The problem isn't getting the combat to run, I have that working cuz I'm not trying anything fancy, but I can't seem to get any of mafia's afteradventure, betweenbattle, recovery, or mood functions to fire between multiple run_combat advs in a row. Presently I'm hacking in restore_hp(something), restore_mp(something), and mood execute, but it's messy.
 

slyz

Developer
You have to use run_combat() because you are adventuring using visit_url() ?
Do before/after adventure Mafia things run when you get normal combats instead of choice adventures?

EDIT: ok, I reread you post more carefully. So yes, you are adventuring using visit_url(). As a result, I guess Mafia doesn't consider that it is adventuring, and the mood/restore/scripts aren't firing.

I guess your adventuring routine will have to reproduce Mafia's functionality, yes.
 
Last edited:

Veracity

Developer
Staff member
KoLmafia does between battle stuff in two cases:

1) You are "adventuring", using the GUI, the "adventure" command in the CLI, or the adventure() function of ASH
2) You are clicking links in the Relay Browser

An ASH program submitting a sequence of visit_url() calls is doing ... something. Maybe it is "adventuring". We don't look at the submitted URLs and guess.

But, executing a choice certainly should count as adventuring - and we don't have a way to do that in ASH other than via visit_url. Perhaps we should. And, if you get redirected to a fight, that should be a clue that what you did was an "adventure".

Can you explain how you are adventuring and how you are detecting that you received a choice - to which you responded with a visit_url, I assume - please?
 
Can you explain how you are adventuring and how you are detecting that you received a choice - to which you responded with a visit_url, I assume - please?

Sure, Veracity. It's a simple little script for using stone wool to fight cave bars. Here's what I was using last night.
Code:
// cave bar hunting
// hidden temple / kingdom of loathing

item wool = $item[stone wool];


void hunt() {
	visit_url("inv_use.php?pwd&which=3&whichitem=5643");
	visit_url("adventure.php?snarfblat=280&pwd");
	visit_url("choice.php?pwd&whichchoice=582&option=3");
	visit_url("choice.php?pwd&whichchoice=581&option=3");
	run_combat();
}

void main(int iter) {
	for i from 1 to iter {
		if (item_amount(wool)>0) {
			hunt();
			cli_execute("mood execute");
			restore_hp(to_int(.65*my_maxhp()));
			restore_mp(to_int(.65*my_maxmp()));
		} else exit;
	}
}
 

Rinn

Developer
You should just be able to use the item normally, then set the two choice adventure settings manually, then just call adventure in this case.
 
Code:
item wool = $item[stone wool];
set_property("choiceAdventure581","3");
set_property("choiceAdventure582","3");

void hunt() {
	use(1,wool);
	adventure(1, $location[hidden temple]);
}

void main(int iter) {
	for i from 1 to iter {
		if (item_amount(wool)>0) {
			hunt();
		} else { print("Out of stone wool.","blue"); exit;}
	}
}

Does indeed work as advertised. Thanks.
 

Theraze

Active member
Eh, I'd also throw in a check for my_adventures() > 0 in the item_amount check. Since otherwise it will keep trying to use wool with 0 adventures left.
 
Top