查看: 2997|回复: 8

[已经解决] 装备耐久度脚本使用方法

[复制链接]
梦石
0
星屑
1410
在线时间
148 小时
注册时间
2018-3-24
回帖
113
发表于 2018-5-23 00:02:35 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 VIPArcher 于 2018-11-1 01:00 编辑

[pre lang="ruby"]#==============================================================================
#   XaiL System - Item Durability
#   Author: Nicke
#   Created: 23/07/2012
#   Edited: 28/08/2012
#   Version: 1.0b
#==============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
#
# This script is pretty extensive which means you need to configure it to
# get it as you want it.
#
# To setup a durability/max durability value for an item do the following in the
# notetag:
# <durability: n>
# <max_durability: n>
# Where n is a floated value (2.3, 2.5 for example).
#
# You can also enable/disable repairing for an item:
# <repairable: bool>
# Where bool is true or false.
# This option will be true as default if you don't specify it.
#
# To check an item's current durability value, do the following in a script call:
# $game_party.durability?(item_id, item_type)
# $game_party.durability?(1, :weapon)
# $game_party.durability?(2, :armor)
# $game_party.durability?(3, :item)
#
# All of those calls above will return the current durability value for each item.
# You can also check the max durability value as well:
# $game_party.max_durability?(item_id, item_type)
# $game_party.max_durability?(3, :item)
#
# Althought the shop is intended for repairing you can force repair an item
# without it costing any gold by the following script call:
# $game_party.change_durability(nil, :repair, 2, :weapon)
# This will repair item_id 2 for weapons without it costing any gold.
#
# Using the same method but with a different option you can damage your item
# by doing the following instead:
# $game_party.change_durability(value, type, item, item_type)
# $game_party.change_durability(0.5, :damage, 2, :weapon)
# This will damage item_id 2 for weapons by a value of 0.5.
#
# You can also restore durability value for an item:
# $game_party.change_durability(2.0, :restore, 2, :weapon)
# This will restore 2.0 durability value to the current value.
#
# You can check if an item can be repaired:
# $game_party.repairable?(1, :item)
#
# You can alter the repair/damage formula in the settings.
# Default for repairing is half the item's price.
# Default for damaging an item is a randomized value by 0.1-0.5 with a
# probability chance at 1/5.
#
# Current durability status for items will be displayed at the end of battle.
# This will only work for the default battle system at the moment.
# A few settings is located below to setup up this.
#
# *** Only for RPG Maker VX Ace. ***
#==============================================================================
($imported ||= {})["XAIL-ITEM-DURABILITY"] = true

module XAIL
  module ITEM_DURABILITY
  #--------------------------------------------------------------------------#
  # * Settings
  #--------------------------------------------------------------------------#
    # FONT = [name, size, color, bold, shadow]
    FONT = [["Anklada™", "Verdana"], 16, Color.new(255,225,255), true, true]

    # Show/hide option for the ahop scene.
    # DISPLAY = [show_help_icon, show_name, show_description,
    # show_type, show_amount]
    DISPLAY = [true, true, true, true, true]

    # Set the name of repair in the shop scene.
    # REPAIR_COMMAND = string
    REPAIR_COMMAND = "Repair"

    # Set the repair cost forumla.
    def self.repair_price(item)
      return item.price / 2
    end

    # Set the damage formula.
    def self.durability_damage
      return rand(5) == 0 ? rand(5).to_f/10 + 0.1 : 0
    end

    # USE_BROKEN = true/false
    # Should you be able to equip broken items.
    USE_BROKEN = false

    # TEXT_BROKEN = string
    # Set the text for a broken item. (Used in battle)
    TEXT_BROKEN = "Broken:"

    # DURABILITY_LOG = true/false
    # Display durability status at scene battle. (Default battle system)
    DURABILITY_LOG = true

    # LOG_WAIT = number
    # How many times should the durability log wait.
    LOG_WAIT = 3

  end
end
# *** Don't edit below unless you know what you are doing. ***
#==============================================================================#
# ** RPG::BaseItem
#==============================================================================#
class RPG::BaseItem

  attr_accessor :durability

  alias xail_item_durability_baseitem_init initialize
  def initialize(*args, &block)
    # // Method to initialize.
    xail_item_durability_baseitem_init(*args, &block)
    @durability = 0
  end

  def durability
    # // Method to check the item durability.
    @note.scan(/<(?:DURABILITY|durability):\s(\d+.\d+)>/i)
    return @durability unless @durability.nil?
    return ($1.to_f > 0.0 ? $1.to_f : 0.0)
  end

  def max_durability
    # // Method to check the item max durability.
    @note.scan(/<(?:MAX_DURABILITY|max_durability):\s(\d+.\d+)>/i)
    return ($1.to_f > 0.0 ? $1.to_f : 0.0)
  end

  def repairable
    # // Method to check if item is repairable.
    @note.scan(/<(?:REPAIRABLE|repairable):\s+(true|false)>/i)
    return false if durability == max_durability
    return true if $1.nil?
    return eval($1)
  end

