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

Project1

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

[已经过期] 怎样设置装备强化系统里强化选项,不要只是增加攻击的

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2013-1-13
帖子
23
跳转到指定楼层
1
发表于 2013-1-16 21:36:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我想在武器强化的时候,可以强化出除了攻击意外的别的能力,现在是连强化法杖的魔法攻击都不会设置{:2_270:}
求大神们告诉我可以在哪里改变

下面是我用的武器强化脚本

#encoding:utf-8
#==============================================================================
# ■ 装备强化系统 By wyongcan
#==============================================================================
module Equipplus
#升到各级时装备颜色请在“颜色描绘”脚本中修改
$maxlv = 12  #最高升到的级数
$gailv = [100,80,70,60,50,30,20,10,5,5,5,5,1] #每级提升概率
$gemlv = [[60,23],[10,28],[25,29],[40,30]] #使用宝石提高的几率  [提高几率,宝石ID]
$uplv = [[12,24],[3,25],[6,26],[9,27]] #强化所需要的强化石 [最大强化到的等级,强化石ID]
$xxlv = [0,0,5,10,15,20,25,30,30,40,40,45,60] #每级强化后失败物品消失的几率
$jjlv = [0,10,15,20,30,45,55,65,70,70,75,80,100] #每级强化后失败物品降级的几率
$tsnl = [10,14,18,22,26,30,34,38,42,46,50,54,65] #每级强化提升能力的百分比
$tswp = [31,32] # 意思是:如果有31号物品则失败后物品不消失,如果有32号物品则失败后物品不降级
#武器强化后的计算公式为: 原攻击 * (1 + 提升能力百分比) + (0到当前强化级数随机) * 5 + 当前强化级数
$gemlv.sort!
$uplv.sort!
$当前使用宝石id = 0
$当前使用宝石加成率 = 0
$强化哈希表 = {
"最高等级" => $maxlv ,
"每级概率" => $gailv ,
"宝石效果" => $gemlv ,
"消失几率" => $xxlv  ,
"降级几率" => $jjlv  ,
"提升能力" => $tsnl  ,
"特殊物品" => $tswp  ,
"强化材料" => $uplv  }
def self.idlostitem(id,amount = 1)
  $game_party.lose_item(idgetitem(id),amount)
end

def self.idlostequip(id,weapon = true,amount = 1)
  weapon == true ? $game_party.lose_item($data_weapons[id],amount,true) : $game_party.lose_item($data_armors[id],amount,true)
end

def self.idgainequip(id,weapon = true,amount = 1)
  weapon == true ? $game_party.gain_item($data_weapons[id],amount,true) : $game_party.gain_item($data_armors[id],amount,true)
end

def self.idgetitem(id)
  $data_items[id]
end

def self.equipable?(id,weapon = true)
  weapon == true ? weaponupisnil(id) : armorupisnil(id)
  weapon == true ? equip = $data_weapons[id].dup : equip = $data_armors[id].dup
  price = equip.price
  @needmoney = price * equip.up
  if @needmoney == 0
    @needmoney = price / 2
  end
#循环取出需要的强化材料
  temp = false
  for i in $强化哈希表["强化材料"]
    if equip.up < i[0]
      @lostitem = idgetitem i[1]
      $game_party.has_item?(idgetitem(i[1])) ? temp = true : temp = false
      break
    end
  end
  $game_party.gold >= @needmoney && temp == true ? true : false
end

def self.upweapon (id)
  $message = ""
  success = false
  weaponupisnil(id)
  weapon = $data_weapons[id].dup
  gl = 0
  fangb = false
  fangj = false
  return unless weapon.up < $强化哈希表["最高等级"] && weaponupable?(id)
  loststh
  $message += "本次强化,共消耗:" + Vocab::currency_unit + " " + @needmoney.to_s
  $message += " " + @lostitem.name + "\n "
  gl = $强化哈希表["每级概率"][weapon.up]
  if $usegem == true
    gl += $当前使用宝石加成率
    idlostitem($当前使用宝石id)
    $message += idgetitem($当前使用宝石id).name + " "
  end
  if $fangb == true
    fangb = true
    idlostitem $强化哈希表["特殊物品"][0]
    $message += idgetitem($强化哈希表["特殊物品"][0]).name + " "
  end
  if $fangj == true
    fangj = true
    idlostitem $强化哈希表["特殊物品"][1]
    $message += idgetitem($强化哈希表["特殊物品"][1]).name + " "
  end
  suiji = rand (100)
  if suiji <= gl
    success = true
  end
  $message += "\n强化结果:"
  if success == true
    $message += "强化成功"
    idlostequip id
    weapon.id = $data_weapons.size
    params = weapon.params.dup
    params[2] *= 1 + $强化哈希表["提升能力"][weapon.up] / 100
    params[2] += rand(weapon.up) * 5 + weapon.up
    params[2] += 1 if params[2] == weapon.params[2]
    $message += " 攻击力提升:" + (params[2] - weapon.params[2]).to_int.to_s
    weapon.up += 1
    $data_weapons.insert $data_weapons.size,weapon
    $data_weapons[$data_weapons.size-1].params = params
    idgainequip weapon.id
  else
    $message += "强化失败"
    suiji = rand (100)
    if suiji <= $强化哈希表["消失几率"][weapon.up]
      if fangb != true
      $message += ",道具消失"
      idlostequip id
      else
      $message += ",由于" + idgetitem($强化哈希表["特殊物品"][0]).name + "的作用,道具未消失"
      end
    else
      suiji = rand (100)
      if suiji <= $强化哈希表["降级几率"][weapon.up]
        if fangj == false && weapon.up != 0
          $message += ",道具降级"
          params = weapon.params.dup
          params[2] -= weapon.up + rand(weapon.up) * 5
          params[2] /= 1 + $强化哈希表["提升能力"][weapon.up] / 100
          weapon.params = params
          weapon.up -= 1
          $data_weapons[id] = weapon
        else
          $message += ",由于" + idgetitem($强化哈希表["特殊物品"][1]).name + "的作用,道具未降级"
        end
      end
    end
  end
   $usegem = false
   $fangb = false
   $fangj = false
end

def self.weaponupisnil(id)
   $data_weapons[id].up = 0 unless $data_weapons[id].up != nil
end

def self.weaponupable?(id)
  equipable?(id)
end

def self.uparmor (id)
  $message = ""
  success = false
  armorupisnil(id)
  armor = $data_armors[id].dup
  gl = 0
  fangb = false
  fangj = false
  return unless armor.up < $强化哈希表["最高等级"] && armorupable?(id)
  loststh
  $message += "本次强化,共消耗:" + Vocab::currency_unit + " " + @needmoney.to_s
  $message += " " + @lostitem.name + "\n "
  gl = $强化哈希表["每级概率"][armor.up]
  if $usegem == true
    gl += $当前使用宝石加成率
    idlostitem($当前使用宝石id)
    $message += idgetitem($当前使用宝石id).name + " "
  end
  if $fangb == true
    fangb = true
    idlostitem $强化哈希表["特殊物品"][0]
    $message += idgetitem($强化哈希表["特殊物品"][0]).name + " "
  end
  if $fangj == true
    fangj = true
    idlostitem $强化哈希表["特殊物品"][1]
    $message += idgetitem($强化哈希表["特殊物品"][1]).name + " "
  end
  suiji = rand (100)
  if suiji <= gl
    success = true
  end
  $message += "\n强化结果:"
  if success == true
    $message += "强化成功"
    idlostequip id,false
    armor.id = $data_armors.size
    params = armor.params.dup
    params[3] *= 1 + $强化哈希表["提升能力"][armor.up] / 100
    params[3] += rand(armor.up) * 5 + armor.up
    params[3] += 1 if params[3] == armor.params[3]
    $message += " 防御力提升:" + (params[3] - armor.params[3]).to_int.to_s
    armor.up += 1
    $data_armors.insert $data_armors.size,armor
    $data_armors[$data_armors.size-1].params = params
    idgainequip armor.id,false
  else
    $message += "强化失败"
    suiji = rand (100)
    if suiji <= $强化哈希表["消失几率"][armor.up]
      if fangb != true
      $message += ",道具消失"
      idlostequip id,false
      else
      $message += ",由于" + idgetitem($强化哈希表["特殊物品"][0]).name + "的作用,道具未消失"
      end
    else
      suiji = rand (100)
      if suiji <= $强化哈希表["降级几率"][armor.up]
        if fangj == false && armor.up != 0
          $message += ",道具降级"
          params = armor.params.dup
          params[3] -= armor.up + rand(armor.up) * 5
          params[3] /= 1 + $强化哈希表["提升能力"][armor.up] / 100
          armor.params = params
          armor.up -= 1
          $data_armors[id] = armor
        else
          $message += ",由于" + idgetitem($强化哈希表["特殊物品"][1]).name + "的作用,道具未降级"
        end
      end
    end
  end
   $usegem = false
   $fangb = false
   $fangj = false
