Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #15  
Old 12-03-2010, 03:50 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

If you want to cast a spell on the entire group, it would be easiest to just get the group and cycle through each member having the NPC cast the spell on them. Though, if you only want group spells to land on the full group (and not single target), it would probably take a bit more work. I am not aware of any current commands to check if a spell is a group spell or not, but it would probably be really easy to add one to the source if needed.

Here is an example script (not tested) that includes a subroutine for casting a spell on the whole group. You could even add the sub into your plugins folder and make it into a plugin instead if you wanted so it can be accessed from any script (using plugin::CastOnGroup(SpellID, MaxDist)).


Code:
sub EVENT_SAY {

	if ($text =~ /Hail/i)
	{
		#plugin::CastOnGroup(11, 100, $client); # Can use like this is saved as a plugin instead
		CastOnGroup(11);
		quest::say("Casting buff on your group");
	}

}


#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 $SpellID = $_[0];
	my $MaxDist = $_[1];
	my $Caster = $_[2];

	# 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();
	
	# If the client is grouped
	if ($ClientGroup)
	{
		# Cycle through all 6 possible group members
		my $GCount = 0;
		while ($GCount < 6)
		{
			$GroupMember = $Group->GetMember($GCount);
			# If this group member exists
			if ($GroupMember)
			{
				my $OutOfRange = 0;
				# 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);
					# 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;
					}
				}
				
				# If they aren't out of range or range was not specified
				if (!$OutOfRange)
				{
					my $MemberID = $GroupMember->GetID();
					# Cast the spell on this member
					$npc->CastSpell($SpellID, $MemberID);
					my $PetID = $GroupMember->GetPetID();
					# Check if this member has a pet and if so, cast it on the pet as well
					if ($PetID)
					{
						$npc->CastSpell($SpellID, $PetID);
					}
				}
			
			}
			$GCount++;
		}
	}
	else
	{
		# Client is not grouped, so just cast on them
		my $CasterID = $Caster->GetID();
		$npc->CastSpell($SpellID, $CasterID);
		my $PetID = $Caster->GetPetID();
		# Check if the client has a pet and if so, cast it on the pet as well
		if ($PetID)
		{
			$npc->CastSpell($SpellID, $PetID);
		}
	}

}
Again, this is untested and I just wrote it from scratch. If it works, it would probably be a good one to add to plugins if there isn't already a better way to do this.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:54 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3