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

Project1

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

[已经过期] 关于“装备等级限制”

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1556
在线时间
626 小时
注册时间
2010-8-5
帖子
451
跳转到指定楼层
1
发表于 2014-10-5 12:50:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我不知道怎么整合..这个是我的物品界面.
RUBY 代码复制
  1. #==============================================================================
  2. # ■ System
  3. #------------------------------------------------------------------------------
  4. #  我的系统。
  5. #==============================================================================
  6. module System
  7.   #============================================================================
  8.   # ■ Interface
  9.   #----------------------------------------------------------------------------
  10.   #  游戏界面。
  11.   #============================================================================
  12.   class Interface
  13.     #------------------------------------------------------------------------
  14.     # ● 生成物品内容
  15.     #------------------------------------------------------------------------
  16.     def item_main
  17.       # 已经生成的情况下
  18.       unless @item_window.nil?
  19.         dispose_item
  20.         return
  21.       end
  22.       # 已经生成召唤兽的情况下
  23.       if Picture.exist?($图表[24])
  24.         # 释放召唤兽属性画面
  25.         dispose_baby
  26.       end
  27.       # 初始化对象
  28.       $活动窗口 = "物品"
  29.       $cash = true
  30.       # 生成窗口
  31.       $图表[22] = Picture.new("UI/道具行囊",0,0,600)
  32.       @item_window = Window_Item.new(@actor)
  33.       @item_window.z = 600
  34.       @equip_window = Window_Equip.new(@actor)
  35.       @equip_window.z = 600
  36.       # 关联帮助窗口
  37.       @item_window.help_window = Window_Help.new
  38.       @equip_window.help_window = Window_Help.new
  39.       # 生成按钮
  40.       @item_exit = Picture.new("UI/叉",291,6,600,[0,0,4,1])
  41.       @pack = Picture.new("UI/道具",27,410,600,[1.5,0,3,1])
  42.       @wallet = Picture.new("UI/行囊",72,410,600,[0,0,3,1])
  43.       [url=home.php?mod=space&uid=358351]@talisman[/url] = Picture.new("UI/法宝",117,410,600,[0,0,3,1])
  44.       @arrange = Picture.new("UI/整理",162,410,600,[0,0,3,1])
  45.       [url=home.php?mod=space&uid=333762]@cash[/url] = Picture.new("UI/现金",7,151,600,[0,0,3,1])
  46.       @select_cursor = Picture.new("UI/锁定",0,0,0)
  47.       @item_button = [@item_exit,@pack,@wallet,@talisman,@arrange,@cash]
  48.       @goos = @pack
  49.     end
  50.     #------------------------------------------------------------------------
  51.     # ● 刷新画面
  52.     #------------------------------------------------------------------------
  53.     def update_item
  54.       return if !Picture.exist?(@item_window) or $exit
  55.       # 刷新画面 Z 坐标
  56.       if @active_window[0] != $活动窗口
  57.         $图表[22].z = $活动窗口 != "物品" ? 500 : 600
  58.         for i in [email]0...@item_button.nitems[/email]
  59.           @item_button[i].z = $活动窗口 != "物品" ? 505 : 600
  60.         end
  61.         @item_window.z = @equip_window.z = $图表[22].z
  62.         @active_window[0] = $活动窗口
  63.       end
  64.       # 选中窗口为自身并按下鼠标左键的情况下
  65.       if $select_window[0] == $图表[22] and Mouse.trigger?(0x01)
  66.         $活动窗口 = "物品"
  67.       end
  68.       return if $活动窗口 == "任务"
  69.       # 刷新物品窗口
  70.       @item_window.update
  71.       # 刷新装备窗口
  72.       @equip_window.update
  73.       # 刷新物品选择
  74.       select_item
  75.       # 刷新装备选择
  76.       select_equip
  77.       # 刷新按钮
  78.       item_button
  79.       # 刷新物品窗口
  80.       @item_window.refresh if $item_refresh
  81.       # 刷新提示
  82.       @item_help.update if @item_help != nil and !@item_help.disposed?
  83.       # 当按下鼠标右键时
  84.       if @item_icon != nil or @equip_icon != nil and Mouse.trigger?(0x02)
  85.         # 还原选中物品
  86.         select_return
  87.         return
  88.       end
  89.       # 当鼠标在窗口内的情况下
  90.       if Mouse.in_rect?($图表[22]) and !@item_window.nil?
  91.         # 装备和物品窗口未激活的情况下
  92.         unless @item_window.active or @equip_window.active
  93.           if @old_x != @mouse_x or @old_y != @mouse_y
  94.             @count = 0
  95.             @old_x,@old_y = Mouse.get_mouse_pos
  96.             @item_help.dispose if @item_help != nil and !@item_help.disposed?
  97.           else
  98.             @count = @count.to_i + 1
  99.             if @count > 20
  100.               @item_help.dispose if @item_help != nil and !@item_help.disposed?
  101.               text = "右键点击界面边缘可以快速关闭界面。"
  102.               @item_help = Window_Warn.new(text,@mouse_x-10,@mouse_y-60)
  103.               @count = 0
  104.             end
  105.           end
  106.           # 当按下鼠标右键时
  107.           if Mouse.trigger?(0x02)
  108.             # 释放物品画面
  109.             dispose_item
  110.             return
  111.           end
  112.         else
  113.           @item_help.dispose if @item_help != nil and !@item_help.disposed?
  114.         end
  115.       else
  116.         # 当按下鼠标左键时
  117.         if @item_icon != nil or @equip_icon != nil and Mouse.trigger?(0x01)
  118.           # 丟失物品
  119.           lose_item(false)
  120.         end
  121.         @item_help.dispose if @item_help != nil and !@item_help.disposed?
  122.       end
  123.       # 刷新选中图标
  124.       if @item_icon != nil
  125.         @item_icon.x = @mouse_x - @initial_x
  126.         @item_icon.y = @mouse_y - @initial_y
  127.       elsif @equip_icon != nil
  128.         @equip_icon.x = @mouse_x - @initial_x
  129.         @equip_icon.y = @mouse_y - @initial_y
  130.       end
  131.       # 取消选中
  132.       if @item_icon.nil? and @equip_icon.nil?
  133.         @select_cursor.z = -10 if Picture.exist?(@select_cursor)
  134.         $select_item = false
  135.       end
  136.       # 刷新金钱
  137.       if @old_gold != [$data.cash,$data.store,$data.deposit]
  138.         # 刷新装备窗口
  139.         @equip_window.refresh
  140.         @old_gold = [$data.cash,$data.store,$data.deposit]
  141.       end
  142.     end
  143.     #------------------------------------------------------------------------
  144.     # ● 刷新按钮
  145.     #------------------------------------------------------------------------
  146.     def item_button
  147.       return if !Mouse.in_rect?($图表[22])
  148.       for i in [email]0...@item_button.nitems[/email]
  149.         System.update_button(@item_button[i],$事件)
  150.         if $事件[@item_button[i]][1]
  151.           case i
  152.           when 0 # 退出
  153.             dispose_item
  154.             return
  155.           when 1 # 道具
  156.             # 没有点中的物品
  157.             if @item_icon.nil?
  158.               @goos = @pack
  159.               @item_window.data = $data.pack
  160.             else
  161.               # 行囊转物品
  162.               if @goos != @pack
  163.                 if $data.pack.include?(nil)
  164.                   if @select_item[0].is_a?(RPG::Item)
  165.                     $data.gain_item(@select_item[0].standard, @select_item[1], $data.pack)
  166.                   else
  167.                     $data.pack[$data.empty($data.pack)] = @select_item
  168.                   end
  169.                   # 释放图标
  170.                   Picture.dispose(@item_icon)
  171.                   @item_icon = nil
  172.                 else
  173.                   text = "包裹已满!"
  174.                   $help = Window_Warn.new(text,120,227,1500,14,true)
  175.                   $help._width = 400
  176.                 end
  177.               end
  178.             end
  179.             # 刷新物品窗口
  180.             @item_window.refresh
  181.           when 2 # 行囊
  182.             # 没有点中的物品
  183.             if @item_icon.nil?
  184.               @goos = @wallet
  185.               @item_window.data = $data.wallet
  186.             else
  187.               if @goos != @wallet
  188.                 if $data.wallet.include?(nil)
  189.                   if @select_item[0].is_a?(RPG::Item)
  190.                     $data.gain_item(@select_item[0].standard, @select_item[1], $data.wallet)
  191.                   else
  192.                     $data.wallet[$data.empty($data.wallet)] = @select_item
  193.                   end
  194.                   # 释放图标
  195.                   Picture.dispose(@item_icon)
  196.                   @item_icon = nil
  197.                 else
  198.                   text = "行囊已满!"
  199.                   $help = Window_Warn.new(text,120,227,1500,14,true)
  200.                   $help._width = 400
  201.                 end
  202.               end
  203.             end
  204.             # 刷新物品窗口
  205.             @item_window.refresh
  206.           when 3 # 法宝
  207.             # 没有点中的物品
  208.             if @item_icon.nil?
  209.               @goos = @talisman
  210.               @item_window.data = $data.talisman
  211.             else
  212.               if @goos != @talisman
  213.                 if @select_item.is_a?(RPG::Weapon) and @select_item[0].element_set.include?(27)
  214.                   if $data.talisman.include?(nil)
  215.                     $data.talisman[$data.empty($data.talisman)] = @select_item
  216.                     # 释放图标
  217.                     Picture.dispose(@item_icon)
  218.                     @item_icon = nil
  219.                   else
  220.                     text = "法宝已满!"
  221.                     $help = Window_Warn.new(text,120,227,1500,14,true)
  222.                     $help._width = 400
  223.                   end
  224.                 else
  225.                   text = "选中物品不是法宝!"
  226.                   $help = Window_Warn.new(text,120,227,1500,14,true)
  227.                   $help._width = 400
  228.                 end
  229.               end
  230.             end
  231.             # 刷新物品窗口
  232.             @item_window.refresh
  233.           when 4 # 整理
  234.             case @goos
  235.             when @pack
  236.               $data.pack = $data.item_arrange($data.pack)
  237.               @item_window.data = $data.pack
  238.             when @wallet
  239.               $data.wallet = $data.item_arrange($data.wallet)
  240.               @item_window.data = $data.wallet
  241.             when @talisman
  242.               $data.talisman = $data.item_arrange($data.talisman)
  243.               @item_window.data = $data.talisman
  244.             end
  245.             # 刷新物品窗口
  246.             @item_window.refresh
  247.           when 5 # 现金
  248.             @cash.bitmap.clear
  249.             @cash.bitmap = Bitmap.new($cash ? "UI/储备" : "UI/现金")
  250.             @cash.src_rect.set(0, 0, @cash.bitmap.width/3, @cash.bitmap.height)
  251.             $cash = $cash ? false : true
  252.             @equip_window.refresh
  253.           end
  254.         end
  255.       end
  256.       @goos.src_rect.set(86,0,43,22)
  257.     end
  258.     #------------------------------------------------------------------------
  259.     # ● 释放物品界面
  260.     #------------------------------------------------------------------------
  261.     def dispose_item
  262.       return if !Picture.exist?(@item_window)
  263.       # 还原物品
  264.       select_return
  265.       @item_window.dispose
  266.       @item_window.help_window.dispose
  267.       @item_window = nil
  268.       @equip_window.dispose
  269.       @equip_window.help_window.dispose
  270.       for i in @item_button
  271.         Picture.dispose(i)
  272.       end
  273.       Picture.dispose($图表[22])
  274.       Picture.dispose(@select_cursor)
  275.       @item_help.dispose if Picture.exist?(@item_help)
  276.     end
  277.     #------------------------------------------------------------------------
  278.     # ● 还原选中物品或装备
  279.     #------------------------------------------------------------------------
  280.     def select_return
  281.       if @item_icon != nil
  282.         # 恢复原物品
  283.         @item_window.data[@select_index] = @select_item
  284.         # 释放图标
  285.         Picture.dispose(@item_icon)
  286.         @item_icon = nil
  287.         # 刷新物品窗口
  288.         @item_window.refresh
  289.       end
  290.       if @equip_icon != nil
  291.         # 恢复原物品
  292.         @actor.armor2_id = @select_item.id if @select_index == 0
  293.         @actor.armor4_id = @select_item.id if @select_index == 1
  294.         @actor.weapon_id = @select_item.id if @select_index == 2
  295.         @actor.armor3_id = @select_item.id if @select_index == 3
  296.         @actor.armor1_id = @select_item.id if @select_index == 4
  297.         @actor.armor5_id = @select_item.id if @select_index == 5
  298.         # 释放图标
  299.         Picture.dispose(@equip_icon)
  300.         @equip_icon = nil
  301.         # 刷新装备窗口
  302.         @equip_window.refresh
  303.       end
  304.     end
  305.     #------------------------------------------------------------------------
  306.     # ● 刷新物品选择
  307.     #------------------------------------------------------------------------
  308.     def select_item
  309.       return if !@item_window.active
  310.       # 获取物品
  311.       item = @item_window.item
  312.       # 当按下鼠标左键时
  313.       if Mouse.trigger?(0x01)
  314.         #--------------------------------------------------------------------
  315.         # ● 拥有选中【物品】
  316.         #--------------------------------------------------------------------
  317.         # 拥有选中物品
  318.         if @item_icon != nil
  319.           # 对象存在物品的情况下
  320.           if item != nil and item[0].is_a?(RPG::Item) and @select_item[0].is_a?(RPG::Item)
  321.             # 不是特殊物品
  322.             unless item[0].element_set.include?(26)
  323.               # 当物品为同类物品的情况下
  324.               if item[0].standard == @select_item[0].standard and item[1] < 20
  325.                 if item[1] + @select_item[1] <= 20
  326.                   item[1] += @select_item[1]
  327.                   # 释放图标
  328.                   Picture.dispose(@item_icon)
  329.                   @item_icon = nil
  330.                 else
  331.                   @select_item[1] -= (20 - item[1])
  332.                   item[1] = 20
  333.                   # 还原物品
  334.                   select_return
  335.                 end
  336.                 # 刷新物品窗口
  337.                 @item_window.refresh
  338.                 return
  339.               end
  340.             end
  341.           end
  342.           # 选中物品与原选中物品兑换
  343.           @item_window.data[@select_index] = item
  344.           @item_window.data[@item_window.index] = @select_item
  345.           # 释放图标
  346.           Picture.dispose(@item_icon)
  347.           @item_icon = nil
  348.           # 刷新物品窗口
  349.           @item_window.refresh
  350.           return
  351.         end
  352.         #--------------------------------------------------------------------
  353.         # ● 没有选中
  354.         #--------------------------------------------------------------------
  355.         # 没有选中物品
  356.         if @item_icon.nil? and @equip_icon.nil? and item != nil
  357.           # 生成图片
  358.           @item_icon = Sprite.new
  359.           @item_icon.bitmap = RPG::Cache.icon(@item_window.item[0].icon_name)
  360.           @item_icon.z = 700
  361.           @initial_x = @mouse_x - (@item_window.cursor_rect.x + @item_window.x + 16) - (50 - @item_icon.bitmap.width) / 2
  362.           @initial_y = @mouse_y - (@item_window.cursor_rect.y + @item_window.y + 16) - (50 - @item_icon.bitmap.height) / 2
  363.           # 记忆选中物品
  364.           @select_index = @item_window.index
  365.           @select_item = item
  366.           # 选中光标
  367.           @select_cursor.x = @select_index % 5 * 51 + 11 + 16
  368.           @select_cursor.y = @select_index / 5 * 51 + 182 + 16
  369.           @select_cursor.z = 600
  370.           $select_item = true
  371.           # 选中物品消失
  372.           @item_window.data[@item_window.index] = nil
  373.           # 刷新物品窗口
  374.           @item_window.refresh
  375.         end
  376.         #--------------------------------------------------------------------
  377.         # ● 拥有选中【装备】
  378.         #--------------------------------------------------------------------
  379.         # 拥有选中装备
  380.         if @equip_icon != nil
  381.           return if @goos != @pack
  382.           # 对象存在物品的情况下
  383.           if item != nil
  384.             case item[0]
  385.             when RPG::Weapon # 武器
  386.               return if @select_index != 2
  387.               @actor.weapon_id = @select_item.id
  388.             when RPG::Armor  # 防具
  389.               # 帽子@select_item
  390.               if item[0].guard_element_set.include?(6)
  391.                 return if @select_index != 0
  392.                 @actor.armor2_id = @select_item.id
  393.               # 项链
  394.               elsif item[0].guard_element_set.include?(7)
  395.                 return if @select_index != 1
  396.                 @actor.armor4_id = @select_item.id
  397.               # 衣服
  398.               elsif item[0].guard_element_set.include?(8)
  399.                 return if @select_index != 3
  400.                 @actor.armor3_id = @select_item.id
  401.               # 腰带
  402.               elsif item[0].guard_element_set.include?(9)
  403.                 return if @select_index != 4
  404.                 @actor.armor1_id = @select_item.id
  405.               # 鞋子
  406.               elsif item[0].guard_element_set.include?(10)
  407.                 return if @select_index != 5
  408.                 @actor.armor5_id = @select_item.id
  409.               end
  410.             end
  411.             # 变更装备
  412.             @actor.equip(@select_index, item[0].id)
  413.           else
  414.             # 变更物品
  415.             @item_window.data[@item_window.index] = [@select_item,1]
  416.           end
  417.           # 释放图标
  418.           Picture.dispose(@equip_icon)
  419.           @equip_icon = nil
  420.           # 刷新物品窗口
  421.           @item_window.refresh
  422.           # 刷新装备窗口
  423.           @equip_window.refresh
  424.         end
  425.       end
  426.       #----------------------------------------------------------------------
  427.       # ● 当按下鼠标右键时
  428.       #----------------------------------------------------------------------
  429.       # 当按下鼠标右键时
  430.       if Mouse.trigger?(0x02)
  431.         return if @goos != @pack
  432.         # 选中物品存在的情况下返回
  433.         return if @item_icon != nil or @equip_icon != nil or item.nil?
  434.         case item[0]
  435.         when RPG::Weapon # 武器
  436.           # 变更武器
  437.           @actor.equip(2, item[0].id)
  438.         when RPG::Armor  # 防具
  439.           # 帽子
  440.           if item[0].guard_element_set.include?(6)
  441.             @actor.equip(0, item[0].id)
  442.           # 项链
  443.           elsif item[0].guard_element_set.include?(7)
  444.             @actor.equip(1, item[0].id)
  445.           # 衣服
  446.           elsif item[0].guard_element_set.include?(8)
  447.             @actor.equip(3, item[0].id)
  448.           # 腰带
  449.           elsif item[0].guard_element_set.include?(9)
  450.             @actor.equip(4, item[0].id)
  451.           # 鞋子
  452.           elsif item[0].guard_element_set.include?(10)
  453.             @actor.equip(5, item[0].id)
  454.           end
  455.         when RPG::Item   # 物品
  456.           # 无法使用的情况下
  457.           if !$data.item_can_use?(item[0].id)
  458.             print "该物品无法使用!"
  459.             return
  460.           end
  461.           # 播放动画
  462.           $game_player.animation_id = item[0].animation2_id
  463.           # 消耗品的情况下
  464.           if item[0].consumable
  465.             # 减少物品数量
  466.             item[1] -= 1
  467.             if item[1] == 0
  468.               @item_window.data[@item_window.index] = nil
  469.             end
  470.           end
  471.           # 处理物品效果
  472.           $game_party.actors[0].item_effect(item[0]) # 普通物品
  473.           # 公共事件 ID 有效的情况下
  474.           if item[0].common_event_id > 0
  475.             # 预约调用公共事件
  476.             $game_temp.common_event_id = item[0].common_event_id
  477.           end
  478.         end
  479.         # 刷新物品窗口
  480.         @item_window.refresh
  481.         # 刷新装备窗口
  482.         @equip_window.refresh
  483.       end
  484.     end
  485.     #------------------------------------------------------------------------
  486.     # ● 刷新装备选择
  487.     #------------------------------------------------------------------------
  488.     def select_equip
  489.       return if !@equip_window.active
  490.       #----------------------------------------------------------------------
  491.       # ● 当按下鼠标左键时
  492.       #----------------------------------------------------------------------
  493.       # 当按下鼠标左键时
  494.       if Mouse.trigger?(0x01)
  495.         #--------------------------------------------------------------------
  496.         # ● 拥有选中【装备】
  497.         #--------------------------------------------------------------------
  498.         # 拥有选中装备
  499.         if @equip_icon != nil
  500.           if @select_index == @equip_window.index
  501.             # 还原装备
  502.             self.select_return
  503.             return
  504.           end
  505.         end
  506.         #----------------------------------------------------------------------
  507.         # ● 拥有选中【物品】
  508.         #----------------------------------------------------------------------
  509.         # 拥有选中物品
  510.         if @item_icon != nil
  511.           # 物品不在行囊中
  512.           return if @goos != @pack
  513.           # 获取物品
  514.           item = @select_item
  515.           case item[0]
  516.           when RPG::Weapon # 武器
  517.             return if @equip_window.index != 2
  518.           when RPG::Armor  # 防具
  519.             # 帽子
  520.             if item[0].guard_element_set.include?(6)
  521.               return if @equip_window.index != 0
  522.             # 项链
  523.             elsif item[0].guard_element_set.include?(7)
  524.               return if @equip_window.index != 1
  525.             # 衣服
  526.             elsif item[0].guard_element_set.include?(8)
  527.               return if @equip_window.index != 3
  528.             # 腰带
  529.             elsif item[0].guard_element_set.include?(9)
  530.               return if @equip_window.index != 4
  531.             # 鞋子
  532.             elsif item[0].guard_element_set.include?(10)
  533.               return if @equip_window.index != 5
  534.             end
  535.           when RPG::Item   # 物品
  536.             return
  537.           end
  538.           # 变更装备
  539.           @item_window.data[@select_index] = item
  540.           @actor.equip(@equip_window.index, item[0].id)
  541.           # 释放图标
  542.           Picture.dispose(@item_icon)
  543.           @item_icon = nil
  544.           # 刷新物品窗口
  545.           @item_window.refresh
  546.           # 刷新装备窗口
  547.           @equip_window.refresh
  548.           return
  549.         end
  550.         #--------------------------------------------------------------------
  551.         # ● 没有选中
  552.         #--------------------------------------------------------------------
  553.         # 没有选中物品
  554.         if @item_icon.nil? and @equip_icon.nil? and @equip_window.item != nil
  555.           # 生成图片
  556.           @equip_icon = Sprite.new
  557.           @equip_icon.bitmap = RPG::Cache.icon(@equip_window.item.icon_name)
  558.           @equip_icon.z = 700
  559.           @initial_x = @mouse_x - (@equip_window.cursor_rect.x + @equip_window.x + 16) - (50 - @equip_icon.bitmap.width) / 2
  560.           @initial_y = @mouse_y - (@equip_window.cursor_rect.y + @equip_window.y + 16) - (50 - @equip_icon.bitmap.height) / 2
  561.           # 记忆选中物品
  562.           @select_index = @equip_window.index
  563.           @select_item = @equip_window.item
  564.           # 选中光标
  565.           @select_cursor.x = @select_index % 2 * 54 + 181 + 16
  566.           @select_cursor.y = @select_index / 2 * 54 + 10 + 16
  567.           @select_cursor.z = 600
  568.           $select_item = true
  569.           # 选中装备消失
  570.           @actor.armor2_id = 0 if @equip_window.index == 0
  571.           @actor.armor4_id = 0 if @equip_window.index == 1
  572.           @actor.weapon_id = 0 if @equip_window.index == 2
  573.           @actor.armor3_id = 0 if @equip_window.index == 3
  574.           @actor.armor1_id = 0 if @equip_window.index == 4
  575.           @actor.armor5_id = 0 if @equip_window.index == 5
  576.           # 刷新物品窗口
  577.           @equip_window.refresh
  578.         end
  579.       end
  580.       #----------------------------------------------------------------------
  581.       # ● 当按下鼠标右键时
  582.       #----------------------------------------------------------------------
  583.       # 当按下鼠标右键时
  584.       if Mouse.trigger?(0x02)
  585.         # 选中物品存在的情况下返回
  586.         return if @item_icon != nil or @equip_icon != nil
  587.         # 获取物品
  588.         item = @equip_window.item
  589.         case item
  590.         when RPG::Weapon # 武器
  591.           # 变更武器
  592.           @actor.equip(2, 0)
  593.         when RPG::Armor  # 防具
  594.           # 帽子
  595.           if item.guard_element_set.include?(6)
  596.             @actor.equip(0, 0)
  597.           # 项链
  598.           elsif item.guard_element_set.include?(7)
  599.             @actor.equip(1, 0)
  600.           # 衣服
  601.           elsif item.guard_element_set.include?(8)
  602.             @actor.equip(3, 0)
  603.           # 腰带
  604.           elsif item.guard_element_set.include?(9)
  605.             @actor.equip(4, 0)
  606.           # 鞋子
  607.           elsif item.guard_element_set.include?(10)
  608.             @actor.equip(5, 0)
  609.           end
  610.         end
  611.         # 刷新物品窗口
  612.         @item_window.refresh
  613.         # 刷新装备窗口
  614.         @equip_window.refresh
  615.       end
  616.     end
  617.   end
  618. end



这个是装备限制等级的..
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_EquipItem
  3. #------------------------------------------------------------------------------
  4. #  装备画面、显示浏览变更装备的候补物品的窗口。
  5. #==============================================================================
  6.  
  7. class Window_EquipItem < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化对像
  10.   #     actor      : 角色
  11.   #     equip_type : 装备部位 (0~3)
  12.   #--------------------------------------------------------------------------
  13.   def initialize(actor, equip_type)
  14.     super(0, 256, 640, 224)
  15.     @actor = actor
  16.     @equip_type = equip_type
  17.     @column_max = 2
  18.     refresh
  19.     self.active = false
  20.     self.index = -1
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 获取物品
  24.   #--------------------------------------------------------------------------
  25.   def item
  26.     return @data[self.index]
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 刷新
  30.   #--------------------------------------------------------------------------
  31.   def refresh
  32.     if self.contents != nil
  33.       self.contents.dispose
  34.       self.contents = nil
  35.     end
  36.     @data = []
  37.     # 添加可以装备的武器
  38.   ###########################################################################
  39.     # 将有限制装备等级的武器编号写在@LLW里面
  40.     @LLW = [2, 3, 4]
  41.     # 将有限制装备等级的防具编号写在@LLA里面
  42.     @LLA = [2, 3, 4]
  43.   ###########################################################################
  44.     if @equip_type == 0
  45.       weapon_set = $data_classes[@actor.class_id].weapon_set
  46.       for i in 1...$data_weapons.size
  47.         if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
  48.   ###########################################################################
  49.           for z in [email]0..@LLW.size[/email]
  50.             if @LLW[z] == i # 该武器限制等级
  51.               lol = true
  52.             end
  53.           end
  54.           if lol == true
  55.             case i # 这个其实是武器编号
  56.             when 2 # 武器编号为2
  57.               if @actor.level >= 5 #角色等级大于5编号2的武器才能装备
  58.                 @data.push($data_weapons[i])
  59.               end
  60.             when 3 # 武器编号为3
  61.               if @actor.level >= 10 #角色等级大于10编号3的武器才能装备
  62.                 @data.push($data_weapons[i])
  63.               end
  64.             when 4 # 武器编号为4
  65.               if @actor.level >= 20 #角色等级大于20编号4的武器才能装备
  66.                 @data.push($data_weapons[i])
  67.               end
  68.             # 要多添加的话按着格式写就行,在@LLW里面出现的编号记得都要在这里设定。
  69.             end
  70.             lol = false
  71.           else
  72.             @data.push($data_weapons[i])
  73.           end
  74.   ###########################################################################
  75.         end
  76.       end
  77.     end
  78.     # 添加可以装备的防具
  79.     if @equip_type != 0
  80.       armor_set = $data_classes[@actor.class_id].armor_set
  81.       for i in 1...$data_armors.size
  82.         if $game_party.armor_number(i) > 0 and armor_set.include?(i)
  83.           if $data_armors[i].kind == @equip_type-1
  84.   ###########################################################################
  85.             for z in [email]0..@LLA.size[/email]
  86.               if @LLA[z] == i # 该防具限制等级
  87.                 lol = true
  88.               end
  89.             end
  90.             if lol == true
  91.               case i # 这个其实是防具编号
  92.               when 2 # 防具编号为2
  93.                 if @actor.level >= 10 #角色等级大于10编号2的防具才能装备
  94.                   @data.push($data_armors[i])
  95.                 end
  96.               when 3 # 防具编号为3
  97.                 if @actor.level >= 20 #角色等级大于20编号3的防具才能装备
  98.                   @data.push($data_armors[i])
  99.                 end
  100.               when 4 # 防具编号为4
  101.                 if @actor.level >= 30 #角色等级大于30编号4的防具才能装备
  102.                   @data.push($data_armors[i])
  103.                 end
  104.               # 要多添加的话按着格式写就行,在@LLA里面出现的编号记得都要在这里设定。
  105.               end
  106.               lol = false
  107.             else
  108.               @data.push($data_armors[i])
  109.             end
  110.   ###########################################################################
  111.           end
  112.         end
  113.       end
  114.     end
  115.     # 添加空白
  116.     @data.push(nil)
  117.     # 生成位图、描绘全部项目
  118.     @item_max = @data.size
  119.     self.contents = Bitmap.new(width - 32, row_max * 32)
  120.     for i in 0...@item_max-1
  121.       draw_item(i)
  122.     end
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 项目的描绘
  126.   #     index : 项目符号
  127.   #--------------------------------------------------------------------------
  128.   def draw_item(index)
  129.     item = @data[index]
  130.     x = 4 + index % 2 * (288 + 32)
  131.     y = index / 2 * 32
  132.     case item
  133.     when RPG::Weapon
  134.       number = $game_party.weapon_number(item.id)
  135.     when RPG::Armor
  136.       number = $game_party.armor_number(item.id)
  137.     end
  138.     bitmap = RPG::Cache.icon(item.icon_name)
  139.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  140.     self.contents.font.color = normal_color
  141.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  142.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  143.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● 刷新帮助文本
  147.   #--------------------------------------------------------------------------
  148.   def update_help
  149.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  150.   end
  151. end

Lv2.观梦者

故九江太守

梦石
0
星屑
559
在线时间
2160 小时
注册时间
2012-12-5
帖子
4463
2
发表于 2014-10-5 13:45:11 | 只看该作者
天啊,好多全局变量
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

3
发表于 2014-10-5 15:30:44 | 只看该作者
这个物品窗口是你自己写的?
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
218 小时
注册时间
2013-12-17
帖子
386
4
发表于 2014-10-5 18:46:52 | 只看该作者
楼主这个装备等级限制实现方法貌似有些问题。
RM脚本定制/修改/整合 群:143356012(入群注明来意)
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
5
发表于 2014-10-7 17:30:59 | 只看该作者
本帖最后由 恐惧剑刃 于 2014-10-7 17:32 编辑

基础,
  1. Weapon_level = [nil, 1, 2, 3]
  2. Armor_level = [nil, 1, 2, 3]

  3. module RPG
  4.   class Weapon
  5.     def level
  6.       return Weapon_level[@id]
  7.     end
  8.   end
  9.   class Armor
  10.     def level
  11.       return Armor_level[@id]
  12.     end
  13.   end
  14. end
复制代码
应用,
找到Game_Actor默认395行,也就是变更装备方法
equip_type : 装备类型
id    : 武器 or 防具 ID  (0 为解除装备)
注释已经解释了。
那么我们只需要判定等级就可以了。
  1. if equip_type == 0
  2.       return if $data_weapons[id].nil?
  3.       if not @level >= $data_weapons[id].level
  4.         return
  5.       end
  6.     else
  7.       return if $data_armors[id].nil?
  8.       if not @level >= $data_armors[id].level
  9.         return
  10.       end
  11.     end
