查看: 2017|回复: 5

[已经过期] 想将Window_BattleStatus向上移动

[复制链接]
梦石
0
星屑
251
在线时间
252 小时
注册时间
2013-11-9
回帖
88
发表于 2016-9-17 11:14:29 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 泪的苍白 于 2016-9-17 11:27 编辑

不是单纯的调整y值。
想弄成的功能是:当某角色进行指令时,其状态窗口向上移动20个像素;当角色指令结束后,状态窗口又会移回去。
在Scene_Battle 3里phase3_setup_command_window的地方添加了
  1. @status_window.move_window(@actor_index, 6)
复制代码

在Window_BattleStatus里也写了  
  1. def move_window(index, move_y = 0)
  2.     @actor_status_window[index].y += move_y
  3.   end
复制代码

但是会出现“NoMethodError”的错误,想知道为什么会出现这样的情况。
如果这么写错误的话又应该要怎么写才对。
初学脚本比较蠢,很多东西半懂不懂的,所以麻烦了。

点评

move_y 是什么鬼?  发表于 2016-9-25 17:49
头像来自百度搜索,自改了一(小)部分。
梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2016-9-17 12:38:41 | 显示全部楼层
本帖最后由 2357691704 于 2016-9-17 12:41 编辑

成功了,修改的地方已经标注。
GAME_TEMP
  1. #==============================================================================
  2. # ■ Game_Temp
  3. #------------------------------------------------------------------------------
  4. #  在没有存档的情况下,处理临时数据的类。这个类的实例请参考
  5. # $game_temp 。
  6. #==============================================================================

  7. class Game_Temp
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_accessor :map_bgm                  # 地图画面 BGM (战斗时记忆用)
  12.   attr_accessor :message_text             # 信息文章
  13.   attr_accessor :message_proc             # 信息 返回调用 (Proc)
  14.   attr_accessor :choice_start             # 选择项 开始行
  15.   attr_accessor :choice_max               # 选择项 项目数
  16.   attr_accessor :choice_cancel_type       # 选择项 取消的情况
  17.   attr_accessor :choice_proc              # 选择项 返回调用 (Proc)
  18.   attr_accessor :num_input_start          # 输入数值 开始行
  19.   attr_accessor :num_input_variable_id    # 输入数值 变量 ID
  20.   attr_accessor :num_input_digits_max     # 输入数值 位数
  21.   attr_accessor :message_window_showing   # 显示信息窗口
  22.   attr_accessor :common_event_id          # 公共事件 ID
  23.   attr_accessor :in_battle                # 战斗中的标志
  24.   attr_accessor :battle_calling           # 调用战斗的标志
  25.   attr_accessor :battle_troop_id          # 战斗 队伍 ID
  26.   attr_accessor :battle_can_escape        # 战斗中 允许逃跑 ID
  27.   attr_accessor :battle_can_lose          # 战斗中 允许失败 ID
  28.   attr_accessor :battle_proc              # 战斗 返回调用 (Proc)
  29.   attr_accessor :battle_turn              # 战斗 回合数
  30.   attr_accessor :battle_event_flags       # 战斗 事件执行执行完毕的标志
  31.   attr_accessor :battle_abort             # 战斗 中断标志
  32.   attr_accessor :battle_main_phase        # 战斗 状态标志
  33.   #################################
  34.   attr_accessor :battle_main_phase2       # 战斗 回合标志
  35.   #################################
  36.   attr_accessor :battleback_name          # 战斗背景 文件名
  37.   attr_accessor :forcing_battler          # 强制行动的战斗者
  38.   attr_accessor :shop_calling             # 调用商店的标志
  39.   attr_accessor :shop_goods               # 商店 商品列表
  40.   attr_accessor :name_calling             # 输入名称 调用标志
  41.   attr_accessor :name_actor_id            # 输入名称 角色 ID
  42.   attr_accessor :name_max_char            # 输入名称 最大字数
  43.   attr_accessor :menu_calling             # 菜单 调用标志
  44.   attr_accessor :menu_beep                # 菜单 SE 演奏标志
  45.   attr_accessor :save_calling             # 存档 调用标志
  46.   attr_accessor :debug_calling            # 调试 调用标志
  47.   attr_accessor :player_transferring      # 主角 场所移动标志
  48.   attr_accessor :player_new_map_id        # 主角 移动目标地图 ID
  49.   attr_accessor :player_new_x             # 主角 移动目标 X 坐标
  50.   attr_accessor :player_new_y             # 主角 移动目标 Y 坐标
  51.   attr_accessor :player_new_direction     # 主角 移动目标 朝向
  52.   attr_accessor :transition_processing    # 过渡处理中标志
  53.   attr_accessor :transition_name          # 过渡 文件名
  54.   attr_accessor :gameover                 # 游戏结束标志
  55.   attr_accessor :to_title                 # 返回标题画面标志
  56.   attr_accessor :last_file_index          # 最后存档的文件编号
  57.   attr_accessor :debug_top_row            # 调试画面 保存状态用
  58.   attr_accessor :debug_index              # 调试画面 保存状态用
  59.   #--------------------------------------------------------------------------
  60.   # ● 初始化对像
  61.   #--------------------------------------------------------------------------
  62.   def initialize
  63.     @map_bgm = nil
  64.     @message_text = nil
  65.     @message_proc = nil
  66.     @choice_start = 99
  67.     @choice_max = 0
  68.     @choice_cancel_type = 0
  69.     @choice_proc = nil
  70.     @num_input_start = 99
  71.     @num_input_variable_id = 0
  72.     @num_input_digits_max = 0
  73.     @message_window_showing = false
  74.     @common_event_id = 0
  75.     @in_battle = false
  76.     @battle_calling = false
  77.     @battle_troop_id = 0
  78.     @battle_can_escape = false
  79.     @battle_can_lose = false
  80.     @battle_proc = nil
  81.     @battle_turn = 0
  82.     @battle_event_flags = {}
  83.     @battle_abort = false
  84.     @battle_main_phase = false
  85.     ###########################
  86.     @battle_main_phase2 = false
  87.     ###########################
  88.     @battleback_name = ''
  89.     @forcing_battler = nil
  90.     @shop_calling = false
  91.     @shop_id = 0
  92.     @name_calling = false
  93.     @name_actor_id = 0
  94.     @name_max_char = 0
  95.     @menu_calling = false
  96.     @menu_beep = false
  97.     @save_calling = false
  98.     @debug_calling = false
  99.     @player_transferring = false
  100.     @player_new_map_id = 0
  101.     @player_new_x = 0
  102.     @player_new_y = 0
  103.     @player_new_direction = 0
  104.     @transition_processing = false
  105.     @transition_name = ""
  106.     @gameover = false
  107.     @to_title = false
  108.     @last_file_index = 0
  109.     @debug_top_row = 0
  110.     @debug_index = 0
  111.   end
  112. end
