Replacing Images with an Actor's Side View Sprites (especifically, replacing images from MOG's BattleHud)

Howdy. This question might be either easy to solve or too complex, so I'll get to the point.

I'm using Moghunter's BattleHud plugin to customize battles. Although it is handy, I came across this issue where the HUD stays above the actors' side view sprites. Everything is a placeholder for now, but it looks like this:

thisiskindaanimage.png


The side view sprites are layers lower than the HUD, which screws over my idea of putting the side view sprites where the HUD's character sprites are. I was thinking of a way of upping some layers the side view sprites so the stay a layer above the HUD's background and below the caracter's meters, however, this ActorHud layout changes the Face sprites depending on how many members are in your team, so I can't put the side view sprites in an specific place if it's not going to line up everytime. My solution for this is finding a way to replace the Face sprites via editing the plugin's code so they'll show the side view actor sprites. I don't how much this is posible because I want to mantain all the side view animations (including one that makes an actor's sprite look different when it's said actor's turn) and the swipe animation the actor does when entering a battle or when performing and action. Don't know how much of this is possible, that's why I'm asking.

By the way, I don't know if it'll be easier to just move the side view sprites to the intended layer and make it so their position alligns to wherever its corresponding Face sprite is. In any case, some help will be grateful.
If you check the MOG code, it seems to add the battle hud to Scene_Battle
this.addChild(this._hudField);
//
this._hudField.addChild(this._battle_hud[i]);

In base code there's the spriteset for Scene_Battle
this.addChild(this._spriteset);
For spriteset
this.addChild(this._baseSprite);
this._baseSprite.addChild(this._battleField);
For actors
this._battleField.addChild(this._actorSprites[i]);

You can try changing where the stuff is added, but I don't know if it causes problems LOL. And depending on what's added first you might have to rearrange the arrays (or change the codes so that the stuff you want top is added later).
If you check the MOG code, it seems to add the battle hud to Scene_Battle
this.addChild(this._hudField);
//
this._hudField.addChild(this._battle_hud[i]);

In base code there's the spriteset for Scene_Battle
this.addChild(this._spriteset);
For spriteset
this.addChild(this._baseSprite);
this._baseSprite.addChild(this._battleField);
For actors
this._battleField.addChild(this._actorSprites[i]);

You can try changing where the stuff is added, but I don't know if it causes problems LOL. And depending on what's added first you might have to rearrange the arrays (or change the codes so that the stuff you want top is added later).

Okay, I tried to change the order in which the spriteset appears. Sometimes that made disappear either MOG's ActorHud sprites or the rest of the entire battle scene, but it usually made no changes in layer position even if I changed the order of the code. Also, just before this.addChild(this._hudField); there's this line of code, this._hudField.z, which may refer to the HUD's layer, but changing its value doesn't make any changes for me. I can't seem to change the side view sprites' layer, at least to put it above any sprite and HUD, because my plan of putting the side view sprites above the HUD background and below the HP meter and such seems impossible right now. So I'm scrapping this solution (although I'm forced to learn how to put sprites in the highest layer for another thing, but I'll catch to that later).

Let's see if I can make it work by making the Face sprite act as the side view sprite. In MOG's BattleHud plugin, this is how the Create Face code looks:

Battle_Hud.prototype.create_face = function() {
if (String(Moghunter.bhud_face_visible) != "true") {return};
this.removeChild(this._face);
if (!this._battler) {return};
this._face = new Sprite(ImageManager.loadBHud("Face_" + this._battler._actorId));
this._face.anchor.x = 0.5;
this._face.anchor.y = 0.5;
this._face_data = [0,0,false,false,false,-1];
this._face.ph = 0;
this._face.animation = [-1,0,0,0,0,0,0,0,0];
this._face.breathEffect = this._battler._bhud.faceBreath;
this._face.scaleY = 0;
if (String(Moghunter.bhud_face_shake) === "true") {this._face_data[2] = true}
if (String(Moghunter.bhud_face_animated) === "true") {this._face_data[4] = true}
this._battler._bhud_face_data = [0,0,0,1]
this.addChild(this._face);
};

Maybe I could try putting the side view sprite information in here? Or I can make it so the Face sprite IS the side view sprite, so instead of putting the side view sprite in said layer independently, it follows all of the Face sprite's position values while mantaining the side view traits (the animations for each of the actor's actions). Could something like that work?
Hmmm, but for example just like writing in the console (for all actors 0, 1, 2, 3):
SceneManager._scene._hudField.addChild(SceneManager._scene._spriteset._actorSprites[0])
seems to throw the sprite on top of the actor hud.

