$Train1 = false;
$Train2 = false;
$T = true;
function Train(%Opt)
{
if($T)
{
if(Fetch("MANA") == 0)
{
echo("Meditate");
say(0, "#meditate");
schedule::Add("say(0, \"#meditate\");", 3, SayMed);
Train::Meditate();
schedule::Add("Train::Meditate();", 3, TrainMeditate);
}
if(%Opt == 0)
{
schedule::Cancel(TrainWeapon);
schedule::Cancel(TrainWeight);
return;
}
else if(%Opt == 1)
{
$Action = 1;
schedule::Cancel(TrainMedWeapon);
$Train1 = true;
postAction(2048, IDACTION_BREAK1, 0);
schedule::Add("Train(1);", 1.8, TrainWeapon);
}
else if(%Opt == 2)
{
$Action = 1;
schedule::Cancel(TrainMedWeight);
$Train2 = true;
postAction(2048, IDACTION_MOVEUP, 1);
schedule::Add("Train(2);", 0.1, TrainWeight);
}
}
}
function Train::Meditate()
{
$Action = 2;
$T = false;
schedule::Add("Train::Meditate();", 2, TrainMeditate);
if(Fetch("MANA") == 100)
{
echo("Wake Up.");
say(0, "#wake");
schedule::Add("say(0, \"#wake\");", 3, SayWake);
schedule::Cancel(TrainMeditate);
$T = true;
if($Train1)
{
Train(1);
schedule::Add("Train(1);", 3, TrainMedWeapon);
}
if($Train2)
{
Train(2);
schedule::Add("Train(2);", 3, TrainMedWeight);
}
}
}
function TrainOff()
{
$T = false;
schedule::Cancel(TrainWeapon);
schedule::Cancel(TrainWeight);
}