复制代码

Window_BattleStatus
  1. #==============================================================================
  2. # ■ Window_BattleStatus
  3. #------------------------------------------------------------------------------
  4. #  显示战斗画面同伴状态的窗口。
  5. #==============================================================================

  6. class Window_BattleStatus < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 320, 640, 160)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     @level_up_flags = [false, false, false, false]
  14.     refresh
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 释放
  18.   #--------------------------------------------------------------------------
  19.   def dispose
  20.     super
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 设置升级标志
  24.   #     actor_index : 角色索引
  25.   #--------------------------------------------------------------------------
  26.   def level_up(actor_index)
  27.     @level_up_flags[actor_index] = true
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● 刷新
  31.   #--------------------------------------------------------------------------
  32.   def refresh
  33.     self.contents.clear
  34.     @item_max = $game_party.actors.size
  35.     for i in 0...$game_party.actors.size
  36.       actor = $game_party.actors[i]
  37.       actor_x = i * 160 + 4
  38.       draw_actor_name(actor, actor_x, 0)
  39.       draw_actor_hp(actor, actor_x, 32, 120)
  40.       draw_actor_sp(actor, actor_x, 64, 120)
  41.       if @level_up_flags[i]
  42.         self.contents.font.color = normal_color
  43.         self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
  44.       else
  45.         draw_actor_state(actor, actor_x, 96)
  46.       end
  47.     end
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 刷新画面
  51.   #--------------------------------------------------------------------------
  52.   def update
  53.     super
  54.     ###################################################
  55.     # 主界面的不透明度下降
  56.     if $game_temp.battle_main_phase
  57.       self.contents_opacity -= 4 if self.contents_opacity > 191
  58.     elsif $game_temp.battle_main_phase2
  59.       self.y = 300 #向上移动20像素
  60.       else
  61.       self.contents_opacity += 4 if self.contents_opacity < 255
  62.     self.y = 320
  63.     ####################################################
  64.     end
  65.   end
  66. end
复制代码

