Combat: showing picture UNDER the battlers

Hi,

I'm wanting to overlay a graphic over a battleback... but I want it to be below the battlers (IOW, it needs to become part of the battleback). The index of a picture only seems to be the index between, err, pictures. Any thoughts?
It's because the background is added to the spriteset first, as part of the "lower layer". The picture container (containing all picture sprites) is added afterwards, in the "upper layer" phase. You can find more detail in rmmz_sprites.js: createLowerLayer of Spriteset_Battle and createUpperLayer of Spriteset_Base.

The easiest option would be to find an existing plugin that lets you set (battle) pictures to different display layers.

Alternatively, you could add your image in by patching an appropriate Spriteset_Battle method, e.g.
  • Patch createBattleback then add as a child sprite to _back2Sprite; or
  • Patch createBattleField then add as a child sprite to _battleField.

[Edit: corrected typo _backSprite2 -> _back2Sprite.]
This plugin by CT_Bolt lets you set pictures above a defined constructor but only works for pictures and won't work for animations

Sorry, you said UNDER. Well, I'll leave it up in case you need it later or someone wants to edit it
Sorry, you said UNDER.
Well, it's all a pile of sprites: under one is over the previous. Could try Sprite_Battleback, but there are two of those so you may end up with two images.
Thanks, it was getting a little too challenging for my 2MB RAM brain, so I found a workaround solution to the problem.

(half-joke but at least it functions as a placeholder until I become more resistant to coding sickness, plus has the added benefit of simulating raft endurance!)

1688805863189.png
@werzque - given your follow-up thread(s), I figure you might find a use for this:
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Show animated sprite on battlefield when in boat vehicle.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/159274/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
'use strict';

  /** Frames to display each cel before moving to the next. */
  const FRAME_TIME = 12;  // 12 => 5 fps anim @ 60 fps game loop

  /** Width per cel of boat sprite. */
  const FRAME_WIDTH = 144;  // file px

  /**
   * Filename for boat sprite, without extension.
   * From img/pictures. Horizontal frame sequence.
   */
  const BMP_NAME = "Actor1";

  /** Raft position on battlefield (centre anchor). */
  const POS = [600, 375];  // screen px

  // Patch - add boat sprite on create.
  void (alias => {
    Spriteset_Battle.prototype.createBattleField = function() {
      alias.apply(this, arguments);
      if (!$gamePlayer.isInBoat()) return;
      const s = this._boatSprite = new Sprite(ImageManager.loadPicture(BMP_NAME));
      s.anim = 0;
      s.anchor.set(0.5);
      s.position.set(...POS);
      s.bitmap.addLoadListener(
        bmp => s.setFrame(0, 0, FRAME_WIDTH, bmp.height), s.anim = 1
      );
      this._battleField.addChild(s);
    };
  })(Spriteset_Battle.prototype.createBattleField);

  // Patch - animate new sprite.
  void (alias => {
    Spriteset_Battle.prototype.update = function() {
      const s = this._boatSprite;
      if (s?.visible && !--s.anim) {
        let x = s._frame.x + FRAME_WIDTH;
        if (x > s.bitmap.width)
          x = 0;
        s.setFrame(x, 0, s._frame.width, s._frame.height);
        s.anim = FRAME_TIME;
      }
      alias.apply(this, arguments);
    };
  })(Spriteset_Battle.prototype.update);

})();
If not, no worries! 👋

(If you do want to use it, you'll probably want to change the values of BMP_NAME, FRAME_WIDTH, etc. I tested with a faceset.)
I figure you might find a use for this:
Spoiler: plugin code
undefined
Thanks! This actually looks very promising, but unfortunately the raft (or whatever picture) will be painted on top of the battlers. This might be caused by VS battle core, which seems to adjusts the graphic's z according to the y.
Ah, I see. You could try replacing _battleField with _back2Sprite to see if that helps? Might need to play around with the coordinates a bit, since the backdrops are tiling sprites.

Original thread: https://forums.rpgmakerweb.com/threads/combat-showing-picture-under-the-battlers.159063/