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

Project1

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

[原创发布] XP口袋妖怪脚本(持续更新)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2014-5-3
帖子
14
跳转到指定楼层
1
发表于 2014-5-3 19:11:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
战斗系统为横版(有5个要分别打在原来的战斗脚本上替换,第五个自己插入在空白处。)
战斗系统1:
  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 1)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================

  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # ● 主处理
  9.   #--------------------------------------------------------------------------
  10.   def main
  11.     ######################
  12.     $game_party.remove_actor(387)
  13.     ######################
  14.     # 初始化战斗用的各种暂时数据
  15.     $game_temp.in_battle = true
  16.     $game_temp.battle_turn = 0
  17.     $game_temp.battle_event_flags.clear
  18.     $game_temp.battle_abort = false
  19.     $game_temp.battle_main_phase = false
  20.     $game_temp.battleback_name = $game_map.battleback_name
  21.     $game_temp.forcing_battler = nil
  22.     # 初始化战斗用事件解释器
  23.     $game_system.battle_interpreter.setup(nil, 0)
  24.     # 准备队伍
  25.     @troop_id = $game_temp.battle_troop_id
  26.     $game_troop.setup(@troop_id)
  27.     # 生成角色命令窗口
  28.     s1 = $data_system.words.attack
  29.     s2 = $data_system.words.skill
  30.     s3 = $data_system.words.guard
  31.     s4 = $data_system.words.item
  32.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,"逃跑"])
  33.     @actor_command_window.y = 160
  34.     @actor_command_window.back_opacity = 160
  35.     @actor_command_window.active = false
  36.     @actor_command_window.visible = false
  37.     # 生成其它窗口
  38.     @party_command_window = Window_PartyCommand.new
  39.     @help_window = Window_Help.new
  40.     @help_window.back_opacity = 160
  41.     @help_window.visible = false
  42.     @status_window = Window_BattleStatus.new
  43.     @message_window = Window_Message.new
  44.     # 生成活动块
  45.     @spriteset = Spriteset_Battle.new
  46.     # 初始化等待计数
  47.     @wait_count = 0
  48.     ###########################
  49.     $game_variables[29] = $game_temp.battle_troop_id
  50.     $game_variables[24] += 1
  51.     $game_variables[26] += 1
  52.     #战斗开始加入图片
  53.     @sprite = Sprite.new
  54.     @sprite.bitmap = RPG::Cache.picture("战斗界面" + $game_party.actors.size.to_s)
  55.     ###########################
  56.     # 执行过渡
  57.     if $data_system.battle_transition == ""
  58.       Graphics.transition(20)
  59.     else
  60.       Graphics.transition(40, "Graphics/Transitions/" +
  61.         $data_system.battle_transition)
  62.     end
  63.     # 开始自由战斗回合
  64.     start_phase1
  65.     # 主循环
  66.     loop do
  67.       # 刷新游戏画面
  68.       Graphics.update
  69.       # 刷新输入信息
  70.       Input.update
  71.       # 刷新画面
  72.       update
  73.       # 如果画面切换的话就中断循环
  74.       if $scene != self
  75.         break
  76.       end
  77.     end
  78.     # 刷新地图
  79.     $game_map.refresh
  80.     # 准备过渡
  81.     Graphics.freeze
  82.     # 释放窗口
  83.     ######################
  84.     #[387号人物加入]
  85.     $game_party.add_actor(387)
  86.     $game_variables[25] = 0
  87.     $game_variables[26] -= 1
  88.     $game_variables[98] = 0
  89.     $game_variables[99] = 0
  90.     ######################
  91.     @sprite.bitmap.dispose
  92.     @sprite.dispose
  93.     ######################
  94.     @actor_command_window.dispose
  95.     @party_command_window.dispose
  96.     @help_window.dispose
  97.     @status_window.dispose
  98.     @message_window.dispose
  99.     if @skill_window != nil
  100.       @skill_window.dispose
  101.     end
  102.     if @item_window != nil
  103.       @item_window.dispose
  104.     end
  105.     if @result_window != nil
  106.       @result_window.dispose
  107.     end
  108.     # 释放活动块
  109.     @spriteset.dispose
  110.     # 标题画面切换中的情况
  111.     if $scene.is_a?(Scene_Title)
  112.       # 淡入淡出画面
  113.       Graphics.transition
  114.       Graphics.freeze
  115.     end
  116.     # 战斗测试或者游戏结束以外的画面切换中的情况
  117.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  118.       $scene = nil
  119.     end
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 胜负判定
  123.   #--------------------------------------------------------------------------
  124.   def judge
  125.     # 全灭判定是真、并且同伴人数为 0 的情况下
  126.     if $game_party.all_dead? or $game_party.actors.size == 0
  127.       # 允许失败的情况下
  128.      if $game_temp.battle_can_lose
  129.         # 还原为战斗开始前的 BGM
  130.         $game_system.bgm_play($game_temp.map_bgm)
  131.         #############################
  132.         $game_variables[22] += 1
  133.         ##############################
  134.         # 战斗结束
  135.         battle_end(2)
  136.         # 返回 true
  137.         return true
  138.       end
  139.       # 设置游戏结束标志
  140.       $game_temp.gameover = true
  141.       # 返回 true
  142.       return true
  143.     end
  144.     # 如果存在任意 1 个敌人就返回 false
  145.     for enemy in $game_troop.enemies
  146.       if enemy.exist?
  147.         return false
  148.       end
  149.     end
  150.     # 开始结束战斗回合 (胜利)
  151.     start_phase5
  152.     # 返回 true
  153.     return true
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 战斗结束
  157.   #     result : 結果 (0:胜利 1:失败 2:逃跑)
  158.   #--------------------------------------------------------------------------
  159.   def battle_end(result)
  160.     # 清除战斗中标志
  161.     $game_temp.in_battle = false
  162.     # 清除全体同伴的行动
  163.     $game_party.clear_actions
  164.     # 解除战斗用状态
  165.     for actor in $game_party.actors
  166.       actor.remove_states_battle
  167.     end
  168.     # 清除敌人
  169.     $game_troop.enemies.clear
  170.     # 调用战斗返回调用
  171.     if $game_temp.battle_proc != nil
  172.       $game_temp.battle_proc.call(result)
  173.       $game_temp.battle_proc = nil
  174.     end
  175.     # 切换到地图画面
  176.     $scene = Scene_Map.new
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 设置战斗事件
  180.   #--------------------------------------------------------------------------
  181.   def setup_battle_event
  182.     # 正在执行战斗事件的情况下
  183.     if $game_system.battle_interpreter.running?
  184.       return
  185.     end
  186.     # 搜索全部页的战斗事件
  187.     for index in 0...$data_troops[@troop_id].pages.size
  188.       # 获取事件页
  189.       page = $data_troops[@troop_id].pages[index]
  190.       # 事件条件可以参考 c
  191.       c = page.condition
  192.       # 没有指定任何条件的情况下转到下一页
  193.       unless c.turn_valid or c.enemy_valid or
  194.              c.actor_valid or c.switch_valid
  195.         next
  196.       end
  197.       # 执行完毕的情况下转到下一页
  198.       if $game_temp.battle_event_flags[index]
  199.         next
  200.       end
  201.       # 确认回合条件
  202.       if c.turn_valid
  203.         n = $game_temp.battle_turn
  204.         a = c.turn_a
  205.         b = c.turn_b
  206.         if (b == 0 and n != a) or
  207.            (b > 0 and (n < 1 or n < a or n % b != a % b))
  208.           next
  209.         end
  210.       end
  211.       # 确认敌人条件
  212.       if c.enemy_valid
  213.         enemy = $game_troop.enemies[c.enemy_index]
  214.         if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
  215.           next
  216.         end
  217.       end
  218.       # 确认角色条件
  219.       if c.actor_valid
  220.         actor = $game_actors[c.actor_id]
  221.         if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
  222.           next
  223.         end
  224.       end
  225.       # 确认开关条件
  226.       if c.switch_valid
  227.         if $game_switches[c.switch_id] == false
  228.           next
  229.         end
  230.       end
  231.       # 设置事件
  232.       $game_system.battle_interpreter.setup(page.list, 0)
  233.       # 本页的范围是 [战斗] 或 [回合] 的情况下
  234.       if page.span <= 1
  235.         # 设置执行结束标志
  236.         $game_temp.battle_event_flags[index] = true
  237.       end
  238.       return
  239.     end
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 刷新画面
  243.   #--------------------------------------------------------------------------
  244.   def update
  245.     # 执行战斗事件中的情况下
  246.     if $game_system.battle_interpreter.running?
  247.       # 刷新解释器
  248.       $game_system.battle_interpreter.update
  249.       # 强制行动的战斗者不存在的情况下
  250.       if $game_temp.forcing_battler == nil
  251.         # 执行战斗事件结束的情况下
  252.         unless $game_system.battle_interpreter.running?
  253.           # 继续战斗的情况下、再执行战斗事件的设置
  254.           unless judge
  255.             setup_battle_event
  256.           end
  257.         end
  258.         # 如果不是结束战斗回合的情况下
  259.         if @phase != 5
  260.           # 刷新状态窗口
  261.           @status_window.refresh
  262.         end
  263.       end
  264.     end
  265.     # 系统 (计时器)、刷新画面
  266.     $game_system.update
  267.     $game_screen.update
  268.     # 计时器为 0 的情况下
  269.     if $game_system.timer_working and $game_system.timer == 0
  270.       # 中断战斗
  271.       $game_temp.battle_abort = true
  272.     end
  273.     # 刷新窗口
  274.     @help_window.update
  275.     @party_command_window.update
  276.     @actor_command_window.update
  277.     @status_window.update
  278.     @message_window.update
  279.     # 刷新活动块
  280.     @spriteset.update
  281.     # 处理过渡中的情况下
  282.     if $game_temp.transition_processing
  283.       # 清除处理过渡中标志
  284.       $game_temp.transition_processing = false
  285.       # 执行过渡
  286.       if $game_temp.transition_name == ""
  287.         Graphics.transition(20)
  288.       else
  289.         Graphics.transition(40, "Graphics/Transitions/" +
  290.           $game_temp.transition_name)
  291.       end
  292.     end
  293.     # 显示信息窗口中的情况下
  294.     if $game_temp.message_window_showing
  295.       return
  296.     end
  297.     # 显示效果中的情况下
  298.     if @spriteset.effect?
  299.       return
  300.     end
  301.     # 游戏结束的情况下
  302.     if $game_temp.gameover
  303.       # 切换到游戏结束画面
  304.       $scene = Scene_Gameover.new
  305.       return
  306.     end
  307.     # 返回标题画面的情况下
  308.     if $game_temp.to_title
  309.       # 切换到标题画面
  310.       $scene = Scene_Title.new
  311.       return
  312.     end
  313.     # 中断战斗的情况下
  314.     if $game_temp.battle_abort
  315.       # 还原为战斗前的 BGM
  316.       $game_system.bgm_play($game_temp.map_bgm)
  317.       # 战斗结束
  318.       battle_end(1)
  319.       return
  320.     end
  321.     # 等待中的情况下
  322.     if @wait_count > 0
  323.       # 减少等待计数
  324.       @wait_count -= 1
  325.       return
  326.     end
  327.     # 强制行动的角色存在、
  328.     # 并且战斗事件正在执行的情况下
  329.     if $game_temp.forcing_battler == nil and
  330.        $game_system.battle_interpreter.running?
  331.       return
  332.     end
  333.     # 回合分支
  334.     case @phase
  335.     when 1  # 自由战斗回合
  336.       update_phase1
  337.     when 2  # 同伴命令回合
  338.       update_phase2
  339.     when 3  # 角色命令回合
  340.       update_phase3
  341.     when 4  # 主回合
  342.       update_phase4
  343.     when 5  # 战斗结束回合
  344.       update_phase5
  345.     end
  346.   end
  347. end
复制代码
战斗系统2:
  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 2)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================

  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # ● 开始自由战斗回合
  9.   #--------------------------------------------------------------------------
  10.   def start_phase1
  11.     # 转移到回合 1
  12.     @phase = 1
  13.     # 清除全体同伴的行动
  14.     $game_party.clear_actions
  15.     # 设置战斗事件
  16.     setup_battle_event
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 刷新画面 (自由战斗回合)
  20.   #--------------------------------------------------------------------------
  21.   def update_phase1
  22.     # 胜败判定
  23.     if judge
  24.       # 胜利或者失败的情况下 : 过程结束
  25.       return
  26.     end
  27.     # 开始同伴命令回合
  28.     start_phase3
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 开始同伴命令回合
  32.   #--------------------------------------------------------------------------
  33.   def start_phase2
  34.     # 转移到回合 2
  35.     @phase = 2
  36.     # 设置角色为非选择状态
  37.     @actor_index = -1
  38.     @active_battler = nil
  39.     # 有效化同伴指令窗口
  40.     @party_command_window.active = true
  41.     @party_command_window.visible = true
  42.     # 无效化角色指令窗口
  43.     @actor_command_window.active = false
  44.     @actor_command_window.visible = false
  45.     # 清除主回合标志
  46.     $game_temp.battle_main_phase = false
  47.     # 清除全体同伴的行动
  48.     $game_party.clear_actions
  49.     # 不能输入命令的情况下
  50.     unless $game_party.inputable?
  51.       # 开始主回合
  52.       start_phase4
  53.     end
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 刷新画面 (同伴命令回合)
  57.   #--------------------------------------------------------------------------
  58.   def update_phase2
  59.     # 开始主回合
  60.     start_phase3
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 开始结束战斗回合
  64.   #--------------------------------------------------------------------------
  65.   def start_phase5
  66.     # 转移到回合 5
  67.     @phase = 5
  68.     # 演奏战斗结束 ME
  69.     $game_system.me_play($game_system.battle_end_me)
  70.     # 还原为战斗开始前的 BGM
  71.     $game_system.bgm_play($game_temp.map_bgm)
  72.     # 初始化 EXP、金钱、宝物
  73.     exp = 0
  74.     gold = 0
  75.     treasures = []
  76.     # 循环
  77.     for enemy in $game_troop.enemies
  78.       # 敌人不是隐藏状态的情况下
  79.       unless enemy.hidden
  80.         # 获得 EXP、增加金钱
  81.         exp += enemy.exp
  82.         gold += enemy.gold
  83.         # 出现宝物判定
  84.         if rand(100) < enemy.treasure_prob
  85.           if enemy.item_id > 0
  86.             treasures.push($data_items[enemy.item_id])
  87.           end
  88.           if enemy.weapon_id > 0
  89.             treasures.push($data_weapons[enemy.weapon_id])
  90.           end
  91.           if enemy.armor_id > 0
  92.             treasures.push($data_armors[enemy.armor_id])
  93.           end
  94.         end
  95.       end
  96.     end
  97.     # 限制宝物数为 6 个
  98.     treasures = treasures[0..5]
  99.    # 获得 EXP
  100.       exp=(exp/$game_party.actors.size).to_i
  101.        # 平分后避免有点数出现,要使用.to_i
  102.        for i in 0...$game_party.actors.size
  103.        actor = $game_party.actors[i]
  104.        if actor.cant_get_exp? == false
  105.        last_level = actor.level
  106.        actor.exp += exp
  107.        if actor.level > last_level
  108.        @status_window.level_up(i)
  109.        end
  110.        end
  111.        end
  112.     # 获得金钱
  113.     $game_party.gain_gold(gold)
  114.     # 获得宝物
  115.     for item in treasures
  116.       case item
  117.       when RPG::Item
  118.         $game_party.gain_item(item.id, 1)
  119.       when RPG::Weapon
  120.         $game_party.gain_weapon(item.id, 1)
  121.       when RPG::Armor
  122.         $game_party.gain_armor(item.id, 1)
  123.       end
  124.     end
  125.     # 生成战斗结果窗口
  126.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  127.     # 设置等待计数
  128.     @phase5_wait_count = 100
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 画面更新 (结束战斗回合)
  132.   #--------------------------------------------------------------------------
  133.   def update_phase5
  134.     # 等待计数大于 0 的情况下
  135.     if @phase5_wait_count > 0
  136.       # 减少等待计数
  137.       @phase5_wait_count -= 1
  138.       # 等待计数为 0 的情况下
  139.       if @phase5_wait_count == 0
  140.         # 显示结果窗口
  141.         @result_window.visible = true
  142.         # 清除主回合标志
  143.         $game_temp.battle_main_phase = false
  144.         # 刷新状态窗口
  145.         @status_window.refresh
  146.       end
  147.       return
  148.     end
  149.     # 按下 C 键的情况下
  150.     if Input.trigger?(Input::C)
  151.       # 战斗结束
  152.       battle_end(0)
  153.     end
  154.   end
  155. end
