Hello, I am trying to create a simple plugin that adds a confirmation window after the last actor in the party selects their action. A window should pop up in the middle of the screen asking if the player wishes to continue with the action. I am making this plugin for players just in case they select too fast and want to think things over. I have some Javascript and programming knowledge, but little knowledge of how the code structure of RMMV works. I'm still figuring that out!
The logic flow for this plugin should be like so:
After last actor selects an action, open window.
If 'confirm' is selected, startTurn();
Else if 'cancel' is selected: return back to PartyCommandWindow.
This is a snippet of what I have so far:
Code:
function Window_ActionConfirm() {
this.initialize.apply(this, arguments);
}
Window_ActionConfirm.prototype = Object.create(Window_Command.prototype);
Window_ActionConfirm.prototype.constructor = Window_Command;
Window_ActionConfirm.prototype.windowWidth = function() {
return 300;
};
Window_ActionConfirm.prototype.windowHeight = function() {
return this.fittingHeight(3);
};
Window_ActionConfirm.prototype.makeCommandList = function() {
this.addCommand("Confirm Actions", 'confirm');
this.addCommand("Cancel", 'cancel');
};
BattleManager.selectNextCommand = function() {
do {
if (!this.actor() || !this.actor().selectNextCommand()) {
this.changeActor(this._actorIndex + 1, 'waiting');
if (this._actorIndex >= $gameParty.size()) {
//open confirm window here
this._actionConfirmWindow = new Window_ActionConfirm(640, 360);
// if confirm is selected, startTurn, else return to the beginning.
this.startTurn();
break;
}
}
} while (!this.actor().canInput());
};
The trouble I'm having is within the BattleManager.selectNextCommand function. I'm not sure how to bind the 'confirm' and 'cancel' actions appropriately to do as I described. Can anyone help me with this? I feel like I'm almost there.
As you can see I have actually moved the commands to the Scene_Battle. The reason for this is because I chose to create the the
Window_ActionConfirm in the Scene_Battle not the BattleManager. The reason for this is because Windows should be in Scenes, and the Scene_Battle is the one that contains the windows for Battles.
In the confirmAction method I call the close method to hide the Window_ActionConfirm after we have selected the command (the same for the cancel method), afterwards the startTurn method of the BattleManager is called.
The cancel method looks a bit more complicated, however it is "simple enough" it changes the phase of the BattleManager to 'input' (this is becuase of a change I made another place in the code), and then simply callse the selectPreviousCommand method until we are back at the first actor.
Now as I said I moved the creation of the Window_ActionConfirm to the Scene_Battle like this:
This method is to be called in the createAllWindows method of Scene_Battle. The method is simple enough, it binds the methods to the commands, adds the window to the scene, and closes the window as it shouldn't be visible yet.
Now we need to make the window appear at an appropriate time. You identified a place yourself. What I choose to do is change the phase of the BattleManager to a phase I call 'pre_turn'.
Code:
BattleManager.selectNextCommand = function() {
do {
if (!this.actor() || !this.actor().selectNextCommand()) {
this.changeActor(this._actorIndex + 1, 'waiting');
if (this._actorIndex >= $gameParty.size()) {
this._phase = 'pre_turn';
break;
}
}
} while (!this.actor().canInput());
};
So how does this make the window show? It does in the changeInputWindow method of the Scene_Battle like this.
This refreshes the window and command list, selects the first command, activates and opens the window.
This basically covers what you want. However there are a few more changes we need to make in order to make it work properly. We have to add the window to the isAnyInputWindowActive of Scene_Battle.
Thank you for the well detailed reply! I'll take a look at what you've written and test it out. So far, it looks good and your explanations are clear. I'm still figuring out how RMMV deals with windows as there's a lot of moving parts to keep track of, which is why this seemingly simple plugin is giving me a hard time. Still learning!
I do have a question out of curiosity: is the addition of the "pre_turn" phase absolutely necessary for this to work? I do understand why you added it though.
Well the addition of the "pre_turn" phase is not absolutely necessary, however it does deal with some other stuff behind the scene. (like making sure you can not select the next party command!). However, you could also do it like this:
Code:
BattleManager.selectNextCommand = function() {
do {
if (!this.actor() || !this.actor().selectNextCommand()) {
this.changeActor(this._actorIndex + 1, 'waiting');
if (this._actorIndex >= $gameParty.size()) {
SceneManager._scene._actionConfirmWindow.setup();
break;
}
}
} while (!this.actor().canInput());
};
Now instead of changing the phase we assume that the current scene is the Scene_Battle and call the setup method of the Window_ActionConfirm directly from the BattleManager. This will make the window show, however because of how the Scene_Battle works it will now also show the party command window. We can fix this by writing the changeInputWindow method of Scene_Battle like this:
As you can see it checks if we are in the "input" phase of the BattleManager and will then either start the ActorCommandSelection or the PartyCommandSelection. We do not want either of those to start when we select rather we want to confirm or cancel our selection.
The endCommandSelection method looks like this:
As you can see it simply closes the windows we do not want to see as well as deselects the statusWindow.
Another way to do it could possible also be adding another field to the BattleManager like BattleManager._confirmActions which would be a boolean. Then set this value to true when we want the confirm window to appear. Then change the changeInputWindow method to something like this:
Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.