查看: 2530|回复: 4

[已经过期] SailCat大神的铁匠铺脚本修理消耗的修改

[复制链接]
梦石
0
星屑
423
在线时间
37 小时
注册时间
2013-7-1
回帖
16
发表于 2020-3-17 16:26:04 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 774204155 于 2020-3-17 16:29 编辑

在用SailCat大神写的铁匠铺脚本,其中进行修理操作的时候[消耗金钱]
我想把它修改成[消耗4号变量]
在依赖插件《装备穿戴耐久》中做了一部分修改:
  1.    #--------------------------------------------------------------------------
  2.   # ● 修理状态检定
  3.   #--------------------------------------------------------------------------
  4.   def repair_state
  5.     return 1 unless broken?
  6.     return 2 unless repairable?
  7.     return 3 unless $game_variables[4] >= repair_cost
  8.     return 0
  9.   end
  10.   #--------------------------------------------------------------------------
  11.   # ● 执行修理
  12.   #--------------------------------------------------------------------------
  13.   def repair
  14.     $game_variables[4] -= repair_cost
  15.     self.durability = [self.max_durability.factor(repair_efficiency), 1].max
  16.     self.max_durability -= repair_wear
  17.     # 恢复装备的自动状态
  18.     if self.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
  19.       $game_party.actors.each do |actor|
  20.         actor.update_auto_state(nil, self) if actor.equipment.include?(self)
  21.       end
  22.     end
  23.   end
复制代码

修理的时候应该是可以改成消耗变量了,
但是铁匠铺的界面不知道该怎么修改,贴上两个脚本的完整代码:

