Attack continues after enemy has been killed

I have just noticed this problem.

An enemy has an all party physical attack.  An ally has a counter attack.  When the enemy hits this particular ally the counter attack occurs and may kill the enemy.  The death pop up occurs, the sprite disappears, but the attack continues on down the line of allies even though there is now no enemy visible to do it.  A true strike from beyond the grave.  To say that it looks ridiculous is something of an understatement.

Does anyone know how to prevent this happening?  

Thanks.
Well, you can add a check on the apply part for targets to check if the caster is still alive... though IMHO, it depends on the ability... coz like if it's a breath attack for example, then it makes sense that the breath already hit the whole party anyways... if it's a 1 time slash, it makes sense too... but if it's like 1 slash per target, then yeah that would look ridiculous...

anyway try this:

Code:
class Scene_Battle  def use_item    item = @subject.current_action.item    @log_window.display_use_item(@subject, item)    @subject.use_item(item)    refresh_status    targets = @subject.current_action.make_targets.compact    show_animation(targets, item.animation_id)    targets.each {|target| item.repeats.times { invoke_item(target, item) if @subject.alive? } }  endend
yes, one slash per target - not only does it look ridiculous, but it also continues to deal damage to the actors - which rather negates the purpose of killing the enemy!

I've put in your snippet, though it will be difficult to test, as the chances of this particular situation occurring are, obviously, small, which is why I've only noticed it now.
you can try to make a sample troop and situation to force it I guess
Yes, I thought of that, but the chances of the enemy being killed by a counter attack part way through their attack are pretty small, no matter how it's set up.  I must have played hundreds, possibly thousands, of battles in play testing, and this is the first time I've seen it happen.
even if you make the counter deal so much damage and has 100% to proc?
Could try that.  Will have to wait until this evening when I get home from work.

Thanks for your input.
I've tried this, and despite many battles, I haven't yet succeeded in replicating the exact circumstances.

However, sadly, I already know that the snippet has a rather unfortunate drawback - it makes every animation (party and enemy skills) play twice.  I therefore can't use it even if it also did what I was looking for.
It shouldn't because I'm not altering the animations part, only the part where the damage will be dealt


so now that I think of it, I think we also need to edit the show animation part, though looking at that, it seems like animations are done before even iterating the invoke_item so I don't know if the counter will already be taking place at that time
ksjp17 you should now this by now not to double post, but to edit your previous post.

Original thread: https://forums.rpgmakerweb.com/threads/attack-continues-after-enemy-has-been-killed.25843/