Project1

标题: 战斗菜单命令个性化 [打印本页]

作者: Flyingpww    时间: 2007-5-20 03:28
标题: 战斗菜单命令个性化

给每个角色有不同名字的攻击命令文字

具体设置在  Window_Command_Battle 里 get_command(battler)

  1. #==============================================================================
  2. # ■ Window_Command_Battle
  3. #------------------------------------------------------------------------------
  4. #  战斗命令选择行窗口。
  5. #==============================================================================

  6. class Window_Command_Battle < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     width    : 窗口的宽
  10.   #     commands : 命令字符串序列
  11.   #--------------------------------------------------------------------------
  12.   def initialize(width, battler)
  13.     commands = get_command(battler)
  14.     # 由命令的个数计算出窗口的高
  15.     super(0, 0, width, commands.size * 32 + 32)
  16.     @item_max = commands.size
  17.     @commands = commands
  18.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  19.     self.z = 100
  20.     refresh(battler)
  21.     self.index = 0
  22.     @old_id = 0
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 刷新
  26.   #--------------------------------------------------------------------------
  27.   def refresh(battler)
  28.     if battler.id != @old_id
  29.       self.contents.clear
  30.       for i in 0...get_command(battler).size
  31.         draw_item(i, normal_color,get_command(battler)[i])
  32.       end
  33.       @old_id = battler.id
  34.     end
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 描绘项目
  38.   #     index : 项目编号
  39.   #     color : 文字色
  40.   #--------------------------------------------------------------------------
  41.   def draw_item(index, color,name)
  42.     self.contents.font.color = color
  43.     rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
  44.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  45.     self.contents.draw_text(rect, name)
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 项目无效化
  49.   #     index : 项目编号
  50.   #--------------------------------------------------------------------------
  51.   def disable_item(index)
  52.     draw_item(index, disabled_color)
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 获取命令
  56.   #--------------------------------------------------------------------------
  57.   def get_command(battler)
  58.     # 根据名字来定义 或者 其它属性来定义
  59.     if battler.name == "阿尔西斯"  
  60.       return ["攻击","剑技","防御","物品"]
  61.     elsif battler.name == "帕吉尔"
  62.       return ["攻击","枪技","防御","物品"]
  63.     elsif battler.name == "克萝莉亚"
  64.       return ["攻击","神术","防御","物品"]
  65.     elsif battler.name == "西露达"
  66.      return ["攻击","魔法","防御","物品"]
  67.     else
  68.      return ["攻击","特技","防御","物品"]
  69.     end
  70.   end
  71. end

  72. class Scene_Battle
  73.    #--------------------------------------------------------------------------
  74.   # ● 主处理
  75.   #--------------------------------------------------------------------------
  76.   def main
  77.     # 初始化战斗用的各种暂时数据
  78.     $game_temp.in_battle = true
  79.     $game_temp.battle_turn = 0
  80.     $game_temp.battle_event_flags.clear
  81.     $game_temp.battle_abort = false
  82.     $game_temp.battle_main_phase = false
  83.     $game_temp.battleback_name = $game_map.battleback_name
  84.     $game_temp.forcing_battler = nil
  85.     # 初始化战斗用事件解释器
  86.     $game_system.battle_interpreter.setup(nil, 0)
  87.     # 准备队伍
  88.     @troop_id = $game_temp.battle_troop_id
  89.     $game_troop.setup(@troop_id)
  90.     # 生成角色命令窗口
  91.     s1 = $data_system.words.attack
  92.     s2 = $data_system.words.skill
  93.     s3 = $data_system.words.guard
  94.     s4 = $data_system.words.item
  95.     @actor_command_window = Window_Command_Battle.new(160,$game_party.actors[0])
  96.     @actor_command_window.y = 160
  97.     @actor_command_window.back_opacity = 160
  98.     @actor_command_window.active = false
  99.     @actor_command_window.visible = false
  100.     # 生成其它窗口
  101.     @party_command_window = Window_PartyCommand.new
  102.     @help_window = Window_Help.new
  103.     @help_window.back_opacity = 160
  104.     @help_window.visible = false
  105.     @status_window = Window_BattleStatus.new
  106.     @message_window = Window_Message.new
  107.     # 生成活动块
  108.     @spriteset = Spriteset_Battle.new
  109.     # 初始化等待计数
  110.     @wait_count = 0
  111.     # 执行过渡
  112.     if $data_system.battle_transition == ""
  113.       Graphics.transition(20)
  114.     else
  115.       Graphics.transition(40, "Graphics/Transitions/" +
  116.         $data_system.battle_transition)
  117.     end
  118.     # 开始自由战斗回合
  119.     start_phase1
  120.     # 主循环
  121.     loop do
  122.       # 刷新游戏画面
  123.       Graphics.update
  124.       # 刷新输入信息
  125.       Input.update
  126.       # 刷新画面
  127.       update
  128.       # 如果画面切换的话就中断循环
  129.       if $scene != self
  130.         break
  131.       end
  132.     end
  133.     # 刷新地图
  134.     $game_map.refresh
  135.     # 准备过渡
  136.     Graphics.freeze
  137.     # 释放窗口
  138.     @actor_command_window.dispose
  139.     @party_command_window.dispose
  140.     @help_window.dispose
  141.     @status_window.dispose
  142.     @message_window.dispose
  143.     if @skill_window != nil
  144.       @skill_window.dispose
  145.     end
  146.     if @item_window != nil
  147.       @item_window.dispose
  148.     end
  149.     if @result_window != nil
  150.       @result_window.dispose
  151.     end
  152.     # 释放活动块
  153.     @spriteset.dispose
  154.     # 标题画面切换中的情况
  155.     if $scene.is_a?(Scene_Title)
  156.       # 淡入淡出画面
  157.       Graphics.transition
  158.       Graphics.freeze
  159.     end
  160.     # 战斗测试或者游戏结束以外的画面切换中的情况
  161.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  162.       $scene = nil
  163.     end
  164.   end
  165.   def phase3_setup_command_window
  166.     @actor_command_window.refresh(@active_battler)
  167.     # 同伴指令窗口无效化
  168.     @party_command_window.active = false
  169.     @party_command_window.visible = false
  170.     # 角色指令窗口无效化
  171.     @actor_command_window.active = true
  172.     @actor_command_window.visible = true
  173.     # 设置角色指令窗口的位置
  174.     @actor_command_window.x = @actor_index * 160
  175.     # 设置索引为 0
  176.     @actor_command_window.index = 0
  177.   end
  178. end