复制代码
战斗系统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.         return
  59.       end
  60.       # 返回角色索引
  61.       @actor_index -= 1
  62.       @active_battler = $game_party.actors[@actor_index]
  63.       @active_battler.blink = true
  64.     # 如果角色是在无法接受指令的状态就再试
  65.     end until @active_battler.inputable?
  66.     # 设置角色的命令窗口
  67.     phase3_setup_command_window
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 设置角色指令窗口
  71.   #--------------------------------------------------------------------------
  72.   def phase3_setup_command_window
  73.    # 同伴指令窗口无效化
  74.    @party_command_window.active = false
  75.    @party_command_window.visible = false
  76.    # 角色指令窗口无效化
  77.    @actor_command_window.active = true
  78.    @actor_command_window.visible = true
  79.    # 设置角色指令窗口的位置
  80.    @actor_command_window.x = @actor_index * 120
  81.    # 设置索引为 0
  82.    @actor_command_window.index = 0
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 刷新画面 (角色命令回合)
  86.   #--------------------------------------------------------------------------
  87.   def update_phase3
  88.     # 敌人光标有效的情况下
  89.     if @enemy_arrow != nil
  90.       update_phase3_enemy_select
  91.     # 角色光标有效的情况下
  92.     elsif @actor_arrow != nil
  93.       update_phase3_actor_select
  94.     # 特技窗口有效的情况下
  95.     elsif @skill_window != nil
  96.       update_phase3_skill_select
  97.     # 物品窗口有效的情况下
  98.     elsif @item_window != nil
  99.       update_phase3_item_select
  100.     # 逃跑窗口有效的情况下
  101.     elsif @escape_window != nil
  102.       update_phase3_escape_select
  103.     # 角色指令窗口有效的情况下
  104.     elsif @actor_command_window.active
  105.       update_phase3_basic_command
  106.     end
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 刷新画面 (角色命令回合 : 基本命令)
  110.   #--------------------------------------------------------------------------
  111.   def update_phase3_basic_command
  112.     # 按下 B 键的情况下
  113.     if Input.trigger?(Input::B)
  114.       # 演奏取消 SE
  115.       $game_system.se_play($data_system.cancel_se)
  116.       # 转向前一个角色的指令输入
  117.       phase3_prior_actor
  118.       return
  119.     end
  120.     # 按下 C 键的情况下
  121.     if Input.trigger?(Input::C)
  122.       # 角色指令窗口光标位置分之
  123.       case @actor_command_window.index
  124.       when 0  # 攻击
  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 = 0
  130.         # 开始选择敌人
  131.         start_enemy_select
  132.       when 1  # 特技
  133.         # 演奏确定 SE
  134.         $game_system.se_play($data_system.decision_se)
  135.         # 设置行动
  136.         @active_battler.current_action.kind = 1
  137.         # 开始选择特技
  138.         start_skill_select
  139.       when 2  # 防御
  140.         # 演奏确定 SE
  141.         $game_system.se_play($data_system.decision_se)
  142.         # 设置行动
  143.         @active_battler.current_action.kind = 0
  144.         @active_battler.current_action.basic = 1
  145.         # 转向下一位角色的指令输入
  146.         phase3_next_actor
  147.       when 3  # 物品
  148.         # 演奏确定 SE
  149.         $game_system.se_play($data_system.decision_se)
  150.         # 设置行动
  151.         @active_battler.current_action.kind = 2
  152.         # 开始选择物品
  153.         start_item_select
  154. ###########################################################################
  155.       when 4  # 逃跑
  156.       if $game_temp.battle_can_escape == false
  157.        # 演奏冻结 SE
  158.        $game_system.se_play($data_system.buzzer_se)
  159.        return
  160.      end
  161.      # 演奏确定 SE
  162.      $game_system.se_play($data_system.decision_se)
  163.      # 逃走处理
  164.      update_phase3_escape_select
  165. ###########################################################################
  166.      end
  167.     return
  168.    end
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 刷新画面 (角色命令回合 : 选择特技)
  172.   #--------------------------------------------------------------------------
  173.   def update_phase3_skill_select
  174.     # 设置特技窗口为可视状态
  175.     @skill_window.visible = true
  176.     # 刷新特技窗口
  177.     @skill_window.update
  178.     # 按下 B 键的情况下
  179.     if Input.trigger?(Input::B)
  180.       # 演奏取消 SE
  181.       $game_system.se_play($data_system.cancel_se)
  182.       # 结束特技选择
  183.       end_skill_select
  184.       return
  185.     end
  186.     # 按下 C 键的情况下
  187.     if Input.trigger?(Input::C)
  188.       # 获取特技选择窗口现在选择的特技的数据
  189.       @skill = @skill_window.skill
  190.       # 无法使用的情况下
  191.       if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
  192.         # 演奏冻结 SE
  193.         $game_system.se_play($data_system.buzzer_se)
  194.         return
  195.       end
  196.       # 演奏确定 SE
  197.       $game_system.se_play($data_system.decision_se)
  198.       # 设置行动
  199.       @active_battler.current_action.skill_id = @skill.id
  200.       # 设置特技窗口为不可见状态
  201.       @skill_window.visible = false
  202.       # 效果范围是敌单体的情况下
  203.       if @skill.scope == 1
  204.         # 开始选择敌人
  205.         start_enemy_select
  206.       # 效果范围是我方单体的情况下
  207.       elsif @skill.scope == 3 or @skill.scope == 5
  208.         # 开始选择角色
  209.         start_actor_select
  210.       # 效果范围不是单体的情况下
  211.       else
  212.         # 选择特技结束
  213.         end_skill_select
  214.         # 转到下一位角色的指令输入
  215.         phase3_next_actor
  216.       end
  217.       return
  218.     end
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● 刷新画面 (角色命令回合 : 选择物品)
  222.   #--------------------------------------------------------------------------
  223.   def update_phase3_item_select
  224.     # 设置物品窗口为可视状态
  225.     @item_window.visible = true
  226.     # 刷新物品窗口
  227.     @item_window.update
  228.     # 按下 B 键的情况下
  229.     if Input.trigger?(Input::B)
  230.       # 演奏取消 SE
  231.       $game_system.se_play($data_system.cancel_se)
  232.       # 选择物品结束
  233.       end_item_select
  234.       return
  235.     end
  236.     # 按下 C 键的情况下
  237.     if Input.trigger?(Input::C)
  238.       # 获取物品窗口现在选择的物品资料
  239.       @item = @item_window.item
  240.       # 无法使用的情况下
  241.       unless $game_party.item_can_use?(@item.id)
  242.         # 演奏冻结 SE
  243.         $game_system.se_play($data_system.buzzer_se)
  244.         return
  245.       end
  246.       # 演奏确定 SE
  247.       $game_system.se_play($data_system.decision_se)
  248.       # 设置行动
  249.       @active_battler.current_action.item_id = @item.id
  250.       # 设置物品窗口为不可见状态
  251.       @item_window.visible = false
  252.       # 效果范围是敌单体的情况下
  253.       if @item.scope == 1
  254.         # 开始选择敌人
  255.         start_enemy_select
  256.       # 效果范围是我方单体的情况下
  257.       elsif @item.scope == 3 or @item.scope == 5
  258.         # 开始选择角色
  259.         start_actor_select
  260.       # 效果范围不是单体的情况下
  261.       else
  262.         # 物品选择结束
  263.         end_item_select
  264.         # 转到下一位角色的指令输入
  265.         phase3_next_actor
  266.       end
  267.       return
  268.     end
  269.   end
  270.     #--------------------------------------------------------------------------
  271.   # ● 画面更新 (同伴指令回合 : 逃跑)
  272.   #--------------------------------------------------------------------------
  273.   def update_phase3_escape_select
  274.     # 计算敌人速度的平均值
  275.     enemies_agi = 0
  276.     enemies_number = 0
  277.     for enemy in $game_troop.enemies
  278.       if enemy.exist?
  279.         enemies_agi += enemy.agi
  280.         enemies_number += 1
  281.       end
  282.     end
  283.     if enemies_number > 0
  284.       enemies_agi /= enemies_number
  285.     end
  286.     # 计算角色速度的平均值
  287.     actors_agi = 0
  288.     actors_number = 0
  289.     for actor in $game_party.actors
  290.       if actor.exist?
  291.         actors_agi += actor.agi
  292.         actors_number += 1
  293.       end
  294.     end
  295.     if actors_number > 0
  296.       actors_agi /= actors_number
  297.     end
  298.     # 逃跑成功判定
  299.     success = rand(100) < 75 * actors_agi / enemies_agi
  300.     # 成功逃跑的情况下
  301.     if success
  302.       ############################
  303.       $game_variables[21] += 1
  304.       ############################
  305.       # 演奏逃跑 SE
  306.       $game_system.se_play($data_system.escape_se)
  307.       # 还原为战斗开始前的 BGM
  308.       $game_system.bgm_play($game_temp.map_bgm)
  309.       # 战斗结束
  310.       battle_end(1)
  311.     # 逃跑失败的情况下
  312.     else
  313.       # 清除全体同伴的行动
  314.       $game_party.clear_actions
  315.       # 开始主回合
  316.       start_phase4
  317.     end
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 刷新画面画面 (角色命令回合 : 选择敌人)
  321.   #--------------------------------------------------------------------------
  322.   def update_phase3_enemy_select
  323.     # 刷新敌人箭头
  324.     @enemy_arrow.update
  325.     # 按下 B 键的情况下
  326.     if Input.trigger?(Input::B)
  327.       # 演奏取消 SE
  328.       $game_system.se_play($data_system.cancel_se)
  329.       # 选择敌人结束
  330.       end_enemy_select
  331.       return
  332.     end
  333.     # 按下 C 键的情况下
  334.     if Input.trigger?(Input::C)
  335.       # 演奏确定 SE
  336.       $game_system.se_play($data_system.decision_se)
  337.       # 设置行动
  338.       @active_battler.current_action.target_index = @enemy_arrow.index
  339.       # 选择敌人结束
  340.       end_enemy_select
  341.       # 显示特技窗口中的情况下
  342.       if @skill_window != nil
  343.         # 结束特技选择
  344.         end_skill_select
  345.       end
  346.       # 显示物品窗口的情况下
  347.       if @item_window != nil
  348.         # 结束物品选择
  349.         end_item_select
  350.       end
  351.       # 转到下一位角色的指令输入
  352.       phase3_next_actor
  353.     end
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 画面更新 (角色指令回合 : 选择角色)
  357.   #--------------------------------------------------------------------------
  358.   def update_phase3_actor_select
  359.     # 刷新角色箭头
  360.     @actor_arrow.update
  361.     # 按下 B 键的情况下
  362.     if Input.trigger?(Input::B)
  363.       # 演奏取消 SE
  364.       $game_system.se_play($data_system.cancel_se)
  365.       # 选择角色结束
  366.       end_actor_select
  367.       return
  368.     end
  369.     # 按下 C 键的情况下
  370.     if Input.trigger?(Input::C)
  371.       # 演奏确定 SE
  372.       $game_system.se_play($data_system.decision_se)
  373.       # 设置行动
  374.       @active_battler.current_action.target_index = @actor_arrow.index
  375.       # 选择角色结束
  376.       end_actor_select
  377.       # 显示特技窗口中的情况下
  378.       if @skill_window != nil
  379.         # 结束特技选择
  380.         end_skill_select
  381.       end
  382.       # 显示物品窗口的情况下
  383.       if @item_window != nil
  384.         # 结束物品选择
  385.         end_item_select
  386.       end
  387.       # 转到下一位角色的指令输入
  388.       phase3_next_actor
  389.     end
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ● 开始选择敌人
  393.   #--------------------------------------------------------------------------
  394.   def start_enemy_select
  395.     # 生成敌人箭头
  396.     @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
  397.     # 关联帮助窗口
  398.     @enemy_arrow.help_window = @help_window
  399.     # 无效化角色指令窗口
  400.     @actor_command_window.active = false
  401.     @actor_command_window.visible = false
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ● 结束选择敌人
  405.   #--------------------------------------------------------------------------
  406.   def end_enemy_select
  407.     # 释放敌人箭头
  408.     @enemy_arrow.dispose
  409.     @enemy_arrow = nil
  410.     # 指令为 [战斗] 的情况下
  411.     if @actor_command_window.index == 0
  412.       # 有效化角色指令窗口
  413.       @actor_command_window.active = true
  414.       @actor_command_window.visible = true
  415.       # 隐藏帮助窗口
  416.       @help_window.visible = false
  417.     end
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 开始选择角色
  421.   #--------------------------------------------------------------------------
  422.   def start_actor_select
  423.     # 生成角色箭头
  424.     @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
  425.     @actor_arrow.index = @actor_index
  426.     # 关联帮助窗口
  427.     @actor_arrow.help_window = @help_window
  428.     # 无效化角色指令窗口
  429.     @actor_command_window.active = false
  430.     @actor_command_window.visible = false
  431.   end
  432.   #--------------------------------------------------------------------------
  433.   # ● 结束选择角色
  434.   #--------------------------------------------------------------------------
  435.   def end_actor_select
  436.     # 释放角色箭头
  437.     @actor_arrow.dispose
  438.     @actor_arrow = nil
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # ● 开始选择特技
  442.   #--------------------------------------------------------------------------
  443.   def start_skill_select
  444.     # 生成特技窗口
  445.     @skill_window = Window_Skill.new(@active_battler)
  446.     # 关联帮助窗口
  447.     @skill_window.help_window = @help_window
  448.     # 无效化角色指令窗口
  449.     @actor_command_window.active = false
  450.     @actor_command_window.visible = false
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● 选择特技结束
  454.   #--------------------------------------------------------------------------
  455.   def end_skill_select
  456.     # 释放特技窗口
  457.     @skill_window.dispose
  458.     @skill_window = nil
  459.     # 隐藏帮助窗口
  460.     @help_window.visible = false
  461.     # 有效化角色指令窗口
  462.     @actor_command_window.active = true
  463.     @actor_command_window.visible = true
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 开始选择物品
  467.   #--------------------------------------------------------------------------
  468.   def start_item_select
  469.     # 生成物品窗口
  470.     @item_window = Window_Item.new
  471.     # 关联帮助窗口
  472.     @item_window.help_window = @help_window
  473.     # 无效化角色指令窗口
  474.     @actor_command_window.active = false
  475.     @actor_command_window.visible = false
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ● 结束选择物品
  479.   #--------------------------------------------------------------------------
  480.   def end_item_select
  481.     # 释放物品窗口
  482.     @item_window.dispose
  483.     @item_window = nil
  484.     # 隐藏帮助窗口
  485.     @help_window.visible = false
  486.     # 有效化角色指令窗口
  487.     @actor_command_window.active = true
  488.     @actor_command_window.visible = true
  489.   end
  490. end