scene_battle 3
  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 3)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================

  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # ● 开始角色命令回合
  9.   #--------------------------------------------------------------------------
  10.   def start_phase3
  11.     # 转移到回合 3
  12.     @phase = 3
  13.     # 设置角色为非选择状态
  14.     @actor_index = -1
  15.     @active_battler = nil
  16.     # 输入下一个角色的命令
  17.     phase3_next_actor
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 转到输入下一个角色的命令
  21.   #--------------------------------------------------------------------------
  22.   def phase3_next_actor
  23.     # 循环
  24.     begin
  25.       # 角色的明灭效果 OFF
  26.       if @active_battler != nil
  27.         @active_battler.blink = false
  28.       end
  29.       # 最后的角色的情况
  30.       if @actor_index == $game_party.actors.size-1
  31.         # 开始主回合
  32.         start_phase4
  33.         return
  34.       end
  35.       # 推进角色索引
  36.       @actor_index += 1
  37.       @active_battler = $game_party.actors[@actor_index]
  38.       @active_battler.blink = true
  39.     # 如果角色是在无法接受指令的状态就再试
  40.     end until @active_battler.inputable?
  41.     # 设置角色的命令窗口
  42.     phase3_setup_command_window
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 转向前一个角色的命令输入
  46.   #--------------------------------------------------------------------------
  47.   def phase3_prior_actor
  48.     # 循环
  49.     begin
  50.       # 角色的明灭效果 OFF
  51.       if @active_battler != nil
  52.         @active_battler.blink = false
  53.       end
  54.       # 最初的角色的情况下
  55.       if @actor_index == 0
  56.         # 开始同伴指令回合
  57.         start_phase2
  58.     #####################################
  59.     $game_temp.battle_main_phase2 = false
  60.     #####################################
  61.         return
  62.       end
  63.       # 返回角色索引
  64.       @actor_index -= 1
  65.       @active_battler = $game_party.actors[@actor_index]
  66.       @active_battler.blink = true
  67.     # 如果角色是在无法接受指令的状态就再试
  68.     end until @active_battler.inputable?
  69.     # 设置角色的命令窗口
  70.     phase3_setup_command_window
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 设置角色指令窗口
  74.   #--------------------------------------------------------------------------
  75.   def phase3_setup_command_window
  76.     # 同伴指令窗口无效化
  77.     @party_command_window.active = false
  78.     @party_command_window.visible = false
  79.     # 角色指令窗口无效化
  80.     @actor_command_window.active = true
  81.     @actor_command_window.visible = true
  82.     #####################################
  83.     $game_temp.battle_main_phase2 = true
  84.     ####################################
  85.     # 设置角色指令窗口的位置
  86.     @actor_command_window.x = @actor_index * 160
  87.     # 设置索引为 0
  88.     @actor_command_window.index = 0
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 刷新画面 (角色命令回合)
  92.   #--------------------------------------------------------------------------
  93.   def update_phase3
  94.     # 敌人光标有效的情况下
  95.     if @enemy_arrow != nil
  96.       update_phase3_enemy_select
  97.     # 角色光标有效的情况下
  98.     elsif @actor_arrow != nil
  99.       update_phase3_actor_select
  100.     # 特技窗口有效的情况下
  101.     elsif @skill_window != nil
  102.       update_phase3_skill_select
  103.     # 物品窗口有效的情况下
  104.     elsif @item_window != nil
  105.       update_phase3_item_select
  106.     # 角色指令窗口有效的情况下
  107.     elsif @actor_command_window.active
  108.       update_phase3_basic_command
  109.     end
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 刷新画面 (角色命令回合 : 基本命令)
  113.   #--------------------------------------------------------------------------
  114.   def update_phase3_basic_command
  115.     # 按下 B 键的情况下
  116.     if Input.trigger?(Input::B)
  117.       # 演奏取消 SE
  118.       $game_system.se_play($data_system.cancel_se)
  119.       # 转向前一个角色的指令输入
  120.       phase3_prior_actor
  121.       return
  122.     end
  123.     # 按下 C 键的情况下
  124.     if Input.trigger?(Input::C)
  125.     #####################################
  126.     $game_temp.battle_main_phase2 = false
  127.     #####################################
  128.       # 角色指令窗口光标位置分之
  129.       case @actor_command_window.index
  130.       when 0  # 攻击
  131.         # 演奏确定 SE
  132.         $game_system.se_play($data_system.decision_se)
  133.         # 设置行动
  134.         @active_battler.current_action.kind = 0
  135.         @active_battler.current_action.basic = 0
  136.         # 开始选择敌人
  137.         start_enemy_select
  138.       when 1  # 特技
  139.         # 演奏确定 SE
  140.         $game_system.se_play($data_system.decision_se)
  141.         # 设置行动
  142.         @active_battler.current_action.kind = 1
  143.         # 开始选择特技
  144.         start_skill_select
  145.       when 2  # 防御
  146.         # 演奏确定 SE
  147.         $game_system.se_play($data_system.decision_se)
  148.         # 设置行动
  149.         @active_battler.current_action.kind = 0
  150.         @active_battler.current_action.basic = 1
  151.         # 转向下一位角色的指令输入
  152.         phase3_next_actor
  153.       when 3  # 物品
  154.         # 演奏确定 SE
  155.         $game_system.se_play($data_system.decision_se)
  156.         # 设置行动
  157.         @active_battler.current_action.kind = 2
  158.         # 开始选择物品
  159.         start_item_select
  160.       end
  161.       return
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 刷新画面 (角色命令回合 : 选择特技)
  166.   #--------------------------------------------------------------------------
  167.   def update_phase3_skill_select
  168.     # 设置特技窗口为可视状态
  169.     @skill_window.visible = true
  170.     # 刷新特技窗口
  171.     @skill_window.update
  172.     # 按下 B 键的情况下
  173.     if Input.trigger?(Input::B)
  174.       # 演奏取消 SE
  175.       $game_system.se_play($data_system.cancel_se)
  176.       # 结束特技选择
  177.       end_skill_select
  178.       return
  179.     end
  180.     # 按下 C 键的情况下
  181.     if Input.trigger?(Input::C)
  182.       # 获取特技选择窗口现在选择的特技的数据
  183.       @skill = @skill_window.skill
  184.       # 无法使用的情况下
  185.       if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
  186.         # 演奏冻结 SE
  187.         $game_system.se_play($data_system.buzzer_se)
  188.         return
  189.       end
  190.       # 演奏确定 SE
  191.       $game_system.se_play($data_system.decision_se)
  192.       # 设置行动
  193.       @active_battler.current_action.skill_id = @skill.id
  194.       # 设置特技窗口为不可见状态
  195.       @skill_window.visible = false
  196.       # 效果范围是敌单体的情况下
  197.       if @skill.scope == 1
  198.         # 开始选择敌人
  199.         start_enemy_select
  200.       # 效果范围是我方单体的情况下
  201.       elsif @skill.scope == 3 or @skill.scope == 5
  202.         # 开始选择角色
  203.         start_actor_select
  204.       # 效果范围不是单体的情况下
  205.       else
  206.         # 选择特技结束
  207.         end_skill_select
  208.         # 转到下一位角色的指令输入
  209.         phase3_next_actor
  210.       end
  211.       return
  212.     end
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ● 刷新画面 (角色命令回合 : 选择物品)
  216.   #--------------------------------------------------------------------------
  217.   def update_phase3_item_select
  218.     # 设置物品窗口为可视状态
  219.     @item_window.visible = true
  220.     # 刷新物品窗口
  221.     @item_window.update
  222.     # 按下 B 键的情况下
  223.     if Input.trigger?(Input::B)
  224.       # 演奏取消 SE
  225.       $game_system.se_play($data_system.cancel_se)
  226.       # 选择物品结束
  227.       end_item_select
  228.       return
  229.     end
  230.     # 按下 C 键的情况下
  231.     if Input.trigger?(Input::C)
  232.       # 获取物品窗口现在选择的物品资料
  233.       @item = @item_window.item
  234.       # 无法使用的情况下
  235.       unless $game_party.item_can_use?(@item.id)
  236.         # 演奏冻结 SE
  237.         $game_system.se_play($data_system.buzzer_se)
  238.         return
  239.       end
  240.       # 演奏确定 SE
  241.       $game_system.se_play($data_system.decision_se)
  242.       # 设置行动
  243.       @active_battler.current_action.item_id = @item.id
  244.       # 设置物品窗口为不可见状态
  245.       @item_window.visible = false
  246.       # 效果范围是敌单体的情况下
  247.       if @item.scope == 1
  248.         # 开始选择敌人
  249.         start_enemy_select
  250.       # 效果范围是我方单体的情况下
  251.       elsif @item.scope == 3 or @item.scope == 5
  252.         # 开始选择角色
  253.         start_actor_select
  254.       # 效果范围不是单体的情况下
  255.       else
  256.         # 物品选择结束
  257.         end_item_select
  258.         # 转到下一位角色的指令输入
  259.         phase3_next_actor
  260.       end
  261.       return
  262.     end
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● 刷新画面画面 (角色命令回合 : 选择敌人)
  266.   #--------------------------------------------------------------------------
  267.   def update_phase3_enemy_select
  268.     # 刷新敌人箭头
  269.     @enemy_arrow.update
  270.     # 按下 B 键的情况下
  271.     if Input.trigger?(Input::B)
  272.       # 演奏取消 SE
  273.       $game_system.se_play($data_system.cancel_se)
  274.       # 选择敌人结束
  275.       end_enemy_select
  276.       return
  277.     end
  278.     # 按下 C 键的情况下
  279.     if Input.trigger?(Input::C)
  280.       # 演奏确定 SE
  281.       $game_system.se_play($data_system.decision_se)
  282.       # 设置行动
  283.       @active_battler.current_action.target_index = @enemy_arrow.index
  284.       # 选择敌人结束
  285.       end_enemy_select
  286.       # 显示特技窗口中的情况下
  287.       if @skill_window != nil
  288.         # 结束特技选择
  289.         end_skill_select
  290.       end
  291.       # 显示物品窗口的情况下
  292.       if @item_window != nil
  293.         # 结束物品选择
  294.         end_item_select
  295.       end
  296.       # 转到下一位角色的指令输入
  297.       phase3_next_actor
  298.     end
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ● 画面更新 (角色指令回合 : 选择角色)
  302.   #--------------------------------------------------------------------------
  303.   def update_phase3_actor_select
  304.     # 刷新角色箭头
  305.     @actor_arrow.update
  306.     # 按下 B 键的情况下
  307.     if Input.trigger?(Input::B)
  308.       # 演奏取消 SE
  309.       $game_system.se_play($data_system.cancel_se)
  310.       # 选择角色结束
  311.       end_actor_select
  312.       return
  313.     end
  314.     # 按下 C 键的情况下
  315.     if Input.trigger?(Input::C)
  316.       # 演奏确定 SE
  317.       $game_system.se_play($data_system.decision_se)
  318.       # 设置行动
  319.       @active_battler.current_action.target_index = @actor_arrow.index
  320.       # 选择角色结束
  321.       end_actor_select
  322.       # 显示特技窗口中的情况下
  323.       if @skill_window != nil
  324.         # 结束特技选择
  325.         end_skill_select
  326.       end
  327.       # 显示物品窗口的情况下
  328.       if @item_window != nil
  329.         # 结束物品选择
  330.         end_item_select
  331.       end
  332.       # 转到下一位角色的指令输入
  333.       phase3_next_actor
  334.     end
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 开始选择敌人
  338.   #--------------------------------------------------------------------------
  339.   def start_enemy_select
  340.     # 生成敌人箭头
  341.     @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
  342.     # 关联帮助窗口
  343.     @enemy_arrow.help_window = @help_window
  344.     # 无效化角色指令窗口
  345.     @actor_command_window.active = false
  346.     @actor_command_window.visible = false
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● 结束选择敌人
  350.   #--------------------------------------------------------------------------
  351.   def end_enemy_select
  352.     # 释放敌人箭头
  353.     @enemy_arrow.dispose
  354.     @enemy_arrow = nil
  355.     # 指令为 [战斗] 的情况下
  356.     if @actor_command_window.index == 0
  357.       # 有效化角色指令窗口
  358.       @actor_command_window.active = true
  359.       @actor_command_window.visible = true
  360.       # 隐藏帮助窗口
  361.       @help_window.visible = false
  362.     end
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 开始选择角色
  366.   #--------------------------------------------------------------------------
  367.   def start_actor_select
  368.     # 生成角色箭头
  369.     @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
  370.     @actor_arrow.index = @actor_index
  371.     # 关联帮助窗口
  372.     @actor_arrow.help_window = @help_window
  373.     # 无效化角色指令窗口
  374.     @actor_command_window.active = false
  375.     @actor_command_window.visible = false
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # ● 结束选择角色
  379.   #--------------------------------------------------------------------------
  380.   def end_actor_select
  381.     # 释放角色箭头
  382.     @actor_arrow.dispose
  383.     @actor_arrow = nil
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ● 开始选择特技
  387.   #--------------------------------------------------------------------------
  388.   def start_skill_select
  389.     # 生成特技窗口
  390.     @skill_window = Window_Skill.new(@active_battler)
  391.     # 关联帮助窗口
  392.     @skill_window.help_window = @help_window
  393.     # 无效化角色指令窗口
  394.     @actor_command_window.active = false
  395.     @actor_command_window.visible = false
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 选择特技结束
  399.   #--------------------------------------------------------------------------
  400.   def end_skill_select
  401.     # 释放特技窗口
  402.     @skill_window.dispose
  403.     @skill_window = nil
  404.     # 隐藏帮助窗口
  405.     @help_window.visible = false
  406.     # 有效化角色指令窗口
  407.     @actor_command_window.active = true
  408.     @actor_command_window.visible = true
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # ● 开始选择物品
  412.   #--------------------------------------------------------------------------
  413.   def start_item_select
  414.     # 生成物品窗口
  415.     @item_window = Window_Item.new
  416.     # 关联帮助窗口
  417.     @item_window.help_window = @help_window
  418.     # 无效化角色指令窗口
  419.     @actor_command_window.active = false
  420.     @actor_command_window.visible = false
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   # ● 结束选择物品
  424.   #--------------------------------------------------------------------------
  425.   def end_item_select
  426.     # 释放物品窗口
  427.     @item_window.dispose
  428.     @item_window = nil
  429.     # 隐藏帮助窗口
  430.     @help_window.visible = false
  431.     # 有效化角色指令窗口
  432.     @actor_command_window.active = true
  433.     @actor_command_window.visible = true
  434.   end
  435. end
