查看: 2220|回复: 3

[已经解决] 强化系统报错!

[复制链接]
梦石
0
星屑
4992
在线时间
1151 小时
注册时间
2014-5-9
回帖
124
发表于 2015-6-20 10:37:56 | 显示全部楼层 |阅读模式

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

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

×
所有东西都设置了好了     强化时出现这个字样:

报错

报错

以下是强化系统脚本:
[pre lang="ruby"]=begin
==============================================================================
  MESS 1.00 (全称:Make Equips Stornger System)
-----------------------------------------------------------------------------
  装备强化系统 1.00 by 804173948
==============================================================================
  与其他大部分强化系统的区别:
  
    (并没有针对某些强化系统、不过按自己的喜好选择吧)
   
    1.增加属性方面
      大部分强化系统强化装备时增加的属性都是用特定公式计算的,
      这个可直接在数据库里面自己设定好每一个属性,不用被公式束缚、
      另外还有一个好处是,因为是数据库里面的装备,
      所以打怪也可以直接在数据库里设定掉落这些被强化的装备
   
    2.强化成功率和所需金钱方面
      很多强化系统都是固定的一个值或几个值,
      本脚本可以直接在数据库里设定、不同装备强化成功率以及所需金钱都不同
   
    3.所需物品方面
      本强化系统可以用多个物品强化一个装备,
      强化每一个装备所需的物品都可以自行设定,
      (打个比方、比如说要强化一个红宝石做的项链、自然要用[红宝石]来强化它;
      但是一个绿宝石做的项链、却用[红宝石]来强化、就会觉得很怪、所以本人觉得
      强化每一个装备所需的物品都可以自行设定 更合理)
      
    4.物品槽
      (个人感觉更像合成系统之类的、、、)
      
  使用说明:
  
    装备:
   
      1.使装备能够强化:
          在备注上加上 [Strongable 强化后的ID]
         
          如:一个武器在备注加上[Strongable 100]
          强化成功后就获得一个 第100号武器
         
      2.强化成功率:
          在备注上加上 [Rate 成功率]
          成功率是0~100之间
         
      3.强化所需金钱:
          在备注上加上 [Gold 数值]
         
      4.强化所需物品:
          在备注上加上 [item n 物品[n]ID]
          n 代表所需的第 n 个物品
         
          如:一个武器需要 第10号物品2个,30号物品一个
          就在备注上加上 [item 1 10]
                        [item 2 10]
                        [item 3 30]
          详细的就直接看范例的数据库里吧、
        
    物品:
   
      1.能够增加成功率:
          在备注上加上 [RateUP 成功率]
          成功率最好是0~100之间
          注意、所谓成功率不是直接加在装备成功率上
          、、比如说、强化一个成功几率为 60% 的装备、使用能够提升 20% 成功率的物品
          成功率不是变为 80,而是 72 ,72 = 60*(1+20%)
      
      2.能够防止装备随坏:
          在备注上加上 [Prevent]
         
    界面:
   
      1.物品装备栏:
          位于左方,选取物品和装备进行强化
      2.物品信息栏:
          中间最大的那个,显示装备物品信息和强化信息
      3.所需物品提示:
          中下方,显示强化某装备必须品
      4.物品槽:
          右下角,选定准备进行强化的物品
      
      ※5.提示框(最最重要的又是最最最容易被人忽略的):
          左上方,提示你接下来要做什么、、、
         
  ※注意事项:
      
    1.此脚本要与“装备帮助增强”脚本共用
    (“装备帮助增强”脚本我改动了、具体行数是 123 行到 133 行,
      请复制到你的工程同一位置中)
      
    2.不知道、、、
  
  BUG、冲突:
  
    暂无- -、
  
  友情提示:
    最好把窗口分辨率调到最大、、、
      
  
=end
module MESS
  # 能够强化的标志
  CanAugmentFlag = "Strongable"
  # 强化成功的几率
  SuccessfulAugmentRate = "Rate"
  # 强化所需物品
  UseItemForAugment = "Item"
  # 强化所需金钱
  MoneyForAugment = "Gold"
  # 增加强化成功率的物品(0~100)
  CanRateUP = "RateUP"
  # 强化失败能避免原装备损坏的标志
  PreventLost = "Prevent"
  # 强化所需物品最大值
  MaxItemUse = 5