装备穿戴耐久
  1. #==============================================================================
  2. # ■ 装备增强-装备穿戴耐久 v1.0 by SailCat
  3. #------------------------------------------------------------------------------
  4. #   方法:本脚本插入到Main之前、并在所有依赖项之后使用
  5. #   依赖:
  6. #     1. 数据库通用备注接口插件(2.1版以上)
  7. #     2. 装备实体接口(1.0版以上)
  8. #   版本:v1.0 (Build 180217)
  9. #   效果:装备具有耐久度,随装备经战斗逐渐减少,不装备不会减少耐久
  10. #   配置:装备耐久度默认数值,修理行为,耐久减损行为,相关用语
  11. #   冲突:同类功能脚本
  12. #   说明:
  13. #     0. 备注均写在描述里,具体格式见依赖的通用备注接口插件相关说明
  14. #        (当[XX集]内容只有一条时,方括号可省略)
  15. #        (备注太长写不下时,可用超长备注法)
  16. #     1. 装备的初始耐久度:du=值,若不设定的话,取配置中的默认值。
  17. #     2. 装备的耐久分散度:dv=值,若不设定取配置值。
  18. #     3. 装备是否允许修理:dr+(允许)或dr-(不允许),默认允许修理。
  19. #     4. 装备的最大耐久和当前耐久均为可读写属性。
  20. #        可以用装备.max_durability和装备.durability来读写耐久属性。
  21. #     5. 装备的耐久度会影响其价格。
  22. #     6. 当装备耐久度为0时,其所有属性均无效,但仍然可以如常装备。
  23. #     7. 装备的耐久减损行为主要兼顾主流,过于细节和非主流的设置并未包含。
  24. #     8. 本脚本中,装备的耐久减损是一个固定行为,而非随机行为。
  25. #==============================================================================
  26. #==============================================================================
  27. # ■ SailCat's 插件公用
  28. #==============================================================================
  29. module SailCat
  30.   $sailcat_import ||= {}
  31.   #--------------------------------------------------------------------------
  32.   # ● 脚本配置区
  33.   #--------------------------------------------------------------------------
  34.   module Equip_Config
  35.     DURABILITY_DEFAULT    = 50                  # 默认耐久度
  36.     DURABILITY_VARIANCE   = 0                   # 耐久度分散度
  37.     SPAWN_MAX_DURABILITY  = true                # 初始满耐久(true/false/开关ID)
  38.     REMOVE_BROKEN_AUTO    = false               # 是否自动解除损坏的装备
  39.     REPAIR_EFFICIENCY     = 100                 # 修复效率(设为0全局禁用修理)
  40.     REPAIR_WEAR_OUT       = 0                   # 修复后最大耐久的减损值
  41.     REMAINDER_VALUE       = 0                   # 装备耐久用完后的残值
  42.     REPAIR_COST_FACTOR    = 70                  # 修复所需金钱比率
  43.     WEAR_FACTOR           = 100                 # 耐久减损的精算系数,不能为0
  44.     WEAROUT_IN_BATTLE     = false               # 战斗中是否允许当场损毁
  45.     WEAPON_WEAR_FACTORS   = {                   # 武器不同场合下耐久的减损因子
  46.       :attack             => 25,                  # 执行攻击指令时
  47.       :guard              => 0,                   # 执行防御指令时
  48.       :skill_physical     => 75,                  # 执行物理特技时
  49.       :skill_magical      => 25,                  # 执行魔法特技时
  50.       :striking           => 25,                  # 击中目标时
  51.       :missing            => 5,                   # 打空时
  52.       :skill_hit          => 25,                  # 特技击中时
  53.       :skill_miss         => 5,                   # 特技打空时
  54.       :critical           => 100,                 # 造成会心一击时
  55.       :turn               => 1,                   # 每回合后
  56.       :combat             => 5,                   # 每场战斗后
  57.     }
  58.     ARMOR_WEAR_FACTORS    = {                   # 防具不同场合下耐久的减损因子
  59.     # 以下每组4个值分别对应盾、头部、身体、饰品
  60.     # 如果扩展了栏位,可以增加此处的值;若不增加,扩展栏位全视为饰品
  61.       :attack             => [0, 0, 0, 0],        # 执行攻击指令时
  62.       :guard              => [100, 0, 0, 0],      # 执行防御指令时
  63.       :skill_physical     => [0, 0, 0, 0],        # 执行物理特技时
  64.       :skill_magical      => [0, 0, 0, 0],        # 执行魔法特技时
  65.       :struck             => [25, 25, 50, 25],    # 被击中时
  66.       :evaded             => [100, 0, 0, 0],      # 被回避时
  67.       :critical_struck    => [0, 50, 100, 50],    # 被会心一击时
  68.       :turn               => [1, 1, 1, 1],        # 每回合后
  69.       :combat             => [5, 5, 5, 5],        # 每场战斗后
  70.     }
  71.     VOCAB_DURABILITY      = "耐久度"            # 耐久度 用语
  72.     VOCAB_DURABILITY_A    = "[%s/%d]"           # 耐久度 用语 简写
  73.     VOCAB_BROKEN          = "损坏的"            # 损坏的 用语
  74.     VOCAB_SCRAPPED        = "损毁的"            # 损毁的 用语
  75.     VOCAB_INDESTRUCTIBLE  = "不可磨损"          # 不可磨损 用语
  76.     VOCAB_UNREPAIRABLE    = "不可修复"          # 不可修复 用语
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 植入与依赖检查
  80.   #--------------------------------------------------------------------------
  81.   dependency = []
  82.   unless $sailcat_import[:DataNoteCore].to_f >= 2.1
  83.     dependency.push "[DataNoteCore] 通用数据库备注接口(v2.1以上版本)"
  84.   end
  85.   unless $sailcat_import[:EquipInstantiate].to_f >= 1.0
  86.     dependency.push "[EquipInstantiate] 装备实体接口(v1.0以上版本)"
  87.   end
  88.   raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
  89.   $sailcat_import[:EquipDurability] = 1.0
  90. end

  91. module RPG
  92.   #============================================================================
  93.   # ■ EquipDurability
  94.   #----------------------------------------------------------------------------
  95.   #  备注定义通用模块。
  96.   #============================================================================
  97.   module EquipDurability
  98.     include SailCat::Equip_Config
  99.     #--------------------------------------------------------------------------
  100.     # ● 备注定义
  101.     #--------------------------------------------------------------------------
  102.     def init_durability;  _du(DURABILITY_DEFAULT);                        end
  103.     def var_durability;   _dv(DURABILITY_VARIANCE);                       end
  104.     def allow_repair;     _dr(true);                                      end
  105.     def repair_efficiency;_de(REPAIR_EFFICIENCY);                         end
  106.     def repair_wear;      _dw(REPAIR_WEAR_OUT);                           end
  107.   end
  108.   #============================================================================
  109.   # ■ RPG::Weapon
  110.   #----------------------------------------------------------------------------
  111.   #  数据库的武器类扩展。
  112.   #============================================================================
  113.   class Weapon
  114.     include EquipDurability
  115.   end
  116.   #============================================================================
  117.   # ■ RPG::Armor
  118.   #----------------------------------------------------------------------------
  119.   #  数据库的防具类扩展。
  120.   #============================================================================
  121.   class Armor
  122.     include EquipDurability
  123.   end
  124. end

  125. #==============================================================================
  126. # ■ EquipDurability
  127. #------------------------------------------------------------------------------
  128. #   耐久处理模块。
  129. #==============================================================================
  130. module SailCat::EquipDurability
  131.   include SailCat::Equip_Config
  132.   #--------------------------------------------------------------------------
  133.   # ● 后续设置扩展方法处理 9000
  134.   #--------------------------------------------------------------------------
  135.   def post_setup_9000
  136.     unless @max_durability
  137.       @max_durability = init_durability.variance(var_durability, 100)
  138.       @max_durability_plus = 0
  139.       if @max_durability > 0
  140.         if SPAWN_MAX_DURABILITY.is_a?(Numeric)
  141.           full = $game_switches[SPAWN_MAX_DURABILITY]
  142.         else
  143.           full = SPAWN_MAX_DURABILITY
  144.         end
  145.         @durability = full ? max_durability : rand(max_durability) + 1
  146.         @durability *= WEAR_FACTOR
  147.       else
  148.         @durability = 0
  149.       end
  150.     end
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 无法损毁判定
  154.   #--------------------------------------------------------------------------
  155.   def indestructible?
  156.     self.max_durability == 0
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 获取最大耐久度
  160.   #--------------------------------------------------------------------------
  161.   def max_durability
  162.     get_value(@max_durability, :durability) + @max_durability_plus
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 设置最大耐久度
  166.   #     value : 最大耐久度
  167.   #--------------------------------------------------------------------------
  168.   def max_durability=(value)
  169.     @max_durability_plus += value - self.max_durability
  170.     @durability = [@durability, value * WEAR_FACTOR].min
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● 损坏的判定
  174.   #--------------------------------------------------------------------------
  175.   def broken?
  176.     @durability == 0 and self.max_durability > 0
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 可以修理判定
  180.   #--------------------------------------------------------------------------
  181.   def repairable?
  182.     max_durability > repair_wear and repair_efficiency > 0 and allow_repair
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 修理状态检定
  186.   #--------------------------------------------------------------------------
  187.   def repair_state
  188.     return 1 unless broken?
  189.     return 2 unless repairable?
  190.     return 3 unless $game_variables[4] >= repair_cost
  191.     return 0
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 执行修理
  195.   #--------------------------------------------------------------------------
  196.   def repair
  197.     $game_variables[i] -= repair_cost
  198.     self.durability = [self.max_durability.factor(repair_efficiency), 1].max
  199.     self.max_durability -= repair_wear
  200.     # 恢复装备的自动状态
  201.     if self.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
  202.       $game_party.actors.each do |actor|
  203.         actor.update_auto_state(nil, self) if actor.equipment.include?(self)
  204.       end
  205.     end
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 获取当前耐久度
  209.   #--------------------------------------------------------------------------
  210.   def durability
  211.     @durability == 0 ? 0 : [@durability / WEAR_FACTOR, 1].max
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # ● 设置当前耐久度
  215.   #     value : 当前耐久度
  216.   #--------------------------------------------------------------------------
  217.   def durability=(value)
  218.     # 装备可用状态有变化的情况下,清除缓存
  219.     clear_value_cache if @durability * value <= 0
  220.     @durability = value.limit(0, self.max_durability) * WEAR_FACTOR
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ● 耐久度的消耗
  224.   #     value_lost : 磨损度
  225.   #     flag       : 允许损毁标记
  226.   #--------------------------------------------------------------------------
  227.   def wear(value_lost, flag)
  228.     # 防止战斗中途损坏
  229.     min = [@durability, flag ? 0 : 1].min
  230.     # 耐久度的精算减损
  231.     @durability = [@durability - value_lost, min].max
  232.     # 磨坏了的情况下,清除缓存
  233.     clear_value_cache if broken?
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 获得残值
  237.   #--------------------------------------------------------------------------
  238.   def remain_value
  239.     sailcat_equipdu_price.factor(REMAINDER_VALUE)
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 获得使用价值
  243.   #--------------------------------------------------------------------------
  244.   def consumable_value
  245.     sailcat_equipdu_price.factor(100 - REMAINDER_VALUE)
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● 获得修理费
  249.   #--------------------------------------------------------------------------
  250.   def repair_cost
  251.     consumable_value.factor(REPAIR_COST_FACTOR)
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # ● 前缀(第四部分)
  255.   #--------------------------------------------------------------------------
  256.   def prefix_part4
  257.     broken? ? (repairable? ? Vocab.broken : Vocab.scrapped) : ""
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● 获得耐久度字符串
  261.   #--------------------------------------------------------------------------
  262.   def durability_s
  263.     if $sailcat_import[:WindowCore]
  264.       if broken?
  265.         color = 18
  266.       elsif durability < max_durability >> 2
  267.         color = 17
  268.       elsif durability == max_durability
  269.         color = 24
  270.       else
  271.         color = 0
  272.       end
  273.       "\\C[#{color}]#{durability}\\C[0]"
  274.     else
  275.       durability.to_s
  276.     end
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 详情信息 耐久度
  280.   #--------------------------------------------------------------------------
  281.   def info_02
  282.     return nil if indestructible?
  283.     text_s(Vocab.durability, sprintf("%s/%d", durability_s, max_durability))
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 详情信息 不可磨损
  287.   #--------------------------------------------------------------------------
  288.   def info_97
  289.     indestructible? && init_durability > 0 ? Vocab.indestructible : nil
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 详情信息 不可修复
  293.   #--------------------------------------------------------------------------
  294.   def info_98
  295.     !indestructible? && !allow_repair ? Vocab.unrepairable : nil
  296.   end
  297. end

  298. #==============================================================================
  299. # ■ Game_Weapon
  300. #==============================================================================
  301. class Game_Weapon
  302.   include SailCat::EquipDurability
  303.   #--------------------------------------------------------------------------
  304.   # ● 方法重定义
  305.   #--------------------------------------------------------------------------
  306.   unless method_defined?(:sailcat_equidu_price)
  307.     alias sailcat_equipdu_price price
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 获得磨损值
  311.   #     symbol : 磨损场合的标识符
  312.   #--------------------------------------------------------------------------
  313.   def wear_value(symbol)
  314.     WEAPON_WEAR_FACTORS[symbol] || 0
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 获得价格
  318.   #--------------------------------------------------------------------------
  319.   def price
  320.     if init_durability > 0
  321.       remain_value + consumable_value.factor(durability, init_durability)
  322.     else
  323.       sailcat_equipdu_price
  324.     end
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● 说明文字
  328.   #--------------------------------------------------------------------------
  329.   def description
  330.     if max_durability > 0
  331.       super + sprintf(Vocab.durability_a, durability_s, max_durability)
  332.     else
  333.       super
  334.     end
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 名称的颜色索引
  338.   #--------------------------------------------------------------------------
  339.   def name_color
  340.     broken? ? 18 : super
  341.   end
  342. end

  343. #==============================================================================
  344. # ■ Game_Armor
  345. #==============================================================================
  346. class Game_Armor
  347.   include SailCat::EquipDurability
  348.   #--------------------------------------------------------------------------
  349.   # ● 方法重定义
  350.   #--------------------------------------------------------------------------
  351.   unless method_defined?(:sailcat_equidu_price)
  352.     alias sailcat_equipdu_price price
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 获得磨损值
  356.   #     symbol : 磨损场合的标识符
  357.   #--------------------------------------------------------------------------
  358.   def wear_value(symbol)
  359.     (set = ARMOR_WEAR_FACTORS[symbol]) ? set[kind] || set[-1] : 0
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # ● 获得价格
  363.   #--------------------------------------------------------------------------
  364.   def price
  365.     if init_durability > 0
  366.       remain_value + consumable_value.factor(durability, init_durability)
  367.     else
  368.       sailcat_equipdu_price
  369.     end
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # ● 说明文字
  373.   #--------------------------------------------------------------------------
  374.   def description
  375.     if max_durability > 0
  376.       super + sprintf(Vocab.durability_a, durability_s, max_durability)
  377.     else
  378.       super
  379.     end
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 名称的颜色索引
  383.   #--------------------------------------------------------------------------
  384.   def name_color
  385.     broken? ? 18 : super
  386.   end
  387. end

  388. #==============================================================================
  389. # ■ Game_Battler
  390. #==============================================================================
  391. class Game_Battler
  392.   #--------------------------------------------------------------------------
  393.   # ● 攻击收尾扩展方法处理 4000
  394.   #--------------------------------------------------------------------------
  395.   def post_attack_4000(attacker)
  396.     # 不是强制行动的情况下,执行磨损
  397.     unless attacker.current_action.forcing
  398.       # 攻击者是角色的情况下
  399.       if attacker.actor?
  400.         # 击中/打空磨损
  401.         attacker.wear_equipment(@damage == Vocab.miss ? :missing : :striking)
  402.         # 会心磨损
  403.         attacker.wear_equipment(:critical) if @critical
  404.       end
  405.       # 被攻击者是角色的情况下
  406.       if actor?
  407.         # 挨打/闪避磨损
  408.         wear_equipment(@damage == Vocab.miss ? :evaded : :struck)
  409.         # 会心磨损
  410.         wear_equipment(:critical_struck) if @critical
  411.       end
  412.     end   
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 特技收尾扩展方法处理 4000
  416.   #--------------------------------------------------------------------------
  417.   def post_skill_4000(user, skill)
  418.     # 不是强制行动的情况下,执行磨损
  419.     unless user.current_action.forcing
  420.       # 攻击者是角色的情况下
  421.       if user.actor?
  422.         # 击中/打空磨损
  423.         user.wear_equipment(@damage == Vocab.miss ? :skill_miss : :skill_hit)
  424.         # 会心磨损
  425.         user.wear_equipment(:critical) if @critical
  426.       end
  427.       # 被攻击者是角色的情况下
  428.       if actor?
  429.         # 挨打/闪避磨损
  430.         wear_equipment(@damage == Vocab.miss ? :evaded : :struck)
  431.         # 会心磨损
  432.         wear_equipment(:critical_struck) if @critical
  433.       end
  434.     end   
  435.   end
  436. end

  437. #==============================================================================
  438. # ■ Game_Actor
  439. #==============================================================================
  440. class Game_Actor
  441.   #--------------------------------------------------------------------------
  442.   # ● 方法重定义
  443.   #--------------------------------------------------------------------------
  444.   unless method_defined?(:sailcat_equidu_weapons)
  445.     alias sailcat_equipdu_weapons weapons
  446.     alias sailcat_equipdu_armors armors
  447.     alias sailcat_equipdu_equipment equipment
  448.     alias sailcat_equipdu_weapon weapon
  449.     alias sailcat_equipdu_update_auto_state update_auto_state
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● 全身的有效装备
  453.   #--------------------------------------------------------------------------
  454.   def equipment
  455.     sailcat_equipdu_equipment.reject {|equip| equip.broken?}
  456.   end
  457.   #--------------------------------------------------------------------------
  458.   # ● 装备的有效武器
  459.   #--------------------------------------------------------------------------
  460.   def weapons
  461.     sailcat_equipdu_weapons.reject {|weapon| weapon.broken?}
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 装备的武器(RPG::Weapon)
  465.   #--------------------------------------------------------------------------
  466.   def weapon
  467.     (w = sailcat_equipdu_weapon) && w.broken? ? nil : w
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # ● 装备的有效防具
  471.   #--------------------------------------------------------------------------
  472.   def armors
  473.     sailcat_equipdu_armors.reject {|armor| armor.broken?}
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # ● 获取来自装备的数值
  477.   #--------------------------------------------------------------------------
  478.   def equip_param(scope, symbol, default = 0)
  479.     scope.to_a.sum do |e|
  480.       e.respond_to?(symbol) && !e.broken? ? e.send(symbol) : default
  481.     end
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ● 磨损装备处理
  485.   #     symbol : 磨损场合标识符
  486.   #--------------------------------------------------------------------------
  487.   def wear_equipment(symbol)
  488.     equipment.each do |e|
  489.       next if e.indestructible? or (value = e.wear_value(symbol)) == 0
  490.       flag = e.broken?
  491.       e.wear(value, WEAROUT_IN_BATTLE || symbol == :combat)
  492.       # 本次磨损损坏的情况下
  493.       if e.broken? and not flag
  494.         if REMOVE_BROKEN_AUTO
  495.           equip(all_equipment.index(e), 0)
  496.         else
  497.           # 取消装备的自动状态效果
  498.           if e.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
  499.             sailcat_equipdu_update_auto_state(e, nil)
  500.           end
  501.           fix_hp
  502.           fix_sp
  503.         end
  504.       end
  505.     end
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ● 更新自动状态
  509.   #     old_equip : 卸下防具/武器
  510.   #     new_equip : 装备防具/武器
  511.   #--------------------------------------------------------------------------
  512.   def update_auto_state(old_equip, new_equip)
  513.     # 取消损坏的装备
  514.     old_equip = nil if old_equip.respond_to?(:broken?) and old_equip.broken?
  515.     new_equip = nil if new_equip.respond_to?(:broken?) and new_equip.broken?
  516.     sailcat_equipdu_update_auto_state(old_equip, new_equip)
  517.   end
  518. end

  519. #==============================================================================
  520. # ■ Scene_Battle
  521. #==============================================================================
  522. class Scene_Battle
  523.   #--------------------------------------------------------------------------
  524.   # ● 方法重定义
  525.   #--------------------------------------------------------------------------
  526.   unless method_defined?(:sailcat_equipdu_make_attack_action_result)
  527.     alias sailcat_equipdu_make_attack_action_result make_attack_action_result
  528.     alias sailcat_equipdu_make_guard_action_result make_guard_action_result
  529.     alias sailcat_equipdu_make_skill_action_result make_skill_action_result
  530.     alias sailcat_equipdu_update_phase4_step6 update_phase4_step6
  531.     alias sailcat_equipdu_battle_end battle_end
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # ● 生成攻击行动结果
  535.   #--------------------------------------------------------------------------
  536.   def make_attack_action_result
  537.     sailcat_equipdu_make_attack_action_result
  538.     # 攻击者是角色的情况下,执行攻击行动磨损
  539.     @active_battler.wear_equipment(:attack) if @active_battler.actor?
  540.   end
  541.   #--------------------------------------------------------------------------
  542.   # ● 生成防御行动结果
  543.   #--------------------------------------------------------------------------
  544.   def make_guard_action_result
  545.     sailcat_equipdu_make_guard_action_result
  546.     # 防御者是角色的情况下,执行防御行动磨损
  547.     @active_battler.wear_equipment(:guard) if @active_battler.actor?
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ● 生成特技行动结果
  551.   #--------------------------------------------------------------------------
  552.   def make_skill_action_result
  553.     sailcat_equipdu_make_skill_action_result
  554.     skill = $data_skills[@active_battler.current_action.skill_id]
  555.     # 特技确实有效的情况下,执行特技行动磨损
  556.     unless @phase4_step == 1 or not @active_battler.actor?
  557.       symbol = skill.atk_f > 0 ? :skill_physical : :skill_magical
  558.       @active_battler.wear_equipment(symbol)
  559.     end
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  563.   #--------------------------------------------------------------------------
  564.   def update_phase4_step6
  565.     sailcat_equipdu_update_phase4_step6
  566.     # 回合磨损
  567.     if @active_battler and @active_battler.actor?
  568.       @active_battler.wear_equipment(:turn)
  569.     end
  570.   end
  571.   #--------------------------------------------------------------------------
  572.   # ● 战斗结束
  573.   #--------------------------------------------------------------------------
  574.   def battle_end(result)
  575.     # 战斗结束磨损
  576.     $game_party.actors.each {|a| a.wear_equipment(:combat)}
  577.     sailcat_equipdu_battle_end(result)
  578.   end
  579. end
