$npc->CastSpell Working on Target, Not Self
Evening gents, I've gone and broken something again!
I am experiencing a weird issue with CastSpell. If I use it to cast on a player, it works fine. If I use it on the npc that is casting (as in self buffing) it is always interrupted. A few previous posts I've found say to use $npc-GetID() for self targetting, but that just end in the script refusing to run certain parts. Enclosed are relevant portions of the script: This is the 'header' to the subroutine. Note @groupMembers is not listed here as it is filled in at the start of the fight on agro (which is relevant, but isn't broken). Code:
sub doDiscord Code:
Code:
elsif($randy > 625) The spell first referenced is unresistable npc mezz, second is incredibly strong Complete Heal v2. Code:
elsif($randy > 125) Spell referenced is a 25k x 5 (per cast) wizard nuke. Code:
elsif($randy < 50) -Hate |
Are these all under 1 sub? Is this the complete script just broken into chunks?
|
First off, that way of displaying your script makes its really hard to debug. Im not sure if you are worried about somebody stealing your script or something but its not conducive to helping those you want help from.
One issue I see is that the mobs ID is not its NPCTypeID. The ID given is unique to that session and is usually not very large. If you want to get an NPC by its TypeID then you need to use GetNPCList() and check with $ent->GetNPCTypeID(). However, I assume this is a secondary NPC(otherwise you would just use $npc->GetID() right?). Since this is not the npc you want casting the spell, you can still simulate that by using $entity_list->GetNPCByID(999173)->CastSpell(xxx); |
Well, right off the bat, I see quite a few issues with your script snippets. Part of the problem is that you broke the script up and didn't show the entire script, so it is really hard to tell you for sure where all of your issues are.
For one thing, if you want an NPC to be able to cast more than 1 spell at a time, you should use the following command: Code:
SpellFinished(spell_id, spell_target = this, mana_cost = 0) Another issue is you seem to be confused on the idea of entity IDs vs getting the actual mob itself. When using CastSpell(), it requires the entity ID, not the actual mob or NPC Type ID, which Caryatis already mentioned a bit. Code:
CastSpell(spell_id, target_id, slot= 10, casttime= -1, mana_cost= -1) Code:
my $NPC_ID = $npc->GetID(); You could then do this: Code:
$npc->CastSpell(11, $NPC_ID); Also, before you try to do something like this: Code:
$selfEntity->GetID() There are a few other issues I can guess you have in that script, but I can't say for sure without seeing the whole script. |
First: Trevius the Bad Ass, joligario and Caryatis...thank you for the replies!
Second: The script is cut into just this subroutine as it is the only relevant one. The rest is just a serious of dialog 'Hail', 'Tell me more', 'What artifact' and other such boring quotes. The only thing that really happens outside this subroutine is the mob engages after the last dialog trigger is hit. So there is nothing else to see. The subroutine itself is broken up because there are several sections of the if-else statement that do the same thing. Either casting 2-3 spells on a player (which work...) or 2-3 on itself (which fail...). I omitted several else 'blocks' as they just randomly cast on player (which even instant multiple castings works, just not on the mob itself due to targeting). Third: Lastly, I broke it up because adding inline comments to describe each individual block looked absolutely horrific. Apparently, I am alone in that view. Trevius, again I can't thank you enough for taking time out to write another long and insanely useful response. You truly are win, Sir! -Hate |
--Double Post--
Sorry, college internet is having massive issues atm |
Quote:
|
All times are GMT -4. The time now is 05:41 AM. |
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.