复制代码
下边还有一个方法,是判定装备是否可以佩戴的。大致修改为
  1. #--------------------------------------------------------------------------
  2.   # ● 可以装备判定
  3.   #     item : 物品
  4.   #--------------------------------------------------------------------------
  5.   def equippable?(item)
  6.     # 武器的情况
  7.     if item.is_a?(RPG::Weapon)
  8.       # 包含当前的职业可以装备武器的场合
  9.       if $data_classes[@class_id].weapon_set.include?(item.id)
  10.         
  11.         if not @level >= $data_weapons[id].level
  12.           return false
  13.         end
  14.         
  15.         return true
  16.       end
  17.     end
  18.     # 防具的情况
  19.     if item.is_a?(RPG::Armor)
  20.       # 不包含当前的职业可以装备武器的场合
  21.       if $data_classes[@class_id].armor_set.include?(item.id)
  22.         
  23.         if not @level >= $data_armors[id].level
  24.           return false
  25.         end
  26.       
  27.         return true
  28.       end
  29.     end
  30.     return false
  31.   end
复制代码
默认脚本的45到49行是刷新初始装备同样可以用类似的方法判定是否可以装备




与默认的数据结构一致。
当然你也可以自己写属于你自己的数据结构,像左手武器(盾等),右手武器,头,铠甲,靴子,项链,腰带等等一切都是可以的
所用到的知识仅仅是【如何附加属性(attr)而已】
自学脚本最多最多一周轻松搞定这一切,如果有老师帮助最多一天。

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1556
在线时间
626 小时
注册时间
2010-8-5
帖子
451
6
 楼主| 发表于 2014-10-7 23:14:23 | 只看该作者
