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

Project1

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

[已经过期] 强化装备脚本怎么使用啊??

[复制链接]

Lv1.梦旅人

梦石
0
星屑
168
在线时间
112 小时
注册时间
2014-2-4
帖子
50
跳转到指定楼层
发表于 2014-2-4 16:24:51 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
本帖最后由 铃仙·优昙华院·因幡 于 2014-2-21 10:41 编辑

就是这个!!

  1. #=============================================================================
  2. # (测试)vx复杂装备系统之 装备升级功能 by 沉影不器
  3. # protosssonny修改版
  4. #-----------------------------------------------------------------------------
  5. # 此版本侧重于捕捉bug,欢迎反馈.
  6. #=============================================================================
  7. # 参数设定如下
  8. #=============================================================================
  9. module Game_Equip
  10.   ## 能力升级基数(倍数)
  11.   BaseAbility = 0.2
  12.   ## 每级价格提高基数(倍数)
  13.   BasePrice = 0.3
  14.   ## 是否保证成功
  15.   UpGrade_Absoluteness = false
  16.   ## 每级成功率基数(百分比,用于逐级下降)
  17.   BaseSucceed = 0.85
  18.   ## 最大等级
  19.   MaxLevel = 10
  20.   ## 需金钱基数(与本身价格的倍数)
  21.   GoldNeed = 1.9
  22. end

  23. #=============================================================================
  24. # 复杂装备模块
  25. #=============================================================================
  26. module Game_Equip
  27.   #--------------------------------------------------------------------------
  28.   # ● 处理价格
  29.   #--------------------------------------------------------------------------
  30.   def self.setup_price(item, price)
  31.     equip_price = item.price
  32.     item.price += [(equip_price * BasePrice).round, 1].max
  33.     item.price += price
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 升级是否成功?
  37.   #--------------------------------------------------------------------------
  38.   def self.upgradesucceed?(lv)
  39.     return true if UpGrade_Absoluteness
  40.     new_lv = lv.nil? ? 1 : lv + 1
  41.     return false if new_lv > MaxLevel
  42.     return true if $item_s == 1
  43.     $item_x = 0 if $item_x == nil
  44.     return BaseSucceed ** new_lv + 0.05 * $item_x > rand(0)
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 装备重生
  48.   #    equip:  装备
  49.   #--------------------------------------------------------------------------
  50.   def self.reini(equip)
  51.     return if equip.nil?
  52.     result = Marshal.load(Marshal.dump(equip))
  53.     result.base_id = equip.id
  54.     setup_price(result, 0)
  55.     case result
  56.     when RPG::Weapon
  57.       result.id = $data_weapons.size
  58.       $data_weapons.push result
  59.     when RPG::Armor
  60.       result.id = $data_armors.size
  61.       $data_armors.push result
  62.     end
  63.     return result
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 直接指定装备等级
  67.   #    equip:  装备
  68.   #    lv:  等级
  69.   #--------------------------------------------------------------------------
  70.   def self.level(equip, lv)
  71.     equip.level = 0 if equip.level.nil?
  72.     n = lv - equip.level
  73.     ## 等级更低时返回
  74.     return if n < 0
  75.     n.times{equip = self.upgrade(equip, true)}
  76.     return equip
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 装备升级
  80.   #    equip:  装备
  81.   #--------------------------------------------------------------------------
  82.   def self.upgrade(equip, abs = false)
  83.     unless abs || upgradesucceed?(equip.level)
  84.       $game_party.gain_item(equip, 1)
  85.       return
  86.     end  
  87.     equip.none_upgrade_name = equip.name if equip.level == nil or equip.level == 0
  88.     equip.level = equip.level + 1 rescue 1
  89.     case equip
  90.     when RPG::Weapon
  91.       return if equip.level == MaxLevel
  92.       equip.atk += [($base_weapons[equip.base_id].atk * BaseAbility).round, 1].max if $base_weapons[equip.base_id].atk > 0
  93.       equip.def += [($base_weapons[equip.base_id].def * BaseAbility).round, 1].max if $base_weapons[equip.base_id].def > 0
  94.       equip.spi += [($base_weapons[equip.base_id].spi * BaseAbility).round, 1].max if $base_weapons[equip.base_id].spi > 0
  95.       equip.agi += [($base_weapons[equip.base_id].agi * BaseAbility).round, 1].max if $base_weapons[equip.base_id].agi > 0
  96.       setup_price(equip, 0)
  97.       equip.name = equip.none_upgrade_name + " +" + equip.level.to_s
  98.     when RPG::Armor
  99.       return if equip.level == MaxLevel
  100.       equip.atk += [($base_armors[equip.base_id].atk * BaseAbility).round, 1].max if $base_armors[equip.base_id].atk > 0
  101.       equip.def += [($base_armors[equip.base_id].def * BaseAbility).round, 1].max if $base_armors[equip.base_id].def > 0
  102.       equip.spi += [($base_armors[equip.base_id].spi * BaseAbility).round, 1].max if $base_armors[equip.base_id].spi > 0
  103.       equip.agi += [($base_armors[equip.base_id].agi * BaseAbility).round, 1].max if $base_armors[equip.base_id].agi > 0
  104.       setup_price(equip, 0)
  105.       equip.name = equip.none_upgrade_name + " +" + equip.level.to_s
  106.     end
  107.     return equip
  108.   end
  109. end
  110. #==============================================================================
  111. # ■ RPG::BaseItem
  112. #==============================================================================
  113. module RPG
  114.   class BaseItem
  115.     def initialize
  116.       @id = 0
  117.       @name = ""
  118.       @icon_index = 0
  119.       @description = ""
  120.       @note = ""
  121.       @base_id = 0
  122.       [url=home.php?mod=space&uid=22147]@level[/url] = 1
  123.     end
  124.     attr_accessor :id
  125.     attr_accessor :name
  126.     attr_accessor :icon_index
  127.     attr_accessor :description
  128.     attr_accessor :note
  129.     attr_accessor :base_id
  130.     attr_accessor :level
  131.   end
  132. end
  133. #==============================================================================
  134. # ■ RPG::Weapon
  135. #==============================================================================
  136. module RPG
  137.   class Weapon < BaseItem
  138.     attr_accessor :none_upgrade_name
  139.   end
  140.   class Armor < BaseItem
  141.     attr_accessor :none_upgrade_name
  142.   end
  143. end  
  144. #==============================================================================
  145. # ■ Game_Actor
  146. #==============================================================================
  147. class Game_Actor < Game_Battler
  148.   #--------------------------------------------------------------------------
  149.   # ● 装备重设
  150.   #--------------------------------------------------------------------------
  151.   def reset_equip_id
  152.     if @weapon_id != 0
  153.       item = Game_Equip.reini($base_weapons[@weapon_id])
  154.       unless item.nil?
  155.         $data_weapons.push item
  156.         @weapon_id = item.id
  157.       end
  158.     end
  159.     if @armor1_id != 0
  160.       if two_swords_style
  161.         item = Game_Equip.reini($base_weapons[@armor1_id])
  162.         unless item.nil?
  163.           $data_weapons.push item
  164.           @armor1_id = item.id
  165.         end
  166.       else
  167.         item = Game_Equip.reini($base_armors[@armor1_id])
  168.         unless item.nil?
  169.           $data_armors.push item
  170.           @armor1_id = item.id
  171.         end
  172.       end
  173.     end
  174.     if @armor2_id != 0
  175.       item = $base_armors[@armor2_id]
  176.       unless item.nil?
  177.         item = Game_Equip.reini(item)
  178.         $data_armors.push item
  179.         @armor2_id = item.id
  180.       end
  181.     end
  182.     if @armor3_id != 0
  183.       item = $base_armors[@armor3_id]
  184.       unless item.nil?
  185.         item = Game_Equip.reini(item)
  186.         $data_armors.push item
  187.         @armor3_id = item.id
  188.       end
  189.     end
  190.     if @armor4_id != 0
  191.       item = $base_armors[@armor4_id]
  192.       unless item.nil?
  193.         item = Game_Equip.reini(item)
  194.         $data_armors.push item
  195.         @armor4_id = item.id
  196.       end
  197.     end
  198.   end
  199. end

  200. #==============================================================================
  201. # ■ Window_ScrEquip
  202. #==============================================================================
  203. class Window_ScrEquip < Window_Selectable
  204.   include Game_Equip
  205.   attr_accessor :equip_only
  206.   #--------------------------------------------------------------------------
  207.   # ● 初始化对象
  208.   #     x      : 窗口的 X 坐标
  209.   #     y      : 窗口的 Y 坐标
  210.   #     width  : 窗口的宽
  211.   #     height : 窗口的高
  212.   #--------------------------------------------------------------------------
  213.   def initialize(x, y, width, height)
  214.     super(x, y, width, height)
  215.     @column_max = 1
  216.     @equip_only = true
  217.     refresh
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 取得物品
  221.   #--------------------------------------------------------------------------
  222.   def item
  223.     return @data[self.index]
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 显示是否可以使用物品
  227.   #     item : 物品
  228.   #--------------------------------------------------------------------------
  229.   def enable?(item)
  230.     return true
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 列表中包含的物品
  234.   #     item : 物品
  235.   #--------------------------------------------------------------------------
  236.   def include?(item)
  237.     return true if item == nil
  238.     if @equip_only
  239.       if item.is_a?(RPG::Item)
  240.         return false
  241.       else
  242.         return false if item.is_a?(RPG::Armor) and item.base_id == PA::CRYSTAL
  243.         return false if item.level == MaxLevel - 1  
  244.       end  
  245.     else
  246.       return false unless item.is_a?(RPG::Item) and [PA::SMHS,PA::XYC,PA::OLS,PA::BLS,PA::GLS,PA::YLS,PA::CLS,PA::PLS,PA::FLS].include?(item.id)
  247.     end
  248.     return true
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 刷新
  252.   #--------------------------------------------------------------------------
  253.   def refresh
  254.     self.index = 0
  255.     @data = []
  256.     for item in $game_party.items
  257.       next unless include?(item)
  258.       @data.push(item)
  259.     end
  260.     @data.push(nil) if include?(nil)
  261.     @item_max = @data.size
  262.     create_contents
  263.     for i in 0...@item_max
  264.       draw_item(i)
  265.     end
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ● 描绘项目
  269.   #     index : 项目编号
  270.   #--------------------------------------------------------------------------
  271.   def draw_item(index)
  272.     rect = item_rect(index)
  273.     self.contents.clear_rect(rect)
  274.     item = @data[index]
  275.     if item != nil
  276.       number = $game_party.item_number(item)
  277.       rect.width -= 4
  278.       draw_item_name(item, rect.x, rect.y)
  279.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  280.     end
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ● 更新帮助文本
  284.   #--------------------------------------------------------------------------
  285.   def update_help
  286.     @help_window.set_text(item)
  287.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  288.     @help_window.x = 72
  289.   end  
  290. end

  291. #==============================================================================
  292. # ■ Window_DestEquip #equip add clear items
  293. #==============================================================================
  294. class Window_DestEquip < Window_Base
  295.   #--------------------------------------------------------------------------
  296.   # ● 定义实例变量
  297.   #--------------------------------------------------------------------------
  298.   attr_reader   :equip
  299.   attr_reader   :items
  300.   attr_accessor :index
  301.   #--------------------------------------------------------------------------
  302.   # ● 初始化对象
  303.   #     x      : 窗口的 X 坐标
  304.   #     y      : 窗口的 Y 坐标
  305.   #     width  : 窗口的宽
  306.   #     height : 窗口的高
  307.   #--------------------------------------------------------------------------
  308.   def initialize(x, y, width, height)
  309.     super(x, y, width, height)
  310.     clear
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 添加物品
  314.   #--------------------------------------------------------------------------
  315.   def add(item, n = 1)
  316.     $game_party.lose_item(item, n)
  317.     if [url=home.php?mod=space&uid=370741]@Index[/url] == -1
  318.       @equip = item
  319.     else
  320.       number = @items[item].to_i
  321.       @items[item] = [[number + n, 0].max, 9999].min
  322.     end
  323.     @index += 1
  324.     draw_item(item, n)
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● 清除物品
  328.   #--------------------------------------------------------------------------
  329.   def clear
  330.     @equip = nil
  331.     @items = {}
  332.     @index = -1
  333.     self.contents.clear
  334.     self.contents.font.color = system_color
  335.     self.contents.draw_text(0,0,self.contents.width-16,WLH,"升级装备:")
  336.     self.contents.draw_text(0,WLH*2,self.contents.width-16,WLH,"炼制材料:")
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● 归还物品
  340.   #--------------------------------------------------------------------------
  341.   def revert
  342.     $game_party.gain_item(@equip, 1)
  343.     @items.each{|i,n| $game_party.gain_item(i, n)}
  344.     clear
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 描绘项目
  348.   #     index : 项目编号
  349.   #--------------------------------------------------------------------------
  350.   def draw_item(item, n)
  351.     rect = Rect.new(4,WLH+WLH*@index,self.contents.width-8, WLH)
  352.     rect.y += WLH if @index >0
  353.     if item != nil
  354.       draw_item_name(item, rect.x, rect.y)
  355.       self.contents.draw_text(rect, sprintf(":%2d", n), 2)
  356.     end
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 更新帮助文本
  360.   #--------------------------------------------------------------------------
  361.   def update_help
  362.     @help_window_another.set_text(item == nil ? "" : item.description)
  363.   end
  364. end

  365. #==============================================================================
  366. # ■ Window_EquipNumber
  367. #==============================================================================
  368. class Window_EquipNumber < Window_Base
  369.   #--------------------------------------------------------------------------
  370.   # ● 初始化对象
  371.   #     x : 窗口的 X 坐标
  372.   #     y : 窗口的 Y 坐标
  373.   #--------------------------------------------------------------------------
  374.   def initialize(x, y)
  375.     super(x, y, 272, 112)
  376.     @item = nil
  377.     [url=home.php?mod=space&uid=25307]@Max[/url] = 1
  378.     [url=home.php?mod=space&uid=27178]@Number[/url] = 1
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● 设置物品、最大个数
  382.   #--------------------------------------------------------------------------
  383.   def set(item, max)
  384.     @item = item
  385.     @max = max
  386.     @number = 1
  387.     refresh
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ● 设置输入个数
  391.   #--------------------------------------------------------------------------
  392.   def number
  393.     return @number
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ● 刷新
  397.   #--------------------------------------------------------------------------
  398.   def refresh
  399.     y = 32
  400.     self.z = 1000
  401.     self.contents.clear
  402.     draw_item_name(@item, 0, y)
  403.     self.contents.font.color = normal_color
  404.     self.contents.draw_text(212-32, y, 20, WLH, "×")
  405.     self.contents.draw_text(248-32, y, 20, WLH, @number, 2)
  406.     self.cursor_rect.set(244-32, y, 28, WLH)
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ● 更新画面
  410.   #--------------------------------------------------------------------------
  411.   def update
  412.     super
  413.     if self.active
  414.       last_number = @number
  415.       if Input.repeat?(Input::RIGHT) and @number < @max
  416.         if @item.id == PA::XYC        #幸运草
  417.           if @number < 3
  418.             @number += 1
  419.           end
  420.         elsif @item.id == PA::SMHS     #神秘红石
  421.           @number += 1 if @number == 0
  422.         else  
  423.           @number += 1
  424.         end  
  425.       end
  426.       if Input.repeat?(Input::LEFT) and @number > 1
  427.         @number -= 1
  428.       end
  429.       if Input.repeat?(Input::UP) and @number < @max
  430.         if @item.id == PA::XYC        #幸运草
  431.           if @number < 3
  432.             @number = [3, @max].min
  433.           end
  434.         elsif @item.id == PA::SMHS     #神秘红石
  435.           @number = 1 if @max > 0  
  436.         else  
  437.           @number = [@number + 10, @max].min
  438.         end
  439.       end
  440.       if Input.repeat?(Input::DOWN) and @number > 1
  441.         @number = [@number - 10, 1].max
  442.       end
  443.       if @number != last_number
  444.         Sound.play_cursor
  445.         refresh
  446.       end
  447.     end
  448.   end
  449. end
  450. #==============================================================================
  451. # ■ Window_Gold_Need
  452. #==============================================================================
  453. class Window_Gold_Need < Window_Base
  454.   #--------------------------------------------------------------------------
  455.   # ● 初始化对像
  456.   #--------------------------------------------------------------------------
  457.   def initialize
  458.     super(272,360, 272, 56)  
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 设置文字
  462.   #  text  : 显示于窗口内的字符串
  463.   #  align : 对其 (0..靠左对齐, 1..居中对齐, 2..靠右对齐)
  464.   #--------------------------------------------------------------------------
  465.   def set_text(gold = 0)
  466.     if gold != @gold
  467.       self.contents.clear
  468.       self.contents.font.color = normal_color
  469.       self.contents.draw_text(4, 0, 100, 24, "总计费用:", 0)
  470.       draw_icon(205, 100, 0)
  471.       self.contents.font.color = Color.new(255,255,0,255)
  472.       self.contents.draw_text(140,0,100,24,"G", 2)
  473.       self.contents.draw_text(102, 0, 120, 24, gold.to_s, 2)
  474.       [url=home.php?mod=space&uid=236945]@gold[/url] = gold
  475.     end
  476.   end
  477. end  
  478. #==============================================================================
  479. # ■ Window_EquipNumber
  480. #==============================================================================
  481. class Window_Success < Window_Base
  482.   #--------------------------------------------------------------------------
  483.   # ● 初始化对像
  484.   #--------------------------------------------------------------------------
  485.   def initialize
  486.     super(272, 304, 272, 56)  
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # ● 设置文字
  490.   #  text  : 显示于窗口内的字符串
  491.   #  align : 对其 (0..靠左对齐, 1..居中对齐, 2..靠右对齐)
  492.   #--------------------------------------------------------------------------
  493.   def set_text(equip = nil, lv = 1)
  494.     @success = nil
  495.     success = 0
  496.     success = 100 if Game_Equip::UpGrade_Absoluteness
  497.     new_lv = lv.nil? ? 1 : lv + 1
  498.     $item_x = 0 if $item_x == nil
  499.     $item_s = 0 if $item_s == nil
  500.     if equip == nil
  501.       success = 0
  502.     elsif $item_s > 0 and $item_x == 0
  503.       success = 100
  504.     elsif $item_s == 0 and $item_x > 0
  505.       number = $item_x
  506.       number = 3 if number > 3
  507.       success = ((Game_Equip::BaseSucceed ** new_lv) * 1000).round / 10.0 + 5 * number     
  508.     elsif $item_s == 0 and $item_x == 0
  509.       success = ((Game_Equip::BaseSucceed ** new_lv) * 1000).round / 10.0
  510.     else  
  511.       success = 0
  512.     end
  513.       success = 0 if new_lv > Game_Equip::MaxLevel
  514.     if success != @success
  515.       self.contents.clear
  516.       self.contents.font.color = normal_color
  517.       self.contents.draw_text(4, 0, 120, 24, "升级成功率:", 0)
  518.       self.contents.draw_text(120, 0, 120, 24, success.to_s + "%", 2)
  519.       @success = success
  520.     end
  521.   end
  522. end  
  523. #==============================================================================
  524. # ■ Scene_UpEquip
  525. #==============================================================================
  526. class Scene_UpEquip < Scene_Base
  527.   include Game_Equip
  528.   #--------------------------------------------------------------------------
  529.   # ● 开始处理
  530.   #--------------------------------------------------------------------------
  531.   def start
  532.     super
  533.     create_menu_background
  534.     create_command_window
  535.     @name_window = Window_Base.new(0,0,512-128,56)
  536.     @name_window.contents.draw_text(4,0,544,24,"装备升级",0)
  537.     @gold_need_window = Window_Gold_Need.new
  538.     @gold_need_window.set_text(0)
  539.     $item_x = 0
  540.     $item_s = 0
  541.     @success_window = Window_Success.new
  542.     @success_window.set_text(nil, 1)
  543.     @help_window_another = Window_Process_Help.new
  544.     @help_window_another.x = 0
  545.     @help_window_another.y = 56
  546.     @help_window = Window_Help.new
  547.     @gold_window = Window_Gold.new(384,0)
  548.     @scr_window = Window_ScrEquip.new(0,168,272,248)
  549.     @scr_window.active = true
  550.     @scr_window.help_window = @help_window
  551.     @dest_window = Window_DestEquip.new(272,112,272,248-56)
  552.     @number_window = Window_EquipNumber.new(272,304)
  553.     @number_window.active = false
  554.     @number_window.visible = false
  555.     @result_window = Window_Base.new(118,112,308,56)
  556.     @result_window.active = false
  557.     @result_window.visible = false
  558.     @material_enough_text = "炼制材料放置有误!"
  559.     @gold_enough_text = "升级费用不足!"
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 结束处理
  563.   #--------------------------------------------------------------------------
  564.   def terminate
  565.     super
  566.     dispose_menu_background
  567.     dispose_command_window
  568.     @name_window.dispose
  569.     @gold_need_window.dispose
  570.     @success_window.dispose
  571.     @help_window.dispose
  572.     @help_window_another.dispose
  573.     @gold_window.dispose
  574.     @scr_window.dispose
  575.     @dest_window.dispose
  576.     @number_window.dispose
  577.   end
  578.   #--------------------------------------------------------------------------
  579.   # ● 更新画面
  580.   #--------------------------------------------------------------------------
  581.   def update
  582.     super
  583.     update_menu_background
  584.     @help_window.update
  585.     @help_window_another.update
  586.     @command_window.update
  587.     @gold_window.update
  588.     @scr_window.update
  589.     @dest_window.update
  590.     @number_window.update
  591.     if @command_window.active
  592.       @scr_window.contents_opacity = 128
  593.       @command_window.contents_opacity = 255
  594.       update_command_selection
  595.     elsif @scr_window.active
  596.       @scr_window.contents_opacity = 255
  597.       @command_window.contents_opacity = 128
  598.       update_item_selection
  599.     elsif @number_window.active
  600.       update_number_input
  601.     elsif @result_window.active
  602.       update_result_window
  603.     end
  604.   end
  605.   #--------------------------------------------------------------------------
  606.   # ● 生成指令窗口
  607.   #--------------------------------------------------------------------------
  608.   def create_command_window
  609.     s1 = "升级"
  610.     s2 = "重来"
  611.     s3 = "退出"
  612.     @command_window = Window_Command.new(272, [s1, s2 ,s3], 3, 0, 8)
  613.     @command_window.x = 0
  614.     @command_window.y = 112
  615.     @command_window.active = false
  616.     @command_window.contents_opacity = 128
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● 释放指令窗口
  620.   #--------------------------------------------------------------------------
  621.   def dispose_command_window
  622.     @command_window.dispose
  623.   end
  624.   #--------------------------------------------------------------------------
  625.   # ● 是否满足装备升级条件?
  626.   #--------------------------------------------------------------------------
  627.   def upgradeable?(equip)
  628.     return false if equip.nil?
  629.     if equip.is_a?(RPG::Weapon) || equip.is_a?(RPG::Armor) and equip.level.nil?
  630.       equip.level = 0
  631.     end
  632.     price = (equip.price * (GoldNeed ** (equip.level + 1))).round
  633.     if $game_party.gold < price
  634.       @gold_enough_text = "升级费用不足!"
  635.     else  
  636.       @gold_enough_text = ""
  637.     end  
  638.     @material_enough_text = "炼制材料放置有误!"
  639.     if equip.gifts != [] and equip.gifts != nil
  640.       if @dest_window.items[$data_items[PA::XYC]] != nil
  641.         return false if @dest_window.items[$data_items[PA::XYC]] > 3
  642.       end   
  643.       if @dest_window.items[$data_items[PA::SMHS]] != nil
  644.         return false if @dest_window.items[$data_items[PA::SMHS]] > 1
  645.       end
  646.       case equip.gifts.size
  647.       when 1
  648.         if @dest_window.items[$data_items[PA::XYC]].nil? and @dest_window.items[$data_items[PA::SMHS]].nil?
  649.           return false if @dest_window.items.size != 1
  650.         else  
  651.           return false if @dest_window.items.size != 2
  652.         end  
  653.         return false if @dest_window.items[$data_items[PA::BLS]].nil?
  654.         return false if @dest_window.items[$data_items[PA::BLS]] != 1
  655.       when 2
  656.         if @dest_window.items[$data_items[PA::XYC]].nil? and @dest_window.items[$data_items[PA::SMHS]].nil?
  657.           return false if @dest_window.items.size != 1
  658.         else  
  659.           return false if @dest_window.items.size != 2
  660.         end  
  661.         return false if @dest_window.items[$data_items[PA::GLS]].nil?
  662.         return false if @dest_window.items[$data_items[PA::GLS]] != 1
  663.       when 3
  664.         if @dest_window.items[$data_items[PA::XYC]].nil? and @dest_window.items[$data_items[PA::SMHS]].nil?
  665.           return false if @dest_window.items.size != 1
  666.         else  
  667.           return false if @dest_window.items.size != 2
  668.         end  
  669.         return false if @dest_window.items[$data_items[PA::YLS]].nil?
  670.         return false if @dest_window.items[$data_items[PA::YLS]] != 1
  671.       when 4
  672.         if @dest_window.items[$data_items[PA::XYC]].nil? and @dest_window.items[$data_items[PA::SMHS]].nil?
  673.           return false if @dest_window.items.size != 1
  674.         else  
  675.           return false if @dest_window.items.size != 2
  676.         end  
  677.         return false if @dest_window.items[$data_items[PA::CLS]].nil?
  678.         return false if @dest_window.items[$data_items[PA::CLS]] != 1
  679.       when 5
  680.         if @dest_window.items[$data_items[PA::XYC]].nil? and @dest_window.items[$data_items[PA::SMHS]].nil?
  681.           return false if @dest_window.items.size != 1
  682.         else  
  683.           return false if @dest_window.items.size != 2
  684.         end  
  685.         return false if @dest_window.items[$data_items[PA::PLS]].nil?
  686.         return false if @dest_window.items[$data_items[PA::PLS]] != 1
  687.       when 6
  688.         if @dest_window.items[$data_items[PA::XYC]].nil? and @dest_window.items[$data_items[PA::SMHS]].nil?
  689.           return false if @dest_window.items.size != 1
  690.         else  
  691.           return false if @dest_window.items.size != 2
  692.         end  
  693.         return false if @dest_window.items[$data_items[PA::FLS]].nil?
  694.         return false if @dest_window.items[$data_items[PA::FLS]] != 1
  695.       end
  696.     elsif equip.is_a?(RPG::Armor) and equip.base_id == PA::CRYSTAL
  697.       return false
  698.     else  
  699.       if @dest_window.items[$data_items[PA::XYC]].nil? and @dest_window.items[$data_items[PA::SMHS]].nil?
  700.         return false if @dest_window.items.size != 1
  701.       else  
  702.         return false if @dest_window.items.size != 2
  703.       end  
  704.       return false if @dest_window.items[$data_items[PA::OLS]].nil?
  705.       return false if @dest_window.items[$data_items[PA::OLS]] != 1
  706.     end
  707.     @material_enough_text = ""
  708.     return false if $game_party.gold < price
  709.     ## 扣钱
  710.     $game_party.lose_gold(price)
  711.     @gold_window.refresh
  712.     return true
  713.   end
  714.   #--------------------------------------------------------------------------
  715.   # ● 显示结果(包括处理金钱物品)
  716.   #--------------------------------------------------------------------------
  717.   def show_result
  718.     @result_window.active = true
  719.     @result_window.visible = true
  720.     unless upgradeable?(@dest_window.equip)
  721.       if @material_enough_text != "" and @gold_enough_text == ""
  722.         @result_window.contents.clear
  723.         @result_window.contents.draw_text(0,0,352,24,@material_enough_text, 0)
  724.       elsif @material_enough_text == "" and @gold_enough_text != ""
  725.         @result_window.contents.clear
  726.         @result_window.contents.draw_text(0,0,352,24,@gold_enough_text, 0)
  727.       elsif @material_enough_text != "" and @gold_enough_text != ""
  728.         @result_window.contents.clear
  729.         @result_window.contents.draw_text(0,0,352,24,@material_enough_text, 0)
  730.         @result_window.contents.draw_text(0,24,352,24,@gold_enough_text, 0)
  731.       end  
  732.       @dest_window.revert
  733.       Sound.play_actor_collapse
  734.       ## 直接返回
  735.       return
  736.     end
  737.     msg = Game_Equip.upgrade(@dest_window.equip)
  738.     @gold_window.refresh
  739.     case msg
  740.     when RPG::Weapon
  741.       @result_window.contents.clear
  742.       @result_window.contents.draw_text(0, 0, 352, 24, "升级成功!")
  743.       $game_party.gain_item(msg, 1)
  744.       Audio.se_play("Audio/SE/" + "Heal7", 100, 100)
  745.       Sound.play_shop
  746.     when RPG::Armor
  747.       @result_window.contents.clear
  748.       @result_window.contents.draw_text(0, 0, 352, 24, "升级成功!")
  749.       $game_party.gain_item(msg, 1)
  750.       Audio.se_play("Audio/SE/" + "Heal7", 100, 100)
  751.       Sound.play_shop
  752.     else
  753.       @result_window.contents.clear
  754.       @result_window.contents.draw_text(0, 0, 352, 24, "升级失败!")
  755.       Sound.play_actor_collapse
  756.     end
  757.     @dest_window.clear
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # ● 更新帮助文本
  761.   #--------------------------------------------------------------------------
  762.   def update_help(text)
  763.     @help_window_another.set_text2(text)
  764.   end  
  765.   #--------------------------------------------------------------------------
  766.   # ● 更新指令窗口
  767.   #--------------------------------------------------------------------------
  768.   def update_command_selection
  769.     case @command_window.index
  770.     when 0
  771.       update_help("确定键执行装备升级。")
  772.     when 1
  773.       update_help("返回升级界面的最初状态。")  
  774.     when 2
  775.       update_help("退出升级界面。")
  776.     end
  777.     if Input.trigger?(Input::B)
  778.       ## 重来
  779.       Sound.play_cancel
  780.       @scr_window.active = true
  781.       @command_window.active = false
  782.       @gold_need_window.set_text(0)
  783.       $item_x = 0
  784.       $item_s = 0
  785.       @success_window.set_text(nil, 1)
  786.     elsif Input.trigger?(Input::C)
  787.       case @command_window.index
  788.       when 0  # 升级
  789.         Sound.play_decision
  790.         @command_window.active = false
  791.         @scr_window.active = false
  792.         ######### 显示升级结果,归还物品
  793.         show_result
  794.         @gold_need_window.set_text(0)
  795.         $item_x = 0
  796.         $item_s = 0
  797.         @success_window.set_text(nil, 1)
  798.       when 1  # 重来
  799.         @command_window.active = false
  800.         @scr_window.active = false
  801.         @dest_window.revert
  802.         update_result_window
  803.         @gold_need_window.set_text(0)
  804.         $item_x = 0
  805.         $item_s = 0
  806.         @success_window.set_text(nil, 1)
  807.       when 2  # 退出
  808.         Sound.play_decision
  809.         @dest_window.revert
  810.         $scene = Scene_Map.new
  811.       end
  812.     end
  813.   end
  814.   #--------------------------------------------------------------------------
  815.   # ● 更新选择物品
  816.   #--------------------------------------------------------------------------
  817.   def update_item_selection
  818.     equip = @dest_window.equip
  819.     if equip.is_a?(RPG::Weapon) || equip.is_a?(RPG::Armor) and equip.level.nil?
  820.       @dest_window.equip.level = 0
  821.     end
  822.     material = PA::MATERIAL
  823.     if @scr_window.equip_only
  824.       update_help("请选择需要升级的装备,或按Q取消。")
  825.     else
  826.       number = equip.gifts.size rescue 0
  827.       update_help("请放置1个#{material[number]}和成功率提升材料,按W确认或按Q重来")
  828.       price = (equip.price * (GoldNeed ** (equip.level + 1))).round
  829.       @gold_need_window.set_text(price)
  830.       @success_window.set_text(equip, equip.level)
  831.     end  
  832.     if Input.trigger?(Input::R)
  833.       if @dest_window.index > 0
  834.         Sound.play_decision
  835.         @command_window.active = true
  836.         @scr_window.active = false
  837.       else  
  838.         Sound.play_buzzer
  839.       end  
  840.       return
  841.     end
  842.     if Input.trigger?(Input::L)
  843.       if @scr_window.equip_only
  844.         Sound.play_cancel
  845.         @dest_window.revert
  846.         $scene = Scene_Map.new
  847.       else  
  848.         @scr_window.equip_only = true
  849.         Sound.play_cancel
  850.         @dest_window.revert
  851.         @scr_window.active = true
  852.         @scr_window.refresh
  853.         @command_window.active = false
  854.         @gold_need_window.set_text(0)
  855.         $item_x = 0
  856.         $item_s = 0
  857.         @success_window.set_text(nil, 1)
  858.         return
  859.       end
  860.     end  
  861.     if Input.trigger?(Input::C)
  862.        @item = @scr_window.item
  863.        number = $game_party.item_number(@item)
  864.       if @item == nil or number == 0
  865.         Sound.play_buzzer
  866.       else
  867.         ##### 传递物品给容器栏
  868.         if number > 1
  869.           Sound.play_decision
  870.           @scr_window.active = false
  871.           @number_window.set(@item, number)
  872.           @number_window.active = true
  873.           @number_window.visible = true
  874.         else
  875.           Sound.play_shop
  876.           @dest_window.add(@scr_window.item, 1)
  877.           @scr_window.equip_only = false
  878.           @scr_window.refresh
  879.         end
  880.       end
  881.     end
  882.   end
  883.   #--------------------------------------------------------------------------
  884.   # ● 更新输入个数
  885.   #--------------------------------------------------------------------------
  886.   def update_number_input
  887.     if Input.trigger?(Input::B)
  888.       cancel_number_input
  889.     elsif Input.trigger?(Input::C)
  890.       decide_number_input
  891.     end
  892.   end
  893.   #--------------------------------------------------------------------------
  894.   # ● 更新结果窗体
  895.   #--------------------------------------------------------------------------
  896.   def update_result_window
  897.     if Input.trigger?(Input::B) or Input.trigger?(Input::C)
  898.       Sound.play_decision
  899.       @scr_window.equip_only = true
  900.       @scr_window.refresh
  901.       @scr_window.active = true
  902.       @result_window.active = false
  903.       @result_window.visible = false
  904.     end
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # ● 取消输入个数
  908.   #--------------------------------------------------------------------------
  909.   def cancel_number_input
  910.     Sound.play_cancel
  911.     @number_window.active = false
  912.     @number_window.visible = false
  913.     @scr_window.active = true
  914.     @scr_window.visible = true
  915.   end
  916.   #--------------------------------------------------------------------------
  917.   # ● 确定输入个数
  918.   #--------------------------------------------------------------------------
  919.   def decide_number_input
  920.     Sound.play_shop
  921.     @number_window.active = false
  922.     @number_window.visible = false
  923.     @dest_window.add(@item, @number_window.number)
  924.     $item_x = @dest_window.items[$data_items[PA::XYC]] #放置幸运草的数量
  925.     $item_s = @dest_window.items[$data_items[PA::SMHS]] #放置神秘红石数量(数量为1个)
  926.     $item_x = 0 if $item_x == nil
  927.     $item_s = 0 if $item_s == nil
  928.     @success_window.set_text(@dest_window.equip, @dest_window.equip.level)
  929.     @scr_window.equip_only = false
  930.     @scr_window.refresh
  931.     @scr_window.active = true
  932.   end
  933. end
复制代码

Lv1.梦旅人

梦石
0
星屑
168
在线时间
112 小时
注册时间
2014-2-4
帖子
50
4
 楼主| 发表于 2014-2-13 13:20:00 | 只看该作者
正太君 发表于 2014-2-4 19:55
据说这个不能单独使用的

额······
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

聪仔

梦石
0
星屑
6182
在线时间
3077 小时
注册时间
2013-12-26
帖子
3145
3
发表于 2014-2-4 19:55:04 | 只看该作者
据说这个不能单独使用的
聪聪全国第三帅...
他们都叫我【人赢聪】
我的RM能力雷达图:

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-10-1 19:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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