end
#==============================================================================#
# ** Game_Party
#==============================================================================#
class Game_Party < Game_Unit

  def check_type(item_type)
    # // Method to check the item type.
    case item_type
    when :item   ; item_type = $data_items
    when :weapon ; item_type = $data_weapons
    when :armor  ; item_type = $data_armors
    end
    item_type
  end

  def durability?(item_id, item_type)
    # // Method to check the current durability of a specified id.
    item_type = check_type(item_type)
    item_type[item_id].durability unless item_type[item_id].nil?
  end

  def max_durability?(item_id, item_type)
    # // Method to check the maximum durability of a specified id.
    item_type = check_type(item_type)
    item_type[item_id].max_durability unless item_type[item_id].nil?
  end

  def change_durability(value, type, item_id, item_type)
    # // Method to change the durability value for an item.
    item_type = check_type(item_type)
    item = item_type[item_id]
    case type
    when :restore
      item.durability = (item.durability + value).clamp(0, item.max_durability)
    when :damage
      item.durability = (item.durability - value).clamp(0, item.max_durability)
    when :repair
      item.durability = item.max_durability
    end unless item.nil?
  end

  def repairable?(item_id, item_type)
    # // Method to check if an item can be repaired.
    item_type = check_type(item_type)
    item_type[item_id].repairable
  end

end
#==============================================================================#
# ** Game_Battler
#==============================================================================#
class Game_Battler < Game_BattlerBase

  alias xail_item_durability_gm_battler_execute_damage execute_damage
  def execute_damage(user)
    # // Method to execute damage.
    if user.is_a?(Game_Actor)
      r = Random.new
      r = r.rand(0..4)
      item = user.actor.equips[r]
      item_type = :armor ; item_type = :weapon if r == 0
      $game_party.change_durability(XAIL::ITEM_DURABILITY.durability_damage, :damage, item, item_type)
      if $game_party.durability?(item, item_type) == 0
        $game_actors[user.actor.id].change_equip(r, nil)
      end
    end
    xail_item_durability_gm_battler_execute_damage(user)
  end

end
#==============================================================================#
# ** Game_Actor
#==============================================================================#
class Game_Actor < Game_Battler

  def optimize_equipments
    # // Method override optimize equipments.
    clear_equipments
    equip_slots.size.times do |i|
      next if !equip_change_ok?(i)
      items = $game_party.equip_items.select do |item|
        item.etype_id == equip_slots &&
        equippable?(item) && item.performance >= 0 && item.durability != 0.0
      end
      change_equip(i, items.max_by {|item| item.performance })
    end
  end

end
#==============================================================================#
# ** Window_Help
#==============================================================================#
class Window_Help < Window_Base

  def set_durability_help(item)
    # // Method to set the item for window help.
    contents.font.name = XAIL::ITEM_DURABILITY::FONT[0]
    contents.font.bold = XAIL::ITEM_DURABILITY::FONT[3]
    contents.font.shadow = XAIL::ITEM_DURABILITY::FONT[4]
    contents.font.out_color = Color.new(0,0,0,255)
    if item
      icon = XAIL::ITEM_DURABILITY::DISPLAY[0] ? '\i[' + item.icon_index.to_s + ']' : ""
      name = XAIL::ITEM_DURABILITY::DISPLAY[1] ? '\c[2] »» ' + item.name + '\c[0]' : ""
      desc = XAIL::ITEM_DURABILITY::DISPLAY[2] ? item.description : ""
      weight = $imported["XAIL-INVENTORY-WEIGHT"] ? weight = " - Weight: #{item.weight}." : ""
      durability = " - Durability: #{item.durability} / #{item.max_durability}."
      if XAIL::ITEM_DURABILITY::DISPLAY[3]
        if item.is_a?(RPG::Weapon) ; item_type = " (" + $data_system.weapon_types[item.wtype_id] + ")" end
        if item.is_a?(RPG::Armor) ; item_type = " (" + $data_system.armor_types[item.etype_id] + ")" end
      else
        item_type = ""
      end
      new_line = "\n"
      item_text = icon + name + item_type.to_s + weight + durability + new_line + desc
    else
      item_text = ""
    end
    set_text(item_text)
  end