end

def self.armorupisnil(id)
   $data_armors[id].up = 0 unless $data_armors[id].up != nil
end
def self.armorupable?(id)
  equipable?(id,false)
end
def self.loststh()
   $game_party.lose_item(@lostitem,1)
   $game_party.lose_gold(@needmoney)
end
def self.needmoney
   @needmoney
end
def self.lostitem
   @lostitem
end
end
#==============================================================================
# ■ Scene_Qiang
#------------------------------------------------------------------------------
#  强化画面
#==============================================================================

class Scene_Qiang < Scene_MenuBase
  $wufang = true
  $usegem = false
  $fangb = false
  $fangj = false
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    @help_window.hide
    create_qianghelp_window
    create_command_window
    create_qiangxz_window
    create_wu_window
    create_fang_window
    create_choosegem_window
  end
  #--------------------------------------------------------------------------
  # ● 生成说明窗口
  #--------------------------------------------------------------------------
  def create_qianghelp_window
    @qianghelp_window = Window_Qianghelp.new
    @qianghelp_window.y = Graphics.height - @qianghelp_window.height
    @qianghelp_window.viewport = @viewport
    @qianghelp_window.hide
  end
  #--------------------------------------------------------------------------
  # ● 生成选择宝石
  #--------------------------------------------------------------------------
  def create_choosegem_window
    @choosegem_window = Window_Choosegem.new
    @choosegem_window.y = Graphics.height - @choosegem_window.height
    @choosegem_window.viewport = @viewport
    @choosegem_window.z = 120
  end
  #--------------------------------------------------------------------------
  # ● 生成选择窗口
  #--------------------------------------------------------------------------
  def create_qiangxz_window
    @qiangxz_window = Window_Qiangxz.new
    @qiangxz_window.y = @help_window.height + fitting_height(5) /2
    @qiangxz_window.z = 110
    @qiangxz_window.viewport = @viewport
    @qiangxz_window.set_handler(:gem,    method(:qiangxz_gem))
    @qiangxz_window.set_handler(:fangb,    method(:qiangxz_fangb))
    @qiangxz_window.set_handler(:fangj,    method(:qiangxz_fangj))
    @qiangxz_window.set_handler(:ok, method(:qiangxz_ok))
    @qiangxz_window.set_handler(:cancel, method(:qiangxz_cancel))
    @qiangxz_window.hide
    @qiangxz_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● 生成指令窗口
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_QiangCommand.new
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height + fitting_height(3) /2
    @command_window.set_handler(:qiangwu,    method(:qiangwu))
    @command_window.set_handler(:qiangfang,   method(:qiangfang))
    @command_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # ● 生成武器强化窗口
  #--------------------------------------------------------------------------
  def create_wu_window
    @wu_window = Window_Qiangwu.new(@qianghelp_window,@qiangxz_window)
    @wu_window.viewport = @viewport
    @wu_window.y += @help_window.height
    @wu_window.hide
    @wu_window.help_window= @help_window
    @wu_window.set_handler(:cancel, method(:qiangwu_cancel))
    @wu_window.set_handler(:ok,     method(:qiangwu_ok))
  end
  #--------------------------------------------------------------------------
  # ● 生成防具强化窗口
  #--------------------------------------------------------------------------
  def create_fang_window
    @fang_window = Window_Qiangfang.new(@qianghelp_window,@qiangxz_window)
    @fang_window.viewport = @viewport
    @fang_window.y += @help_window.height
    @fang_window.hide
    @fang_window.help_window= @help_window
    @fang_window.set_handler(:cancel, method(:qiangfang_cancel))
    @fang_window.set_handler(:ok,     method(:qiangfang_ok))
  end
  #--------------------------------------------------------------------------
  # ● 计算窗口显示指定行数时的应用高度
  #--------------------------------------------------------------------------
  def fitting_height(line_number)
    line_number * 24 + 12 * 2
  end
  #--------------------------------------------------------------------------
  # ● 显示强化武器
  #--------------------------------------------------------------------------
  def qiangwu
    @command_window.hide
    @help_window.show
    @wu_window.show
    @wu_window.start
    @qianghelp_window.show
    @wu_window.activate
    $wufang = true
    @command_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● 显示强化防具
  #--------------------------------------------------------------------------
  def qiangfang
    @command_window.hide
    @help_window.show
    @fang_window.show
    @fang_window.start
    @qianghelp_window.show
    @fang_window.activate
    $wufang = false
    @command_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● 取消强化武器
  #--------------------------------------------------------------------------
  def qiangwu_cancel
    @command_window.show
    @help_window.hide
    @wu_window.hide
    @qianghelp_window.hide
    @command_window.activate
    @qianghelp_window.set_text("")
    @help_window.set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 取消强化防具
  #--------------------------------------------------------------------------
  def qiangfang_cancel
    @command_window.show
    @help_window.hide
    @fang_window.hide
    @qianghelp_window.hide
    @command_window.activate
    @qianghelp_window.set_text("")
    @help_window.set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 确定强化武器
  #--------------------------------------------------------------------------
  def qiangwu_ok
    @help_window.hide
    @wu_window.qiangwu_ok
    @qiangxz_window.show
    @qiangxz_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 确定强化防具
  #--------------------------------------------------------------------------
  def qiangfang_ok
    @help_window.hide
    @fang_window.qiangfang_ok
    @qiangxz_window.show
    @qiangxz_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 获取卖出价格
  #--------------------------------------------------------------------------
  def selling_price
    @item.price / 2
  end
  
  def qiangxz_gem
    @choosegem_window.start
    @qiangxz_window.deactivate
    @choosegem_window.qiangxz= @qiangxz_window
    if $wufang == true
      @choosegem_window.wufangwindow= @wu_window
    else
      @choosegem_window.wufangwindow= @fang_window
    end
  end
  
  def qiangxz_fangb
    $fangb = !$fangb
    if $wufang == true
      @wu_window.update_help
    else
      @fang_window.update_help
    end
    @qiangxz_window.activate
  end
  
  def qiangxz_fangj
    $fangj = !$fangj
    if $wufang == true
      @wu_window.update_help
    else
      @fang_window.update_help
    end
    @qiangxz_window.activate
  end
  
  def qiangxz_ok
    if $wufang == true
      Equipplus.upweapon(@wu_window.itemid)
      qianging
      @qianghelp_window.set_text($message)
      @qiangxz_window.hide
      Graphics.wait(60)
      @wu_window.activate
      @qiangxz_window.deactivate
      @help_window.hide
      $当前使用宝石加成率 = 0
      $usegem = false
      @fang_window.update_help
      @wu_window.refresh
      @command_window.deactivate
    else
      Equipplus.uparmor(@fang_window.itemid)
      qianging
      @qianghelp_window.set_text($message)
      @qiangxz_window.hide
      Graphics.wait(60)
      @fang_window.activate
      @qiangxz_window.deactivate
      @help_window.hide
      $当前使用宝石加成率 = 0
      $usegem = false
      @fang_window.update_help
      @fang_window.refresh
      @command_window.deactivate
    end
  end
  
  def qiangxz_cancel
    @help_window.refresh
                @help_window.show
    @wu_window.show
    @qiangxz_window.hide
    @qiangxz_window.deactivate
    if $wufang == true
      @wu_window.activate
    else
      @fang_window.activate
    end
    $当前使用宝石加成率 = 0
    $usegem = false
    @command_window.deactivate
  end
  
  def qianging
    i = 0
    while i < 20
      i += 1
      text = "\n"
      text += "★" * i + "☆" * (20 - i)
      text = text + "\n强化中,请等待。"
      @qianghelp_window.set_text(text)
      Graphics.wait(6)
    end
  end
end

class RPG::EquipItem < RPG::BaseItem
  alias old initialize
  def initialize
    old
    @up = 0 #装备强化次数
  end
  attr_accessor :up
end
#==============================================================================
# ■ Window_Qiangwu
#------------------------------------------------------------------------------
#  强化系统_武器强化窗口
#==============================================================================

