- Joined
- May 5, 2020
- Messages
- 191
- Reaction score
- 83
- First Language
- French
- Primarily Uses
- RMMV
[EDIT: This seems to be working, so I've changed the title from "need help" to "how to". I kept the rest of my post intact so future dwellers can learn about the process and have the code]
Hello. I need help.
So far, I've been able to reposition actors to the left of the screen, and the enemies on the right. In order to make all of them attack in the correct direction, I have changed the parameters of this.setMirror to true in the CODE of YEP_BattleEngineCore
This makes the battlers face the targets properly, swing weapons in the right direction, etc.
Where I'm stuck: The only thing that I'm not able to figure out is that at the beginning of the battle, every battler is looking in the wrong direction (picture below).
But once the battle begins, things come to normal. For actors: they all turn in the right direction after the first action input (so when they move back to their home position). For the enemies, when the last actor has set its action, all the enemies turn around all at once.
I have the feeling I need to inject some kind of a refresh at the very beginning of the battle (force a this.spriteFaceForward() on each battler), or set a default parameter when the battlers are initialized. I just do not know where. Been trying for a couple of days
Here's basically a step-by-step how I got here:
Hello. I need help.
So far, I've been able to reposition actors to the left of the screen, and the enemies on the right. In order to make all of them attack in the correct direction, I have changed the parameters of this.setMirror to true in the CODE of YEP_BattleEngineCore
JavaScript:
Game_Battler.prototype.spriteFaceForward = function() {
this.setMirror(true);
};
Game_Battler.prototype.spriteFaceBackward = function() {
this.setMirror(true);
This makes the battlers face the targets properly, swing weapons in the right direction, etc.
Where I'm stuck: The only thing that I'm not able to figure out is that at the beginning of the battle, every battler is looking in the wrong direction (picture below).
But once the battle begins, things come to normal. For actors: they all turn in the right direction after the first action input (so when they move back to their home position). For the enemies, when the last actor has set its action, all the enemies turn around all at once.
I have the feeling I need to inject some kind of a refresh at the very beginning of the battle (force a this.spriteFaceForward() on each battler), or set a default parameter when the battlers are initialized. I just do not know where. Been trying for a couple of days
Here's basically a step-by-step how I got here:
Notes:
- I'm using Yanfly plugins.
- I'm using screen size of 1280 x 720. You can use pretty much any size that you want, but you will need to change the hard values (150, 26, 52...) to fit your game screen size.
STEP 1 - Position our actors and enemies.
I used YEP_RowFormation to automate the positions. My game will use 3 rows for actors and enemies. Row1 (fighters) is at the front, Row2 (support) is middle, Row3 (casters) is at the back.
The values below assume that the sprites are 64x64. If they are any bigger, you will want to change the values of 16, 32 and 64.
The value 150 is the distance from the edge of the screen.
The values 26 and 52 are for the staggering. Simply put, we add (or retract) these values for each sprite on a row, so that it gives a sense of perspective. These will need to be changed (trial and error) if you use a different screen size than 1280 x 720. If you are using default RMMV size, you can use 16 and 32 as a starting point. This is what it would look like.
In YEP_RowFormation:
Maximum Rows: 3
Maximum Row X: screenWidth - 150 + 26
Maximum Row Y: screenHeight - statusHeight - 16
Minimum Row Y: screenHeight - statusHeight - 16 - ((maxRows + 1) * 64)
Center Row Y: (maxRowY + minRowY) / 2 + 16
Row 1 Home X: 150 - 32 + $gameParty.rowSize(maxRows) * 26 + (maxRows - rowId) * 150 - $gameParty.rowSize(rowId) * 26 + rowIndex * 52
Row 1 Home Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
Row 2 Home X: 150 - 32 + $gameParty.rowSize(maxRows) * 26 + (maxRows - rowId) * 150 - $gameParty.rowSize(rowId) * 26 + rowIndex * 52
Row 2 Home Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
Row 3 Home X: 150 - 32 + $gameParty.rowSize(maxRows) * 26 + (maxRows - rowId) * 150 - $gameParty.rowSize(rowId) * 26 + rowIndex * 52
Row 3 Home Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
Enemy Row X: screenWidth - 150 + 32 - $gameTroop.rowSize(maxRows) * 26 - (maxRows - rowId) * 150 + $gameTroop.rowSize(rowId) * 26 - rowIndex * 52
Enemy Row Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
STEP 2 - Flip (mirror) the sprites
Now that I have positioned the actors where the enemies should be, and vice-versa, the sprites are looking in the wrong direction. To fix this:
In YEP_BattleEngineCore:
Step Distance: -32
Flinch Distance: -16
In the *CODE* of YEP_BattleEngineCore.js:
I switched the values for mirroring. Find the following lines:
Change the false to true, and true to false
STEP 3 - Action Sequence (no longer needed, code in 3rd post of this thread fixes all of this)
Everything is now reversed, even action sequence. For instance, moving an actor to the front of an enemy was: move user: target, front, 30 but is it now: move user: target, back, 30
A simple attack will now look like this:
- I'm using Yanfly plugins.
- I'm using screen size of 1280 x 720. You can use pretty much any size that you want, but you will need to change the hard values (150, 26, 52...) to fit your game screen size.
STEP 1 - Position our actors and enemies.
I used YEP_RowFormation to automate the positions. My game will use 3 rows for actors and enemies. Row1 (fighters) is at the front, Row2 (support) is middle, Row3 (casters) is at the back.
The values below assume that the sprites are 64x64. If they are any bigger, you will want to change the values of 16, 32 and 64.
The value 150 is the distance from the edge of the screen.
The values 26 and 52 are for the staggering. Simply put, we add (or retract) these values for each sprite on a row, so that it gives a sense of perspective. These will need to be changed (trial and error) if you use a different screen size than 1280 x 720. If you are using default RMMV size, you can use 16 and 32 as a starting point. This is what it would look like.
In YEP_RowFormation:
Maximum Rows: 3
Maximum Row X: screenWidth - 150 + 26
Maximum Row Y: screenHeight - statusHeight - 16
Minimum Row Y: screenHeight - statusHeight - 16 - ((maxRows + 1) * 64)
Center Row Y: (maxRowY + minRowY) / 2 + 16
Row 1 Home X: 150 - 32 + $gameParty.rowSize(maxRows) * 26 + (maxRows - rowId) * 150 - $gameParty.rowSize(rowId) * 26 + rowIndex * 52
Row 1 Home Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
Row 2 Home X: 150 - 32 + $gameParty.rowSize(maxRows) * 26 + (maxRows - rowId) * 150 - $gameParty.rowSize(rowId) * 26 + rowIndex * 52
Row 2 Home Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
Row 3 Home X: 150 - 32 + $gameParty.rowSize(maxRows) * 26 + (maxRows - rowId) * 150 - $gameParty.rowSize(rowId) * 26 + rowIndex * 52
Row 3 Home Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
Enemy Row X: screenWidth - 150 + 32 - $gameTroop.rowSize(maxRows) * 26 - (maxRows - rowId) * 150 + $gameTroop.rowSize(rowId) * 26 - rowIndex * 52
Enemy Row Y: centerY - ((rowSize / -2 + 0.5) + rowIndex) * 64
STEP 2 - Flip (mirror) the sprites
Now that I have positioned the actors where the enemies should be, and vice-versa, the sprites are looking in the wrong direction. To fix this:
In YEP_BattleEngineCore:
Step Distance: -32
Flinch Distance: -16
In the *CODE* of YEP_BattleEngineCore.js:
I switched the values for mirroring. Find the following lines:
JavaScript:
Game_Battler.prototype.spriteFaceForward = function() {
this.setMirror(false);
};
Game_Battler.prototype.spriteFaceBackward = function() {
this.setMirror(true);
};
Change the false to true, and true to false
JavaScript:
Game_Battler.prototype.spriteFaceForward = function() {
this.setMirror(true); // Default: false
};
Game_Battler.prototype.spriteFaceBackward = function() {
this.setMirror(false); // Default: true
};
STEP 3 - Action Sequence (no longer needed, code in 3rd post of this thread fixes all of this)
A simple attack will now look like this:
Code:
<setup action>
clear battle log
display action
immortal: targets, true
cast animation
wait for animation
</setup action>
<whole action>
face user: target
if user.attackMotion() !== 'missile'
move user: target, back, 30
wait for movement
else
perform start
wait for movement
end
</whole action>
<target action>
motion attack: user
wait: 10
action effect
if target.result().missed || target.result().evaded
else
attack animation: target
wait for animation
end
</target action>
<finish action>
immortal: targets, false
wait for new line
clear battle log
perform finish
wait for movement
wait for effect
</finish action>
Last edited: