Hello I currently have an item that allows players to swap equipment in the middle of a battle. I wanted to add an accessory that when worn will allow the player to use the equipment swap item and then immediately be able to go again. What I tried doing was creating a conditional branch for the common event that the equipment item was using. The if for the branch was supposed to check for the equipped accessory then it called the common event for the equip screen then a script that is supposed to allow the user to go again immediately. Then there is an else branch that just has the equip screen common event. Would anyone be able to tell me how to do the if statement as well as the script for going again? What I was trying didn't work unfortunately. Please and thank you!
MZ Script for an item that allows a player to go again immediately after using it?
RPG Maker MZ SupportIf you're using the Steam version, the DLC folder contains a script that lets you swap equipment during battle. It may not be precisely what you want (I haven't tried the MZ version of this plugin myself), but if you have any coding skill at all, maybe you can look at it for clues on how to do what you want.
It depends on which kind of battle system you're using, because turn-based works differently than the various time-based options, not even counting the various possibilities done by plugins.
I'm using the vanilla out of the box turn based system that comes with MZ. I've been trying not to touch the actual battle system too much since the project I am currently working on is mostly just to learn how to use rpgmaker in general.
I know this isn't exactly what you wanted, but you could also try that common event run by the accessory to bestow an invisible state you create that gives Agility*1000 for exactly one turn.
This should guarantee the user to immediately get another turn, followed by returning to their normal speed (I didn't test this, mind you).
Not sure how exactly you trigger that common event in your project, but you could also make a unique skill, e.g. "Change Equipment & Go Again", gained only by equipping your accessory. That skill can then call an event that first opens the menu screen you need, and then applies the invisible superspeed state I mentioned above.
This should guarantee the user to immediately get another turn, followed by returning to their normal speed (I didn't test this, mind you).
Not sure how exactly you trigger that common event in your project, but you could also make a unique skill, e.g. "Change Equipment & Go Again", gained only by equipping your accessory. That skill can then call an event that first opens the menu screen you need, and then applies the invisible superspeed state I mentioned above.
The way that the common event works is it just uses this script in a common event. Then the common event can be placed onto a skill or item.
Code:
SceneManager.push(Scene_Equip)
JavaScript:
/*: * @target MZ
* @plugindesc Don't initialise battle data if previous scene was a menu.
* @author Caethyril
* @url https://forums.rpgmakerweb.com/posts/1529996/
* @help Free to use and/or modify for any project, no credit required.
*/
;void (() => {
"use strict";
/** Scenes to/from which battle should *NOT* initialise. @type {Scene_Base[]} */
const NO_INIT_SCENES = [Scene_Equip];
/** @returns {boolean} `true` iff should init battle data on scene start. */
const shouldInit = function() {
for (const s of NO_INIT_SCENES)
if (SceneManager.isPreviousScene(s))
return false;
return true;
};
/** @returns {boolean} `true` iff should clear temporary battler data on scene end. */
const shouldClear = function() {
for (const s of NO_INIT_SCENES)
if (SceneManager.isNextScene(s))
return false;
return true;
};
// Patch - only initialise battle data if appropriate.
void (alias => {
BattleManager.startBattle = function() {
if (shouldInit())
alias.apply(this, arguments);
};
})(BattleManager.startBattle);
// Patch - only process battle end effects when appropriate.
for (const C of [Game_Party, Game_Troop])
void (alias => {
C.prototype.onBattleEnd = function() {
if (shouldClear())
alias.apply(this, arguments);
};
})(C.prototype.onBattleEnd);
})();
Welp, I won't be much help with javascript...
You might want to ask caethyril directly.
You might want to ask caethyril directly.
in turn-based, the battleturn is divided into two phases - the selection phase and the action phase.
In the selection phase you decide what the one action of each actor is, then those actions are ordered for agility and skill speed to get the order in which they are executed in the action phase.
getting two actions (item plus skill) into the action phases is not exactly easy, but there is a different approach:
For MV, yanfly made an instant cast plugin that would cause marked skills to be processed during selection phase, allowing a second selection for the action directly after that.
I do not know if Visustella ported that plugin to MZ, and neither if it was for skill only or could be used for items as well.
But that is a possible solution: have an instant item plugin that executes the item use in the selection phase before allowing to select a regular action after that.
But I don't know if such a plugin already exists or if you need to request it.
I will look into this. Thank you for trying to help! I also appreciate you explaining how exactly turn based works. I feel like I am stumbling around in the dark with a lot of the things I am working on with this project lol.
Original thread: https://forums.rpgmakerweb.com/threads/script-for-an-item-that-allows-a-player-to-go-again-immediately-after-using-it.180084/