class Window_Qiangwu < Window_ItemList
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(qianghelp,xuanze)
    super(0, 0, Graphics.width, fitting_height(8))
    self.openness = 0
    deactivate
    @qianghelp = qianghelp
    @xuanze = xuanze
  end
  #--------------------------------------------------------------------------
  # ● 开始输入的处理
  #--------------------------------------------------------------------------
  def start
    self.category = :weapon
    refresh
    select(0)
    open
    activate
  end
  #--------------------------------------------------------------------------
  # ● 查询此物品是否可用
  #--------------------------------------------------------------------------
  def enable?(item)
    return false unless item != nil
    Equipplus.weaponupable?(item.id)
  end
  #--------------------------------------------------------------------------
  # ● 确定强化武器
  #--------------------------------------------------------------------------
  def qiangwu_ok
    result = item ? item.id : 0
  end
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    return unless item != nil
    @help_window.set_item(item)
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
    needmoney = 0
    Equipplus.weaponupable?(item.id)
    qitemname = Equipplus.lostitem.name
    if item.up >= $强化哈希表["最高等级"]
      qitemname = "无法继续升级"
    end
    temp = []
    $usegem == true ? temp.push("使用") : temp.push("未使用")
    temp.push($data_items[$强化哈希表["特殊物品"][0]].name)
    $fangb == true ? temp.push("使用") : temp.push("未使用")
    temp.push($data_items[$强化哈希表["特殊物品"][1]].name)
    $fangj == true ? temp.push("使用") : temp.push("未使用")
    cgl = ($强化哈希表["每级概率"][item.up] + $当前使用宝石加成率).to_s
    if item.up == 0
      min = item.params[2] + 1
      max = min + 5
    else
      if item.up >= $强化哈希表["最高等级"]
        min = item.params[2].to_int
        max = min
      else
    min = (item.params[2] * (1 + $强化哈希表["提升能力"][item.up] / 100)).to_int + item.up
    max = min + item.up * 5
    end
  end
    text = "装备名称:" + item.name + "\n强化所需" + Vocab::currency_unit + ":" + Equipplus.needmoney.to_s
    text += "\n当前强化等级:" + item.up.to_s + "\n强化需要:" +  qitemname
    text += "\n强化宝石:" + temp [0] + " " + temp[1] + ":" + temp[2]+ " " + temp[3] + ":" + temp[4]
    text += "\n成功率:" + cgl + "% " + "\n强化后攻击力范围:" + min.to_s + "~" + max.to_s
    @qianghelp.set_text(text)
  end
  #--------------------------------------------------------------------------
  # ● 获取当前武器等级
  #--------------------------------------------------------------------------
  def getweaponup
    Equipplus.weaponupisnil(item.id)
    item.up
  end
  
  def itemid
    item.id
  end
  #--------------------------------------------------------------------------
  # ● 选择项目
  #--------------------------------------------------------------------------
  def select(index)
    self.index = index if index
    update_help
  end
end
#==============================================================================
# ■ Window_Qiangfang
#------------------------------------------------------------------------------
#  强化系统_防具强化窗口
#==============================================================================

class Window_Qiangfang < Window_ItemList
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(qianghelp,xuanze)
    super(0, 0, Graphics.width, fitting_height(8))
    self.openness = 0
    deactivate
    @qianghelp = qianghelp
    @xuanze = xuanze
  end
  #--------------------------------------------------------------------------
  # ● 开始输入的处理
  #--------------------------------------------------------------------------
  def start
    self.category = :armor
    refresh
    select(0)
    open
    activate
  end
  #--------------------------------------------------------------------------
  # ● 查询此物品是否可用
  #--------------------------------------------------------------------------
  def enable?(item)
    return false unless item != nil
    Equipplus.armorupable?(item.id)
  end
  #--------------------------------------------------------------------------
  # ● 确定强化防具
  #--------------------------------------------------------------------------
  def qiangfang_ok
    result = item ? item.id : 0
  end
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    return unless item != nil
    @help_window.set_item(item)
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
    needmoney = 0
    Equipplus.armorupable?(item.id)
    qitemname = Equipplus.lostitem.name
    if item.up >= $强化哈希表["最高等级"]
      qitemname = "无法继续升级"
    end
    temp = []
    $usegem == true ? temp.push("使用") : temp.push("未使用")
    temp.push($data_items[$强化哈希表["特殊物品"][0]].name)
    $fangb == true ? temp.push("使用") : temp.push("未使用")
    temp.push($data_items[$强化哈希表["特殊物品"][1]].name)
    $fangj == true ? temp.push("使用") : temp.push("未使用")
    cgl = ($强化哈希表["每级概率"][item.up] + $当前使用宝石加成率).to_s
    if item.up == 0
      min = item.params[3] + 1
      max = min + 5
    else
      if item.up >= $强化哈希表["最高等级"]
        min = item.params[3].to_int
        max = min
      else
    min = (item.params[3] * (1 + $强化哈希表["提升能力"][item.up] / 100)).to_int + item.up
    max = min + item.up * 5
    end
  end
    text = "装备名称:" + item.name + "\n强化所需" + Vocab::currency_unit + ":" + Equipplus.needmoney.to_s
    text += "\n当前强化等级:" + item.up.to_s + "\n强化需要:" +  qitemname
    text += "\n强化宝石:" + temp [0] + " " + temp[1] + ":" + temp[2]+ " " + temp[3] + ":" + temp[4]
    text += "\n成功率:" + cgl + "% " + "\n强化后防御力范围:" + min.to_s + "~" + max.to_s
    @qianghelp.set_text(text)
  end
  #--------------------------------------------------------------------------
  # ● 获取当前防具等级
  #--------------------------------------------------------------------------
  def getarmorup
    Equipplus.armorupisnil(item.id)
    item.up
  end
  
  def itemid
    item.id
  end
  #--------------------------------------------------------------------------
  # ● 选择项目
  #--------------------------------------------------------------------------
  def select(index)
    self.index = index if index
    update_help
  end
end
#==============================================================================
# ■ Window_QiangCommand
#------------------------------------------------------------------------------
#  强化系统中,处理命令选择的窗口。
#==============================================================================

class Window_QiangCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    update_placement
    self.openness = 0
    open
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # ● 更新窗口的位置
  #--------------------------------------------------------------------------
  def update_placement
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("强化武器",    :qiangwu)
    add_command(Vocab::ShopCancel, :cancel)
  end
end
#==============================================================================
# ■ Window_Qianghelp
#------------------------------------------------------------------------------
#  显示说明
#==============================================================================

class Window_Qianghelp < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, window_width, fitting_height(7) + 8)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    return 544
  end
  #--------------------------------------------------------------------------
  # ● 获取持有金钱
  #--------------------------------------------------------------------------
  def value
    $game_party.gold
  end
  #--------------------------------------------------------------------------
  # ● 获取货币单位
  #--------------------------------------------------------------------------
  def currency_unit
    Vocab::currency_unit
  end
  #--------------------------------------------------------------------------
  # ● 设置内容
  #--------------------------------------------------------------------------
  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● 清除
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text_ex(4, 0, @text)
  end
end
#==============================================================================
# ■ Window_Qiangxz
#------------------------------------------------------------------------------
#  强化系统中,选择强化方式的窗口。
#==============================================================================

class Window_Qiangxz < Window_Command
  @havegem = false
  @havefangb = false
  @havefangj = false
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    index = 0
    update_placement
    self.openness = 0
    open
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    return 180
  end
  #--------------------------------------------------------------------------
  # ● 更新窗口的位置
  #--------------------------------------------------------------------------
  def update_placement
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end
  #--------------------------------------------------------------------------
  # ● 检查可用
  #--------------------------------------------------------------------------
  def haveitem
    @havegem = false
    @havefangb = false
    @havefangj = false
    for i in $强化哈希表["宝石效果"]
        if $game_party.has_item?($data_items[i[1]])
        @havegem = true
      end
    end
    @havefangb = $game_party.has_item?($data_items[$强化哈希表["特殊物品"][0]])
    @havefangj = $game_party.has_item?($data_items[$强化哈希表["特殊物品"][1]])
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    haveitem
    add_command("宝石",     :gem, @havegem)
    add_command(Equipplus.idgetitem($强化哈希表["特殊物品"][0]).name, :fangb, @havefangb)
    add_command(Equipplus.idgetitem($强化哈希表["特殊物品"][1]).name, :fangj, @havefangj)
    add_command("开始强化", :start)
    add_command("取消强化", :cancel)
  end
