How to add more Battle Party Members and Make them stand in row and columns

Q) How to add more Battle Party Members and Make them stand in row and columns.
A) I have seen many of the people don't know coding and they want to add more party member rather than just 4 in
Battle party and also want that all member don't stand in same line.
I make a small code in Visustella battle core plugin so you guys can use it too.

I have explain every thing in video please check it full then. Just copy paste the code and use it in game as, I told in Video.

T-1.png


Please this video how to do this thing.



Code :

Add more party member in team just type this code in your script :


Game_Party.prototype.maxBattleMembers = function() {

return 4;

};

Change the number 4 to the how many member you want in your party ok.


Code : to make all members not stand in same line
you must have visustella free plugin core and battle core.

open the battle core plugin => Actor Battle Setting => Home Position

just change the code given below what shown in video


// Declare Constants

const sprite = this;

const actor = this._actor;

const index = arguments[0];

const members = $gameParty.battleMembers().length;

let x;

let y;

// Make Calculations

if(members == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12)
{
if(index == 0){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 480);}
if(index == 1){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 410);}
if(index == 2){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 340);}
if(index == 3){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 270);}

if(index == 4){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 480);}
if(index == 5){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 410);}
if(index == 6){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 340);}
if(index == 7){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 270);}

if(index == 8){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 480);}
if(index == 9){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 410);}
if(index == 10){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 340);}
if(index == 11){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 270);}
}




I hope you guys what the answer you wanted for this how to add battle party member and how to make them stand in position
if you have basic calculation knowledge you can do fun thing with this code.

like if you have 6 party member then stand them in 1 = 2 = 3 like pyramid sturcture
and many more


See you guys.

Thank you for reading...
Enram Rohsik
WisePot^
Q) How to add more Battle Party Members and Make them stand in row and columns.
A) I have seen many of the people don't know coding and they want to add more party member rather than just 4 in
Battle party and also want that all member don't stand in same line.
I make a small code in Visustella battle core plugin so you guys can use it too.

I have explain every thing in video please check it full then. Just copy paste the code and use it in game as, I told in Video.

View attachment 250964

Please this video how to do this thing.



Code :

Add more party member in team just type this code in your script :


Game_Party.prototype.maxBattleMembers = function() {

return 4;

};

Change the number 4 to the how many member you want in your party ok.


Code : to make all members not stand in same line
you must have visustella free plugin core and battle core.

open the battle core plugin => Actor Battle Setting => Home Position

just change the code given below what shown in video


// Declare Constants

const sprite = this;

const actor = this._actor;

const index = arguments[0];

const members = $gameParty.battleMembers().length;

let x;

let y;

// Make Calculations

if(members == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12)
{
if(index == 0){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 480);}
if(index == 1){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 410);}
if(index == 2){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 340);}
if(index == 3){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 270);}

if(index == 4){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 480);}
if(index == 5){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 410);}
if(index == 6){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 340);}
if(index == 7){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 270);}

if(index == 8){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 480);}
if(index == 9){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 410);}
if(index == 10){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 340);}
if(index == 11){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 270);}
}




I hope you guys what the answer you wanted for this how to add battle party member and how to make them stand in position
if you have basic calculation knowledge you can do fun thing with this code.

like if you have 6 party member then stand them in 1 = 2 = 3 like pyramid sturcture
and many more


See you guys.

Thank you for reading...
Enram Rohsik
WisePot^

Question, what if we don't have Yanfly Battlecore? I'm asking since I'm broke.
Question, what if we don't have Yanfly Battlecore? I'm asking since I'm broke.
You don't need money. Battle Core is free.
Question, what if we don't have Yanfly Battlecore? I'm asking since I'm broke.
Also, this is not for Yanfly, this is for the VisuStella plugins. The relevant ones are also free, per the original post and the plugin pages. Both MV and MZ also come with included dlc plugins for SV actor positions that should be able to take JavaScript in the plugin parameters.

@Wisepot, thanks for posting these instructions! Just a few notes:

Code:
if(members == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12)
This is incorrect syntax. Every time you use a boolean operator it expects a full expression to evaluate. So this isn't saying "if members is equal to 1 or 2 or 3..." it's saying "if members equalling 1 is true or 2 is true or 3 is true..." which will always be true, since 1 through 12 are values. Just having if (1) is always true. So your conditional will always evaluate to true.

I don't know why you'd try to go about it that way, instead of just doing if (members<=12)

I also don't get the point of the conditional. What is it checking? If someone tries to put more actors into their party than they define the max party size, they won't show up in battle anyway. It makes more sense to just make your positioning code not number-specific.

Speaking of...

{
if(index == 0){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 480);}
if(index == 1){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 410);}
if(index == 2){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 340);}
if(index == 3){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 270);}

if(index == 4){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 480);}
if(index == 5){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 410);}
if(index == 6){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 340);}
if(index == 7){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 270);}

if(index == 8){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 480);}
if(index == 9){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 410);}
if(index == 10){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 340);}
if(index == 11){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 270);}
}
There are a number of ways to make this more compact. You could use a switch:
Code:
switch (index)
{
    case 0:
    case 1:
    case 2:
    case 3:
        x=Math.round(Graphics.width-100);
        break;
etc.

You could also use the modulo operator % to see where the index falls in relation to the number 4. But, then, you can also replace a lot of your code with just actual math.

I think the easiest way to replace the above code is:
Code:
x=Math.round(Graphics.width-100+(index/4)*96);
y=Math.round(Graphics.height-270-(index%4)*70);

That's it.

And then, of course, the question is why bother declaring all of those const variables that you never use. 😉
Q) How to add more Battle Party Members and Make them stand in row and columns.
A) I have seen many of the people don't know coding and they want to add more party member rather than just 4 in
Battle party and also want that all member don't stand in same line.
I make a small code in Visustella battle core plugin so you guys can use it too.

I have explain every thing in video please check it full then. Just copy paste the code and use it in game as, I told in Video.

View attachment 250964

Please this video how to do this thing.



Code :

Add more party member in team just type this code in your script :


Game_Party.prototype.maxBattleMembers = function() {

return 4;

};

Change the number 4 to the how many member you want in your party ok.


Code : to make all members not stand in same line
you must have visustella free plugin core and battle core.

open the battle core plugin => Actor Battle Setting => Home Position

just change the code given below what shown in video


// Declare Constants

const sprite = this;

const actor = this._actor;

const index = arguments[0];

const members = $gameParty.battleMembers().length;

let x;

let y;

// Make Calculations

if(members == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12)
{
if(index == 0){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 480);}
if(index == 1){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 410);}
if(index == 2){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 340);}
if(index == 3){x = Math.round(Graphics.width - 100); y = Math.round(Graphics.height - 270);}

if(index == 4){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 480);}
if(index == 5){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 410);}
if(index == 6){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 340);}
if(index == 7){x = Math.round(Graphics.width - 196); y = Math.round(Graphics.height - 270);}

if(index == 8){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 480);}
if(index == 9){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 410);}
if(index == 10){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 340);}
if(index == 11){x = Math.round(Graphics.width - 292); y = Math.round(Graphics.height - 270);}
}




I hope you guys what the answer you wanted for this how to add battle party member and how to make them stand in position
if you have basic calculation knowledge you can do fun thing with this code.

like if you have 6 party member then stand them in 1 = 2 = 3 like pyramid sturcture
and many more


See you guys.

Thank you for reading...
Enram Rohsik
WisePot^

Rather than this litany of if statements, you could just do:

JavaScript:
const row = index % 4;
const column = index / 4;
x = Math.round(Graphics.width - (100 + column * 96));
y = Math.round(Graphics.height - (480 - row * 70));

if(members == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12)

Also this line will always return true; only the first condition checks whether the length is a certain number (1), and the rest just return the number, so if members isn't 1 that if statement will just return 2, and if(2) will never be able to return false.
I also don't get the point of the conditional. What is it checking?
He probably didn't understand the context of my original code when he copied and modified it:
https://forums.rpgmakerweb.com/index.php?threads/visustella-battle-core-sv-actor-positions.153054/