复制代码
战斗系统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_phase = true
  36.     # 生成敌人行动
  37.     for enemy in $game_troop.enemies
  38.       enemy.make_action
  39.     end
  40.     # 生成行动顺序
  41.     make_action_orders
  42.     # 移动到步骤 1
  43.     @phase4_step = 1
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 生成行动循序
  47.   #--------------------------------------------------------------------------
  48.   def make_action_orders
  49.     # 初始化序列 @action_battlers
  50.     @action_battlers = []
  51.     # 添加敌人到 @action_battlers 序列
  52.     for enemy in $game_troop.enemies
  53.       @action_battlers.push(enemy)
  54.     end
  55.     # 添加角色到 @action_battlers 序列
  56.     for actor in $game_party.actors
  57.       @action_battlers.push(actor)
  58.     end
  59.     # 确定全体的行动速度
  60.     for battler in @action_battlers
  61.       battler.make_action_speed
  62.     end
  63.     # 按照行动速度从大到小排列
  64.     @action_battlers.sort! {|a,b|
  65.       b.current_action.speed - a.current_action.speed }
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 刷新画面 (主回合)
  69.   #--------------------------------------------------------------------------
  70.   def update_phase4
  71.     case @phase4_step
  72.     when 1
  73.       update_phase4_step1
  74.     when 2
  75.       update_phase4_step2
  76.     when 3
  77.       update_phase4_step3
  78.     when 4
  79.       update_phase4_step4
  80.     when 5
  81.       update_phase4_step5
  82.     when 6
  83.       update_phase4_step6
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新画面 (主回合步骤 1 : 准备行动)
  88.   #--------------------------------------------------------------------------
  89.   def update_phase4_step1
  90.     # 隐藏帮助窗口
  91.     @help_window.visible = false
  92.     # 判定胜败
  93.     if judge
  94.       # 胜利或者失败的情况下 : 过程结束
  95.       return
  96.     end
  97.     # 强制行动的战斗者不存在的情况下
  98.     if $game_temp.forcing_battler == nil
  99.       # 设置战斗事件
  100.       setup_battle_event
  101.       # 执行战斗事件中的情况下
  102.       if $game_system.battle_interpreter.running?
  103.         return
  104.       end
  105.     end
  106.     # 强制行动的战斗者存在的情况下
  107.     if $game_temp.forcing_battler != nil
  108.       # 在头部添加后移动
  109.       @action_battlers.delete($game_temp.forcing_battler)
  110.       @action_battlers.unshift($game_temp.forcing_battler)
  111.     end
  112.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  113.     if @action_battlers.size == 0
  114.       # 开始同伴命令回合
  115.       start_phase2
  116.       return
  117.     end
  118.     # 初始化动画 ID 和公共事件 ID
  119.     @animation1_id = 0
  120.     @animation2_id = 0
  121.     @common_event_id = 0
  122.     # 未行动的战斗者移动到序列的头部
  123.     @active_battler = @action_battlers.shift
  124.     # 如果已经在战斗之外的情况下
  125.     if @active_battler.index == nil
  126.       return
  127.     end
  128.     # 连续伤害
  129.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  130.       @active_battler.slip_damage_effect
  131.       @active_battler.damage_pop = true
  132.     end
  133.     # 当角色生命>0并且中了22号状态
  134.    if @active_battler.hp > 0 and @active_battler.state?(22)
  135.      @active_battler.hp += @active_battler.maxhp/10 # 恢复1/10的最大生命
  136.     end
  137.     # 自然解除状态
  138.     @active_battler.remove_states_auto
  139.     # 刷新状态窗口
  140.     @status_window.refresh
  141.     # 移至步骤 2
  142.     @phase4_step = 2
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  146.   #--------------------------------------------------------------------------
  147.   def update_phase4_step2
  148.     # 如果不是强制行动
  149.     unless @active_battler.current_action.forcing
  150.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  151.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  152.         # 设置行动为攻击
  153.         @active_battler.current_action.kind = 0
  154.         @active_battler.current_action.basic = 0
  155.       end
  156.       # 限制为 [不能行动] 的情况下
  157.       if @active_battler.restriction == 4
  158.         # 清除行动强制对像的战斗者
  159.         $game_temp.forcing_battler = nil
  160.         # 移至步骤 1
  161.         @phase4_step = 1
  162.         return
  163.       end
  164.     end
  165.     # 清除对像战斗者
  166.     @target_battlers = []
  167.     # 行动种类分支
  168.     case @active_battler.current_action.kind
  169.     when 0  # 基本
  170.       make_basic_action_result
  171.     when 1  # 特技
  172.       make_skill_action_result
  173.     when 2  # 物品
  174.       make_item_action_result
  175.     when 3  # 逃跑
  176.       make_escape_action_result
  177.     end
  178.     # 移至步骤 3
  179.     if @phase4_step == 2
  180.       @phase4_step = 3
  181.     end
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 生成基本行动结果
  185.   #--------------------------------------------------------------------------
  186.   def make_basic_action_result
  187.     # 攻击的情况下
  188.     if @active_battler.current_action.basic == 0
  189.       # 设置攻击 ID
  190.       @animation1_id = @active_battler.animation1_id
  191.       @animation2_id = @active_battler.animation2_id
  192.       # 行动方的战斗者是敌人的情况下
  193.       if @active_battler.is_a?(Game_Enemy)
  194.         if @active_battler.restriction == 3
  195.           target = $game_troop.random_target_enemy
  196.         elsif @active_battler.restriction == 2
  197.           target = $game_party.random_target_actor
  198.         else
  199.           index = @active_battler.current_action.target_index
  200.           target = $game_party.smooth_target_actor(index)
  201.         end
  202.       end
  203.       # 行动方的战斗者是角色的情况下
  204.       if @active_battler.is_a?(Game_Actor)
  205.         if @active_battler.restriction == 3
  206.           target = $game_party.random_target_actor
  207.         elsif @active_battler.restriction == 2
  208.           target = $game_troop.random_target_enemy
  209.         else
  210.           index = @active_battler.current_action.target_index
  211.           target = $game_troop.smooth_target_enemy(index)
  212.         end
  213.       end
  214.       # 设置对像方的战斗者序列
  215.       @target_battlers = [target]
  216.       # 应用通常攻击效果
  217.       for target in @target_battlers
  218.         target.attack_effect(@active_battler)
  219.       end
  220.       return
  221.     end
  222.     # 防御的情况下
  223.     if @active_battler.current_action.basic == 1
  224.       # 帮助窗口显示"防御"
  225.       @help_window.set_text($data_system.words.guard, 1)
  226.       return
  227.     end
  228.     # 逃跑的情况下
  229.     if @active_battler.is_a?(Game_Enemy) and
  230.        @active_battler.current_action.basic == 2
  231.       #  帮助窗口显示"逃跑"
  232.       @help_window.set_text("逃跑", 1)
  233.       # 逃跑
  234.       @active_battler.escape
  235.       return
  236.     end
  237.     # 什么也不做的情况下
  238.     if @active_battler.current_action.basic == 3
  239.       # 清除强制行动对像的战斗者
  240.       $game_temp.forcing_battler = nil
  241.       # 移至步骤 1
  242.       @phase4_step = 1
  243.       return
  244.     end
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● 设置物品或特技对像方的战斗者
  248.   #     scope : 特技或者是物品的范围
  249.   #--------------------------------------------------------------------------
  250.   def set_target_battlers(scope)
  251.     # 行动方的战斗者是敌人的情况下
  252.     if @active_battler.is_a?(Game_Enemy)
  253.       # 效果范围分支
  254.       case scope
  255.       when 1  # 敌单体
  256.         index = @active_battler.current_action.target_index
  257.         @target_battlers.push($game_party.smooth_target_actor(index))
  258.       when 2  # 敌全体
  259.         for actor in $game_party.actors
  260.           if actor.exist?
  261.             @target_battlers.push(actor)
  262.           end
  263.         end
  264.       when 3  # 我方单体
  265.         index = @active_battler.current_action.target_index
  266.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  267.       when 4  # 我方全体
  268.         for enemy in $game_troop.enemies
  269.           if enemy.exist?
  270.             @target_battlers.push(enemy)
  271.           end
  272.         end
  273.       when 5  # 我方单体 (HP 0)
  274.         index = @active_battler.current_action.target_index
  275.         enemy = $game_troop.enemies[index]
  276.         if enemy != nil and enemy.hp0?
  277.           @target_battlers.push(enemy)
  278.         end
  279.       when 6  # 我方全体 (HP 0)
  280.         for enemy in $game_troop.enemies
  281.           if enemy != nil and enemy.hp0?
  282.             @target_battlers.push(enemy)
  283.           end
  284.         end
  285.       when 7  # 使用者
  286.         @target_battlers.push(@active_battler)
  287.       end
  288.     end
  289.     # 行动方的战斗者是角色的情况下
  290.     if @active_battler.is_a?(Game_Actor)
  291.       # 效果范围分支
  292.       case scope
  293.       when 1  # 敌单体
  294.         index = @active_battler.current_action.target_index
  295.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  296.       when 2  # 敌全体
  297.         for enemy in $game_troop.enemies
  298.           if enemy.exist?
  299.             @target_battlers.push(enemy)
  300.           end
  301.         end
  302.       when 3  # 我方单体
  303.         index = @active_battler.current_action.target_index
  304.         @target_battlers.push($game_party.smooth_target_actor(index))
  305.       when 4  # 我方全体
  306.         for actor in $game_party.actors
  307.           if actor.exist?
  308.             @target_battlers.push(actor)
  309.           end
  310.         end
  311.       when 5  # 我方单体 (HP 0)
  312.         index = @active_battler.current_action.target_index
  313.         actor = $game_party.actors[index]
  314.         if actor != nil and actor.hp0?
  315.           @target_battlers.push(actor)
  316.         end
  317.       when 6  # 我方全体 (HP 0)
  318.         for actor in $game_party.actors
  319.           if actor != nil and actor.hp0?
  320.             @target_battlers.push(actor)
  321.           end
  322.         end
  323.       when 7  # 使用者
  324.         @target_battlers.push(@active_battler)
  325.       end
  326.     end
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # ● 生成特技行动结果
  330.   #--------------------------------------------------------------------------
  331.   def make_skill_action_result
  332.     # 获取特技
  333.     @skill = $data_skills[@active_battler.current_action.skill_id]
  334.     # 如果不是强制行动
  335.     unless @active_battler.current_action.forcing
  336.       # 因为 SP 耗尽而无法使用的情况下
  337.       unless @active_battler.skill_can_use?(@skill.id)
  338.         # 清除强制行动对像的战斗者
  339.         $game_temp.forcing_battler = nil
  340.         # 移至步骤 1
  341.         @phase4_step = 1
  342.         return
  343.       end
  344.     end
  345.     # 消耗 SP
  346.     @active_battler.sp -= @skill.sp_cost
  347.     # 刷新状态窗口
  348.     @status_window.refresh
  349.     # 在帮助窗口显示特技名
  350.     @help_window.set_text(@skill.name, 1)
  351.     # 设置动画 ID
  352.     @animation1_id = @skill.animation1_id
  353.     @animation2_id = @skill.animation2_id
  354.     # 设置公共事件 ID
  355.     @common_event_id = @skill.common_event_id
  356.     # 设置对像侧战斗者
  357.     set_target_battlers(@skill.scope)
  358.     # 应用特技效果
  359.     for target in @target_battlers
  360.       target.skill_effect(@active_battler, @skill)
  361.     end
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● 生成物品行动结果
  365.   #--------------------------------------------------------------------------
  366.   def make_item_action_result
  367.     # 获取物品
  368.     @item = $data_items[@active_battler.current_action.item_id]
  369.     # 因为物品耗尽而无法使用的情况下
  370.     unless $game_party.item_can_use?(@item.id)
  371.       # 移至步骤 1
  372.       @phase4_step = 1
  373.       return
  374.     end
  375.     # 消耗品的情况下
  376.     if @item.consumable
  377.       # 使用的物品减 1
  378.       $game_party.lose_item(@item.id, 1)
  379.     end
  380.     # 在帮助窗口显示物品名
  381.     @help_window.set_text(@item.name, 1)
  382.     # 设置动画 ID
  383.     @animation1_id = @item.animation1_id
  384.     @animation2_id = @item.animation2_id
  385.     # 设置公共事件 ID
  386.     @common_event_id = @item.common_event_id
  387.     # 确定对像
  388.     index = @active_battler.current_action.target_index
  389.     target = $game_party.smooth_target_actor(index)
  390.     # 设置对像侧战斗者
  391.     set_target_battlers(@item.scope)
  392.     # 应用物品效果
  393.     for target in @target_battlers
  394.       target.item_effect(@item)
  395.     end
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 生成逃跑行动结果
  399.   #--------------------------------------------------------------------------
  400.   def make_escape_action_result
  401.     # 计算敌人速度的平均值
  402.     enemies_agi = 0
  403.     enemies_number = 0
  404.     for enemy in $game_troop.enemies
  405.       if enemy.exist?
  406.         enemies_agi += enemy.agi
  407.         enemies_number += 1
  408.       end
  409.     end
  410.     if enemies_number > 0
  411.       enemies_agi /= enemies_number
  412.     end
  413.     # 计算角色速度的平均值
  414.     actors_agi = 0
  415.     actors_number = 0
  416.     for actor in $game_party.actors
  417.       if actor.exist?
  418.         actors_agi += actor.agi
  419.         actors_number += 1
  420.       end
  421.     end
  422.     if actors_number > 0
  423.       actors_agi /= actors_number
  424.     end
  425.     # 逃跑成功判定
  426.     success = rand(100) < 75 * actors_agi / enemies_agi
  427.     # 成功逃跑的情况下
  428.     if success
  429.       ############################
  430.       $game_variables[21] += 1
  431.       $data_common_events[425]
  432.       ############################
  433.       # 演奏逃跑 SE
  434.       $game_system.se_play($data_system.escape_se)
  435.       # 还原为战斗开始前的 BGM
  436.       $game_system.bgm_play($game_temp.map_bgm)
  437.       # 战斗结束
  438.       battle_end(1)
  439.     # 逃跑失败的情况下
  440.     else
  441.       # 清除全体同伴的行动
  442.       $game_party.clear_actions
  443.       # 开始主回合
  444.       start_phase4
  445.     end
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  449.   #--------------------------------------------------------------------------
  450.   def update_phase4_step3
  451.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  452.     if @animation1_id == 0
  453.       @active_battler.white_flash = true
  454.     else
  455.       @active_battler.animation_id = @animation1_id
  456.       @active_battler.animation_hit = true
  457.     end
  458.     # 移至步骤 4
  459.     @phase4_step = 4
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  463.   #--------------------------------------------------------------------------
  464.   def update_phase4_step4
  465.     # 对像方动画
  466.     for target in @target_battlers
  467.       target.animation_id = @animation2_id
  468.       target.animation_hit = (target.damage != "Miss")
  469.      if target.is_a?(Game_Actor)
  470.      end
  471.    end
  472.     # 限制动画长度、最低 8 帧
  473.     @wait_count = 8
  474.     # 移至步骤 5
  475.     @phase4_step = 5
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  479.   #--------------------------------------------------------------------------
  480.   def update_phase4_step5
  481.     # 隐藏帮助窗口
  482.     @help_window.visible = false
  483.     # 刷新状态窗口
  484.     @status_window.refresh
  485.     # 显示伤害
  486.     for target in @target_battlers
  487.         if @active_battler.current_action.kind == 1 and @skill.name == "精灵球"
  488.         $game_switches[500] = false
  489.         rate_a = [( target.int*10 ),100].min
  490.         rate_b = (100 - rate_a)
  491.         bingo = (rand(100) < rate_b)
  492.      if bingo
  493.         #成功偷窃,生成偷窃物品
  494.          make_steal_result  
  495.         #成功偷窃,设置伤害文字为Success
  496.         target.damage = ""
  497.         target.damage = "Success!!"
  498.         #播放偷窃成功音效
  499.         Audio.se_play("Audio/SE/"+"002-System02",100,100)
  500.         $game_switches[500] = true
  501.         $game_variables[103] += 1
  502.       else
  503.         #偷窃失败,设置伤害为Failed
  504.         target.damage = ""
  505.         target.damage = "Failed!!"
  506.         #播放偷窃失败音效
  507.         Audio.se_play("Audio/SE/"+"010-System10",100,100)
  508.       end   
  509.       target.damage_pop = true
  510.       elsif target.damage != nil
  511.         target.damage_pop = true
  512.       end
  513.     end
  514.     # 移至步骤 6
  515.     @phase4_step = 6
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  519.   #--------------------------------------------------------------------------
  520.   def update_phase4_step6
  521.     # 清除强制行动对像的战斗者
  522.     $game_temp.forcing_battler = nil
  523.     # 公共事件 ID 有效的情况下
  524.     if @common_event_id > 0
  525.       # 设置事件
  526.       common_event = $data_common_events[@common_event_id]
  527.       $game_system.battle_interpreter.setup(common_event.list, 0)
  528.     end
  529.     # 移至步骤 1
  530.     @phase4_step = 1
  531.   end
  532. end
