[RMMV] Yanfly Row Formation - Sharing the formulas for enemy position

Hi all,

It took me a while to figure this one out, thought I could share in case someone else is faced with same situation.

Basically, I wanted the plugin to reposition my battlers automatically on the battle screen. The formulas for the actors seem to be working just fine, but the formulas for the enemies are a mess.

Below is my code which allows to reposition the enemy battlers. My game only uses 3 rows, but I would assume this would work with any amount of rows (as long as you tweak the hard-coded 16, 32 and 64 values).

Parameters in YEP_RowFormation plugin:

At the top:

Code:
---Position Settings---
screenHeight - statusHeight - 16 - ((maxRows + 1) * 64)

At the very end:

Code:
---Enemy Rows---
Adjust Relative : true
Enemy Row X: 64 + $gameTroop.rowSize(maxRows) * 16 + (maxRows - rowId) * 112 - $gameTroop.rowSize(rowId) * 16 + rowIndex * 32
Enemy Row Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 32


In your troops, don't forget to set the row for each enemy, and set it to Turn 0 // Battle
Spoiler
0.png


End result is you get spaced rows, with enemies staggered.
Spoiler
1.png

2.png
3.png

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-yanfly-row-formation-sharing-the-formulas-for-enemy-position.122901/