Const members was something I added for this example; it's not present in original code. Good effort tho.
thank you so much all of you for responding on my post, and really sorry i was not well so was offline from internet for quit long time

the code i try to make it, is not for who can understand how to do coding or have its knowledge
since, i try to make this code for who don't understand coding,

but by making it in this, way many of the ppl easily understood index 0 is for one hero in party and 1 for 2 hero in party and so on up to 12 hero's in party and there x and y position already given and can change it as per there requirement.

by using forumula this can be achieved easily but again if anyone want to change position of only one hero out of 12 for some reason, then he wont able to use formula or if he dont know coding then it might tough for him to do it,

so in my code i just give the option and xy position of all 12 heros if you wnt to change just use it as you like

by doing some changes in the x y position given in my way even person dont understand coding will enjoy the having 12 party of heros in game😛

just want to help who dnt know how to do it 🙂
Thank you so much for your replay , i really appreciate it , at the same time i m not trying to find memeber are less than or equal to 12 in my code but instead checking it if its either 0 or 1 or 2 or 3 and so on 😛
@Wisepot I'm sorry, I don't understand the distinction you're making.

The original line of code I quoted (besides being written incorrectly) was asking "is members 1 or 2 or 3...up to 12?"

That is functionally identical to simply saying "is members <= 12?"

If you meant something else, please show the code you're referring to.
yes members<=12 can be also used without problem
the code i try to make it, is not for who can understand how to do coding or have its knowledge
since, i try to make this code for who don't understand coding,
Its nice you want to help those who don't understand code, but the example you've shown isn't accurate and may confuse those trying to learn.

This is the default code:
Spoiler: JS: Home Position
Code:
// Declare Constants
const sprite = this;
const actor = this._actor;
const index = arguments[0];

// Make Calculations
let x = Math.round((Graphics.width / 2) + 192)
x -= Math.floor((Graphics.width - Graphics.boxWidth) / 2);
x += index * 32;
let y = (Graphics.height - 200) - ($gameParty.maxBattleMembers() * 48);
y -= Math.floor((Graphics.height - Graphics.boxHeight) / 2);
y += index * 48;

// Home Position Offsets
const offsetNote = /<SIDEVIEW HOME OFFSET:[ ]([\+\-]\d+),[ ]([\+\-]\d+)>/i;
const xOffsets = actor.traitObjects().map((obj) => (obj && obj.note.match(offsetNote) ? Number(RegExp.$1) : 0));
const yOffsets = actor.traitObjects().map((obj) => (obj && obj.note.match(offsetNote) ? Number(RegExp.$2) : 0));
x = xOffsets.reduce((r, offset) => r + offset, x);
y = yOffsets.reduce((r, offset) => r + offset, y);

// Set Home Position
this.setHome(x, y);

Explanation of the default code
My Dynamic Example: Dynamic Position

When you used my example as a basis of your example, you may not have understood the code.
Code:
members
is used to determine how many party members are attending battle as to change layout position for that party configuration. The layout is calculated on the member's index, multiplied by position parameter.

The example I provided may not have been the best as it was an example, not a tutorial. The intention was to show how one could set a single member party in center(or wherever), a two-member party could have a column layout(or wherever); a three-member party could have a triangle, column, diagonal(or wherever) configuration. etc etc...

Code:
members
is just to direct the layout style.
Since people had pointed out every imaginable flaw in the OP's code (and having had a few laughs here and there) wouldn't it also be fair to point out the flaws in an old timer's code since nobody had bothered to point them out?

But, then, you can also replace a lot of your code with just actual math.

I think the easiest way to replace the above code is:
Code:
x=Math.round(Graphics.width-100+(index/4)*96);
y=Math.round(Graphics.height-270-(index%4)*70);

That's it.
Code:
y=Math.round(Graphics.height-270-(index%4)*70);
That will give you 270, 340, 410, 480, 270, ..., 410, 480.
Must be nice to give lectures about "actual math" when your own math is actually wrong.

Code:
x=Math.round(Graphics.width-100+(index/4)*96);
You could have just replaced (index / 4) * 96 with index * 24.
Or for that matter in the name of "efficiency" or whatnot you should have just told him to forgo the Math.round() part as well since the Graphics height & width, indices, the modulo and the quotient of 96 and 4 are all whole numbers.

@Trihan @NaosoX Thank you for explaining the OP's shortcomings without being patronizing.
Since people had pointed out every imaginable flaw in the OP's code (and having had a few laughs here and there) wouldn't it also be fair to point out the flaws in an old timer's code since nobody had bothered to point them out?
You are making up your own emotional implications that did not exist. Nothing I said was rude, you are making that presumption to choose to be offended on the part of the OP. The words "actual math" are not being snarky, they mean "use math instead of long strings of code conditionals." That's not rude, it's basic programming technique.

As for lecturing, I submit you do not know what the word means when the section of my post you're referencing is one sentence.

To the point of "pointing out every imaginable flaw"...the code that was posted did not work. Is it better if no one responded and let people find and try to use JavaScript that's non-functional?

Code:
y=Math.round(Graphics.height-270-(index%4)*70);
That will give you 270, 340, 410, 480, 270, ..., 410, 480.
Must be nice to give lectures about "actual math" when your own math is actually wrong.
I have no idea what you're talking about. Those values you're listing are exactly what the original post had listed for their y values - 270, 340, 410, and 480. What exactly do you think is wrong?

Code:
x=Math.round(Graphics.width-100+(index/4)*96);
You could have just replaced (index / 4) * 96 with index * 24.
That's true. It doesn't make anything in the code not work correctly and it has no measurable effect on the efficiency of it, but you are correct that the math could be reworded in that way.

Or for that matter in the name of "efficiency" or whatnot you should have just told him to forgo the Math.round() part as well since the Graphics height & width, indices, the modulo and the quotient of 96 and 4 are all whole numbers.
This is also true. I was attempting to leave what portions of the OP's code I could, to demonstrate what was functional and what was incorrect syntax. I notice that for some reason you're not picking on @Trihan for doing the exact same thing in his post.

I don't know what in my post struck you as being so patronizing - the OP clearly is not well-versed in JavaScript, so I was polite to them off the bat by thanking them for their contribution, then demonstrated which parts of the code were incorrect and offered alternatives. I don't think the world needs more people choosing to be offended on others' behalf.
You are making up your own emotional implications that did not exist. Nothing I said was rude, you are making that presumption to choose to be offended on the part of the OP. The words "actual math" are not being snarky, they mean "use math instead of long strings of code conditionals." That's not rude, it's basic programming technique.

As for lecturing, I submit you do not know what the word means when the section of my post you're referencing is one sentence.

To the point of "pointing out every imaginable flaw"...the code that was posted did not work. Is it better if no one responded and let people find and try to use JavaScript that's non-functional?


I have no idea what you're talking about. Those values you're listing are exactly what the original post had listed for their y values - 270, 340, 410, and 480. What exactly do you think is wrong?


That's true. It doesn't make anything in the code not work correctly and it has no measurable effect on the efficiency of it, but you are correct that the math could be reworded in that way.


This is also true. I was attempting to leave what portions of the OP's code I could, to demonstrate what was functional and what was incorrect syntax. I notice that for some reason you're not picking on @Trihan for doing the exact same thing in his post.

I don't know what in my post struck you as being so patronizing - the OP clearly is not well-versed in JavaScript, so I was polite to them off the bat by thanking them for their contribution, then demonstrated which parts of the code were incorrect and offered alternatives. I don't think the world needs more people choosing to be offended on others' behalf.
I too am unsure of why Math.round was a focal point when I also left it in, but attitude of the post aside your y value *was* incorrect because at index 0 the subtraction starts at 270 rather than 480. Not a big deal, just the wrong number.
your y value *was* incorrect because at index 0 the subtraction starts at 270 rather than 480. Not a big deal, just the wrong number.
Okay. I didn't go back and re-read the original post and re-calculate my math based on Anastasius' rant, so I believe it 😉 All I saw were the numbers he listed being the same numbers the OP listed.

Perhaps more words could have been spent clearly explaining the mistake in my math instead of laying into me for imagined slights to someone else.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-add-more-battle-party-members-and-make-them-stand-in-row-and-columns.154210/