EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Can anyone help me with this script (calling npcs in to attack player) (https://www.eqemulator.org/forums/showthread.php?t=33467)

Astal 05-05-2011 05:41 AM

Can anyone help me with this script (calling npcs in to attack player)
 
It doesnt call all of the NPCs of with the ID in $NPCToRespond, sometimes it will call 3 sometimes 7. Its random also, it doesnt call the same ones each time.

Im not sure whats going on with it.


Code:

sub EVENT_HP {

        if ($hpevent == 90) { #call the odel tal demons
                quest::shout("Destroy The Humans!!");
                quest::setnexthpevent(80);
                my $NPCToRespond = 2700235; # NPCID to call in to assist 146337
                my @hatelist = $npc->GetHateList();        # Get the NPC's current Hate List
                my $HateCount = @hatelist;        # Total mobs on the NPC's hate list
                my @npclist = $entity_list->GetNPCList();        # Get the full NPC list for the zone
                foreach $ent (@npclist)
                {
                        if($ent->GetNPCTypeID() == $NPCToRespond)        # Verify that the current NPC being checked is the NPCID we want
                        {
                                my $RandomHateNum = plugin::RandomRange(0, $HateCount);        # Choose a random mob in the Hate List array
                                my $RandomHateEnt = $hatelist[$RandomHateNum];        # Get the Hate list entry for the selected number of the array
                                if ($RandomHateEnt && $RandomHateEnt->GetEnt())        # Verify that the hate entry exists and that we can get the entity
                                {
                                        my $HateEnt = $RandomHateEnt->GetEnt();        # Get the hated entity
                                        $ent->AddToHateList($HateEnt, 1);        # Tell the current NPC to attack the random mob on the boss' hate list.
                                }
                        }
                }
        }
       
        elsif ($hpevent == 80) { #call illryia minions 1
                quest::shout("Attack You Lazy Maggots!!");
                quest::setnexthpevent(70);
                my $NPCToRespond = 2700234; # NPCID to call in to assist 146337
                my @hatelist = $npc->GetHateList();        # Get the NPC's current Hate List
                my $HateCount = @hatelist;        # Total mobs on the NPC's hate list
                my @npclist = $entity_list->GetNPCList();        # Get the full NPC list for the zone
                foreach $ent (@npclist)
                {
                        if($ent->GetNPCTypeID() == $NPCToRespond)        # Verify that the current NPC being checked is the NPCID we want
                        {
                                my $RandomHateNum = plugin::RandomRange(0, $HateCount);        # Choose a random mob in the Hate List array
                                my $RandomHateEnt = $hatelist[$RandomHateNum];        # Get the Hate list entry for the selected number of the array
                                if ($RandomHateEnt && $RandomHateEnt->GetEnt())        # Verify that the hate entry exists and that we can get the entity
                                {
                                        my $HateEnt = $RandomHateEnt->GetEnt();        # Get the hated entity
                                        $ent->AddToHateList($HateEnt, 1);        # Tell the current NPC to attack the random mob on the boss' hate list.
                                }
                        }
                }
        }
       
        elsif ($hpevent == 70) {
                quest::shout("Dont Just Sit There....HELP ME!!");
                quest::setnexthpevent(60);
                my $NPCToRespond = 2700239; # NPCID to call in to assist 146337
                my @hatelist = $npc->GetHateList();        # Get the NPC's current Hate List
                my $HateCount = @hatelist;        # Total mobs on the NPC's hate list
                my @npclist = $entity_list->GetNPCList();        # Get the full NPC list for the zone
                foreach $ent (@npclist)
                {
                        if($ent->GetNPCTypeID() == $NPCToRespond)        # Verify that the current NPC being checked is the NPCID we want
                        {
                                my $RandomHateNum = plugin::RandomRange(0, $HateCount);        # Choose a random mob in the Hate List array
                                my $RandomHateEnt = $hatelist[$RandomHateNum];        # Get the Hate list entry for the selected number of the array
                                if ($RandomHateEnt && $RandomHateEnt->GetEnt())        # Verify that the hate entry exists and that we can get the entity
                                {
                                        my $HateEnt = $RandomHateEnt->GetEnt();        # Get the hated entity
                                        $ent->AddToHateList($HateEnt, 1);        # Tell the current NPC to attack the random mob on the boss' hate list.
                                }
                        }
                }
        }
       
        elsif ($hpevent == 60) {
                quest::shout("Are You Demons or PUSSIES!!??");
                quest::setnexthpevent(50);
                my $NPCToRespond = 2700244; # NPCID to call in to assist 146337
                my @hatelist = $npc->GetHateList();        # Get the NPC's current Hate List
                my $HateCount = @hatelist;        # Total mobs on the NPC's hate list
                my @npclist = $entity_list->GetNPCList();        # Get the full NPC list for the zone
                foreach $ent (@npclist)
                {
                        if($ent->GetNPCTypeID() == $NPCToRespond)        # Verify that the current NPC being checked is the NPCID we want
                        {
                                my $RandomHateNum = plugin::RandomRange(0, $HateCount);        # Choose a random mob in the Hate List array
                                my $RandomHateEnt = $hatelist[$RandomHateNum];        # Get the Hate list entry for the selected number of the array
                                if ($RandomHateEnt && $RandomHateEnt->GetEnt())        # Verify that the hate entry exists and that we can get the entity
                                {
                                        my $HateEnt = $RandomHateEnt->GetEnt();        # Get the hated entity
                                        $ent->AddToHateList($HateEnt, 1);        # Tell the current NPC to attack the random mob on the boss' hate list.
                                }
                        }
                }
        }

        elsif ($hpevent == 50) {
                quest::shout("Time For A MOSH PIT!!!");
                quest::setnexthpevent(40);
                my $NPCToRespond = 2700240; # NPCID to call in to assist 146337
                my @hatelist = $npc->GetHateList();        # Get the NPC's current Hate List
                my $HateCount = @hatelist;        # Total mobs on the NPC's hate list
                my @npclist = $entity_list->GetNPCList();        # Get the full NPC list for the zone
                foreach $ent (@npclist)
                {
                        if($ent->GetNPCTypeID() == $NPCToRespond)        # Verify that the current NPC being checked is the NPCID we want
                        {
                                my $RandomHateNum = plugin::RandomRange(0, $HateCount);        # Choose a random mob in the Hate List array
                                my $RandomHateEnt = $hatelist[$RandomHateNum];        # Get the Hate list entry for the selected number of the array
                                if ($RandomHateEnt && $RandomHateEnt->GetEnt())        # Verify that the hate entry exists and that we can get the entity
                                {
                                        my $HateEnt = $RandomHateEnt->GetEnt();        # Get the hated entity
                                        $ent->AddToHateList($HateEnt, 1);        # Tell the current NPC to attack the random mob on the boss' hate list.
                                }
                        }
                }
        }
       
        elsif ($hpevent == 40) {
                quest::shout("The Drugs Arent Working I Still Feel The Pain!");
                quest::setnexthpevent(30);
                my $NPCToRespond = 2700241; # NPCID to call in to assist 146337
                my @hatelist = $npc->GetHateList();        # Get the NPC's current Hate List
                my $HateCount = @hatelist;        # Total mobs on the NPC's hate list
                my @npclist = $entity_list->GetNPCList();        # Get the full NPC list for the zone
                foreach $ent (@npclist)
                {
                        if($ent->GetNPCTypeID() == $NPCToRespond)        # Verify that the current NPC being checked is the NPCID we want
                        {
                                my $RandomHateNum = plugin::RandomRange(0, $HateCount);        # Choose a random mob in the Hate List array
                                my $RandomHateEnt = $hatelist[$RandomHateNum];        # Get the Hate list entry for the selected number of the array
                                if ($RandomHateEnt && $RandomHateEnt->GetEnt())        # Verify that the hate entry exists and that we can get the entity
                                {
                                        my $HateEnt = $RandomHateEnt->GetEnt();        # Get the hated entity
                                        $ent->AddToHateList($HateEnt, 1);        # Tell the current NPC to attack the random mob on the boss' hate list.
                                }
                        }
                }
        }

        elsif ($hpevent == 30) {
                quest::shout("Unleash Hell My Brethren!!");
                my $NPCToRespond = 2700242; # NPCID to call in to assist 146337
                my @hatelist = $npc->GetHateList();        # Get the NPC's current Hate List
                my $HateCount = @hatelist;        # Total mobs on the NPC's hate list
                my @npclist = $entity_list->GetNPCList();        # Get the full NPC list for the zone
                foreach $ent (@npclist)
                {
                        if($ent->GetNPCTypeID() == $NPCToRespond)        # Verify that the current NPC being checked is the NPCID we want
                        {
                                my $RandomHateNum = plugin::RandomRange(0, $HateCount);        # Choose a random mob in the Hate List array
                                my $RandomHateEnt = $hatelist[$RandomHateNum];        # Get the Hate list entry for the selected number of the array
                                if ($RandomHateEnt && $RandomHateEnt->GetEnt())        # Verify that the hate entry exists and that we can get the entity
                                {
                                        my $HateEnt = $RandomHateEnt->GetEnt();        # Get the hated entity
                                        $ent->AddToHateList($HateEnt, 1);        # Tell the current NPC to attack the random mob on the boss' hate list.
                                }
                        }
                }
        }

}


joligario 05-05-2011 07:06 AM

Just a cursory glance.

I noticed your NPCID is really high. Is that definitely the correct NPCID?

When selecting a random NPC, you go from 0 to $HateCount. You probably want $HateCount -1.

Astal 05-05-2011 07:34 AM

Quote:

Originally Posted by joligario (Post 199404)
Just a cursory glance.

I noticed your NPCID is really high. Is that definitely the correct NPCID?

When selecting a random NPC, you go from 0 to $HateCount. You probably want $HateCount -1.

yeah its the right npcid, thats what it set it to when i created em for some reason /shrug


Awesome that works man, thanks


All times are GMT -4. The time now is 02:52 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.