end
#==============================================================================
# ** Window_ShopCommand
#==============================================================================
class Window_ShopCommand < Window_HorzCommand

  def col_max
    # // Method to set col max.
    return 4
  end

  alias xail_item_durability_winshop_make_cmd_list make_command_list
  def make_command_list(*args, &block)
    # // Method to make command list.
    xail_item_durability_winshop_make_cmd_list(*args, &block)
    add_command(XAIL::ITEM_DURABILITY::REPAIR_COMMAND, :repair)
  end

end
#==============================================================================
# ** Window_ShopRepair
#==============================================================================
class Window_ShopRepair < Window_ItemList

  def initialize(x, y, width, height)
    # // Method to initialize.
    super(x, y, width, height)
  end

  def enable?(item)
    # // Method to check if a item is valid to be repair.
    item && XAIL::ITEM_DURABILITY.repair_price(item) <= $game_party.gold &&
    !$game_party.item_max?(item) && item.max_durability != item.durability
  end

  alias xail_item_durability_shop_update_help update_help
  def update_help(*args, &block)
    # // Method to check if a item is valid to be repair.
    xail_item_durability_shop_update_help(*args, &block)
    @help_window.set_durability_help(item) if @help_window
  end

end
#==============================================================================#
# ** Window_BattleLog
#==============================================================================#
class Window_BattleLog < Window_Selectable

  def display_durability(battler)
    # // Method to display durability status in battle.
    # i.e if a item has been broken.
    if battler.is_a?(Game_Actor)
      for i in 0..4
        item = battler.actor.equips
        item_type = :armor ; item_type = :weapon if i == 0
        if $game_party.durability?(item, item_type) == 0
          item_type = $game_party.check_type(item_type)
          item = item_type[item]
          item = XAIL::ITEM_DURABILITY::TEXT_BROKEN + " " + item.name
          add_text(sprintf(item))
          XAIL::ITEM_DURABILITY::LOG_WAIT.times do
            wait
          end
        end
      end
    end
  end

end
#==============================================================================#
# ** Window_EquipItem
#==============================================================================#
class Window_EquipItem < Window_ItemList

  alias xail_item_durability_win_equip_enable? enable?
  def enable?(item)
    # // Method to check if a item is enabled/disabled.
    return false if item.durability == 0 && !XAIL::ITEM_DURABILITY::USE_BROKEN unless item.nil?
    xail_item_durability_win_equip_enable?(item)
  end

end
#==============================================================================#
# ** Scene_Shop
#==============================================================================#
class Scene_Shop < Scene_MenuBase

  alias xail_item_durability_shop_start start
  def start(*args, &block)
    # // Method to start the scene.
    xail_item_durability_shop_start(*args, &block)
    create_repair_window
  end

  alias xail_item_durability_shop_create_cmd_win create_command_window
  def create_command_window(*args, &block)
    # // Method to create command window.
    xail_item_durability_shop_create_cmd_win(*args, &block)
    @command_window.set_handler(:repair, method(:command_repair))
  end

  def create_repair_window
    # // Method to create repair window.
    wy = @category_window.y + @category_window.height
    wh = Graphics.height - wy
    @repair_window = Window_ShopRepair.new(0, wy, Graphics.width, wh)
    @repair_window.viewport = @viewport
    @repair_window.help_window = @help_window
    @repair_window.hide
    @repair_window.set_handler(:ok,     method(:on_repair_ok))
    @repair_window.set_handler(:cancel, method(:on_repair_cancel))
    @category_window.item_window = @repair_window
  end

  def command_repair
    # // Method for command repair.
    @dummy_window.hide
    @category_window.show.activate
    @repair_window.show
    @repair_window.unselect
    @repair_window.refresh
  end

  def activate_repair
    # // Method to active command options.
    @repair_window.select(0)
    @category_window.show
    @repair_window.refresh
    @repair_window.show.activate
    @status_window.hide
  end

  alias xail_item_durability_shop_on_cat_ok on_category_ok
  def on_category_ok(*args, &block)
    # // Method for category ok.
    case @command_window.current_symbol
    when :repair
      activate_repair
    when :sell
      xail_item_durability_shop_on_cat_ok(*args, &block)
    end
  end

  alias xail_item_durability_shop_on_cat_cancel on_category_cancel
  def on_category_cancel(*args, &block)
    # // Method for category cancel.
    xail_item_durability_shop_on_cat_cancel(*args, &block)
    @repair_window.hide
  end

  def on_repair_ok
    # // Method to repair item.
    @item = @repair_window.item
    @status_window.item = @item
    @category_window.hide
    @repair_window.hide
    @number_window.set(@item, max_item, repair_price, currency_unit)
    @number_window.show.activate
    @status_window.show
  end

  def on_repair_cancel
    # // Method to cancel repair.
    @repair_window.unselect
    @category_window.activate
    @status_window.item = nil
    @help_window.clear
  end

  alias xail_item_durability_shop_on_number_ok on_number_ok
  def on_number_ok(*args, &block)
    # // Method on number ok.
    if @command_window.current_symbol == :repair
      do_repair(@number_window.number)
    end
    xail_item_durability_shop_on_number_ok(*args, &block)
  end

  alias xail_item_durability_shop_end_number_input end_number_input
  def end_number_input(*args, &block)
    # // Method to check input number.
    if @command_window.current_symbol == :repair
      activate_repair
    end
    xail_item_durability_shop_end_number_input(*args, &block)
  end

  def do_repair(number)
    # // Method to do repair.
    if @item.is_a?(RPG::Item)   ; item_type = :item     end
    if @item.is_a?(RPG::Weapon) ; item_type = :weapon   end
    if @item.is_a?(RPG::Armor)  ; item_type = :armor    end
    $game_party.lose_gold(number * repair_price)
    $game_party.change_durability(nil, :repair, @item.id, item_type)
    @repair_window.refresh
    @gold_window.refresh
    @status_window.refresh
    @help_window.refresh
  end

  def max_item
    # // Method to determine max item.
    $game_party.item_number(@item)
  end

  def repair_price
    # // Method to set the repair price for the item.
    XAIL::ITEM_DURABILITY.repair_price(@item)
  end

