烁灵 发表于 2024-5-29 09:49:45

【汉化】独立回合战斗行动

使每个角色战斗行动在选择后立即执行


原地址:Individual Turn Battle System | RPG Maker Forums (rpgmakerweb.com)

预览:
https://pic.imgdb.cn/item/66568996d9c307b7e9a03090.gif


汉化脚本:
//=============================================================================
// RPG Maker MZ - Individual Turn Battle System - Version 1.1
//=============================================================================

/*:
* @target MZ
* @plugindesc 实现战斗中单个角色的行动设定后立即执行的效果。
* 汉化 by 烁灵 更多脚本请访问 www.hknmtt.com
* @author Fomar0153
*
* @param Battle Turn Order Formula
* @type string
* @desc 战斗行动顺序计算公式
* @default this.agi + Math.randomInt(this.agi / 2)
*
* @param Use Party Command Window
* @type boolean
* @desc 当在角色行动窗口中选择取消时,呼出队员行动窗口,而不是跳过回合
* @default true
*
* @param Add Pass to Party Command Window
* @type boolean
* @desc 当时用队员行动窗口时,是否显示“跳过”选项
* @default true
*
* @param Pass Command Name
* @type string
* @desc “跳过” 选项的文本
* @default 跳过
*
* @help Fomar0153_IndividualTurnBattleSystem.js
* 行动顺序公式的一些例子:
* this.agi
* 将按敏捷排序
* this.agi + Math.randomInt(this.agi / 2)
* 将按敏捷排序,同时增加一些随机性
*
* Version 1.0 -> 1.1
* Bug fixes! Specifically to do with restrictions on status effects.
*/

var Fomar = Fomar || {};
Fomar.ITBS = {};

Fomar.ITBS.parameters = PluginManager.parameters('Fomar0153_IndividualTurnBattleSystem');

Fomar.ITBS.battleAgi = Fomar.ITBS.parameters["Battle Turn Order Formula"] || "this.agi";
Fomar.ITBS.partyCommand = (Fomar.ITBS.parameters["Use Party Command Window"] == "true");
Fomar.ITBS.passCommand = (Fomar.ITBS.parameters["Add Pass to Party Command Window"] == "true");
Fomar.ITBS.passText = Fomar.ITBS.parameters["Pass Command Name"] || "Pass";

(() => {

BattleManager.isTpb = function() {
    return true;
};

Fomar.ITBS.BattleManager_initMembers = BattleManager.initMembers;
BattleManager.initMembers = function() {
    Fomar.ITBS.BattleManager_initMembers.call(this);
    this._battlers = [];
};

Fomar.ITBS.BattleManager_startBattle = BattleManager.startBattle;
BattleManager.startBattle = function() {
    Fomar.ITBS.BattleManager_startBattle.call(this);
    this._battlers = [];
    $gameParty.aliveMembers().concat($gameTroop.aliveMembers()).forEach((member) => {
      this._battlers.push(member);
    });
    this._battlers.sort(function(a, b) {
      return b._battleAgi - a._battleAgi
    });
};

BattleManager.updateTurn = function(timeActive) {
    $gameParty.requestMotionRefresh();
    if (!this._subject && !this._currentActor) {
      this.updateTpb();
    }
    if (this._subject) {
      this.processTurn();
    }
};

BattleManager.updateTpb = function() {
    $gameParty.members().concat($gameTroop.members()).forEach((member) => {
      if (!member.isAlive()) {
      this._battlers.remove(member);
      } else {
      if (!this._battlers.includes(member)) {
          this._battlers.push(member);
      }
      }
    });
    if (this._battlers) {
      this._battlers.onTurnEnd();
      if (this._battlers.isActor()) {
      if (this._battlers.canMove()) {
          if (this._battlers.canInput()) {
            this._inputting = true;
            this._currentActor = this._battlers;
            this._currentActor.makeActions();
            this.startActorInput();
          } else {
            this._subject = this._battlers;
            this._subject.makeActions();
          }
      }
      } else {
      this._subject = this._battlers;
      this._subject.makeActions();
      $gameTroop.increaseTurn();
      }
      this._battlers.remove(this._battlers);
    }
};

BattleManager.updateTpbInput = function() {
    // done elsewhere now
};

BattleManager.finishActorInput = function() {
    if (this._currentActor) {
      this._subject = this._currentActor;
      this._inputting = false;
    }
};

BattleManager.changeCurrentActor = function(forward) {
      this._currentActor = null;
};

Fomar.ITBS.Game_Battler_onBattleStart = Game_Battler.prototype.onBattleStart;
Game_Battler.prototype.onBattleStart = function(advantageous) {
    Fomar.ITBS.Game_Battler_onBattleStart.call(this);
    this._battleAgi = eval(Fomar.ITBS.battleAgi);
    if (advantageous) {
      this._battleAgi *= 2;
    }
};

Game_Battler.prototype.canInput = function() {
    return Game_BattlerBase.prototype.canInput.call(this);
};

Game_Battler.prototype.applyTpbPenalty = function() {
    // surely failing to escape is penalty enough?
};

Window_StatusBase.prototype.placeTimeGauge = function(actor, x, y) {
    // no time bar, thanks
};

Window_PartyCommand.prototype.makeCommandList = function() {
    this.addCommand(TextManager.fight, "fight");
    if (Fomar.ITBS.passCommand) {
      this.addCommand(Fomar.ITBS.passText, "pass");
    }
    this.addCommand(TextManager.escape, "escape", BattleManager.canEscape());
};

Fomar.ITBS.Scene_Battle_createPartyCommandWindow = Scene_Battle.prototype.createPartyCommandWindow;
Scene_Battle.prototype.createPartyCommandWindow = function() {
    Fomar.ITBS.Scene_Battle_createPartyCommandWindow.call(this);
    this._partyCommandWindow.setHandler("pass", this.commandPass.bind(this));
};

Scene_Battle.prototype.startPartyCommandSelection = function() {
    this._statusWindow.show();
    this._statusWindow.open();
    this._actorCommandWindow.close();
    this._partyCommandWindow.setup();
};

Scene_Battle.prototype.commandCancel = function() {
    if (Fomar.ITBS.partyCommand) {
      this.startPartyCommandSelection();
    } else {
      this.selectPreviousCommand();
    }
};

Scene_Battle.prototype.commandFight = function() {
    this._partyCommandWindow.close();
    this._actorCommandWindow.open();
    this._actorCommandWindow.activate();
};

Scene_Battle.prototype.commandPass = function() {
    this.selectNextCommand();
};

Scene_Battle.prototype.commandEscape = function() {
    BattleManager.processEscape();
    this.selectNextCommand();
};

})();使用方法:
在插件中启用即可,无插件指令。

做游戏塔诺西 发表于 2024-8-14 10:35:57

太有用了,感谢!
页: [1]
查看完整版本: 【汉化】独立回合战斗行动