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.
|
something like
Code:
foreach $ent ($npc->GetHateList()) { |
meh. try this instead. syntax got me.
Code:
foreach $ent (@{$npc->GetHateList()}) { |
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! |
|
or you could use GetHateRandom()
|
thanks! ;)
|
Code:
foreach $ent (@{$npc->GetHateList()}) { |
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. |
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.
|
I cant remember since its been forever since I last did that. Think you need to cast it to mob though: $ent->CastToMob()->GetID();
|
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. |
Code:
if ($hpevent == 90) Code:
@npcArray = $npc->GetHateList(); |
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. |
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. |
i just realized that it's likely because the npc's target is at the top of the hate list (the first entity in the array), and the loop you have is trying to get the npc to cast the spell on a new target while he's still casting on the first one.
you could attempt to address this by putting a delay (sleep($seconds)) equal to the cast time of the spell in the loop (you'd want to place it after the casting has begun). you could also check $npc->IsCasting() periodically to see if you needed to continue on to the next target. that way you wouldn't have a lengthy delay between casts if the cast was ever interrupted by the players. i'm not sure what sort of load that would cause on the server, however. DUH. or you could set the cast time to 0 in CastSpell()... i forgot that one. :) CastSpell(spell_id, target_id, slot= 10, casttime= -1, mana_cost= -1) |
The spell didn't have a cast time in the first place. I couldn't get it to work with npc->CastSpell, but for some reason, quest::castspell works perfectly.
|
in the source code, quest::castspell() calls Mob::SpellFinished() while $npc->CastSpell() calls Mob::CastSpell(). i haven't looked over the source to be able to tell you exactly what the difference is, nor do i know the benefits of using one instead of the other (except for the fact that only one is working for you).
|
looks like quest::castspell() skips a lot of the validation checks (movement, stun, combat, etc) and timers involved with spell casting. i'm going to have to guess that the problem with using $npc->CastSpell() is still timer related, since it hits one target when you use it. otherwise, clients would probably see interruption messages while in combat with the npc in question.
|
All times are GMT -4. The time now is 02:23 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.