查看: 3040|回复: 8

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

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

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

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

×
本帖最后由 VIPArcher 于 2018-11-1 01:00 编辑
  1. #==============================================================================
  2. #   XaiL System - Item Durability
  3. #   Author: Nicke
  4. #   Created: 23/07/2012
  5. #   Edited: 28/08/2012
  6. #   Version: 1.0b
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ? Materials but above ? Main. Remember to save.
  12. #
  13. # This script is pretty extensive which means you need to configure it to
  14. # get it as you want it.
  15. #
  16. # To setup a durability/max durability value for an item do the following in the
  17. # notetag:
  18. # <durability: n>
  19. # <max_durability: n>
  20. # Where n is a floated value (2.3, 2.5 for example).
  21. #
  22. # You can also enable/disable repairing for an item:
  23. # <repairable: bool>
  24. # Where bool is true or false.
  25. # This option will be true as default if you don't specify it.
  26. #
  27. # To check an item's current durability value, do the following in a script call:
  28. # $game_party.durability?(item_id, item_type)
  29. # $game_party.durability?(1, :weapon)
  30. # $game_party.durability?(2, :armor)
  31. # $game_party.durability?(3, :item)
  32. #
  33. # All of those calls above will return the current durability value for each item.
  34. # You can also check the max durability value as well:
  35. # $game_party.max_durability?(item_id, item_type)
  36. # $game_party.max_durability?(3, :item)
  37. #
  38. # Althought the shop is intended for repairing you can force repair an item
  39. # without it costing any gold by the following script call:
  40. # $game_party.change_durability(nil, :repair, 2, :weapon)
  41. # This will repair item_id 2 for weapons without it costing any gold.
  42. #
  43. # Using the same method but with a different option you can damage your item
  44. # by doing the following instead:
  45. # $game_party.change_durability(value, type, item, item_type)
  46. # $game_party.change_durability(0.5, :damage, 2, :weapon)
  47. # This will damage item_id 2 for weapons by a value of 0.5.
  48. #
  49. # You can also restore durability value for an item:
  50. # $game_party.change_durability(2.0, :restore, 2, :weapon)
  51. # This will restore 2.0 durability value to the current value.
  52. #
  53. # You can check if an item can be repaired:
  54. # $game_party.repairable?(1, :item)
  55. #
  56. # You can alter the repair/damage formula in the settings.
  57. # Default for repairing is half the item's price.
  58. # Default for damaging an item is a randomized value by 0.1-0.5 with a
  59. # probability chance at 1/5.
  60. #
  61. # Current durability status for items will be displayed at the end of battle.
  62. # This will only work for the default battle system at the moment.
  63. # A few settings is located below to setup up this.
  64. #
  65. # *** Only for RPG Maker VX Ace. ***
  66. #==============================================================================
  67. ($imported ||= {})["XAIL-ITEM-DURABILITY"] = true

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

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

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

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

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

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

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

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

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

  102.   end
  103. end
  104. # *** Don't edit below unless you know what you are doing. ***
  105. #==============================================================================#
  106. # ** RPG::BaseItem
  107. #==============================================================================#
  108. class RPG::BaseItem

  109.   attr_accessor :durability

  110.   alias xail_item_durability_baseitem_init initialize
  111.   def initialize(*args, &block)
  112.     # // Method to initialize.
  113.     xail_item_durability_baseitem_init(*args, &block)
  114.     @durability = 0
  115.   end

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

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

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

  134. end
  135. #==============================================================================#
  136. # ** Game_Party
  137. #==============================================================================#
  138. class Game_Party < Game_Unit

  139.   def check_type(item_type)
  140.     # // Method to check the item type.
  141.     case item_type
  142.     when :item   ; item_type = $data_items
  143.     when :weapon ; item_type = $data_weapons
  144.     when :armor  ; item_type = $data_armors
  145.     end
  146.     item_type
  147.   end

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

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

  158.   def change_durability(value, type, item_id, item_type)
  159.     # // Method to change the durability value for an item.
  160.     item_type = check_type(item_type)
  161.     item = item_type[item_id]
  162.     case type
  163.     when :restore
  164.       item.durability = (item.durability + value).clamp(0, item.max_durability)
  165.     when :damage
  166.       item.durability = (item.durability - value).clamp(0, item.max_durability)
  167.     when :repair
  168.       item.durability = item.max_durability
  169.     end unless item.nil?
  170.   end

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

  176. end
  177. #==============================================================================#
  178. # ** Game_Battler
  179. #==============================================================================#
  180. class Game_Battler < Game_BattlerBase

  181.   alias xail_item_durability_gm_battler_execute_damage execute_damage
  182.   def execute_damage(user)
  183.     # // Method to execute damage.
  184.     if user.is_a?(Game_Actor)
  185.       r = Random.new
  186.       r = r.rand(0..4)
  187.       item = user.actor.equips[r]
  188.       item_type = :armor ; item_type = :weapon if r == 0
  189.       $game_party.change_durability(XAIL::ITEM_DURABILITY.durability_damage, :damage, item, item_type)
  190.       if $game_party.durability?(item, item_type) == 0
  191.         $game_actors[user.actor.id].change_equip(r, nil)
  192.       end
  193.     end
  194.     xail_item_durability_gm_battler_execute_damage(user)
  195.   end

  196. end
  197. #==============================================================================#
  198. # ** Game_Actor
  199. #==============================================================================#
  200. class Game_Actor < Game_Battler

  201.   def optimize_equipments
  202.     # // Method override optimize equipments.
  203.     clear_equipments
  204.     equip_slots.size.times do |i|
  205.       next if !equip_change_ok?(i)
  206.       items = $game_party.equip_items.select do |item|
  207.         item.etype_id == equip_slots[i] &&
  208.         equippable?(item) && item.performance >= 0 && item.durability != 0.0
  209.       end
  210.       change_equip(i, items.max_by {|item| item.performance })
  211.     end
  212.   end

  213. end
  214. #==============================================================================#
  215. # ** Window_Help
  216. #==============================================================================#
  217. class Window_Help < Window_Base

  218.   def set_durability_help(item)
  219.     # // Method to set the item for window help.
  220.     contents.font.name = XAIL::ITEM_DURABILITY::FONT[0]
  221.     contents.font.bold = XAIL::ITEM_DURABILITY::FONT[3]
  222.     contents.font.shadow = XAIL::ITEM_DURABILITY::FONT[4]
  223.     contents.font.out_color = Color.new(0,0,0,255)
  224.     if item
  225.       icon = XAIL::ITEM_DURABILITY::DISPLAY[0] ? '\i[' + item.icon_index.to_s + ']' : ""
  226.       name = XAIL::ITEM_DURABILITY::DISPLAY[1] ? '\c[2] »» ' + item.name + '\c[0]' : ""
  227.       desc = XAIL::ITEM_DURABILITY::DISPLAY[2] ? item.description : ""
  228.       weight = $imported["XAIL-INVENTORY-WEIGHT"] ? weight = " - Weight: #{item.weight}." : ""
  229.       durability = " - Durability: #{item.durability} / #{item.max_durability}."
  230.       if XAIL::ITEM_DURABILITY::DISPLAY[3]
  231.         if item.is_a?(RPG::Weapon) ; item_type = " (" + $data_system.weapon_types[item.wtype_id] + ")" end
  232.         if item.is_a?(RPG::Armor) ; item_type = " (" + $data_system.armor_types[item.etype_id] + ")" end
  233.       else
  234.         item_type = ""
  235.       end
  236.       new_line = "\n"
  237.       item_text = icon + name + item_type.to_s + weight + durability + new_line + desc
  238.     else
  239.       item_text = ""
  240.     end
  241.     set_text(item_text)
  242.   end

  243. end
  244. #==============================================================================
  245. # ** Window_ShopCommand
  246. #==============================================================================
  247. class Window_ShopCommand < Window_HorzCommand

  248.   def col_max
  249.     # // Method to set col max.
  250.     return 4
  251.   end

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

  258. end
  259. #==============================================================================
  260. # ** Window_ShopRepair
  261. #==============================================================================
  262. class Window_ShopRepair < Window_ItemList

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

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

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

  278. end
  279. #==============================================================================#
  280. # ** Window_BattleLog
  281. #==============================================================================#
  282. class Window_BattleLog < Window_Selectable

  283.   def display_durability(battler)
  284.     # // Method to display durability status in battle.
  285.     # i.e if a item has been broken.
  286.     if battler.is_a?(Game_Actor)
  287.       for i in 0..4
  288.         item = battler.actor.equips[i]
  289.         item_type = :armor ; item_type = :weapon if i == 0
  290.         if $game_party.durability?(item, item_type) == 0
  291.           item_type = $game_party.check_type(item_type)
  292.           item = item_type[item]
  293.           item = XAIL::ITEM_DURABILITY::TEXT_BROKEN + " " + item.name
  294.           add_text(sprintf(item))
  295.           XAIL::ITEM_DURABILITY::LOG_WAIT.times do
  296.             wait
  297.           end
  298.         end
  299.       end
  300.     end
  301.   end

  302. end
  303. #==============================================================================#
  304. # ** Window_EquipItem
  305. #==============================================================================#
  306. class Window_EquipItem < Window_ItemList

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

  313. end
  314. #==============================================================================#
  315. # ** Scene_Shop
  316. #==============================================================================#
  317. class Scene_Shop < Scene_MenuBase

  318.   alias xail_item_durability_shop_start start
  319.   def start(*args, &block)
  320.     # // Method to start the scene.
  321.     xail_item_durability_shop_start(*args, &block)
  322.     create_repair_window
  323.   end

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

  330.   def create_repair_window
  331.     # // Method to create repair window.
  332.     wy = @category_window.y + @category_window.height
  333.     wh = Graphics.height - wy
  334.     @repair_window = Window_ShopRepair.new(0, wy, Graphics.width, wh)
  335.     @repair_window.viewport = @viewport
  336.     @repair_window.help_window = @help_window
  337.     @repair_window.hide
  338.     @repair_window.set_handler(:ok,     method(:on_repair_ok))
  339.     @repair_window.set_handler(:cancel, method(:on_repair_cancel))
  340.     @category_window.item_window = @repair_window
  341.   end

  342.   def command_repair
  343.     # // Method for command repair.
  344.     @dummy_window.hide
  345.     @category_window.show.activate
  346.     @repair_window.show
  347.     @repair_window.unselect
  348.     @repair_window.refresh
  349.   end

  350.   def activate_repair
  351.     # // Method to active command options.
  352.     @repair_window.select(0)
  353.     @category_window.show
  354.     @repair_window.refresh
  355.     @repair_window.show.activate
  356.     @status_window.hide
  357.   end

  358.   alias xail_item_durability_shop_on_cat_ok on_category_ok
  359.   def on_category_ok(*args, &block)
  360.     # // Method for category ok.
  361.     case @command_window.current_symbol
  362.     when :repair
  363.       activate_repair
  364.     when :sell
  365.       xail_item_durability_shop_on_cat_ok(*args, &block)
  366.     end
  367.   end

  368.   alias xail_item_durability_shop_on_cat_cancel on_category_cancel
  369.   def on_category_cancel(*args, &block)
  370.     # // Method for category cancel.
  371.     xail_item_durability_shop_on_cat_cancel(*args, &block)
  372.     @repair_window.hide
  373.   end

  374.   def on_repair_ok
  375.     # // Method to repair item.
  376.     @item = @repair_window.item
  377.     @status_window.item = @item
  378.     @category_window.hide
  379.     @repair_window.hide
  380.     @number_window.set(@item, max_item, repair_price, currency_unit)
  381.     @number_window.show.activate
  382.     @status_window.show
  383.   end

  384.   def on_repair_cancel
  385.     # // Method to cancel repair.
  386.     @repair_window.unselect
  387.     @category_window.activate
  388.     @status_window.item = nil
  389.     @help_window.clear
  390.   end

  391.   alias xail_item_durability_shop_on_number_ok on_number_ok
  392.   def on_number_ok(*args, &block)
  393.     # // Method on number ok.
  394.     if @command_window.current_symbol == :repair
  395.       do_repair(@number_window.number)
  396.     end
  397.     xail_item_durability_shop_on_number_ok(*args, &block)
  398.   end

  399.   alias xail_item_durability_shop_end_number_input end_number_input
  400.   def end_number_input(*args, &block)
  401.     # // Method to check input number.
  402.     if @command_window.current_symbol == :repair
  403.       activate_repair
  404.     end
  405.     xail_item_durability_shop_end_number_input(*args, &block)
  406.   end

  407.   def do_repair(number)
  408.     # // Method to do repair.
  409.     if @item.is_a?(RPG::Item)   ; item_type = :item     end
  410.     if @item.is_a?(RPG::Weapon) ; item_type = :weapon   end
  411.     if @item.is_a?(RPG::Armor)  ; item_type = :armor    end
  412.     $game_party.lose_gold(number * repair_price)
  413.     $game_party.change_durability(nil, :repair, @item.id, item_type)
  414.     @repair_window.refresh
  415.     @gold_window.refresh
  416.     @status_window.refresh
  417.     @help_window.refresh
  418.   end

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

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

  427. end
  428. #==============================================================================#
  429. # ** Scene_Battle
  430. #==============================================================================#
  431. class Scene_Battle < Scene_Base

  432.   alias xail_item_durability_scene_battle_process_action_end process_action_end
  433.   def process_action_end(*args, &block)
  434.     # // Method when process end at scene battle.
  435.     if XAIL::ITEM_DURABILITY::DURABILITY_LOG
  436.       @log_window.display_durability(@subject)
  437.       @log_window.wait_and_clear
  438.     end
  439.     xail_item_durability_scene_battle_process_action_end(*args, &block)
  440.   end

  441. end # END OF FILE

  442. #=*==========================================================================*=#
  443. # ** END OF FILE
  444. #=*==========================================================================*=#