end
#==============================================================================#
# ** Scene_Battle
#==============================================================================#
class Scene_Battle < Scene_Base

  alias xail_item_durability_scene_battle_process_action_end process_action_end
  def process_action_end(*args, &block)
    # // Method when process end at scene battle.
    if XAIL::ITEM_DURABILITY::DURABILITY_LOG
      @log_window.display_durability(@subject)
      @log_window.wait_and_clear
    end
    xail_item_durability_scene_battle_process_action_end(*args, &block)
  end

end # END OF FILE

#=*==========================================================================*=#
# ** END OF FILE
#=*==========================================================================*=#[/pre]
梦石
0
星屑
1410
在线时间
148 小时
注册时间
2018-3-24
回帖
113
 楼主| 发表于 2018-5-23 00:03:22 | 显示全部楼层
求问大神上边装备脚本耐久的使用方法   越具体越好 谢谢
回复

使用道具 举报

梦石
0
星屑
1410
在线时间
148 小时
注册时间
2018-3-24
回帖
113
 楼主| 发表于 2018-5-23 11:08:41 | 显示全部楼层
这是别人发出来的脚本   由于不懂脚本清大神解析下
回复

使用道具 举报

梦石
0
星屑
39236
在线时间
11155 小时
注册时间
2009-3-15
回帖
4768
发表于 2018-5-23 13:03:22 | 显示全部楼层
#================================================= =============================
#XaiL System - Item耐久度
#作者:Nicke
#创建日期:23/07/2012
#Edited: 2012年12月28日
#版本:1.0b
#======================================= =======================================
#说明
#-------- -------------------------------------------------- -------------------
#要安装此脚本,请打开您的脚本编辑器并将此脚本
#复制/粘贴到下面的一个开放式插槽中?材料但以上?主要。记得保存。
##
这个脚本非常广泛,这意味着你需要将它配置为
#根据需要获取它。
#
#要设置项目的耐久性/最大耐久性值,请在
#notetag中执行以下操作:
#<durability:n>
#<max_durability:n>
#其中n是浮动值(例如2.3,2.5 )。
##
您也可以启用/禁用修复项目:
#<repairable:bool>
#其中布尔是true或false。
#如果你没有指定它,这个选项默认为true。
##
为了检查物品当前的持久性值,请在脚本调用中执行以下操作:
#$ game_party.durability?(item_id,item_type)
#$ game_party.durability?(1,:武器)
#$ game_party.durability?(2, :armor)
#$ game_party.durability?(3,:item)
#
#以上所有这些调用都会返回每个项目的当前耐久性值。
#你也可以检查最大耐久值,以及:
#$ game_party.max_durability(ITEM_ID,ITEM_TYPE)?
#$ game_party.max_durability(3:项目)?
#
#Althought店旨在修复可以强制修理项目
#没有它通过以下脚本调用花费任何黄金:
#$ game_party.change_durability(nil,:repair,2,:weapon)
#这将修复item_id 2的武器,而不需要花费任何金币。
##
使用相同的方法,但使用不同的选项,您可以
通过执行以下操作来损坏您的物品
##$ game_party.change_durability(value,type,item,item_type)
#$ game_party.change_durability(0.5,:伤害,2,:武器)
#这将使武器的item_id 2受到0.5的伤害。
##
你还可以恢复一个物品的持久性值:
#$ game_party.change_durability(2.0,:restore,2,:weapon)
#这会将2.0耐久性值恢复到当前值。
#
#你可以检查的项目可以修复:
#$ game_party.repairable(1:项目)? #
#
你可以改变设置的维修/伤害公式。
#修复的默认值是商品价格的一半。
#损坏项目的默认值是0.1-0.5的随机值,
#概率为1/5。
#
#当前物品的耐久性状态将在战斗结束时显示。
#此时此功能仅适用于默认的战斗系统。
#几个设置位于下面来设置这个。
##
***只适用于RPG Maker VX Ace。***