复制代码
战斗系统5:
  1. #-----------------------------------------------------------------------
  2. class Scene_Battle
  3. #表示这是一个Scene_Battle类
  4.    
  5.      def make_steal_result
  6. #在这个类中定义一个方法:make_steal_result
  7.        item_ser_num = rand(50)
  8. #获取随机数item_ser_num,值为0~49中的一个
  9.        item_ser = 0
  10. #初始化item_ser为0,这个变量是用来表示偷到的物品种类,是武器,还是道具或者(可参照公共事件和下面的脚本理解)
  11.        item_id = 101
  12. #初始化item_id为0,这个变量用来储存偷到的物品ID
  13.        item_num = 102
  14. #初始化item_num为0,这个变量用来储存偷到的该物品数量
  15.         case item_ser_num
  16. #对item_ser_num这个随机数进行条件分歧

  17.           when 0
  18. #当其值为0的时候
  19.             item_ser = 1
  20. #item_ser = 1,表示这是一个武器
  21.             item_id = 7
  22. #item_id = ,表示ID为7
  23.             item_num = 1
  24. #表示数量为1

  25.           when 1
  26. #当其值为1的时候
  27.             item_ser = 1
  28. #表示这是一个武器
  29.             item_id = (rand(3) + 1)
  30. #ID为1~3中的一个
  31.             item_num = 1
  32. #数量为1

  33.           when 2
  34. #当其值为2的时候
  35.             item_ser = 2
  36. #表示这是一个防具
  37.             item_id = (rand(3) + 5)
  38. #ID为5~7中的任意一个  
  39.            item_num = 1
  40. #数量为1

  41.           when 3..9
  42. #当其值为3~9之间的一个数字时
  43.             item_ser = 0
  44. #表示这是一个物品
  45.             item_id = $game_variables[99]
  46. #ID为9~11中的任意一个数
  47.             item_num = 1
  48. #数量为1

  49.         else #酒类
  50. #如果不是以上提到的任何数字且在49以内
  51.             item_ser = 0
  52. #表示这是一个物品
  53.             item_id = $game_variables[99]
  54. #ID为89~93中任意一个数字            
  55.             item_num = 1
  56. #数量为1个
  57.         end
  58. #结束对于item_ser_num的条件分歧

  59.         case item_ser
  60. #对于item_ser(即物品种类)进行条件分歧
  61.         when 0 #物品
  62.           $game_variables[100] = 0
  63. #是物品的话,第100号变量 = 0,用来告诉公共事件这是个物品
  64.         when 1 #武器
  65.           $game_variables[100] = 1
  66. #是武器的话,第100号变量 = 1,用来告诉公共事件这是个武器
  67.         when 2 #防具
  68.           $game_variables[100] = 2
  69. #是防具的话,第100号变量 = 2,用来告诉公共事件这是个防具
  70.         end
  71. #结束对于item_ser的条件分歧
  72.   
  73.         $game_variables[101] = item_id
  74. #用第101号变量存储得到的道具ID
  75.         $game_variables[102] = item_num
  76. #用第102号变量存储得到的道具数量
  77.       end
  78. end
  79. #结束

  80. #------------------------------------------------------------
复制代码
战斗系统行走图战斗:
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. #==============================================================================
  5. #冲突脚本:宠物脚本1.2版(66主页拿的宠物脚本应该都会冲突)
  6. #注意:以下一共有两个脚本,插入后就能达到战斗动画。
  7. #插入脚本后先进入游戏进行战斗一下,然后就会明白素材问题了
  8. #素材问题:脚本采用了战斗图自动选择行走图~~~
  9. #使用方法:插入main前即可
  10. #==============================================================================
  11. #==============================================================================
  12. # ■ Sprite_Battler
  13. #==============================================================================

  14. class Sprite_Battler < RPG::Sprite
  15. #--------------------------------------------------------------------------
  16. # ● instance变量
  17. #--------------------------------------------------------------------------
  18. attr_accessor :battler                  # butler
  19. #--------------------------------------------------------------------------
  20. # ● 初始化
  21. #     viewport : viewport
  22. #     battler  : butler(Game_Battler)
  23. #--------------------------------------------------------------------------
  24. def initialize(viewport, battler = nil)
  25.    super(viewport)
  26.    @battler = battler
  27.    @battler_visible = false
  28.    # 定义动画用变量
  29.    @hoko_wait = 0
  30.    @hoko_pattern = 0
  31. end
  32. #--------------------------------------------------------------------------
  33. # ● 解放
  34. #--------------------------------------------------------------------------
  35. def dispose
  36.    if self.bitmap != nil
  37.      self.bitmap.dispose
  38.    end
  39.    super
  40. end
  41. #--------------------------------------------------------------------------
  42. # ● 更新
  43. #--------------------------------------------------------------------------
  44. def update
  45.    super
  46.      # butler nil 的场合
  47.    if @battler == nil
  48.      self.bitmap = nil
  49.      loop_animation(nil)
  50.      return
  51.    end
  52.      # 如果文件名或者色相与现在的东西不同
  53.    if @battler.battler_name != @battler_name or
  54.       @battler.battler_hue != @battler_hue
  55.      # 取得位图设定
  56.      @battler_name = @battler.battler_name
  57.      @battler_hue = @battler.battler_hue

  58.      # battler→character变更
  59.      #self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  60.      self.bitmap = RPG::Cache.character(@battler_name, @battler_hue)
  61.      # width→宽度  height→高度
  62.      @width = bitmap.width / 4
  63.      @height = bitmap.height / 4
  64.      self.ox = @width / 2
  65.      self.oy = @height
  66.      self.src_rect.set(@hoko_pattern * @width, 0, @width, @height)
  67.      # 战斗不能再隐藏要是状态把不透明度做为 0
  68.      if @battler.dead? or @battler.hidden
  69.        self.opacity = 0
  70.      end
  71.    end
  72.    # 如果动画ID与现在的东西有差异
  73.    if @battler.damage == nil and
  74.       @battler.state_animation_id != @state_animation_id
  75.      @state_animation_id = @battler.state_animation_id
  76.      loop_animation($data_animations[@state_animation_id])
  77.    end
  78.    # 应该被表示actor的场合
  79.    if @battler.is_a?(Game_Actor) and @battler_visible
  80.      # 不是主要阶段的时候把不透明度稍稍下降
  81.      if $game_temp.battle_main_phase
  82.        self.opacity += 3 if self.opacity < 255
  83.      else
  84.        self.opacity -= 3 if self.opacity > 207
  85.      end
  86.    end
  87.    # 闪烁
  88.    if @battler.blink
  89.      blink_on
  90.    else
  91.      blink_off
  92.    end
  93.    # 不可见的场合
  94.    unless @battler_visible
  95.      # 出现
  96.      if not @battler.hidden and not @battler.dead? and
  97.         (@battler.damage == nil or @battler.damage_pop)
  98.        appear
  99.        @battler_visible = true
  100.      end
  101.    end
  102.    # 可见的场合
  103.    if @battler_visible
  104.      # 逃走
  105.      if @battler.hidden
  106.        $game_system.se_play($data_system.escape_se)
  107.        escape
  108.        @battler_visible = false
  109.      end
  110.      # 白闪光
  111.      if @battler.white_flash
  112.        whiten
  113.        @battler.white_flash = false
  114.      end
  115.      # 动画
  116.      if @battler.animation_id != 0
  117.        animation = $data_animations[@battler.animation_id]
  118.        animation(animation, @battler.animation_hit)
  119.        @battler.animation_id = 0
  120.      end
  121.      # 损坏
  122.      if @battler.damage_pop
  123.        damage(@battler.damage, @battler.critical)
  124.        @battler.damage = nil
  125.        @battler.critical = false
  126.        @battler.damage_pop = false
  127.      end
  128.      # korapusu
  129.      if @battler.damage == nil and @battler.dead?
  130.        if @battler.is_a?(Game_Enemy)
  131.          $game_system.se_play($data_system.enemy_collapse_se)
  132.        else
  133.          $game_system.se_play($data_system.actor_collapse_se)
  134.        end
  135.        collapse
  136.        @battler_visible = false
  137.      end
  138.      # 行走动画
  139.      hoko_anime()
  140.      # p @hoko_pattern
  141.    end
  142.    # 设定行走图位置的坐标
  143.    self.x = @battler.screen_x
  144.    self.y = @battler.screen_y - 43
  145.    self.z = @battler.screen_z
  146. end
  147. #--------------------------------------------------------------------------
  148. # ● 行走动画(@hoko_pattern * @width, 0, @width, @height)能设置行走图方向
  149. #--------------------------------------------------------------------------
  150. def hoko_anime()
  151.    @hoko_wait += 1
  152.    if @hoko_wait > 6   # wait 等待
  153.      @hoko_wait = 0
  154.      @hoko_pattern += 1
  155.      if @hoko_pattern > 3
  156.        @hoko_pattern = 0
  157.        # p "0"
  158.      end                   #pattern图案/width宽度/height高度
  159.      self.src_rect.set(@hoko_pattern * @width, @height * 2, @width, @height)
  160.      if battler.is_a?(Game_Actor)
  161.      self.src_rect.set(@hoko_pattern * @width, @height, @width, @height)
  162.    end
  163.   end
  164. end
  165. end            #enemy敌人
  166. #==============================================================================
  167. #冲突脚本:宠物脚本1.2版(66主页拿的宠物脚本应该都会冲突)
  168. #注意:以下一共有两个脚本,插入后就能达到战斗动画。
  169. #插入脚本后先进入游戏进行战斗一下,然后就会明白素材问题了
  170. #素材问题:脚本采用了战斗图自动选择行走图~~~
  171. #==============================================================================
  172. #==============================================================================
  173. # ■ Game_BattleAction
  174. #------------------------------------------------------------------------------
  175. #是处理动作 (战斗中的行动)的级。这个级 在 Game_Battler kura# su内部被使用。
  176. #==============================================================================

  177. class Game_BattleAction
  178. #--------------------------------------------------------------------------
  179. # ● instance变量
  180. #--------------------------------------------------------------------------
  181. attr_accessor :speed                    # 速度
  182. attr_accessor :kind                     # 类别(基本/ 技艺 / 物品)
  183. attr_accessor :basic                    # 基本(攻击/防御/逃跑)
  184. attr_accessor :skill_id                 # 特技ID
  185. attr_accessor :item_id                  # 物品ID
  186. attr_accessor :target_index             # 对象禁书目录
  187. attr_accessor :forcing                  # 强制标志
  188. #--------------------------------------------------------------------------
  189. # ● 初始化
  190. #--------------------------------------------------------------------------
  191. def initialize
  192.    clear
  193. end
  194. #--------------------------------------------------------------------------
  195. # ● clearness
  196. #--------------------------------------------------------------------------
  197. def clear
  198.    @speed = 0
  199.    @kind = 0
  200.    @basic = 3
  201.    @skill_id = 0
  202.    @item_id = 0
  203.    @target_index = -1
  204.    @forcing = false
  205. end
  206. #--------------------------------------------------------------------------
  207. # ● 判断
  208. #--------------------------------------------------------------------------
  209. def valid?
  210.    return (not (@kind == 0 and @basic == 3))
  211. end
  212. #--------------------------------------------------------------------------
  213. # ● 单体判断
  214. #--------------------------------------------------------------------------
  215. def for_one_friend?
  216.    # 类别特技,效果范围包含伙伴单体(HP 0 的)场合
  217.    if @kind == 1 and [3, 5].include?($data_skills[@skill_id].scope)
  218.      return true
  219.    end
  220.    # 类别以条款,效果范围包含伙伴单体(HP 0 的)场合
  221.    if @kind == 2 and [3, 5].include?($data_items[@item_id].scope)
  222.      return true
  223.    end
  224.    return false
  225. end
  226. #--------------------------------------------------------------------------
  227. # ● 单体用(HP 0)判断
  228. #--------------------------------------------------------------------------
  229. def for_one_friend_hp0?
  230.    # 特技效果范围单体(HP 0 )的场合
  231.    if @kind == 1 and [5].include?($data_skills[@skill_id].scope)
  232.      return true
  233.    end
  234.    # 物品效果范围单体(HP 0 )的场合
  235.    if @kind == 2 and [5].include?($data_items[@item_id].scope)
  236.      return true
  237.    end
  238.    return false
  239. end
  240. #--------------------------------------------------------------------------
  241. # ● random目标 (actor用)
  242. #--------------------------------------------------------------------------
  243. def decide_random_target_for_actor
  244.    # 效果范围分歧
  245.    if for_one_friend_hp0?
  246.      battler = $game_party.random_target_actor_hp0
  247.    elsif for_one_friend?
  248.      battler = $game_party.random_target_actor
  249.    else
  250.      battler = $game_troop.random_target_enemy
  251.    end
  252. # 如果对象存在取得禁书目录,
  253. # 对象不存在的情况clearness动作
  254.    if battler != nil
  255.      @target_index = battler.index
  256.    else
  257.      clear
  258.    end
  259. end
  260. #--------------------------------------------------------------------------
  261. # ● random目标 (enemy用)
  262. #--------------------------------------------------------------------------
  263. def decide_random_target_for_enemy
  264.    # 效果范围分歧
  265.    if for_one_friend_hp0?
  266.      battler = $game_troop.random_target_enemy_hp0
  267.    elsif for_one_friend?
  268.      battler = $game_troop.random_target_enemy
  269.    else
  270.      battler = $game_party.random_target_actor
  271.    end
  272.    # 如果对象存在取得禁书目录,
  273.    # 对象不存在的情况clearness动作
  274.    if battler != nil
  275.      @target_index = battler.index
  276.    else
  277.      clear
  278.    end
  279. end
  280. #--------------------------------------------------------------------------
  281. # ● 最后目标 (actor)
  282. #--------------------------------------------------------------------------
  283. def decide_last_target_for_actor
  284.    # 单体actor效果范围,(enemy)
  285.    if @target_index == -1
  286.      battler = nil
  287.    elsif for_one_friend?
  288.      battler = $game_party.actors[@target_index]
  289.    else
  290.      battler = $game_troop.enemies[@target_index]
  291.    end
  292.    # 对象不存在的情况clearness动作
  293.    if battler == nil or not battler.exist?
  294.      clear
  295.    end
  296. end
  297. #--------------------------------------------------------------------------
  298. # ● 最后目标 (enemy)
  299. #--------------------------------------------------------------------------
  300. def decide_last_target_for_enemy
  301.    # 单体enemy效果范围 (actor)
  302.    if @target_index == -1
  303.      battler = nil
  304.    elsif for_one_friend?
  305.      battler = $game_troop.enemies[@target_index]
  306.    else
  307.      battler = $game_party.actors[@target_index]
  308.    end
  309.    # 对象不存在的情况clearness动作
  310.    if battler == nil or not battler.exist?
  311.      clear
  312.    end
  313. end
  314. end

  315. #==============================================================================
  316. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  317. #==============================================================================
