View Full Version : Hey does anyone have an example of a mob script...
Astal
12-16-2010, 05:32 PM
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
Astal
12-16-2010, 06:53 PM
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
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 {
}
joligario
12-16-2010, 07:12 PM
I'm pretty sure the $client is not passed with the HP event. Maybe you could use the mob's target?
nenelan
12-16-2010, 08:07 PM
Try this:
$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.
trevius
12-16-2010, 08:58 PM
Here is one way to do it:
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:
#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
}
}
Akkadius
12-16-2010, 09:10 PM
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.
Astal
12-16-2010, 11:55 PM
Thanks Ill try it out
One question, what about PB AOEs?
Do i have to make em player targeted for em to work?
Astal
12-17-2010, 07:00 PM
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.
#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 {
}
lerxst2112
12-17-2010, 07:21 PM
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)
...
joligario
12-17-2010, 08:12 PM
Or == since the event was triggered by 98 and then 95
trevius
12-17-2010, 10:51 PM
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.
$npc->CastSpell(21439, $mobid);
Astal
12-18-2010, 04:44 AM
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.
$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
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.