复制代码


铁匠铺界面:
  1. #==============================================================================
  2. # ■ 装备增强-铁匠铺界面 v1.0 by SailCat
  3. #------------------------------------------------------------------------------
  4. #   方法:本脚本插入到Main之前、并在所有依赖项之后使用
  5. #   依赖:
  6. #     1. 装备实体接口(1.0版以上)
  7. #     2. 消息对话框(1.0版以上)
  8. #     3. 上下文菜单(1.0版以上)
  9. #     4. 详情窗口(1.0版以上)
  10. #     5. 以下装备实体增强至少其一:
  11. #        穿戴耐久、质量分等、附魔词缀、锻造升级、镶嵌道具、随机生成
  12. #   版本:v1.0 (Build 180716)
  13. #   效果:支持装备实体化的可视化功能操作
  14. #   配置:界面的表现和用语设置
  15. #   冲突:同类功能脚本
  16. #   说明:
  17. #     1. 使用$scene = Scene_Smith.new来开启铁匠界面。
  18. #==============================================================================
  19. #==============================================================================
  20. # ■ SailCat's 插件公用
  21. #==============================================================================
  22. module SailCat
  23.   $sailcat_import ||= {}
  24.   #--------------------------------------------------------------------------
  25.   # ● 脚本配置区
  26.   #--------------------------------------------------------------------------
  27.   module Equip_Config
  28.     GOLD_WINDOW_DELAY     = 60                  # 金钱窗口的切换延迟
  29.     GOLD_WINDOW_FADE      = 10                  # 金钱窗口的淡入速度
  30.     REROLL_COST_RATIO     = [0, 33, 300]        # 幻化消费比例(低/中/高级)
  31.     DESTROY_GAIN_RATIO    = 33                  # 熔毁回收比例
  32.     VOCAB_REPAIR          = "修理"              # 修理 用语
  33.     VOCAB_ENCHANT         = "附魔"              # 附魔 用语
  34.     VOCAB_REFINE          = "锤炼"              # 锤炼 用语
  35.     VOCAB_FORGE           = "锻造"              # 锻造 用语
  36.     VOCAB_PUNCH           = "打孔"              # 打孔 用语
  37.     VOCAB_EMBED           = "镶嵌"              # 镶嵌 用语
  38.     VOCAB_REROLL          = "幻化"              # 幻化 用语
  39.     VOCAB_DESTROY         = "熔毁"              # 熔毁 用语
  40.     HELP_REPAIR           = "修理损坏的装备。"  # 修理 帮助文字
  41.     HELP_ENCHANT          = "为装备加持魔法。"  # 附魔 帮助文字
  42.     HELP_REFINE           = "锤炼装备提升质量。"# 锤炼 帮助文字
  43.     HELP_FORGE            = "锻造装备提高等级。"# 锻造 帮助文字
  44.     HELP_PUNCH            = "在装备上开镶孔。"  # 打孔 帮助文字
  45.     HELP_EMBED            = "在镶孔中镶嵌道具。"# 镶嵌 帮助文字
  46.     HELP_REROLL           = "将装备随机幻化。"  # 幻化 帮助文字
  47.     HELP_DESTROY          = "熔毁装备回收金钱。"# 熔毁 帮助文字
  48.     # 修理部分的提示用语
  49.     VOCAB_REPAIR_FAIL_1   = "装备状态良好。"
  50.     VOCAB_REPAIR_FAIL_2   = "无法修理。"
  51.     VOCAB_REPAIR_FAIL_3   = "所需零件不足。"
  52.     VOCAB_REPAIR_CONFIRM  = "修理装备:%s\n需要零件:%d\\C[16]\枚\n要修理吗?"
  53.     VOCAB_REPAIR_INFO     = "修理完成。\n现耐久度为:%d/%d。"
  54.     # 附魔部分的提示用语
  55.     VOCAB_ENCHANT_FAIL_1  = "无法附魔这个装备。"
  56.     VOCAB_ENCHANT_FAIL_2  = "附魔词缀数已达上限。"
  57.     VOCAB_ENCHANT_FAIL_3  = "该词缀已被锁定。"
  58.     VOCAB_ENCHANT_FAIL_4  = "附魔费用不足。"
  59.     VOCAB_ENCHANT_CONFIRM = "附魔装备:%s\n附魔费用:%d\\C[16]\\$\n要附魔吗?"
  60.     VOCAB_ENCHANT_INFO    = "附魔完成。\n删除词缀%d个,新增词缀%d个。"
  61.     # 锤炼部分的提示用语
  62.     VOCAB_REFINE_FAIL_1   = "装备质量已达极致。"
  63.     VOCAB_REFINE_FAIL_2   = "技术所限,无法进一步锤炼。"
  64.     VOCAB_REFINE_FAIL_3   = "锤炼材料不足。"
  65.     VOCAB_REFINE_CONFIRM  = "锤炼装备:%s\n所用材料:\\D[I%d] × %d\n继续吗?"
  66.     VOCAB_REFINE_INFO     = "锤炼完成。\n现质量为:%s。"
  67.     # 锻造部分的提示用语
  68.     VOCAB_FORGE_FAIL_1    = "装备等级已达上限。"
  69.     VOCAB_FORGE_FAIL_2    = "消费过低,无法锻造。"
  70.     VOCAB_FORGE_FAIL_3    = "锻造失败。\n返还了消费的一半。"
  71.     VOCAB_FORGE_FAIL_4    = "锻造失败。\n装备等级没有变化。"
  72.     VOCAB_FORGE_FAIL_5    = "锻造失败。\n装备的等级下降了。"
  73.     VOCAB_FORGE_INFO      = "锻造成功。\n现等级为:%+d。"
  74.     VOCAB_FORGE_TEXT_GOLD = "消费%s"
  75.     VOCAB_FORGE_TEXT_ITEM = "消费道具"
  76.     VOCAB_FORGE_TEXT_BONUS= "额外道具"
  77.     VOCAB_FORGE_TEXT_RATE = "锻造成功率"
  78.     VOCAB_FORGE_NO_BONUS  = "(不使用额外道具)"
  79.     VOCAB_FORGE_NO_RATE   = "无法锻造"
  80.     # 打孔部分的提示用语
  81.     VOCAB_PUNCH_FAIL_1    = "装备无法打孔。"
  82.     VOCAB_PUNCH_FAIL_2    = "打孔材料不足。"
  83.     VOCAB_PUNCH_OPEN      = "开启镶孔"
  84.     VOCAB_PUNCH_CLOSE     = "封闭镶孔"
  85.     VOCAB_PUNCH_CONFIRM   = "%s:%s\n所用材料:\\D[I%d] × 1\n继续吗?"
  86.     VOCAB_PUNCH_INFO      = "%s成功。\n现镶孔数为:%d个。"
  87.     # 镶嵌部分的提示用语
  88.     VOCAB_EMBED_FAIL_1    = "装备没有镶孔。"
  89.     VOCAB_EMBED_FAIL_2    = "装备镶嵌已满。"
  90.     VOCAB_EMBED_FAIL_3    = "这个装备不允许拆解镶嵌物。"
  91.     VOCAB_EMBED_EMPTY     = "这个镶嵌孔是空的。"
  92.     # 幻化部分的提示用语
  93.     VOCAB_REROLL_FAIL_1   = "无法幻化这个装备。"
  94.     VOCAB_REROLL_FAIL_2   = "幻化消费不足。"
  95.     VOCAB_REROLL_GRADE_1  = "基础"
  96.     VOCAB_REROLL_GRADE_2  = "普通"
  97.     VOCAB_REROLL_GRADE_3  = "专家"
  98.     VOCAB_REROLL_CONFIRM  = "幻化装备:%s\n幻化费用:%d\\C[16]\\$\n" +
  99.       "\\C[18]\\*警告\\*\\C[0]:装备将丢失原先所有属性!\n继续吗?"
  100.     VOCAB_REROLL_INFO     = "幻化成功。\n新装备为:%s"
  101.     # 熔毁部分的提示用语
  102.     VOCAB_DESTROY_CONFIRM = "熔毁装备:%s\n回收金钱:%d\\C[16]\\$\n继续吗?"
  103.     VOCAB_DESTROY_INFO    = "熔毁完成。"
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 植入与依赖检查
  107.   #--------------------------------------------------------------------------
  108.   dependency = []
  109.   unless $sailcat_import[:EquipInstantiate].to_f >= 1.0
  110.     dependency.push "[EquipInstantiate] 装备实体接口(v1.0以上版本)"
  111.   end
  112.   unless $sailcat_import[:WindowMessageBox].to_f >= 1.0
  113.     dependency.push "[WindowMessageBox] 消息对话框(v1.0以上版本)"
  114.   end
  115.   unless $sailcat_import[:WindowContextMenu].to_f >= 1.0
  116.     dependency.push "[WindowContextMenu] 上下文菜单(v1.0以上版本)"
  117.   end
  118.   unless $sailcat_import[:WindowInfo].to_f >= 1.0
  119.     dependency.push "[WindowInfo] 详情窗口(v1.0以上版本)"
  120.   end
  121.   raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
  122.   $sailcat_import[:EquipSmithery] = 1.0
  123. end

  124. #==============================================================================
  125. # ■ Vocab
  126. #------------------------------------------------------------------------------
  127. #   所有用语的整合模块。
  128. #==============================================================================
  129. module Vocab
  130.   self.help_text.merge!({
  131.     :smith_repair => HELP_REPAIR,
  132.     :smith_enchant => HELP_ENCHANT,
  133.     :smith_refine => HELP_REFINE,
  134.     :smith_forge => HELP_FORGE,
  135.     :smith_punch => HELP_PUNCH,
  136.     :smith_embed => HELP_EMBED,
  137.     :smith_reroll => HELP_REROLL,
  138.   })
  139. end

  140. #==============================================================================
  141. # ■ Window_SmithCommand
  142. #------------------------------------------------------------------------------
  143. #   铁匠铺界面,显示铁匠指令列表的窗口。
  144. #==============================================================================
  145. class Window_SmithCommand < Window_HorzCommand
  146.   #--------------------------------------------------------------------------
  147.   # ● 初期化
  148.   #--------------------------------------------------------------------------
  149.   def initialize
  150.     @commands = []
  151.     @commands.push(Vocab.repair)  if $sailcat_import[:EquipDurability]
  152.     @commands.push(Vocab.enchant) if $sailcat_import[:EquipEnchant]
  153.     @commands.push(Vocab.refine)  if $sailcat_import[:EquipQuality]
  154.     @commands.push(Vocab.forge)   if $sailcat_import[:EquipLevel]
  155.     @commands.push(Vocab.embed)   if $sailcat_import[:EquipSocket]
  156.     @commands.push(Vocab.reroll)  if $sailcat_import[:EquipRandomize]
  157.     super(SCREEN_W, @commands)
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● 选中的命令文字
  161.   #--------------------------------------------------------------------------
  162.   def command_text
  163.     @commands[@index]
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 刷新帮助文本
  167.   #--------------------------------------------------------------------------
  168.   def update_help
  169.     case command_text
  170.     when Vocab.repair
  171.       @help_window.set_text(Vocab.help_text[:smith_repair])
  172.     when Vocab.enchant
  173.       @help_window.set_text(Vocab.help_text[:smith_enchant])
  174.     when Vocab.refine
  175.       @help_window.set_text(Vocab.help_text[:smith_refine])
  176.     when Vocab.forge
  177.       @help_window.set_text(Vocab.help_text[:smith_forge])
  178.     when Vocab.embed
  179.       @help_window.set_text(Vocab.help_text[:smith_embed])
  180.     when Vocab.reroll
  181.       @help_window.set_text(Vocab.help_text[:smith_reroll])
  182.     end
  183.   end
  184. end

  185. #==============================================================================
  186. # ■ Window_SmithItem
  187. #------------------------------------------------------------------------------
  188. #   铁匠铺界面,显示装备列表的窗口。
  189. #==============================================================================
  190. class Window_SmithItem < Window_Data
  191.   #--------------------------------------------------------------------------
  192.   # ● 定义实例变量
  193.   #--------------------------------------------------------------------------
  194.   attr_reader   :mode                     # 模式
  195.   #--------------------------------------------------------------------------
  196.   # ● 初始化对像
  197.   #--------------------------------------------------------------------------
  198.   def initialize
  199.     @mode = 0
  200.     super(0, window_h << 1, SCREEN_W >> 1, -window_h * 3, nil, 1)
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 生成数据
  204.   #--------------------------------------------------------------------------
  205.   def make_data
  206.     super
  207.     @data = $game_party.sorted_weapons + $game_party.sorted_armors
  208.     @enable_proc = Proc.new {|item|
  209.       case @mode
  210.       when 0
  211.         true
  212.       when 1
  213.         item.broken? and item.repairable?
  214.       when 2
  215.         item.prototype.available_enchants.size > 0
  216.       when 3
  217.         item.quality < item.max_quality
  218.       when 4
  219.         item.level < item.max_level
  220.       when 5
  221.         item.sockets > 0 and (item.embed_removable or item.empty_sockets > 0)
  222.       end}
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 设置模式
  226.   #     mode : 模式
  227.   #--------------------------------------------------------------------------
  228.   def set_mode(mode)
  229.     @mode = mode
  230.     refresh
  231.   end
  232. end

  233. #==============================================================================
  234. # ■ Window_SmithGold
  235. #------------------------------------------------------------------------------
  236. #   铁匠铺界面,显示金钱或所需道具的窗口。
  237. #==============================================================================
  238. class Window_SmithGold < Window_Base
  239.   include SailCat::Equip_Config
  240.   #--------------------------------------------------------------------------
  241.   # ● 初始化窗口
  242.   #--------------------------------------------------------------------------
  243.   def initialize
  244.     super(0, SCREEN_H - window_h, SCREEN_W >> 1, window_h)
  245.     self.contents = Bitmap.new(width - 32, height - 32)
  246.     @item_ids = [-1]
  247.     @index = 0
  248.     @frame_count = 0
  249.     refresh
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● 刷新
  253.   #--------------------------------------------------------------------------
  254.   def refresh
  255.     contents.clear
  256.     self.contents_opacity = 255
  257.     @frame_count = 0
  258.     if @item_ids[@index] == -1
  259.       draw_currency_value(number, Vocab.gold, 4, 0, width - 40)
  260.     elsif @item_ids[@index] > 0
  261.       rect = contents.rect.inflate(-4, 0)
  262.       number_width = text_size(ITEM_MAX).width.limit(24, 66) + 16
  263.       draw_item_name($data_items[@item_ids[@index]], 4, 0, true,
  264.         rect.width - number_width)
  265.       draw_text(rect.right - number_width, 0, 16, rect.height, ":", 1)
  266.       draw_text(rect.right - number_width + 16, 0,
  267.         number_width - 16, rect.height, number, 2)
  268.     end
  269.   end
  270.   #--------------------------------------------------------------------------
  271.   # ● 设置要显示的道具ID
  272.   #     item_id : 道具ID
  273.   #--------------------------------------------------------------------------
  274.   def set_item_id(item_id)
  275.     if @item_ids != item_id.to_a
  276.       @item_ids = item_id.to_a
  277.       @index = 0
  278.       refresh
  279.     end
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # ● 获取数目
  283.   #--------------------------------------------------------------------------
  284.   def number
  285.     item_id = @item_ids[@index]
  286.     item_id == -1 ? $game_party.gold : $game_party.item_number(item_id)
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● 刷新画面
  290.   #--------------------------------------------------------------------------
  291.   def update
  292.     super
  293.     if @item_ids.size > 1
  294.       @frame_count += 1
  295.       if @frame_count >= GOLD_WINDOW_DELAY
  296.         self.contents_opacity -= (255.to_f / GOLD_WINDOW_FADE).ceil
  297.         if @frame_count == GOLD_WINDOW_DELAY + GOLD_WINDOW_FADE
  298.           @index = (@index + 1) % @item_ids.size
  299.           refresh
  300.           self.contents_opacity = 0
  301.           @frame_count = -GOLD_WINDOW_FADE
  302.         end
  303.       elsif @frame_count < 0
  304.         self.contents_opacity += (255.to_f / GOLD_WINDOW_FADE).ceil
  305.       end
  306.     end
  307.   end
  308. end

  309. #==============================================================================
  310. # ■ Window_SmithEnchant
  311. #------------------------------------------------------------------------------
  312. #   铁匠铺界面,显示附魔词缀的选择窗口。
  313. #==============================================================================
  314. class Window_SmithEnchant < Window_Selectable
  315.   #--------------------------------------------------------------------------
  316.   # ● 初始化窗口
  317.   #--------------------------------------------------------------------------
  318.   def initialize
  319.     super(0, 0, 576, 416)
  320.     center.hide.deactivate.z += 3
  321.     @selected = []
  322.     @column_max = 3
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ● 设置显示的装备
  326.   #     item : 装备
  327.   #--------------------------------------------------------------------------
  328.   def show_enchant(item)
  329.     return unless item
  330.     @data = item.prototype.available_enchants
  331.     main_set = item.main_set
  332.     sub_set = item.sub_set
  333.     available_set = item.available_enchants
  334.     @selected = @data.map {|k|
  335.       if main_set.include?(k) or main_set.include?(-k)
  336.         1
  337.       elsif sub_set.include?(k) or sub_set.include?(-k)
  338.         3
  339.       elsif not available_set.include?(k)
  340.         2
  341.       else
  342.         0
  343.       end}
  344.     @item_max = @data.size
  345.     @max_sel = item.max_enchant
  346.     refresh
  347.     self.height = [contents.height + 32, 416].min
  348.     center.show.activate.index = 0
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 刷新
  352.   #--------------------------------------------------------------------------
  353.   def refresh
  354.     create_contents
  355.     @item_max.times {|n| draw_state(n)}
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● 设置选择状态
  359.   #     index  : 索引
  360.   #     select : 选择状态(0-3)
  361.   #--------------------------------------------------------------------------
  362.   def set_select(index, select)
  363.     @selected[index] = select
  364.     draw_state(index)
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ● 获得词缀状态
  368.   #     index  : 索引
  369.   #--------------------------------------------------------------------------
  370.   def enchant_state(index = @index)
  371.     n = @selected[index]
  372.     n == 0 ? (selected_enchants.size >= @max_sel ? -1 : 0) : n
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● 切换所选附魔开关
  376.   #--------------------------------------------------------------------------
  377.   def toggle_enchant
  378.     return unless state = $data_states[@data[@index]]
  379.     if @selected[@index] == 0
  380.       set_select(@index, 1)
  381.       state.chain_enchant_set.each do |x|
  382.         set_select(i, 3) if i = @data.index(x) and x != @data[@index]
  383.       end
  384.       state.reject_enchant_set.each do |x|
  385.         set_select(i, 2) if i = @data.index(x) and x != @data[@index]
  386.       end
  387.     elsif @selected[@index] == 1
  388.       set_select(@index, 0)
  389.       state.chain_enchant_set.each do |x|
  390.         set_select(i, 0) if i = @data.index(x) and x != @data[@index]
  391.       end
  392.       state.reject_enchant_set.each do |x|
  393.         set_select(i, 0) if i = @data.index(x) and x != @data[@index]
  394.       end
  395.     end
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 绘制词缀名
  399.   #--------------------------------------------------------------------------
  400.   def draw_state(index)
  401.     contents.clear_rect(item_rect(index))
  402.     text = $data_states[@data[index]].enchant_name
  403.     text = "[" + text + "]" if @selected[index] & 1 == 1
  404.     change_color(@selected[index] > 1 ? disabled_color : normal_color)
  405.     draw_text(item_rect(index), text, 1)
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # ● 获得选中的词缀集
  409.   #--------------------------------------------------------------------------
  410.   def selected_enchants
  411.     (0...@item_max).map {|i| @selected[i] == 1 ? @data[i] : nil}.compact
  412.   end
  413. end

  414. #==============================================================================
  415. # ■ Window_SmithForge
  416. #------------------------------------------------------------------------------
  417. #   铁匠铺界面,显示锻造消费情况的确认窗口。
  418. #==============================================================================
  419. class Window_SmithForge < Window_Base
  420.   include Window_Handler
  421.   #--------------------------------------------------------------------------
  422.   # ● 定义实例变量
  423.   #--------------------------------------------------------------------------
  424.   attr_reader   :index                    # 光标位置
  425.   attr_reader   :item_max                 # 项目数
  426.   attr_reader   :gold                     # 变量
  427.   #--------------------------------------------------------------------------
  428.   # ● 初始化窗口
  429.   #--------------------------------------------------------------------------
  430.   def initialize
  431.     super(0, 0, SCREEN_W >> 1, 320)
  432.     @handler = {}
  433.     center.hide.deactivate.z += 3
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 设置显示的装备
  437.   #     item : 装备
  438.   #--------------------------------------------------------------------------
  439.   def show_forge(item)
  440.     # 设置锻造目标
  441.     @target = item
  442.     # 锻造用物品
  443.     @items = item.accept_items
  444.     @sub_items = {}
  445.     # 额外物品
  446.     @bonus_items = $game_party.sorted_items.select {|item|
  447.       item.equip_bonus_rate != 0}.map {|item| item.id}
  448.     @bonus_items.unshift(0)
  449.     @item_max = @items.size + 4
  450.     resize(SCREEN_W >> 1, window_h(@item_max + 2))
  451.     create_contents
  452.     reset_cost
  453.     refresh
  454.     center.show.activate.index = 0
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ● 重设消费数值
  458.   #--------------------------------------------------------------------------
  459.   def reset_cost
  460.     @gold = 0
  461.     @items.each {|item_id| @sub_items[item_id] = 0}
  462.     @bonus_item_id = 0
  463.   end
  464.   #--------------------------------------------------------------------------
  465.   # ● 刷新
  466.   #--------------------------------------------------------------------------
  467.   def refresh
  468.     # 清除内容
  469.     contents.clear
  470.     # 绘制各提示语文字
  471.     change_color(system_color)
  472.     w = contents.width
  473.     h = line_height
  474.     x = @items.size
  475.     draw_text(0, 0, w, h, Vocab.forge, 1)
  476.     contents.fill_rect(0, h - 1, w, 1, system_color)
  477.     gold_text = sprintf(Vocab.forge_text_gold, Vocab.gold)
  478.     draw_text(0, line_height(1), w, h, gold_text)
  479.     draw_text(0, line_height(2), w, h, Vocab.forge_text_item)
  480.     draw_text(0, line_height(3 + x), w, h, Vocab.forge_text_bonus)
  481.     draw_text(0, line_height(4 + x), w, h, Vocab.forge_text_rate)
  482.     # 绘制物品名称
  483.     w = text_size(ITEM_MAX).width.limit(24, 66) + 32
  484.     x.times do |i|
  485.       item = $data_items[@items[i]]
  486.       draw_item_name(item, 0, line_height(3 + i), true, contents.width - w)
  487.       change_color(normal_color)
  488.       draw_text(contents.width - w - 32, line_height(3 + i), 24, h, "×", 1)
  489.     end
  490.     # 绘制各项可调数值
  491.     draw_gold
  492.     x.times {|i| draw_item_number(i)}
  493.     draw_bonus_item
  494.     update_rate
  495.     # 绘制确定和取消按钮
  496.     change_color(normal_color)
  497.     w = contents.width - CURSOR_PADDING >> 1
  498.     draw_text(0, line_height(5 + x), w, h, Vocab.ok, 1)
  499.     draw_text(w + CURSOR_PADDING, line_height(5 + x), w, h, Vocab.cancel, 1)
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # ● 绘制变量数量
  503.   #--------------------------------------------------------------------------
  504.   def draw_gold
  505.     change_color(normal_color)
  506.     w = text_size(GOLD_MAX).width.limit(48, 100) + 4
  507.     contents.redraw_text(contents.width - w, line_height(1),
  508.       w - 4, line_height, @gold, 2)
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● 绘制物品数量
  512.   #--------------------------------------------------------------------------
  513.   def draw_item_number(i = @index - 1)
  514.     change_color(normal_color)
  515.     w = text_size(ITEM_MAX).width.limit(24, 66) + 4
  516.     contents.redraw_text(contents.width - w, line_height(3 + i),
  517.       w - 4, line_height, @sub_items[@items[i]], 2)
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ● 绘制额外物品
  521.   #--------------------------------------------------------------------------
  522.   def draw_bonus_item
  523.     x = text_size(Vocab.forge_text_bonus).width + 8
  524.     w = contents.width - x - 4
  525.     rect = Rect.new(x, line_height(3 + @items.size), w, line_height)
  526.     if @bonus_item_id == 0
  527.       change_color(disabled_color)
  528.       contents.redraw_text(rect, Vocab.forge_no_bonus)
  529.     else
  530.       item = $data_items[@bonus_item_id]
  531.       contents.clear_rect(rect)
  532.       draw_item_name(item, rect.x, rect.y, true, rect.width)
  533.     end
  534.   end
  535.   #--------------------------------------------------------------------------
  536.   # ● 刷新画面
  537.   #--------------------------------------------------------------------------
  538.   def update
  539.     super
  540.     update_keypress if self.active
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # ● 设置光标的位置
  544.   #     index : 新的光标位置
  545.   #--------------------------------------------------------------------------
  546.   def index=(index)
  547.     @index = index
  548.     update_cursor_rect
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ● 上键处理
  552.   #--------------------------------------------------------------------------
  553.   def update_up(force)
  554.     if @index > 0 or force
  555.       $game_system.se_play($data_system.cursor_se)
  556.       self.index = @index > 0 ? [@index - 1, @item_max - 3].min : @item_max - 2
  557.     end
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # ● 下键处理
  561.   #--------------------------------------------------------------------------
  562.   def update_down(force)
  563.     if @index > @item_max - 3 or force
  564.       $game_system.se_play($data_system.cursor_se)
  565.       self.index = @index > @item_max - 3 ? 0 : @index + 1
  566.     end
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # ● 左右键、LR键处理
  570.   #--------------------------------------------------------------------------
  571.   def update_left(force); key_num(@index != @item_max - 2 || force, -1);  end
  572.   def update_right(force);key_num(@index != @item_max - 1 || force, +1);  end
  573.   def update_pageup;      key_num(@index != @item_max - 2, -10);          end
  574.   def update_pagedown;    key_num(@index != @item_max - 1, +10);          end
  575.   #--------------------------------------------------------------------------
  576.   # ● 按键变化数值处理
  577.   #     condition   : 变化条件
  578.   #     delta_value : 变化量
  579.   #--------------------------------------------------------------------------
  580.   def key_num(condition, delta_value)
  581.     if condition
  582.       # 演奏光标 SE
  583.       $game_system.se_play($data_system.cursor_se)
  584.       change_value(delta_value * 100 ** Input.modifier)
  585.     end
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # ● 增减数量值
  589.   #     delta : 变化量
  590.   #--------------------------------------------------------------------------
  591.   def change_value(delta)
  592.     case @index
  593.     when 0
  594.       set_gold(@gold + delta)
  595.     when 1..@items.size
  596.       item_id = @items[@index - 1]
  597.       set_item(item_id, @sub_items[item_id] + delta)
  598.     when @item_max - 3
  599.       set_bonus(delta <=> 0)
  600.     else
  601.       self.index = (@item_max << 1) - @index - 3
  602.     end
  603.   end
  604.   #--------------------------------------------------------------------------
  605.   # ● 光标有效判定
  606.   #--------------------------------------------------------------------------
  607.   def cursor_respond?
  608.     true
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ● 更新光标矩形
  612.   #--------------------------------------------------------------------------
  613.   def update_cursor_rect
  614.     cw = contents.width
  615.     case @index
  616.     when 0
  617.       w = text_size(GOLD_MAX).width.limit(48, 100) + 8
  618.       x, y = cw - w, 1
  619.     when 1..@items.size
  620.       w = text_size(ITEM_MAX).width.limit(24, 66) + 8
  621.       x, y = cw - w, 2
  622.     when @item_max - 3
  623.       w = cw - text_size(Vocab.forge_text_bonus).width - 4
  624.       x, y = cw - w, 2
  625.     when @item_max - 2
  626.       w = cw - CURSOR_PADDING >> 1
  627.       x, y = 0, 3
  628.     when @item_max - 1
  629.       w = cw - CURSOR_PADDING >> 1
  630.       x, y = cw - w, 2
  631.     end
  632.     self.cursor_rect = Rect.new(x, line_height(@index + y), w, line_height)
  633.   end
  634.   #--------------------------------------------------------------------------
  635.   # ● 设置金钱数量
  636.   #     gold : 金钱数量
  637.   #--------------------------------------------------------------------------
  638.   def set_gold(gold)
  639.     @gold = gold.limit(0, $game_party.gold)
  640.     draw_gold
  641.     update_rate
  642.   end
  643.   #--------------------------------------------------------------------------
  644.   # ● 设置物品数量
  645.   #     id     : 物品 ID
  646.   #     number : 物品数量
  647.   #--------------------------------------------------------------------------
  648.   def set_item(id, number)
  649.     @sub_items[id] = number.limit(0, $game_party.item_number(id))
  650.     draw_item_number
  651.     update_rate
  652.   end
  653.   #--------------------------------------------------------------------------
  654.   # ● 设置奖励物品
  655.   #     delta : 增减方向
  656.   #--------------------------------------------------------------------------
  657.   def set_bonus(delta)
  658.     bonus_index = @bonus_items.index(@bonus_item_id)
  659.     @bonus_item_id = @bonus_items[(bonus_index + delta) % @bonus_items.size]
  660.     draw_bonus_item
  661.     update_rate
  662.   end
  663.   #--------------------------------------------------------------------------
  664.   # ● 更新机率显示
  665.   #--------------------------------------------------------------------------
  666.   def update_rate
  667.     rate = @target.preview_chance(money, bonus_rate).to_i
  668.     color = [disabled_color, power_down_color, crisis_color, power_up_color,
  669.       power_up_color, normal_color][(rate / 25 + 1).limit(0, 5)]
  670.     change_color(color)
  671.     text = rate < 0 ? Vocab.forge_no_rate : rate.to_s + "%"
  672.     x = text_size(Vocab.forge_text_rate).width + 8
  673.     contents.redraw_text(x, line_height(4 + @items.size),
  674.       contents.width - x - 4, line_height, text, 2)
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ● 更新消费显示
  678.   #--------------------------------------------------------------------------
  679.   def update_cost
  680.     rate = @target.preview_chance(money, bonus_rate).to_i
  681.     if rate < 0
  682.       new_cost = @target.preview_cost(0, bonus_rate)
  683.     elsif rate < @target.success_rate
  684.       new_cost = @target.preview_cost(@target.success_rate, bonus_rate)
  685.     else
  686.       new_cost = @target.preview_cost(100, bonus_rate)
  687.     end
  688.     if @index == 0
  689.       change_value(new_cost - money)
  690.     else
  691.       price = [$data_items[@items[@index - 1]].price, 1].max
  692.       change_value(((new_cost - money).to_f / price).ceil)
  693.     end
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● 获取要消费的物品
  697.   #--------------------------------------------------------------------------
  698.   def items
  699.     @bonus_item_id > 0 ? @sub_items.merge({@bonus_item_id => 1}) : @sub_items
  700.   end
  701.   #--------------------------------------------------------------------------
  702.   # ● 获取总计消费价值
  703.   #--------------------------------------------------------------------------
  704.   def money
  705.     @sub_items.inject(@gold) {|g, i| g + $data_items[i[0]].price * i[1]}
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # ● 获取奖励机率
  709.   #--------------------------------------------------------------------------
  710.   def bonus_rate
  711.     (item = $data_items[@bonus_item_id]) ? item.equip_bonus_rate : 0
  712.   end
  713. end

  714. #==============================================================================
  715. # ■ Window_SmithEmbed
  716. #------------------------------------------------------------------------------
  717. #   铁匠铺界面,镶嵌孔的选择窗口。
  718. #==============================================================================
  719. class Window_SmithEmbed < Window_Data
  720.   #--------------------------------------------------------------------------
  721.   # ● 初始化对像
  722.   #--------------------------------------------------------------------------
  723.   def initialize
  724.     @equipment = nil
  725.     super(0, window_h << 1, SCREEN_W >> 1, window_h, nil, 4)
  726.     self.z += 3
  727.     deactivate.hide.index = -1
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   # ● 设置当前镶嵌装备
  731.   #--------------------------------------------------------------------------
  732.   def show_embed(equipment)
  733.     @equipment = equipment
  734.     self.height = window_h([equipment.sockets + 3 >> 2, 4].min)
  735.     refresh
  736.     show.activate.index = 0
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # ● 生成数据
  740.   #--------------------------------------------------------------------------
  741.   def make_data
  742.     super
  743.     return unless @equipment
  744.     @data.concat(@equipment.socket_items.map {|i| $data_items[i]})
  745.     @enable_proc = Proc.new {|item| item == nil or @equipment.embed_removable}
  746.   end
  747.   #--------------------------------------------------------------------------
  748.   # ● 绘制镶嵌孔
  749.   #--------------------------------------------------------------------------
  750.   def draw_item(index)
  751.     item = @data[index]
  752.     @drawn[index] = true
  753.     enabled = (@enable_proc == nil or @enable_proc.call(item))
  754.     rect = item_rect(index).inflate(-4, 0)
  755.     # 绘制孔外廓
  756.     text_w = text_size("[").width
  757.     change_color(enabled ? normal_color : disabled_color)
  758.     rect = item_rect(index)
  759.     contents.clear_rect(rect)
  760.     draw_text(rect.x, rect.y, text_w, line_height, "[")
  761.     draw_text(rect.right - text_w, rect.y, text_w, line_height, "]")
  762.     # 如果孔内有道具,绘制道具图标
  763.     if item
  764.       draw_icon(item.icon_name, rect.x + (rect.width - ICON_WIDTH >> 1),
  765.         rect.y, true, line_height)
  766.     end
  767.   end
  768.   #--------------------------------------------------------------------------
  769.   # ● 刷新帮助文本
  770.   #--------------------------------------------------------------------------
  771.   def update_help
  772.     if self.item == nil
  773.       @help_window.set_text(Vocab.embed_empty)
  774.     else
  775.       super
  776.     end
  777.   end
  778. end

  779. #==============================================================================
  780. # ■ Window_SmithEmbedItem
  781. #------------------------------------------------------------------------------
  782. #   铁匠铺界面,镶嵌用道具的选择窗口。
  783. #==============================================================================
  784. class Window_SmithEmbedItem < Window_Data
  785.   #--------------------------------------------------------------------------
  786.   # ● 初始化对像
  787.   #--------------------------------------------------------------------------
  788.   def initialize
  789.     super(0, window_h * 3, SCREEN_W >> 1, -window_h * 3, nil, 1)
  790.     @equipment = nil
  791.     self.z += 3
  792.     deactivate.hide.index = -1
  793.   end
  794.   #--------------------------------------------------------------------------
  795.   # ● 设置当前镶嵌装备
  796.   #--------------------------------------------------------------------------
  797.   def show_embed(equipment)
  798.     @equipment = equipment
  799.     lines_top = [@equipment.sockets + 3 >> 2, 4].min
  800.     top = window_h(lines_top) + (window_h << 1)
  801.     move(0, top, SCREEN_W >> 1, SCREEN_H - top)
  802.     self.index = -1
  803.     refresh
  804.     show
  805.   end
  806.   #--------------------------------------------------------------------------
  807.   # ● 生成数据
  808.   #--------------------------------------------------------------------------
  809.   def make_data
  810.     super
  811.     # 添加可以镶嵌的道具
  812.     @data.concat($game_party.sorted_items.select {|item| item.socketable})
  813.     # 若允许解除镶嵌则添加空白
  814.     @data.push(nil) if @equipment and @equipment.embed_removable
  815.   end
  816. end

  817. #==============================================================================
  818. # ■ Scene_Smith
  819. #------------------------------------------------------------------------------
  820. #   处理铁匠画面的类。
  821. #==============================================================================
  822. class Scene_Smith
  823.   include Scene_Base
  824.   include SailCat::Window_Config
  825.   include SailCat::Equip_Config
  826.   #--------------------------------------------------------------------------
  827.   # ● 建立窗口
  828.   #--------------------------------------------------------------------------
  829.   def create_all_windows
  830.     # 建立帮助窗口
  831.     @help_window = Window_Help.new
  832.     # 建立命令窗口
  833.     @command_window = Window_SmithCommand.new
  834.     # 建立金钱窗口
  835.     @gold_window = Window_SmithGold.new
  836.     # 建立物品窗口
  837.     @item_window = Window_SmithItem.new
  838.     # 建立详情窗口
  839.     height_offset = @help_window.height + @command_window.height
  840.     @info_window = Window_Info.new(SCREEN_W >> 1, height_offset,
  841.       SCREEN_W >> 1, -height_offset)
  842.     # 建立插件独立窗口
  843.     @enchant_window = Window_SmithEnchant.new if $sailcat_import[:EquipEnchant]
  844.     @forge_window = Window_SmithForge.new if $sailcat_import[:EquipLevel]
  845.     if $sailcat_import[:EquipSocket]
  846.       @top_window = Window_SmithEmbed.new
  847.       @bottom_window = Window_SmithEmbedItem.new
  848.     end
  849.   end
  850.   #--------------------------------------------------------------------------
  851.   # ● 设置场景扩展方法处理 1000
  852.   #--------------------------------------------------------------------------
  853.   def post_create_1000
  854.     @help_window.moveto(0, @command_window.height)
  855.     @command_window.help_window = @help_window
  856.     @item_window.index = -1
  857.     @item_window.help_window = @help_window
  858.     @item_window.info_window = @info_window
  859.     @item_window.set_handler(:index_changed, method(:item_index_changed))
  860.     if $sailcat_import[:EquipSocket]
  861.       @top_window.help_window = @help_window
  862.       @bottom_window.help_window = @help_window
  863.     end
  864.   end
  865.   #--------------------------------------------------------------------------
  866.   # ● 设置场景扩展方法处理 9000
  867.   #--------------------------------------------------------------------------
  868.   def post_create_9000
  869.     # 窗口初始状态设置
  870.     @command_window.activate.index = 0
  871.     @item_window.deactivate
  872.   end
  873.   #--------------------------------------------------------------------------
  874.   # ● 更新
  875.   #--------------------------------------------------------------------------
  876.   def update
  877.     # 更新所有窗口
  878.     update_all_windows
  879.   end
  880.   #--------------------------------------------------------------------------
  881.   # ● 更改物品选择处理
  882.   #--------------------------------------------------------------------------
  883.   def item_index_changed
  884.     if @item_window.index == -1 or (item = @item_window.item) == nil
  885.       item_id = -1
  886.     else
  887.       case @item_window.mode
  888.       when 3
  889.         item_id = item.quality_item_id
  890.       when 4
  891.         item_id = [-1].concat(item.accept_items)
  892.       when 5
  893.         item_id = [item.socket_item, item.unsocket_item]
  894.       else
  895.         item_id = -1
  896.       end
  897.     end
  898.     @gold_window.set_item_id(item_id)
  899.   end
  900.   #--------------------------------------------------------------------------
  901.   # ● 命令窗口 B 键处理
  902.   #--------------------------------------------------------------------------
  903.   def command_window_b
  904.     # 演奏取消 SE
  905.     $game_system.se_play($data_system.cancel_se)
  906.     # 返回场景
  907.     SceneManager.return
  908.   end
  909.   #--------------------------------------------------------------------------
  910.   # ● 命令窗口 C 键处理
  911.   #--------------------------------------------------------------------------
  912.   def command_window_c
  913.     # 演奏确定 SE
  914.     $game_system.se_play($data_system.decision_se)
  915.     # 切换窗口焦点
  916.     @command_window.deactivate
  917.     # 根据所选功能刷新物品窗口
  918.     case @command_window.command_text
  919.     when Vocab.repair
  920.       @item_window.set_mode(1)
  921.     when Vocab.enchant
  922.       @item_window.set_mode(2)
  923.     when Vocab.refine
  924.       @item_window.set_mode(3)
  925.     when Vocab.forge
  926.       @item_window.set_mode(4)
  927.     when Vocab.punch
  928.       @item_window.set_mode(5)
  929.     when Vocab.embed
  930.       @item_window.set_mode(6)
  931.     when Vocab.reroll
  932.       @item_window.set_mode(7)
  933.     when Vocab.destroy
  934.       @item_window.set_mode(8)
  935.     end
  936.     @item_window.activate.index = 0
  937.   end
  938.   #--------------------------------------------------------------------------
  939.   # ● 物品窗口 B 键处理
  940.   #--------------------------------------------------------------------------
  941.   def item_window_b
  942.     # 演奏取消 SE
  943.     $game_system.se_play($data_system.cancel_se)
  944.     # 切换窗口焦点
  945.     @item_window.deactivate.index = -1
  946.     @command_window.activate
  947.     @item_window.set_mode(0)
  948.   end
  949.   #--------------------------------------------------------------------------
  950.   # ● 物品窗口 C 键处理
  951.   #--------------------------------------------------------------------------
  952.   def item_window_c
  953.     # 选中物品无效的情况下
  954.     unless @item_window.item
  955.       # 演奏冻结 SE
  956.       $game_system.se_play($data_system.buzzer_se)
  957.       return
  958.     end
  959.     # 执行物品操作
  960.     method("process_item_#{@item_window.mode}".to_sym).call
  961.   end
  962.   #--------------------------------------------------------------------------
  963.   # ● 物品操作取消
  964.   #--------------------------------------------------------------------------
  965.   def process_item_0
  966.     item_window_b
  967.   end
  968.   #--------------------------------------------------------------------------
  969.   # ● 物品操作修理
  970.   #--------------------------------------------------------------------------
  971.   def process_item_1
  972.     # 获得当前的待操作物品
  973.     item = @item_window.item
  974.     # 修理检定未通过的情况下
  975.     if (error = item.repair_state) > 0
  976.       # 演奏冻结 SE
  977.       $game_system.se_play($data_system.buzzer_se)
  978.       # 显示错误信息
  979.       Window_MessageBox.new(Vocab.send("repair_fail_#{error}"), Vocab.repair)
  980.     # 修理检定通过的情况下
  981.     else
  982.       # 演奏确定 SE
  983.       $game_system.se_play($data_system.decision_se)
  984.       # 询问确认的情况下,执行修理
  985.       msg = sprintf(Vocab.repair_confirm, item.info_00, item.repair_cost)
  986.       if Window_MessageBox.new(msg, Vocab.repair, MB_YN).result == DR_YES
  987.         # 演奏装备 SE
  988.         $game_system.se_play($data_system.equip_se)
  989.         # 执行修理
  990.         item.repair
  991.         # 更新相关窗口
  992.         @item_window.refresh
  993.         @item_window.update_help
  994.         @item_window.update_info
  995.         @gold_window.refresh
  996.         info = sprintf(Vocab.repair_info, item.durability, item.max_durability)
  997.         Window_MessageBox.new(info, Vocab.repair)
  998.       end
  999.     end
  1000.   end
  1001.   #--------------------------------------------------------------------------
  1002.   # ● 物品操作附魔
  1003.   #--------------------------------------------------------------------------
  1004.   def process_item_2
  1005.     # 获得当前的待操作物品
  1006.     item = @item_window.item
  1007.     # 附魔检定未通过的情况下
  1008.     if (error = item.enchant_state) > 0
  1009.       # 演奏冻结 SE
  1010.       $game_system.se_play($data_system.buzzer_se)
  1011.       # 显示错误信息
  1012.       Window_MessageBox.new(Vocab.send("enchant_fail_#{error}"), Vocab.enchant)
  1013.     else
  1014.       # 演奏确定 SE
  1015.       $game_system.se_play($data_system.decision_se)
  1016.       # 切换到附魔词缀窗口
  1017.       @item_window.deactivate
  1018.       @enchant_window.show_enchant(item)
  1019.     end
  1020.   end
  1021.   #--------------------------------------------------------------------------
  1022.   # ● 附魔窗口 B 键处理
  1023.   #--------------------------------------------------------------------------
  1024.   def enchant_window_b
  1025.     # 演奏取消 SE
  1026.     $game_system.se_play($data_system.cancel_se)
  1027.     @enchant_window.deactivate.hide
  1028.     # 获得当前的待操作物品
  1029.     item = @item_window.item
  1030.     # 比较附魔词缀变化
  1031.     old_set = item.main_set
  1032.     new_set = @enchant_window.selected_enchants
  1033.     delete_set = old_set - new_set
  1034.     keep_set = old_set & new_set
  1035.     add_set = new_set - old_set
  1036.     # 词缀有变的情况下
  1037.     unless delete_set.empty? and add_set.empty?
  1038.       # 检查附魔消费
  1039.       cost1 = keep_set.sum {|x| $data_states[x].enchant_effects[:price]}
  1040.       cost1 *= keep_set.size
  1041.       cost2 = new_set.sum {|x| $data_states[x].enchant_effects[:price]}
  1042.       cost2 *= new_set.size
  1043.       cost = [cost2 - cost1, 0].max * item.prototype.price / 100
  1044.       # 消费不足的情况下
  1045.       if $game_party.gold < cost
  1046.         Window_MessageBox.new(Vocab.enchant_fail_4, Vocab.enchant)
  1047.       else
  1048.         # 询问确认的情况下,执行附魔
  1049.         msg = sprintf(Vocab.enchant_confirm, item.info_00, cost)
  1050.         if Window_MessageBox.new(msg, Vocab.enchant, MB_YN).result == DR_YES
  1051.           # 演奏装备 SE
  1052.           $game_system.se_play($data_system.equip_se)
  1053.           # 执行附魔
  1054.           $game_party.lose_gold(cost)
  1055.           delete_set.each {|x| item.remove_enchant(x)}
  1056.           add_set.each {|x| item.add_enchant(x)}
  1057.           # 更新相关窗口
  1058.           @item_window.refresh
  1059.           @item_window.update_info
  1060.           @gold_window.refresh
  1061.           info = sprintf(Vocab.enchant_info, delete_set.size, add_set.size)
  1062.           Window_MessageBox.new(info, Vocab.enchant)
  1063.         end
  1064.       end
  1065.     end
  1066.     # 切换到物品窗口
  1067.     @item_window.activate
  1068.   end
  1069.   #--------------------------------------------------------------------------
  1070.   # ● 附魔窗口 C 键处理
  1071.   #--------------------------------------------------------------------------
  1072.   def enchant_window_c
  1073.     case @enchant_window.enchant_state
  1074.     when -1
  1075.       # 演奏冻结 SE
  1076.       $game_system.se_play($data_system.buzzer_se)
  1077.       Window_MessageBox.new(Vocab.enchant_fail_2, Vocab.enchant)
  1078.     when 0, 1
  1079.       # 演奏确定 SE
  1080.       $game_system.se_play($data_system.decision_se)
  1081.       @enchant_window.toggle_enchant
  1082.     when 2, 3
  1083.       # 演奏冻结 SE
  1084.       $game_system.se_play($data_system.buzzer_se)
  1085.       Window_MessageBox.new(Vocab.enchant_fail_3, Vocab.enchant)
  1086.     end
  1087.   end
  1088.   #--------------------------------------------------------------------------
  1089.   # ● 物品操作锤炼
  1090.   #--------------------------------------------------------------------------
  1091.   def process_item_3
  1092.     # 获得当前的待操作物品
  1093.     item = @item_window.item
  1094.     # 锤炼检定未通过的情况下
  1095.     if (error = item.quality_state) > 0
  1096.       # 演奏冻结 SE
  1097.       $game_system.se_play($data_system.buzzer_se)
  1098.       # 显示错误信息
  1099.       Window_MessageBox.new(Vocab.send("refine_fail_#{error}"), Vocab.refine)
  1100.     else
  1101.       # 演奏确定 SE
  1102.       $game_system.se_play($data_system.decision_se)
  1103.       # 询问确认的情况下,执行锤炼
  1104.       msg = sprintf(Vocab.refine_confirm, item.info_00,
  1105.         item.quality_item_id, item.quality_item_count)
  1106.       if Window_MessageBox.new(msg, Vocab.refine, MB_YN).result == DR_YES
  1107.         # 演奏装备 SE
  1108.         $game_system.se_play($data_system.equip_se)
  1109.         # 执行锤炼
  1110.         item.quality_up
  1111.         # 更新相关窗口
  1112.         @item_window.refresh
  1113.         @item_window.update_info
  1114.         @gold_window.refresh
  1115.         text = Vocab.qualities[item.quality - 1] || Vocab.quality_ex
  1116.         if item.quality_param_rate != 0
  1117.           param = sprintf("(%+d)", item.quality_param_rate)
  1118.         else
  1119.           param = "(--)"
  1120.         end
  1121.         new_quality_text = "\\C[#{item.name_color}]#{text}\\}#{param}\\{\\C[0]"
  1122.         info = sprintf(Vocab.refine_info, new_quality_text)
  1123.         Window_MessageBox.new(info, Vocab.refine)
  1124.       end
  1125.     end
  1126.   end
  1127.   #--------------------------------------------------------------------------
  1128.   # ● 物品操作锻造
  1129.   #--------------------------------------------------------------------------
  1130.   def process_item_4
  1131.     # 获得当前的待操作物品
  1132.     item = @item_window.item
  1133.     # 锻造检定未通过的情况下
  1134.     if (error = item.level_state) > 0
  1135.       # 演奏冻结 SE
  1136.       $game_system.se_play($data_system.buzzer_se)
  1137.       # 显示错误信息
  1138.       Window_MessageBox.new(Vocab.send("forge_fail_#{error}"), Vocab.forge)
  1139.     else
  1140.       # 演奏确定 SE
  1141.       $game_system.se_play($data_system.decision_se)
  1142.       # 切换到锻造窗口
  1143.       @item_window.deactivate
  1144.       @forge_window.show_forge(item)
  1145.     end
  1146.   end
  1147.   #--------------------------------------------------------------------------
  1148.   # ● 锻造窗口 B 键处理
  1149.   #--------------------------------------------------------------------------
  1150.   def forge_window_b
  1151.     # 演奏取消 SE
  1152.     $game_system.se_play($data_system.cancel_se)
  1153.     # 切换到物品窗口
  1154.     @forge_window.deactivate.hide
  1155.     @item_window.activate
  1156.   end
  1157.   #--------------------------------------------------------------------------
  1158.   # ● 锻造窗口 C 键处理
  1159.   #--------------------------------------------------------------------------
  1160.   def forge_window_c
  1161.     # 获得当前的待操作物品
  1162.     item = @item_window.item
  1163.     case @forge_window.index
  1164.     when 0...@forge_window.item_max - 3
  1165.       # 演奏确定 SE
  1166.       $game_system.se_play($data_system.decision_se)
  1167.       @forge_window.update_cost
  1168.     when @forge_window.item_max - 3
  1169.       # 演奏确定 SE
  1170.       $game_system.se_play($data_system.decision_se)
  1171.       @forge_window.change_value(1)
  1172.     when @forge_window.item_max - 2
  1173.       # 执行升级操作
  1174.       result = item.level_up(@forge_window.gold, @forge_window.items,
  1175.         @forge_window.bonus_rate)
  1176.       # 升级成功的情况下
  1177.       if result == 0
  1178.         # 演奏装备 SE
  1179.         $game_system.se_play($data_system.equip_se)
  1180.         info = sprintf(Vocab.forge_info, item.level)
  1181.         Window_MessageBox.new(info, Vocab.forge)
  1182.       # 升级失败的情况下
  1183.       else
  1184.         # 装备等级下降的情况下
  1185.         if result == 5
  1186.           # 演奏受伤 SE
  1187.           $game_system.se_play($data_system.actor_collapse_se)
  1188.         # 无法操作的情况下
  1189.         elsif result <= 2
  1190.           # 演奏冻结 SE
  1191.           $game_system.se_play($data_system.buzzer_se)
  1192.         else
  1193.           # 演奏确定 SE
  1194.           $game_system.se_play($data_system.decision_se)
  1195.         end
  1196.         Window_MessageBox.new(Vocab.send("forge_fail_#{result}"), Vocab.forge)
  1197.       end
  1198.       # 更新相关窗口
  1199.       @item_window.refresh
  1200.       @item_window.update_info
  1201.       @gold_window.refresh
  1202.       if item.level_state == 0
  1203.         @forge_window.reset_cost
  1204.         @forge_window.refresh
  1205.       else
  1206.         # 切换到物品窗口
  1207.         @forge_window.deactivate.hide
  1208.         @item_window.activate
  1209.       end
  1210.     when @forge_window.item_max - 1
  1211.       # 演奏确定 SE
  1212.       $game_system.se_play($data_system.decision_se)
  1213.       # 切换到物品窗口
  1214.       @forge_window.deactivate.hide
  1215.       @item_window.activate
  1216.     end
  1217.   end
  1218.   #--------------------------------------------------------------------------
  1219.   # ● 物品操作打孔
  1220.   #--------------------------------------------------------------------------
  1221.   def process_item_5
  1222.     # 获得当前的待操作物品
  1223.     item = @item_window.item
  1224.     # 打孔检定未通过的情况下
  1225.     if item.max_sockets == 0
  1226.       # 演奏冻结 SE
  1227.       $game_system.se_play($data_system.buzzer_se)
  1228.       # 显示错误信息
  1229.       Window_MessageBox.new(Vocab.punch_fail_1, Vocab.punch)
  1230.     else
  1231.       # 演奏确定 SE
  1232.       $game_system.se_play($data_system.decision_se)
  1233.       # 显示打孔菜单
  1234.       commands = [Vocab.punch_open, Vocab.punch_close]
  1235.       menu = Window_ContextMenu.new(commands)
  1236.       start_index = 0
  1237.       if item.sockets == 0
  1238.         menu.disable_item(1)
  1239.       end
  1240.       if item.sockets == item.max_sockets
  1241.         menu.disable_item(0)
  1242.         start_index = 1
  1243.       end
  1244.       x = @item_window.cursor_rect.right + @item_window.x + 16
  1245.       y = @item_window.cursor_rect.y + @item_window.y + 16
  1246.       case menu.show_menu(x, y, start_index)
  1247.       when 0 # 开孔
  1248.         word = Vocab.punch_open
  1249.         material = item.socket_item
  1250.         sym = :open_socket
  1251.       when 1 # 封孔
  1252.         word = Vocab.punch_close
  1253.         material = item.unsocket_item
  1254.         sym = :close_socket
  1255.       when 2
  1256.         return
  1257.       end
  1258.       # 打孔操作
  1259.       if $game_party.item_number(material) > 0
  1260.         msg = sprintf(Vocab.punch_confirm, word, item.info_00, material)
  1261.         if Window_MessageBox.new(msg, Vocab.punch, MB_YN).result == DR_YES
  1262.           # 演奏装备 SE
  1263.           $game_system.se_play($data_system.equip_se)
  1264.           # 执行打孔
  1265.           item.send(sym)
  1266.           # 更新相关窗口
  1267.           @item_window.refresh
  1268.           @item_window.update_info
  1269.           @gold_window.refresh
  1270.           info = sprintf(Vocab.punch_info, word, item.sockets)
  1271.           Window_MessageBox.new(info, Vocab.punch)
  1272.         end
  1273.       else
  1274.         # 演奏冻结 SE
  1275.         $game_system.se_play($data_system.buzzer_se)
  1276.         # 显示错误信息
  1277.         Window_MessageBox.new(Vocab.punch_fail_2, Vocab.punch)
  1278.       end
  1279.     end
  1280.   end
  1281.   #--------------------------------------------------------------------------
  1282.   # ● 物品操作镶嵌
  1283.   #--------------------------------------------------------------------------
  1284.   def process_item_6
  1285.     # 获得当前的待操作物品
  1286.     item = @item_window.item
  1287.     # 镶嵌检定未通过的情况下
  1288.     if (error = item.embed_state) > 0
  1289.       # 演奏冻结 SE
  1290.       $game_system.se_play($data_system.buzzer_se)
  1291.       # 显示错误信息
  1292.       Window_MessageBox.new(Vocab.send("embed_fail_#{error}"), Vocab.embed)
  1293.     else
  1294.       # 演奏确定 SE
  1295.       $game_system.se_play($data_system.decision_se)
  1296.       # 切换到镶嵌窗口
  1297.       @item_window.deactivate
  1298.       @top_window.show_embed(item)
  1299.       @bottom_window.show_embed(item)
  1300.     end
  1301.   end
  1302.   #--------------------------------------------------------------------------
  1303.   # ● 镶孔窗口 B 键处理
  1304.   #--------------------------------------------------------------------------
  1305.   def top_window_b
  1306.     # 演奏取消 SE
  1307.     $game_system.se_play($data_system.cancel_se)
  1308.     # 切换到物品窗口
  1309.     @top_window.deactivate.hide
  1310.     @bottom_window.hide
  1311.     @item_window.activate
  1312.   end
  1313.   #--------------------------------------------------------------------------
  1314.   # ● 镶孔窗口 C 键处理
  1315.   #--------------------------------------------------------------------------
  1316.   def top_window_c
  1317.     # 镶嵌物不能取下的情况下
  1318.     if @top_window.item and not @item_window.item.embed_removable
  1319.       # 演奏冻结 SE
  1320.       $game_system.se_play($data_system.buzzer_se)
  1321.       Window_MessageBox.new(Vocab.embed_fail_3, Vocab.embed)
  1322.     else
  1323.       # 切换到镶嵌物窗口
  1324.       @top_window.deactivate
  1325.       @bottom_window.activate.index = 0
  1326.     end
  1327.   end
  1328.   #--------------------------------------------------------------------------
  1329.   # ● 镶嵌物窗口 B 键处理
  1330.   #--------------------------------------------------------------------------
  1331.   def bottom_window_b
  1332.     # 演奏取消 SE
  1333.     $game_system.se_play($data_system.cancel_se)
  1334.     # 切换到镶孔窗口
  1335.     @bottom_window.deactivate.index = -1
  1336.     @top_window.activate
  1337.   end
  1338.   #--------------------------------------------------------------------------
  1339.   # ● 镶嵌物窗口 C 键处理
  1340.   #--------------------------------------------------------------------------
  1341.   def bottom_window_c
  1342.     # 取得选中的镶嵌物
  1343.     item = @bottom_window.item
  1344.     # 演奏装备 SE
  1345.     $game_system.se_play($data_system.equip_se)
  1346.     # 执行镶嵌
  1347.     @item_window.item.socket(@top_window.index, item ? item.id : 0)
  1348.     # 刷新相关窗口
  1349.     @item_window.refresh
  1350.     @item_window.update_info
  1351.     @top_window.refresh
  1352.     @bottom_window.refresh
  1353.     # 切换到镶孔窗口
  1354.     @bottom_window.deactivate.index = -1
  1355.     @top_window.activate
  1356.   end
  1357.   #--------------------------------------------------------------------------
  1358.   # ● 物品操作幻化
  1359.   #--------------------------------------------------------------------------
  1360.   def process_item_7
  1361.     # 获得当前的待操作物品
  1362.     item = @item_window.item
  1363.     sym = $sailcat_import[:EquipDurability] ? :sailcat_equipdu_price : :price
  1364.     price = item.send(sym)
  1365.     # 幻化检定未通过的情况下
  1366.     if not item.random_enabled?(:ALL)
  1367.       # 演奏冻结 SE
  1368.       $game_system.se_play($data_system.buzzer_se)
  1369.       # 显示错误信息
  1370.       Window_MessageBox.new(Vocab.reroll_fail_1, Vocab.reroll)
  1371.     # 幻化最低消费不足的情况下
  1372.     elsif $game_party.gold < price.factor(REROLL_COST_RATIO.min)
  1373.       # 演奏冻结 SE
  1374.       $game_system.se_play($data_system.buzzer_se)
  1375.       # 显示错误信息
  1376.       Window_MessageBox.new(Vocab.reroll_fail_2, Vocab.reroll)
  1377.     # 幻化检定通过的情况下
  1378.     else
  1379.       # 演奏确定 SE
  1380.       $game_system.se_play($data_system.decision_se)
  1381.       # 显示幻化菜单
  1382.       commands = [1, 2, 3].map {|n|
  1383.         Vocab.send("reroll_grade_#{n}") + Vocab.nbsp + Vocab.reroll}
  1384.       menu = Window_ContextMenu.new(commands)
  1385.       start_index = 0
  1386.       3.times do |x|
  1387.         if $game_party.gold < price.factor(REROLL_COST_RATIO[x])
  1388.           menu.disable_item(x)
  1389.         end
  1390.       end
  1391.       x = @item_window.cursor_rect.right + @item_window.x + 16
  1392.       y = @item_window.cursor_rect.y + @item_window.y + 16
  1393.       result = menu.show_menu(x, y, start_index)
  1394.       # 菜单被取消的情况下,返回
  1395.       return if result == 3
  1396.       cost = price.factor(REROLL_COST_RATIO[result])
  1397.       ranges = []
  1398.       # 低级或高级需限定幻化范围
  1399.       if result != 1
  1400.         if item.random_enabled?(:QUALITY)
  1401.           min = result == 0 ? item.min_quality : item.quality
  1402.           max = result == 0 ? item.quality : item.max_quality
  1403.           ranges.push(min..max)
  1404.         end
  1405.         if item.random_enabled?(:ENCHANT)
  1406.           min = result == 0 ? 0 : item.enchant_count
  1407.           max = result == 0 ? item.enchant_count : item.max_enchant
  1408.           ranges.push(min..max)
  1409.         end
  1410.         if item.random_enabled?(:LEVEL)
  1411.           min = result == 0 ? 0 : item.level
  1412.           max = result == 0 ? item.level : item.max_level
  1413.           ranges.push(min..max)
  1414.         end
  1415.         if item.random_enabled?(:SOCKET)
  1416.           min = result == 0 ? 1 : [item.sockets, 1].max
  1417.           max = result == 0 ? [item.sockets, 1].max : item.max_sockets
  1418.           ranges.push(min..max)
  1419.         end
  1420.       end
  1421.       # 幻化操作
  1422.       msg = sprintf(Vocab.reroll_confirm, item.info_00, cost)
  1423.       if Window_MessageBox.new(msg, Vocab.reroll, MB_YN).result == DR_YES
  1424.         # 演奏装备 SE
  1425.         $game_system.se_play($data_system.equip_se)
  1426.         # 执行幻化
  1427.         $game_party.lose_gold(cost)
  1428.         item.randomize(*ranges)
  1429.         # 更新相关窗口
  1430.         @item_window.refresh
  1431.         @item_window.update_info
  1432.         @gold_window.refresh
  1433.         info = sprintf(Vocab.reroll_info, item.info_00)
  1434.         Window_MessageBox.new(info, Vocab.reroll)
  1435.       end
  1436.     end
  1437.   end
  1438.   #--------------------------------------------------------------------------
  1439.   # ● 物品操作熔毁
  1440.   #--------------------------------------------------------------------------
  1441.   def process_item_8
  1442.     # 获得当前的待操作物品
  1443.     item = @item_window.item
  1444.     # 演奏确定 SE
  1445.     $game_system.se_play($data_system.decision_se)
  1446.     # 询问确认的情况下,执行熔毁
  1447.     gain = item.price.factor(DESTROY_GAIN_RATIO)
  1448.     msg = sprintf(Vocab.destroy_confirm, item.info_00, gain)
  1449.     if Window_MessageBox.new(msg, Vocab.destroy, MB_YN).result == DR_YES
  1450.       # 演奏销毁 SE
  1451.       $game_system.se_play($data_system.enemy_collapse_se)
  1452.       # 执行熔毁
  1453.       item.unsocket_all if $sailcat_import[:EquipSocket]
  1454.       $game_party.lose_object(item, 1)
  1455.       $game_party.gain_gold(gain)
  1456.       # 更新相关窗口
  1457.       @item_window.refresh
  1458.       @item_window.update_help
  1459.       @item_window.update_info
  1460.       @gold_window.refresh
  1461.       Window_MessageBox.new(Vocab.destroy_info, Vocab.repair)
  1462.     end
  1463.   end
  1464. end