评分

参与人数 1赞 +1 收起 理由
够爱 + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
1410
在线时间
148 小时
注册时间
2018-3-24
回帖
113
 楼主| 发表于 2018-5-23 23:39:45 | 显示全部楼层
soulsaga 发表于 2018-5-23 13:03
#================================================= =============================
#XaiL System - I ...

谢谢大神   
回复

使用道具 举报

梦石
1
星屑
14374
在线时间
2109 小时
注册时间
2017-9-28
回帖
607
发表于 2018-5-25 23:21:20 | 显示全部楼层
你的问题真的很多。

[pre lang="ruby"]#==============================================================================
#   XaiL System - 物品耐久度
#   Author: Nicke
#   Created: 23/07/2012
#   Edited: 28/08/2012
#   Version: 1.0b
#==============================================================================
# 安装
# -----------------------------------------------------------------------------
# 安装此脚本的方法为:打开你工程的脚本编辑器,将此脚本复制/拷贝到▼ 插件脚本之下
# ▼ Main之上的位置。记得保存工程使脚本生效。
#
# 此脚本的设定内容相当多,意味着你需要自己去调整设定才能达到你想要的效果。
#
# 设置耐久度/最大耐久度的物品备注:
# <durability: n>
# <max_durability: n>
# n为带小数点的浮点数 (例如 2.3, 2.5 等).
#
# 该物品可以被修复/不可以被修复的物品备注:
# <repairable: true>
# <repairable: false>
# 不使用以上备注的物品,则默认为true.
#
# 使用以下脚本,可以检查物品当前的耐久度:
# $game_party.durability?(物品_id, 物品_类型)
# $game_party.durability?(1, :weapon)
# $game_party.durability?(2, :armor)
# $game_party.durability?(3, :item)
#
# 以上脚本全部会为每个物品返回一个当前耐久度的数值.
#
# 你也可以使用下面的脚本检查物品的最大耐久度:
# $game_party.max_durability?(物品_id, 物品_类型)
# $game_party.max_durability?(3, :item)
#
# 尽管玩家可以在商店中花钱修复,你还可以使用脚本来免费修复:
# $game_party.change_durability(nil, :repair, 2, :weapon)
# 此脚本代表:修复2号武器,且不消耗金钱.
#
# 损耗物品的耐久度:
# $game_party.change_durability(数值, 类型, 物品_id, 物品_类型)
# $game_party.change_durability(0.5, :damage, 2, :weapon)
# 此脚本代表:损耗2号武器0.5的耐久度.
#
# 存储物品耐久度的值:
# $game_party.change_durability(2.0, :restore, 2, :weapon)
# 这会将2.0耐久度的数值存储到当前数值.
#
# 检查某物品是否可以被修复:
# $game_party.repairable?(1, :item)
#
# 你可以在本脚本中的设定部分,设置修改/损坏的公式。
# 修复费用的默认值是商品价格的一半。
# 损坏项目的默认值是0.1-0.5的随机值,概率为1/5。
#
# 当前物品的耐久性状态将在战斗结束时显示。
# 此功能仅适用于默认的战斗系统。
#
# *** 仅用于 RPG Maker VX Ace. ***
#==============================================================================
($imported ||= {})["XAIL-ITEM-DURABILITY"] = true

