Between Violence script

Tyken

New member
I proudly present my first work here (plus my first post, too): a script for those times between when you're inflicting violence upon your foes, when you renew your buffs, patch your wounds, and get roaring drunk on seltzer. This is a patchwork of the BetweenFights script of Presto Ragu, the MP-purchasing script of Illarion, and extensive revisions and hole-patching by myself, and includes a healing-skill selector.

The script first heals you (via skills, then items, then Doc or resting), then casts buffs to chew up 80% of your max MP (restoring MP as necessary to cast each individual buff, but skipping any buffs you already have), then restores your MP to 90% of maximum (via existing items, then purchase or resting). Since I can't tell whether the user has finished Doc's quest, there's no way to tell if Doc is cheaper than soda water. (EDIT: I stole cjswimmer's quest checker, and this script and Illarion's script now check to see if the Doc is cheaper.)

This script is usable in hardcore, as it ignores buffbots and the mall.

There are two basic user-modified areas: selecting skills to self-buff with (choose any number of them, and the script will gain MP as needed to cast them), and choosing whether you spend a single meat on anything.

Attached are my main script, and the modifications I made to Illarion's script to allow its major method to be called after importing it. (I renamed the previous main() function to payForMP(), and created a new main() that simply calls payForMP() once. The file itself has been slightly renamed to avoid any conflicts with the previous version.) This script also uses Presto Ragu's RestorerSelector, found over here.

EDIT: After glancing at the blue snowcone thread, I saw that I can ignore a cli_execute failure if I assign it to a variable. Therefore, relaxing to restore MP now works.

Also, this script used the Quest Checker, found over here.
 
its awesome to see a scriptor that still adds comments to his scripts! But do you have a "raw" copy with no comments? Its easier to see whats going on, if you know what you're looking for! Great job! ;D
 
Alas, no, I have no raw copy. In fact, I have no other copies at all, since the script is (almost-kina) short and (fairly) intuitive should I need to re-create it. (okay, okay, that's just rationalizing the fact that I never got around to making backups. That, and I usually comment as I go, to keep track of what I'm doing.) Stripping the comments yourself shouldn't take too long, though.
 
change line 70

Code:
void restore_soda()

to

Code:
boolean restore_soda()

It appears to just be a simple error in the declaration of the function.
 
Thanks!

That fixed that little problem... the only other one I'm running into now is anything referenching the QuestCheck.ash file, i.e.

Undefined reference QuestCheck at line 104 in file Illarion - Mana Restore 1.1.ash

Code:
boolean cheapGalaktik = (QuestCheck("Galaktik", true) == "Completed");

Undefined reference QuestCheck at line 143 in file BetweenViolence 1.2.ash Script verification complete.

Code:
boolean useGalaktik = (QuestCheck("Galaktik", true) == "Completed") || my_maxhp() - my_mp() < 6;

...but, I figure those have something to do with the fact that every time I try to run QuestCheck.ash by itself, I get

Orc Chasm-Bridge: No matching quest found

...that and/or my complete cluelessness when it comes to more advanced stuff like this.

Another note on this one that I *was* able to figure out for myself was the replacing of mymaxmp() and mymp() with my_maxmp() and my_mp()... I are SMRT!
 
You are missing 1 more file, maybe 2 more files. In the top post there are urls to two different threads on this sight which are about files imported into this script. You will need to go download them too. All together this is a pretty big script just for a between battle script.
 
I've got both RestorerSelecterASH.ash and QuestCheck.ash (and, of course, Illarion - Mana Restore 1.1.ash and BetweenViolence 1.2.ash), and it still gives that message.

Like I said, when I run QuestCheck.ash by itself, it gives me the message I posted previously.

Another problem I ran into is that it kept giving the error "HP not fully restored. Are you buying healing, and did you run out of money?", which indicates that the restoreHP() function failed, even though that character has over 7,000 meat. I got around it by pre-purchasing the restorers (ailment ointments, in this case), but, on another character, all it did was keep purchasing ungents, which is far less productive/useful than purchasing ailment ointments. This, too, "corrected itself", after I purchased some ailment ointments in bulk.
 
