You were calling for the npc to attack a client, but a client is not returned in a timer (does not check for client interaction!). So, you would have needed to add a $client = $npc->GetHateTop(); or something.
That still doesn't account for the other issue. Try this:
Code:
#Nightwhisker Fight
my $adds = undef;
sub EVENT_SPAWN { #Not really needed. Was for testing.
quest::stoptimer("rat_adds");
my $adds = 0;
}
sub EVENT_COMBAT {
if ($combat_state == 0) {
quest::depopall(2700659);
quest::depopall(2700660);
quest::depopall(2700661);
quest::stoptimer("rat_adds");
quest::stoptimer("rat_agro");
}
#Replaced event attack with:
if ($combat_state == 1) {
quest::stoptimer("rat_adds");
quest::shout("Rats of Dreadsire, I call upon you! Come to my aid!");
quest::settimer("rat_adds",10);
}
}
sub EVENT_TIMER {
if ($timer eq "rat_adds") {
quest::stoptimer("rat_adds");
#the big chunk of change
for($adds = 0; $adds < 10; $adds++) {
quest::spawn2(quest::ChooseRandom(2700659,2700660,2700661),0,0, $x, $y, $z, 0);
sethate();
}
quest::say("Come! Come! Rid these halls of the humaniods!");
$adds = 0;
quest::settimer("rat_adds",10); }
}
sub EVENT_DEATH {
$timestamp = localtime(time);
quest::depopall(2700659);
quest::depopall(2700660);
quest::depopall(2700661);
quest::stoptimer("rat_adds");
quest::shout2("SQUEEEEEEEK!");
quest::write("bossdeaths.txt","[$timestamp]:Nightwhisker was killed by $name the $class.");
}
#added routine to process ALL npcs.
sub sethate {
my $client = $npc->GetHateTop();
my $tiny_rats = $entity_list->GetMobByNpcTypeID(2700659);
my $albino_rats = $entity_list->GetMobByNpcTypeID(2700660);
my $black_rats = $entity_list->GetMobByNpcTypeID(2700661);
if ($tiny_rats) {
my $hate_tiny_rats = $tiny_rats->CastToNPC();
$hate_tiny_rats->AddToHateList($client, 1); }
if ($albino_rats) {
my $hate_albino_rats = $albino_rats->CastToNPC();
$hate_albino_rats->AddToHateList($client, 1); }
if ($black_rats) {
my $hate_black_rats = $black_rats->CastToNPC();
$hate_black_rats->AddToHateList($client, 1); }
}
Technically, it could still have a problem or two so you could consider using an array and processing a loop for each npcspawn. While it is *technically* possible to run into a problem, you won't run into the potential problem with this script. Let me know if it works for you!