Maximizing MP consult script version 0.4

Have you ever been using a Star Starfish, Gluttonous Green Ghost, or Ninja Pirate Zombie Robot for mana
regeneration and you wanted mafia to just stop when you reached your maximum MP so you could cast stuff,
or maybe summon candy hearts or divine items? Well that's what this script is for.

The only caveat is that since this is a consult script, when you reach your maximum MP, the script stops at
the end of the combat, so you'll have to finish off whatever you are fighting. You could easily modify this script
to not abort when you reach your maximum MP.

In the ccs script you set it up like this:
[default]
1: consult maxmp.ash
2: attack

Of course instead of attack you can define whatever finishing move is best for your class.

Also, this script works great with the wormwood.ash script too. Just start up the wormwood script as per
normal, and this script will stop the sequence when you MP is full. Then just start the wormwood script
again, and it will resume where it left off.

Version 0.4 adds in the stuff that is in the hobomonkey script. The ability to steal if you are the correct class.

Code:
# maxmp.ash (version 0.4)
# written by Captain Kirk 7/24/2008

// This script assumes you can survive on your own with moods. All it does
// is use an item that won't kill the monster until your mana is full, then it
// aborts so you can do stuff. If mana isn't full, it dumps you back to the ccs
// script at round 27.

item itemToUse;
boolean itemFound;

void PickItem()
{
	boolean inValley;

	//Pick the best items to use to do no damage for a while
	inValley = (my_location() == $location[Orc Chasm]);

	itemFound=true;

	if (! inValley ) {
		if (item_amount($item[facsimile dictionary])>0) {
			itemToUse = $item[facsimile dictionary];
		} else if (item_amount($item[dictionary])>0) {
			itemToUse = $item[dictionary];
		} else {
			itemFound=false;
		}
	}
	if ( inValley || (! inValley && itemFound == false) ) {
		itemFound = true;
		if (item_amount($item[spices])>0) {
			itemToUse = $item[spices];
		} else if (item_amount($item[turtle totem])>0) {
			itemToUse = $item[turtle totem];
		} else if (item_amount($item[seal tooth])>0 ) {
			itemToUse = $item[seal tooth];
		} else if (item_amount($item[spectre scepter])>0) {
			itemToUse = $item[spectre scepter];
		} else {
			itemFound=false;
		}
	}
}

void main (int theRound, monster theEncounter, string pageString)
{
	boolean NPZR;
	boolean didSomething;
	boolean mpFull;

	NPZR = (my_familiar() == $familiar[Ninja Pirate Zombie Robot]) ;
	didSomething = false;
	mpFull = (my_mp() == my_maxmp());
	
	PickItem();
	if (contains_text(pageString,"You get the jump")) {
		if (my_class() == $class[accordion thief] || my_class() == $class[disco bandit]) {
			pageString = steal();
			theRound = theRound + 1;
			didSomething = true;
		}
	}

	
	// If using NPZR, stick around for 10 rounds even if mana is full to get full meat steal
	while ( (! mpFull && theRound < 27) || (NPZR && mpFull && theRound < 10) || (! didSomething) ) {
		if (itemFound) {
			pageString = throw_item(itemToUse);
			mpFull = (my_mp() == my_maxmp());
			didSomething = true;
			theRound = theRound + 1;
		} else {
			abort("You don't have any applicable items to use");
		}
	}

	if ( mpFull ) {
		abort("You are at Max MP");
	}
}
 
Top