Line 95 contains a typo:
lines 94 and 95
Code:
while( item_amount( restorer_selecter( "most", "mp")) > 0 && my_mp() < minMP) {
		use( 1, restorer_selecter( "most", "hp"));

it checks:
Code:
item_amount( restorer_selecter( "most", "mp"))
then uses:
Code:
use( 1, restorer_selecter( "most", "hp"));
which means that it will near-infinite loop trying to use an HP restorer to restore MP if restorer_selecter returns a HP only restorer. I'm pretty sure Tyken intended to have it read:
Code:
while( item_amount( restorer_selecter( "most", "mp")) > 0 && my_mp() < minMP) {
		use( 1, restorer_selecter( "most", "mp"));

"mp" and "hp" as I remember are parameters which simply tell restorer_selector which kind of restorer it should return.



The repetitiveness of using 1 mp restorer at a time is not a desirable aspect of this script. If ran daily as a between battle script, and no new MP restorers are introduced into inventory, then eventually it will hit soda water in which case it will restore about 3 mp at a time. The result would be about 100 server hits to restore 300 mp (assuming you have 100 soda water) when further calculations could easily reduce that to 2.

Since kolmafia now has the functions:
boolean restore_hp( int amount )
boolean restore_mp( int amount )


the whole function starting at line 91:
Code:
// restore MP until you have at least minMP.
boolean getMinMP(int minMP) {
	//first, items.
	while( item_amount( restorer_selecter( "most", "mp")) > 0 && my_mp() < minMP) {
		use( 1, restorer_selecter( "most", "hp"));
	}
	
	// if we're cheap, rest, if we're not, use the Doc. Sadly, I can't detect the beanbag, and 
	// relaxing without a beanbag causes an abort.
	if (SKINFLINT_USER) {
		boolean canRelax = cli_execute("relax 1");
		if (canRelax) {
			while (my_mp() < minMP) {
				cli_execute("relax 1");
			}
		}
		else {
			while (my_mp() < minMP) {
				cli_execute("rest 1");
			}
		}
	}
	// pay through the nose, capitalist pig-dog! 
	else {
		payForMP();
	}
	
	return my_mp() >= minMP;
}

could be replaced with:
Code:
// restore MP until you have at least minMP.
boolean getMinMP(int minMP) {
return restore_mp( minMP );
}

and do almost the exact same thing except be more efficient, and use less server hits in doing so. This was a feature I requested because I wrote a script "icypeak.ash" which does the same thing except when the character ran out of soda water, it would buy 1, use 1, repeat getting 200 server hits out of 100 soda water which could easily have been done in 2: (buy 100, use 100) if I had only done the math.

OK this also means that:
starting at line 121 (before the previous edit is done)
Code:
boolean restoreHP() {
	//skills first. Comment this if you don't like healing with skills.
	skill layOnHands=healingSkillSelector();
	while ( my_hp() < my_maxhp() && layOnHands!=$skill[headbutt]) {
		if (my_mp() < mp_cost(layOnHands)) {
			getMinMP(mp_cost(layOnHands));
		}
		use_skill(1,layOnHands);
	}
		
	//if you don't have the skills, use items.
	while( item_amount( restorer_selecter( "most", "hp")) > 0 && my_hp() < my_maxhp()) {
		use( 1, restorer_selecter( "most", "hp"));
	}
		
	//otherwise, camp if you're cheap, pay if you're not.
	if (SKINFLINT_USER) {
		while (my_hp()<my_maxhp()) {
			cli_execute("rest 1");
		}
	}
	else {
		boolean useGalaktik = (QuestCheck("Galaktik", true) == "Completed") || my_maxhp() - my_mp() < 6;
		if (!useGalaktik) {
			//we already checked for healing items earlier, so a brain-dead healing script is fine.
			while (my_hp()<my_maxhp()) {
				if (my_meat() <60) break;
				else if (my_maxhp() - my_hp() < 6) {
					cli_execute("galaktik hp");
					break;
				}
				buy( 1, $item[Doc Galaktik's Ailment Ointment] );
				use( 1, $item[Doc Galaktik's Ailment Ointment] );
			}
		}
		else {
			cli_execute("galaktik hp");
		}
	}
	
	// if this is working, it should always return true. Otherwise, you probably ran 
	// out of money.
	return (my_hp()==my_maxhp());
}

should be changed to:
Code:
boolean restoreHP() {
return restore_hp( my_maxhp() );
}

to prevent the same loop.

If you make those 2 changes, then the line:
line#18
Code:
import <RestorerSelecterASH.ash>;
can be removed entirely because restorerselector is no longer needed.

the function
Code:
skill healingSkillSelector()
which is no longer used.
is no longer used, and can be removed.

Code:
import <Illarion - Mana Restore 1.1.ash>;
import <QuestCheck.ash>;
are also no longer used and can be removed.

Now that all this has been done, the script should be a lot more efficient and up to date. To make matters worse though there is a feature in the gui called moods on the preferences tab. If you click the auto-fill button, then kolmafia will do what this script is designed to do for you with exception to restoring MP. That would be set up on the Auto Recovery tab of the adventure pane.
 
Well, I liked the idea of this one because it seemed to cause a lot less underheal/overheal than mafia's built-in auto restore (tested after the first typo-fix).

I haven't had a chance to test it on a character that actually has more than one healing skill yet, but I like the look of the efficiency calculations taken to figure out which one to use. I don't know what mafia's internal skill/items preference selector looks like, so I can't really tell if it's better than what's already built in or not..
 
[quote author=muffins link=topic=397.msg2727#msg2727 date=1162725793]
Well, I liked the idea of this one because it seemed to cause a lot less underheal/overheal than mafia's built-in auto restore (tested after the first typo-fix).
[/quote]
That is cofigurable, however if scroll of drastic healing or medicinal herbs is used, then kolmafia will over-heal because that is the nature of those 2 items which are about the best restorers available relative to cost in my oppinion.

[quote author=muffins link=topic=397.msg2727#msg2727 date=1162725793]
I haven't had a chance to test it on a character that actually has more than one healing skill yet, but I like the look of the efficiency calculations taken to figure out which one to use. I don't know what mafia's internal skill/items preference selector looks like, so I can't really tell if it's better than what's already built in or not..
[/quote]

OK well that was my oppinion at first too. It changed with time.

Wanna know how kolmafia does it? Start here: http://kolmafia.us/index.php/topic,374.0.html then once you have the files check out \src\net\sourceforge\kolmafia\HPRestoreItemList.java and \src\net\sourceforge\kolmafia\MPRestoreItemList.java I believe a lot of the core restoration functionality is in those 2 files.
 
I usually update via SVN, but the only file I'd ever really looked at was the KoLConstants.java file, to update the revision number.

I took a look at HPRestoreItemList.java, and it does look like it does a pretty good job of determining which would be best. I'm just not sure about the MP efficiency of using the healing skills, as, like I said, I don't have a character I can really efficiently test it on. I suppose I'll go back to using the built-in autorestore for now, and give it another shot once I have some more healing skills...

Thanks.
 
Hm, it's been a while since I've been here. Looking at the newest KolMafia, there's absolutely no point at all to this script anymore. Everything this script does is handled by the "healing thresholds" and moods in KolMafia, and for the most part, handled better. I suppose this script can stand as a slightly buggy testament to old versions, or something....
 
Back
Top