复制代码
梦石
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
星屑
39336
在线时间
11161 小时
注册时间
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
星屑
14389
在线时间
2110 小时
注册时间
2017-9-28
回帖
607
发表于 2018-5-25 23:21:20 | 显示全部楼层
你的问题真的很多。

  1. #==============================================================================
  2. #   XaiL System - 物品耐久度
  3. #   Author: Nicke
  4. #   Created: 23/07/2012
  5. #   Edited: 28/08/2012
  6. #   Version: 1.0b
  7. #==============================================================================
  8. # 安装
  9. # -----------------------------------------------------------------------------
  10. # 安装此脚本的方法为:打开你工程的脚本编辑器,将此脚本复制/拷贝到▼ 插件脚本之下
  11. # ▼ Main之上的位置。记得保存工程使脚本生效。
  12. #
  13. # 此脚本的设定内容相当多,意味着你需要自己去调整设定才能达到你想要的效果。
  14. #
  15. # 设置耐久度/最大耐久度的物品备注:
  16. # <durability: n>
  17. # <max_durability: n>
  18. # n为带小数点的浮点数 (例如 2.3, 2.5 等).
  19. #
  20. # 该物品可以被修复/不可以被修复的物品备注:
  21. # <repairable: true>
  22. # <repairable: false>
  23. # 不使用以上备注的物品,则默认为true.
  24. #
  25. # 使用以下脚本,可以检查物品当前的耐久度:
  26. # $game_party.durability?(物品_id, 物品_类型)
  27. # $game_party.durability?(1, :weapon)
  28. # $game_party.durability?(2, :armor)
  29. # $game_party.durability?(3, :item)
  30. #
  31. # 以上脚本全部会为每个物品返回一个当前耐久度的数值.
  32. #
  33. # 你也可以使用下面的脚本检查物品的最大耐久度:
  34. # $game_party.max_durability?(物品_id, 物品_类型)
  35. # $game_party.max_durability?(3, :item)
  36. #
  37. # 尽管玩家可以在商店中花钱修复,你还可以使用脚本来免费修复:
  38. # $game_party.change_durability(nil, :repair, 2, :weapon)
  39. # 此脚本代表:修复2号武器,且不消耗金钱.
  40. #
  41. # 损耗物品的耐久度:
  42. # $game_party.change_durability(数值, 类型, 物品_id, 物品_类型)
  43. # $game_party.change_durability(0.5, :damage, 2, :weapon)
  44. # 此脚本代表:损耗2号武器0.5的耐久度.
  45. #
  46. # 存储物品耐久度的值:
  47. # $game_party.change_durability(2.0, :restore, 2, :weapon)
  48. # 这会将2.0耐久度的数值存储到当前数值.
  49. #
  50. # 检查某物品是否可以被修复:
  51. # $game_party.repairable?(1, :item)
  52. #
  53. # 你可以在本脚本中的设定部分,设置修改/损坏的公式。
  54. # 修复费用的默认值是商品价格的一半。
  55. # 损坏项目的默认值是0.1-0.5的随机值,概率为1/5。
  56. #
  57. # 当前物品的耐久性状态将在战斗结束时显示。
  58. # 此功能仅适用于默认的战斗系统。
  59. #
  60. # *** 仅用于 RPG Maker VX Ace. ***
  61. #==============================================================================
  62. ($imported ||= {})["XAIL-ITEM-DURABILITY"] = true

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

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

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

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

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

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

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

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

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

  97.   end
  98. end
  99. # *** Don't edit below unless you know what you are doing. ***
  100. #==============================================================================#
  101. # ** RPG::BaseItem
  102. #==============================================================================#
  103. class RPG::BaseItem

  104.   attr_accessor :durability

  105.   alias xail_item_durability_baseitem_init initialize
  106.   def initialize(*args, &block)
  107.     # // Method to initialize.
  108.     xail_item_durability_baseitem_init(*args, &block)
  109.     @durability = 0
  110.   end

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

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

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

  129. end
  130. #==============================================================================#
  131. # ** Game_Party
  132. #==============================================================================#
  133. class Game_Party < Game_Unit

  134.   def check_type(item_type)
  135.     # // Method to check the item type.
  136.     case item_type
  137.     when :item   ; item_type = $data_items
  138.     when :weapon ; item_type = $data_weapons
  139.     when :armor  ; item_type = $data_armors
  140.     end
  141.     item_type
  142.   end

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

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

  153.   def change_durability(value, type, item_id, item_type)
  154.     # // Method to change the durability value for an item.
  155.     item_type = check_type(item_type)
  156.     item = item_type[item_id]
  157.     case type
  158.     when :restore
  159.       item.durability = (item.durability + value).clamp(0, item.max_durability)
  160.     when :damage
  161.       item.durability = (item.durability - value).clamp(0, item.max_durability)
  162.     when :repair
  163.       item.durability = item.max_durability
  164.     end unless item.nil?
  165.   end

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

  171. end
  172. #==============================================================================#
  173. # ** Game_Battler
  174. #==============================================================================#
  175. class Game_Battler < Game_BattlerBase

  176.   alias xail_item_durability_gm_battler_execute_damage execute_damage
  177.   def execute_damage(user)
  178.     # // Method to execute damage.
  179.     if user.is_a?(Game_Actor)
  180.       r = Random.new
  181.       r = r.rand(0..4)
  182.       item = user.actor.equips[r]
  183.       item_type = :armor ; item_type = :weapon if r == 0
  184.       $game_party.change_durability(XAIL::ITEM_DURABILITY.durability_damage, :damage, item, item_type)
  185.       if $game_party.durability?(item, item_type) == 0
  186.         $game_actors[user.actor.id].change_equip(r, nil)
  187.       end
  188.     end
  189.     xail_item_durability_gm_battler_execute_damage(user)
  190.   end

  191. end
  192. #==============================================================================#
  193. # ** Game_Actor
  194. #==============================================================================#
  195. class Game_Actor < Game_Battler

  196.   def optimize_equipments
  197.     # // Method override optimize equipments.
  198.     clear_equipments
  199.     equip_slots.size.times do |i|
  200.       next if !equip_change_ok?(i)
  201.       items = $game_party.equip_items.select do |item|
  202.         item.etype_id == equip_slots[i] &&
  203.         equippable?(item) && item.performance >= 0 && item.durability != 0.0
  204.       end
  205.       change_equip(i, items.max_by {|item| item.performance })
  206.     end
  207.   end

  208. end
  209. #==============================================================================#
  210. # ** Window_Help
  211. #==============================================================================#
  212. class Window_Help < Window_Base

  213.   def set_durability_help(item)
  214.     # // Method to set the item for window help.
  215.     contents.font.name = XAIL::ITEM_DURABILITY::FONT[0]
  216.     contents.font.bold = XAIL::ITEM_DURABILITY::FONT[3]
  217.     contents.font.shadow = XAIL::ITEM_DURABILITY::FONT[4]
  218.     contents.font.out_color = Color.new(0,0,0,255)
  219.     if item
  220.       icon = XAIL::ITEM_DURABILITY::DISPLAY[0] ? '\i[' + item.icon_index.to_s + ']' : ""
  221.       name = XAIL::ITEM_DURABILITY::DISPLAY[1] ? '\c[2] ?? ' + item.name + '\c[0]' : ""
  222.       desc = XAIL::ITEM_DURABILITY::DISPLAY[2] ? item.description : ""
  223.       weight = $imported["XAIL-INVENTORY-WEIGHT"] ? weight = " - Weight: #{item.weight}." : ""
  224.       durability = " - Durability: #{item.durability} / #{item.max_durability}."
  225.       if XAIL::ITEM_DURABILITY::DISPLAY[3]
  226.         if item.is_a?(RPG::Weapon) ; item_type = " (" + $data_system.weapon_types[item.wtype_id] + ")" end
  227.         if item.is_a?(RPG::Armor) ; item_type = " (" + $data_system.armor_types[item.etype_id] + ")" end
  228.       else
  229.         item_type = ""
  230.       end
  231.       new_line = "\n"
  232.       item_text = icon + name + item_type.to_s + weight + durability + new_line + desc
  233.     else
  234.       item_text = ""
  235.     end
  236.     set_text(item_text)
  237.   end

  238. end
  239. #==============================================================================
  240. # ** Window_ShopCommand
  241. #==============================================================================
  242. class Window_ShopCommand < Window_HorzCommand

  243.   def col_max
  244.     # // Method to set col max.
  245.     return 4
  246.   end

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

  253. end
  254. #==============================================================================
  255. # ** Window_ShopRepair
  256. #==============================================================================
  257. class Window_ShopRepair < Window_ItemList

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

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

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

  273. end
  274. #==============================================================================#
  275. # ** Window_BattleLog
  276. #==============================================================================#
  277. class Window_BattleLog < Window_Selectable

  278.   def display_durability(battler)
  279.     # // Method to display durability status in battle.
  280.     # i.e if a item has been broken.
  281.     if battler.is_a?(Game_Actor)
  282.       for i in 0..4
  283.         item = battler.actor.equips[i]
  284.         item_type = :armor ; item_type = :weapon if i == 0
  285.         if $game_party.durability?(item, item_type) == 0
  286.           item_type = $game_party.check_type(item_type)
  287.           item = item_type[item]
  288.           item = XAIL::ITEM_DURABILITY::TEXT_BROKEN + " " + item.name
  289.           add_text(sprintf(item))
  290.           XAIL::ITEM_DURABILITY::LOG_WAIT.times do
  291.             wait
  292.           end
  293.         end
  294.       end
  295.     end
  296.   end

  297. end
  298. #==============================================================================#
  299. # ** Window_EquipItem
  300. #==============================================================================#
  301. class Window_EquipItem < Window_ItemList

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

  308. end
  309. #==============================================================================#
  310. # ** Scene_Shop
  311. #==============================================================================#
  312. class Scene_Shop < Scene_MenuBase

  313.   alias xail_item_durability_shop_start start
  314.   def start(*args, &block)
  315.     # // Method to start the scene.
  316.     xail_item_durability_shop_start(*args, &block)
  317.     create_repair_window
  318.   end

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

  325.   def create_repair_window
  326.     # // Method to create repair window.
  327.     wy = @category_window.y + @category_window.height
  328.     wh = Graphics.height - wy
  329.     @repair_window = Window_ShopRepair.new(0, wy, Graphics.width, wh)
  330.     @repair_window.viewport = @viewport
  331.     @repair_window.help_window = @help_window
  332.     @repair_window.hide
  333.     @repair_window.set_handler(:ok,     method(:on_repair_ok))
  334.     @repair_window.set_handler(:cancel, method(:on_repair_cancel))
  335.     @category_window.item_window = @repair_window
  336.   end

  337.   def command_repair
  338.     # // Method for command repair.
  339.     @dummy_window.hide
  340.     @category_window.show.activate
  341.     @repair_window.show
  342.     @repair_window.unselect
  343.     @repair_window.refresh
  344.   end

  345.   def activate_repair
  346.     # // Method to active command options.
  347.     @repair_window.select(0)
  348.     @category_window.show
  349.     @repair_window.refresh
  350.     @repair_window.show.activate
  351.     @status_window.hide
  352.   end

  353.   alias xail_item_durability_shop_on_cat_ok on_category_ok
  354.   def on_category_ok(*args, &block)
  355.     # // Method for category ok.
  356.     case @command_window.current_symbol
  357.     when :repair
  358.       activate_repair
  359.     when :sell
  360.       xail_item_durability_shop_on_cat_ok(*args, &block)
  361.     end
  362.   end

  363.   alias xail_item_durability_shop_on_cat_cancel on_category_cancel
  364.   def on_category_cancel(*args, &block)
  365.     # // Method for category cancel.
  366.     xail_item_durability_shop_on_cat_cancel(*args, &block)
  367.     @repair_window.hide
  368.   end

  369.   def on_repair_ok
  370.     # // Method to repair item.
  371.     @item = @repair_window.item
  372.     @status_window.item = @item
  373.     @category_window.hide
  374.     @repair_window.hide
  375.     @number_window.set(@item, max_item, repair_price, currency_unit)
  376.     @number_window.show.activate
  377.     @status_window.show
  378.   end

  379.   def on_repair_cancel
  380.     # // Method to cancel repair.
  381.     @repair_window.unselect
  382.     @category_window.activate
  383.     @status_window.item = nil
  384.     @help_window.clear
  385.   end

  386.   alias xail_item_durability_shop_on_number_ok on_number_ok
  387.   def on_number_ok(*args, &block)
  388.     # // Method on number ok.
  389.     if @command_window.current_symbol == :repair
  390.       do_repair(@number_window.number)
  391.     end
  392.     xail_item_durability_shop_on_number_ok(*args, &block)
  393.   end

  394.   alias xail_item_durability_shop_end_number_input end_number_input
  395.   def end_number_input(*args, &block)
  396.     # // Method to check input number.
  397.     if @command_window.current_symbol == :repair
  398.       activate_repair
  399.     end
  400.     xail_item_durability_shop_end_number_input(*args, &block)
  401.   end

  402.   def do_repair(number)
  403.     # // Method to do repair.
  404.     if @item.is_a?(RPG::Item)   ; item_type = :item     end
  405.     if @item.is_a?(RPG::Weapon) ; item_type = :weapon   end
  406.     if @item.is_a?(RPG::Armor)  ; item_type = :armor    end
  407.     $game_party.lose_gold(number * repair_price)
  408.     $game_party.change_durability(nil, :repair, @item.id, item_type)
  409.     @repair_window.refresh
  410.     @gold_window.refresh
  411.     @status_window.refresh
  412.     @help_window.refresh
  413.   end

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

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

  422. end
  423. #==============================================================================#
  424. # ** Scene_Battle
  425. #==============================================================================#
  426. class Scene_Battle < Scene_Base

  427.   alias xail_item_durability_scene_battle_process_action_end process_action_end
  428.   def process_action_end(*args, &block)
  429.     # // Method when process end at scene battle.
  430.     if XAIL::ITEM_DURABILITY::DURABILITY_LOG
  431.       @log_window.display_durability(@subject)
  432.       @log_window.wait_and_clear
  433.     end
  434.     xail_item_durability_scene_battle_process_action_end(*args, &block)
  435.   end

  436. end # END OF FILE

  437. #=*==========================================================================*=#
  438. # ** END OF FILE
  439. #=*==========================================================================*=#
复制代码
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.

在本版发帖返回顶部