查看: 3216|回复: 5

[已经解决] 求助 怎么在战斗菜单中加入自动战斗

[复制链接]
梦石
0
星屑
62
在线时间
44 小时
注册时间
2015-5-11
回帖
23
发表于 2015-12-31 10:51:26 | 显示全部楼层 |阅读模式

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

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

×
战斗场景  指令有1战斗 2撤退   怎么在1战斗前 加一个自动战斗的指令   确定了自动战斗指令后将进行自动战斗  玩家不能操作战斗 直到战斗结束为止
梦石
0
星屑
9823
在线时间
1648 小时
注册时间
2012-6-6
回帖
306
发表于 2015-12-31 17:02:32 | 显示全部楼层
[pre lang="ruby"]#==============================================================================
# ■ Vocab
#------------------------------------------------------------------------------
#  用語とメッセージを定義するモジュールです。定数でメッセージなどを直接定義す
# るほか、グローバル変数 $data_system から用語データを取得します。
#==============================================================================
module Vocab
  # 戦闘
  Auto         = "自动"
end

#==============================================================================
# ■ Window_PartyCommand
#------------------------------------------------------------------------------
#  バトル画面で、戦うか逃げるかを選択するウィンドウです。
#==============================================================================
class Window_PartyCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  alias make_command_list_auto make_command_list
  def make_command_list
    make_command_list_auto
    add_command(Vocab::Auto,   :auto)
  end  
end

#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● パーティコマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias create_party_command_window_auto create_party_command_window
  def create_party_command_window
    create_party_command_window_auto
    @party_command_window.set_handler(:auto, method(:command_auto))
    @party_command_window.unselect
  end
  #--------------------------------------------------------------------------
  # ● コマンド[オート]
  #--------------------------------------------------------------------------
  def command_auto
    BattleManager.auto_on
    BattleManager.skip_on
    auto_set
    turn_start
  end
  #--------------------------------------------------------------------------
  # ● 早送り判定
  #--------------------------------------------------------------------------
  def show_fast?
    return true if BattleManager.skip?
    return true if Input.press?(:B) || Input.press?(:C)
    return false
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新(基本)
  #--------------------------------------------------------------------------
  alias update_basic2 update_basic
  def update_basic
    update_basic2
    update_auto_battle
  end
  #--------------------------------------------------------------------------
  # ● オート戦闘の更新
  #--------------------------------------------------------------------------
  def update_auto_battle
    BattleManager.auto_off if Input.press?(:B)
  end
  #--------------------------------------------------------------------------
  # ● オート戦闘のセット
  #--------------------------------------------------------------------------
  def auto_set
    BattleManager.input_start   
    loop do
      break unless BattleManager.next_command
      BattleManager.actor.input.set_attack
    end
  end
  #--------------------------------------------------------------------------
  # ● パーティコマンド選択の開始
  #--------------------------------------------------------------------------
  alias start_party_command_selection2 start_party_command_selection
  def start_party_command_selection
    if BattleManager.auto?
      @party_command_window.deactivate
      auto_set
      turn_start
      return
    end
    BattleManager.skip_off
    start_party_command_selection2
  end
  
  #--------------------------------------------------------------------------
  # ● アニメーションの表示
  #     targets      : 対象者の配列
  #     animation_id : アニメーション ID(-1: 通常攻撃と同じ)
  #--------------------------------------------------------------------------
  def show_animation(targets, animation_id)
    unless anim_skip?
      if animation_id < 0
        show_attack_animation(targets)
      else
        show_normal_animation(targets, animation_id)
      end
    end
    @log_window.wait
    wait_for_animation unless anim_skip?
  end
  #--------------------------------------------------------------------------
  # ● アニメーションをスキップするか?
  #--------------------------------------------------------------------------
  def anim_skip?
    BattleManager.auto?
  end
  
end

#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
#  戦闘の進行を管理するモジュールです。
#==============================================================================
module BattleManager
  #--------------------------------------------------------------------------
  # ● メンバ変数の初期化
  #--------------------------------------------------------------------------
  def self.init_members
    @phase = :init              # 戦闘進行フェーズ
    @can_escape = false         # 逃走可能フラグ
    @can_lose = false           # 敗北可能フラグ
    @event_proc = nil           # イベント用コールバック
    @preemptive = false         # 先制攻撃フラグ
    @surprise = false           # 不意打ちフラグ
    @actor_index = -1           # コマンド入力中のアクター
    @action_forced = nil        # 戦闘行動の強制
    @map_bgm = nil              # 戦闘前の BGM 記憶用
    @map_bgs = nil              # 戦闘前の BGS 記憶用
    @action_battlers = []       # 行動順序リスト
    @auto_flg = false           # オート戦闘フラグ
    @turn_skip = false          # このターンをスキップするか
  end
  #--------------------------------------------------------------------------
  # ● オート・オン
  #--------------------------------------------------------------------------
  def self.auto_on
    @auto_flg = true
  end
  #--------------------------------------------------------------------------
  # ● オート・オフ
  #--------------------------------------------------------------------------
  def self.auto_off
    @auto_flg = false
  end
  #--------------------------------------------------------------------------
  # ● オートか?
  #--------------------------------------------------------------------------
  def self.auto?
    @auto_flg
  end
  #--------------------------------------------------------------------------
  # ● ターンをスキップする
  #--------------------------------------------------------------------------
  def self.skip_on
    @turn_skip = true
  end
  #--------------------------------------------------------------------------
  # ● ターンをスキップしない
  #--------------------------------------------------------------------------
  def self.skip_off
    @turn_skip = false  
  end
  #--------------------------------------------------------------------------
  # ● スキップ状態か?
  #--------------------------------------------------------------------------
  def self.skip?
    @turn_skip
  end
  
end
[/pre]

点评

现在的答复回报才200jy,真是小气,对吗,层主?  发表于 2016-8-21 16:26

评分

参与人数 1星屑 +200 收起 理由
taroxd + 200 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
9823
在线时间
1648 小时
注册时间
2012-6-6
回帖
306
发表于 2015-12-31 17:03:31 | 显示全部楼层
拿去试试,我想应该可以吧
回复

使用道具 举报

梦石
0
星屑
62
在线时间
44 小时
注册时间
2015-5-11
回帖
23
 楼主| 发表于 2015-12-31 19:09:20 | 显示全部楼层
流浪杰哥 发表于 2015-12-31 17:03
拿去试试,我想应该可以吧

多谢了 ,非常有用,太有才了,我想做个补充,能否让战斗速度提升一倍,这样等待结束的时间就会更短
回复

使用道具 举报

梦石
0
星屑
50
在线时间
21 小时
注册时间
2014-11-27
回帖
4
发表于 2016-8-17 11:10:18 | 显示全部楼层
流浪杰哥 发表于 2015-12-31 17:02
#==============================================================================
# ■ Vocab
#-------- ...

为什么我复制后用不了啊 好像是注释无效 手动注释也注释不了
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部