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 12-16-2010, 05:32 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default Hey does anyone have an example of a mob script...

that casts spells ect...

Im looking to do some custom scripted mobs with spells in em. Ive done custom scripted mobs before just nothing with spells.

I know u use the $NPC->CastSpell or whatever it is but it wants a target Id, should I just use whatever target has aggro?

And what about AOE spells, do you still need a target id?

Wiki doesnt have much info on it
Reply With Quote
  #2  
Old 12-16-2010, 06:53 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

So far I have this, i was reading around and found out about using $client->GetID() inside the cast spell. Her shouts but doesnt cast

Code:
sub EVENT_SPAWN {
	quest::setnexthpevent(98);
}

sub EVENT_HP {
	if($hpevent <= 98)
	{
	quest::shout("Roar Mother *******!!");
	$mob->CastSpell(21439, $client->GetID(), 1, -1, -1);
	}
}

sub EVENT_AGGRO {

}
Reply With Quote
  #3  
Old 12-16-2010, 07:12 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default

I'm pretty sure the $client is not passed with the HP event. Maybe you could use the mob's target?
Reply With Quote
  #4  
Old 12-16-2010, 08:07 PM
nenelan
Hill Giant
 
Join Date: Feb 2008
Posts: 116
Default

Try this:

Code:
            $targ = $npc->GetHateTop();
            $targid = $targ->GetID();
            $npc->CastSpell(21439, $targid);
Also, shoot me an email if you need mob scripts done. I got free time lately.
Reply With Quote
  #5  
Old 12-16-2010, 08:58 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

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
	}
}
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 12-17-2010 at 10:52 PM..
Reply With Quote
  #6  
Old 12-16-2010, 09:10 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Funny thing is, I thought about doing the same thing. I'll commit this later.

And by the way Trevius, whenever you have time I'd like to IRC you about the armorsets. Got some things made you might appreciate.
Reply With Quote
  #7  
Old 12-16-2010, 11:55 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

Thanks Ill try it out


One question, what about PB AOEs?

Do i have to make em player targeted for em to work?
Reply With Quote
  #8  
Old 12-17-2010, 07:00 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

Hey am I missing something? Smaug is only casting the one type of spell 21439 at both events.

Instead of 21440.

If i change it to 21440 on top and 21439 he will only cast 21440.

Code:
#Smaug

sub EVENT_SPAWN {
	quest::setnexthpevent(98);
}

sub EVENT_HP {

	if($hpevent <= 98)
	{
	quest::shout("Roar Mother !!");
	plugin::CastOnTarget(21439);
	quest::setnexthpevent(95);
	}
	
	if($hpevent <= 95)
	{
	quest::shout("Roar Mother !!");
	plugin::CastOnTarget(21440);
	}
	
}

sub EVENT_AGGRO {

}
Reply With Quote
  #9  
Old 12-17-2010, 07:21 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,743
Default

You might want an else in there since if the hpevent is 95 then both ifs are true.

I'd check them in reverse order for what I assume you want. I'm not a perl coder, so take this as pseudo code.

if($hpevent <= 95)
...
else if($hpevent <= 98)
...

Last edited by lerxst2112; 12-17-2010 at 07:22 PM.. Reason: Turned smilies off
Reply With Quote
  #10  
Old 12-17-2010, 08:12 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default

Or == since the event was triggered by 98 and then 95
Reply With Quote
  #11  
Old 12-17-2010, 10:51 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Yeah, always use == in hp events, otherwise it may make more than 1 match that is not intended (which is what is happening in your example since the first one is always true once the NPC drops below 98%).

And to cast a PBAE, I think you can just use $mobid variable export to cast the spell with the NPC as the target.

Code:
$npc->CastSpell(21439, $mobid);
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #12  
Old 12-18-2010, 04:44 AM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

Quote:
Originally Posted by trevius View Post
Yeah, always use == in hp events, otherwise it may make more than 1 match that is not intended (which is what is happening in your example since the first one is always true once the NPC drops below 98%).

And to cast a PBAE, I think you can just use $mobid variable export to cast the spell with the NPC as the target.

Code:
$npc->CastSpell(21439, $mobid);
ahh ok thanks a ton guys, i didnt have this problem before with the <= so i figured it would be ok
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 04:56 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