复制代码

scene_battle 4
  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 4)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================

  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # ● 开始主回合
  9.   #--------------------------------------------------------------------------
  10.   def start_phase4
  11.     # 转移到回合 4
  12.     @phase = 4
  13.     # 回合数计数
  14.     $game_temp.battle_turn += 1
  15.     # 搜索全页的战斗事件
  16.     for index in 0...$data_troops[@troop_id].pages.size
  17.       # 获取事件页
  18.       page = $data_troops[@troop_id].pages[index]
  19.       # 本页的范围是 [回合] 的情况下
  20.       if page.span == 1
  21.         # 设置已经执行标志
  22.         $game_temp.battle_event_flags[index] = false
  23.       end
  24.     end
  25.     # 设置角色为非选择状态
  26.     @actor_index = -1
  27.     @active_battler = nil
  28.     # 有效化同伴指令窗口
  29.     @party_command_window.active = false
  30.     @party_command_window.visible = false
  31.     # 无效化角色指令窗口
  32.     @actor_command_window.active = false
  33.     @actor_command_window.visible = false
  34.     #####################################
  35.     $game_temp.battle_main_phase2 = false
  36.     #####################################
  37.     # 设置主回合标志
  38.     $game_temp.battle_main_phase = true
  39.     # 生成敌人行动
  40.     for enemy in $game_troop.enemies
  41.       enemy.make_action
  42.     end
  43.     # 生成行动顺序
  44.     make_action_orders
  45.     # 移动到步骤 1
  46.     @phase4_step = 1
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ● 生成行动循序
  50.   #--------------------------------------------------------------------------
  51.   def make_action_orders
  52.     # 初始化序列 @action_battlers
  53.     @action_battlers = []
  54.     # 添加敌人到 @action_battlers 序列
  55.     for enemy in $game_troop.enemies
  56.       @action_battlers.push(enemy)
  57.     end
  58.     # 添加角色到 @action_battlers 序列
  59.     for actor in $game_party.actors
  60.       @action_battlers.push(actor)
  61.     end
  62.     # 确定全体的行动速度
  63.     for battler in @action_battlers
  64.       battler.make_action_speed
  65.     end
  66.     # 按照行动速度从大到小排列
  67.     @action_battlers.sort! {|a,b|
  68.       b.current_action.speed - a.current_action.speed }
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 刷新画面 (主回合)
  72.   #--------------------------------------------------------------------------
  73.   def update_phase4
  74.     case @phase4_step
  75.     when 1
  76.       update_phase4_step1
  77.     when 2
  78.       update_phase4_step2
  79.     when 3
  80.       update_phase4_step3
  81.     when 4
  82.       update_phase4_step4
  83.     when 5
  84.       update_phase4_step5
  85.     when 6
  86.       update_phase4_step6
  87.     end
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● 刷新画面 (主回合步骤 1 : 准备行动)
  91.   #--------------------------------------------------------------------------
  92.   def update_phase4_step1
  93.     # 隐藏帮助窗口
  94.     @help_window.visible = false
  95.     # 判定胜败
  96.     if judge
  97.       # 胜利或者失败的情况下 : 过程结束
  98.       return
  99.     end
  100.     # 强制行动的战斗者不存在的情况下
  101.     if $game_temp.forcing_battler == nil
  102.       # 设置战斗事件
  103.       setup_battle_event
  104.       # 执行战斗事件中的情况下
  105.       if $game_system.battle_interpreter.running?
  106.         return
  107.       end
  108.     end
  109.     # 强制行动的战斗者存在的情况下
  110.     if $game_temp.forcing_battler != nil
  111.       # 在头部添加后移动
  112.       @action_battlers.delete($game_temp.forcing_battler)
  113.       @action_battlers.unshift($game_temp.forcing_battler)
  114.     end
  115.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  116.     if @action_battlers.size == 0
  117.       # 开始同伴命令回合
  118.       start_phase2
  119.       return
  120.     end
  121.     # 初始化动画 ID 和公共事件 ID
  122.     @animation1_id = 0
  123.     @animation2_id = 0
  124.     @common_event_id = 0
  125.     # 未行动的战斗者移动到序列的头部
  126.     @active_battler = @action_battlers.shift
  127.     # 如果已经在战斗之外的情况下
  128.     if @active_battler.index == nil
  129.       return
  130.     end
  131.     # 连续伤害
  132.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  133.       @active_battler.slip_damage_effect
  134.       @active_battler.damage_pop = true
  135.     end
  136.     # 自然解除状态
  137.     @active_battler.remove_states_auto
  138.     # 刷新状态窗口
  139.     @status_window.refresh
  140.     # 移至步骤 2
  141.     @phase4_step = 2
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  145.   #--------------------------------------------------------------------------
  146.   def update_phase4_step2
  147.     # 如果不是强制行动
  148.     unless @active_battler.current_action.forcing
  149.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  150.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  151.         # 设置行动为攻击
  152.         @active_battler.current_action.kind = 0
  153.         @active_battler.current_action.basic = 0
  154.       end
  155.       # 限制为 [不能行动] 的情况下
  156.       if @active_battler.restriction == 4
  157.         # 清除行动强制对像的战斗者
  158.         $game_temp.forcing_battler = nil
  159.         # 移至步骤 1
  160.         @phase4_step = 1
  161.         return
  162.       end
  163.     end
  164.     # 清除对像战斗者
  165.     @target_battlers = []
  166.     # 行动种类分支
  167.     case @active_battler.current_action.kind
  168.     when 0  # 基本
  169.       make_basic_action_result
  170.     when 1  # 特技
  171.       make_skill_action_result
  172.     when 2  # 物品
  173.       make_item_action_result
  174.     end
  175.     # 移至步骤 3
  176.     if @phase4_step == 2
  177.       @phase4_step = 3
  178.     end
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 生成基本行动结果
  182.   #--------------------------------------------------------------------------
  183.   def make_basic_action_result
  184.     # 攻击的情况下
  185.     if @active_battler.current_action.basic == 0
  186.       # 设置攻击 ID
  187.       @animation1_id = @active_battler.animation1_id
  188.       @animation2_id = @active_battler.animation2_id
  189.       # 行动方的战斗者是敌人的情况下
  190.       if @active_battler.is_a?(Game_Enemy)
  191.         if @active_battler.restriction == 3
  192.           target = $game_troop.random_target_enemy
  193.         elsif @active_battler.restriction == 2
  194.           target = $game_party.random_target_actor
  195.         else
  196.           index = @active_battler.current_action.target_index
  197.           target = $game_party.smooth_target_actor(index)
  198.         end
  199.       end
  200.       # 行动方的战斗者是角色的情况下
  201.       if @active_battler.is_a?(Game_Actor)
  202.         if @active_battler.restriction == 3
  203.           target = $game_party.random_target_actor
  204.         elsif @active_battler.restriction == 2
  205.           target = $game_troop.random_target_enemy
  206.         else
  207.           index = @active_battler.current_action.target_index
  208.           target = $game_troop.smooth_target_enemy(index)
  209.         end
  210.       end
  211.       # 设置对像方的战斗者序列
  212.       @target_battlers = [target]
  213.       # 应用通常攻击效果
  214.       for target in @target_battlers
  215.         target.attack_effect(@active_battler)
  216.       end
  217.       return
  218.     end
  219.     # 防御的情况下
  220.     if @active_battler.current_action.basic == 1
  221.       # 帮助窗口显示"防御"
  222.       @help_window.set_text($data_system.words.guard, 1)
  223.       return
  224.     end
  225.     # 逃跑的情况下
  226.     if @active_battler.is_a?(Game_Enemy) and
  227.        @active_battler.current_action.basic == 2
  228.       #  帮助窗口显示"逃跑"
  229.       @help_window.set_text("逃跑", 1)
  230.       # 逃跑
  231.       @active_battler.escape
  232.       return
  233.     end
  234.     # 什么也不做的情况下
  235.     if @active_battler.current_action.basic == 3
  236.       # 清除强制行动对像的战斗者
  237.       $game_temp.forcing_battler = nil
  238.       # 移至步骤 1
  239.       @phase4_step = 1
  240.       return
  241.     end
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 设置物品或特技对像方的战斗者
  245.   #     scope : 特技或者是物品的范围
  246.   #--------------------------------------------------------------------------
  247.   def set_target_battlers(scope)
  248.     # 行动方的战斗者是敌人的情况下
  249.     if @active_battler.is_a?(Game_Enemy)
  250.       # 效果范围分支
  251.       case scope
  252.       when 1  # 敌单体
  253.         index = @active_battler.current_action.target_index
  254.         @target_battlers.push($game_party.smooth_target_actor(index))
  255.       when 2  # 敌全体
  256.         for actor in $game_party.actors
  257.           if actor.exist?
  258.             @target_battlers.push(actor)
  259.           end
  260.         end
  261.       when 3  # 我方单体
  262.         index = @active_battler.current_action.target_index
  263.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  264.       when 4  # 我方全体
  265.         for enemy in $game_troop.enemies
  266.           if enemy.exist?
  267.             @target_battlers.push(enemy)
  268.           end
  269.         end
  270.       when 5  # 我方单体 (HP 0)
  271.         index = @active_battler.current_action.target_index
  272.         enemy = $game_troop.enemies[index]
  273.         if enemy != nil and enemy.hp0?
  274.           @target_battlers.push(enemy)
  275.         end
  276.       when 6  # 我方全体 (HP 0)
  277.         for enemy in $game_troop.enemies
  278.           if enemy != nil and enemy.hp0?
  279.             @target_battlers.push(enemy)
  280.           end
  281.         end
  282.       when 7  # 使用者
  283.         @target_battlers.push(@active_battler)
  284.       end
  285.     end
  286.     # 行动方的战斗者是角色的情况下
  287.     if @active_battler.is_a?(Game_Actor)
  288.       # 效果范围分支
  289.       case scope
  290.       when 1  # 敌单体
  291.         index = @active_battler.current_action.target_index
  292.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  293.       when 2  # 敌全体
  294.         for enemy in $game_troop.enemies
  295.           if enemy.exist?
  296.             @target_battlers.push(enemy)
  297.           end
  298.         end
  299.       when 3  # 我方单体
  300.         index = @active_battler.current_action.target_index
  301.         @target_battlers.push($game_party.smooth_target_actor(index))
  302.       when 4  # 我方全体
  303.         for actor in $game_party.actors
  304.           if actor.exist?
  305.             @target_battlers.push(actor)
  306.           end
  307.         end
  308.       when 5  # 我方单体 (HP 0)
  309.         index = @active_battler.current_action.target_index
  310.         actor = $game_party.actors[index]
  311.         if actor != nil and actor.hp0?
  312.           @target_battlers.push(actor)
  313.         end
  314.       when 6  # 我方全体 (HP 0)
  315.         for actor in $game_party.actors
  316.           if actor != nil and actor.hp0?
  317.             @target_battlers.push(actor)
  318.           end
  319.         end
  320.       when 7  # 使用者
  321.         @target_battlers.push(@active_battler)
  322.       end
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 生成特技行动结果
  327.   #--------------------------------------------------------------------------
  328.   def make_skill_action_result
  329.     # 获取特技
  330.     @skill = $data_skills[@active_battler.current_action.skill_id]
  331.     # 如果不是强制行动
  332.     unless @active_battler.current_action.forcing
  333.       # 因为 SP 耗尽而无法使用的情况下
  334.       unless @active_battler.skill_can_use?(@skill.id)
  335.         # 清除强制行动对像的战斗者
  336.         $game_temp.forcing_battler = nil
  337.         # 移至步骤 1
  338.         @phase4_step = 1
  339.         return
  340.       end
  341.     end
  342.     # 消耗 SP
  343.     @active_battler.sp -= @skill.sp_cost
  344.     # 刷新状态窗口
  345.     @status_window.refresh
  346.     # 在帮助窗口显示特技名
  347.     @help_window.set_text(@skill.name, 1)
  348.     # 设置动画 ID
  349.     @animation1_id = @skill.animation1_id
  350.     @animation2_id = @skill.animation2_id
  351.     # 设置公共事件 ID
  352.     @common_event_id = @skill.common_event_id
  353.     # 设置对像侧战斗者
  354.     set_target_battlers(@skill.scope)
  355.     # 应用特技效果
  356.     for target in @target_battlers
  357.       target.skill_effect(@active_battler, @skill)
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 生成物品行动结果
  362.   #--------------------------------------------------------------------------
  363.   def make_item_action_result
  364.     # 获取物品
  365.     @item = $data_items[@active_battler.current_action.item_id]
  366.     # 因为物品耗尽而无法使用的情况下
  367.     unless $game_party.item_can_use?(@item.id)
  368.       # 移至步骤 1
  369.       @phase4_step = 1
  370.       return
  371.     end
  372.     # 消耗品的情况下
  373.     if @item.consumable
  374.       # 使用的物品减 1
  375.       $game_party.lose_item(@item.id, 1)
  376.     end
  377.     # 在帮助窗口显示物品名
  378.     @help_window.set_text(@item.name, 1)
  379.     # 设置动画 ID
  380.     @animation1_id = @item.animation1_id
  381.     @animation2_id = @item.animation2_id
  382.     # 设置公共事件 ID
  383.     @common_event_id = @item.common_event_id
  384.     # 确定对像
  385.     index = @active_battler.current_action.target_index
  386.     target = $game_party.smooth_target_actor(index)
  387.     # 设置对像侧战斗者
  388.     set_target_battlers(@item.scope)
  389.     # 应用物品效果
  390.     for target in @target_battlers
  391.       target.item_effect(@item)
  392.     end
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  396.   #--------------------------------------------------------------------------
  397.   def update_phase4_step3
  398.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  399.     if @animation1_id == 0
  400.       @active_battler.white_flash = true
  401.     else
  402.       @active_battler.animation_id = @animation1_id
  403.       @active_battler.animation_hit = true
  404.     end
  405.     # 移至步骤 4
  406.     @phase4_step = 4
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  410.   #--------------------------------------------------------------------------
  411.   def update_phase4_step4
  412.     # 对像方动画
  413.     for target in @target_battlers
  414.       target.animation_id = @animation2_id
  415.       target.animation_hit = (target.damage != "Miss")
  416.     end
  417.     # 限制动画长度、最低 8 帧
  418.     @wait_count = 8
  419.     # 移至步骤 5
  420.     @phase4_step = 5
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  424.   #--------------------------------------------------------------------------
  425.   def update_phase4_step5
  426.     # 隐藏帮助窗口
  427.     @help_window.visible = false
  428.     # 刷新状态窗口
  429.     @status_window.refresh
  430.     # 显示伤害
  431.     for target in @target_battlers
  432.       if target.damage != nil
  433.         target.damage_pop = true
  434.       end
  435.     end
  436.     # 移至步骤 6
  437.     @phase4_step = 6
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  441.   #--------------------------------------------------------------------------
  442.   def update_phase4_step6
  443.     # 清除强制行动对像的战斗者
  444.     $game_temp.forcing_battler = nil
  445.     # 公共事件 ID 有效的情况下
  446.     if @common_event_id > 0
  447.       # 设置事件
  448.       common_event = $data_common_events[@common_event_id]
  449.       $game_system.battle_interpreter.setup(common_event.list, 0)
  450.     end
  451.     # 移至步骤 1
  452.     @phase4_step = 1
  453.   end
  454. end
