EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Mob attacks everything on hate list (https://www.eqemulator.org/forums/showthread.php?t=35763)

Randymarsh9 09-16-2012 03:07 AM

Mob attacks everything on hate list
 
I'm trying to think of a way for a monster to attack everything on its hate list like the title of the post says. I don't want to have it cast a PBAE, but rather cast a single target spell on each one of the people it is fighting. Is there anyway to do this? Also, if that wouldn't work, is there a way to count how many people are on a monster's hate list and store it as a variable? That might work as well.

c0ncrete 09-16-2012 09:33 AM

something like

Code:

foreach $ent ($npc->GetHateList()) {
    $npc->CastSpell($spellID, $ent->GetID());
}

should work, triggered via a timer or hp event

c0ncrete 09-16-2012 11:40 AM

meh. try this instead. syntax got me.

Code:

foreach $ent (@{$npc->GetHateList()}) {
    $npc->CastSpell($spellID, $ent->GetID());
}


ChaosSlayerZ 09-16-2012 11:51 PM

I have a related question on this.
Same idea, but I would like npc to a pick a RANDOM person from his hate list.
How would it modify the code?

thanks!

Caryatis 09-17-2012 09:32 AM

Surprisingly people use perl for non eq related things, which makes searching for coding questions pretty easy

c0ncrete 09-17-2012 10:09 AM

or you could use GetHateRandom()

ChaosSlayerZ 09-18-2012 11:34 AM

thanks! ;)

Randymarsh9 09-18-2012 03:21 PM

Code:

foreach $ent (@{$npc->GetHateList()}) {
    $npc->CastSpell($spellID, $ent->GetID());
}

This code doesn't seem to work. Quest stops working after "foreach $ent (@{$npc->GetHateList()}) {"

Caryatis 09-18-2012 04:26 PM

Thats where alittle perl knowledge comes in handy...

@npcArray = $npc->GetHateList();
foreach $ent (@npcArray)
{
}

Having never used the syntax Concrete used, I can't comment on its correctness however the above works.

Randymarsh9 09-18-2012 07:11 PM

And now what would you use as the client ID in a cast spell command using that syntax? $ent->GetID() did not work as a target type.

Caryatis 09-18-2012 07:59 PM

I cant remember since its been forever since I last did that. Think you need to cast it to mob though: $ent->CastToMob()->GetID();

c0ncrete 09-18-2012 08:37 PM

it's what i get for second guessing myself. the data returned from GetHateList() doesn't need the be enclosed in @{} as it isn't a reference to an array. you might have to get the entity itself by using $ent->GetEnt()->GetID() or something of that nature first (see bottom of http://www.eqemulator.net/wiki/wikka...ListIterations for example). i wasn't at a computer with the emulator installed for testing and only had access to perl at the time of my posting(s), so i wrote a test class to emulate the $npc object.

as to creating an array for capturing the list of entities in the npc's hate list before iterating through them... i just have a habit of not storing returned values into individual variables if they're only going to be used once. it's just a preference. it should work either way, as long as you don't try to use the @{} as i did in my second post.

Randymarsh9 09-18-2012 09:56 PM

Code:

if ($hpevent == 90)
        {
                foreach $ent ($npc->GetHateList())
                {
                            $npc->CastSpell(6799, $ent->GetEnt()->GetID());
                }
                quest::setnexthpevent(80);

        }

This is my current code. It only casts the selected spell on the player that it is directly attacking though.

Code:

@npcArray = $npc->GetHateList();
                foreach $ent (@npcArray)
                {
                        $npc->CastSpell(6799, $ent->GetEnt()->GetID());
                }

Also just casts on the target.

c0ncrete 09-18-2012 10:30 PM

that's because both of those snippets do the same thing. the only difference is that you aren't storing the hate list returned into a array variable, you're just using it directly from GetHateList().

not sure why CastSpell() isn't landing on the target specified.

Randymarsh9 09-18-2012 10:57 PM

Interestingly, if I do something like having the monster shout a line saying the client's name and ID, it will do it for each person on the hate list, but the castspell will only affect the monster's target even if it is recognizing there are other people on its hate list.

Note:

quest::castspell(spellid, entid) works. It will cast a spell on every client on its list.


All times are GMT -4. The time now is 12:14 AM.

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