PDA

View Full Version : Trouble with NPC casting


Randymarsh9
07-15-2009, 04:24 PM
I am trying to make an npc cast the spell flurry every 25% which is supposed to just make him attack, but it just says "Khabahn's casting has been interrupted" everytime I fight him. Also the whole timer thing doesn't seem to be working at all

sub EVENT_COMBAT{
if ($combat_state == 1){
quest::settimer("knockback", 15);
quest::setnexthpevent(75);
}
}
sub EVENT_TIMER{
if ($timer eq "knockback"){
$target = $npc->GetTarget();
$npc->CastSpell($target, 904);
$client->Message(4,"A blow from Khabahn sends you flying.");
quest::stoptimer("knockback");
quest::settimer("knockback", 15);
}
}
sub EVENT_HP{
if ($hpevent == 75){
$target = $npc->GetTarget();
quest::shout("This is over!");
$npc->CastSpell($target, 4607);
$npc->CastSpell($target, 4607);
$npc->CastSpell($target, 4607);
$npc->CastSpell($target, 4607);
$npc->CastSpell($target, 4607);
$npc->CastSpell($target, 4607);
quest::setnexthpevent(50);
}
if ($hpevent == 50){
$target = $npc->GetTarget();
quest::shout("Prepare yourself!");
$npc->CastSpell(4607, $target);
$npc->CastSpell(4607, $target);
$npc->CastSpell(4607, $target);
$npc->CastSpell(4607, $target);
$npc->CastSpell(4607, $target);
$npc->CastSpell(4607, $target);
quest::setnexthpevent(25);
}
if ($hpevent == 25){
$target = $npc->GetTarget();
quest::shout("Take this!");
$npc->CastSpell(470, $target);
}
}
sub EVENT_DEATH{
quest::setglobal("arena", 8, 5, "F");
quest::shout("No, how did this happen?!?");
quest::setglobal("khabahn", 1, 5, "F");
quest::signalwith(1370,3,1);
quest::spawn(1371,0,0,-19, 106, 6.4);
}

KLS
07-15-2009, 05:06 PM
usage:
Mob::CastSpell(spell_id, target_id, slot= 10, casttime= -1, mana_cost= -1)
so:
$npc->CastSpell(4607, $target->GetID());

Randymarsh9
07-15-2009, 05:16 PM
So will that first one make them do it with no delay? And with that can I get rid of the $target = $npc->GetTarget()?

Randymarsh9
07-15-2009, 05:41 PM
Ok I changed it to be like this
sub EVENT_COMBAT{
if ($combat_state == 1){
quest::settimer("knockback", 8);
quest::setnexthpevent(75);
}
}
sub EVENT_TIMER{
if ($timer eq "knockback"){
$target = $npc->GetTarget();
$npc->CastSpell(904, $target->GetID());
$client->Message(4,"A blow from Khabahn sends you flying.");
quest::stoptimer("knockback");
quest::settimer("knockback", 8);
}
}
sub EVENT_HP{
if ($hpevent == 75){
$target = $npc->GetTarget();
quest::shout("This is over!");
$npc->CastSpell(2802, $target->GetID());
$npc->CastSpell(2802, $target->GetID());
$npc->CastSpell(2802, $target->GetID());
$npc->CastSpell(2802, $target->GetID());
$npc->CastSpell(2802, $target->GetID());
$npc->CastSpell(2802, $target->GetID());
quest::setnexthpevent(50);
}
if ($hpevent == 50){
$target = $npc->GetTarget();
quest::shout("Prepare yourself!");
Mob::CastSpell(2802, $target->GetID(), slot= 10, casttime= -1, mana_cost= -1)
Mob::CastSpell(2802, $target->GetID(), slot= 10, casttime= -1, mana_cost= -1)
Mob::CastSpell(2802, $target->GetID(), slot= 10, casttime= -1, mana_cost= -1)
Mob::CastSpell(2802, $target->GetID(), slot= 10, casttime= -1, mana_cost= -1)
Mob::CastSpell(2802, $target->GetID(), slot= 10, casttime= -1, mana_cost= -1)
Mob::CastSpell(2802, $target->GetID(), slot= 10, casttime= -1, mana_cost= -1)
quest::setnexthpevent(25);
}
if ($hpevent == 25){
$target = $npc->GetTarget();
quest::shout("Take this!");
Mob::CastSpell(470, $target->GetID(), slot= 10, casttime= -1, mana_cost= -1)
}
}
sub EVENT_DEATH{
quest::setglobal("arena", 8, 5, "F");
quest::shout("No, how did this happen?!?");
quest::setglobal("khabahn", 1, 5, "F");
quest::signalwith(1370,3,1);
quest::spawn(1371,0,0,-19, 106, 6.4);
}


The knockback part of the timer works, but none of the other casts do anything

Randymarsh9
07-15-2009, 07:00 PM
can anyone just rewrite that in a way they know will work? I've been working on it all day and can't get the thing to work with any spell.

KLS
07-15-2009, 07:28 PM
Your problem with that is that sub EVENT_HP is probably not compiling because of Mob::CastSpell instead of $npc->CastSpell() in the final two if statements.

Randymarsh9
07-15-2009, 07:56 PM
hm ok I'll try putting it back to like that

Randymarsh9
07-15-2009, 08:17 PM
I finally got it working. I just changed the multiple casts for one cast of a powerful spell and changed the mob::quest thing. Thanks for the help KLS!