cji3bp62000 / hello-world

hello world!!
12 stars 6 forks source link

[FilterController.js] Effect targeting for case 4 (all characters/events) results in battle errors that break the game #2

Open adachis opened 5 years ago

adachis commented 5 years ago

Problem When targeting case 4 (all characters/events) with a Pixi effect (e.g. <Filter:rgbsplitter,rgbsplit,1>) and a battle begins the game will stop on an error because it's looking for targets to apply the effect to and case 4 doesn't have any logic for dealing with the different sprite classes (only the map sprites). Because there are no targets to read during a battle, targets gets set to undefined and, because there is no length property in undefined, the foreach loop set to run on Map throws the error since it can't run on an array with an undefined length.

Solution While there's definitely a more beneficial solution that could retain the effect and apply it to all battle sprites instead, the quickest and easiest way to fix this issue is to just test if this._spriteset._characterSprites is defined or not. If it's defined, then the code can set the targets as usual. If not, then it just doesn't do anything and the error doesn't occur because no targets are present.

There's definitely a better, more comprehensive solution but my goal was just to stop the error from occurring. You know your code better so you could probably resolve this the proper way more easily than I can. :) Anyway, I just wanted to let you know about the bug and help out a bit. You made a great script that saved me hours and hours of work, so I really appreciate it!

P.S. Here's the small adjustment I made in the code because sometime's that's easier to understand code than an explanation. :)

case 4:
                if(!!this._spriteset) {
                    if (this._spriteset._characterSprites != undefined)
                    {
                        targets = this._spriteset._characterSprites; // special
                    }