Project1

标题: 逃跑菜单并入ActorCommand的问题 [打印本页]

作者: doranikofu    时间: 2015-11-18 14:51
标题: 逃跑菜单并入ActorCommand的问题
不太喜欢默认的逃跑选项的位置在PartyCommand,于是把逃跑并入了ActorCommand跟攻击物品技能放在一起

使用Yanfly的插件的话,战斗开始的时候自动跳过partycommand那个战斗还是逃跑的菜单直接进入角色行动。
稍微改一下ActorCommand加入逃跑,并且屏蔽掉退回上一层菜单就可以了,修改如下

JAVASCRIPT 代码复制
  1. Scene_Battle.prototype.createActorCommandWindow = function() {
  2.     this._actorCommandWindow = new Window_ActorCommand();
  3.     this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
  4.     this._actorCommandWindow.setHandler('skill',  this.commandSkill.bind(this));
  5.     this._actorCommandWindow.setHandler('guard',  this.commandGuard.bind(this));
  6.     this._actorCommandWindow.setHandler('item',   this.commandItem.bind(this));
  7. //    this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));
  8. // 加入逃跑选项
  9.     this._actorCommandWindow.setHandler('escape', this.commandEscape.bind(this));
  10.     this.addWindow(this._actorCommandWindow);
  11.         //this._actorCommandWindow.opacity = 150;
  12.  
  13. };
  14.  
  15. Window_ActorCommand.prototype.makeCommandList = function() {
  16.     if (this._actor) {
  17.         this.addAttackCommand();
  18.         this.addSkillCommands();
  19.         this.addGuardCommand();
  20.         this.addItemCommand();
  21. //加入逃跑选项
  22.                 this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  23.     }
  24. };


回合制的时候没有任何问题,然而ATB的模式问题来了。
如果逃跑失败的话,atb就不会继续更新,然后战斗就停留在逃跑失败的状态无法继续。翻了半天js也没找到究竟是哪个地方的问题。默认的在partycommand里面逃跑没有这个问题。应该是turn的计算哪里错了导致没有继续。这次代码一层套一层感觉很难找到哪里有问题。不知道有木有熟悉Yanfly的ATB的菊苣指点一下。。。

Yanfly的逃跑的函数是这个
JAVASCRIPT 代码复制
  1. BattleManager.processEscapeATB = function() {
  2.   $gameParty.performEscape();
  3.   SoundManager.playEscape();
  4.   var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
  5.   if (success) {
  6.       $gameParty.removeBattleStates();
  7.       this.displayEscapeSuccessMessage();
  8.       this._escaped = true;
  9.       this.processAbort();
  10.   } else {
  11.       this.displayEscapeFailureMessage();
  12.       this._escapeRatio += this._escapeFailBoost;
  13.       $gameParty.clearActions();
  14.       this.startTurn();
  15.       this.processFailEscapeATB();
  16.   }
  17.   return success;
  18. };


然后那个默认的startTurn在ATB模式下是直接被跳过了,没有搞懂到底咋继续的。。。
JAVASCRIPT 代码复制
  1. Yanfly.ATB.BattleManager_startTurn = BattleManager.startTurn;
  2. BattleManager.startTurn = function() {
  3.     if (this.isATB()) return;
  4.     Yanfly.ATB.BattleManager_startTurn.call(this);
  5. };

作者: trentswd    时间: 2015-12-7 22:13
本帖最后由 trentswd 于 2015-12-7 22:36 编辑

原因是
actor->party  party->actor 菜单切换的时候做了一些处理
所以要把这些处理给弄好
JAVASCRIPT 代码复制
  1. Scene_Battle.prototype.createActorCommandWindow = function() {
  2.   this._actorCommandWindow = new Window_ActorCommand();
  3.   this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
  4.   this._actorCommandWindow.setHandler('skill', this.commandSkill.bind(this));
  5.   this._actorCommandWindow.setHandler('guard', this.commandGuard.bind(this));
  6.   this._actorCommandWindow.setHandler('item', this.commandItem.bind(this));
  7.   //    this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));
  8.   // 加入逃跑选项
  9.   this._actorCommandWindow.setHandler('escape', this.commandEscapeActor.bind(this));
  10.   this.addWindow(this._actorCommandWindow);
  11.   //this._actorCommandWindow.opacity = 150;
  12.  
  13. };
  14.  
  15. Scene_Battle.prototype.commandEscapeActor = function() {
  16.   var actorIndex = BattleManager._actorIndex;
  17.   BattleManager.selectNextCommand();
  18.   BattleManager._actorIndex = actorIndex;
  19.   this.commandEscape();
  20. }
  21.  
  22. Window_ActorCommand.prototype.makeCommandList = function() {
  23.   if (this._actor) {
  24.     this.addAttackCommand();
  25.     this.addSkillCommands();
  26.     this.addGuardCommand();
  27.     this.addItemCommand();
  28.     //加入逃跑选项
  29.     this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  30.   }
  31. };





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1