module XAIL
  module ITEM_DURABILITY
  #--------------------------------------------------------------------------#
  # * Settings
  #--------------------------------------------------------------------------#
    # FONT = [字体名称, 字体大小, 颜色, 是否加粗, 是否有阴影]
    FONT = [["微软雅黑", "宋体"], 16, Color.new(255,225,255), true, true]

    # 帮助场景里显示/隐藏某些信息.
    # DISPLAY = [显示帮助图标, 显示名称, 显示介绍,
    # 显示类型, 显示数量]
    DISPLAY = [true, true, true, true, true]

    # 设置商店里修复的,名称.
    # REPAIR_COMMAND = 字符串
    REPAIR_COMMAND = "修复"

    # 修复费用的公式.
    def self.repair_price(item)
      return item.price / 2
    end

    # 设置伤害公式.
    def self.durability_damage
      return rand(5) == 0 ? rand(5).to_f/10 + 0.1 : 0
    end

    # USE_BROKEN = true/false
    # 是否可以使用已损坏的物品.
    USE_BROKEN = false

    # TEXT_BROKEN = 字符串
    # 已损坏物品显示的文字. (在战斗中显示)
    TEXT_BROKEN = "已损坏:"

    # DURABILITY_LOG = true/false
    # 是否在战斗场景中显示耐久度信息. (默认战斗系统)
    DURABILITY_LOG = true

    # LOG_WAIT = 数字
    # 耐久度信息显示的时间.
    LOG_WAIT = 3

  end
end
# *** Don't edit below unless you know what you are doing. ***
#==============================================================================#
# ** RPG::BaseItem
#==============================================================================#
class RPG::BaseItem

  attr_accessor :durability

  alias xail_item_durability_baseitem_init initialize
  def initialize(*args, &block)
    # // Method to initialize.
    xail_item_durability_baseitem_init(*args, &block)
    @durability = 0
  end

  def durability
    # // Method to check the item durability.
    @note.scan(/<(?:DURABILITY|durability):\s(\d+.\d+)>/i)
    return @durability unless @durability.nil?
    return ($1.to_f > 0.0 ? $1.to_f : 0.0)
  end

  def max_durability
    # // Method to check the item max durability.
    @note.scan(/<(?:MAX_DURABILITY|max_durability):\s(\d+.\d+)>/i)
    return ($1.to_f > 0.0 ? $1.to_f : 0.0)
  end

  def repairable
    # // Method to check if item is repairable.
    @note.scan(/<(?:REPAIRABLE|repairable):\s+(true|false)>/i)
    return false if durability == max_durability
    return true if $1.nil?
    return eval($1)
  end

end
#==============================================================================#
# ** Game_Party
#==============================================================================#
class Game_Party < Game_Unit

  def check_type(item_type)
    # // Method to check the item type.
    case item_type
    when :item   ; item_type = $data_items
    when :weapon ; item_type = $data_weapons
    when :armor  ; item_type = $data_armors
    end
    item_type
  end

  def durability?(item_id, item_type)
    # // Method to check the current durability of a specified id.
    item_type = check_type(item_type)
    item_type[item_id].durability unless item_type[item_id].nil?
  end

  def max_durability?(item_id, item_type)
    # // Method to check the maximum durability of a specified id.
    item_type = check_type(item_type)
    item_type[item_id].max_durability unless item_type[item_id].nil?
  end

  def change_durability(value, type, item_id, item_type)
    # // Method to change the durability value for an item.
    item_type = check_type(item_type)
    item = item_type[item_id]
    case type
    when :restore
      item.durability = (item.durability + value).clamp(0, item.max_durability)
    when :damage
      item.durability = (item.durability - value).clamp(0, item.max_durability)
    when :repair
      item.durability = item.max_durability
    end unless item.nil?
  end

  def repairable?(item_id, item_type)
    # // Method to check if an item can be repaired.
    item_type = check_type(item_type)
    item_type[item_id].repairable
  end

end
#==============================================================================#
# ** Game_Battler
#==============================================================================#
class Game_Battler < Game_BattlerBase

  alias xail_item_durability_gm_battler_execute_damage execute_damage
  def execute_damage(user)
    # // Method to execute damage.
    if user.is_a?(Game_Actor)
      r = Random.new
      r = r.rand(0..4)
      item = user.actor.equips[r]
      item_type = :armor ; item_type = :weapon if r == 0
      $game_party.change_durability(XAIL::ITEM_DURABILITY.durability_damage, :damage, item, item_type)
      if $game_party.durability?(item, item_type) == 0
        $game_actors[user.actor.id].change_equip(r, nil)
      end
    end
    xail_item_durability_gm_battler_execute_damage(user)
  end

end
#==============================================================================#
# ** Game_Actor
#==============================================================================#
class Game_Actor < Game_Battler

  def optimize_equipments
    # // Method override optimize equipments.
    clear_equipments
    equip_slots.size.times do |i|
      next if !equip_change_ok?(i)
      items = $game_party.equip_items.select do |item|
        item.etype_id == equip_slots &&
        equippable?(item) && item.performance >= 0 && item.durability != 0.0
      end
      change_equip(i, items.max_by {|item| item.performance })
    end
  end

