I realised today that for some reason enemies with SV battler generated by YEP_X_AnimatedSVEnemies for some reason have their sprites duplicated (and they keep adding up when transforming).
It doesn't prevent the plugin from working mostly as intended (although I would assume it isn't helping in the performance department). However due to this duplication, the states icons (Sprite_StateIcon) who should be above the base sprite thanks to this code in YEP_X_VisualStateFX.js appear actually below since a second set of sprite is added above it.
Rather than changing priorities, it seems smarter to prevent the sv ennemis from duplicating their sprite to begin with. They are caused by those two next functions there:
All the creation functions add a new child to the list. initSVSprites is called twice at the initialisation (in both initMembers and setBattler), hence why there is duplication even without doing a transformation.
I was thinking to simply add a simple "if sprite exist return" to the ennemy version of createShadowSprite, createWeaponSprite, createMainSprite and createStateSprite. For example:
Is there something in my analysis that seems off to you?
Like, may be there is a genuine reason why this plugin adds extra sprites?
It doesn't prevent the plugin from working mostly as intended (although I would assume it isn't helping in the performance department). However due to this duplication, the states icons (Sprite_StateIcon) who should be above the base sprite thanks to this code in YEP_X_VisualStateFX.js appear actually below since a second set of sprite is added above it.
JavaScript:
Sprite_Battler.prototype.initChildStateSprites = function(overlay, icon) {
if (this._stateSprite) {
this.removeChild(this._stateSprite);
}
if (this._stateIconSprite) {
this.removeChild(this._stateIconSprite);
}
if (overlay) {
if (!this._stateSprite) {
this._stateSprite = new Sprite_StateOverlay();
}
if (this._mainSprite) {
var index = this.getChildIndex(this._mainSprite);
this.addChildAt(this._stateSprite, index + 1);
} else {
this.addChild(this._stateSprite);
}
}
if (icon) {
if (!this._stateIconSprite) {
this._stateIconSprite = new Sprite_StateIcon();
}
if (this._mainSprite) {
var index = this.getChildIndex(this._mainSprite);
this.addChildAt(this._stateIconSprite, index + 1);
} else {
this.addChild(this._stateIconSprite);
}
}
};
Rather than changing priorities, it seems smarter to prevent the sv ennemis from duplicating their sprite to begin with. They are caused by those two next functions there:
JavaScript:
Sprite_Enemy.prototype.initSVSprites = function() {
this._svRand = Math.random() * 10000;
this._svBattlerName = '';
this._motion = null;
this._motionCount = 0;
this._pattern = 0;
this._svBattlerEnabled = false;
this.createShadowSprite();
this.createWeaponSprite();
this.createMainSprite();
this.createStateSprite();
this._effectTarget = this;
};
Sprite_Enemy.prototype.setTransform = function(battler) {
this._shadowSprite.opacity = 0;
this._weaponSprite.opacity = 0;
this._mainSprite.opacity = 0;
this._stateSprite.opacity = 0;
if (battler.svBattlerName()) {
this.createShadowSprite();
this.createWeaponSprite();
this.createMainSprite();
this.createStateSprite();
this._shadowSprite.opacity = 255;
this._weaponSprite.opacity = 255;
this._mainSprite.opacity = 255;
this._stateSprite.opacity = 255;
}
};
Yanfly.SVE.Sprite_Enemy_initMembers = Sprite_Enemy.prototype.initMembers;
Sprite_Enemy.prototype.initMembers = function() {
Yanfly.SVE.Sprite_Enemy_initMembers.call(this);
this._battlerName = null;
this.initSVSprites();
};
Yanfly.SVE.Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler;
Sprite_Enemy.prototype.setBattler = function(battler) {
this._svBattlerEnabled = false;
this.initSVSprites();
Yanfly.SVE.Sprite_Enemy_setBattler.call(this, battler);
this.setSVBattler(battler);
};
All the creation functions add a new child to the list. initSVSprites is called twice at the initialisation (in both initMembers and setBattler), hence why there is duplication even without doing a transformation.
I was thinking to simply add a simple "if sprite exist return" to the ennemy version of createShadowSprite, createWeaponSprite, createMainSprite and createStateSprite. For example:
JavaScript:
Sprite_Enemy.prototype.createMainSprite = function() {
// NEW
if (this._mainSprite) return;
//
Sprite_Actor.prototype.createMainSprite.call(this);
};
Is there something in my analysis that seems off to you?
Like, may be there is a genuine reason why this plugin adds extra sprites?