查看: 5190|回复: 1

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

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

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

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

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

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

[pre lang="javascript"]
Scene_Battle.prototype.createActorCommandWindow = function() {
    this._actorCommandWindow = new Window_ActorCommand();
    this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
    this._actorCommandWindow.setHandler('skill',  this.commandSkill.bind(this));
    this._actorCommandWindow.setHandler('guard',  this.commandGuard.bind(this));
    this._actorCommandWindow.setHandler('item',   this.commandItem.bind(this));
//    this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));
// 加入逃跑选项
    this._actorCommandWindow.setHandler('escape', this.commandEscape.bind(this));
    this.addWindow(this._actorCommandWindow);
        //this._actorCommandWindow.opacity = 150;

};

Window_ActorCommand.prototype.makeCommandList = function() {
    if (this._actor) {
        this.addAttackCommand();
        this.addSkillCommands();
        this.addGuardCommand();
        this.addItemCommand();
//加入逃跑选项
                this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
    }
};[/pre]

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

Yanfly的逃跑的函数是这个
[pre lang="javascript"]BattleManager.processEscapeATB = function() {
  $gameParty.performEscape();
  SoundManager.playEscape();
  var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
  if (success) {
      $gameParty.removeBattleStates();
      this.displayEscapeSuccessMessage();
      this._escaped = true;
      this.processAbort();
  } else {
      this.displayEscapeFailureMessage();
      this._escapeRatio += this._escapeFailBoost;
      $gameParty.clearActions();
      this.startTurn();
      this.processFailEscapeATB();
  }
  return success;
};[/pre]

然后那个默认的startTurn在ATB模式下是直接被跳过了,没有搞懂到底咋继续的。。。
[pre lang="javascript"]Yanfly.ATB.BattleManager_startTurn = BattleManager.startTurn;
BattleManager.startTurn = function() {
    if (this.isATB()) return;
    Yanfly.ATB.BattleManager_startTurn.call(this);
};[/pre]
梦石
0
星屑
80
在线时间
386 小时
注册时间
2007-7-27
回帖
4075

开拓者

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

原因是
actor->party  party->actor 菜单切换的时候做了一些处理
所以要把这些处理给弄好[pre lang="javascript"]Scene_Battle.prototype.createActorCommandWindow = function() {
  this._actorCommandWindow = new Window_ActorCommand();
  this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
  this._actorCommandWindow.setHandler('skill', this.commandSkill.bind(this));
  this._actorCommandWindow.setHandler('guard', this.commandGuard.bind(this));
  this._actorCommandWindow.setHandler('item', this.commandItem.bind(this));
  //    this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));
  // 加入逃跑选项
  this._actorCommandWindow.setHandler('escape', this.commandEscapeActor.bind(this));
  this.addWindow(this._actorCommandWindow);
  //this._actorCommandWindow.opacity = 150;

};

Scene_Battle.prototype.commandEscapeActor = function() {
  var actorIndex = BattleManager._actorIndex;
  BattleManager.selectNextCommand();
  BattleManager._actorIndex = actorIndex;
  this.commandEscape();
}

Window_ActorCommand.prototype.makeCommandList = function() {
  if (this._actor) {
    this.addAttackCommand();
    this.addSkillCommands();
    this.addGuardCommand();
    this.addItemCommand();
    //加入逃跑选项
    this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  }
};[/pre]

点评

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

评分

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

查看全部评分

吸吸
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部