MZ Enemy Row Formation (Save Me.)

I'm back at it with another Row Formation situation, but this time? FOR ENEMIES!

Has anyone had any luck altering enemy Position in battle beyond the troop database?

What I'm looking to do is run a <Once Parallel When Start Battle> via Battle Core
to change enemy position based on note tag.

<melee> in row 0
<range> in row 1
<boss> in row 2

no note tag in row 0

I've tried modifying my existing Actor Row Formation to work but its not catching.

Spoiler: Enemy Row Formation
// Declare Constants const sprite = this; const enemy = this._battler; const index = arguments[0]; // Declare Variables const target = arguments[0]; let goalX = 0; let goalY = 0; // Check for note tags let row; if (enemy.enemy().meta.melee) { row = 0; // Melee tag found, place in the front row } else if (enemy.enemy().meta.ranged) { row = 1; // Ranged tag found, place in the back row } else { // If no specific tag is found, you can set a default row here row = 0; // Default to front row } // Calculate X Position / Row Formation let x; if (row === 0) { // Front Row - Melee Enemies x = Math.round((Graphics.width / 2) + 275); } else { // Back Row - Ranged Enemies x = Math.round((Graphics.width / 2) + 430); } x += index * 15; // Calculate Y Position let y = (Graphics.height - 220) - ($gameTroop.members().length * 48) - Math.floor((Graphics.height - Graphics.boxHeight) / 2); y += $gameTroop.rows[row] * 70; $gameTroop.rows[row]++; // Set Home Position this.setHome(x, y); // Set goalX and goalY goalX = x; goalY = y;
Well, for one thing, under Calculate Y, you're referencing this $gameTroop.rows[] array that doesn't exist.

You never declared it anyplace and you never put any values into it. So when you say
Code:
y += $gameTroop.rows[row] * 70
that results in 0 because of math with undefined.
Code:
y += $gameTroop.rows[row] * 70
that results in 0 because of math with undefined.
there was an iteration of this I had that actually did have it exist properly. Idk when i removed it but I went ahead and through a

if (index == 0){ $gameTroop.rows = [0, 0]; }

after declaring variables now. The issue I'm running into more consistently though is I get the error:

Cannot read property 'enemy' of undefined


I think I have to call out $gameTroop.members() first to have this working the way I want to. then hook that into enemy?
Well, where is this code going?

You have at the top that enemy = this._battler but how are you running this code such that it's being applied to enemies at all?
A lot of this is a shot in the dark @ATT_Turan , I'm hardly an expert coder when it comes to RPGM, let alone JS.

I tried to alter the the script you helped me with for party row formation a week or so ago, to fit this need. I'm using trying to use Battle Cores
1694528697656.png
to get this to work. But since its defining home positions, that makes me think its meant solely for actors
That little picture of a caption doesn't tell me much, but it appears to be an Action Sequence command, which would happen inside a skill. I don't see how that would apply to setting up a formation at the start of battle.

By default, enemy positions are set individually using the locations you defined in the troop screen of the editor (inside Sprite_Enemy.setBattler() ). You'd have to backtrack to the function that initializes all of the enemy sprites and adjust their home coordinates there. I don't know what that is off the top of my head.
By default, enemy positions are set individually using the locations you defined in the troop screen of the editor (inside Sprite_Enemy.setBattler() ). You'd have to backtrack to the function that initializes all of the enemy sprites and adjust their home coordinates there.
Ill look into this and do some digging. Thank you for giving me a sense of direction
Back tracked a bit realizing (thanks to Trihan) that I was focusing on sprites vs the enemy index itself. So to be more in line with the Change Home to JS Coordinates plugin command I altered to :

Spoiler: Updated Enemy Row Stuff
// Declare Variables const target = arguments[0] const enemy = $gameTroop.members()[target] if (target == 0) { $gameTroop.rows = [0, 0, 0]; } // Calculations let goalX, row; if (enemy.enemy().meta.melee) { goalX = Math.round((Graphics.width / 2) - 275); row = 0; } else if (enemy.enemy().meta.range) { goalX = Math.round((Graphics.width / 2) - 450); row = 1; } else if (enemy.enemy().meta.boss) { goalX = Math.round((Graphics.width / 2) + 450); row = 2; } else { goalX = Math.round((Graphics.width / 2) - 275); row = 0; } goalX -= target * 40; let goalY = (Graphics.height - 220) - ($gameTroop.members().length * 48) - Math.floor((Graphics.height - Graphics.boxHeight) / 2); goalY += $gameTroop.rows[row] * 70; $gameTroop.rows[row]++; // Return Data return new Point(goalX, goalY);

However its having trouble pulling up the actual note from the enemies. Any thoughts?
Here is the one you asked about.. didnt know you had one u wanted to go with instead.. https://naoso.itch.io/naoso-enemyposition

Re: notetag..
When pulling notetag, you need to grab the data from $dataEnemies.. you may be looking at troop enemy data?
At least when I looked into it for u, that's what I did.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/enemy-row-formation-save-me.161118/