end
#==============================================================================#
# ** Window_Help
#==============================================================================#
class Window_Help < Window_Base

  def set_durability_help(item)
    # // Method to set the item for window help.
    contents.font.name = XAIL::ITEM_DURABILITY::FONT[0]
    contents.font.bold = XAIL::ITEM_DURABILITY::FONT[3]
    contents.font.shadow = XAIL::ITEM_DURABILITY::FONT[4]
    contents.font.out_color = Color.new(0,0,0,255)
    if item
      icon = XAIL::ITEM_DURABILITY::DISPLAY[0] ? '\i[' + item.icon_index.to_s + ']' : ""
      name = XAIL::ITEM_DURABILITY::DISPLAY[1] ? '\c[2] ?? ' + item.name + '\c[0]' : ""
      desc = XAIL::ITEM_DURABILITY::DISPLAY[2] ? item.description : ""
      weight = $imported["XAIL-INVENTORY-WEIGHT"] ? weight = " - Weight: #{item.weight}." : ""
      durability = " - Durability: #{item.durability} / #{item.max_durability}."
      if XAIL::ITEM_DURABILITY::DISPLAY[3]
        if item.is_a?(RPG::Weapon) ; item_type = " (" + $data_system.weapon_types[item.wtype_id] + ")" end
        if item.is_a?(RPG::Armor) ; item_type = " (" + $data_system.armor_types[item.etype_id] + ")" end
      else
        item_type = ""
      end
      new_line = "\n"
      item_text = icon + name + item_type.to_s + weight + durability + new_line + desc
    else
      item_text = ""
    end
    set_text(item_text)
  end

end
#==============================================================================
# ** Window_ShopCommand
#==============================================================================
class Window_ShopCommand < Window_HorzCommand

  def col_max
    # // Method to set col max.
    return 4
  end

  alias xail_item_durability_winshop_make_cmd_list make_command_list
  def make_command_list(*args, &block)
    # // Method to make command list.
    xail_item_durability_winshop_make_cmd_list(*args, &block)
    add_command(XAIL::ITEM_DURABILITY::REPAIR_COMMAND, :repair)
  end

end
#==============================================================================
# ** Window_ShopRepair
#==============================================================================
class Window_ShopRepair < Window_ItemList

  def initialize(x, y, width, height)
    # // Method to initialize.
    super(x, y, width, height)
  end

  def enable?(item)
    # // Method to check if a item is valid to be repair.
    item && XAIL::ITEM_DURABILITY.repair_price(item) <= $game_party.gold &&
    !$game_party.item_max?(item) && item.max_durability != item.durability
  end

  alias xail_item_durability_shop_update_help update_help
  def update_help(*args, &block)
    # // Method to check if a item is valid to be repair.
    xail_item_durability_shop_update_help(*args, &block)
    @help_window.set_durability_help(item) if @help_window
  end

end
#==============================================================================#
# ** Window_BattleLog
#==============================================================================#
class Window_BattleLog < Window_Selectable

  def display_durability(battler)
    # // Method to display durability status in battle.
    # i.e if a item has been broken.
    if battler.is_a?(Game_Actor)
      for i in 0..4
        item = battler.actor.equips
        item_type = :armor ; item_type = :weapon if i == 0
        if $game_party.durability?(item, item_type) == 0
          item_type = $game_party.check_type(item_type)
          item = item_type[item]
          item = XAIL::ITEM_DURABILITY::TEXT_BROKEN + " " + item.name
          add_text(sprintf(item))
          XAIL::ITEM_DURABILITY::LOG_WAIT.times do
            wait
          end
        end
      end
    end
  end

end
#==============================================================================#
# ** Window_EquipItem
#==============================================================================#
class Window_EquipItem < Window_ItemList

  alias xail_item_durability_win_equip_enable? enable?
  def enable?(item)
    # // Method to check if a item is enabled/disabled.
    return false if item.durability == 0 && !XAIL::ITEM_DURABILITY::USE_BROKEN unless item.nil?
    xail_item_durability_win_equip_enable?(item)
  end

