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

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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2019, 11:38 PM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default Client CastSpell From EVENT_SPELL_EFFECT

I have a table that saves the spell id of certain buffs. When a user casts a particular spell, I want all of the buffs they have saved to be cast on their target (basically the buff master guy that was on Dungeon Crawl, if anyone remembers). I'm unable to get CastSpell to actually fire though, so I'm not sure if I'm referencing the caster (and target) of the spell correctly.

I currently have the spell in its own global/spells file. I know I could move the code to global_player.pl in an EVENT_CAST sub, but I don't want to clutter up that file unnecessarily, so I'd prefer to get this method to work.

Here is what I have so far.

Code:
sub EVENT_SPELL_EFFECT_CLIENT
{
	my $target = $client;
	CastBuffs($caster_id, $target);
}

sub EVENT_SPELL_EFFECT_NPC
{
	my $target = $npc;
	CastBuffs($caster_id, $target);
}

sub CastBuffs
{
	my $caster_id = $_[0];
	my $target = $_[1];
	my $target_id = $target->GetID();
	my $caster = $entity_list->GetClientByID($caster_id);
	
	my $dbh = plugin::LoadMysql();
	my $query = $dbh->prepare("SELECT spell_id FROM character_stored_buffs WHERE id = ?");
	$query->execute($caster->CharacterID());
	
	while (my @row = $query->fetchrow_array())
	{
		$caster->CastSpell($row[0], $target_id);
	}
	
	$query->finish();
	$dbh->disconnect();
}
In the while loop, if I do something like
Code:
$caster->Message(5,"$row[0]");
$target->Message(5,"You are the target");
It will message the caster with the correct spell id and message the target as well, so those references somewhat seem to work.

Here are some of the other ways I've tried to reference the caster.

Code:
$caster->CastToClient()->CastSpell($row[0], $target_id);
$caster->CastToMob()->CastSpell($row[0], $target_id);
$entity_list->GetClientByCharID($caster->CharacterID())->CastSpell($row[0], $target_id);
$entity_list->GetClientByID($caster_id)->CastSpell($row[0], $target_id);
$entity_list->GetClientByID($caster->CharacterID())->CastSpell($row[0], $target_id);
$entity_list->GetMobByID($caster_id)->CastSpell($row[0], $target_id);
$entity_list->GetMobByID($caster->CharacterID())->CastSpell($row[0], $target_id);
Does anyone have any insight on how to make CastSpell work from an EVENT_SPELL_EFFECT sub? It seems like if I copy my code into a sub EVENT_SAY, my code works exactly as expected, so I'm not sure if these subs are just weird or not.
Reply With Quote
  #2  
Old 01-23-2019, 01:38 AM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

you can't spam CastSpell calls, using SpellFinished should avoid the rate limit timer.
Reply With Quote
  #3  
Old 01-23-2019, 11:04 PM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default

Quote:
Originally Posted by demonstar55 View Post
you can't spam CastSpell calls, using SpellFinished should avoid the rate limit timer.
Great, that worked. Thanks!
Reply With Quote
Reply


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 11:34 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3