设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 913|回复: 0
打印 上一主题 下一主题

[已经过期] ARPG如何修改class Scene_Battle才能在地图控件

[复制链接]

Lv4.逐梦者

梦石
0
星屑
6291
在线时间
1103 小时
注册时间
2015-8-15
帖子
658
跳转到指定楼层
1
发表于 2022-11-12 11:43:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. # ■ Scene_Battle
  2. #==============================================================================
  3. class Scene_Battle #类场景_战斗
  4.   #--------------------------------------------------------------------------
  5.   # ● メイン処理●主处理
  6.   #--------------------------------------------------------------------------
  7.   alias xrxs65_main main#主处理名称xrxs65
  8.   def main            #开始主处理
  9.     # エクストラスプライトの初期化 初始化附加精灵
  10.     @extra_sprites = [] if @extra_sprites == nil
  11.     # CP の初期化
  12.     cp_preset_party
  13.     # CP メーターの作成  创建CP仪表
  14.     @cp_meters = CP_Meters.new
  15.     # CP メーターをエクストラスプライトへ登録 将CP仪表注册到附加精灵
  16.     @extra_sprites.push(@cp_meters)
  17.     # 呼び戻す 重新调用
  18.     xrxs65_main
  19.     # メーターの解放 释放仪表
  20.     @cp_meters.dispose
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● プレバトルフェーズ開始
  24.   #--------------------------------------------------------------------------
  25.   alias xrxs65_start_phase1 start_phase1
  26.   def start_phase1
  27.     # 呼び戻す
  28.     xrxs65_start_phase1
  29.     # CP の初期化
  30.     cp_preset_troop
  31.     # CP メーターの更新
  32.     @cp_meters.refresh
  33.     # インデックスを計算
  34.     @cp_escape_actor_command_index = @actor_command_window.height/32 - 1
  35.     # アクターコマンドウィンドウに追加
  36.     @actor_command_window.add_command("逃げる")
  37.     if !$game_temp.battle_can_escape
  38.       @actor_command_window.disable_item(@cp_escape_actor_command_index)
  39.     end
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● パーティコマンドフェーズ開始
  43.   #--------------------------------------------------------------------------
  44.   alias xrxs65_start_phase2 start_phase2
  45.   def start_phase2
  46.     # 呼び戻す
  47.     xrxs65_start_phase2
  48.     # パーティコマンドウィンドウを無効化
  49.     @party_command_window.active  = false
  50.     @party_command_window.visible = false
  51.     # 強制的にフェイズ 2 を保持
  52.     @phase = 2
  53.     # ただし、既に行動可能者が存在する場合は 3 へ
  54.     start_phase3 if anybody_movable?
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ○ CP制での ターンのカウント
  58.   #--------------------------------------------------------------------------
  59.   def cp_turn_count
  60.     $game_temp.battle_turn += 1
  61.     # バトルイベントの全ページを検索
  62.     for index in 0...$data_troops[@troop_id].pages.size
  63.       # このページのスパンが [ターン] の場合
  64.       if $data_troops[@troop_id].pages[index].span == 1
  65.         # 実行済みフラグをクリア
  66.         $game_temp.battle_event_flags[index] = false
  67.       end
  68.     end
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● フレーム更新 (パーティコマンドフェーズ)
  72.   #--------------------------------------------------------------------------
  73.   alias xrxs65_update_phase2 update_phase2
  74.   def update_phase2
  75.     # パーティコマンドウィンドウのインデックスを無効化
  76.     @party_command_window.index = -1
  77.     # 呼び戻す
  78.     xrxs65_update_phase2
  79.     # 例外補正
  80.     @turn_count_time = 1 if @turn_count_time == nil
  81.     # ターンのカウント
  82.     if @turn_count_time > 0
  83.       @turn_count_time -= 1
  84.       if @turn_count_time == 0
  85.         cp_turn_count
  86.         @turn_count_time = XRXS65::CPT if XRXS65::TC == nil
  87.       end
  88.     end
  89.     # CP のフレーム更新
  90.     cp_update
  91.     @cp_meters.refresh
  92.     # フル CP のバトラーが存在する場合、ターン開始
  93.     start_phase3 if anybody_movable?
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ○ フル CP バトラーが存在するか?
  97.   #--------------------------------------------------------------------------
  98.   def anybody_movable?
  99.     for battler in $game_party.actors + $game_troop.enemies
  100.       return true if battler.cp_full?
  101.     end
  102.     return false
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● アクターコマンドウィンドウのセットアップ
  106.   #--------------------------------------------------------------------------
  107.   alias xrxs65_phase3_setup_command_window phase3_setup_command_window
  108.   def phase3_setup_command_window
  109.     # 効果音の再生
  110.     Audio.se_play(XRXS65::COMMAND_UP_SE) rescue nil
  111.     # 呼び戻す
  112.     xrxs65_phase3_setup_command_window
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  116.   #--------------------------------------------------------------------------
  117.   alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
  118.   def update_phase3_basic_command
  119.     # C ボタンが押された場合
  120.     if Input.trigger?(Input::C)
  121.       # アクターコマンドウィンドウのカーソル位置で分岐
  122.       case @actor_command_window.index
  123.       when @cp_escape_actor_command_index # 逃げる
  124.         if $game_temp.battle_can_escape
  125.           # 決定 SE を演奏
  126.           $game_system.se_play($data_system.decision_se)
  127.           # アクションを設定
  128.           @active_battler.current_action.kind = 0
  129.           @active_battler.current_action.basic = 4
  130.           # 次のアクターのコマンド入力へ
  131.           phase3_next_actor
  132.         else
  133.           # ブザー SE を演奏
  134.           $game_system.se_play($data_system.buzzer_se)
  135.         end
  136.         return
  137.       end
  138.     end
  139.     # 呼び戻す
  140.     xrxs_bsp1_update_phase3_basic_command
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● メインフェーズ開始
  144.   #--------------------------------------------------------------------------
  145.   alias xrxs65_start_phase4 start_phase4
  146.   def start_phase4
  147.     # ターン数を引くことによって擬似的にカウントに変化を起こさせない
  148.     $game_temp.battle_turn -= 1
  149.     # フラグを退避
  150.     save_flags = $game_temp.battle_event_flags.dup
  151.     # 呼び戻す
  152.     xrxs65_start_phase4
  153.     # フラグを復旧
  154.     $game_temp.battle_event_flags = save_flags
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 行動順序作成
  158.   #--------------------------------------------------------------------------
  159.   alias xrxs65_make_action_orders make_action_orders
  160.   def make_action_orders
  161.     # 呼び戻す
  162.     xrxs65_make_action_orders
  163.     # CPが不足している場合は @action_battlers から除外する
  164.     for battler in @action_battlers.dup
  165.       @action_battlers.delete(battler) unless battler.cp_full?
  166.     end
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  170.   #--------------------------------------------------------------------------
  171.   alias xrxs65_update_phase4_step2 update_phase4_step2
  172.   def update_phase4_step2
  173.     # ガードの解除
  174.     @active_battler.guarding = false
  175.     # CPの消費
  176.     @active_battler.cp = 0
  177.     # CP メーターの更新
  178.     @cp_meters.refresh
  179.     # 呼び戻す
  180.     xrxs65_update_phase4_step2
  181.     # 例外補正
  182.     return if @active_battler == nil
  183.     # ターンコントローラ
  184.     if @active_battler.is_a?(Game_Enemy) and @active_battler.index == XRXS65::TC
  185.       cp_turn_count
  186.     end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 基本アクション 結果作成
  190.   #--------------------------------------------------------------------------
  191.   alias xrxs65_make_basic_action_result make_basic_action_result
  192.   def make_basic_action_result
  193.     # 呼び戻す
  194.     xrxs65_make_basic_action_result
  195.     # 防御の場合
  196.     if @active_battler.current_action.basic == 1
  197.       @active_battler.guarding = true
  198.       return
  199.     end
  200.     # パーティの逃亡の場合
  201.     if @active_battler.current_action.basic == 4
  202.       # 逃走可能ではない場合
  203.       if $game_temp.battle_can_escape == false
  204.         # ブザー SE を演奏
  205.         $game_system.se_play($data_system.buzzer_se)
  206.         return
  207.       end
  208.       # パーティ全員の CP をクリア
  209.       for actor in $game_party.actors
  210.         actor.cp = 0
  211.       end
  212.       # CP メーターの更新
  213.       @cp_meters.refresh
  214.       # 逃走処理
  215.       update_phase2_escape
  216.       return
  217.     end
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  221.   #--------------------------------------------------------------------------
  222.   alias xrxs65_update_phase4_step5 update_phase4_step5
  223.   def update_phase4_step5
  224.     # 呼び戻す
  225.     xrxs65_update_phase4_step5
  226.     # CP メーターの更新
  227.     @cp_meters.refresh
  228.   end
  229. end
  230. #==============================================================================
  231. # --- CP メーターをまとめて管理するクラス、表示関係はすべてココ ---
  232. #==============================================================================
  233. class CP_Meters
  234.   #--------------------------------------------------------------------------
  235.   # ○ オブジェクト初期化
  236.   #--------------------------------------------------------------------------
  237.   def initialize
  238.     # メーター群の生成
  239.     @meters = []
  240.     for i in 0...$game_party.actors.size
  241.       make_meter(i)
  242.     end
  243.     refresh
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ○ リフレッシュ
  247.   #--------------------------------------------------------------------------
  248.   def refresh
  249.     # 戦闘メンバー数の変更を判別
  250.     for i in @meters.size...$game_party.actors.size
  251.       make_meter(i)
  252.     end
  253.     for i in $game_party.actors.size...@meters.size
  254.       @meters[i].dispose
  255.       @meters[i] = nil
  256.     end
  257.     @meters.compact!
  258.     # 表示更新
  259.     for i in 0...$game_party.actors.size
  260.       actor = $game_party.actors[i]
  261.       @meters[i].line   = actor.cp_linetype
  262.       @meters[i].amount = actor.cp_lineamount
  263.     end
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ○ メーターひとつの生成
  267.   #--------------------------------------------------------------------------
  268.   def make_meter(i)
  269.     # スキンの取得
  270.     skin = RPG::Cache.windowskin(XRXS65::SKIN)
  271.     #
  272.     space = 640 / XRXS65::MAX
  273.     case XRXS65::ALIGN
  274.     when 0
  275.       actor_x = i * space + 4
  276.     when 1
  277.       actor_x = (space * ((XRXS65::MAX - $game_party.actors.size)/2.0 + i)).floor
  278.     when 2
  279.       actor_x = (i + XRXS65::MAX - $game_party.actors.size) * space + 4
  280.     end
  281.     meter = MeterSprite.new(skin, XRXS65::LINE_HEIGHT)
  282.     meter.x = actor_x + XRXS65::X_OFFSET - skin.width
  283.     meter.y = XRXS65::Y_OFFSET
  284.     @meters[i] = meter
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ○ 可視状態
  288.   #--------------------------------------------------------------------------
  289.   def visible=(b)
  290.     @meters.each{|sprite| sprite.visible = b }
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ○ 解放
  294.   #--------------------------------------------------------------------------
  295.   def dispose
  296.     @meters.each{|sprite| sprite.dispose }
  297.   end
  298. end
  299. #==============================================================================
  300. # --- XRXS. レクタンギュラーメーター表示・極 ---
  301. #==============================================================================
  302. class MeterSprite < Sprite
  303.   #--------------------------------------------------------------------------
  304.   # ○ オブジェクト初期化
  305.   #--------------------------------------------------------------------------
  306.   def initialize(skin, line_height)
  307.     @skin   = skin
  308.     @width  = @skin.width
  309.     @height = line_height
  310.     @line   = 1
  311.     @amount = 0
  312.     @base_sprite = Sprite.new
  313.     @base_sprite.bitmap = @skin
  314.     @base_sprite.src_rect.set(0, 0, @width, @height)
  315.     @base_sprite.z = 601
  316.     super()
  317.     self.z = @base_sprite.z + 1
  318.     self.bitmap = @skin
  319.     self.line = 1
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ○ 値の設定
  323.   #--------------------------------------------------------------------------
  324.   def line=(n)
  325.     @line = n
  326.     refresh
  327.   end
  328.   def amount=(n)
  329.     @amount = n
  330.     refresh
  331.   end
  332.   def refresh
  333.     self.src_rect.set(0, @line * @height, @width * @amount / 100, @height)
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ○ 座標の設定
  337.   #--------------------------------------------------------------------------
  338.   def x=(n)
  339.     super
  340.     @base_sprite.x = n
  341.   end
  342.   def y=(n)
  343.     super
  344.     @base_sprite.y = n
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ○ 解放
  348.   #--------------------------------------------------------------------------
  349.   def dispose
  350.     @base_sprite.dispose
  351.     super
  352.   end
  353. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-28 07:46

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表