end
class Scene_MESS < Scene_ItemBase
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_text_help_window
    create_item_status_window
    create_item_window
    create_augment_setting_window
    create_item_slot_window
  end
  #--------------------------------------------------------------------------
  # ● 生成文字提示窗口
  #--------------------------------------------------------------------------
  def create_text_help_window
    @text_help_window = Window_Help.new(1)
    @text_help_window.width = 256
    @text_help_window.set_text("选择装备进行强化")
  end
  #--------------------------------------------------------------------------
  # ● 生成物品窗口
  #--------------------------------------------------------------------------
  def create_item_window
    wy = @text_help_window.y + @text_help_window.height
    ww = @text_help_window.width
    wh = Graphics.height - wy
    @item_window = Window_EquipList.new(0, wy, ww, wh)
    @item_window.viewport = @viewport
    @item_window.help_window = @item_status_window
    @item_window.set_handler(:ok    , method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
  end
  #--------------------------------------------------------------------------
  # ● 生成物品状态窗口
  #--------------------------------------------------------------------------
  def create_item_status_window
    wx = @text_help_window.width
    wy = 0
    ww = Graphics.width - wx
    wh = Graphics.height / 3 * 2
    @item_status_window = Window_EquipStatus2.new(wx, wy, ww, wh)
    @item_status_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 生成强化设定窗口(中下窗口)
  #--------------------------------------------------------------------------
  def create_augment_setting_window
    wx = @text_help_window.width
    wy = @item_status_window.height
    ww = (Graphics.width - wx)/2
    wh = Graphics.height - wy
    @augment_setting_window = Window_AugmentSet.new(wx, wy, ww, wh)
    @augment_setting_window.viewport = @viewport
    @item_status_window.relation_window = @augment_setting_window
  end
  #--------------------------------------------------------------------------
  # ● 生成物品槽
  #--------------------------------------------------------------------------
  def create_item_slot_window
    wx = @augment_setting_window.x + @augment_setting_window.width
    wy = @augment_setting_window.y
    ww = Graphics.width - wx
    wh = Graphics.height - wy
    @slot_window = Window_ItemSlot.new(wx, wy, ww, wh)
    @slot_window.viewport = @viewport
    @slot_window.help_window = @item_status_window
    @slot_window.set_handler(:ok    , method(:on_slot_ok))
    @slot_window.set_handler(:cancel, method(:on_slot_cancel))
    @item_window.index = 0
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 生成警示窗口
  #--------------------------------------------------------------------------
  def create_warn_window
    ww = Graphics.width / 4 * 3
    wx = (Graphics.width - ww) / 2
    wy = 80
    @warn_window = Window_Help.new(1)
    @warn_window.x = wx
    @warn_window.y = wy
    @warn_window.width = ww
    @warn_window.viewport = @viewport
    @warn_window.hide
  end
  #--------------------------------------------------------------------------
  # ● 物品“确定”
  #--------------------------------------------------------------------------
  def on_item_ok
    if @item_window.item
      if @item_window.itemtype == :equip
        @item_window.equip = @item_status_window.equip
        @text_help_window.set_text("选择物品进行强化")
        @item_window.itemtype = :item
        @item_window.refresh
        @item_window.index = 0
        @item_window.activate
      elsif @item_window.itemtype == :item
        @text_help_window.set_text("选择物品槽放置物品")
        @slot_window.index = 0 if @slot_window.index < 0
        @slot_window.activate
      end
    else
      on_item_change
    end
  end
  #--------------------------------------------------------------------------
  # ● 物品“取消”
  #--------------------------------------------------------------------------
  def on_item_cancel(augmenting = false)
    if @item_window.itemtype == :item
      if @slot_window.data != [] && augmenting == false
        MESS::MaxItemUse.times {|i| $game_party.gain_item(@slot_window.data,1) if @slot_window.data}
        MESS::MaxItemUse.times {|i| @slot_window.remove_item(i)}
      end
      @item_window.equip = nil
      @text_help_window.set_text("选择装备进行强化")
      @item_window.itemtype = :equip
      @item_window.refresh
      @item_window.index = 0
      @item_status_window.clear(true) if augmenting
      @item_window.activate
    elsif @item_window.itemtype == :equip
      SceneManager.return
    end
  end
  #--------------------------------------------------------------------------
  # ● 装备栏“确定”
  #--------------------------------------------------------------------------
  def on_slot_ok
    if @slot_window.item != :augment
      if @item_window.windowstatus == :owner
        @text_help_window.set_text("选择物品进行强化")
        @augment_setting_window.set_item(@item_status_window.equip)
        item = @item_window.item
        if item.porveup > 0
          rate = @item_status_window.basic_rate.to_f
          rate *= item.porveup/100.0
          rate *= 10
          rate.round
          rate /= 10.0
          @item_status_window.rate = @item_status_window.rate + rate
        end
        item = @slot_window.item
        if item
          if item.porveup > 0
            rate = @item_status_window.basic_rate.to_f
            rate *= item.porveup/100.0
            rate *= 10
            rate.round
            rate /= 10.0
            @item_status_window.rate = @item_status_window.rate - rate
          end
        end
        $game_party.lose_item(@item_window.item,1)
        $game_party.gain_item(@slot_window.item,1) if @slot_window.item
        @slot_window.set_item(@item_window.item,@slot_window.index)
        @item_status_window.refresh_aug_status
        @item_window.refresh
        @item_window.activate
      elsif @item_window.windowstatus == :given
        item = @slot_window.item
        if item
          if item.porveup > 0
            rate = @item_status_window.basic_rate.to_f
            rate *= item.porveup/100.0
            rate *= 10
            rate.round
            rate /= 10.0
            @item_status_window.rate = @item_status_window.rate - rate
          end
          $game_party.gain_item(item,1)
          @slot_window.remove_item(@slot_window.index)
        end
        @item_status_window.refresh_aug_status
        @item_window.refresh
        @slot_window.activate
      end
    else
      @text_help_window.set_text("正在进行强化中...")
      augment
    end
  end
  #--------------------------------------------------------------------------
  # ● 装备栏“取消”
  #--------------------------------------------------------------------------
  def on_slot_cancel
    if @item_window.windowstatus == :owner
      @text_help_window.set_text("选择物品进行强化")
      @item_window.refresh
      @item_window.activate
    elsif @item_window.windowstatus == :given
      on_slot_change
    end
  end
  
  def augment
    create_warn_window
    equip = @item_status_window.equip
    if equip
      rate = @item_status_window.rate
      gold = @item_status_window.gold
      item = @slot_window.data.select {|item| item != :augment && item }
      needitem = []
      MESS::MaxItemUse.times {|i| needitem.push($data_items[equip.strongitem(i+1)]) if equip.strongitem(i+1) > 0}
      # 检查必需品
      needcount = 0
      for i in 0 ... needitem.size
        if item.include?(needitem)
          needcount += 1
          for a in 0 ... item.size
            if item[a] == needitem
              item.delete_at(a)
              break
            end
          end
        end
      end
#~       needitem.size.times{|i| item.delete(needitem) if item.include?(needitem)}
      if needcount >= needitem.size
        if $game_party.gold >= gold
          $game_party.lose_gold(gold)
          $game_party.lose_item(equip,1)
          rand = rand(100)
          if rand <= rate
            new_item = nil
            if equip.is_a?(RPG::Weapon)
              new_item = $data_weapons[equip.strongto]
            elsif equip.is_a?(RPG::Armor)
              new_item = $data_armors[equip.strongto]
            end
            $game_party.gain_item(new_item,1)
            BattleManager.play_battle_end_me
            @warn_window.show
            @warn_window.set_text("恭喜!装备强化到了" + new_item.name + "!")
            Graphics.wait(60)
            @warn_window.hide
            @slot_window.clear
            @slot_window.refresh
            on_slot_cancel
            on_item_cancel(true)
          else
            prevent = false
            for i in 0 ... item.size
              if item.prevent?
                prevent = true
                break
              end
            end
            if !prevent
              $data_system.gameover_me.play
              @warn_window.show
              @warn_window.set_text("很遗憾,强化失败,装备消失")
              Graphics.wait(60)
              @warn_window.hide
              @slot_window.clear
              @slot_window.refresh
              on_slot_cancel
              on_item_cancel(true)
            else
              $game_party.gain_item(equip,1)
              $data_system.gameover_me.play
              @warn_window.show
              @warn_window.set_text("强化失败,使用特殊道具,装备保留")
              Graphics.wait(60)
              @warn_window.hide
              @slot_window.clear
              @slot_window.refresh
              on_slot_cancel
              on_item_cancel(true)
            end
          end
        else
          Sound.play_buzzer
          @warn_window.show
          @warn_window.set_text("没有足够金钱")
          Graphics.wait(30)
          @warn_window.hide
          on_slot_cancel
        end
      else
        Sound.play_buzzer
        @warn_window.show
        @warn_window.set_text("没有足够物品")
        Graphics.wait(30)
        @warn_window.hide
        on_slot_cancel
      end
    else
      Sound.play_buzzer
      @warn_window.show
      @warn_window.set_text("没有选定装备")
      Graphics.wait(30)
      @warn_window.hide
      on_slot_cancel
    end
  end
  
  def on_item_change
    @text_help_window.set_text("移除物品槽物品")
    @item_window.windowstatus = :given
    @slot_window.refresh
    @slot_window.activate
  end
  
  def on_slot_change
    @text_help_window.set_text("选择物品进行强化")
    @item_window.windowstatus = :owner
    @slot_window.index = 0
    @item_window.refresh
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 播放使用物品声效
  #--------------------------------------------------------------------------
  def play_se_for_item
    Sound.play_use_item
  end
  #--------------------------------------------------------------------------
  # ● 使用物品
  #--------------------------------------------------------------------------
  def use_item
    super
    @item_window.redraw_current_item
  end
end

class Window_EquipList <  Window_ItemList
  attr_accessor       :equip
  attr_accessor       :itemtype
  attr_accessor       :windowstatus
  def initialize(x, y, width, height)
    super
    @data = []
    @equip = nil
    @itemtype = :equip
    @windowstatus = :owner
    refresh
  end
  def col_max
    return 1
  end
  def can_use?(id)
    for i in 1 .. MESS::MaxItemUse
      return true if @equip.strongitem(i) == id
    end
    return false
  end
  def include?(item,times = 0)
    if item
      case @itemtype
      when :equip
        if !item.is_a?(RPG::Item)
          item.strongto > 0
        else
          false
        end
      when :item
        if item.is_a?(RPG::Item)
          if times == 0
            can_use?(item.id)
          elsif times == 1
            item.prevent? || item.porveup > 0
          end
        else
          false
        end
      else
        false
      end
    else
      true
    end
  end
  def enable?(item)
    return true
  end
  def make_item_list
    @data = []
    case @itemtype
    when :equip
      @data = $game_party.all_items.select {|item| include?(item) }
    when :item
      2.times {|i| @data += $game_party.all_items.select{|item| include?(item,i) } }
    end
    @data.push(nil) if include?(nil)
  end
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, enable?(item))
      draw_item_number(rect, item)
    elsif index == @data.size - 1 && !item
      rect = item_rect(index)
      draw_text(rect.x, rect.y, self.width-(rect.x+update_padding)*2, line_height, "光标移到物品槽",1)
    end
  end
  def update_help
    @help_window.set_item(item)
  end