复制代码
口袋妖怪新创意(加点脚本):
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # 脚本使用设定:

  5. LEVEL_UP_POINT = 1  # 每升一级所增加的点数
  6. LEVEL_UP_VARIABLE = 110  # 储存角色点数的变量编号与角色id编号的差值
  7.                          # 默认情况 = 100,
  8.                          # 则是数据库里1号角色的加点数存于101号变量
  9.                          # 3号角色的加点数存于103号变量。
  10.                          # 你可以直接操作变量赠与角色可分配点数

  11. # 每增加一次点数,各项能力值的变化:357-410行
  12.                         
  13. # 使用方法介绍:

  14. # 本脚本不会取代原猩豆δ埽皇且桓龈郊庸δ堋?BR># 也就是说,默认的升级还在,但可以用这个功能手动追加点数。
  15. # 如果你想纯粹使用手动加点(而升级不提升能力),只要把数据库中角色升级能力,
  16. # 1-99级全部等于一个相同数值就行了。

  17. # 呼唤加点场景的方法:$scene = Scene_Lvup.new(角色编号,返回菜单编号)。
  18. # 默认都是0号

  19. # 加点场景中,page up,page down换人,如果想加点完毕后返回地图,
  20. # 464行$scene = Scene_Menu.new(0)改为$scene = Scene_Map.new

  21. # 推荐脚本搭配:魔法商店脚本,两者结合,制作自由型RPG

  22. #==============================================================================
  23. # ■ Window_Command
  24. #------------------------------------------------------------------------------
  25. #  一般的命令选择行窗口。(追加定义)
  26. #==============================================================================
  27. class Window_Command < Window_Selectable
  28.   #--------------------------------------------------------------------------
  29.   # ● 项目有效化
  30.   #     index : 项目编号
  31.   #--------------------------------------------------------------------------
  32.   def able_item(index)
  33.     draw_item(index, normal_color)
  34.   end
  35. end
  36. #==============================================================================
  37. # ■ Game_Actor
  38. #------------------------------------------------------------------------------
  39. #  处理角色的类。(再定义)
  40. #==============================================================================
  41. class Game_Actor < Game_Battler
  42.   #--------------------------------------------------------------------------
  43.   # ● 更改 EXP
  44.   #     exp : 新的 EXP
  45.   #--------------------------------------------------------------------------
  46.   def exp=(exp)
  47.     @exp = [[exp, 9999999].min, 0].max
  48.     # 升级
  49.     while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
  50.       @level += 1
  51.       # 增加4点可自由分配的点数
  52.       $game_variables[self.id + LEVEL_UP_VARIABLE] += LEVEL_UP_POINT
  53.       # 学会特技
  54.       for j in $data_classes[@class_id].learnings
  55.         if j.level == @level
  56.           learn_skill(j.skill_id)
  57.         end
  58.       end
  59.     end
  60.     # 降级
  61.     while @exp < @exp_list[@level]
  62.       @level -= 1
  63.     end
  64.     # 修正当前的 HP 与 SP 超过最大值
  65.     @hp = [@hp, self.maxhp].min
  66.     @sp = [@sp, self.maxsp].min
  67.   end
  68. end
  69. #==============================================================================
  70. # ■ Window_Base
  71. #------------------------------------------------------------------------------
  72. #  游戏中全部窗口的超级类(追加定义)
  73. #==============================================================================
  74. class Window_Base < Window
  75.   #--------------------------------------------------------------------------
  76.   # ● 描绘 HP
  77.   #     actor : 角色
  78.   #     x     : 描画目标 X 坐标
  79.   #     y     : 描画目标 Y 坐标
  80.   #     width : 描画目标的宽
  81.   #--------------------------------------------------------------------------
  82.   def draw_actor_hp_lvup(actor, x, y)
  83.     self.contents.font.color = system_color
  84.     self.contents.draw_text(x , y, 96, 32, "最大" + $data_system.words.hp)
  85.     if $temp_hp == 0
  86.       self.contents.font.color = normal_color
  87.       self.contents.draw_text(x + 120 , y, 48, 32, actor.maxhp.to_s, 2)
  88.     else
  89.       maxhp = actor.maxhp + $temp_hp
  90.       self.contents.font.color = Color.new(255, 128, 128, 255)
  91.       self.contents.draw_text(x + 120 , y, 48, 32, maxhp.to_s ,2)
  92.       self.contents.font.color = normal_color      
  93.       self.contents.draw_text(x + 155, y, 36, 32, "( ", 2)
  94.       if $temp_hp >=0
  95.         self.contents.font.color = Color.new(255, 128, 128, 255)
  96.         self.contents.draw_text(x + 155, y, 36, 32, " +",2)
  97.       else
  98.         self.contents.font.color = Color.new(255,255,0,255)
  99.         self.contents.draw_text(x + 155, y, 36, 32, " -",2)
  100.       end
  101.       self.contents.draw_text(x + 200, y, 36, 32, $temp_hp.to_s, 2)
  102.       self.contents.font.color = normal_color
  103.       self.contents.draw_text(x + 215, y, 36, 32, ")", 2)
  104.     end
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 描绘 SP
  108.   #     actor : 角色
  109.   #     x     : 描画目标 X 坐标
  110.   #     y     : 描画目标 Y 坐标
  111.   #     width : 描画目标的宽
  112.   #--------------------------------------------------------------------------
  113.   def draw_actor_sp_lvup(actor, x, y)
  114.     self.contents.font.color = system_color
  115.     self.contents.draw_text(x , y, 96, 32, "最大" + $data_system.words.sp)
  116.     if $temp_sp == 0
  117.       self.contents.font.color = normal_color
  118.       self.contents.draw_text(x + 120 , y, 48, 32, actor.maxsp.to_s, 2)
  119.     else
  120.       maxsp = actor.maxsp + $temp_sp
  121.       self.contents.font.color = Color.new(255, 128, 128, 255)
  122.       self.contents.draw_text(x + 120 , y, 48, 32, maxsp.to_s ,2)
  123.       self.contents.font.color = normal_color      
  124.       self.contents.draw_text(x + 155, y, 36, 32, "( ", 2)
  125.       if $temp_sp >=0
  126.         self.contents.font.color = Color.new(255, 128, 128, 255)
  127.         self.contents.draw_text(x + 155, y, 36, 32, " +",2)
  128.       else
  129.         self.contents.font.color = Color.new(255,255,0,255)
  130.         self.contents.draw_text(x + 155, y, 36, 32, " -",2)
  131.       end
  132.       self.contents.draw_text(x + 200, y, 36, 32, $temp_sp.to_s, 2)
  133.       self.contents.font.color = normal_color
  134.       self.contents.draw_text(x + 215, y, 36, 32, ")", 2)
  135.     end
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 描绘能力值
  139.   #     actor : 角色
  140.   #     x     : 描画目标 X 坐标
  141.   #     y     : 描画目标 Y 坐标
  142.   #     type  : 能力值种类 (0~4)
  143.   #--------------------------------------------------------------------------
  144.   def draw_actor_lvup(actor, x, y, type)   
  145.     # 定义数字颜色
  146.     lvup = normal_color
  147.     upcolor = Color.new(255, 128, 128, 255)
  148.     self.contents.font.color = normal_color   
  149.     case type
  150.     when 0
  151.       parameter_name = $data_system.words.str
  152.       parameter_value = actor.str
  153.       parameter_value_temp = parameter_value + $temp_str
  154.       if $temp_str != 0
  155.         lvup = upcolor
  156.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  157.         if $temp_str >= 0
  158.           self.contents.font.color = lvup
  159.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  160.         else
  161.           self.contents.font.color = Color.new(255,255,0,255)
  162.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  163.         end        
  164.         self.contents.draw_text(x + 272, y, 80, 32, $temp_str.abs.to_s,1)
  165.         self.contents.font.color = normal_color
  166.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  167.       end
  168.     when 1
  169.       parameter_name = $data_system.words.dex
  170.       parameter_value = actor.dex
  171.       parameter_value_temp = parameter_value + $temp_dex
  172.       if $temp_dex != 0
  173.         lvup = upcolor
  174.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  175.         if $temp_dex >= 0
  176.           self.contents.font.color = lvup
  177.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  178.         else
  179.           self.contents.font.color = Color.new(255,255,0,255)
  180.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  181.         end        
  182.         self.contents.draw_text(x + 272, y, 80, 32, $temp_dex.abs.to_s,1)
  183.         self.contents.font.color = normal_color
  184.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  185.       end
  186.     when 2
  187.       parameter_name = $data_system.words.agi
  188.       parameter_value = actor.agi
  189.       parameter_value_temp = parameter_value + $temp_agi
  190.       if $temp_agi != 0
  191.         lvup = upcolor
  192.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  193.         if $temp_agi >= 0
  194.           self.contents.font.color = lvup
  195.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  196.         else
  197.           self.contents.font.color = Color.new(255,255,0,255)
  198.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  199.         end        
  200.         self.contents.draw_text(x + 272, y, 80, 32, $temp_agi.abs.to_s,1)
  201.         self.contents.font.color = normal_color
  202.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  203.       end
  204.     when 3
  205.       parameter_name = $data_system.words.int
  206.       parameter_value = actor.int
  207.       parameter_value_temp = parameter_value + $temp_int
  208.       if $temp_int != 0
  209.         lvup = upcolor
  210.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  211.         if $temp_int >= 0
  212.           self.contents.font.color = lvup
  213.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  214.         else
  215.           self.contents.font.color = Color.new(255,255,0,255)
  216.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  217.         end        
  218.         self.contents.draw_text(x + 272, y, 80, 32, $temp_int.abs.to_s,1)
  219.         self.contents.font.color = normal_color
  220.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  221.       end
  222.     when 4
  223.       parameter_name = "剩余点数"
  224.       parameter_value = $point
  225.       if $point != 0
  226.         lvup = upcolor
  227.       end
  228.     end   
  229.     self.contents.font.color = system_color
  230.     self.contents.draw_text(x, y, 120, 32, parameter_name)
  231.     self.contents.font.color = normal_color
  232.     self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s)   
  233.     if type != 4
  234.       self.contents.draw_text(x + 150, y, 36, 32, "→")
  235.     end  
  236.     self.contents.font.color = lvup
  237.     self.contents.draw_text(x + 180, y, 60, 32, parameter_value_temp.to_s)
  238.     self.contents.font.color = normal_color        
  239.   end
  240. end
  241. #==============================================================================
  242. # ■ Window_lvup
  243. #------------------------------------------------------------------------------
  244. #  显示升级状态窗口。
  245. #==============================================================================
  246. class Window_Lvup < Window_Base
  247.   #--------------------------------------------------------------------------
  248.   # ● 初始化对像
  249.   #     actor : 角色
  250.   #--------------------------------------------------------------------------
  251.   def initialize(actor)
  252.     super(0, 0, 512, 320)
  253.     self.contents = Bitmap.new(width - 32, height - 32)
  254.     @actor = actor
  255.     refresh
  256.   end  
  257.   #--------------------------------------------------------------------------
  258.   # ● 刷新
  259.   #--------------------------------------------------------------------------
  260.   def refresh
  261.     self.contents.clear
  262.     draw_actor_graphic(@actor, 40, 112)
  263.     draw_actor_name(@actor, 4, 0)
  264.     draw_actor_class(@actor, 4 + 144, 0)
  265.     draw_actor_level(@actor, 96, 32)
  266.     draw_actor_state(@actor, 96, 64)   
  267.     draw_actor_hp_lvup(@actor, 96+128, 32)
  268.     draw_actor_sp_lvup(@actor, 96+128, 64)
  269.     draw_actor_lvup(@actor, 96, 128, 0)
  270.     draw_actor_lvup(@actor, 96, 160, 1)
  271.     draw_actor_lvup(@actor, 96, 192, 2)
  272.     draw_actor_lvup(@actor, 96, 224, 3)
  273.     draw_actor_lvup(@actor, 96, 256, 4)
  274.   end
  275. end
  276. #==============================================================================
  277. # ■ Window_Help
  278. #------------------------------------------------------------------------------
  279. #  特技及物品的说明、角色的状态显示的窗口。
  280. #==============================================================================
  281. class Window_Lvup_Help < Window_Base
  282.   #--------------------------------------------------------------------------
  283.   # ● 初始化对像
  284.   #--------------------------------------------------------------------------
  285.   def initialize
  286.     super(0, 320, 640, 160)
  287.     self.contents = Bitmap.new(width - 32, height - 32)
  288.     @test = "" #——这个东西用来检测,节约内存专用
  289.   end  
  290.   #--------------------------------------------------------------------------
  291.   # ● 设置文本
  292.   #--------------------------------------------------------------------------
  293.   def lvup_text(text1, text2 = nil, text3 = nil, text4 = nil, text5 = nil)
  294.     if @test != text1
  295.       @test = text1
  296.     else
  297.       return
  298.     end   
  299.     self.contents.clear
  300.     self.contents.font.color = normal_color
  301.     self.contents.draw_text(5, 0, self.width - 40, 32, text1)
  302.     if text2 != nil
  303.       self.contents.draw_text(5 , 32, self.width - 40, 32, text2)
  304.     end
  305.     self.contents.font.size -= 5
  306.     if text3 != nil
  307.       self.contents.draw_text(5 , 64, self.width - 40, 32, text3)
  308.     end
  309.     if text4 != nil
  310.       self.contents.draw_text(5 , 96, self.width - 40, 32, text4)
  311.     end
  312.     if text5 != nil
  313.       self.contents.draw_text(5 , 96, self.width - 40, 32, text5)
  314.     end
  315.     self.contents.font.size += 5
  316.   end
  317. end
  318. #==============================================================================
  319. # ■ Scene_lvup
  320. #------------------------------------------------------------------------------
  321. #  处理升级画面的类。
  322. #==============================================================================
  323. class Scene_Lvup
  324.   #--------------------------------------------------------------------------
  325.   # ● 初始化对像
  326.   #     actor_index : 角色索引
  327.   #     menu_index : 选项起始位置
  328.   #--------------------------------------------------------------------------
  329.   def initialize(actor_index = 0 , menu_index = 0)
  330.     @actor_index = actor_index
  331.     @menu_index = menu_index
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 主处理
  335.   #--------------------------------------------------------------------------
  336.   def main
  337.     s1 = "增加HP"
  338.     s2 = "增加PP"
  339.     s3 = "增加"+$data_system.words.str
  340.     s4 = "增加"+$data_system.words.dex
  341.     s5 = "增加"+$data_system.words.agi
  342.     s6 = "增加"+$data_system.words.int
  343.     s7 = "确认加点"
  344.     s8 = "点数重置"
  345.     @command_window = Window_Command.new(128, [s1, s2, s3, s4, s5, s6, s7, s8])
  346.     @command_window.index = @menu_index
  347.     # 获取角色
  348.     @actor = $game_party.actors[@actor_index]
  349.     # 将角色的剩余点数带入
  350.     $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE]   
  351.     # 初始化临时量
  352.     $temp_str = 0
  353.     $temp_dex = 0
  354.     $temp_agi = 0
  355.     $temp_int = 0
  356.     $temp_hp = 0
  357.     $temp_sp = 0
  358.     #=========================================================================
  359.     # 特别提示:这些设置也可以使用小数,但是可能出现0值意外错误
  360.     #  (各种编程语言都有这种意外),建议还是使用整数,正负不限
  361.     #=========================================================================
  362.     #=========================================================================
  363.     # 每提升一次HP,提升多少附加能力
  364.     #=========================================================================
  365.     @hp_hp = 11      # 每提升一次体力提升多少HP
  366.     @hp_sp = 0       # 每提升一次体力提升多少SP
  367.     @hp_str = 0   # 每提升一次体力提升多少力量
  368.     @hp_dex = 0   # 每提升一次体力提升多少速度
  369.     @hp_agi = 0   # 每提升一次体力提升多少灵巧
  370.     @hp_int = 0   # 每提升一次体力提升多少魔力  
  371.     #=========================================================================
  372.     # 每提升一次SP,提升多少附加能力
  373.     #=========================================================================
  374.     @sp_hp = 1       # 每提升一次体力提升多少HP
  375.     @sp_sp = 10      # 每提升一次体力提升多少SP
  376.     @sp_str = 0   # 每提升一次体力提升多少力量
  377.     @sp_dex = 0   # 每提升一次体力提升多少速度
  378.     @sp_agi = 0   # 每提升一次体力提升多少灵巧
  379.     @sp_int = 0   # 每提升一次体力提升多少魔力
  380.     #=========================================================================
  381.     # 每提升一次力量,提升多少附加能力
  382.     #=========================================================================
  383.     @str_hp = 1     # 每提升一次力量附加提升多少HP
  384.     @str_sp = 0     # 每提升一次力量附加提升多少SP
  385.     @str_dex = 0    # 每提升一次力量附加提升多少灵巧
  386.     @str_agi = 0    # 每提升一次力量附加提升多少速度
  387.     @str_int = 0    # 每提升一次力量附加提升多少魔力
  388.     @str_str = 1    # 每提升一次力量附加提升多少力量
  389.     #=========================================================================
  390.     # 每提升一次灵巧,提升多少附加能力
  391.     #=========================================================================
  392.     @dex_hp = 1     # 每提升一次灵巧附加提升多少HP
  393.     @dex_sp = 0     # 每提升一次灵巧附加提升多少SP
  394.     @dex_str = 0    # 每提升一次灵巧附加提升多少力量
  395.     @dex_agi = 0    # 每提升一次灵巧附加提升多少速度
  396.     @dex_int = 0    # 每提升一次灵巧附加提升多少魔力
  397.     @dex_dex = 1    # 每提升一次灵巧附加提升多少灵巧
  398.     #=========================================================================
  399.     # 每提升一次速度,提升多少附加能力
  400.     #=========================================================================
  401.     @agi_hp = 1     # 每提升一次速度附加提升多少HP
  402.     @agi_sp = 0     # 每提升一次速度附加提升多少SP
  403.     @agi_str = 0    # 每提升一次速度附加提升多少力量
  404.     @agi_dex = 0    # 每提升一次速度附加提升多少灵巧
  405.     @agi_int = 0    # 每提升一次速度附加提升多少魔力
  406.     @agi_agi = 1    # 每提升一次速度附加提升多少速度
  407.     #=========================================================================
  408.     # 每提升一次魔力,提升多少附加能力
  409.     #=========================================================================
  410.     @int_hp = 1     # 每提升一次魔力附加提升多少HP
  411.     @int_sp = 0    # 每提升一次魔力附加提升多少SP
  412.     @int_str = 0   # 每提升一次魔力附加提升多少力量
  413.     @int_dex = 0   # 每提升一次魔力附加提升多少灵巧
  414.     @int_agi = 0   # 每提升一次魔力附加提升多少速度
  415.     @int_int = 1   # 每提升一次魔力附加提升多少魔力
  416.     # 定义说明文字
  417.     @text_hp_sc = "HP可以增加生存的能力,可以延长生存的时间!"
  418.     @text_sp_sc = "PP可以增加特技的次数,还可提升自身特防!"
  419.     @text_str_sc = $data_system.words.str + "可以增加普攻的威力!"
  420.     @text_dex_sc = $data_system.words.dex + "可以提高防御力、命中率和必杀!"
  421.     @text_agi_sc = $data_system.words.agi + "可以提高回避、命中!"
  422.     @text_int_sc = $data_system.words.int + "可以提高特攻的效果!"
  423.     @text_save = "保存分配情况并返回游戏"
  424.     @text_reset= "重新分配能力点数"
  425.     @text_2 = "每增加一次此项能力值,可以提升能力值"
  426.     @text_hp = "最大" + $data_system.words.hp + "值"
  427.     @text_sp = "最大" + $data_system.words.sp + "值"
  428.     @text_str = "最大" + $data_system.words.str + "值"
  429.     @text_dex = "最大" + $data_system.words.dex + "值"
  430.     @text_agi = "最大" + $data_system.words.agi + "值"
  431.     @text_int = "最大" + $data_system.words.int + "值"
  432.     s_disable
  433.     # 生成状态窗口
  434.     @lvup_window = Window_Lvup.new(@actor)
  435.     @lvup_window.x = 128
  436.     @lvup_window.y = 0   
  437.     # 生成帮助窗口并初始化帮助文本
  438.     @help_window = Window_Lvup_Help.new   
  439.     # 执行过渡
  440.     Graphics.transition(0, "Graphics/Transitions/" + $data_system.battle_transition)
  441.     # 主循环
  442.     loop do
  443.       # 刷新游戏画面
  444.       Graphics.update
  445.       # 刷新输入信息
  446.       Input.update
  447.       # 刷新画面
  448.       update
  449.       # 如果切换画面就中断循环
  450.       if $scene != self
  451.         break
  452.       end
  453.     end
  454.     # 准备过渡
  455.     Graphics.freeze
  456.     # 释放窗口
  457.     @command_window.dispose
  458.     @lvup_window.dispose
  459.     @help_window.dispose
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● 刷新画面
  463.   #--------------------------------------------------------------------------
  464.   def update
  465.     # 刷新窗口
  466.     @command_window.update
  467.     # 选项明暗判断(因为太消耗资源,所以屏蔽掉了)
  468.     s_disable
  469.     @lvup_window.update
  470.     #=============================================================
  471.     # 按下 B 键的情况下
  472.     #=============================================================
  473.     if Input.trigger?(Input::B)
  474.       # 演奏取消 SE
  475.       $game_system.se_play($data_system.cancel_se)
  476.       # 切换到地图画面
  477.       #################################################
  478.       $scene = Scene_Menu.new(3)
  479.       #################################################
  480.       return
  481.     end
  482.     #=============================================================
  483.     # 按下 C 键的情况下
  484.     #=============================================================
  485.     if Input.trigger?(Input::C)      
  486.       if @command_window.index == 6
  487.           # 演奏确定 SE
  488.         $game_system.se_play($data_system.decision_se)
  489.         # 将角色的剩余点数带回
  490.         $game_variables[@actor.id + LEVEL_UP_VARIABLE] = $point
  491.         # 将角色点数实际加上
  492.         @actor.str += $temp_str
  493.         @actor.dex += $temp_dex
  494.         @actor.agi += $temp_agi
  495.         @actor.int += $temp_int
  496.         @actor.maxhp += $temp_hp
  497.         @actor.maxsp += $temp_sp
  498.         # 切换到地图画面
  499.         #################################################
  500.         $scene = Scene_Menu.new(3)
  501.         #################################################
  502.         return
  503.       end
  504.       if @command_window.index == 7
  505.           # 演奏确定 SE
  506.         $game_system.se_play($data_system.cancel_se)
  507.           # 将角色的剩余点数带入
  508.         $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE]   
  509.           # 初始化临时量
  510.         $temp_str = 0
  511.         $temp_dex = 0
  512.         $temp_agi = 0
  513.         $temp_int = 0
  514.         $temp_hp = 0
  515.         $temp_sp = 0
  516.         @lvup_window.refresh
  517.         return
  518.       end
  519.       if $point == 0
  520.         # 演奏冻结 SE
  521.         $game_system.se_play($data_system.buzzer_se)
  522.         return
  523.       end
  524.       case @command_window.index
  525.       when 0
  526.         # 演奏确定 SE
  527.         $game_system.se_play($data_system.decision_se)
  528.         $temp_hp += @hp_hp
  529.         $temp_sp += @hp_sp
  530.         $temp_str += @hp_str
  531.         $temp_dex += @hp_dex
  532.         $temp_agi += @hp_agi
  533.         $temp_int += @hp_int
  534.         $point -= 1
  535.         @lvup_window.refresh
  536.         s_disable
  537.         return
  538.       when 1
  539.         # 演奏确定 SE
  540.         $game_system.se_play($data_system.decision_se)
  541.         $temp_sp += @sp_sp
  542.         $temp_hp += @sp_hp
  543.         $temp_str += @hp_str
  544.         $temp_dex += @hp_dex
  545.         $temp_agi += @hp_agi
  546.         $temp_int += @hp_int
  547.         $point -= 1
  548.         @lvup_window.refresh
  549.         s_disable
  550.         return
  551.       when 2
  552.         # 演奏确定 SE
  553.         $game_system.se_play($data_system.decision_se)
  554.         $temp_str += @str_str
  555.         $temp_hp += @str_hp
  556.         $temp_sp += @str_sp
  557.         $temp_dex += @str_dex
  558.         $temp_agi += @str_agi
  559.         $temp_int += @str_int
  560.         $point -= 1
  561.         @lvup_window.refresh
  562.         s_disable
  563.         return
  564.       when 3
  565.         # 演奏确定 SE
  566.         $game_system.se_play($data_system.decision_se)
  567.         $temp_dex += @dex_dex
  568.         $temp_hp += @dex_hp
  569.         $temp_sp += @dex_sp
  570.         $temp_str += @dex_str
  571.         $temp_agi += @dex_agi
  572.         $temp_int += @dex_int
  573.         $point -= 1
  574.         @lvup_window.refresh
  575.         s_disable
  576.         return
  577.       when 4
  578.         # 演奏确定 SE
  579.         $game_system.se_play($data_system.decision_se)
  580.         $temp_agi += @agi_agi
  581.         $temp_hp += @agi_hp
  582.         $temp_sp += @agi_sp
  583.         $temp_str += @agi_str
  584.         $temp_dex += @agi_dex
  585.         $temp_int += @agi_int
  586.         $point -= 1
  587.         @lvup_window.refresh
  588.         s_disable
  589.         return
  590.       when 5
  591.         # 演奏确定 SE
  592.         $game_system.se_play($data_system.decision_se)
  593.         $temp_int += @int_int
  594.         $temp_hp += @int_hp
  595.         $temp_sp += @int_sp
  596.         $temp_str += @int_str
  597.         $temp_dex += @int_dex
  598.         $temp_agi += @int_agi
  599.         $point -= 1
  600.         @lvup_window.refresh
  601.         s_disable
  602.         return
  603.       end
  604.     end
  605.     #=============================================================
  606.     # 什么都没有按下的情况
  607.     #=============================================================
  608.     case @command_window.index   
  609.     when 0  # 增加HP
  610.       temptext1 = @text_hp + @hp_hp.to_s + "点   " + @text_str + @hp_str.to_s + "点   " + @text_dex + @hp_dex.to_s + "点"
  611.       temptext2 = @text_sp + @hp_sp.to_s + "点   " + @text_agi + @hp_agi.to_s + "点   " + @text_int + @hp_int.to_s + "点"
  612.       @help_window.lvup_text(@text_hp_sc , @text_2 , temptext1 , temptext2)
  613.     when 1  # 增加SP
  614.       temptext1 = @text_hp + @sp_hp.to_s + "点   " + @text_str + @sp_str.to_s + "点   " + @text_dex + @sp_dex.to_s + "点"
  615.       temptext2 = @text_sp + @sp_sp.to_s + "点   " + @text_agi + @sp_agi.to_s + "点   " + @text_int + @sp_int.to_s + "点"
  616.       @help_window.lvup_text(@text_sp_sc , @text_2 , temptext1 , temptext2)
  617.     when 2  # 增加力量
  618.       temptext1 = @text_hp + @str_hp.to_s + "点   " + @text_str + @str_str.to_s + "点   " + @text_dex + @str_dex.to_s + "点"
  619.       temptext2 = @text_sp + @str_sp.to_s + "点   " + @text_agi + @str_agi.to_s + "点   " + @text_int + @str_int.to_s + "点"
  620.       @help_window.lvup_text(@text_str_sc , @text_2 , temptext1 , temptext2)
  621.     when 3  # 增加灵巧
  622.       temptext1 = @text_hp + @dex_hp.to_s + "点   " + @text_str + @dex_agi.to_s + "点   " + @text_dex + @dex_dex.to_s + "点"
  623.       temptext2 = @text_sp + @dex_sp.to_s + "点   " + @text_agi + @dex_agi.to_s + "点   " + @text_int + @dex_int.to_s + "点"
  624.       @help_window.lvup_text(@text_dex_sc , @text_2 , temptext1 , temptext2)
  625.     when 4  # 增加速度
  626.       temptext1 = @text_hp + @agi_hp.to_s + "点   " + @text_str + @agi_str.to_s + "点   " + @text_dex + @agi_dex.to_s + "点"
  627.       temptext2 = @text_sp + @agi_sp.to_s + "点   " + @text_agi + @agi_agi.to_s + "点   " + @text_int + @agi_int.to_s + "点"
  628.       @help_window.lvup_text(@text_agi_sc , @text_2 , temptext1 , temptext2)
  629.     when 5  # 增加魔力
  630.       temptext1 = @text_hp + @int_hp.to_s + "点   " + @text_str + @int_str.to_s + "点   " + @text_dex + @int_dex.to_s + "点"
  631.       temptext2 = @text_sp + @int_sp.to_s + "点   " + @text_agi + @int_agi.to_s + "点   " + @text_int + @int_int.to_s + "点"
  632.       @help_window.lvup_text(@text_int_sc , @text_2 , temptext1 , temptext2)
  633.     when 6 # 保存设定
  634.       @help_window.lvup_text(@text_save)
  635.     when 7 # 点数重置
  636.       @help_window.lvup_text(@text_reset)     
  637.     end
  638.     #=============================================================
  639.     # 按下R与L换人的情况
  640.     #=============================================================      
  641.     if Input.trigger?(Input::R)
  642.       # 演奏光标 SE
  643.       $game_system.se_play($data_system.cursor_se)
  644.       # 移至下一位角色
  645.       @actor_index += 1
  646.       @actor_index %= $game_party.actors.size
  647.       # 切换到别的状态画面
  648.       $scene = Scene_Lvup.new(@actor_index , @command_window.index)
  649.       return
  650.     end
  651.     # 按下 L 键的情况下
  652.     if Input.trigger?(Input::L)
  653.       # 演奏光标 SE
  654.       $game_system.se_play($data_system.cursor_se)
  655.       # 移至上一位角色
  656.       @actor_index += $game_party.actors.size - 1
  657.       @actor_index %= $game_party.actors.size
  658.       # 切换到别的状态画面
  659.       $scene = Scene_Lvup.new(@actor_index , @command_window.index)
  660.       return
  661.     end
  662.   end  
  663.   #--------------------------------------------------------------------------
  664.   # ● 选项明暗判断
  665.   #--------------------------------------------------------------------------
  666.   def s_disable
  667.     # 判断剩余点数是否为0,如果为0,那么增加选项表示为暗色
  668.     if $point == 0
  669.       @command_window.disable_item(0)
  670.       @command_window.disable_item(1)
  671.       @command_window.disable_item(2)
  672.       @command_window.disable_item(3)
  673.       @command_window.disable_item(4)
  674.       @command_window.disable_item(5)
  675.     else
  676.       @command_window.able_item(0)
  677.       @command_window.able_item(1)      
  678.       @command_window.able_item(2)
  679.       @command_window.able_item(3)
  680.       @command_window.able_item(4)
  681.       @command_window.able_item(5)
  682.     end
  683.   end
  684. end

  685. #==============================================================================
  686. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  687. #==============================================================================
