MV Centering Battler Sprites With YEP Battle Engine Core

(I'm new to the forums and RMMV, please let me know if I'm doing anything wrong!)

I'm using a couple plugins for battle UI purposes, and one of my main focuses right now is getting damage popups to work with a frontview UI. I'm using Victor's Battle Status Window for the overall UI appearance, Victor's Damage Popups for the actual popups themselves, and I'm using Yanfly's Battle Engine Core with DreamX's VE Damage Popup Extension to make the popups appear over the battle status window. The way the plugins work, to the best of my knowledge, is that Yanfly's battle engine core turns on the battler sprites underneath the battle status window, and that's what anchors the damage popups. I got this to work nicely when the party is full, but I'm having problems making it look nice when the party doesn't have a full four members.

When the party has four members, the damage popups show over the correct portrait, as seen in this picture:

1738025365723.png


(Please don't mind the two empty portraits-those are still a work in progress, haha)

However, when the party has less than four members, the damage popups get skewed to the left:

1738025415058.png


I believe I know what the actual issue here is. YEP Battle Engine Core has a parameter in the frontview UI section that allows you to change where the battler sprites are positioned using a formula. I am not very good at math so I just tweaked the numbers in the formula until it looked nice, and so the battler sprites are positioned correctly from the left side of the screen under the battle status window. However, when there isn't four characters in the party, the battle status window portraits are centered, whereas the battler sprites are all positioned to the left side. I was hoping someone who is better at coding and/or math could help me figure out a positioning formula that would account for the centering thing when there's less than four party members!

If it helps at all, here's what the UI looks like when it's not mid-action:

1738025619162.png


And this is what my X-position formula currently is! Again, I just tweaked numbers in the formula until it looked good in-game, so if this is painful to look at for anyone who is good at math... my sincerest apologies.

Graphics.boxWidth / 10 + Graphics.boxWidth / 5 * index + 12

1738025721131.png
After spending almost 24 hours constantly thinking over my problem I stumbled upon a very basic realization: I was trying to do too much. It finally occurred to me that the portraits shift the same amount each time a character is removed or added, and I just needed to make the sprites shift that same amount as well-no need to devise any crazy new formula.

My numbers will be different than other peoples might be, of course, but I will do my best to explain my process with my calculations in case anyone else stumbles across this post and wants to replicate my solution!

The amount the portraits moved was about half of the portrait size; the width of my portraits + the window frame is approximately 168 pixels, so I needed to move the sprites over to the right 84 pixels for every missing party member. To achieve this, I tacked on the equation "+ 336 - (84 * partySize)" to the end of my positioning formula. At a full four character party, 84 * partySize is 336, making the whole section equal + 0, so the sprites don't move to the right at all. With a three character party, 84 * partySize is 252, making the section equal + 84, shifting all the sprites over to the right the desired amount. I'm sure you can extrapolate from there how it works for a two and one character party! For clarity's sake I'll paste my whole uninterrupted formula below:

Graphics.boxWidth / 10 + Graphics.boxWidth / 5 * index + 12 + 336 - (84 * partySize)

(And just a reminder that the first part of that formula was just me adjusting the constants in the default x positioning formula included in YEP Battle Engine Core, so anyone trying to adjust the positioning for themselves will wanna play around with those numbers!)

Sorry for the trouble of opening a forum post just to end up solving it myself haha, but I hope this can maybe help someone else in the future! ☺️

Original thread: https://forums.rpgmakerweb.com/threads/centering-battler-sprites-with-yep-battle-engine-core.175001/