Yanfly Row Formation – Saving Row before a combat

Gregaur

Veteran
Veteran
Joined
Jan 3, 2017
Messages
134
Reaction score
20
First Language
french
Primarily Uses
RMMV
Hello makers !

Here is my situation. I use the Yanfly row formation plugin in my game. Row are very important. Some enemies have the ability to change my actors row during a fight. At the end of the fight, If my actors moved during the combat, they keep their position. So in a Donjon, the play have to change back his team formation after every fight. That’s kind of annoying for him. So My question is : Is there a way to save the actor position at the beginning of a fight and then put them back to their position after the fight. It would be like this.

My team :
Actor 1 Row 1
Actor 2 Row 2
Actor 3 Row 3

The combat start (maybe on turn 0 or with another plugin) :
Variable 1 = Actor1RowIndex (so equal to 1)
Variable 2 = Actor2RowIndex (so equal to 2)
Variable 3 = Actor3RowIndex (so equal to 3)

My team kick so monster because they’re badass but some of the monsters change their position. At the end of the fight here we are :

Actor 1 Row 2
Actor 2 Row 3
Actor 3 Row 3

As you can see two of the actors were push back. And I don’t want them to stay there or to change it manually. So I would need an event :
Put back Actor1 to Row number Variable 1 (Row 1)
Put back Actor2 to Row number Variable 2 (Row 2)
Put back Actor3 to Row number Variable 3 (Row 3)


I know this is not a big issue in a game, but it would be far more comfortable for the player to nota have to change it back after every fight.

I Don’t know how to use correctly Java (and English for that matter) so it’s kind of difficult for me to find a solution.

Anyways thank you very much guys !
 

Gregaur

Veteran
Veteran
Joined
Jan 3, 2017
Messages
134
Reaction score
20
First Language
french
Primarily Uses
RMMV
Is it too hard to do ?
 

boikish

Always trying to help :)
Veteran
Joined
Sep 8, 2016
Messages
154
Reaction score
49
First Language
English
Primarily Uses
N/A
I'm not too familiar with this plugin, but I have an idea.

Perhaps you can use Yanfly's Troop Events: http://yanfly.moe/2015/10/18/yep-15-base-troop-events/

Within the event, you can store the current row formation in a few variables. Then, using the troop events, you can revert the row formation back to what it was.

I am not home and able to try this out right now. But maybe later I can provide screenshots.
 

Gregaur

Veteran
Veteran
Joined
Jan 3, 2017
Messages
134
Reaction score
20
First Language
french
Primarily Uses
RMMV
Hi Boikish

I think it's may be a good idea, my problem is, how do I get the Row number on a variable ?

in the line : Variable 1 = Actor1RowIndex (so equal to 1), I don't know how to get the Actor1RowIndex (I thnik if there is a way to get it, the rest will be easy). But I didn't it in the JS ...
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
I think the best way is to have 2 Common Events - "Save Row Positions" which is used before battle, and "Reset Row Positions" which is used after battle.

How you call the Common Event is up to you, boikish already gave one suggestion. I'll describe an approach that does not require plugins, but using plugins could make it easier for you.

1.) Set up the Variables
Reserve some variables that you can use to store the actor's row. The maximum size of the party is how many variables you need. Also, remember the Variable ID # of the first variable you use, this will be the "offset".
Example:
The party can have 8 members maximum. I have Variables #41 - #48 available to use (I need 8 variables total) --> and the "offset" value is 41.
2.) Create the "Save Row Positions" Common Event
Create a Common Event and use a "script" event command with this code:
Code:
const offset = 41;
$gameParty.members().forEach((actor, i) => $gameVariables.setValue(i + offset, actor.row()));
You can add a comment to help you remember what the code is doing. Here is the explanation:
Get a list of the actors in the party. For each of those actors, save their current row to the next variable with the offset.

Remember the offset value is important (see step 1).

MV versions older than 1.6 can't use modern Javascript syntax. Here is the same code using old Javascript syntax.
Code:
var offset = 41;
$gameParty.members().forEach(function(actor, i) { $gameVariables.setValue(i + offset, actor.row())});

3.) Create the "Reset Row Positions" Common Event
Create a Common Event and use this code in a "script" event command.
Code:
const offset = 41;
$gameParty.members().forEach((actor, i) => actor.setRow($gameVariables.value(i + offset)));
You can add a comment to help you remember what the code is doing. Here is the explanation:
Get a list of the actors in the party. For each of those actors, set the row position to the value of the next variable with offset.

Remember the offset value is important (see step 1).
MV versions older than 1.6 can't use modern Javascript syntax. Here is the same code using old Javascript syntax.
Code:
var offset = 41;
$gameParty.members().forEach(function(actor, i) { actor.setRow($gameVariables.value(i + offset))});

4.) Set up the Common Events to run at the start and end of battles.

You can run the "Save Row Positions" Common Event on Turn 0 of the battle using troop events. Without plugins, you would have to add this to every troop in your database. Using the plugin suggested above, you can add this to the "Base Troop Event" and it will run for all.

Also, inside the "Save Row Positions" Common Event, set a switch to ON. This switch can be called "Need to Reset Rows".
Then your "Reset Row Positions" Common Event can be parallel with the condition of the switch "Need to Reset Rows". Make sure to turn OFF this switch during the Common Event.

SRD Battle End Events allows you to run Common Events at the end of battle, and HIME Random Encounter Events allows you to run Common Events at the start of random battles.
 

Gregaur

Veteran
Veteran
Joined
Jan 3, 2017
Messages
134
Reaction score
20
First Language
french
Primarily Uses
RMMV
Thank you so much for your answer ! It works perfectly !

There is few pluggin to call an event at the beginining and the end of a fight so I think i'll use it ! Thank's a lot !
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top