Weapon Sprite Priority

So, I have my side-view battle system-and I have the YEP_WeaponAnimation plugin. Unfortunately, all my weapon sprites appear behind the characters, and after doing some research, it looks like this is the default. How can I change this? I want my weapon sprites to appear in front of the characters.
As this involves how a plugin works, it needs to be moved.
Moved to: Javascript/Plugin Support
Oh, this doesn't have anything to do with the plugin. It's the default setting for RPGmaker MV. I only mentioned the plugin in case that would affect any potential fixes.
But you need a plugin to change the default...
Oh, I see what you're saying. Sorry for the confusion! If anyone knows of a good plugin that can change this, please let me know.
I have a miny plugin for that in this thread: https://forums.rpgmakerweb.com/inde...lles-miscellaneous-javascript-snippets.80663/
I haven't tested it with Yanfly's Weapon Animation plugin, though, so let me know if you encounter any issues there.
Ah, ok! That seems to work on the player's party just fine! Now I just need to figure out how to get it to work on the enemy's weapons.

Thanks for the help!
Which plugin do you use to give your enemies weapons?
Which plugin do you use to give your enemies weapons?
YEP_X_AnimatedSVEnemies
http://yanfly.moe/2015/12/13/yep-44-animated-sideview-enemies/
This is untested, if there are any errors, please open the console with F8 and show a screenshot of the message there.
Save the following code in a .js file, add it as a plugin somewhere below Yanfly's and use the notetag <WeaponOverEnemy> on all enemies where you want the weapon to appear in front of the sprite.
Code:
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();
    if (this._enemy.enemy().meta.WeaponOverEnemy) {
        this.createMainSprite();
        this.createWeaponSprite();
    } else {
        this.createWeaponSprite();
        this.createMainSprite();
    }
    this.createStateSprite();
    this._effectTarget = this;
};
fixTest.png
Try this, please:
Code:
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.createSprites();
    this._effectTarget = this;
};

Sprite_Enemy.prototype.createSprites = function() {
    this.createShadowSprite();
    if (this._enemy && this._enemy.enemy().meta.WeaponOverEnemy) {
        this.createMainSprite();
        this.createWeaponSprite();
    } else {
        this.createWeaponSprite();
        this.createMainSprite();
    }
    this.createStateSprite();
};

var _Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler;
Sprite_Enemy.prototype.setBattler = function(battler) {
    _Sprite_Enemy_setBattler.call(this, battler);
    this._enemy = battler;
    this.createSprites();
    this.setHome(battler.screenX(), battler.screenY());
    this._stateIconSprite.setup(battler);
};
No error messages this time, but the enemy gun's still behind the enemy sprite.
I want to make sure I'm installing these correctly, too. I've been taking each of these and putting it in a new JS file and putting that in plugins, is that the right way to use them?
Yes, that is how you should install them. Just checking - you did put in the <WeaponOverEnemy> notetag in the enemy's notebox, right? Then I'll have to update a few things and do more extensive bughunting later. I just saw I missed one function where it should also be changed, but that should only have an impact if you have an enemy that transforms into another...

If you want the weapon to always appear behind the enemy, you could also just do this instead (no notetags):
Code:
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.createMainSprite();
    this.createWeaponSprite();
   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.createMainSprite();
     this.createWeaponSprite();
     this.createStateSprite();
     this._shadowSprite.opacity = 255;
     this._weaponSprite.opacity = 255;
     this._mainSprite.opacity = 255;
     this._stateSprite.opacity = 255;
   }
};
Ooh, I see the problem, I wasn't adding that notetag.
Ah well, for this project this last script will be more appropriate anyway.
Thanks so much for your help!
You're welcome! Glad it's working now!

Original thread: https://forums.rpgmakerweb.com/threads/weapon-sprite-priority.92441/