复制代码

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2014-5-3
帖子
14
2
 楼主| 发表于 2014-5-3 19:21:10 | 只看该作者
继续更新!口袋妖怪的电脑将被仓库代替
仓库代码:
  1. #==============================================================================
  2. # 本脚本来自www.66rpg.com,转载和使用请保留此信息
  3. # ikki,根据柳柳真实商店改编。存东西收费1元,取东西不收费。
  4. #==============================================================================
  5. #
  6. # 调用:$scene = Scene_Shop_Va.new(1)  
  7. #
  8. #==============================================================================
  9. # ■ Scene_Shop
  10. #------------------------------------------------------------------------------
  11. #  处理商店画面的类。
  12. #==============================================================================
  13. class Game_System
  14. attr_accessor :goods   
  15. alias vaule_shop_66RPG_initialize initialize
  16. def initialize
  17.    vaule_shop_66RPG_initialize
  18.    @goods = []
  19. ###########################################################################
  20.    # 初期的时候的商店物品,编号顺序:种类,ID,可卖数量
  21.    @goods[1] = [[-1,-1,-1]]  
  22. ###########################################################################
  23. end
  24. def shop_change(shop,kind,id,delnumber)
  25.    dl = delnumber
  26.    for dt in $game_system.goods[shop]
  27.      if (dt[0]==kind) and (dt[1]==id)
  28.        dt[2] -= dl
  29.        dt[2] = [dt[2],99].min
  30.        if dt[2] == 0
  31.          $game_system.goods[shop].delete(dt)
  32.        end
  33.        return
  34.      end
  35.    end
  36.    $game_system.goods[shop].push([kind,id,-delnumber])
  37. end
  38. end

  39. class Scene_Shop_Va
  40. def initialize(shop_number)
  41.    # 当前商店编号
  42.    @shop_now = shop_number     
  43. end   
  44. #--------------------------------------------------------------------------
  45. # ● 主处理
  46. #--------------------------------------------------------------------------
  47. def main
  48.    # 生成帮助窗口
  49.    @help_window = Window_Help.new
  50.    # 生成指令窗口
  51.    @command_window = Window_ShopCommand_Va.new
  52.    # 生成金钱窗口
  53.    @gold_window = Window_Gold.new
  54.    @gold_window.x = 480
  55.    @gold_window.y = 64
  56.    # 生成时间窗口
  57.    @dummy_window = Window_Base.new(0, 128, 640, 352)
  58.    # 生成购买窗口
  59.    @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  60.    @buy_window.active = false
  61.    @buy_window.visible = false
  62.    @buy_window.help_window = @help_window
  63.    # 生成卖出窗口
  64.    @sell_window = Window_ShopSell_Va.new
  65.    @sell_window.active = false
  66.    @sell_window.visible = false
  67.    @sell_window.help_window = @help_window
  68.    # 生成数量输入窗口
  69.    @number_window = Window_ShopNumber_Va.new
  70.    @number_window.active = false
  71.    @number_window.visible = false
  72.    # 生成状态窗口
  73.    @status_window = Window_ShopStatus_Va.new
  74.    @status_window.visible = false
  75.    # 执行过渡
  76.    Graphics.transition
  77.    # 主循环
  78.    loop do
  79.      # 刷新游戏画面
  80.      Graphics.update
  81.      # 刷新输入信息
  82.      Input.update
  83.      # 刷新画面
  84.      update
  85.      # 如果画面切换的话就中断循环
  86.      if $scene != self
  87.        break
  88.      end
  89.    end
  90.    # 准备过渡
  91.    Graphics.freeze
  92.    # 释放窗口
  93.    @help_window.dispose
  94.    @command_window.dispose
  95.    @gold_window.dispose
  96.    @dummy_window.dispose
  97.    @buy_window.dispose
  98.    @sell_window.dispose
  99.    @number_window.dispose
  100.    @status_window.dispose
  101. end
  102. #--------------------------------------------------------------------------
  103. # ● 刷新画面
  104. #--------------------------------------------------------------------------
  105. def update
  106.    # 刷新窗口
  107.    @help_window.update
  108.    @command_window.update
  109.    @gold_window.update
  110.    @dummy_window.update
  111.    @buy_window.update
  112.    @sell_window.update
  113.    @number_window.update
  114.    @status_window.update
  115.    # 指令窗口激活的情况下: 调用 update_command
  116.    if @command_window.active
  117.      update_command
  118.      return
  119.    end
  120.    # 购买窗口激活的情况下: 调用 update_buy
  121.    if @buy_window.active
  122.      update_buy
  123.      return
  124.    end
  125.    # 卖出窗口激活的情况下: 调用 update_sell
  126.    if @sell_window.active
  127.      update_sell
  128.      return
  129.    end
  130.    # 个数输入窗口激活的情况下: 调用 update_number
  131.    if @number_window.active
  132.      update_number
  133.      return
  134.    end
  135. end
  136. #--------------------------------------------------------------------------
  137. # ● 刷新画面 (指令窗口激活的情况下)
  138. #--------------------------------------------------------------------------
  139. def update_command
  140.    # 按下 B 键的情况下
  141.    if Input.trigger?(Input::B)
  142.      # 演奏取消 SE
  143.      $game_system.se_play($data_system.cancel_se)
  144.      # 切换到地图画面
  145.      $scene = Scene_Map.new
  146.      return
  147.    end
  148.    # 按下 C 键的情况下
  149.    if Input.trigger?(Input::C)
  150.      # 命令窗口光标位置分支
  151.      case @command_window.index
  152.      when 0  # 购买
  153.        # 演奏确定 SE
  154.        $game_system.se_play($data_system.decision_se)
  155.        # 窗口状态转向购买模式
  156.        @command_window.active = false
  157.        @dummy_window.visible = false
  158.        @buy_window.active = true
  159.        @buy_window.visible = true
  160.        @buy_window.refresh
  161.        @status_window.visible = true
  162.      when 1  # 卖出
  163.        # 演奏确定 SE
  164.        $game_system.se_play($data_system.decision_se)
  165.        # 窗口状态转向卖出模式
  166.        @command_window.active = false
  167.        @dummy_window.visible = false
  168.        @sell_window.active = true
  169.        @sell_window.visible = true
  170.        @sell_window.refresh
  171.      when 2  # 取消
  172.        # 演奏确定 SE
  173.        $game_system.se_play($data_system.decision_se)
  174.        # 切换到地图画面
  175.        $scene = Scene_Map.new
  176.      end
  177.      return
  178.    end
  179. end
  180. #--------------------------------------------------------------------------
  181. # ● 刷新画面 (购买窗口激活的情况下)
  182. #--------------------------------------------------------------------------
  183. def update_buy
  184.    # 设置状态窗口的物品
  185.    @status_window.item = @buy_window.item
  186.    # 按下 B 键的情况下
  187.    if Input.trigger?(Input::B)
  188.      # 演奏取消 SE
  189.      $game_system.se_play($data_system.cancel_se)
  190.      # 窗口状态转向初期模式
  191.      @command_window.active = true
  192.      @dummy_window.visible = true
  193.      @buy_window.active = false
  194.      @buy_window.visible = false
  195.      @status_window.visible = false
  196.      @status_window.item = nil
  197.      # 删除帮助文本
  198.      @help_window.set_text("")
  199.      return
  200.    end
  201.    # 按下 C 键的情况下
  202.    if Input.trigger?(Input::C)
  203.      # 获取物品
  204.      @item = @buy_window.item
  205.      # 物品无效的情况下、或者价格在所持金以上的情况下
  206.      if @item == nil# or @item.price > $game_party.gold
  207.        # 演奏冻结 SE
  208.        $game_system.se_play($data_system.buzzer_se)
  209.        return
  210.      end
  211.      # 获取物品所持数
  212.      case @item
  213.      when RPG::Item
  214.        number = $game_party.item_number(@item.id)
  215.      when RPG::Weapon
  216.        number = $game_party.weapon_number(@item.id)
  217.      when RPG::Armor
  218.        number = $game_party.armor_number(@item.id)
  219.      end
  220.      # 如果已经拥有了 99 个情况下
  221.      if number == 99
  222.        # 演奏冻结 SE
  223.        $game_system.se_play($data_system.buzzer_se)
  224.        return
  225.      end
  226.      # 演奏确定 SE
  227.      $game_system.se_play($data_system.decision_se)
  228.      # 计算可以最多购买的数量
  229.      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  230.      max = [[max, 99 - number].min,@buy_window.item_number].min
  231.      # 窗口状态转向数值输入模式
  232.      @buy_window.active = false
  233.      @buy_window.visible = false
  234.      @number_window.set(@item, max, @item.price)
  235.      @number_window.active = true
  236.      @number_window.visible = true
  237.    end
  238. end
  239. #--------------------------------------------------------------------------
  240. # ● 画面更新 (卖出窗口激活的情况下)
  241. #--------------------------------------------------------------------------
  242. def update_sell
  243.    # 按下 B 键的情况下
  244.    if Input.trigger?(Input::B)
  245.      # 演奏取消 SE
  246.      $game_system.se_play($data_system.cancel_se)
  247.      # 窗口状态转向初期模式
  248.      @command_window.active = true
  249.      @dummy_window.visible = true
  250.      @sell_window.active = false
  251.      @sell_window.visible = false
  252.      @status_window.item = nil
  253.      # 删除帮助文本
  254.      @help_window.set_text("")
  255.      return
  256.    end
  257.    # 按下 C 键的情况下
  258.    if Input.trigger?(Input::C)
  259.      # 获取物品
  260.      @item = @sell_window.item
  261.      # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  262.      if @item == nil# or @item.price == 0
  263.        # 演奏冻结 SE
  264.        $game_system.se_play($data_system.buzzer_se)
  265.        return
  266.      end
  267.      
  268.      
  269.      # 如果金钱为 0 G情况下
  270.      if $game_party.gold == 0
  271.        # 演奏冻结 SE
  272.        $game_system.se_play($data_system.buzzer_se)
  273.        $game_temp.message_text = "没钱了,请续费."
  274.        # 切换到地图画面
  275.        $scene = Scene_Map.new
  276.        return
  277.      end
  278.      
  279.      
  280.      # 演奏确定 SE
  281.      $game_system.se_play($data_system.decision_se)
  282.      # 获取物品的所持数
  283.      case @item
  284.      when RPG::Item
  285.        number = $game_party.item_number(@item.id)
  286.      when RPG::Weapon
  287.        number = $game_party.weapon_number(@item.id)
  288.      when RPG::Armor
  289.        number = $game_party.armor_number(@item.id)
  290.      end
  291.      # 最大卖出个数 = 物品的所持数
  292.      max = number
  293.      # 窗口状态转向个数输入模式
  294.      @sell_window.active = false
  295.      @sell_window.visible = false
  296.      @number_window.set(@item, max, @item.price / 2)
  297.      @number_window.active = true
  298.      @number_window.visible = true
  299.      @status_window.visible = true
  300.    end
  301. end
  302. #--------------------------------------------------------------------------
  303. # ● 刷新画面 (个数输入窗口激活的情况下)
  304. #--------------------------------------------------------------------------
  305. def update_number
  306.    # 按下 B 键的情况下
  307.    if Input.trigger?(Input::B)
  308.      # 演奏取消 SE
  309.      $game_system.se_play($data_system.cancel_se)
  310.      # 设置个数输入窗口为不活动·非可视状态
  311.      @number_window.active = false
  312.      @number_window.visible = false
  313.      # 命令窗口光标位置分支
  314.      case @command_window.index
  315.      when 0  # 购买
  316.        # 窗口状态转向购买模式
  317.        @buy_window.active = true
  318.        @buy_window.visible = true
  319.      when 1  # 卖出
  320.        # 窗口状态转向卖出模式
  321.        @sell_window.active = true
  322.        @sell_window.visible = true
  323.        @status_window.visible = false
  324.      end
  325.      return
  326.    end
  327.    # 按下 C 键的情况下
  328.    if Input.trigger?(Input::C)
  329.      # 演奏商店 SE
  330.      $game_system.se_play($data_system.shop_se)
  331.      # 设置个数输入窗口为不活动·非可视状态
  332.      @number_window.active = false
  333.      @number_window.visible = false
  334.      # 命令窗口光标位置分支
  335.      case @command_window.index
  336.      when 0  # 购买
  337.        # 购买处理
  338.        temp = 0
  339.        case @item
  340.        when RPG::Item
  341.          $game_party.gain_item(@item.id, @number_window.number)
  342.        when RPG::Weapon
  343.          $game_party.gain_weapon(@item.id, @number_window.number)
  344.          temp = 1
  345.        when RPG::Armor
  346.          $game_party.gain_armor(@item.id, @number_window.number)
  347.          temp = 2
  348.        end
  349.        goods_del(temp,@item.id,@number_window.number)
  350.        # 刷新各窗口
  351.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  352.        @gold_window.refresh
  353.        @buy_window.refresh
  354.        @status_window.refresh
  355.        # 窗口状态转向购买模式
  356.        @buy_window.active = true
  357.        @buy_window.visible = true
  358.      when 1  # 卖出
  359.        # 卖出处理
  360.        $game_party.lose_gold(@number_window.number)
  361.        temp = 0
  362.        case @item
  363.        when RPG::Item
  364.          $game_party.lose_item(@item.id, @number_window.number)
  365.        when RPG::Weapon
  366.          $game_party.lose_weapon(@item.id, @number_window.number)
  367.          temp = 1
  368.        when RPG::Armor
  369.          $game_party.lose_armor(@item.id, @number_window.number)
  370.          temp = 2
  371.        end
  372.        # 刷新各窗口
  373.        goods_del(temp,@item.id,-@number_window.number)
  374.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  375.        @buy_window.active = false
  376.        @buy_window.visible = false
  377.        @buy_window.help_window = @help_window
  378.        @gold_window.refresh
  379.        @sell_window.refresh
  380.        @status_window.refresh
  381.        # 窗口状态转向卖出模式
  382.        @sell_window.active = true
  383.        @sell_window.visible = true
  384.        @status_window.visible = false
  385.      end
  386.      return
  387.    end
  388. end
  389. # 删除可出售商品内容
  390. def goods_del(kind,id,delnumber)
  391.    dl = delnumber
  392.    for dt in $game_system.goods[@shop_now]
  393.      if (dt[0]==kind) and (dt[1]==id)
  394.        dt[2] -= dl
  395.        dt[2] = [dt[2],99].min
  396.        if dt[2] == 0
  397.          $game_system.goods[@shop_now].delete(dt)
  398.        end
  399.        return
  400.      end
  401.    end
  402.    $game_system.goods[@shop_now].push([kind,id,-delnumber])
  403. end
  404. end

  405. #==============================================================================
  406. # ■ Window_ShopBuy_Va
  407. #------------------------------------------------------------------------------
  408. #  商店画面、浏览显示可以购买的商品的窗口。
  409. #==============================================================================

  410. class Window_ShopBuy_Va < Window_Selectable
  411. attr_accessor :shop_goods
  412. #--------------------------------------------------------------------------
  413. # ● 初始化对像
  414. #     shop_goods : 商品
  415. #--------------------------------------------------------------------------
  416. def initialize(shop_goods)
  417.    super(0, 128, 368, 352)
  418.    @shop_goods = shop_goods
  419.    refresh
  420.    self.index = 0
  421. end
  422. #--------------------------------------------------------------------------
  423. # ● 获取物品
  424. #--------------------------------------------------------------------------
  425. def item
  426.    return @data[self.index]
  427. end
  428. #--------------------------------------------------------------------------
  429. # ● 获取物品
  430. #--------------------------------------------------------------------------
  431. def item_number
  432.    return @data_number[self.index]
  433. end
  434. #--------------------------------------------------------------------------
  435. # ● 刷新
  436. #--------------------------------------------------------------------------
  437. def refresh
  438.    if self.contents != nil
  439.      self.contents.dispose
  440.      self.contents = nil
  441.    end
  442.    @data = []
  443.    @data_number = []
  444.    for goods_item in @shop_goods
  445.      case goods_item[0]
  446.      when 0
  447.        item = $data_items[goods_item[1]]
  448.      when 1
  449.        item = $data_weapons[goods_item[1]]
  450.      when 2
  451.        item = $data_armors[goods_item[1]]
  452.      end
  453.      if (item != nil) and (goods_item[2] != 0)
  454.        @data.push(item)
  455.        @data_number.push(goods_item[2])
  456.      else
  457.        @data.delete(item)
  458.      end
  459.    end
  460.    # 如果项目数不是 0 就生成位图、描绘全部项目
  461.    @item_max = @data.size
  462.    if @item_max > 0
  463.      self.contents = Bitmap.new(width - 32, row_max * 32)
  464.      for i in 0...@item_max
  465.        draw_item(i)
  466.      end
  467.    end
  468. end
  469. #--------------------------------------------------------------------------
  470. # ● 描绘羡慕
  471. #     index : 项目编号
  472. #--------------------------------------------------------------------------
  473. def draw_item(index)
  474.    item = @data[index]
  475.    # 获取物品所持数
  476.    case item
  477.    when RPG::Item
  478.      number = $game_party.item_number(item.id)
  479.    when RPG::Weapon
  480.      number = $game_party.weapon_number(item.id)
  481.    when RPG::Armor
  482.      number = $game_party.armor_number(item.id)
  483.    end
  484.    x = 4
  485.    y = index * 32
  486.    rect = Rect.new(x, y, self.width - 32, 32)
  487.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  488.    bitmap = RPG::Cache.icon(item.icon_name)
  489.    opacity = self.contents.font.color == normal_color ? 255 : 128
  490.    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  491.    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  492.    self.contents.draw_text(x + 240, y, 88, 32, "存有  ", 2)
  493.    self.contents.draw_text(x + 240, y, 88, 32, @data_number[index].to_s, 2)
  494. #    self.contents.draw_text(x + 180, y, 88, 32, item.price.to_s, 2)
  495. end
  496. #--------------------------------------------------------------------------
  497. # ● 刷新帮助文本
  498. #--------------------------------------------------------------------------
  499. def update_help
  500.    @help_window.set_text(self.item == nil ? "" : self.item.description)
  501. end
  502. end




  503. #==============================================================================
  504. # ■ Window_ShopCommand_Va
  505. #------------------------------------------------------------------------------
  506. #  商店画面、选择要做的事的窗口
  507. #==============================================================================

  508. class Window_ShopCommand_Va < Window_Selectable
  509. #--------------------------------------------------------------------------
  510. # ● 初始化对像
  511. #--------------------------------------------------------------------------
  512. def initialize
  513.    super(0, 64, 480, 64)
  514.    self.contents = Bitmap.new(width - 32, height - 32)
  515.    @item_max = 3
  516.    @column_max = 3
  517.    @commands = ["取出物品", "存入电脑", "离开"]
  518.    refresh
  519.    self.index = 0
  520. end
  521. #--------------------------------------------------------------------------
  522. # ● 刷新
  523. #--------------------------------------------------------------------------
  524. def refresh
  525.    self.contents.clear
  526.    for i in 0...@item_max
  527.      draw_item(i)
  528.    end
  529. end
  530. #--------------------------------------------------------------------------
  531. # ● 描绘项目
  532. #     index : 项目编号
  533. #--------------------------------------------------------------------------
  534. def draw_item(index)
  535.    x = 4 + index * 160
  536.    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  537. end
  538. end




  539. #==============================================================================
  540. # ■ Window_ShopSell_Va
  541. #------------------------------------------------------------------------------
  542. #  商店画面、浏览显示可以卖掉的商品的窗口。
  543. #==============================================================================

  544. class Window_ShopSell_Va < Window_Selectable
  545. #--------------------------------------------------------------------------
  546. # ● 初始化对像
  547. #--------------------------------------------------------------------------
  548. def initialize
  549.    super(0, 128, 640, 352)
  550.    @column_max = 2
  551.    refresh
  552.    self.index = 0
  553. end
  554. #--------------------------------------------------------------------------
  555. # ● 获取物品
  556. #--------------------------------------------------------------------------
  557. def item
  558.    return @data[self.index]
  559. end
  560. #--------------------------------------------------------------------------
  561. # ● 刷新
  562. #--------------------------------------------------------------------------
  563. def refresh
  564.    if self.contents != nil
  565.      self.contents.dispose
  566.      self.contents = nil
  567.    end
  568.    @data = []
  569.    for i in 1...$data_items.size
  570.      if $game_party.item_number(i) > 0
  571.        @data.push($data_items[i])
  572.      end
  573.    end
  574.    for i in 1...$data_weapons.size
  575.      if $game_party.weapon_number(i) > 0
  576.        @data.push($data_weapons[i])
  577.      end
  578.    end
  579.    for i in 1...$data_armors.size
  580.      if $game_party.armor_number(i) > 0
  581.        @data.push($data_armors[i])
  582.      end
  583.    end
  584.    # 如果项目数不是 0 就生成位图、描绘全部项目
  585.    @item_max = @data.size
  586.    if @item_max > 0
  587.      self.contents = Bitmap.new(width - 32, row_max * 32)
  588.      for i in 0...@item_max
  589.        draw_item(i)
  590.      end
  591.    end
  592. end
  593. #--------------------------------------------------------------------------
  594. # ● 描绘项目
  595. #     index : 项目标号
  596. #--------------------------------------------------------------------------
  597. def draw_item(index)
  598.    item = @data[index]
  599.    case item
  600.    when RPG::Item
  601.      number = $game_party.item_number(item.id)
  602.    when RPG::Weapon
  603.      number = $game_party.weapon_number(item.id)
  604.    when RPG::Armor
  605.      number = $game_party.armor_number(item.id)
  606.    end
  607.    x = 4 + index % 2 * (288 + 32)
  608.    y = index / 2 * 32
  609.    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  610.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  611.    bitmap = RPG::Cache.icon(item.icon_name)
  612.    opacity = self.contents.font.color == normal_color ? 255 : 128
  613.    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  614.    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  615.    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  616.    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  617. end
  618. #--------------------------------------------------------------------------
  619. # ● 刷新帮助文本
  620. #--------------------------------------------------------------------------
  621. def update_help
  622.    @help_window.set_text(self.item == nil ? "" : self.item.description)
  623. end
  624. end



  625. #==============================================================================
  626. # ■ Window_ShopNumber_Va
  627. #------------------------------------------------------------------------------
  628. #  商店画面、输入买卖数量的窗口。
  629. #==============================================================================

  630. class Window_ShopNumber_Va < Window_Base
  631. #--------------------------------------------------------------------------
  632. # ● 初始化对像
  633. #--------------------------------------------------------------------------
  634. def initialize
  635.    super(0, 128, 368, 352)
  636.    self.contents = Bitmap.new(width - 32, height - 32)
  637.    @item = nil
  638.    @max = 1
  639.    @price = 0
  640.    @number = 1
  641. end
  642. #--------------------------------------------------------------------------
  643. # ● 设置物品、最大个数、价格
  644. #--------------------------------------------------------------------------
  645. def set(item, max, price)
  646.    @item = item
  647.    @max = max
  648.    @price = price
  649.    @number = 1
  650.    refresh
  651. end
  652. #--------------------------------------------------------------------------
  653. # ● 被输入的件数设置
  654. #--------------------------------------------------------------------------
  655. def number
  656.    return @number
  657. end
  658. #--------------------------------------------------------------------------
  659. # ● 刷新
  660. #--------------------------------------------------------------------------
  661. def refresh
  662.    self.contents.clear
  663.    draw_item_name(@item, 4, 96)
  664.    self.contents.font.color = normal_color
  665.    self.contents.draw_text(272, 96, 32, 32, "×")
  666.    self.contents.draw_text(308, 96, 24, 32, @number.to_s, 2)
  667.    self.cursor_rect.set(304, 96, 32, 32)
  668. end
  669. #--------------------------------------------------------------------------
  670. # ● 刷新画面
  671. #--------------------------------------------------------------------------
  672. def update
  673.    super
  674.    if self.active
  675.      # 光标右 (+1)
  676.      if Input.repeat?(Input::RIGHT) and @number < @max
  677.        $game_system.se_play($data_system.cursor_se)
  678.        @number += 1
  679.        refresh
  680.      end
  681.      # 光标左 (-1)
  682.      if Input.repeat?(Input::LEFT) and @number > 1
  683.        $game_system.se_play($data_system.cursor_se)
  684.        @number -= 1
  685.        refresh
  686.      end
  687.      # 光标上 (+10)
  688.      if Input.repeat?(Input::UP) and @number < @max
  689.        $game_system.se_play($data_system.cursor_se)
  690.        @number = [@number + 10, @max].min
  691.        refresh
  692.      end
  693.      # 光标下 (-10)
  694.      if Input.repeat?(Input::DOWN) and @number > 1
  695.        $game_system.se_play($data_system.cursor_se)
  696.        @number = [@number - 10, 1].max
  697.        refresh
  698.      end
  699.    end
  700. end
  701. end




  702. #==============================================================================
  703. # ■ Window_ShopStatus_Va
  704. #------------------------------------------------------------------------------
  705. #  商店画面、显示物品所持数与角色装备的窗口。
  706. #==============================================================================

  707. class Window_ShopStatus_Va < Window_Base
  708. #--------------------------------------------------------------------------
  709. # ● 初始化对像
  710. #--------------------------------------------------------------------------
  711. def initialize
  712.    super(368, 128, 272, 352)
  713.    self.contents = Bitmap.new(width - 32, height - 32)
  714.    @item = nil
  715.    refresh
  716. end
  717. #--------------------------------------------------------------------------
  718. # ● 刷新
  719. #--------------------------------------------------------------------------
  720. def refresh
  721.    self.contents.clear
  722.    self.contents.font.color = system_color
  723.    self.contents.font.size -= 4
  724.    self.contents.draw_text(0, 0, 252, 32, "每次存入需要1G的传输费.")
  725.    self.contents.draw_text(0, 34, 252, 32, "取出物品无须任何费用.")
  726.    self.contents.font.size += 4
  727. end
  728. #--------------------------------------------------------------------------
  729. # ● 设置物品
  730. #     item : 新的物品
  731. #--------------------------------------------------------------------------
  732. def item=(item)
  733.    if @item != item
  734.      @item = item
  735.      refresh
  736.    end
  737. end
  738. end
