查看: 5279|回复: 1

[已经解决] 逃跑菜单并入ActorCommand的问题

[复制链接]
梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
回帖
780
发表于 2015-11-18 14:51:40 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
不太喜欢默认的逃跑选项的位置在PartyCommand,于是把逃跑并入了ActorCommand跟攻击物品技能放在一起

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


  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. Window_ActorCommand.prototype.makeCommandList = function() {
  14.     if (this._actor) {
  15.         this.addAttackCommand();
  16.         this.addSkillCommands();
  17.         this.addGuardCommand();
  18.         this.addItemCommand();
  19. //加入逃跑选项
  20.                 this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  21.     }
  22. };
复制代码


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

Yanfly的逃跑的函数是这个
  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模式下是直接被跳过了,没有搞懂到底咋继续的。。。
  1. Yanfly.ATB.BattleManager_startTurn = BattleManager.startTurn;
  2. BattleManager.startTurn = function() {
  3.     if (this.isATB()) return;
  4.     Yanfly.ATB.BattleManager_startTurn.call(this);
  5. };
复制代码
梦石
0
星屑
90
在线时间
387 小时
注册时间
2007-7-27
回帖
4075

开拓者

发表于 2015-12-7 22:13:33 | 显示全部楼层
本帖最后由 trentswd 于 2015-12-7 22:36 编辑

原因是
actor->party  party->actor 菜单切换的时候做了一些处理
所以要把这些处理给弄好
  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. Scene_Battle.prototype.commandEscapeActor = function() {
  14.   var actorIndex = BattleManager._actorIndex;
  15.   BattleManager.selectNextCommand();
  16.   BattleManager._actorIndex = actorIndex;
  17.   this.commandEscape();
  18. }

  19. Window_ActorCommand.prototype.makeCommandList = function() {
  20.   if (this._actor) {
  21.     this.addAttackCommand();
  22.     this.addSkillCommands();
  23.     this.addGuardCommand();
  24.     this.addItemCommand();
  25.     //加入逃跑选项
  26.     this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  27.   }
  28. };
复制代码

点评

菊苣实在是太强大了!  发表于 2015-12-8 11:09

评分

参与人数 2星屑 +60 梦石 +1 收起 理由
余烬之中 + 1 菊苣实在是太强大了!
doranikofu + 60 认可答案

查看全部评分

吸吸
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部