You can just use GetLevel(), which is listed here:
http://www.eqemulator.net/wiki/wikka...a=QuestObjects
It is under mob class, so you can use it on anything.
Code:
my $SPELL_ID = quest::ChooseRandom(12505, 12506, 12507);
my $NPC_TARGET = $npc->GetTarget();
my $TARGET_LEVEL = 0;
if ($NPC_TARGET)
{
$TARGET_LEVEL = $NPC_TARGET->GetLevel();
my $TARGET_ID = $NPC_TARGET->GetID();
$npc->CastSpell($SPELL_ID,$TARGET_ID);
}