Yanfly Row Formation – Saving Row before a combat

● ARCHIVED · READ-ONLY
Started by Gregaur 6 posts View original ↗
  1. 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 !
  2. Is it too hard to do ?
  3. 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.
  4. 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 ...
  5. 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
    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
    Save Row Positions
    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
    Reset Row Positions
    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.

    Some more ideas using plugins
    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.
  6. 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 !