end
class Window_ItemList
  #--------------------------------------------------------------------------
  # ● 查询列表中是否含有此物品
  #--------------------------------------------------------------------------
  def include?(item)
    case @category
    when :item
      item.is_a?(RPG::Item) && !item.key_item?
    when :weapon
      item.is_a?(RPG::Weapon)
    when :armor
      item.is_a?(RPG::Armor)
    when :key_item
      item.is_a?(RPG::Item) && item.key_item?
    when :gem
      itemid = item ? item.id : 0
      itemid != 0 ? isgem(itemid) : false
    else
      false
    end
  end
  
  def isgem(itemid)
    for i in $强化哈希表["宝石效果"]
      return true if i[1] == itemid
    end
    false
  end
end
#==============================================================================
# ■ Window_Choosegem
#------------------------------------------------------------------------------
#  选择强化使用的宝石
#==============================================================================

class Window_Choosegem < Window_ItemList
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize()
    super(0, 0, Graphics.width, fitting_height(2))
    self.openness = 0
    deactivate
    @wufangwindow = nil
    @qiangxz = nil
    set_handler(:ok,     method(:on_ok))
    set_handler(:cancel, method(:on_cancel))
  end
  
  def wufangwindow=(wufangwindow)
    @wufangwindow = wufangwindow
  end
  def qiangxz=(qiangxz)
    @qiangxz = qiangxz
  end
  #--------------------------------------------------------------------------
  # ● 开始输入的处理
  #--------------------------------------------------------------------------
  def start
    self.category = :gem
    self.y = (Graphics.height - height) / 2
    refresh
    select(0)
    open
    activate
  end
  #--------------------------------------------------------------------------
  # ● 确定时的处理
  #--------------------------------------------------------------------------
  def on_ok
    result = item ? item.id : 0
    if result != 0
     $usegem = true
     $当前使用宝石id = result
     for i in $强化哈希表["宝石效果"]
       $当前使用宝石加成率 = i[0] if i[1] == $当前使用宝石id
     end
   else
     $当前使用宝石加成率 = 0
     $usegem = false
    end
    @wufangwindow.update_help
    @qiangxz.activate
    close
  end
  #--------------------------------------------------------------------------
  # ● 查询此物品是否可用
  #--------------------------------------------------------------------------
  def enable?(item)
    true
  end
  #--------------------------------------------------------------------------
  # ● 取消时的处理
  #--------------------------------------------------------------------------
  def on_cancel
    $当前使用宝石加成率 = 0
    $usegem = false
    @wufangwindow.update_help
    @qiangxz.activate
    close
  end
end
#==============================================================================
# ■ 强化系统DataManager
#------------------------------------------------------------------------------
#  将武器和防具数据保存入存档
#==============================================================================
module DataManager
  #--------------------------------------------------------------------------
  # ● 生成存档内容
  #--------------------------------------------------------------------------
  def self.make_save_contents
    contents = {}
    contents[:system]        = $game_system
    contents[:timer]         = $game_timer
    contents[:message]       = $game_message
    contents[:switches]      = $game_switches
    contents[:variables]     = $game_variables
    contents[:self_switches] = $game_self_switches
    contents[:actors]        = $game_actors
    contents[:party]         = $game_party
    contents[:troop]         = $game_troop
    contents[:map]           = $game_map
    contents[:player]        = $game_player
    contents[:weapons]       = $data_weapons
    contents[:armors]        = $data_armors
    contents
  end
  #--------------------------------------------------------------------------
  # ● 展开存档内容
  #--------------------------------------------------------------------------
  def self.extract_save_contents(contents)
    $game_system        = contents[:system]
    $game_timer         = contents[:timer]
    $game_message       = contents[:message]
    $game_switches      = contents[:switches]
    $game_variables     = contents[:variables]
    $game_self_switches = contents[:self_switches]
    $game_actors        = contents[:actors]
    $game_party         = contents[:party]
    $game_troop         = contents[:troop]
    $game_map           = contents[:map]
    $game_player        = contents[:player]
    $data_weapons       = contents[:weapons]
    $data_armors        = contents[:armors]
  end
end

Lv1.梦旅人

