(RMXP) Error on "Moonpearl"'s Battle system when fighting with dead party members?

Hello all, I really need help regarding Moonpearl's animated battlers script, it's just that:


when characters in my party are dead, and I fight alone (with 1 surviving party member) an error pops up when I try to target attack an enemy in a battle:


ThvyUac.png



I really am not very good at this, but what is causing the problem? thankyou so much for those who can answer 🙂  


I also wanted to thank @Shuya for being the one to have reported this error from my game! 🙂  


And here's the link to Moonpearl's scripts:


http://moonpearl-gm.blogspot.fr/2012/11/monnpearls-animated-battlers.html
Bump!! I really need help on this one x(( I just have no idea how scripting works in general! I've been looking for help regarding this problem anywhere, and it seems I had no luck.. 


also, I'm using other moonpearl scripts for my project, here's the order:


- SDK/Basic stuff
- MP Animated Battlers
- MP Balloon messages
- MP Animated costume menu system


here is my script file from my project:
https://www.mediafire.com/?gauahjb7nc2a5as


I would be very happy if anyone can help me regarding this! x((
Alright so... you're rewriting the battle scripts multiple times. Sometimes you're extending it, sometimes you're overwriting it. This is gonna much bug-hunting/troubleshooting very difficult. I know you're probably just following the script writer's instructions but I would urge you to get a scripter for your project to help organize and simplify things.


I believe the problem is in "Scene_Battle" underneath "MP Animated Battlers". Note there's another "Scene_Battle" underneath "MP Scene Base" which is why I have to specify and relates back to my first comment about rewriting multiple times.

Spoiler
104 alias mp_abattlers_update_phase4_step2 update_phase4_step2
105 def update_phase4_step2
106 mp_abattlers_update_phase4_step2
107 # Raise damaged flag
108 for target in @target_battlers
109 if target.damage.is_a?(Fixnum)
110 if target.damage > 0
111 target.damaged = true
112 next
113 end
114 end
115 target.damaged = false
116 end

Line 108 is "for target in @target_battlers". For some reason, when there's only a single party member, @target_battlers isn't getting created properly. It's supposed to be created above in Line 106. I tried tracing where that goes, but again there's so much rewriting going on that I can't find the issue. Now, what I can do is offer you a band-aid. It should fix this particular issue but there's likely a deeper underlying issue that needs fixed. Again, why you should look at getting a scripter to help you out.


Anyways, change the code to this:

Spoiler
104 alias mp_abattlers_update_phase4_step2 update_phase4_step2
105 def update_phase4_step2
106 mp_abattlers_update_phase4_step2
107 # Raise damaged flag
@target_battlers ||= [] # <=============== This is what you should add
108 for target in @target_battlers
109 if target.damage.is_a?(Fixnum)
110 if target.damage > 0
111 target.damaged = true
112 next
113 end
114 end
115 target.damaged = false
116 end

 This should either fix the issue, or you'll get a different error message when battling with a single actor. 

Original thread: https://forums.rpgmakerweb.com/threads/rmxp-error-on-moonpearl-s-battle-system-when-fighting-with-dead-party-members.61466/