复制代码

点评

麻烦了=v=不过本来只是希望提供一个思路所以主楼也没说清楚……战斗脚本采用了希土的即时战斗以及菜鸟横版,而状态窗口则采用了图片式的。  发表于 2016-9-20 23:50
Vanyogin
回复

使用道具 举报

梦石
0
星屑
1788
在线时间
1313 小时
注册时间
2012-8-4
回帖
724
发表于 2016-9-17 12:44:12 | 显示全部楼层
本帖最后由 夜狠简单 于 2016-9-17 13:29 编辑

默认战斗窗口吗?- -显示的角色图片y坐标减掉20应该就能看出是哪个角色行动了
执行战斗指令的角色y坐标上升
  1. #==============================================================================
  2. # ■ Game_Temp
  3. #------------------------------------------------------------------------------
  4. #  在没有存档的情况下,处理临时数据的类。这个类的实例请参考
  5. # $game_temp 。
  6. #==============================================================================
  7. class Game_Temp
  8.     attr_accessor :actor_index              # 角色指令窗口位置
  9. end
  10. #==============================================================================
  11. # ■ Game_Actor
  12. #------------------------------------------------------------------------------
  13. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  14. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  15. #==============================================================================
  16. class Game_Actor < Game_Battler
  17.   #--------------------------------------------------------------------------
  18.   # ● 取得战斗画面的 Y 坐标
  19.   #--------------------------------------------------------------------------
  20.   def screen_y
  21.     $game_temp.actor_index||=-1
  22.     case self.index
  23.     when $game_temp.actor_index
  24.         return 464-20
  25.     else
  26.         return 464
  27.     end
  28.   end
  29. end
  30. #==============================================================================
  31. # ■ Scene_Battle (分割定义 3)
  32. #------------------------------------------------------------------------------
  33. #  处理战斗画面的类。
  34. #==============================================================================
  35. class Scene_Battle
  36.   alias phase3_setup_command_window16917 phase3_setup_command_window
  37.   def phase3_setup_command_window
  38.     $game_temp.actor_index=@actor_index
  39.     phase3_setup_command_window16917
  40.   end
  41.   alias start_phase416917 start_phase4
  42.   #最后一个角色选完后所有坐标恢复,不需要就删掉下面这段start_phase4函数
  43.   def start_phase4
  44.     $game_temp.actor_index=-1
  45.     start_phase416917
  46.   end
  47. end
复制代码

点评

方法挺好XD不过不适用我的游戏,感谢您的回答。  发表于 2016-9-20 23:50

评分

参与人数 1星屑 +10 收起 理由
泪的苍白 + 10

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部