梦石
0
星屑
50
在线时间
687 小时
注册时间
2012-10-29
帖子
1543
2
发表于 2013-1-16 22:34:15 | 只看该作者
贴脚本时请用代码,在问一些错误讯息时也可以直接查第几行,省去不少麻烦。
修改劇本中,仔細審查原來的劇情大綱,覺得有點不太滿意,嘗試編寫不同主角不同主線的劇情,希望能寫得出來。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2013-1-13
帖子
23
3
 楼主| 发表于 2013-1-16 22:38:05 | 只看该作者
  1. 下面是我用的武器强化脚本

  2. #encoding:utf-8
  3. #==============================================================================
  4. # ■ 装备强化系统 By wyongcan
  5. #==============================================================================
  6. module Equipplus
  7. #升到各级时装备颜色请在“颜色描绘”脚本中修改
  8. $maxlv = 12  #最高升到的级数
  9. $gailv = [100,80,70,60,50,30,20,10,5,5,5,5,1] #每级提升概率
  10. $gemlv = [[60,23],[10,28],[25,29],[40,30]] #使用宝石提高的几率  [提高几率,宝石ID]
  11. $uplv = [[12,24],[3,25],[6,26],[9,27]] #强化所需要的强化石 [最大强化到的等级,强化石ID]
  12. $xxlv = [0,0,5,10,15,20,25,30,30,40,40,45,60] #每级强化后失败物品消失的几率
  13. $jjlv = [0,10,15,20,30,45,55,65,70,70,75,80,100] #每级强化后失败物品降级的几率
  14. $tsnl = [10,14,18,22,26,30,34,38,42,46,50,54,65] #每级强化提升能力的百分比
  15. $tswp = [31,32] # 意思是:如果有31号物品则失败后物品不消失,如果有32号物品则失败后物品不降级
  16. #武器强化后的计算公式为: 原攻击 * (1 + 提升能力百分比) + (0到当前强化级数随机) * 5 + 当前强化级数
  17. $gemlv.sort!
  18. $uplv.sort!
  19. $当前使用宝石id = 0
  20. $当前使用宝石加成率 = 0
  21. $强化哈希表 = {
  22. "最高等级" => $maxlv ,
  23. "每级概率" => $gailv ,
  24. "宝石效果" => $gemlv ,
  25. "消失几率" => $xxlv  ,
  26. "降级几率" => $jjlv  ,
  27. "提升能力" => $tsnl  ,
  28. "特殊物品" => $tswp  ,
  29. "强化材料" => $uplv  }
  30. def self.idlostitem(id,amount = 1)
  31.   $game_party.lose_item(idgetitem(id),amount)
  32. end

  33. def self.idlostequip(id,weapon = true,amount = 1)
  34.   weapon == true ? $game_party.lose_item($data_weapons[id],amount,true) : $game_party.lose_item($data_armors[id],amount,true)
  35. end

  36. def self.idgainequip(id,weapon = true,amount = 1)
  37.   weapon == true ? $game_party.gain_item($data_weapons[id],amount,true) : $game_party.gain_item($data_armors[id],amount,true)
  38. end

  39. def self.idgetitem(id)
  40.   $data_items[id]
  41. end

  42. def self.equipable?(id,weapon = true)
  43.   weapon == true ? weaponupisnil(id) : armorupisnil(id)
  44.   weapon == true ? equip = $data_weapons[id].dup : equip = $data_armors[id].dup
  45.   price = equip.price
  46.   @needmoney = price * equip.up
  47.   if @needmoney == 0
  48.     @needmoney = price / 2
  49.   end
  50. #循环取出需要的强化材料
  51.   temp = false
  52.   for i in $强化哈希表["强化材料"]
  53.     if equip.up < i[0]
  54.       @lostitem = idgetitem i[1]
  55.       $game_party.has_item?(idgetitem(i[1])) ? temp = true : temp = false
  56.       break
  57.     end
  58.   end
  59.   $game_party.gold >= @needmoney && temp == true ? true : false
  60. end

  61. def self.upweapon (id)
  62.   $message = ""
  63.   success = false
  64.   weaponupisnil(id)
  65.   weapon = $data_weapons[id].dup
  66.   gl = 0
  67.   fangb = false
  68.   fangj = false
  69.   return unless weapon.up < $强化哈希表["最高等级"] && weaponupable?(id)
  70.   loststh
  71.   $message += "本次强化,共消耗:" + Vocab::currency_unit + " " + @needmoney.to_s
  72.   $message += " " + @lostitem.name + "\n "
  73.   gl = $强化哈希表["每级概率"][weapon.up]
  74.   if $usegem == true
  75.     gl += $当前使用宝石加成率
  76.     idlostitem($当前使用宝石id)
  77.     $message += idgetitem($当前使用宝石id).name + " "
  78.   end
  79.   if $fangb == true
  80.     fangb = true
  81.     idlostitem $强化哈希表["特殊物品"][0]
  82.     $message += idgetitem($强化哈希表["特殊物品"][0]).name + " "
  83.   end
  84.   if $fangj == true
  85.     fangj = true
  86.     idlostitem $强化哈希表["特殊物品"][1]
  87.     $message += idgetitem($强化哈希表["特殊物品"][1]).name + " "
  88.   end
  89.   suiji = rand (100)
  90.   if suiji <= gl
  91.     success = true
  92.   end
  93.   $message += "\n强化结果:"
  94.   if success == true
  95.     $message += "强化成功"
  96.     idlostequip id
  97.     weapon.id = $data_weapons.size
  98.     params = weapon.params.dup
  99.     params[2] *= 1 + $强化哈希表["提升能力"][weapon.up] / 100
  100.     params[2] += rand(weapon.up) * 5 + weapon.up
  101.     params[2] += 1 if params[2] == weapon.params[2]
  102.     $message += " 攻击力提升:" + (params[2] - weapon.params[2]).to_int.to_s
  103.     weapon.up += 1
  104.     $data_weapons.insert $data_weapons.size,weapon
  105.     $data_weapons[$data_weapons.size-1].params = params
  106.     idgainequip weapon.id
  107.   else
  108.     $message += "强化失败"
  109.     suiji = rand (100)
  110.     if suiji <= $强化哈希表["消失几率"][weapon.up]
  111.       if fangb != true
  112.       $message += ",道具消失"
  113.       idlostequip id
  114.       else
  115.       $message += ",由于" + idgetitem($强化哈希表["特殊物品"][0]).name + "的作用,道具未消失"
  116.       end
  117.     else
  118.       suiji = rand (100)
  119.       if suiji <= $强化哈希表["降级几率"][weapon.up]
  120.         if fangj == false && weapon.up != 0
  121.           $message += ",道具降级"
  122.           params = weapon.params.dup
  123.           params[2] -= weapon.up + rand(weapon.up) * 5
  124.           params[2] /= 1 + $强化哈希表["提升能力"][weapon.up] / 100
  125.           weapon.params = params
  126.           weapon.up -= 1
  127.           $data_weapons[id] = weapon
  128.         else
  129.           $message += ",由于" + idgetitem($强化哈希表["特殊物品"][1]).name + "的作用,道具未降级"
  130.         end
  131.       end
  132.     end
  133.   end
  134.    $usegem = false
  135.    $fangb = false
  136.    $fangj = false
  137. end

  138. def self.weaponupisnil(id)
  139.    $data_weapons[id].up = 0 unless $data_weapons[id].up != nil
  140. end

  141. def self.weaponupable?(id)
  142.   equipable?(id)
  143. end

  144. def self.uparmor (id)
  145.   $message = ""
  146.   success = false
  147.   armorupisnil(id)
  148.   armor = $data_armors[id].dup
  149.   gl = 0
  150.   fangb = false
  151.   fangj = false
  152.   return unless armor.up < $强化哈希表["最高等级"] && armorupable?(id)
  153.   loststh
  154.   $message += "本次强化,共消耗:" + Vocab::currency_unit + " " + @needmoney.to_s
  155.   $message += " " + @lostitem.name + "\n "
  156.   gl = $强化哈希表["每级概率"][armor.up]
  157.   if $usegem == true
  158.     gl += $当前使用宝石加成率
  159.     idlostitem($当前使用宝石id)
  160.     $message += idgetitem($当前使用宝石id).name + " "
  161.   end
  162.   if $fangb == true
  163.     fangb = true
  164.     idlostitem $强化哈希表["特殊物品"][0]
  165.     $message += idgetitem($强化哈希表["特殊物品"][0]).name + " "
  166.   end
  167.   if $fangj == true
  168.     fangj = true
  169.     idlostitem $强化哈希表["特殊物品"][1]
  170.     $message += idgetitem($强化哈希表["特殊物品"][1]).name + " "
  171.   end
  172.   suiji = rand (100)
  173.   if suiji <= gl
  174.     success = true
  175.   end
  176.   $message += "\n强化结果:"
  177.   if success == true
  178.     $message += "强化成功"
  179.     idlostequip id,false
  180.     armor.id = $data_armors.size
  181.     params = armor.params.dup
  182.     params[3] *= 1 + $强化哈希表["提升能力"][armor.up] / 100
  183.     params[3] += rand(armor.up) * 5 + armor.up
  184.     params[3] += 1 if params[3] == armor.params[3]
  185.     $message += " 防御力提升:" + (params[3] - armor.params[3]).to_int.to_s
  186.     armor.up += 1
  187.     $data_armors.insert $data_armors.size,armor
  188.     $data_armors[$data_armors.size-1].params = params
  189.     idgainequip armor.id,false
  190.   else
  191.     $message += "强化失败"
  192.     suiji = rand (100)
  193.     if suiji <= $强化哈希表["消失几率"][armor.up]
  194.       if fangb != true
  195.       $message += ",道具消失"
  196.       idlostequip id,false
  197.       else
  198.       $message += ",由于" + idgetitem($强化哈希表["特殊物品"][0]).name + "的作用,道具未消失"
  199.       end
  200.     else
  201.       suiji = rand (100)
  202.       if suiji <= $强化哈希表["降级几率"][armor.up]
  203.         if fangj == false && armor.up != 0
  204.           $message += ",道具降级"
  205.           params = armor.params.dup
  206.           params[3] -= armor.up + rand(armor.up) * 5
  207.           params[3] /= 1 + $强化哈希表["提升能力"][armor.up] / 100
  208.           armor.params = params
  209.           armor.up -= 1
  210.           $data_armors[id] = armor
  211.         else
  212.           $message += ",由于" + idgetitem($强化哈希表["特殊物品"][1]).name + "的作用,道具未降级"
  213.         end
  214.       end
  215.     end
  216.   end
  217.    $usegem = false
  218.    $fangb = false
  219.    $fangj = false
  220. end

  221. def self.armorupisnil(id)
  222.    $data_armors[id].up = 0 unless $data_armors[id].up != nil
  223. end
  224. def self.armorupable?(id)
  225.   equipable?(id,false)
  226. end
  227. def self.loststh()
  228.    $game_party.lose_item(@lostitem,1)
  229.    $game_party.lose_gold(@needmoney)
  230. end
  231. def self.needmoney
  232.    @needmoney
  233. end
  234. def self.lostitem
  235.    @lostitem
  236. end
  237. end
  238. #==============================================================================
  239. # ■ Scene_Qiang
  240. #------------------------------------------------------------------------------
  241. #  强化画面
  242. #==============================================================================

  243. class Scene_Qiang < Scene_MenuBase
  244.   $wufang = true
  245.   $usegem = false
  246.   $fangb = false
  247.   $fangj = false
  248.   #--------------------------------------------------------------------------
  249.   # ● 开始处理
  250.   #--------------------------------------------------------------------------
  251.   def start
  252.     super
  253.     create_help_window
  254.     @help_window.hide
  255.     create_qianghelp_window
  256.     create_command_window
  257.     create_qiangxz_window
  258.     create_wu_window
  259.     create_fang_window
  260.     create_choosegem_window
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 生成说明窗口
  264.   #--------------------------------------------------------------------------
  265.   def create_qianghelp_window
  266.     @qianghelp_window = Window_Qianghelp.new
  267.     @qianghelp_window.y = Graphics.height - @qianghelp_window.height
  268.     @qianghelp_window.viewport = @viewport
  269.     @qianghelp_window.hide
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 生成选择宝石
  273.   #--------------------------------------------------------------------------
  274.   def create_choosegem_window
  275.     @choosegem_window = Window_Choosegem.new
  276.     @choosegem_window.y = Graphics.height - @choosegem_window.height
  277.     @choosegem_window.viewport = @viewport
  278.     @choosegem_window.z = 120
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 生成选择窗口
  282.   #--------------------------------------------------------------------------
  283.   def create_qiangxz_window
  284.     @qiangxz_window = Window_Qiangxz.new
  285.     @qiangxz_window.y = @help_window.height + fitting_height(5) /2
  286.     @qiangxz_window.z = 110
  287.     @qiangxz_window.viewport = @viewport
  288.     @qiangxz_window.set_handler(:gem,    method(:qiangxz_gem))
  289.     @qiangxz_window.set_handler(:fangb,    method(:qiangxz_fangb))
  290.     @qiangxz_window.set_handler(:fangj,    method(:qiangxz_fangj))
  291.     @qiangxz_window.set_handler(:ok, method(:qiangxz_ok))
  292.     @qiangxz_window.set_handler(:cancel, method(:qiangxz_cancel))
  293.     @qiangxz_window.hide
  294.     @qiangxz_window.deactivate
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 生成指令窗口
  298.   #--------------------------------------------------------------------------
  299.   def create_command_window
  300.     @command_window = Window_QiangCommand.new
  301.     @command_window.viewport = @viewport
  302.     @command_window.y = @help_window.height + fitting_height(3) /2
  303.     @command_window.set_handler(:qiangwu,    method(:qiangwu))
  304.     @command_window.set_handler(:qiangfang,   method(:qiangfang))
  305.     @command_window.set_handler(:cancel, method(:return_scene))
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ● 生成武器强化窗口
  309.   #--------------------------------------------------------------------------
  310.   def create_wu_window
  311.     @wu_window = Window_Qiangwu.new(@qianghelp_window,@qiangxz_window)
  312.     @wu_window.viewport = @viewport
  313.     @wu_window.y += @help_window.height
  314.     @wu_window.hide
  315.     @wu_window.help_window= @help_window
  316.     @wu_window.set_handler(:cancel, method(:qiangwu_cancel))
  317.     @wu_window.set_handler(:ok,     method(:qiangwu_ok))
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 生成防具强化窗口
  321.   #--------------------------------------------------------------------------
  322.   def create_fang_window
  323.     @fang_window = Window_Qiangfang.new(@qianghelp_window,@qiangxz_window)
  324.     @fang_window.viewport = @viewport
  325.     @fang_window.y += @help_window.height
  326.     @fang_window.hide
  327.     @fang_window.help_window= @help_window
  328.     @fang_window.set_handler(:cancel, method(:qiangfang_cancel))
  329.     @fang_window.set_handler(:ok,     method(:qiangfang_ok))
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 计算窗口显示指定行数时的应用高度
  333.   #--------------------------------------------------------------------------
  334.   def fitting_height(line_number)
  335.     line_number * 24 + 12 * 2
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 显示强化武器
  339.   #--------------------------------------------------------------------------
  340.   def qiangwu
  341.     @command_window.hide
  342.     @help_window.show
  343.     @wu_window.show
  344.     @wu_window.start
  345.     @qianghelp_window.show
  346.     @wu_window.activate
  347.     $wufang = true
  348.     @command_window.deactivate
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 显示强化防具
  352.   #--------------------------------------------------------------------------
  353.   def qiangfang
  354.     @command_window.hide
  355.     @help_window.show
  356.     @fang_window.show
  357.     @fang_window.start
  358.     @qianghelp_window.show
  359.     @fang_window.activate
  360.     $wufang = false
  361.     @command_window.deactivate
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● 取消强化武器
  365.   #--------------------------------------------------------------------------
  366.   def qiangwu_cancel
  367.     @command_window.show
  368.     @help_window.hide
  369.     @wu_window.hide
  370.     @qianghelp_window.hide
  371.     @command_window.activate
  372.     @qianghelp_window.set_text("")
  373.     @help_window.set_text("")
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 取消强化防具
  377.   #--------------------------------------------------------------------------
  378.   def qiangfang_cancel
  379.     @command_window.show
  380.     @help_window.hide
  381.     @fang_window.hide
  382.     @qianghelp_window.hide
  383.     @command_window.activate
  384.     @qianghelp_window.set_text("")
  385.     @help_window.set_text("")
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # ● 确定强化武器
  389.   #--------------------------------------------------------------------------
  390.   def qiangwu_ok
  391.     @help_window.hide
  392.     @wu_window.qiangwu_ok
  393.     @qiangxz_window.show
  394.     @qiangxz_window.activate
  395.   end
  396.   #--------------------------------------------------------------------------
  397.   # ● 确定强化防具
  398.   #--------------------------------------------------------------------------
  399.   def qiangfang_ok
  400.     @help_window.hide
  401.     @fang_window.qiangfang_ok
  402.     @qiangxz_window.show
  403.     @qiangxz_window.activate
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # ● 获取卖出价格
  407.   #--------------------------------------------------------------------------
  408.   def selling_price
  409.     @item.price / 2
  410.   end
  411.   
  412.   def qiangxz_gem
  413.     @choosegem_window.start
  414.     @qiangxz_window.deactivate
  415.     @choosegem_window.qiangxz= @qiangxz_window
  416.     if $wufang == true
  417.       @choosegem_window.wufangwindow= @wu_window
  418.     else
  419.       @choosegem_window.wufangwindow= @fang_window
  420.     end
  421.   end
  422.   
  423.   def qiangxz_fangb
  424.     $fangb = !$fangb
  425.     if $wufang == true
  426.       @wu_window.update_help
  427.     else
  428.       @fang_window.update_help
  429.     end
  430.     @qiangxz_window.activate
  431.   end
  432.   
  433.   def qiangxz_fangj
  434.     $fangj = !$fangj
  435.     if $wufang == true
  436.       @wu_window.update_help
  437.     else
  438.       @fang_window.update_help
  439.     end
  440.     @qiangxz_window.activate
  441.   end
  442.   
  443.   def qiangxz_ok
  444.     if $wufang == true
  445.       Equipplus.upweapon(@wu_window.itemid)
  446.       qianging
  447.       @qianghelp_window.set_text($message)
  448.       @qiangxz_window.hide
  449.       Graphics.wait(60)
  450.       @wu_window.activate
  451.       @qiangxz_window.deactivate
  452.       @help_window.hide
  453.       $当前使用宝石加成率 = 0
  454.       $usegem = false
  455.       @fang_window.update_help
  456.       @wu_window.refresh
  457.       @command_window.deactivate
  458.     else
  459.       Equipplus.uparmor(@fang_window.itemid)
  460.       qianging
  461.       @qianghelp_window.set_text($message)
  462.       @qiangxz_window.hide
  463.       Graphics.wait(60)
  464.       @fang_window.activate
  465.       @qiangxz_window.deactivate
  466.       @help_window.hide
  467.       $当前使用宝石加成率 = 0
  468.       $usegem = false
  469.       @fang_window.update_help
  470.       @fang_window.refresh
  471.       @command_window.deactivate
  472.     end
  473.   end
  474.   
  475.   def qiangxz_cancel
  476.     @help_window.refresh
  477.                 @help_window.show
  478.     @wu_window.show
  479.     @qiangxz_window.hide
  480.     @qiangxz_window.deactivate
  481.     if $wufang == true
  482.       @wu_window.activate
  483.     else
  484.       @fang_window.activate
  485.     end
  486.     $当前使用宝石加成率 = 0
  487.     $usegem = false
  488.     @command_window.deactivate
  489.   end
  490.   
  491.   def qianging
  492.     i = 0
  493.     while i < 20
  494.       i += 1
  495.       text = "\n"
  496.       text += "★" * i + "☆" * (20 - i)
  497.       text = text + "\n强化中,请等待。"
  498.       @qianghelp_window.set_text(text)
  499.       Graphics.wait(6)
  500.     end
  501.   end
  502. end

  503. class RPG::EquipItem < RPG::BaseItem
  504.   alias old initialize
  505.   def initialize
  506.     old
  507.     @up = 0 #装备强化次数
  508.   end
  509.   attr_accessor :up
  510. end
  511. #==============================================================================
  512. # ■ Window_Qiangwu
  513. #------------------------------------------------------------------------------
  514. #  强化系统_武器强化窗口
  515. #==============================================================================

  516. class Window_Qiangwu < Window_ItemList
  517.   #--------------------------------------------------------------------------
  518.   # ● 初始化对象
  519.   #--------------------------------------------------------------------------
  520.   def initialize(qianghelp,xuanze)
  521.     super(0, 0, Graphics.width, fitting_height(8))
  522.     self.openness = 0
  523.     deactivate
  524.     @qianghelp = qianghelp
  525.     @xuanze = xuanze
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # ● 开始输入的处理
  529.   #--------------------------------------------------------------------------
  530.   def start
  531.     self.category = :weapon
  532.     refresh
  533.     select(0)
  534.     open
  535.     activate
  536.   end
  537.   #--------------------------------------------------------------------------
  538.   # ● 查询此物品是否可用
  539.   #--------------------------------------------------------------------------
  540.   def enable?(item)
  541.     return false unless item != nil
  542.     Equipplus.weaponupable?(item.id)
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● 确定强化武器
  546.   #--------------------------------------------------------------------------
  547.   def qiangwu_ok
  548.     result = item ? item.id : 0
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ● 更新帮助内容
  552.   #--------------------------------------------------------------------------
  553.   def update_help
  554.     return unless item != nil
  555.     @help_window.set_item(item)
  556.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  557.     needmoney = 0
  558.     Equipplus.weaponupable?(item.id)
  559.     qitemname = Equipplus.lostitem.name
  560.     if item.up >= $强化哈希表["最高等级"]
  561.       qitemname = "无法继续升级"
  562.     end
  563.     temp = []
  564.     $usegem == true ? temp.push("使用") : temp.push("未使用")
  565.     temp.push($data_items[$强化哈希表["特殊物品"][0]].name)
  566.     $fangb == true ? temp.push("使用") : temp.push("未使用")
  567.     temp.push($data_items[$强化哈希表["特殊物品"][1]].name)
  568.     $fangj == true ? temp.push("使用") : temp.push("未使用")
  569.     cgl = ($强化哈希表["每级概率"][item.up] + $当前使用宝石加成率).to_s
  570.     if item.up == 0
  571.       min = item.params[2] + 1
  572.       max = min + 5
  573.     else
  574.       if item.up >= $强化哈希表["最高等级"]
  575.         min = item.params[2].to_int
  576.         max = min
  577.       else
  578.     min = (item.params[2] * (1 + $强化哈希表["提升能力"][item.up] / 100)).to_int + item.up
  579.     max = min + item.up * 5
  580.     end
  581.   end
  582.     text = "装备名称:" + item.name + "\n强化所需" + Vocab::currency_unit + ":" + Equipplus.needmoney.to_s
  583.     text += "\n当前强化等级:" + item.up.to_s + "\n强化需要:" +  qitemname
  584.     text += "\n强化宝石:" + temp [0] + " " + temp[1] + ":" + temp[2]+ " " + temp[3] + ":" + temp[4]
  585.     text += "\n成功率:" + cgl + "% " + "\n强化后攻击力范围:" + min.to_s + "~" + max.to_s
  586.     @qianghelp.set_text(text)
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # ● 获取当前武器等级
  590.   #--------------------------------------------------------------------------
  591.   def getweaponup
  592.     Equipplus.weaponupisnil(item.id)
  593.     item.up
  594.   end
  595.   
  596.   def itemid
  597.     item.id
  598.   end
  599.   #--------------------------------------------------------------------------
  600.   # ● 选择项目
  601.   #--------------------------------------------------------------------------
  602.   def select(index)
  603.     self.index = index if index
  604.     update_help
  605.   end
  606. end
  607. #==============================================================================
  608. # ■ Window_Qiangfang
  609. #------------------------------------------------------------------------------
  610. #  强化系统_防具强化窗口
  611. #==============================================================================

  612. class Window_Qiangfang < Window_ItemList
  613.   #--------------------------------------------------------------------------
  614.   # ● 初始化对象
  615.   #--------------------------------------------------------------------------
  616.   def initialize(qianghelp,xuanze)
  617.     super(0, 0, Graphics.width, fitting_height(8))
  618.     self.openness = 0
  619.     deactivate
  620.     @qianghelp = qianghelp
  621.     @xuanze = xuanze
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ● 开始输入的处理
  625.   #--------------------------------------------------------------------------
  626.   def start
  627.     self.category = :armor
  628.     refresh
  629.     select(0)
  630.     open
  631.     activate
  632.   end
  633.   #--------------------------------------------------------------------------
  634.   # ● 查询此物品是否可用
  635.   #--------------------------------------------------------------------------
  636.   def enable?(item)
  637.     return false unless item != nil
  638.     Equipplus.armorupable?(item.id)
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 确定强化防具
  642.   #--------------------------------------------------------------------------
  643.   def qiangfang_ok
  644.     result = item ? item.id : 0
  645.   end
  646.   #--------------------------------------------------------------------------
  647.   # ● 更新帮助内容
  648.   #--------------------------------------------------------------------------
  649.   def update_help
  650.     return unless item != nil
  651.     @help_window.set_item(item)
  652.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  653.     needmoney = 0
  654.     Equipplus.armorupable?(item.id)
  655.     qitemname = Equipplus.lostitem.name
  656.     if item.up >= $强化哈希表["最高等级"]
  657.       qitemname = "无法继续升级"
  658.     end
  659.     temp = []
  660.     $usegem == true ? temp.push("使用") : temp.push("未使用")
  661.     temp.push($data_items[$强化哈希表["特殊物品"][0]].name)
  662.     $fangb == true ? temp.push("使用") : temp.push("未使用")
  663.     temp.push($data_items[$强化哈希表["特殊物品"][1]].name)
  664.     $fangj == true ? temp.push("使用") : temp.push("未使用")
  665.     cgl = ($强化哈希表["每级概率"][item.up] + $当前使用宝石加成率).to_s
  666.     if item.up == 0
  667.       min = item.params[3] + 1
  668.       max = min + 5
  669.     else
  670.       if item.up >= $强化哈希表["最高等级"]
  671.         min = item.params[3].to_int
  672.         max = min
  673.       else
  674.     min = (item.params[3] * (1 + $强化哈希表["提升能力"][item.up] / 100)).to_int + item.up
  675.     max = min + item.up * 5
  676.     end
  677.   end
  678.     text = "装备名称:" + item.name + "\n强化所需" + Vocab::currency_unit + ":" + Equipplus.needmoney.to_s
  679.     text += "\n当前强化等级:" + item.up.to_s + "\n强化需要:" +  qitemname
  680.     text += "\n强化宝石:" + temp [0] + " " + temp[1] + ":" + temp[2]+ " " + temp[3] + ":" + temp[4]
  681.     text += "\n成功率:" + cgl + "% " + "\n强化后防御力范围:" + min.to_s + "~" + max.to_s
  682.     @qianghelp.set_text(text)
  683.   end
  684.   #--------------------------------------------------------------------------
  685.   # ● 获取当前防具等级
  686.   #--------------------------------------------------------------------------
  687.   def getarmorup
  688.     Equipplus.armorupisnil(item.id)
  689.     item.up
  690.   end
  691.   
  692.   def itemid
  693.     item.id
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● 选择项目
  697.   #--------------------------------------------------------------------------
  698.   def select(index)
  699.     self.index = index if index
  700.     update_help
  701.   end
  702. end
  703. #==============================================================================
  704. # ■ Window_QiangCommand
  705. #------------------------------------------------------------------------------
  706. #  强化系统中,处理命令选择的窗口。
  707. #==============================================================================

  708. class Window_QiangCommand < Window_Command
  709.   #--------------------------------------------------------------------------
  710.   # ● 初始化对象
  711.   #--------------------------------------------------------------------------
  712.   def initialize
  713.     super(0, 0)
  714.     update_placement
  715.     self.openness = 0
  716.     open
  717.   end
  718.   #--------------------------------------------------------------------------
  719.   # ● 获取窗口的宽度
  720.   #--------------------------------------------------------------------------
  721.   def window_width
  722.     return 160
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # ● 更新窗口的位置
  726.   #--------------------------------------------------------------------------
  727.   def update_placement
  728.     self.x = (Graphics.width - width) / 2
  729.     self.y = (Graphics.height - height) / 2
  730.   end
  731.   #--------------------------------------------------------------------------
  732.   # ● 生成指令列表
  733.   #--------------------------------------------------------------------------
  734.   def make_command_list
  735.     add_command("强化武器",    :qiangwu)
  736.     add_command(Vocab::ShopCancel, :cancel)
  737.   end
  738. end
  739. #==============================================================================
  740. # ■ Window_Qianghelp
  741. #------------------------------------------------------------------------------
  742. #  显示说明
  743. #==============================================================================

  744. class Window_Qianghelp < Window_Base
  745.   #--------------------------------------------------------------------------
  746.   # ● 初始化对象
  747.   #--------------------------------------------------------------------------
  748.   def initialize
  749.     super(0, 0, window_width, fitting_height(7) + 8)
  750.     refresh
  751.   end
  752.   #--------------------------------------------------------------------------
  753.   # ● 获取窗口的宽度
  754.   #--------------------------------------------------------------------------
  755.   def window_width
  756.     return 544
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   # ● 获取持有金钱
  760.   #--------------------------------------------------------------------------
  761.   def value
  762.     $game_party.gold
  763.   end
  764.   #--------------------------------------------------------------------------
  765.   # ● 获取货币单位
  766.   #--------------------------------------------------------------------------
  767.   def currency_unit
  768.     Vocab::currency_unit
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # ● 设置内容
  772.   #--------------------------------------------------------------------------
  773.   def set_text(text)
  774.     if text != @text
  775.       @text = text
  776.       refresh
  777.     end
  778.   end
  779.   #--------------------------------------------------------------------------
  780.   # ● 清除
  781.   #--------------------------------------------------------------------------
  782.   def clear
  783.     set_text("")
  784.   end
  785.   #--------------------------------------------------------------------------
  786.   # ● 刷新
  787.   #--------------------------------------------------------------------------
  788.   def refresh
  789.     contents.clear
  790.     draw_text_ex(4, 0, @text)
  791.   end
  792. end
  793. #==============================================================================
  794. # ■ Window_Qiangxz
  795. #------------------------------------------------------------------------------
  796. #  强化系统中,选择强化方式的窗口。
  797. #==============================================================================

  798. class Window_Qiangxz < Window_Command
  799.   @havegem = false
  800.   @havefangb = false
  801.   @havefangj = false
  802.   #--------------------------------------------------------------------------
  803.   # ● 初始化对象
  804.   #--------------------------------------------------------------------------
  805.   def initialize
  806.     super(0, 0)
  807.     index = 0
  808.     update_placement
  809.     self.openness = 0
  810.     open
  811.   end
  812.   #--------------------------------------------------------------------------
  813.   # ● 获取窗口的宽度
  814.   #--------------------------------------------------------------------------
  815.   def window_width
  816.     return 180
  817.   end
  818.   #--------------------------------------------------------------------------
  819.   # ● 更新窗口的位置
  820.   #--------------------------------------------------------------------------
  821.   def update_placement
  822.     self.x = (Graphics.width - width) / 2
  823.     self.y = (Graphics.height - height) / 2
  824.   end
  825.   #--------------------------------------------------------------------------
  826.   # ● 检查可用
  827.   #--------------------------------------------------------------------------
  828.   def haveitem
  829.     @havegem = false
  830.     @havefangb = false
  831.     @havefangj = false
  832.     for i in $强化哈希表["宝石效果"]
  833.         if $game_party.has_item?($data_items[i[1]])
  834.         @havegem = true
  835.       end
  836.     end
  837.     @havefangb = $game_party.has_item?($data_items[$强化哈希表["特殊物品"][0]])
  838.     @havefangj = $game_party.has_item?($data_items[$强化哈希表["特殊物品"][1]])
  839.   end
  840.   #--------------------------------------------------------------------------
  841.   # ● 生成指令列表
  842.   #--------------------------------------------------------------------------
  843.   def make_command_list
  844.     haveitem
  845.     add_command("宝石",     :gem, @havegem)
  846.     add_command(Equipplus.idgetitem($强化哈希表["特殊物品"][0]).name, :fangb, @havefangb)
  847.     add_command(Equipplus.idgetitem($强化哈希表["特殊物品"][1]).name, :fangj, @havefangj)
  848.     add_command("开始强化", :start)
  849.     add_command("取消强化", :cancel)
  850.   end
  851. end
  852. class Window_ItemList
  853.   #--------------------------------------------------------------------------
  854.   # ● 查询列表中是否含有此物品
  855.   #--------------------------------------------------------------------------
  856.   def include?(item)
  857.     case @category
  858.     when :item
  859.       item.is_a?(RPG::Item) && !item.key_item?
  860.     when :weapon
  861.       item.is_a?(RPG::Weapon)
  862.     when :armor
  863.       item.is_a?(RPG::Armor)
  864.     when :key_item
  865.       item.is_a?(RPG::Item) && item.key_item?
  866.     when :gem
  867.       itemid = item ? item.id : 0
  868.       itemid != 0 ? isgem(itemid) : false
  869.     else
  870.       false
  871.     end
  872.   end
  873.   
  874.   def isgem(itemid)
  875.     for i in $强化哈希表["宝石效果"]
  876.       return true if i[1] == itemid
  877.     end
  878.     false
  879.   end
  880. end
  881. #==============================================================================
  882. # ■ Window_Choosegem
  883. #------------------------------------------------------------------------------
  884. #  选择强化使用的宝石
  885. #==============================================================================

  886. class Window_Choosegem < Window_ItemList
  887.   #--------------------------------------------------------------------------
  888.   # ● 初始化对象
  889.   #--------------------------------------------------------------------------
  890.   def initialize()
  891.     super(0, 0, Graphics.width, fitting_height(2))
  892.     self.openness = 0
  893.     deactivate
  894.     @wufangwindow = nil
  895.     @qiangxz = nil
  896.     set_handler(:ok,     method(:on_ok))
  897.     set_handler(:cancel, method(:on_cancel))
  898.   end
  899.   
  900.   def wufangwindow=(wufangwindow)
  901.     @wufangwindow = wufangwindow
  902.   end
  903.   def qiangxz=(qiangxz)
  904.     @qiangxz = qiangxz
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # ● 开始输入的处理
  908.   #--------------------------------------------------------------------------
  909.   def start
  910.     self.category = :gem
  911.     self.y = (Graphics.height - height) / 2
  912.     refresh
  913.     select(0)
  914.     open
  915.     activate
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # ● 确定时的处理
  919.   #--------------------------------------------------------------------------
  920.   def on_ok
  921.     result = item ? item.id : 0
  922.     if result != 0
  923.      $usegem = true
  924.      $当前使用宝石id = result
  925.      for i in $强化哈希表["宝石效果"]
  926.        $当前使用宝石加成率 = i[0] if i[1] == $当前使用宝石id
  927.      end
  928.    else
  929.      $当前使用宝石加成率 = 0
  930.      $usegem = false
  931.     end
  932.     @wufangwindow.update_help
  933.     @qiangxz.activate
  934.     close
  935.   end
  936.   #--------------------------------------------------------------------------
  937.   # ● 查询此物品是否可用
  938.   #--------------------------------------------------------------------------
  939.   def enable?(item)
  940.     true
  941.   end
  942.   #--------------------------------------------------------------------------
  943.   # ● 取消时的处理
  944.   #--------------------------------------------------------------------------
  945.   def on_cancel
  946.     $当前使用宝石加成率 = 0
  947.     $usegem = false
  948.     @wufangwindow.update_help
  949.     @qiangxz.activate
  950.     close
  951.   end
  952. end
  953. #==============================================================================
  954. # ■ 强化系统DataManager
  955. #------------------------------------------------------------------------------
  956. #  将武器和防具数据保存入存档
  957. #==============================================================================
  958. module DataManager
  959.   #--------------------------------------------------------------------------
  960.   # ● 生成存档内容
  961.   #--------------------------------------------------------------------------
  962.   def self.make_save_contents
  963.     contents = {}
  964.     contents[:system]        = $game_system
  965.     contents[:timer]         = $game_timer
  966.     contents[:message]       = $game_message
  967.     contents[:switches]      = $game_switches
  968.     contents[:variables]     = $game_variables
  969.     contents[:self_switches] = $game_self_switches
  970.     contents[:actors]        = $game_actors
  971.     contents[:party]         = $game_party
  972.     contents[:troop]         = $game_troop
  973.     contents[:map]           = $game_map
  974.     contents[:player]        = $game_player
  975.     contents[:weapons]       = $data_weapons
  976.     contents[:armors]        = $data_armors
  977.     contents
  978.   end
  979.   #--------------------------------------------------------------------------
  980.   # ● 展开存档内容
  981.   #--------------------------------------------------------------------------
  982.   def self.extract_save_contents(contents)
  983.     $game_system        = contents[:system]
  984.     $game_timer         = contents[:timer]
  985.     $game_message       = contents[:message]
  986.     $game_switches      = contents[:switches]
  987.     $game_variables     = contents[:variables]
  988.     $game_self_switches = contents[:self_switches]
  989.     $game_actors        = contents[:actors]
  990.     $game_party         = contents[:party]
  991.     $game_troop         = contents[:troop]
  992.     $game_map           = contents[:map]
  993.     $game_player        = contents[:player]
  994.     $data_weapons       = contents[:weapons]
  995.     $data_armors        = contents[:armors]
  996.   end
  997. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-1-14 04:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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