illarion's mana restore script v1.0 (ASH)

illarion

Member
( Attached - see bottom of message... -Daychilde ;D )

Code:
#restores mana using MMJ if possible, else soda water, without
#wastage.
#
#no safety check for available meat, or guild being opened.
#
#Written by Illarion/Aaron Gunstone, March 2006
#Based on ASH tutorial by Xylpher

int MMJCalcMax()
#X = (1.5 * level) + (4 to 6) MP 
{
	return ((1.5 * my_level()) + 6);

}

void use_soda( int amount)
{
  if( item_amount( $item[soda water]) < amount)
  {
	buy( amount - item_amount( $item[soda water]), $item[soda water]);
  }
  use( amount, $item[soda water]);
}

void use_MMJ( int amount)
{
  if( item_amount( $item[magical mystery juice]) < amount)
  {
	buy( amount - item_amount( $item[magical mystery juice]), $item[magical mystery juice]);
  }
  use( amount, $item[magical mystery juice]);
}

void restore_MMJ()
{
  int MMJAmount;
  MMJAmount = MMJCalcMax();
  
  while( my_maxmp() > my_mp())
  {
  	
	int torestore;
	int amount;
	torestore = my_maxmp() - my_mp();
	amount = torestore / MMJAmount;
	if( amount == 0)
	{
	  break;
	}
	use_MMJ( amount);
  }
}

void restore_soda()
{
  while( my_maxmp() > my_mp())
  {
	int torestore;
	int amount;
	torestore = my_maxmp() - my_mp();
	amount = torestore / 5;
	if( amount == 0)
	{
	  break;
	}
	use_soda( amount);
  }
}


string main()
{
  string retval;
  boolean useMMJ;
  useMMJ = false;
  if( my_class() == $class[pastamancer] || my_class() == $class[sauceror])
  {
	useMMJ = true;
  }
  if( my_class() == $class[accordion thief] && my_level() >= 9)
  {
	useMMJ = true;
  }
  
  if( useMMJ)
  {
	restore_MMJ();
	retval = "restored with MMJ";
  }
  
  if (!useMMJ)
  {
	restore_soda();
	if ((my_maxmp() - my_mp()) > 5)
	{
		retval = "failed to restore";
	}
	else
	{
		retval = "restored with soda water";
	}
		
  }
  return retval;
}
 
Top