Editing/Combining Party and Actor Command Lists (compatible with Yanfly CTB)

Damascus7

Veteran
Veteran
Joined
Jul 21, 2019
Messages
99
Reaction score
23
First Language
English
Primarily Uses
RMMV
Hi all. I'm looking for a way to streamline the battle commands in my game. Specifically, I'd like to get rid of the Party Command window, and add the "Escape" command to the Actor Command window so only one list is necessary. I'd also like to get rid of the Guard command altogether, as I'd prefer not to use it in my game at all.

I found a thread for something very similar to what I want, but unfortunately, that plugin is not compatible with Yanfly's CTB battle system; after the Escape command is used, if it fails, the battle freezes with nothing the player can do. If anyone with plenty of plugin experience can help me out here, I would greatly appreciate it.
 

Lay

Veteran
Veteran
Joined
Jul 18, 2019
Messages
124
Reaction score
47
First Language
French
Primarily Uses
RMMV
Hi,

YEP_BattleSysCTB introduce a new BattleManager phase namely "ctb".
When the party command is active, the BattleManager phase is set to "ctb".
When the actor command is active, the BattleManager switch to phase "input".

Because the escape command has been made to work from the party command, it might be used during 'ctb' phase. Otherwise, the BattleManager will stuck in its 'input' phase (so waiting for instruction) and the Scene management will deactivate all window that might be used for selecting an input. This is what happen when you talk about "freeze".

Thus, when calling the function that process escape from the actor command window, it could be a good idea to set the BattleManager to 'CTB' phase. See below the script. I've annotated it so you can uderstand what it does and maybe integrate it to an other plugin that provides more functionalities. You can also copy paste it in a new .js file and load it in the plugin manager.

If other people are interested in doing the same thing but with an other battle system such as 'atb', you will meet the same "freeze" issue for the exact same reason.

JavaScript:
var Imported = Imported || {};

var Lay = Lay || {};
Lay.forumRequest = {} || Lay.forumRequest;


//=============================================================================
// Window_ActorCommand
//=============================================================================

Lay.forumRequest.Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList;
Window_ActorCommand.prototype.makeCommandList = function() {
    Lay.forumRequest.Window_ActorCommand_makeCommandList.call(this);
    if (this._actor) this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
    // Above we add the command escape to the actorCommand window.
};

//=============================================================================
// Scene_Battle
//=============================================================================

Lay.forumRequest.Scene_Battle_createActorCommandWindow = Scene_Battle.prototype.createActorCommandWindow;
Scene_Battle.prototype.createActorCommandWindow = function() {
    Lay.forumRequest.Scene_Battle_createActorCommandWindow.call(this);
    var win = this._actorCommandWindow;
    delete win._handlers.cancel
    // Above we delete the command cancel. This line can be remove if you want
    // to use the Party command window.
    // If you keep this line, the player couldn't switch from actor command to
    // party command anymore
    win.setHandler('escape', this.commandEscape.bind(this) );
    // Above we bind the function that process escape to the command escape we
    // have previously added to the corresponding window (actor command in this case)
};

//=============================================================================
// BattleManager
//=============================================================================

if (Imported.YEP_X_BattleSysCTB) {
Lay.forumRequest.BattleManager_processEscapeCTB = BattleManager.processEscapeCTB;
BattleManager.processEscapeCTB = function() {
  BattleManager.setCTBPhase()
  // if using CTB, you can set the BattleManager phase to 'ctb' using the function above.
  Lay.forumRequest.BattleManager_processEscapeCTB.call(this);
  // after setting the battlemanager to 'ctb' we process the escape command as yanfly has defined it in its plugin.
};
};
 
Last edited:

Damascus7

Veteran
Veteran
Joined
Jul 21, 2019
Messages
99
Reaction score
23
First Language
English
Primarily Uses
RMMV
This works great! Is there also a good way to remove the "Guard" command in the same way that "Cancel" was removed?
 

Lay

Veteran
Veteran
Joined
Jul 18, 2019
Messages
124
Reaction score
47
First Language
French
Primarily Uses
RMMV
It is possible to remove the guard command but not as we did for cancel.

When we removed the cancel, we removed the command that is triggered when the cancel button is pressed.
If you do the same with guard (delete win._handler.guard), this will removes the command that is triggered when guard is selected in the actorCommand window. Then, selecting guard will just do nothing.
I assume that what you want is to remove the guard option in the window.

So keep in mind that on one hand you have to setup the selection option in a window and on the other hand you have to bind a function to this command.

I think the best here is to directly edit the function used to add command and just say to do nothing if the command that is about to be added has the "guard" symbol. See the code below.

One other option is to let the program adding the guard command and then remove it. But it will involved more executions...
The last option is to overwrite the function that add command in the actor command window and just don't add the guard command. While this method is the best, it has a very bad compatibility with other plugins since the default code is overwrite...


JavaScript:
var Imported = Imported || {};

var Lay = Lay || {};
Lay.forumRequest = {} || Lay.forumRequest;


//=============================================================================
// Window_ActorCommand
//=============================================================================

Lay.forumRequest.Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList;
Window_ActorCommand.prototype.makeCommandList = function() {
    Lay.forumRequest.Window_ActorCommand_makeCommandList.call(this);
    if (this._actor) {
      this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
    };
};

Window_ActorCommand.prototype.addCommand = function(name, symbol, enabled, ext) {
    if (symbol === "guard") return;
    // above if the symbol of the command is guard, stop the execution of the function
    Window_Command.prototype.addCommand.call(this,name,symbol,enabled,ext);
   // if not, just run the function as usual
};

//=============================================================================
// Scene_Battle
//=============================================================================

Lay.forumRequest.Scene_Battle_createActorCommandWindow = Scene_Battle.prototype.createActorCommandWindow;
Scene_Battle.prototype.createActorCommandWindow = function() {
    Lay.forumRequest.Scene_Battle_createActorCommandWindow.call(this);
    var win = this._actorCommandWindow;
    delete win._handlers.cancel // Remove the command cancel
    win.setHandler('escape', this.commandEscape.bind(this) ); // Add the command escape
};

//=============================================================================
// BattleManager
//=============================================================================

if (Imported.YEP_X_BattleSysCTB) {
Lay.forumRequest.BattleManager_processEscapeCTB = BattleManager.processEscapeCTB;
BattleManager.processEscapeCTB = function() {
  BattleManager.setCTBPhase();
  Lay.forumRequest.BattleManager_processEscapeCTB.call(this);
};
};
 
Last edited:

Damascus7

Veteran
Veteran
Joined
Jul 21, 2019
Messages
99
Reaction score
23
First Language
English
Primarily Uses
RMMV
This does exactly what I need! Many thanks, friend!
 

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

Latest Threads

Latest Profile Posts

Stream will be live shortly with a session of the Interactive text Adventure! Feel free to drop by!
Quick! Someone give me a snake pun about moving.
Meet the crew...Arrrr!
Who knew modern medieval was an actual music genre? I don't know what the youtube algorithms are doing but for once they found something actually fascinating:
Yay! Got 3 new frying pans, its weird, but I'm so happy about it.

Forum statistics

Threads
99,526
Messages
966,403
Members
131,152
Latest member
rai1209
Top