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

Project1

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

[已经过期] 请问这个问题如何解决?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
153 小时
注册时间
2010-12-18
帖子
167
跳转到指定楼层
1
发表于 2013-6-4 13:46:05 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 mo88 于 2013-6-9 12:40 编辑

这个装备强化脚本出现几个问题。其中有两个问题我不知道如何解决。
1.每逢和道具店NPC对话就出错(但是和武器防具NPC对话就不会出错)
2.装备强化我只设置了只需要一种材料,但是在强化装备时 , 物品数量只要是1以上的东西(包括药水什么的)都会显示在装备升级素材选择里。

RUBY 代码复制
  1. #=============================================================================
  2. # (测试)vx复杂装备系统之 装备升级功能 by 沉影不器
  3. #-----------------------------------------------------------------------------
  4. # 此版本侧重于捕捉bug,欢迎反馈.
  5. #=============================================================================
  6. # 参数设定如下         $scene = Scene_UpEquip.new
  7. #=============================================================================
  8. module Game_Equip
  9.   ## 能力升级基数(倍数)
  10.   BaseAbility = 0.03
  11.   ## 每级价格提高基数(倍数)
  12.   BasePrice = 0.3
  13.   ## 是否保证成功
  14.   UpGrade_Absoluteness = true
  15.   ## 每级成功率基数(百分比,用于逐级下降)
  16.   BaseSucceed = 0.8
  17.   ## 最大等级
  18.   MaxLevel = 10
  19.   ## 需金钱基数(与本身价格的倍数)
  20.   GoldNeed = 0.3
  21.   ## 需物品id => 数量
  22.   ItemsNeed = {17=>1}
  23. end
  24.  
  25. #=============================================================================
  26. # 复杂装备模块
  27. #=============================================================================
  28. module Game_Equip
  29.   #--------------------------------------------------------------------------
  30.   # ● 处理价格
  31.   #--------------------------------------------------------------------------
  32.   def self.setup_price(item, price)
  33.     item.price = $base_weapons[item.base_id].price
  34.     item.price += [(item.price * BasePrice).round, 1].max
  35.     item.price += price
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 升级是否成功?
  39.   #--------------------------------------------------------------------------
  40.   def self.upgradesucceed?(lv)
  41.     return true if UpGrade_Absoluteness
  42.     new_lv = lv.nil? ? 1 : lv + 1
  43.     return false if new_lv > MaxLevel
  44.     return BaseSucceed**new_lv > 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.       ##result.name += result.id.to_s
  59.       $data_weapons.push result
  60.     when RPG::Armor
  61.       result.id = $data_armors.size
  62.       ##result.name += result.id.to_s
  63.       $data_armors.push result
  64.     end
  65.     return result
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 直接指定装备等级
  69.   #    equip:  装备
  70.   #    lv:  等级
  71.   #--------------------------------------------------------------------------
  72.   def self.level(equip, lv)
  73.     equip.level = 1 if equip.level.nil?
  74.     n = lv - equip.level
  75.     ## 等级更低时返回
  76.     return if n < 0
  77.     n.times{equip = self.upgrade(equip, true)}
  78.     return equip
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 装备升级
  82.   #    equip:  装备
  83.   #--------------------------------------------------------------------------
  84.   def self.upgrade(equip, abs = false)
  85.     return unless abs || upgradesucceed?(equip.level)
  86.     case equip
  87.     when RPG::Weapon
  88.       return if equip.level == MaxLevel
  89.       equip.level += 1
  90.       if equip.level == 2
  91.         equip.name.concat "(Lv.2)"
  92.       elsif equip.level > 2
  93.         equip.name.sub!(/\(Lv\.([0-9]+)\)/) {"(Lv.#{equip.level})"}
  94.       end
  95.       equip.atk += [(equip.atk * BaseAbility).round, 1].max
  96.       setup_price(equip, 0)
  97.     when RPG::Armor
  98.       return if equip.level == MaxLevel
  99.       equip.level += 1
  100.       if equip.level == 2
  101.         equip.name.concat "(Lv.2)"
  102.       elsif equip.level > 2
  103.         equip.name.sub!(/\(Lv\.([0-9]+)\)/) {"(Lv.#{equip.level})"}
  104.       end
  105.       equip.def += [(equip.def * BaseAbility).round, 1].max
  106.       setup_price(equip, 0)
  107.     end
  108.     return equip
  109.   end
  110. end
  111. #==============================================================================
  112. # ■ RPG::BaseItem
  113. #==============================================================================
  114. module RPG
  115.   class BaseItem
  116.     def initialize
  117.       @id = 0
  118.       @name = ""
  119.       @icon_index = 0
  120.       @description = ""
  121.       @note = ""
  122.       @base_id = 0
  123.       [url=home.php?mod=space&uid=22147]@level[/url] = 1
  124.     end
  125.     attr_accessor :id
  126.     attr_accessor :name
  127.     attr_accessor :icon_index
  128.     attr_accessor :description
  129.     attr_accessor :note
  130.     attr_accessor :base_id
  131.     attr_accessor :level
  132.   end
  133. end
  134.  
  135. #==============================================================================
  136. # ■ Game_Actor
  137. #==============================================================================
  138. class Game_Actor < Game_Battler
  139.   #--------------------------------------------------------------------------
  140.   # ● 设置
  141.   #     actor_id : 角色 ID
  142.   #--------------------------------------------------------------------------
  143.   def setup(actor_id)
  144.     actor = $data_actors[actor_id]
  145.     @actor_id = actor_id
  146.     @name = actor.name
  147.     @character_name = actor.character_name
  148.     @character_index = actor.character_index
  149.     @face_name = actor.face_name
  150.     @face_index = actor.face_index
  151.     @class_id = actor.class_id
  152.     @weapon_id = actor.weapon_id
  153.     @armor1_id = actor.armor1_id
  154.     @armor2_id = actor.armor2_id
  155.     @armor3_id = actor.armor3_id
  156.     @armor4_id = actor.armor4_id
  157.     [url=home.php?mod=space&uid=22147]@level[/url] = actor.initial_level
  158.     @exp_list = Array.new(101)
  159.     make_exp_list
  160.     [url=home.php?mod=space&uid=13302]@exp[/url] = @exp_list[@level]
  161.     @skills = []
  162.     for i in self.class.learnings
  163.       learn_skill(i.skill_id) if i.level <= @level
  164.     end
  165.     clear_extra_values
  166.     recover_all
  167.     ## 生成新装备id
  168.     reset_equip_id
  169.   end
  170.  
  171.   #--------------------------------------------------------------------------
  172.   # ● 装备重设
  173.   #--------------------------------------------------------------------------
  174.   def reset_equip_id
  175.     if @weapon_id != 0
  176.       item = Game_Equip.reini($base_weapons[@weapon_id])
  177.       unless item.nil?
  178.         $data_weapons.push item
  179.         @weapon_id = item.id
  180.       end
  181.     end
  182.     if @armor1_id != 0
  183.       if two_swords_style####two_hands_legal?
  184.         item = Game_Equip.reini($base_weapons[@armor1_id])
  185.         unless item.nil?
  186.           $data_weapons.push item
  187.           @armor1_id = item.id
  188.         end
  189.       else
  190.         item = Game_Equip.reini($base_armors[@armor1_id])
  191.         unless item.nil?
  192.           $data_armors.push item
  193.           @armor1_id = item.id
  194.         end
  195.       end
  196.     end
  197.     if @armor2_id != 0
  198.       item = $base_armors[@armor2_id]
  199.       unless item.nil?
  200.         item = Game_Equip.reini(item)
  201.         $data_armors.push item
  202.         @armor2_id = item.id
  203.       end
  204.     end
  205.     if @armor3_id != 0
  206.       item = $base_armors[@armor3_id]
  207.       unless item.nil?
  208.         item = Game_Equip.reini(item)
  209.         $data_armors.push item
  210.         @armor3_id = item.id
  211.       end
  212.     end
  213.     if @armor4_id != 0
  214.       item = $base_armors[@armor4_id]
  215.       unless item.nil?
  216.         item = Game_Equip.reini(item)
  217.         $data_armors.push item
  218.         @armor4_id = item.id
  219.       end
  220.     end
  221.   end
  222.  
  223.   #--------------------------------------------------------------------------
  224.   # ● 判断是否可以装备
  225.   #     item : 物品
  226.   #     base : 是否读取母版数据
  227.   #--------------------------------------------------------------------------
  228.   def equippable?(item, base = true)
  229.     id = base ? item.base_id : item.id
  230.     if item.is_a?(RPG::Weapon)
  231.       return self.class.weapon_set.include?(id)
  232.     elsif item.is_a?(RPG::Armor)
  233.       return false if two_swords_style and item.kind == 0
  234.       return self.class.armor_set.include?(id)
  235.     end
  236.     return false
  237.   end
  238. end
  239.  
  240. #==============================================================================
  241. # ■ Game_Party
  242. #==============================================================================
  243. class Game_Party < Game_Unit
  244.   #--------------------------------------------------------------------------
  245.   # ● 判断持有的物品
  246.   #     item          : 物品
  247.   #     include_equip : 包括装备品
  248.   #--------------------------------------------------------------------------
  249.   def has_item_by_base_id?(item, include_equip = false)
  250.     for i in items
  251.       return true if i.base_id == item.id
  252.     end
  253.     if include_equip
  254.       for actor in members
  255.         for e in actor.equips
  256.           return true if e.base_id == item.id
  257.         end
  258.       end
  259.     end
  260.     return false
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 获得物品
  264.   #     item          : 物品
  265.   #     n             : 个数
  266.   #--------------------------------------------------------------------------
  267.   def gain_reini_item(item, n, include_equip = false)
  268.     if n < 0
  269.       lose_item(item, -n, include_equip = false)
  270.     else
  271.       case item
  272.       when RPG::Item
  273.         number = item_number(item)
  274.         @items[item.id] = [[number + n, 0].max, 99].min
  275.       when RPG::Weapon
  276.         for i in 0...n
  277.           w = Game_Equip.reini(item)
  278.           @weapons[w.id] = 1
  279.         end
  280.       when RPG::Armor
  281.         for i in 0...n
  282.           a = Game_Equip.reini(item)
  283.           @armors[a.id] = 1
  284.         end
  285.       end
  286.     end
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● 减少物品 (减少)
  290.   #     item          : 物品
  291.   #     n             : 个数
  292.   #     include_equip : 包括装备品
  293.   #--------------------------------------------------------------------------
  294.   def lose_reini_item(item, n, include_equip = false)
  295.     number = item_number(item)
  296.     case item
  297.     when RPG::Item
  298.       @items[item.id] = [[number - n, 0].max, 99].min
  299.     when RPG::Weapon
  300.       @weapons[item.id] = [[number - n, 0].max, 99].min
  301.     when RPG::Armor
  302.       @armors[item.id] = [[number - n, 0].max, 99].min
  303.     end
  304.     n -= number
  305.     if include_equip and n > 0
  306.       for actor in members
  307.         while n > 0 and actor.equips.include?(item)
  308.           actor.discard_equip(item)
  309.           n -= 1
  310.         end
  311.       end
  312.     end
  313.   end
  314. end
  315.  
  316. #==============================================================================
  317. # ■ Game_Troop
  318. #==============================================================================
  319. class Game_Troop < Game_Unit
  320.   #--------------------------------------------------------------------------
  321.   # ● 敌人角色名称后的文字表
  322.   #--------------------------------------------------------------------------
  323.   LETTER_TABLE = [ 'A','B','C','D','E','F','G','H','I','J',
  324.                    'K','L','M','N','O','P','Q','R','S','T',
  325.                    'U','V','W','X','Y','Z']
  326.   #--------------------------------------------------------------------------
  327.   # ● 生成掉落物品队列
  328.   #--------------------------------------------------------------------------
  329.   def make_drop_items
  330.     drop_items = []
  331.     for enemy in dead_members
  332.       for di in [enemy.drop_item1, enemy.drop_item2]
  333.         next if di.kind == 0
  334.         next if rand(di.denominator) != 0
  335.         if di.kind == 1
  336.           drop_items.push($data_items[di.item_id])
  337.         elsif di.kind == 2
  338.           drop_items.push($base_weapons[di.weapon_id])
  339.         elsif di.kind == 3
  340.           drop_items.push($base_armors[di.armor_id])
  341.         end
  342.       end
  343.     end
  344.     return drop_items
  345.   end
  346. end
  347.  
  348. #==============================================================================
  349. # ■ Game_Interpreter
  350. #==============================================================================
  351. class Game_Interpreter
  352.   #--------------------------------------------------------------------------
  353.   # ● 计算操作的值
  354.   #     operation    : 操作 (0:增加 1:减少)
  355.   #     operand_type : 运算域类型 (0:常量 1:变量)
  356.   #     operand      : 运算域 (数值为变量 ID)
  357.   #--------------------------------------------------------------------------
  358.   def operate_value(operation, operand_type, operand)
  359.     if operand_type == 0
  360.       value = operand
  361.     else
  362.       value = $game_variables[operand]
  363.     end
  364.     if operation == 1
  365.       value = -value
  366.     end
  367.     return value
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 条件分歧
  371.   #--------------------------------------------------------------------------
  372.   def command_111
  373.     result = false
  374.     case @params[0]
  375.     when 0  # 开关
  376.       result = ($game_switches[@params[1]] == (@params[2] == 0))
  377.     when 1  # 变量
  378.       value1 = $game_variables[@params[1]]
  379.       if @params[2] == 0
  380.         value2 = @params[3]
  381.       else
  382.         value2 = $game_variables[@params[3]]
  383.       end
  384.       case @params[4]
  385.       when 0  # 相等
  386.         result = (value1 == value2)
  387.       when 1  # 大于等于
  388.         result = (value1 >= value2)
  389.       when 2  # 小于等于
  390.         result = (value1 <= value2)
  391.       when 3  # 大于
  392.         result = (value1 > value2)
  393.       when 4  # 小于
  394.         result = (value1 < value2)
  395.       when 5  # 不等于
  396.         result = (value1 != value2)
  397.       end
  398.     when 2  # 自我开关
  399.       if @original_event_id > 0
  400.         key = [@map_id, @original_event_id, @params[1]]
  401.         if @params[2] == 0
  402.           result = ($game_self_switches[key] == true)
  403.         else
  404.           result = ($game_self_switches[key] != true)
  405.         end
  406.       end
  407.     when 3  # 计时器
  408.       if $game_system.timer_working
  409.         sec = $game_system.timer / Graphics.frame_rate
  410.         if @params[2] == 0
  411.           result = (sec >= @params[1])
  412.         else
  413.           result = (sec <= @params[1])
  414.         end
  415.       end
  416.     when 4  # 角色
  417.       actor = $game_actors[@params[1]]
  418.       if actor != nil
  419.         case @params[2]
  420.         when 0  # 是同伴
  421.           result = ($game_party.members.include?(actor))
  422.         when 1  # 姓名
  423.           result = (actor.name == @params[3])
  424.         when 2  # 特技
  425.           result = (actor.skill_learn?($data_skills[@params[3]]))
  426.         when 3  # 武器
  427.           ## 判断是否符合母版id
  428.           actor.weapons.each do |weapon|
  429.             if weapon.base_id == @params[3]
  430.               result = true
  431.               break
  432.             end
  433.           end
  434.         when 4  # 防具
  435.           ## 判断是否符合母版id
  436.           actor.armors.each do |armor|
  437.             if armor.base_id == @params[3]
  438.               result = true
  439.               break
  440.             end
  441.           end
  442.         when 5  # 状态
  443.           result = (actor.state?(@params[3]))
  444.         end
  445.       end
  446.     when 5  # 敌方角色
  447.       enemy = $game_troop.members[@params[1]]
  448.       if enemy != nil
  449.         case @params[2]
  450.         when 0  # 出现
  451.           result = (enemy.exist?)
  452.         when 1  # 状态
  453.           result = (enemy.state?(@params[3]))
  454.         end
  455.       end
  456.     when 6  # 角色
  457.       character = get_character(@params[1])
  458.       if character != nil
  459.         result = (character.direction == @params[2])
  460.       end
  461.     when 7  # 金钱
  462.       if @params[2] == 0
  463.         result = ($game_party.gold >= @params[1])
  464.       else
  465.         result = ($game_party.gold <= @params[1])
  466.       end
  467.     when 8  # 物品
  468.       result = $game_party.has_item?($data_items[@params[1]])
  469.     when 9  # 武器
  470.       result = $game_party.has_item_by_base_id?($base_weapons[@params[1]], @params[2])
  471.     when 10  # 防具
  472.       result = $game_party.has_item_by_base_id?($base_armors[@params[1]], @params[2])
  473.     when 11  # 按钮
  474.       result = Input.press?(@params[1])
  475.     when 12  # 脚本
  476.       result = eval(@params[1])
  477.     when 13  # 交通工具
  478.       result = ($game_player.vehicle_type == @params[1])
  479.     end
  480.     @branch[@indent] = result     # 将判断结果放置在缓存中
  481.     if @branch[@indent] == true
  482.       @branch.delete(@indent)
  483.       return true
  484.     end
  485.     return command_skip
  486.   end
  487.  
  488.  
  489.   #--------------------------------------------------------------------------
  490.   # ● 计算装备操作的值
  491.   #     operand_type : 运算域类型 (0:常量 1:变量)
  492.   #     operand      : 运算域 (数值为变量 ID)
  493.   #--------------------------------------------------------------------------
  494.   def opera_equip_value(operation, operand_type, operand)
  495.     if operand_type == 0
  496.       value = operand
  497.     else
  498.       value = $game_variables[operand]
  499.     end
  500.     return value
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # ● 增减武器
  504.   #--------------------------------------------------------------------------
  505.   def command_127
  506.     value = operate_value(@params[1], @params[2], @params[3])
  507.     if @params[1] == 0
  508.       $game_party.gain_reini_item($base_weapons[@params[0]], value.abs, @params[4])
  509.     else
  510.       $game_party.lose_reini_item($base_weapons[@params[0]], value.abs, @params[4])
  511.     end
  512.     return true
  513.   end
  514.   #--------------------------------------------------------------------------
  515.   # ● 增减防具
  516.   #--------------------------------------------------------------------------
  517.   def command_128
  518.     value = operate_value(@params[1], @params[2], @params[3])
  519.     if @params[1] == 0
  520.       $game_party.gain_reini_item($base_armors[@params[0]], value.abs, @params[4])
  521.     else
  522.       $game_party.lose_reini_item($base_armors[@params[0]], value.abs, @params[4])
  523.     end
  524.     return true
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 更改装备
  528.   #--------------------------------------------------------------------------
  529.   def command_319
  530.     actor = $game_actors[@params[0]]
  531.     if actor != nil
  532.       actor.change_equip_by_id(@params[1], @params[2])
  533.     end
  534.     return true
  535.   end
  536. end
  537.  
  538. #==============================================================================
  539. # ■ Window_ShopBuy
  540. #==============================================================================
  541. class Window_ShopBuy < Window_Selectable
  542.   #--------------------------------------------------------------------------
  543.   # ● 刷新
  544.   #--------------------------------------------------------------------------
  545.   def refresh
  546.     @data = []
  547.     for goods_item in @shop_goods
  548.       case goods_item[0]
  549.       when 0
  550.         item = $base_items[goods_item[1]]
  551.       when 1
  552.         item = $base_weapons[goods_item[1]]
  553.       when 2
  554.         item = $base_armors[goods_item[1]]
  555.       end
  556.       if item != nil
  557.         @data.push(item)
  558.       end
  559.     end
  560.     @item_max = @data.size
  561.     create_contents
  562.     for i in 0...@item_max
  563.       draw_item(i)
  564.     end
  565.   end
  566. end
  567.  
  568. #==============================================================================
  569. # ■ Window_ShopStatus
  570. #==============================================================================
  571. class Window_ShopStatus < Window_Base
  572.   #--------------------------------------------------------------------------
  573.   # ● 描绘角色现在装备的能力值变化
  574.   #     actor : 角色
  575.   #     x     : 描画目标 X 坐标
  576.   #     y     : 描画目标 Y 坐标
  577.   #--------------------------------------------------------------------------
  578.   def draw_actor_parameter_change(actor, x, y)
  579.     return if @item.is_a?(RPG::Item)
  580.     enabled = actor.equippable?(@item, false)
  581.     self.contents.font.color = normal_color
  582.     self.contents.font.color.alpha = enabled ? 255 : 128
  583.     self.contents.draw_text(x, y, 200, WLH, actor.name)
  584.     if @item.is_a?(RPG::Weapon)
  585.       item1 = weaker_weapon(actor)
  586.     elsif actor.two_swords_style and @item.kind == 0
  587.       item1 = nil
  588.     else
  589.       item1 = actor.equips[1 + @item.kind]
  590.     end
  591.     if enabled
  592.       if @item.is_a?(RPG::Weapon)
  593.         atk1 = item1 == nil ? 0 : item1.atk
  594.         atk2 = @item == nil ? 0 : @item.atk
  595.         change = atk2 - atk1
  596.       else
  597.         def1 = item1 == nil ? 0 : item1.def
  598.         def2 = @item == nil ? 0 : @item.def
  599.         change = def2 - def1
  600.       end
  601.       self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
  602.     end
  603.     draw_item_name(item1, x, y + WLH, enabled)
  604.   end
  605. end
  606.  
  607. #==============================================================================
  608. # ■ Window_ScrEquip
  609. #==============================================================================
  610. class Window_ScrEquip < Window_Selectable
  611.   attr_accessor :equip_only
  612.   #--------------------------------------------------------------------------
  613.   # ● 初始化对象
  614.   #     x      : 窗口的 X 坐标
  615.   #     y      : 窗口的 Y 坐标
  616.   #     width  : 窗口的宽
  617.   #     height : 窗口的高
  618.   #--------------------------------------------------------------------------
  619.   def initialize(x, y, width, height)
  620.     super(x, y, width, height)
  621.     @column_max = 1
  622.     @equip_only = true
  623.     refresh
  624.   end
  625.   #--------------------------------------------------------------------------
  626.   # ● 取得物品
  627.   #--------------------------------------------------------------------------
  628.   def item
  629.     return @data[self.index]
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● 显示是否可以使用物品
  633.   #     item : 物品
  634.   #--------------------------------------------------------------------------
  635.   def enable?(item)
  636.     return true
  637.   end
  638.   #--------------------------------------------------------------------------
  639.   # ● 列表中包含的物品
  640.   #     item : 物品
  641.   #--------------------------------------------------------------------------
  642.   def include?(item)
  643.     return true if item == nil
  644.     if @equip_only
  645.       return false if item.is_a? RPG::Item
  646.     else
  647.       return false unless item.is_a? RPG::Item
  648.     end
  649.     return true
  650.   end
  651.   #--------------------------------------------------------------------------
  652.   # ● 刷新
  653.   #--------------------------------------------------------------------------
  654.   def refresh
  655.     self.index = 0
  656.     @data = []
  657.     for item in $game_party.items
  658.       next unless include?(item)
  659.       @data.push(item)
  660.     end
  661.     @data.push(nil) if include?(nil)
  662.     @item_max = @data.size
  663.     create_contents
  664.     for i in 0...@item_max
  665.       draw_item(i)
  666.     end
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # ● 描绘项目
  670.   #     index : 项目编号
  671.   #--------------------------------------------------------------------------
  672.   def draw_item(index)
  673.     rect = item_rect(index)
  674.     self.contents.clear_rect(rect)
  675.     item = @data[index]
  676.     if item != nil
  677.       number = $game_party.item_number(item)
  678.       rect.width -= 4
  679.       draw_item_name(item, rect.x, rect.y)
  680.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  681.     end
  682.   end
  683.   #--------------------------------------------------------------------------
  684.   # ● 更新帮助文本
  685.   #--------------------------------------------------------------------------
  686.   def update_help
  687.     @help_window.set_text(item == nil ? "" : item.description)
  688.   end  
  689. end
  690.  
  691. #==============================================================================
  692. # ■ Window_DestEquip #equip add clear items
  693. #==============================================================================
  694. class Window_DestEquip < Window_Base
  695.   #--------------------------------------------------------------------------
  696.   # ● 定义实例变量
  697.   #--------------------------------------------------------------------------
  698.   attr_reader   :equip
  699.   attr_reader   :items
  700.   #--------------------------------------------------------------------------
  701.   # ● 初始化对象
  702.   #     x      : 窗口的 X 坐标
  703.   #     y      : 窗口的 Y 坐标
  704.   #     width  : 窗口的宽
  705.   #     height : 窗口的高
  706.   #--------------------------------------------------------------------------
  707.   def initialize(x, y, width, height)
  708.     super(x, y, width, height)
  709.     clear
  710.   end
  711.   #--------------------------------------------------------------------------
  712.   # ● 添加物品
  713.   #--------------------------------------------------------------------------
  714.   def add(item, n = 1)
  715.     $game_party.lose_item(item, n)
  716.     if @index == -1
  717.       @equip = item
  718.     else
  719.       number = @items[item].to_i
  720.       @items[item] = [[number + n, 0].max, 99].min
  721.     end
  722.     @index += 1
  723.     draw_item(item, n)
  724.   end
  725.   #--------------------------------------------------------------------------
  726.   # ● 清除物品
  727.   #--------------------------------------------------------------------------
  728.   def clear
  729.     @equip = nil
  730.     @items = {}
  731.     @index = -1
  732.     self.contents.clear
  733.     self.contents.font.color = system_color
  734.     self.contents.draw_text(0,0,self.contents.width-16,WLH,"请放入升级装备:")
  735.     self.contents.draw_text(0,WLH*2,self.contents.width-16,WLH,"请放入炼制物品:")
  736.   end
  737.   #--------------------------------------------------------------------------
  738.   # ● 归还物品
  739.   #--------------------------------------------------------------------------
  740.   def revert
  741.     $game_party.gain_item(@equip, 1)
  742.     @items.each{|i,n| $game_party.gain_item(i, n)}
  743.     clear
  744.   end
  745.   #--------------------------------------------------------------------------
  746.   # ● 描绘项目
  747.   #     index : 项目编号
  748.   #--------------------------------------------------------------------------
  749.   def draw_item(item, n)
  750.     rect = Rect.new(4,WLH+WLH*@index,self.contents.width-8, WLH)
  751.     rect.y += WLH if @index >0
  752.     ##self.contents.clear_rect(rect)
  753.     if item != nil
  754.       ##rect.width -= 4
  755.       draw_item_name(item, rect.x, rect.y)
  756.       self.contents.draw_text(rect, sprintf(":%2d", n), 2)
  757.     end
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # ● 更新帮助文本
  761.   #--------------------------------------------------------------------------
  762.   def update_help
  763.     @help_window.set_text(item == nil ? "" : item.description)
  764.   end
  765. end
  766.  
  767. #==============================================================================
  768. # ■ Window_EquipNumber
  769. #==============================================================================
  770. class Window_EquipNumber < Window_Base
  771.   #--------------------------------------------------------------------------
  772.   # ● 初始化对象
  773.   #     x : 窗口的 X 坐标
  774.   #     y : 窗口的 Y 坐标
  775.   #--------------------------------------------------------------------------
  776.   def initialize(x, y)
  777.     super(x, y, 272, 304)
  778.     @item = nil
  779.     [url=home.php?mod=space&uid=25307]@Max[/url] = 1
  780.     [url=home.php?mod=space&uid=27178]@Number[/url] = 1
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 设置物品、最大个数
  784.   #--------------------------------------------------------------------------
  785.   def set(item, max)
  786.     @item = item
  787.     [url=home.php?mod=space&uid=25307]@Max[/url] = max
  788.     [url=home.php?mod=space&uid=27178]@Number[/url] = 1
  789.     refresh
  790.   end
  791.   #--------------------------------------------------------------------------
  792.   # ● 设置输入个数
  793.   #--------------------------------------------------------------------------
  794.   def number
  795.     return @number
  796.   end
  797.   #--------------------------------------------------------------------------
  798.   # ● 刷新
  799.   #--------------------------------------------------------------------------
  800.   def refresh
  801.     y = 96
  802.     self.contents.clear
  803.     draw_item_name(@item, 0, y)
  804.     self.contents.font.color = normal_color
  805.     self.contents.draw_text(212-32, y, 20, WLH, "×")
  806.     self.contents.draw_text(248-32, y, 20, WLH, @number, 2)
  807.     self.cursor_rect.set(244-32, y, 28, WLH)
  808.   end
  809.   #--------------------------------------------------------------------------
  810.   # ● 更新画面
  811.   #--------------------------------------------------------------------------
  812.   def update
  813.     super
  814.     if self.active
  815.       last_number = @number
  816.       if Input.repeat?(Input::RIGHT) and [url=home.php?mod=space&uid=27178]@Number[/url] < @max
  817.         @number += 1
  818.       end
  819.       if Input.repeat?(Input::LEFT) and @number > 1
  820.         @number -= 1
  821.       end
  822.       if Input.repeat?(Input::UP) and @number < @max
  823.         @number = [@number + 10, @max].min
  824.       end
  825.       if Input.repeat?(Input::DOWN) and @number > 1
  826.         @number = [@number - 10, 1].max
  827.       end
  828.       if @number != last_number
  829.         Sound.play_cursor
  830.         refresh
  831.       end
  832.     end
  833.   end
  834. end
  835.  
  836. #==============================================================================
  837. # ■ Scene_UpEquip
  838. #==============================================================================
  839. class Scene_UpEquip < Scene_Base
  840.   include Game_Equip
  841.   #--------------------------------------------------------------------------
  842.   # ● 开始处理
  843.   #--------------------------------------------------------------------------
  844.   def start
  845.     super
  846.     create_menu_background
  847.     create_command_window
  848.     @help_window = Window_Help.new
  849.     @gold_window = Window_Gold.new(96+16, 56)
  850.     @gold_window.opacity = 0
  851.     @scr_window = Window_ScrEquip.new(0,112,272,304)
  852.     @scr_window.active = true
  853.     @scr_window.help_window = @help_window
  854.     @dest_window = Window_DestEquip.new(272,56,272,304+56)
  855.     @number_window = Window_EquipNumber.new(0, 112)
  856.     @number_window.active = false
  857.     @number_window.visible = false
  858.     @result_window = Window_Base.new(56,56,384,80)
  859.     @result_window.active = false
  860.     @result_window.visible = false
  861.   end
  862.   #--------------------------------------------------------------------------
  863.   # ● 结束处理
  864.   #--------------------------------------------------------------------------
  865.   def terminate
  866.     super
  867.     dispose_menu_background
  868.     dispose_command_window
  869.     @help_window.dispose
  870.     @gold_window.dispose
  871.     @scr_window.dispose
  872.     @dest_window.dispose
  873.     @number_window.dispose
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # ● 更新画面
  877.   #--------------------------------------------------------------------------
  878.   def update
  879.     super
  880.     update_menu_background
  881.     @help_window.update
  882.     @command_window.update
  883.     @gold_window.update
  884.     @scr_window.update
  885.     @dest_window.update
  886.     @number_window.update
  887.     if @command_window.active
  888.       @scr_window.contents_opacity = 128
  889.       @command_window.contents_opacity = 255
  890.       update_command_selection
  891.     elsif @scr_window.active
  892.       @scr_window.contents_opacity = 255
  893.       @command_window.contents_opacity = 128
  894.       update_item_selection
  895.     elsif @number_window.active
  896.       update_number_input
  897.     elsif @result_window.active
  898.       update_result_window
  899.     end
  900.   end
  901.   #--------------------------------------------------------------------------
  902.   # ● 生成指令窗口
  903.   #--------------------------------------------------------------------------
  904.   def create_command_window
  905.     s1 = "升级"
  906.     s2 = "退出"
  907.     @command_window = Window_Command.new(272, [s1, s2], 4, 0, 8)
  908.     @command_window.y = 56
  909.     @command_window.active = false
  910.     @command_window.contents_opacity = 128
  911.   end
  912.   #--------------------------------------------------------------------------
  913.   # ● 释放指令窗口
  914.   #--------------------------------------------------------------------------
  915.   def dispose_command_window
  916.     @command_window.dispose
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ● 是否满足装备升级条件?
  920.   #--------------------------------------------------------------------------
  921.   def upgradeable?(equip)
  922.     return false if equip.nil?
  923.     if equip.is_a?(RPG::Weapon) || equip.is_a?(RPG::Armor) and equip.level.nil?
  924.       equip.level = 1
  925.     end
  926.     price = (equip.price * (GoldNeed ** equip.level)).round
  927.     return false if $game_party.gold < price
  928.     ItemsNeed.each do |id,n|
  929.       return false if @dest_window.items[$data_items[id]].nil?
  930.       return false if @dest_window.items[$data_items[id]] < n
  931.     end
  932.     ## 扣钱
  933.     $game_party.lose_gold(price)
  934.     return true
  935.   end
  936.   #--------------------------------------------------------------------------
  937.   # ● 显示结果(包括处理金钱物品)
  938.   #--------------------------------------------------------------------------
  939.   def show_result
  940.     @result_window.active = true
  941.     @result_window.visible = true
  942.     ###@scr_window.refresh
  943.     unless upgradeable?(@dest_window.equip)
  944.       @result_window.contents.clear
  945.       @result_window.contents.draw_text(0,0,352,24,"材料或金钱不足!", 1)
  946.       @result_window.contents.draw_text(0,24,352,24,"物品已自动归还.", 1)
  947.       @dest_window.revert
  948.       Sound.play_actor_collapse
  949.       ## 直接返回
  950.       return
  951.     end
  952.     msg = Game_Equip.upgrade(@dest_window.equip)
  953.     case msg
  954.     when RPG::Weapon
  955.       s = "攻击力提升到(#{msg.atk})"
  956.       @result_window.contents.clear
  957.       @result_window.contents.draw_text(0, 0, 352, 24, "#{msg.name}升级成功!")
  958.       @result_window.contents.draw_text(4, 24, 352-4, 24, s)
  959.       $game_party.gain_item(msg, 1)
  960.       Sound.play_shop
  961.     when RPG::Armor
  962.       s = "防御力提升到(#{msg.def})"
  963.       @result_window.contents.clear
  964.       @result_window.contents.draw_text(0, 0, 352, 24, "#{msg.name}升级成功!")
  965.       @result_window.contents.draw_text(4, 24, 352-4, 24, s)
  966.       $game_party.gain_item(msg, 1)
  967.       Sound.play_shop
  968.     else
  969.       @result_window.contents.clear
  970.       @result_window.contents.draw_text(0,0,352,24,"升级失败, 物品已损坏!", 1)
  971.       Sound.play_actor_collapse
  972.     end
  973.     @dest_window.clear
  974.   end
  975.   #--------------------------------------------------------------------------
  976.   # ● 更新帮助文本
  977.   #--------------------------------------------------------------------------
  978.   def update_help(text)
  979.     @help_window.set_text(text)
  980.   end  
  981.   #--------------------------------------------------------------------------
  982.   # ● 更新指令窗口
  983.   #--------------------------------------------------------------------------
  984.   def update_command_selection
  985.     case @command_window.index
  986.     when 0
  987.       update_help("确定键执行装备升级")
  988.     when 1
  989.       update_help("退出升级界面")
  990.     end
  991.     if Input.trigger?(Input::B)
  992.       ## 重来
  993.       Sound.play_cancel
  994.       @scr_window.active = true
  995.       @command_window.active = false
  996.     elsif Input.trigger?(Input::C)
  997.       case @command_window.index
  998.       when 0  # 升级
  999.         Sound.play_decision
  1000.         @command_window.active = false
  1001.         @scr_window.active = false
  1002.         ######### 显示升级结果,归还物品
  1003.         show_result
  1004.       when 1  # 退出
  1005.         Sound.play_decision
  1006.         @dest_window.revert
  1007.         $scene = Scene_Map.new
  1008.       end
  1009.     end
  1010.   end
  1011.   #--------------------------------------------------------------------------
  1012.   # ● 更新选择物品
  1013.   #--------------------------------------------------------------------------
  1014.   def update_item_selection
  1015.     if Input.trigger?(Input::B)
  1016.       Sound.play_cancel
  1017.       @command_window.active = true
  1018.       @scr_window.active = false
  1019.       ###@help_window.set_text("")
  1020.       return
  1021.     end
  1022.     if Input.trigger?(Input::C)
  1023.       @item = @scr_window.item
  1024.       number = $game_party.item_number(@item)
  1025.       if @item == nil or number == 0
  1026.         Sound.play_buzzer
  1027.       else
  1028.         Sound.play_decision
  1029.         ##### 传递物品给容器栏
  1030.         if number > 1
  1031.           @scr_window.active = false
  1032.           @number_window.set(@item, number)
  1033.           @number_window.active = true
  1034.           @number_window.visible = true
  1035.         else
  1036.           Sound.play_shop
  1037.           @dest_window.add(@scr_window.item, 1)
  1038.           @scr_window.equip_only = false
  1039.           @scr_window.refresh
  1040.         end
  1041.       end
  1042.     end
  1043.   end
  1044.   #--------------------------------------------------------------------------
  1045.   # ● 更新输入个数
  1046.   #--------------------------------------------------------------------------
  1047.   def update_number_input
  1048.     if Input.trigger?(Input::B)
  1049.       cancel_number_input
  1050.     elsif Input.trigger?(Input::C)
  1051.       decide_number_input
  1052.     end
  1053.   end
  1054.   #--------------------------------------------------------------------------
  1055.   # ● 更新结果窗体
  1056.   #--------------------------------------------------------------------------
  1057.   def update_result_window
  1058.     if Input.trigger?(Input::B) or Input.trigger?(Input::C)
  1059.       Sound.play_decision
  1060.       @scr_window.equip_only = true
  1061.       @scr_window.refresh
  1062.       @scr_window.active = true
  1063.       @result_window.active = false
  1064.       @result_window.visible = false
  1065.     end
  1066.   end
  1067.   #--------------------------------------------------------------------------
  1068.   # ● 取消输入个数
  1069.   #--------------------------------------------------------------------------
  1070.   def cancel_number_input
  1071.     Sound.play_cancel
  1072.     @number_window.active = false
  1073.     @number_window.visible = false
  1074.     @scr_window.active = true
  1075.     @scr_window.visible = true
  1076.   end
  1077.   #--------------------------------------------------------------------------
  1078.   # ● 确定输入个数
  1079.   #--------------------------------------------------------------------------
  1080.   def decide_number_input
  1081.     Sound.play_shop
  1082.     @number_window.active = false
  1083.     @number_window.visible = false
  1084.     @dest_window.add(@item, @number_window.number)
  1085.     @scr_window.equip_only = false
  1086.     @scr_window.refresh
  1087.     @scr_window.active = true
  1088.   end
  1089. end
  1090.  
  1091. #==============================================================================
  1092. # ■ Scene_File
  1093. #==============================================================================
  1094. class Scene_File < Scene_Base
  1095.   #--------------------------------------------------------------------------
  1096.   # ● 写入存档数据
  1097.   #     file : 写入文件用对象 (已经打开)
  1098.   #--------------------------------------------------------------------------
  1099.   def write_save_data(file)
  1100.     characters = []
  1101.     for actor in $game_party.members
  1102.       characters.push([actor.character_name, actor.character_index])
  1103.     end
  1104.     $game_system.save_count += 1
  1105.     $game_system.version_id = $data_system.version_id
  1106.     @last_bgm = RPG::BGM::last
  1107.     @last_bgs = RPG::BGS::last
  1108.     Marshal.dump(characters,           file)
  1109.     Marshal.dump(Graphics.frame_count, file)
  1110.     Marshal.dump(@last_bgm,            file)
  1111.     Marshal.dump(@last_bgs,            file)
  1112.     Marshal.dump($game_system,         file)
  1113.     Marshal.dump($game_message,        file)
  1114.     Marshal.dump($game_switches,       file)
  1115.     Marshal.dump($game_variables,      file)
  1116.     Marshal.dump($game_self_switches,  file)
  1117.     Marshal.dump($game_actors,         file)
  1118.     Marshal.dump($game_party,          file)
  1119.     Marshal.dump($game_troop,          file)
  1120.     Marshal.dump($game_map,            file)
  1121.     Marshal.dump($game_player,         file)
  1122.     Marshal.dump($data_weapons,        file)
  1123.     Marshal.dump($data_armors,         file)
  1124.   end
  1125.   #--------------------------------------------------------------------------
  1126.   # ● 读取存档数据
  1127.   #     file : 读取文件用对象 (已经打开)
  1128.   #--------------------------------------------------------------------------
  1129.   def read_save_data(file)
  1130.     characters           = Marshal.load(file)
  1131.     Graphics.frame_count = Marshal.load(file)
  1132.     @last_bgm            = Marshal.load(file)
  1133.     @last_bgs            = Marshal.load(file)
  1134.     $game_system         = Marshal.load(file)
  1135.     $game_message        = Marshal.load(file)
  1136.     $game_switches       = Marshal.load(file)
  1137.     $game_variables      = Marshal.load(file)
  1138.     $game_self_switches  = Marshal.load(file)
  1139.     $game_actors         = Marshal.load(file)
  1140.     $game_party          = Marshal.load(file)
  1141.     $game_troop          = Marshal.load(file)
  1142.     $game_map            = Marshal.load(file)
  1143.     $game_player         = Marshal.load(file)
  1144.     $data_weapons        = Marshal.load(file)
  1145.     $data_armors         = Marshal.load(file)
  1146.     if $game_system.version_id != $data_system.version_id
  1147.       $game_map.setup($game_map.map_id)
  1148.       $game_player.center($game_player.x, $game_player.y)
  1149.     end
  1150.   end
  1151. end
  1152.  
  1153. #==============================================================================
  1154. # ■ Scene_Shop
  1155. #==============================================================================
  1156. class Scene_Shop < Scene_Base
  1157.   #--------------------------------------------------------------------------
  1158.   # ● 确定输入个数
  1159.   #--------------------------------------------------------------------------
  1160.   def decide_number_input
  1161.     Sound.play_shop
  1162.     @number_window.active = false
  1163.     @number_window.visible = false
  1164.     case @command_window.index
  1165.     when 0  # 购买
  1166.       $game_party.lose_gold(@number_window.number * @item.price)
  1167.       $game_party.gain_reini_item(@item, @number_window.number)
  1168.       @gold_window.refresh
  1169.       @buy_window.refresh
  1170.       @status_window.refresh
  1171.       @buy_window.active = true
  1172.       @buy_window.visible = true
  1173.     when 1  # 卖出
  1174.       $game_party.gain_gold(@number_window.number * (@item.price / 2))
  1175.       $game_party.lose_reini_item(@item, @number_window.number)
  1176.       @gold_window.refresh
  1177.       @sell_window.refresh
  1178.       @status_window.refresh
  1179.       @sell_window.active = true
  1180.       @sell_window.visible = true
  1181.       @status_window.visible = false
  1182.     end
  1183.   end
  1184. end
  1185.  
  1186. #==============================================================================
  1187. # ■ Scene_Title
  1188. #==============================================================================
  1189. class Scene_Title < Scene_Base
  1190.   #--------------------------------------------------------------------------
  1191.   # ● 载入数据库
  1192.   #--------------------------------------------------------------------------
  1193.   def load_database
  1194.     $data_actors        = load_data("Data/Actors.rvdata")
  1195.     $data_classes       = load_data("Data/Classes.rvdata")
  1196.     $data_skills        = load_data("Data/Skills.rvdata")
  1197.     $data_items         = load_data("Data/Items.rvdata")
  1198.     $base_weapons       = load_data("Data/Weapons.rvdata")
  1199.     $base_armors        = load_data("Data/Armors.rvdata")
  1200.     $data_enemies       = load_data("Data/Enemies.rvdata")
  1201.     $data_troops        = load_data("Data/Troops.rvdata")
  1202.     $data_states        = load_data("Data/States.rvdata")
  1203.     $data_animations    = load_data("Data/Animations.rvdata")
  1204.     $data_common_events = load_data("Data/CommonEvents.rvdata")
  1205.     $data_system        = load_data("Data/System.rvdata")
  1206.     $data_areas         = load_data("Data/Areas.rvdata")
  1207.     $data_weapons       = [nil]
  1208.     $data_armors        = [nil]
  1209.   end
  1210.   #--------------------------------------------------------------------------
  1211.   # ● 载入战斗测试用的数据库
  1212.   #--------------------------------------------------------------------------
  1213.   def load_bt_database
  1214.     $data_actors        = load_data("Data/BT_Actors.rvdata")
  1215.     $data_classes       = load_data("Data/BT_Classes.rvdata")
  1216.     $data_skills        = load_data("Data/BT_Skills.rvdata")
  1217.     $data_items         = load_data("Data/BT_Items.rvdata")
  1218.     $data_weapons       = load_data("Data/BT_Weapons.rvdata")
  1219.     $data_armors        = load_data("Data/BT_Armors.rvdata")
  1220.     $data_enemies       = load_data("Data/BT_Enemies.rvdata")
  1221.     $data_troops        = load_data("Data/BT_Troops.rvdata")
  1222.     $data_states        = load_data("Data/BT_States.rvdata")
  1223.     $data_animations    = load_data("Data/BT_Animations.rvdata")
  1224.     $data_common_events = load_data("Data/BT_CommonEvents.rvdata")
  1225.     $data_system        = load_data("Data/BT_System.rvdata")
  1226.     $base_weapons       = $data_weapons
  1227.     $base_armors        = $data_armors
  1228.   end
  1229. end
   

QQ图片20130604133100.jpg (15.92 KB, 下载次数: 8)

道具店对话出错

道具店对话出错

170452xsbkk2x82snzom3t.jpg (59.05 KB, 下载次数: 3)

玛雅宝石是强化材料,但是药水和老鼠不是

玛雅宝石是强化材料,但是药水和老鼠不是
第一个游戏《神马传说》完成度:
策划:★★★★★★★★★★ 100%
素材:★★★★★★★★★★ 100%
脚本:★★★★★★★★★★ 100%
数据库:★★★★★★★★★★ 100%
剧情:★★★★★★★★★★ 100%
BUG修复:★★★★★★★★★★ 100%
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-10-2 06:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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