end
class Window_EquipStatus2 < Window_Base
  attr_reader       :equip
  attr_accessor     :relation_window  
  attr_accessor     :rate
  attr_accessor     :gold
  def initialize(x,y,w,h)
    super(x,y,w,h)
    @equip = nil
    @relation_window = nil   
    @rate = 0.0
    @gold = 0
  end  
  def basic_rate
    return @equip ? @equip.strongrate : nil
  end
  def item_rate
    return basic_rate ? (@rate - basic_rate).to_i : nil
  end
  def basic_gold
    return @equip ? @equip.strongmoney : nil
  end
  def draw_augment_status(x,y,width)
    if @equip
      contents.font.size -= 6
      contents.font.color = Color.new(128,255,128)
      rate = [@rate,100].min
      rate *= 10
      rate.round
      rate /= 10.0
      draw_text(x,y,width,line_height,"成功率:"+rate.to_s+" ( "+item_rate.to_s+" )%")
      contents.font.color = Color.new(255,255,128)
      draw_text(x,y+line_height,width,line_height,Vocab::currency_unit+" ×"+basic_gold.to_s)
      contents.font.size += 6
      contents.font.color = Color.new(255,255,255)
    end
  end
  
  def can_use?(id)
    for i in 1 .. MESS::MaxItemUse
      return true if @equip.strongitem(i) == id
    end
    return false
  end
  def clear(equip_nil = false)
    contents.clear
    @equip = nil if equip_nil
  end
  def draw_old_equip(x,y,width,item)
    change_color(system_color)
    draw_text(x, y, width,line_height,"原装备:")
    contents.font.color = Color.new(255,255,128)
    rect = Rect.new(x,y+line_height+4,width,24)
    draw_item_name(item, rect.x, rect.y)
    help = "\\c[6]" + Equipplus.getequiphelp(item)
    contents.font.size -= 8
    draw_text_ex(x,y+line_height+4+24+4,help,width,40,false)
    contents.font.size += 8
    change_color(normal_color)
  end
  def draw_new_equip(x,y,width,item)
    change_color(system_color)
    draw_text(x, y, width,line_height,"新装备:")
    contents.font.color = Color.new(128,255,128)
    rect = Rect.new(x,y+line_height+4,width,24)
    draw_item_name(item, rect.x, rect.y)
    help = "\\c[3]" + Equipplus.getequiphelp(item)
    contents.font.size -= 8
    draw_text_ex(x,y+line_height+4+24+4,help,width,40,false)
    contents.font.size += 8
  end
  def draw_item_effect(x,y,width,item)
    change_color(system_color)
    draw_text(x, y, width,line_height,"道具效果:")
    rect = Rect.new(x,y+line_height+4,width,24)
    draw_item_name(item, rect.x, rect.y)
    help = make_item_help(item)
    contents.font.size -= 4
    draw_text_ex(x,y+line_height+4+24+4,help,width,40,false)
    contents.font.size += 4
    change_color(normal_color)
  end
  def make_item_help(item)
    help = ""
    if item.porveup > 0
      help += "\\c[24]增加成功率:"+item.porveup.to_s+"% \n"
    end
    if item.prevent?
      help += "\\c[13]防止装备损坏 \n"
    end
    if can_use?(item.id)
      help += "\\c[2]必需品\n"
    end
    return help
  end  
  def set_item(item)
    contents.clear
    new_item = nil
    if item.is_a?(RPG::EquipItem)
      @equip = item
      @rate = basic_rate
      @gold = basic_gold
      set_relation_window
      draw_old_equip(4,0,(self.width-(4+update_padding)*2)/2,item)
    elsif item.is_a?(RPG::Item)         
      draw_item_effect(4,0,(self.width-(4+update_padding)*2)/2,item)
      refresh_aug_status if @rate > 0.0 && @gold > 0
    end
    if @equip.is_a?(RPG::Weapon)
        new_item = $data_weapons[@equip.strongto]
    elsif @equip.is_a?(RPG::Armor)
        new_item = $data_armors[@equip.strongto]
    end
    draw_new_equip(8+(self.width-(4+update_padding)*2)/2,0,(self.width-(4+update_padding)*2)/2,new_item) if new_item
  end
  def set_relation_window
    @relation_window.set_item(@equip) if @relation_window
  end
  def refresh_aug_status
    contents.clear_rect(4,self.height - line_height*3,(self.width-(4+update_padding)*2)/2,line_height*2)
    draw_augment_status(4,self.height - line_height*3,(self.width-(4+update_padding)*2)/2)
  end
