MZ Making Dynamic Rows based on Class Battle Core VisuStella

Good afternoon/evening all

I am using the attached script in Battle Core VS > Actor Battler Settings > JS: Home Position to determine where Party members are drawn in battle based on their Class.

Even number Class Ids = Front Row
Odd numbered Classes = Back Row

That was simple enough.

What I'm trying to do to elevate this script is to check what class the previous party member index is and if there is a space available behind or in front of the previous member, move the actor up when possible.

Currently, the script can only effectively check the current actor being drawn and the actor above to make any adjustments like so:

Row 3.png
Row 1.png


1st pic is all Even Class Ids, 2nd pic is a mix of Even, Odd, Even, Odd

Row 2.png


However in this section, we have Even, Even, Even, Odd.

What I would like is for that Odd-ball to move as high up as possible if there is a space available.



Any thoughts?


I set up some other constants that haven't been used in the script to check addition part member indices but haven't gotten them to work
I'd make a two-element array and track actors placed into each row.
JavaScript:
// Declare Constants
const sprite = this;
const actor = this._actor;
const index = arguments[0];
const classId = actor.multiclassId(2);

if (index==0)
    $gameParty.rows=[0, 0];

// Calculate X Position / Row Formation based on Class ID
let x, row;
if (classId % 2 === 0) { // Even class ID at Front Row
    x = Math.round((Graphics.width / 2) + 280);
    row = 0;
} else { // Odd class ID at Back Row
    x = Math.round((Graphics.width / 2) + 430);
    row = 1;
}
x += index * 15;

// Calculate Y Position
const spriteHeight = 128
// I'm having trouble following the intent with the two different places you reference the Graphics 
// height so...I'm just chopping all this. Change if necessary.

let y = (Graphics.height-250) - ($gameParty.maxBattleMembers()*48) - Math.floor((Graphics.height-Graphics.boxHeight)/2);
y += $gameParty.rows[row]*70;
$gameParty.rows[row]++;

// Set Home Position
this.setHome(x, y);
That did it!

Row4.png


this bit

const spriteHeight = 128

was a leftover from old code I forgot to remove

This

const frontRowY = (Graphics.height - 250) - ($gameParty.maxBattleMembers() * 48);

Was created because at one point there was a separate backRowY constant that worked alongside it. But I realize it wasn't useful so i took the backRowY variable out but was lazy and left in the frontRowY instead of reverting it to the
`let y = `

lol


Thank you a ton for this man!


Now to work on the functional aspects of this!
This thread is being closed due to being solved. If you need it reopened, report it to let us know why. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/making-dynamic-rows-based-on-class-battle-core-visustella.160709/