查看: 82|回复: 0

[转载发布] 技能书 修改Scene_Item

[复制链接]
  • TA的每日心情
    开心
    6 小时前
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元一千年八月五日(秋) | 显示全部楼层 |阅读模式
    经常会看到有人问RMXP的技能书的技能书怎么制作,回答经常是状态法,但是,如果角色很多的话,用状态法实在太麻烦了,所以就有了这个脚本。
    看到@天地有正气 写了个有关技能书的脚本,于是嘛。。。
    我也动手写了个。。。思路不同。。。
    用法:
    替换原来的Scene_Item
    "技能书"物品的分散度为 100
    SP 回复量 为 所学习技能的 ID
    如果还是不会的话请看楼下截图或范例。。。
    先上脚本(脚本修改的地方前面带“★”、“☆”):
    1. #==============================================================================# ■ Scene_Item#------------------------------------------------------------------------------#  处理物品画面的类。#   "技能书"物品的分散度为 100#   SP 回复量 为 所学习技能的 ID#   ━━By zx56783586#==============================================================================class Scene_Item  #--------------------------------------------------------------------------  # ● 主处理  #--------------------------------------------------------------------------  def main    # 生成帮助窗口、物品窗口    @help_window = Window_Help.new    @item_window = Window_Item.new    # 关联帮助窗口    @item_window.help_window = @help_window    # 生成目标窗口 (设置为不可见・不活动)    @target_window = Window_Target.new    @target_window.visible = false    @target_window.active = false    # 执行过度    Graphics.transition    # 主循环    loop do      # 刷新游戏画面      Graphics.update      # 刷新输入信息      Input.update      # 刷新画面      update      # 如果画面切换就中断循环      if $scene != self        break      end    end    # 装备过渡    Graphics.freeze    # 释放窗口    @help_window.dispose    @item_window.dispose    @target_window.dispose  end  #--------------------------------------------------------------------------  # ● 刷新画面  #--------------------------------------------------------------------------  def update    # 刷新窗口    @help_window.update    @item_window.update    @target_window.update    # 物品窗口被激活的情况下: 调用 update_item    if @item_window.active      update_item      return    end    # 目标窗口被激活的情况下: 调用 update_target    if @target_window.active      update_target      return    end  end  #--------------------------------------------------------------------------  # ● 刷新画面 (物品窗口被激活的情况下)  #--------------------------------------------------------------------------  def update_item    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 切换到菜单画面      $scene = Scene_Menu.new(0)      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 获取物品窗口当前选中的物品数据      @item = @item_window.item      # 不使用物品的情况下      unless @item.is_a?(RPG::Item)        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 不能使用的情况下      unless $game_party.item_can_use?(@item.id)        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 演奏确定 SE      $game_system.se_play($data_system.decision_se)      # 效果范围是我方的情况下      if @item.scope >= 3        # 激活目标窗口        @item_window.active = false        @target_window.x = (@item_window.index + 1) % 2 * 304        @target_window.visible = true        @target_window.active = true        # 设置效果范围 (单体/全体) 的对应光标位置        if @item.scope == 4 || @item.scope == 6          @target_window.index = -1        else          @target_window.index = 0        end      # 效果在我方以外的情况下      else        # 公共事件 ID 有效的情况下        if @item.common_event_id > 0          # 预约调用公共事件          $game_temp.common_event_id = @item.common_event_id          # 演奏物品使用时的 SE          $game_system.se_play(@item.menu_se)          # 消耗品的情况下          if @item.consumable            # 使用的物品数减 1            $game_party.lose_item(@item.id, 1)            # 再描绘物品窗口的项目            @item_window.draw_item(@item_window.index)          end          # 切换到地图画面          $scene = Scene_Map.new          return        end      end      return    end  end  #--------------------------------------------------------------------------  # ● 刷新画面 (目标窗口被激活的情况下)  #--------------------------------------------------------------------------  def update_target    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 由于物品用完而不能使用的场合      unless $game_party.item_can_use?(@item.id)        # 再次生成物品窗口的内容        @item_window.refresh      end      # 删除目标窗口      @item_window.active = true      @target_window.visible = false      @target_window.active = false      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 如果物品用完的情况下      if $game_party.item_number(@item.id) == 0        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 目标是全体的情况下      if @target_window.index == -1        #★        if @item.variance == 100          case $game_party.actors.size          when 1            $game_party.actors[0].learn_skill(@item.recover_sp)          when 2            $game_party.actors[0].learn_skill(@item.recover_sp)            $game_party.actors[1].learn_skill(@item.recover_sp)          when 3            $game_party.actors[0].learn_skill(@item.recover_sp)            $game_party.actors[1].learn_skill(@item.recover_sp)            $game_party.actors[2].learn_skill(@item.recover_sp)          when 4            $game_party.actors[0].learn_skill(@item.recover_sp)            $game_party.actors[1].learn_skill(@item.recover_sp)            $game_party.actors[2].learn_skill(@item.recover_sp)            $game_party.actors[3].learn_skill(@item.recover_sp)          end          $game_party.lose_item(@item.id, 1)          @item_window.draw_item(@item_window.index)        else          used = false          for i in $game_party.actors            used |= i.item_effect(@item)          end        end        #☆         # 对同伴全体应用物品使用效果      end      # 目标是单体的情况下      if @target_window.index >= 0        #★        if @item.variance == 100          $game_party.actors[@target_window.index].learn_skill(@item.recover_sp)          $game_party.lose_item(@item.id, 1)          @item_window.draw_item(@item_window.index)        else          # 对目标角色应用物品的使用效果          target = $game_party.actors[@target_window.index]          used = target.item_effect(@item)        end        #☆      end      # 使用物品的情况下      if used        # 演奏物品使用时的 SE        $game_system.se_play(@item.menu_se)        # 消耗品的情况下        if @item.consumable          # 使用的物品数减 1          $game_party.lose_item(@item.id, 1)          # 再描绘物品窗口的项目          @item_window.draw_item(@item_window.index)        end        # 再生成目标窗口的内容        @target_window.refresh        # 全灭的情况下        if $game_party.all_dead?          # 切换到游戏结束画面          $scene = Scene_Gameover.new          return        end        # 公共事件 ID 有效的情况下        if @item.common_event_id > 0          # 预约调用公共事件          $game_temp.common_event_id = @item.common_event_id          # 切换到地图画面          $scene = Scene_Map.new          return        end      end      # 无法使用物品的情况下      unless used        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)      end      return    end  endend复制代码
    复制代码
    @protosssonny   

                 本帖来自P1论坛作者zhouzhuofan1,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=343885  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-10 16:12 , Processed in 0.049104 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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