复制代码


因为SailCat大神的脚本之间有依赖关系,可能单看这两个脚本还不是特别明朗吧。。

点评

已解决  发表于 2020-3-23 23:13
菜得真实但还是想做游戏
梦石
0
星屑
423
在线时间
37 小时
注册时间
2013-7-1
回帖
16
 楼主| 发表于 2020-3-17 16:38:04 | 显示全部楼层
紧接着不知道什么时候出现的问题。。。
GMV2A887NW}DU1MK_NQ9I%H.png
之前还是好的,只修改了一楼提到的那一个外挂脚本(没有发生错误)
之后再进入战斗就这样了……
百思不得其解……
之前也出现了这种情况,我把脚本备份了一下,删除了所有的外挂脚本
再逐个添回并测试游戏,最终全部添回,错误又消失了
摸不着头脑。。。
菜得真实但还是想做游戏
回复

使用道具 举报

梦石
0
星屑
413
在线时间
214 小时
注册时间
2011-3-21
回帖
142
发表于 2020-3-18 12:32:46 | 显示全部楼层
查找$game_party.gold替换成$game_variables[4]试试?
签名是什么 好吃么
【好吃】
回复

使用道具 举报

梦石
0
星屑
423
在线时间
37 小时
注册时间
2013-7-1
回帖
16
 楼主| 发表于 2020-3-19 12:41:22 | 显示全部楼层
1095884734 发表于 2020-3-18 12:32
查找$game_party.gold替换成$game_variables[4]试试?

消耗金钱改成消耗变量其实已经做到了,我现在面临的问题是
SailCat大神的这个脚本 铁匠铺的界面是单独的金钱窗口,并没有调用通用的window_gold.new,
然后我尝试着修改单独的铁匠铺金钱窗口就会报错  也不知道问题出在哪儿。。
菜得真实但还是想做游戏
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部