
12-04-2010, 02:00 PM
|
 |
Administrator
|
|
Join Date: Feb 2009
Location: MN
Posts: 2,072
|
|
Quote:
Originally Posted by trevius
I am not having any issues casting group spells from an NPC using this:
Code:
sub EVENT_SAY {
if ($text =~/hail/i) {
my $Group = $client->GetGroup();
if($Group) {
$Group->CastGroupSpell($npc, 1693)
}
else {
my $GetPlayerID = $client->GetID();
$npc->CastSpell(1693, $GetPlayerID );
}
quest::say("Incoming Clarity for $name");
}
}
And, Akkadius, keep in mind that that code was untested. I tested it a bit and there was an issue or 2 with it. This updated one seems to work well enough though:
Code:
#Usage: plugin::CastOnGroup(SpellID, MaxDist=0, Client=$client);
# This script will cast the spell on the client's group from an NPC (such as a buff bot).
# SpellID - This is just the spell ID to be cast.
# MaxDist - This is an optional field for setting the Max Distance for the spell to land on group members.
# The Default 0 setting for MaxDist disables the check for distance so it will be cast on all group members in zone.
# Client - This is an optional field to set a specific client to cast buffs on their group (Default is the client interacting with the NPC)
sub CastOnGroup {
my $npc = plugin::val('$npc');
my $client = plugin::val('$client');
my $entity_list = plugin::val('$entity_list');
my $SpellID = $_[0];
my $MaxDist = $_[1];
my $Caster = $_[2];
#plugin::Debug("If the caster field was not set, use the client interacting with the NPC as the caster");
if (!$Caster)
{
$Caster = $client;
}
my $ClientGroup = $client->GetGroup();
#plugin::Debug("If the client is grouped");
if ($ClientGroup)
{
#plugin::Debug("Cycle through all 6 possible group members");
my $GCount = 0;
while ($GCount < 6)
{
$GroupMember = $ClientGroup->GetMember($GCount);
#plugin::Debug("If this group member exists");
if ($GroupMember)
{
my $OutOfRange = 0;
#plugin::Debug("If MaxDist was set, make sure the client is within the desired range");
if ($MaxDist)
{
my $ClientX = $GroupMember->GetX();
my $ClientY = $GroupMember->GetY();
my $ClientZ = $GroupMember->GetZ();
my $ClientDist = $npc->CalculateDistance($ClientX, $ClientY, $ClientZ);
#plugin::Debug("Check if the Square Root of the Distance from NPC to Client is less than MaxDist");
# CalculateDistance returns squared distance
if (sqrt($ClientDist) > $MaxDist)
{
$OutOfRange = 1;
}
}
#plugin::Debug("If they aren't out of range or range was not specified");
if (!$OutOfRange)
{
my $MemberID = $GroupMember->GetID();
#plugin::Debug("Cast the spell on this member");
#$npc->CastSpell($SpellID, $MemberID);
$npc->SpellFinished($SpellID, $GroupMember, 0);
my $PetID = $GroupMember->GetPetID();
#plugin::Debug("Check if this member has a pet and if so, cast it on the pet as well");
if ($PetID)
{
#$npc->CastSpell($SpellID, $PetID);
$npc->SpellFinished($SpellID, $entity_list->GetMobByID($PetID), 0);
}
}
}
$GCount++;
}
}
else
{
#plugin::Debug("Client is not grouped, so just cast on them");
my $CasterID = $Caster->GetID();
#$npc->CastSpell($SpellID, $CasterID);
$npc->SpellFinished($SpellID, $Caster, 0);
my $PetID = $Caster->GetPetID();
#plugin::Debug("Check if the client has a pet and if so, cast it on the pet as well");
if ($PetID)
{
#$npc->CastSpell($SpellID, $PetID);
$npc->SpellFinished($SpellID, $entity_list->GetMobByID($PetID), 0);
}
}
}
|
I figured since your history of posting plugins it would be fine. Not a big deal, updated the plugin. Good job
|