Here is one way to do it:
Code:
sub EVENT_SPAWN {
quest::setnexthpevent(98);
}
sub EVENT_HP {
if($hpevent <= 98)
{
quest::shout("Roar Mother *******!!");
my $NPCTarget = $npc->GetTarget(); # Get the NPC's Target
# Make sure they have a target before getting the ID, or the zone could crash
if ($NPCTarget)
{
my $TargetID = $NPCTarget->GetID();
$npc->CastSpell(21439, $TargetID);
}
}
}
I always just use this simple plugin I made a while back for casting on the NPC's target:
Code:
#Usage: plugin::CastOnTarget(spellid);
# This can be used anywhere, but is best used from events
# that don't export a $client value such as EVENT_TIMER.
# This simply tries to get the NPCs target and then casts
# the spell on them if it has a target
sub CastOnTarget {
my $npc = plugin::val('$npc');
my $CastSpellID = $_[0]; #Use the Spell ID Supplied to the Function - "$_[0]" means to use the first argument given
my $Cur_Target = $npc->GetTarget(); #Get the current Target for this NPC
if ($Cur_Target && ($Cur_Target->IsNPC() || $Cur_Target->IsClient())) { #Only cast if the NPC actually has a Target
my $My_Target = $Cur_Target->GetID(); #Get the Entity ID of the Target
$npc->CastSpell($CastSpellID, $My_Target, 11); #Cast the requested Spell ID on the NPC's Target
# Note: Uses slot 11 argument to prevent fizzling from ever happening
}
}