Strange Game_Enemy#actions iteration bug
#1
Script's Purpose

The script I'm writing is supposed to prevent enemies from using pointless state-only skills that don't have a damage factor, also supposed to prevent enemies from random targeting actors whom the skill would be useless on, etc.

Symptoms

Iteration bug: With the method Game_Enemy#actions, I run an iteration that is supposed to filter all actions, check which is a skill, check if skill has power 0, check if skill has valid +/- state sets, then remove skill if conditions are all met and the action is pointless against the offending party. The problem sort of defies logic, and I have no other meddling scripts to cause this glitch.

I can print the default method, which returns all RPG::Enemy::Action objects just fine.

Right after that, I iterate through the script with actions.each {|action| ...}, but for some reason there are certain actions that get skipped. From the tests I ran, it appears that it only skips state-skills which target all (ie, Mass Venom) while at the same time others are successfully iterated through (ie, Mass Fire).

Target Random bug: The script is set up to fix random targeting methods so that a pointless state-skill won't be used on somebody whom the skill would be pointless on. It does have a DBS limitation I'm not really worried about (the same actor might be targeted during the same turn even though an enemy who acted before it inflicted actor with [state].) The one thing that is bugging me though is once in awhile, on a new turn, enemies might target an actor with a pointless state-only skill, I'm not sure where I slipped up.

Demo

I've got a ton of scripts on this, so I've isolated the problem script to its own demo.

http://www.mediafire.com/?g2x031be8g8z3w4

You can go into the script itself to set testing = true/false, which will give you a printout of whats going on behind the scenes.
[Image: Button-BOTB.png]
[Image: Save-Point.gif][Image: Button-You-Tube2.png][Image: Button-Sound-Cloud2.png][Image: Button-Audio-Mack2.png]
[Image: LS-Banner.gif]
NEW ALBUM OUT NOW!

Reply }
#2
downloaded, will start testing asap
[Image: facebook_icon.png] [Image: youtube_128x128-120x120.png] [Image: deviant.png] [Image: save-point.png]
Reply }
#3
Ok, i think that the each iterator is not happy when you delete items in the array it is iterating through.
Let's say the array is A. I usually create a temp array B, where I put the objects I determine have to be deleted. At the end of the iteration on A, I run an iteration on B and delete the objects in it from A.
[Image: facebook_icon.png] [Image: youtube_128x128-120x120.png] [Image: deviant.png] [Image: save-point.png]
Reply }
#4
With your help I was able to fix the main bug in my script, thank you Charlie!

Bugfix #1

I haven't had time to test it yet, but this might've solved the 2nd bug. Anyways, thank you for your help.
[Image: Button-BOTB.png]
[Image: Save-Point.gif][Image: Button-You-Tube2.png][Image: Button-Sound-Cloud2.png][Image: Button-Audio-Mack2.png]
[Image: LS-Banner.gif]
NEW ALBUM OUT NOW!

Reply }
#5
I'm glad I could help. :)
[Image: facebook_icon.png] [Image: youtube_128x128-120x120.png] [Image: deviant.png] [Image: save-point.png]
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Strange behavior RGSS Charlie Fleed 10 16,823 03-15-2009, 04:11 PM
Last Post: woratana



Users browsing this thread: 1 Guest(s)