# XP Rate counter by Urquart
print "${BGreen}Loading sancs.pl\n";

my $sancleft = 0;
my $checksanc = 0;

sub cmd_sed { $sancleft = 125; }
sub cmd_sanc { 
	run ("c s $_");
	if ($_ eq "Kethlore") { $checksanc = 1; }
	if ($_ eq "me") { $checksanc = 1; }
}

sub sanccheck {
	if (/You fumble over the correct inflection used to cast sanctuary./)
         { $checksanc = 0; }
	if (/The command you are engaged in prevents you./)
	 { $checksanc = 0; }
	if (/A glowing white aura surrounds your body./)
	 { $checksanc = 0; $sancleft = 125; }
	if (/A white glowing aura surrounds your body./)
	 { $checksanc = 0; $sancleft = 125; }
	if (/The white aura around your body fades./)
	 { $checksanc = 0; $sancleft = 0; }
	if (/The white aura flashes brightly and disappears./)
	 { $checksanc = 0; $sancleft = 0; }
	if (/The white aura flashes brightly and vanishes./)
	 { $checksanc = 0; $sancleft = 0; }
 	if (/(.*) and are drained of 75 mana./)
	 { if ($checksanc == 1) { $checksanc = 0; $sancleft = 125; } }
}


	
sub sanctimer {
	$sancleft = $sancleft - 1;
        if ($sancleft < 0) { run("/prompt ***> "); }
	else { 
         if ($sancleft < 10) { run("/prompt **$sancleft> "); } 
	 else {
          if ($sancleft < 100) { run("/prompt *$sancleft> "); }
	  else {
           if ($sancleft < 125) { run("/prompt $sancleft> "); }
          }
         }
        }
}
	
callout_add(\&sanctimer, 1);
output_add(\&sanccheck);

1;