复制代码
防卡脚本(实用):
  1. #======================================
  2. # ■ Anti Event Lag Script
  3. #======================================
  4. #  By: Near Fantastica
  5. #   Date: 12.06.05
  6. #   Version: 3
  7. #======================================

  8. #======================================
  9. # ■ Game_Map
  10. #======================================

  11. class Game_Map
  12. #--------------------------------------------------------------------------
  13. def in_range?(object)
  14. screne_x = $game_map.display_x
  15. screne_x -= 256
  16. screne_y = $game_map.display_y
  17. screne_y -= 256
  18. screne_width = $game_map.display_x
  19. screne_width += 2816
  20. screne_height = $game_map.display_y
  21. screne_height += 2176
  22. return false if object.real_x <= screne_x
  23. return false if object.real_x >= screne_width
  24. return false if object.real_y <= screne_y
  25. return false if object.real_y >= screne_height
  26. return true
  27. end
  28. #--------------------------------------------------------------------------
  29. def update
  30. if $game_map.need_refresh
  31.    refresh
  32. end
  33. if @scroll_rest > 0
  34.    distance = 2 ** @scroll_speed
  35.    case @scroll_direction
  36.    when 2
  37.      scroll_down(distance)
  38.    when 4
  39.      scroll_left(distance)
  40.    when 6  
  41.      scroll_right(distance)
  42.    when 8  
  43.      scroll_up(distance)
  44.    end
  45.    @scroll_rest -= distance
  46. end
  47. for event in @events.values
  48.    if in_range?(event) or event.trigger == 3 or event.trigger == 4
  49.      event.update
  50.    end
  51. end
  52. for common_event in @common_events.values
  53.    common_event.update
  54. end
  55. @fog_ox -= @fog_sx / 8.0
  56. @fog_oy -= @fog_sy / 8.0
  57. if @fog_tone_duration >= 1
  58.    d = @fog_tone_duration
  59.    target = @fog_tone_target
  60.    @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
  61.    @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
  62.    @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
  63.    @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
  64.    @fog_tone_duration -= 1
  65. end
  66. if @fog_opacity_duration >= 1
  67.    d = @fog_opacity_duration
  68.    @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
  69.    @fog_opacity_duration -= 1
  70. end
  71. end
  72. end

  73. #======================================
  74. # ■ Spriteset_Map
  75. #======================================

  76. class Spriteset_Map
  77. #--------------------------------------------------------------------------
  78. def in_range?(object)
  79. screne_x = $game_map.display_x
  80. screne_x -= 256
  81. screne_y = $game_map.display_y
  82. screne_y -= 256
  83. screne_width = $game_map.display_x
  84. screne_width += 2816
  85. screne_height = $game_map.display_y
  86. screne_height += 2176
  87. return false if object.real_x <= screne_x
  88. return false if object.real_x >= screne_width
  89. return false if object.real_y <= screne_y
  90. return false if object.real_y >= screne_height
  91. return true
  92. end
  93. #--------------------------------------------------------------------------
  94. def update
  95. if @panorama_name != $game_map.panorama_name or
  96.     @panorama_hue != $game_map.panorama_hue
  97.    @panorama_name = $game_map.panorama_name
  98.    @panorama_hue = $game_map.panorama_hue
  99.    if @panorama.bitmap != nil
  100.      @panorama.bitmap.dispose
  101.      @panorama.bitmap = nil
  102.    end
  103.    if @panorama_name != ""
  104.      @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  105.    end
  106.    Graphics.frame_reset
  107. end
  108. if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  109.    @fog_name = $game_map.fog_name
  110.    @fog_hue = $game_map.fog_hue
  111.    if @fog.bitmap != nil
  112.      @fog.bitmap.dispose
  113.      @fog.bitmap = nil
  114.    end
  115.    if @fog_name != ""
  116.      @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  117.    end
  118.    Graphics.frame_reset
  119. end
  120. @tilemap.ox = $game_map.display_x / 4
  121. @tilemap.oy = $game_map.display_y / 4
  122. @tilemap.update
  123. @panorama.ox = $game_map.display_x / 8
  124. @panorama.oy = $game_map.display_y / 8
  125. @fog.zoom_x = $game_map.fog_zoom / 100.0
  126. @fog.zoom_y = $game_map.fog_zoom / 100.0
  127. @fog.opacity = $game_map.fog_opacity
  128. @fog.blend_type = $game_map.fog_blend_type
  129. @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  130. @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  131. @fog.tone = $game_map.fog_tone
  132. i=0
  133. for sprite in @character_sprites
  134.    if sprite.character.is_a?(Game_Event)
  135.      if in_range?(sprite.character) or sprite.character.trigger == 3 or sprite.character.trigger == 4
  136.        sprite.update
  137.        i+=1
  138.      end
  139.    else
  140.      sprite.update
  141.      i+=1
  142.    end
  143. end
  144. #p i
  145. @weather.type = $game_screen.weather_type
  146. @weather.max = $game_screen.weather_max
  147. @weather.ox = $game_map.display_x / 4
  148. @weather.oy = $game_map.display_y / 4
  149. @weather.update
  150. for sprite in @picture_sprites
  151.    sprite.update
  152. end
  153. @timer_sprite.update
  154. @viewport1.tone = $game_screen.tone
  155. @viewport1.ox = $game_screen.shake
  156. @viewport3.color = $game_screen.flash_color
  157. @viewport1.update
  158. @viewport3.update
  159. end
  160. end
复制代码
回复 支持 1 反对 0

使用道具 举报

Lv2.观梦者

梦石
0
星屑
319
在线时间
890 小时
注册时间
2009-10-12
帖子
1829
3
发表于 2014-5-4 11:10:37 手机端发表。 | 只看该作者
你知道吗 国外有rmxp的口袋改版支持双屏,全复刻黑白战斗系统 下屏菜单访做得也很像,都是模拟nds的呀~
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
40170
在线时间
7506 小时
注册时间
2009-7-6
帖子
13489

开拓者贵宾

4
发表于 2014-5-4 16:25:59 | 只看该作者
日月星辰 发表于 2014-5-4 11:10
你知道吗 国外有rmxp的口袋改版支持双屏,全复刻黑白战斗系统 下屏菜单访做得也很像,都是模拟nds的呀~ ...

这个游戏我有收藏哦《Eméraude céléste》

另外楼主发个范例吧
RGDirect - DirectX驱动的RGSS,点我了解.
RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
67
在线时间
76 小时
注册时间
2015-5-10
帖子
18
5
发表于 2015-5-23 23:30:36 | 只看该作者
怎么宠物战斗
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-8 01:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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