复制代码

作者: Flyingpww    时间: 2007-5-20 03:28
标题: 战斗菜单命令个性化

给每个角色有不同名字的攻击命令文字

具体设置在  Window_Command_Battle 里 get_command(battler)

  1. #==============================================================================
  2. # ■ Window_Command_Battle
  3. #------------------------------------------------------------------------------
  4. #  战斗命令选择行窗口。
  5. #==============================================================================

  6. class Window_Command_Battle < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     width    : 窗口的宽
  10.   #     commands : 命令字符串序列
  11.   #--------------------------------------------------------------------------
  12.   def initialize(width, battler)
  13.     commands = get_command(battler)
  14.     # 由命令的个数计算出窗口的高
  15.     super(0, 0, width, commands.size * 32 + 32)
  16.     @item_max = commands.size
  17.     @commands = commands
  18.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  19.     self.z = 100
  20.     refresh(battler)
  21.     self.index = 0
  22.     @old_id = 0
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 刷新
  26.   #--------------------------------------------------------------------------
  27.   def refresh(battler)
  28.     if battler.id != @old_id
  29.       self.contents.clear
  30.       for i in 0...get_command(battler).size
  31.         draw_item(i, normal_color,get_command(battler)[i])
  32.       end
  33.       @old_id = battler.id
  34.     end
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 描绘项目
  38.   #     index : 项目编号
  39.   #     color : 文字色
  40.   #--------------------------------------------------------------------------
  41.   def draw_item(index, color,name)
  42.     self.contents.font.color = color
  43.     rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
  44.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  45.     self.contents.draw_text(rect, name)
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 项目无效化
  49.   #     index : 项目编号
  50.   #--------------------------------------------------------------------------
  51.   def disable_item(index)
  52.     draw_item(index, disabled_color)
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 获取命令
  56.   #--------------------------------------------------------------------------
  57.   def get_command(battler)
  58.     # 根据名字来定义 或者 其它属性来定义
  59.     if battler.name == "阿尔西斯"  
  60.       return ["攻击","剑技","防御","物品"]
  61.     elsif battler.name == "帕吉尔"
  62.       return ["攻击","枪技","防御","物品"]
  63.     elsif battler.name == "克萝莉亚"
  64.       return ["攻击","神术","防御","物品"]
  65.     elsif battler.name == "西露达"
  66.      return ["攻击","魔法","防御","物品"]
  67.     else
  68.      return ["攻击","特技","防御","物品"]
  69.     end
  70.   end
  71. end

  72. class Scene_Battle
  73.    #--------------------------------------------------------------------------
  74.   # ● 主处理
  75.   #--------------------------------------------------------------------------
  76.   def main
  77.     # 初始化战斗用的各种暂时数据
  78.     $game_temp.in_battle = true
  79.     $game_temp.battle_turn = 0
  80.     $game_temp.battle_event_flags.clear
  81.     $game_temp.battle_abort = false
  82.     $game_temp.battle_main_phase = false
  83.     $game_temp.battleback_name = $game_map.battleback_name
  84.     $game_temp.forcing_battler = nil
  85.     # 初始化战斗用事件解释器
  86.     $game_system.battle_interpreter.setup(nil, 0)
  87.     # 准备队伍
  88.     @troop_id = $game_temp.battle_troop_id
  89.     $game_troop.setup(@troop_id)
  90.     # 生成角色命令窗口
  91.     s1 = $data_system.words.attack
  92.     s2 = $data_system.words.skill
  93.     s3 = $data_system.words.guard
  94.     s4 = $data_system.words.item
  95.     @actor_command_window = Window_Command_Battle.new(160,$game_party.actors[0])
  96.     @actor_command_window.y = 160
  97.     @actor_command_window.back_opacity = 160
  98.     @actor_command_window.active = false
  99.     @actor_command_window.visible = false
  100.     # 生成其它窗口
  101.     @party_command_window = Window_PartyCommand.new
  102.     @help_window = Window_Help.new
  103.     @help_window.back_opacity = 160
  104.     @help_window.visible = false
  105.     @status_window = Window_BattleStatus.new
  106.     @message_window = Window_Message.new
  107.     # 生成活动块
  108.     @spriteset = Spriteset_Battle.new
  109.     # 初始化等待计数
  110.     @wait_count = 0
  111.     # 执行过渡
  112.     if $data_system.battle_transition == ""
  113.       Graphics.transition(20)
  114.     else
  115.       Graphics.transition(40, "Graphics/Transitions/" +
  116.         $data_system.battle_transition)
  117.     end
  118.     # 开始自由战斗回合
  119.     start_phase1
  120.     # 主循环
  121.     loop do
  122.       # 刷新游戏画面
  123.       Graphics.update
  124.       # 刷新输入信息
  125.       Input.update
  126.       # 刷新画面
  127.       update
  128.       # 如果画面切换的话就中断循环
  129.       if $scene != self
  130.         break
  131.       end
  132.     end
  133.     # 刷新地图
  134.     $game_map.refresh
  135.     # 准备过渡
  136.     Graphics.freeze
  137.     # 释放窗口
  138.     @actor_command_window.dispose
  139.     @party_command_window.dispose
  140.     @help_window.dispose
  141.     @status_window.dispose
  142.     @message_window.dispose
  143.     if @skill_window != nil
  144.       @skill_window.dispose
  145.     end
  146.     if @item_window != nil
  147.       @item_window.dispose
  148.     end
  149.     if @result_window != nil
  150.       @result_window.dispose
  151.     end
  152.     # 释放活动块
  153.     @spriteset.dispose
  154.     # 标题画面切换中的情况
  155.     if $scene.is_a?(Scene_Title)
  156.       # 淡入淡出画面
  157.       Graphics.transition
  158.       Graphics.freeze
  159.     end
  160.     # 战斗测试或者游戏结束以外的画面切换中的情况
  161.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  162.       $scene = nil
  163.     end
  164.   end
  165.   def phase3_setup_command_window
  166.     @actor_command_window.refresh(@active_battler)
  167.     # 同伴指令窗口无效化
  168.     @party_command_window.active = false
  169.     @party_command_window.visible = false
  170.     # 角色指令窗口无效化
  171.     @actor_command_window.active = true
  172.     @actor_command_window.visible = true
  173.     # 设置角色指令窗口的位置
  174.     @actor_command_window.x = @actor_index * 160
  175.     # 设置索引为 0
  176.     @actor_command_window.index = 0
  177.   end
  178. end

复制代码

作者: gpra8764    时间: 2007-5-21 08:34
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1