恐惧剑刃 发表于 2014-10-7 17:30
基础,应用,
找到Game_Actor默认395行,也就是变更装备方法
equip_type : 装备类型

版主.这是额ACTOR的脚本...最近自身原因.哎/希望版主大人能写里面去.[自身原因]。。。谢过
  1. #==============================================================================
  2. # ■ Game_Actor
  3. #------------------------------------------------------------------------------
  4. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  5. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  6. #==============================================================================

  7. #空手时动画ID: 角色ID => 动画 ID
  8. ANIMATIONS = {12=>633,10=>802,4=>635,14=>545}

  9. class Game_Actor < Game_Battler
  10.   #--------------------------------------------------------------------------
  11.   # ● 定义实例变量
  12.   #--------------------------------------------------------------------------
  13.   attr_reader   :name                     # 名称
  14.   attr_reader   :character_name           # 角色 文件名
  15.   attr_reader   :character_hue            # 角色 色相
  16.   attr_reader   :class_id                 # 职业 ID
  17.   attr_reader   :exp                      # EXP
  18.   attr_accessor :weapon_id                # 武器 ID
  19.   attr_accessor :armor1_id                # 腰带 ID
  20.   attr_accessor :armor2_id                # 帽子 ID
  21.   attr_accessor :armor3_id                # 衣服 ID
  22.   attr_accessor :armor4_id                # 项链 ID
  23.   attr_accessor :armor5_id                # 鞋子 ID
  24.   attr_accessor :baby                     # 当前宠物
  25.   attr_accessor :babys                    # 拥有宠物
  26.   attr_accessor :loyal                    # 宠物忠诚
  27.   attr_accessor :skilled                  # 技能等级
  28.   attr_accessor :vitality                 # 活力
  29.   attr_accessor :spirit                   # 体力
  30.   attr_accessor :latent                   # 潜力
  31.   attr_accessor :add_tizhi                # 加上去的体质
  32.   attr_accessor :add_moli                 # 加上去的魔力
  33.   attr_accessor :add_liliang              # 加上去的力量
  34.   attr_accessor :add_naili                # 加上去的耐力
  35.   attr_accessor :add_minjie               # 加上去的敏捷
  36.   #--------------------------------------------------------------------------
  37.   # ● 初始化对像
  38.   #     actor_id : 角色 ID
  39.   #--------------------------------------------------------------------------
  40.   def initialize(actor_id)
  41.     super()
  42.     setup(actor_id)
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 设置
  46.   #     actor_id : 角色 ID
  47.   #--------------------------------------------------------------------------
  48.   def setup(actor_id)
  49.     actor = $data_actors[actor_id]
  50.     @actor_id = actor_id
  51.     @name = actor.name
  52.     @character_name = actor.character_name
  53.     @character_hue = actor.character_hue
  54.     # 循环规律: (id-1)*7+1
  55.     @battler_name = actor.battler_name
  56.     @battler_hue = actor.battler_hue
  57.     @class_id = actor.class_id
  58.     @weapon_id = actor.weapon_id
  59.     @armor1_id = actor.armor1_id
  60.     @armor2_id = actor.armor2_id
  61.     @armor3_id = actor.armor3_id
  62.     @armor4_id = actor.armor4_id
  63.     @armor5_id = 0
  64.     @level = actor.initial_level
  65.     @exp_list = Array.new(101)
  66.     make_exp_list
  67.     @exp = @exp_list[@level]
  68.     @skills = []
  69.     @hp = maxhp
  70.     @sp = maxsp
  71.     [url=home.php?mod=space&uid=7728]@Baby[/url] = 0
  72.     @babys = [24]
  73.     @vitality = 0
  74.     [url=home.php?mod=space&uid=33152]@spirit[/url] = 150
  75.     @latent = 5
  76.     @tizhi   = 10
  77.     [url=home.php?mod=space&uid=69897]@moli[/url]    = 10
  78.     [url=home.php?mod=space&uid=67935]@liliang[/url] = 10
  79.     @naili   = 10
  80.     [url=home.php?mod=space&uid=25810]@minjie[/url]  = 10
  81.     @add_tizhi   = 0
  82.     @add_moli    = 0
  83.     @add_liliang = 0
  84.     @add_naili   = 0
  85.     @add_minjie  = 0
  86.     @states = [20]
  87.     @states_turn = {}
  88.     @maxhp_plus = 0
  89.     @maxsp_plus = 0
  90.     @str_plus = 0
  91.     @dex_plus = 0
  92.     @agi_plus = 0
  93.     @int_plus = 0
  94.     # 学会特技
  95.     for i in 1..@level
  96.       for j in $data_classes[@class_id].learnings
  97.         if j.level == i
  98.           learn_skill(j.skill_id)
  99.         end
  100.       end
  101.     end
  102.     # 其他
  103.     #if actor_id > 20
  104.       @name = actor.name.split(/【/)[0]
  105.       baby = $pet["#{@name}"]
  106.       if baby != nil
  107.       @攻击资质 = baby[0] - rand(200)
  108.       @防御资质 = baby[1] - rand(200)
  109.       @体力资质 = baby[2] - rand(400)
  110.       @法力资质 = baby[3] - rand(200)
  111.       @速度资质 = baby[4] - rand(200)
  112.       @躲闪资质 = baby[5] - rand(200)
  113.       @成长 = baby[6][rand(5)]
  114.       @loyal = 100
  115.       end
  116.       [url=home.php?mod=space&uid=422313]@五行[/url] = ["金","木","水","火","土"][rand(5)]
  117.     #end
  118.     # 获取装备
  119.     [url=home.php?mod=space&uid=36793]@weapon[/url] = $data_weapons[@weapon_id]
  120.     @armor1 = $data_armors[@armor1_id]
  121.     @armor2 = $data_armors[@armor2_id]
  122.     @armor3 = $data_armors[@armor3_id]
  123.     @armor4 = $data_armors[@armor4_id]
  124.     @armor5 = $data_armors[@armor5_id]
  125.     # 刷新自动状态
  126.     update_auto_state(nil, $data_armors[@armor1_id])
  127.     update_auto_state(nil, $data_armors[@armor2_id])
  128.     update_auto_state(nil, $data_armors[@armor3_id])
  129.     update_auto_state(nil, $data_armors[@armor4_id])
  130.     update_auto_state(nil, $data_armors[@armor5_id])
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   def file_name
  134.     weapon = $data_weapons[@weapon_id]
  135.     n = weapon.nil?  ? "" : ("_" + weapon.name)
  136.     fn = @actor_id < 20 ? @name + n : @name
  137.     return fn
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 获得宠物
  141.   #     baby_id   : 宠物 ID
  142.   #--------------------------------------------------------------------------
  143.   def add_baby(baby_id)
  144.     # 添加宠物
  145.     @babys.push(baby_id)
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 放生宠物
  149.   #     baby_id : 宠物 ID
  150.   #--------------------------------------------------------------------------
  151.   def remove_baby(baby_id)
  152.     # 删除宠物
  153.     @babys.delete(baby_id)
  154.     $data_actors[baby_id] = nil
  155.     #在队伍中删除该成员
  156.     $game_party.remove_actor(baby_id)
  157.     # 当放生宠物为参战宠物时,将参战的宠物设为空
  158.     @baby = 0 if @baby == baby_id
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 宠物参战
  162.   #     baby_id : 宠物 ID
  163.   #--------------------------------------------------------------------------
  164.   def enter_baby(baby_id)
  165.     # 当参战的宠物不为空
  166.     if @baby != 0
  167.       # 参战的宠物等于选择参战的宠物
  168.       if @baby == baby_id
  169.         # 参战的宠物设为空
  170.         $game_party.remove_actor(baby_id)
  171.         @baby = 0
  172.       else # 其他
  173.         # 参战的宠物设为选择参战的宠物
  174.         $text_window.txt = "\\p[_系统]\\c[6]已有参战的召唤兽,请确定当前没有参战的召唤兽后再操作!\\c[0]"
  175.       end
  176.     else
  177.       # 参战的宠物设为选择参战的宠物
  178.       $game_party.add_actor(baby_id)
  179.       @baby = baby_id
  180.     end
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 获取角色 ID
  184.   #--------------------------------------------------------------------------
  185.   def id
  186.     return @actor_id
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 获取索引
  190.   #--------------------------------------------------------------------------
  191.   def index
  192.     return $game_party.actors.index(self)
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 最高级等级限制
  196.   #--------------------------------------------------------------------------
  197.   def new_final_level
  198.     #如果是宝宝则返回180
  199.     if self.id > 20
  200.       return 180
  201.     end
  202.     return 175
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 计算 EXP
  206.   #--------------------------------------------------------------------------
  207.   def make_exp_list
  208.     actor = $data_actors[@actor_id]
  209.     @exp_list[1] = 0
  210.     pow_i = 2.4 + actor.exp_inflation / 100.0
  211.     for i in 2..100
  212.       if i > actor.final_level
  213.         @exp_list[i] = 0
  214.       else
  215.         n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)
  216.         @exp_list[i] = @exp_list[i-1] + Integer(n)
  217.       end
  218.     end
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● 取得属性修正值
  222.   #     element_id : 属性 ID
  223.   #--------------------------------------------------------------------------
  224.   def element_rate(element_id)
  225.     # 获取对应属性有效度的数值
  226.     table = [0,200,150,100,50,0,-100]
  227.     result = table[$data_classes[@class_id].element_ranks[element_id]]
  228.     # 防具能防御本属性的情况下效果减半
  229.     for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, @armor5_id]
  230.       armor = $data_armors[i]
  231.       if armor != nil and armor.guard_element_set.include?(element_id)
  232.         result /= 2
  233.       end
  234.     end
  235.     # 状态能防御本属性的情况下效果减半
  236.     for i in @states
  237.       if $data_states[i].guard_element_set.include?(element_id)
  238.         result /= 2
  239.       end
  240.     end
  241.     # 过程结束
  242.     return result
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 获取属性有效度
  246.   #--------------------------------------------------------------------------
  247.   def state_ranks
  248.     return $data_classes[@class_id].state_ranks
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 判定防御属性
  252.   #     state_id : 属性 ID
  253.   #--------------------------------------------------------------------------
  254.   def state_guard?(state_id)
  255.     for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, @armor5_id]
  256.       armor = $data_armors[i]
  257.       if armor != nil
  258.         if armor.guard_state_set.include?(state_id)
  259.           return true
  260.         end
  261.       end
  262.     end
  263.     return false
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● 获取普通攻击属性
  267.   #--------------------------------------------------------------------------
  268.   def element_set
  269.     weapon = $data_weapons[@weapon_id]
  270.     return weapon != nil ? weapon.element_set : []
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 获取普通攻击状态变化 (+)
  274.   #--------------------------------------------------------------------------
  275.   def plus_state_set
  276.     weapon = $data_weapons[@weapon_id]
  277.     return weapon != nil ? weapon.plus_state_set : []
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● 获取普通攻击状态变化 (-)
  281.   #--------------------------------------------------------------------------
  282.   def minus_state_set
  283.     weapon = $data_weapons[@weapon_id]
  284.     return weapon != nil ? weapon.minus_state_set : []
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ● 获取基本 MaxHP
  288.   #--------------------------------------------------------------------------
  289.   def base_maxhp
  290.     return $data_actors[@actor_id].parameters[0, @level]
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ● 获取基本 MaxSP
  294.   #--------------------------------------------------------------------------
  295.   def base_maxsp
  296.     return $data_actors[@actor_id].parameters[1, @level]
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 获取基本力量
  300.   #--------------------------------------------------------------------------
  301.   def base_str
  302.     n = $data_actors[@actor_id].parameters[2, @level]
  303.     weapon = $data_weapons[@weapon_id]
  304.     armor1 = $data_armors[@armor1_id]
  305.     armor2 = $data_armors[@armor2_id]
  306.     armor3 = $data_armors[@armor3_id]
  307.     armor4 = $data_armors[@armor4_id]
  308.     armor5 = $data_armors[@armor5_id]
  309.     n += weapon != nil ? weapon.str_plus : 0
  310.     n += armor1 != nil ? armor1.str_plus : 0
  311.     n += armor2 != nil ? armor2.str_plus : 0
  312.     n += armor3 != nil ? armor3.str_plus : 0
  313.     n += armor4 != nil ? armor4.str_plus : 0
  314.     n += armor5 != nil ? armor5.str_plus : 0
  315.     return [[n, 1].max, 999].min
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● 获取基本灵巧
  319.   #--------------------------------------------------------------------------
  320.   def base_dex
  321.     n = $data_actors[@actor_id].parameters[3, @level]
  322.     weapon = $data_weapons[@weapon_id]
  323.     armor1 = $data_armors[@armor1_id]
  324.     armor2 = $data_armors[@armor2_id]
  325.     armor3 = $data_armors[@armor3_id]
  326.     armor4 = $data_armors[@armor4_id]
  327.     armor5 = $data_armors[@armor5_id]
  328.     n += weapon != nil ? weapon.dex_plus : 0
  329.     n += armor1 != nil ? armor1.dex_plus : 0
  330.     n += armor2 != nil ? armor2.dex_plus : 0
  331.     n += armor3 != nil ? armor3.dex_plus : 0
  332.     n += armor4 != nil ? armor4.dex_plus : 0
  333.     n += armor5 != nil ? armor5.dex_plus : 0
  334.     return [[n, 1].max, 999].min
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 获取基本速度
  338.   #--------------------------------------------------------------------------
  339.   def base_agi
  340.     n = $data_actors[@actor_id].parameters[4, @level]
  341.     weapon = $data_weapons[@weapon_id]
  342.     armor1 = $data_armors[@armor1_id]
  343.     armor2 = $data_armors[@armor2_id]
  344.     armor3 = $data_armors[@armor3_id]
  345.     armor4 = $data_armors[@armor4_id]
  346.     armor5 = $data_armors[@armor5_id]
  347.     n += weapon != nil ? weapon.agi_plus : 0
  348.     n += armor1 != nil ? armor1.agi_plus : 0
  349.     n += armor2 != nil ? armor2.agi_plus : 0
  350.     n += armor3 != nil ? armor3.agi_plus : 0
  351.     n += armor4 != nil ? armor4.agi_plus : 0
  352.     n += armor5 != nil ? armor5.agi_plus : 0
  353.     return [[n, 1].max, 999].min
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 获取基本魔力
  357.   #--------------------------------------------------------------------------
  358.   def base_int
  359.     n = $data_actors[@actor_id].parameters[5, @level]
  360.     weapon = $data_weapons[@weapon_id]
  361.     armor1 = $data_armors[@armor1_id]
  362.     armor2 = $data_armors[@armor2_id]
  363.     armor3 = $data_armors[@armor3_id]
  364.     armor4 = $data_armors[@armor4_id]
  365.     armor5 = $data_armors[@armor5_id]
  366.     n += weapon != nil ? weapon.int_plus : 0
  367.     n += armor1 != nil ? armor1.int_plus : 0
  368.     n += armor2 != nil ? armor2.int_plus : 0
  369.     n += armor3 != nil ? armor3.int_plus : 0
  370.     n += armor4 != nil ? armor4.int_plus : 0
  371.     n += armor5 != nil ? armor5.int_plus : 0
  372.     return [[n, 1].max, 999].min
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● 获取基本攻击力
  376.   #--------------------------------------------------------------------------
  377.   def base_atk
  378.     weapon = $data_weapons[@weapon_id]
  379.     return weapon != nil ? weapon.atk : 0
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 获取基本物理防御
  383.   #--------------------------------------------------------------------------
  384.   def base_pdef
  385.     weapon = $data_weapons[@weapon_id]
  386.     armor1 = $data_armors[@armor1_id]
  387.     armor2 = $data_armors[@armor2_id]
  388.     armor3 = $data_armors[@armor3_id]
  389.     armor4 = $data_armors[@armor4_id]
  390.     armor5 = $data_armors[@armor5_id]
  391.     pdef1 = weapon != nil ? weapon.pdef : 0
  392.     pdef2 = armor1 != nil ? armor1.pdef : 0
  393.     pdef3 = armor2 != nil ? armor2.pdef : 0
  394.     pdef4 = armor3 != nil ? armor3.pdef : 0
  395.     pdef5 = armor4 != nil ? armor4.pdef : 0
  396.     pdef6 = armor5 != nil ? armor5.pdef : 0
  397.     return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + pdef6
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # ● 获取基本魔法防御
  401.   #--------------------------------------------------------------------------
  402.   def base_mdef
  403.     weapon = $data_weapons[@weapon_id]
  404.     armor1 = $data_armors[@armor1_id]
  405.     armor2 = $data_armors[@armor2_id]
  406.     armor3 = $data_armors[@armor3_id]
  407.     armor4 = $data_armors[@armor4_id]
  408.     armor5 = $data_armors[@armor5_id]
  409.     mdef1 = weapon != nil ? weapon.mdef : 0
  410.     mdef2 = armor1 != nil ? armor1.mdef : 0
  411.     mdef3 = armor2 != nil ? armor2.mdef : 0
  412.     mdef4 = armor3 != nil ? armor3.mdef : 0
  413.     mdef5 = armor4 != nil ? armor4.mdef : 0
  414.     mdef6 = armor5 != nil ? armor5.mdef : 0
  415.     return mdef1 + mdef2 + mdef3 + mdef4 + mdef5 + mdef6
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● 获取基本回避修正
  419.   #--------------------------------------------------------------------------
  420.   def base_eva
  421.     armor1 = $data_armors[@armor1_id]
  422.     armor2 = $data_armors[@armor2_id]
  423.     armor3 = $data_armors[@armor3_id]
  424.     armor4 = $data_armors[@armor4_id]
  425.     armor5 = $data_armors[@armor5_id]
  426.     eva1 = armor1 != nil ? armor1.eva : 0
  427.     eva2 = armor2 != nil ? armor2.eva : 0
  428.     eva3 = armor3 != nil ? armor3.eva : 0
  429.     eva4 = armor4 != nil ? armor4.eva : 0
  430.     eva5 = armor5 != nil ? armor5.eva : 0
  431.     return eva1 + eva2 + eva3 + eva4 + eva5
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # ● 普通攻击 获取攻击方动画 ID
  435.   #--------------------------------------------------------------------------
  436.   def animation1_id
  437.     weapon = $data_weapons[@weapon_id]
  438.     id = weapon != nil ? weapon.animation1_id : 0
  439.     id = ANIMATIONS[@actor_id] if @weapon_id == 0 and ANIMATIONS.include?(@actor_id)
  440.     return id
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ● 普通技能 获取施法方动画 ID
  444.   #--------------------------------------------------------------------------
  445.   def skill_animation_id
  446.     if @weapon_id == 0 and actor_id == 12
  447.       return skill_animation_id = 634#龙太子
  448.     end
  449.     if @weapon_id == 156
  450.       return skill_animation_id = 742#大力金刚
  451.     end
  452.     if @weapon_id == 356
  453.       return skill_animation_id = 491#大力金刚
  454.     end
  455.     if @weapon_id == 363
  456.       return skill_animation_id = 505#海星
  457.     end
  458.     if @weapon_id == 364
  459.       return skill_animation_id = 507#浣熊
  460.     end
  461.     if @weapon_id == 365
  462.       return skill_animation_id = 509#章鱼
  463.     end
  464.     if @weapon_id == 366
  465.       return skill_animation_id = 511#周杰伦
  466.    
  467.     end
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # ● 获取类名
  471.   #--------------------------------------------------------------------------
  472.   def class_name
  473.     return $data_classes[@class_id].name
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # ● 获取 EXP 字符串
  477.   #--------------------------------------------------------------------------
  478.   def exp_s
  479.     return @exp_list[@level+1] > 0 ? @exp.to_s : "-------"
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # ● 获取下一等级的 EXP 字符串
  483.   #--------------------------------------------------------------------------
  484.   def next_exp_s
  485.     return @exp_list[@level+1] > 0 ? @exp_list[@level+1].to_s : "-------"
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ● 获取离下一等级还需的 EXP 字符串
  489.   #--------------------------------------------------------------------------
  490.   def next_rest_exp_s
  491.     return @exp_list[@level+1] > 0 ?
  492.     (@exp_list[@level+1] - @exp).to_s : "-------"
  493.   end
  494.   #--------------------------------------------------------------------------
  495.   # ● 获取当前经验
  496.   #--------------------------------------------------------------------------
  497.   def now_exp
  498.     return @exp - @exp_list[@level]
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ● 获取升级经验
  502.   #--------------------------------------------------------------------------
  503.   def next_exp
  504.     return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ● 更新自动状态
  508.   #     old_armor : 卸下防具
  509.   #     new_armor : 装备防具
  510.   #--------------------------------------------------------------------------
  511.   def update_auto_state(old_armor, new_armor)
  512.     # 强制解除卸下防具的自动状态
  513.     if old_armor != nil and old_armor.auto_state_id != 0
  514.       remove_state(old_armor.auto_state_id, true)
  515.     end
  516.     # 强制附加装备防具的自动状态
  517.     if new_armor != nil and new_armor.auto_state_id != 0
  518.       add_state(new_armor.auto_state_id, true)
  519.     end
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # ● 装备固定判定
  523.   #     equip_type : 装备类型
  524.   #--------------------------------------------------------------------------
  525.   def equip_fix?(equip_type)
  526.     case equip_type
  527.     when 0  # 武器
  528.       return $data_actors[@actor_id].weapon_fix
  529.     when 1  # 盾
  530.       return $data_actors[@actor_id].armor1_fix
  531.     when 2  # 头
  532.       return $data_actors[@actor_id].armor2_fix
  533.     when 3  # 身体
  534.       return $data_actors[@actor_id].armor3_fix
  535.     when 4  # 装饰品
  536.       return $data_actors[@actor_id].armor4_fix
  537.     end
  538.     return false
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # ● 变更装备
  542.   #     equip_type : 装备类型
  543.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  544.   #--------------------------------------------------------------------------
  545.   def equip(equip_type, id)
  546.     case equip_type
  547.     when 0  # 帽子
  548.       update_auto_state($data_armors[@armor2_id], $data_armors[id])
  549.       alter_equip($data_armors[id], $data_armors[@armor2_id])
  550.       @armor2_id = id
  551.     when 1  # 项链
  552.       update_auto_state($data_armors[@armor4_id], $data_armors[id])
  553.       alter_equip($data_armors[id], $data_armors[@armor4_id])
  554.       @armor4_id = id
  555.     when 2  # 武器
  556.       #@add_name = $data_weapons[id].nil?  ? "" : ("_" + $data_weapons[id].name)
  557.       alter_equip($data_weapons[id], $data_weapons[@weapon_id])
  558.       @weapon_id = id
  559.     when 3  # 衣服
  560.       update_auto_state($data_armors[@armor3_id], $data_armors[id])
  561.       alter_equip($data_armors[id], $data_armors[@armor3_id])
  562.       @armor3_id = id
  563.     when 4  # 腰带
  564.       update_auto_state($data_armors[@armor1_id], $data_armors[id])
  565.       alter_equip($data_armors[id], $data_armors[@armor1_id])
  566.       @armor1_id = id
  567.     when 5  # 鞋子
  568.       update_auto_state($data_armors[@armor5_id], $data_armors[id])
  569.       alter_equip($data_armors[id], $data_armors[@armor5_id])
  570.       @armor5_id = id
  571.     end
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # ● 变更装备
  575.   #     new_equip :更改的装备
  576.   #     old_equip :原来的装备
  577.   #--------------------------------------------------------------------------
  578.   def alter_equip(new_equip, old_equip)
  579.     if new_equip.nil?
  580.       $data.pack[$data.empty($data.pack)] = [old_equip,1]
  581.       return
  582.     end
  583.     for i in 0...$data.pack.size
  584.       unless $data.pack[i].nil?
  585.         if $data.pack[i][0] == new_equip
  586.           if old_equip.nil?
  587.             $data.pack[i] = nil
  588.             return
  589.           end
  590.           $data.pack[i][0] = old_equip
  591.         end
  592.       end
  593.     end
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● 可以装备判定
  597.   #     item : 物品
  598.   #--------------------------------------------------------------------------
  599.   def equippable?(item)
  600.     # 武器的情况
  601.     if item.is_a?(RPG::Weapon)
  602.       # 包含当前的职业可以装备武器的场合
  603.       if $data_classes[@class_id].weapon_set.include?(item.id)
  604.         return true
  605.       end
  606.     end
  607.     # 防具的情况
  608.     if item.is_a?(RPG::Armor)
  609.       # 不包含当前的职业可以装备武器的场合
  610.       if $data_classes[@class_id].armor_set.include?(item.id)
  611.         return true
  612.       end
  613.     end
  614.     return false
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # ● 增加exp
  618.   # 茄子修改
  619.   #--------------------------------------------------------------------------
  620.   def change_exp(val)
  621.     @exp = [[exp+val, 9999999].min, 0].max
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ● 升级exp
  625.   # 茄子修改
  626.   #--------------------------------------------------------------------------
  627.   def change_level
  628.       # 升级
  629.     if @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
  630.       @level += 1
  631.       @latent += 5
  632.       #$text_window.txt = "\\p[_系统]\\c[6]#{@name}\\c[0]升为\\c[5]#{@level}\\c[0]级!"
  633.       # 学会特技
  634.       for j in $data_classes[@class_id].learnings
  635.         if j.level == @level
  636.           learn_skill(j.skill_id)
  637.         end
  638.       end
  639.     end
  640.     # 降级
  641.     if @exp < @exp_list[@level]
  642.       @level -= 1
  643.     end
  644.     if @actor.id > 20
  645.       exp=0
  646.     end
  647.     # 修正当前的 HP 与 SP 超过最大值
  648.     @hp = [@hp, self.maxhp].min
  649.     @sp = [@sp, self.maxsp].min
  650.   end
  651.   #--------------------------------------------------------------------------
  652.   # ● 更改 EXP
  653.   #     exp : 新的 EXP
  654.   #--------------------------------------------------------------------------
  655.   def exp=(exp)
  656.     @exp = [[exp, 9999999].min, 0].max
  657.     # 升级
  658.     while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
  659.       @level += 1
  660.       # 学会特技
  661.       for j in $data_classes[@class_id].learnings
  662.         if j.level == @level
  663.           learn_skill(j.skill_id)
  664.         end
  665.       end
  666.     end
  667.     # 降级
  668.     while @exp < @exp_list[@level]
  669.       @level -= 1
  670.     end
  671.     # 修正当前的 HP 与 SP 超过最大值
  672.     @hp = [@hp, self.maxhp].min
  673.     @sp = [@sp, self.maxsp].min
  674.   end
  675.   #--------------------------------------------------------------------------
  676.   # ● 更改水品
  677.   #     level : 新的等级
  678.   #--------------------------------------------------------------------------
  679.   def level=(level)
  680.     # 检查上下限
  681.     level = [[level, $data_actors[@actor_id].final_level].min, 1].max
  682.     # 更改 EXP
  683.     self.exp = @exp_list[level]
  684.   end
  685.   #--------------------------------------------------------------------------
  686.   # ● 觉悟特技
  687.   #     skill_id : 特技 ID
  688.   #--------------------------------------------------------------------------
  689.   def learn_skill(skill_id)
  690.     if skill_id > 0 and not skill_learn?(skill_id)
  691.       @skills.push(skill_id)
  692.       @skills.sort!
  693.     end
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● 遗忘特技
  697.   #     skill_id : 特技 ID
  698.   #--------------------------------------------------------------------------
  699.   def forget_skill(skill_id)
  700.     @skills.delete(skill_id)
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # ● 已经学会的特技判定
  704.   #     skill_id : 特技 ID
  705.   #--------------------------------------------------------------------------
  706.   def skill_learn?(skill_id)
  707.     return @skills.include?(skill_id)
  708.   end
  709.   #--------------------------------------------------------------------------
  710.   # ● 可以使用特技判定
  711.   #     skill_id : 特技 ID
  712.   #--------------------------------------------------------------------------
  713.   def skill_can_use?(skill_id)
  714.     if not skill_learn?(skill_id)
  715.       return false
  716.     end
  717.     return super
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● 更改名称
  721.   #     name : 新的名称
  722.   #--------------------------------------------------------------------------
  723.   def name=(name)
  724.     @name = name
  725.   end
  726.   #--------------------------------------------------------------------------
  727.   # ● 更改职业 ID
  728.   #     class_id : 新的职业 ID
  729.   #--------------------------------------------------------------------------
  730.   def class_id=(class_id)
  731.     if $data_classes[class_id] != nil
  732.       @class_id = class_id
  733.       # 避开无法装备的物品
  734.       unless equippable?($data_weapons[@weapon_id])
  735.         equip(0, 0)
  736.       end
  737.       unless equippable?($data_armors[@armor1_id])
  738.         equip(1, 0)
  739.       end
  740.       unless equippable?($data_armors[@armor2_id])
  741.         equip(2, 0)
  742.       end
  743.       unless equippable?($data_armors[@armor3_id])
  744.         equip(3, 0)
  745.       end
  746.       unless equippable?($data_armors[@armor4_id])
  747.         equip(4, 0)
  748.       unless equippable?($data_armors[@armor5_id])
  749.         equip(5, 0)
  750.       end
  751.     end
  752.   end
  753.   end
  754.   #--------------------------------------------------------------------------
  755.   # ● 更改图形
  756.   #     character_name : 新的角色 文件名
  757.   #     character_hue  : 新的角色 色相
  758.   #     battler_name   : 新的战斗者 文件名
  759.   #     battler_hue    : 新的战斗者 色相
  760.   #--------------------------------------------------------------------------
  761.   def set_graphic(character_name, character_hue, battler_name, battler_hue)
  762.     @character_name = character_name
  763.     @character_hue = character_hue
  764.     @battler_name = battler_name
  765.     @battler_hue = battler_hue
  766.   end
  767.   #--------------------------------------------------------------------------
  768.   # ● 生成行动
  769.   #--------------------------------------------------------------------------
  770.   def make_action
  771.     # 清除当前行动
  772.     self.current_action.clear
  773.     # 无法行动的情况
  774.     unless self.movable?
  775.       # 过程结束
  776.       return
  777.     end
  778.     self.current_action.kind = 0
  779.     self.current_action.basic = 0
  780.     self.current_action.decide_random_target_for_actor
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 取得战斗画面的 X 坐标
  784.   #--------------------------------------------------------------------------
  785.   def screen_x
  786.     # 返回计算后的队伍 X 坐标的排列顺序
  787.     if self.index != nil
  788.       return 500 - self.index * 50 + @movex
  789.     else
  790.       return 0
  791.     end
  792.   end
  793.   #--------------------------------------------------------------------------
  794.   # ● 取得战斗画面的 Y 坐标
  795.   #--------------------------------------------------------------------------
  796.   def screen_y
  797.      if self.index != nil
  798.       return 350 - self.index * 50 + @movey
  799.     else
  800.       return 0
  801.     end
  802.   end
  803.   #--------------------------------------------------------------------------
  804.   # ● 取得战斗画面的 Z 坐标
  805.   #--------------------------------------------------------------------------
  806.   def screen_z
  807.     # 返回计算后的队伍 Z 坐标的排列顺序
  808.     if self.index != nil
  809.       return 4 - self.index
  810.     else
  811.       return 0
  812.     end
  813.   end
  814. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 18:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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