end
#==============================================================================#
# ** Scene_Shop
#==============================================================================#
class Scene_Shop < Scene_MenuBase

  alias xail_item_durability_shop_start start
  def start(*args, &block)
    # // Method to start the scene.
    xail_item_durability_shop_start(*args, &block)
    create_repair_window
  end

  alias xail_item_durability_shop_create_cmd_win create_command_window
  def create_command_window(*args, &block)
    # // Method to create command window.
    xail_item_durability_shop_create_cmd_win(*args, &block)
    @command_window.set_handler(:repair, method(:command_repair))
  end

  def create_repair_window
    # // Method to create repair window.
    wy = @category_window.y + @category_window.height
    wh = Graphics.height - wy
    @repair_window = Window_ShopRepair.new(0, wy, Graphics.width, wh)
    @repair_window.viewport = @viewport
    @repair_window.help_window = @help_window
    @repair_window.hide
    @repair_window.set_handler(:ok,     method(:on_repair_ok))
    @repair_window.set_handler(:cancel, method(:on_repair_cancel))
    @category_window.item_window = @repair_window
  end

  def command_repair
    # // Method for command repair.
    @dummy_window.hide
    @category_window.show.activate
    @repair_window.show
    @repair_window.unselect
    @repair_window.refresh
  end

  def activate_repair
    # // Method to active command options.
    @repair_window.select(0)
    @category_window.show
    @repair_window.refresh
    @repair_window.show.activate
    @status_window.hide
  end

  alias xail_item_durability_shop_on_cat_ok on_category_ok
  def on_category_ok(*args, &block)
    # // Method for category ok.
    case @command_window.current_symbol
    when :repair
      activate_repair
    when :sell
      xail_item_durability_shop_on_cat_ok(*args, &block)
    end
  end

  alias xail_item_durability_shop_on_cat_cancel on_category_cancel
  def on_category_cancel(*args, &block)
    # // Method for category cancel.
    xail_item_durability_shop_on_cat_cancel(*args, &block)
    @repair_window.hide
  end

  def on_repair_ok
    # // Method to repair item.
    @item = @repair_window.item
    @status_window.item = @item
    @category_window.hide
    @repair_window.hide
    @number_window.set(@item, max_item, repair_price, currency_unit)
    @number_window.show.activate
    @status_window.show
  end

  def on_repair_cancel
    # // Method to cancel repair.
    @repair_window.unselect
    @category_window.activate
    @status_window.item = nil
    @help_window.clear
  end

  alias xail_item_durability_shop_on_number_ok on_number_ok
  def on_number_ok(*args, &block)
    # // Method on number ok.
    if @command_window.current_symbol == :repair
      do_repair(@number_window.number)
    end
    xail_item_durability_shop_on_number_ok(*args, &block)
  end

  alias xail_item_durability_shop_end_number_input end_number_input
  def end_number_input(*args, &block)
    # // Method to check input number.
    if @command_window.current_symbol == :repair
      activate_repair
    end
    xail_item_durability_shop_end_number_input(*args, &block)
  end

  def do_repair(number)
    # // Method to do repair.
    if @item.is_a?(RPG::Item)   ; item_type = :item     end
    if @item.is_a?(RPG::Weapon) ; item_type = :weapon   end
    if @item.is_a?(RPG::Armor)  ; item_type = :armor    end
    $game_party.lose_gold(number * repair_price)
    $game_party.change_durability(nil, :repair, @item.id, item_type)
    @repair_window.refresh
    @gold_window.refresh
    @status_window.refresh
    @help_window.refresh
  end

  def max_item
    # // Method to determine max item.
    $game_party.item_number(@item)
  end

  def repair_price
    # // Method to set the repair price for the item.
    XAIL::ITEM_DURABILITY.repair_price(@item)
  end

end
#==============================================================================#
# ** Scene_Battle
#==============================================================================#
class Scene_Battle < Scene_Base

  alias xail_item_durability_scene_battle_process_action_end process_action_end
  def process_action_end(*args, &block)
    # // Method when process end at scene battle.
    if XAIL::ITEM_DURABILITY::DURABILITY_LOG
      @log_window.display_durability(@subject)
      @log_window.wait_and_clear
    end
    xail_item_durability_scene_battle_process_action_end(*args, &block)
  end

end # END OF FILE

#=*==========================================================================*=#
# ** END OF FILE
#=*==========================================================================*=#[/pre]
VA外站脚本汉化群:226308173   |    部分远古文件备份:https://wwzv.lanzoue.com/b02rac5pc  密码:acgm
回复

使用道具 举报

梦石
0
星屑
1410
在线时间
148 小时
注册时间
2018-3-24
回帖
113
 楼主| 发表于 2018-5-27 01:12:04 | 显示全部楼层
Nil2018 发表于 2018-5-25 23:21
你的问题真的很多。

#==============================================================================

正在着手做大型AX游戏  自己脚本又不懂所以系统等问题比较多需要解决的
回复

使用道具 举报

梦石
0
星屑
1410
在线时间
148 小时
注册时间
2018-3-24
回帖
113
 楼主| 发表于 2018-5-28 11:26:14 | 显示全部楼层
Nil2018 发表于 2018-5-25 23:21
你的问题真的很多。

#==============================================================================

在第181行出现错误 请问怎么解决

点评

向脚本大佬砸钱。  发表于 2018-5-29 22:04
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部