EDIT: Or at least the pic (haven't moved them around to check different elements)
Tried it myself and it works. It does stay on top of basically everything, so it might work for the other thing I want to place on top. However, the sprite stays also on top of the HP meter and other parameters and I still have to move manually to side view actor sprite, so it'll break if I add more party members and the HUD changes position. Would it be possible to make the parameters and its sprites independent from the whole HUD layout so I can put them above the whole BattleHud AND above the side view sprite? And could I make each actor's side view sprite have its home position matched with the Face sprite with the same actor ID?
You'll just have to rearrange them the way you want, and maybe add your own objects to hold stuff.
I think the order (of the stuff I posted above) is currently like (if you throw stuff in the same category it's drawn according to order of children)

1. Scene Battle
1.1 Spriteset Battle
1.1.1 Base Sprite
1.1.1.1 Battlefield
1.1.1.1.1 Actor Sprites
1.2 Hudfield
1.2.1 Battle Huds

(PS. Haven't really thought if there's some better way of achieving what you want.)
Okay, I think I might have a solution:

Since I didn't like the sprites of the meters that much, I'm just going to hide them and replace them with gauge sprites from SRD's HUD Maker which seem to stay always on top (as for the states, I can just place them above the side view sprites, next to each name, so it doesn't stack with the sprites). It's still messy, but it looks like this:

1768583551692.png


Now, the last step should be adjusting each independent sprite and HUD part (side view sprites and each gauge and text) so it matches the XY coordinates with the BattleHud changes depending of how many party members are there. I might be wrong, but the Set Hud Position part of BatlleHud's code is definitively related to how many members you have in your party:

Battle_Hud.prototype.set_hud_position = function() {
this._hud_size = [this._layout.bitmap.width,this._layout.bitmap.height];
this._members_max = $gameParty.battleMembers().length;
var ps = [Number(Moghunter.bhud_space_x) * this._hud_id,
Number(Moghunter.bhud_space_y) * this._hud_id];
if ($gameSystem._bhud_position[this._hud_id]) {
this._pos_x = $gameSystem._bhud_position[this._hud_id][0];
this._pos_y = $gameSystem._bhud_position[this._hud_id][1];
}
else {
if (Number($gameSystem._bhud_pos_mode) === 0) {
var spc = ((Graphics.boxWidth - 14) / this._members_max);
var px = (spc / 2) + (spc * this._hud_id);
this._pos_x = Moghunter.bhud_pos_x + px + ps[0];
this._pos_y = Moghunter.bhud_pos_y + ps[1];
}
else {
var py = (this._hud_size[1] + 5) * this._hud_id;
this._pos_x = Moghunter.bhud_pos_x + ps[0];
this._pos_y = Moghunter.bhud_pos_y + py + ps[1];
};
};
$gameTemp._bhud_position[this._hud_id] = [this._pos_x,this._pos_y];
};

Can I turn the X and Y base position that depends on party members into a variable, so the sprites and HUD from each actor start on the same coordinates as the BattleHud sprites of the same Actor ID? If it's possible, I could make it easily for side view sprites because I have a plugin to customize their position, I'd just need to add the variable, but what about SRD's HUD Maker gauges and parameters?
Well if you look at the last line you posted:
$gameTemp._bhud_position[this._hud_id] = [this._pos_x,this._pos_y];
I assume that's by index. So to get the coordinates of the huds, it's like (battler indexes start at 0):
X: $gameTemp._bhud_position[index][0];
Y: $gameTemp._bhud_position[index][1];
So you can use those, but that's assuming that the creation of that HUD happens before your battler sprites, so they can read that data. Same for HUD Maker. Anyway, you can also position the elements by feel, referencing $gameParty.battleMembers().length to get how many battlers you have. Haven't really used HUD Maker, so I forgot how you put the elements, but I guess just use conditionals.
Well, I'm back with some good and bad news:

I found this post about a Dynamic Party Positions script for VX Ace. Had to translate it to JavaScript and, due to my horrible coding skills, it's still messy and heavily based on constant Google searches, but it seems to place the side view sprites perfectly. I'll clean it and post the translation here someday soon.

As for the HUD Maker elements, I tried looking online for any answer but I haven't found anyone asking this same question. If I use the same variables and position data as the side view sprites, it should be fine, but I'm struggling to find a way to position a HUD element by using other plugins. So I made another post asking about this and let's see if anyone experienced in HUD Maker has an answer.

I'll be back with the translated plugin or if my issue is solved. Farewell.

Original thread: https://forums.rpgmakerweb.com/threads/replacing-images-with-an-actors-side-view-sprites-especifically-replacing-images-from-mogs-battlehud.181960/