Hime-Works / Requests

Bug reports and requests that may require longer discussions and is not suitable to leave on the blog
http://himeworks.com/
GNU General Public License v2.0
7 stars 9 forks source link

Target Any Scope crashes when an escape fails under certian conditions) #379

Open weso12 opened 3 years ago

weso12 commented 3 years ago

To replicate the issue here's what I did

  1. Create a New Project
  2. Install the Hime Target Any scope plugin (and nothing else)
  3. Give the attack command ""
  4. Give the goblins 999 speed to ensure an escape fails
  5. Initiate a battle with said goblins (make sure escape is possible)
  6. Attempt to escape
  7. See crash (line 154) Reading the source code and testing the console (I have mild programing knowledge but enough to know how to fix it) it seems that what happens is that the battler variable in this context will attempt to index an array when the _targetIndex is at -1 which creates undefined array.
HimeWorks commented 3 years ago

Thanks for the report. I looked at the issue and found that the problem is related to "random" targeting in general.

When I wrote the plugin I had intended it to be used for skills where you would select a target and hadn't considered what happens if the skill picks a random target.

So for example you pick an ally, and then if the ally is dead, it would apply the skill to another ally. And if you pick an opponent, it would apply the skill to another opponent. This is to match the default targeting behavior.

Problem is, for random targeting, this logic doesn't work, because we don't actually have a specific target at this point (an actor or an enemy). How "any" target should be determined is open to interpretation at this point. Would it randomly decide to attack allies or opponents, and then from the selected team, pick one random target?

The issue could be fixed if a specific team were to be determined for a random target, but I'm not sure what would be the best way to do it.