end

class Window_AugmentSet < Window_Base
  def initialize(x,y,w,h)
    super(x,y,w,h)
    @equip = nil
  end
  def draw_equip_need(x,y,width,item)
    useable = []
    change_color(system_color)
    contents.font.size -= 2
    draw_text(x,y,width,line_height,"必需品")
    change_color(normal_color)
    for i in 1 .. MESS::MaxItemUse
      if @equip.strongitem(i) > 0
        useable.push($data_items[@equip.strongitem(i)])
        draw_item_name(useable[i-1], x, y+i*(line_height+2))
      end
    end
    contents.font.size += 2
  end
  def set_item(item)
    contents.clear
    if item
      @equip = item
      draw_equip_need(4,0,(self.width-(4+update_padding)*2)/2,item)
    end
  end
end
class Window_ItemSlot < Window_Selectable
  attr_reader       :data
  def initialize(x, y, width,height)
    super(x, y, width, height)
    @data = []
    refresh
  end
  def clear
    @data = []
  end
  def item_max
    return MESS::MaxItemUse + 1
  end
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  def set_item(item,id)
    @data[id] = item
    refresh
  end
  def remove_item(index)
    @data[index] = nil
    refresh
  end
  def draw_item(index)
    if index < MESS::MaxItemUse
      contents.font.size -= 2
      rect = item_rect_for_text(index)
      change_color(system_color, enable?(index))
      draw_text(rect.x, rect.y, 0, line_height, slot_name(index))
      draw_item_name(@data[index], rect.x + 0, rect.y, enable?(index)) if @data[index]
      change_color(normal_color)
      contents.font.size += 2
    elsif index == MESS::MaxItemUse
      rect = item_rect_for_text(index)
      draw_text(rect.x, rect.y, self.width-(rect.x+update_padding)*2, line_height, "强化装备",1)
      @data[index] = :augment
    end
  end
  def slot_name(index)
    return "空"+(index+1).to_s
  end
  def enable?(index)
    return true
  end
  def update_help
    super
    @help_window.set_item(item) if @help_window
  end
end
[/pre]

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2015-6-20 10:53:37 | 显示全部楼层
见脚本“注意事项”一
回复

使用道具 举报

梦石
0
星屑
4992
在线时间
1151 小时
注册时间
2014-5-9
回帖
124
 楼主| 发表于 2015-6-20 14:57:48 | 显示全部楼层
已自行解决问题!
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2015-6-20 17:36:16 | 显示全部楼层
a965645462 发表于 2015-6-19 21:57
已自行解决问题!

@VIPArcher @taroxd 问题解决
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部