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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
423
在线时间
37 小时
注册时间
2013-7-1
帖子
27
跳转到指定楼层
1
发表于 2020-3-17 16:26:04 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

在用SailCat大神写的铁匠铺脚本,其中进行修理操作的时候[消耗金钱]
我想把它修改成[消耗4号变量]
在依赖插件《装备穿戴耐久》中做了一部分修改:
RUBY 代码复制
  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

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

装备穿戴耐久
RUBY 代码复制
  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.  
  92. module RPG
  93.   #============================================================================
  94.   # ■ EquipDurability
  95.   #----------------------------------------------------------------------------
  96.   #  备注定义通用模块。
  97.   #============================================================================
  98.   module EquipDurability
  99.     include SailCat::Equip_Config
  100.     #--------------------------------------------------------------------------
  101.     # ● 备注定义
  102.     #--------------------------------------------------------------------------
  103.     def init_durability;  _du(DURABILITY_DEFAULT);                        end
  104.     def var_durability;   _dv(DURABILITY_VARIANCE);                       end
  105.     def allow_repair;     _dr(true);                                      end
  106.     def repair_efficiency;_de(REPAIR_EFFICIENCY);                         end
  107.     def repair_wear;      _dw(REPAIR_WEAR_OUT);                           end
  108.   end
  109.   #============================================================================
  110.   # ■ RPG::Weapon
  111.   #----------------------------------------------------------------------------
  112.   #  数据库的武器类扩展。
  113.   #============================================================================
  114.   class Weapon
  115.     include EquipDurability
  116.   end
  117.   #============================================================================
  118.   # ■ RPG::Armor
  119.   #----------------------------------------------------------------------------
  120.   #  数据库的防具类扩展。
  121.   #============================================================================
  122.   class Armor
  123.     include EquipDurability
  124.   end
  125. end
  126.  
  127. #==============================================================================
  128. # ■ EquipDurability
  129. #------------------------------------------------------------------------------
  130. #   耐久处理模块。
  131. #==============================================================================
  132. module SailCat::EquipDurability
  133.   include SailCat::Equip_Config
  134.   #--------------------------------------------------------------------------
  135.   # ● 后续设置扩展方法处理 9000
  136.   #--------------------------------------------------------------------------
  137.   def post_setup_9000
  138.     unless @max_durability
  139.       @max_durability = init_durability.variance(var_durability, 100)
  140.       @max_durability_plus = 0
  141.       if @max_durability > 0
  142.         if SPAWN_MAX_DURABILITY.is_a?(Numeric)
  143.           full = $game_switches[SPAWN_MAX_DURABILITY]
  144.         else
  145.           full = SPAWN_MAX_DURABILITY
  146.         end
  147.         @durability = full ? max_durability : rand(max_durability) + 1
  148.         @durability *= WEAR_FACTOR
  149.       else
  150.         @durability = 0
  151.       end
  152.     end
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 无法损毁判定
  156.   #--------------------------------------------------------------------------
  157.   def indestructible?
  158.     self.max_durability == 0
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 获取最大耐久度
  162.   #--------------------------------------------------------------------------
  163.   def max_durability
  164.     get_value(@max_durability, :durability) + @max_durability_plus
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ● 设置最大耐久度
  168.   #     value : 最大耐久度
  169.   #--------------------------------------------------------------------------
  170.   def max_durability=(value)
  171.     @max_durability_plus += value - self.max_durability
  172.     @durability = [@durability, value * WEAR_FACTOR].min
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● 损坏的判定
  176.   #--------------------------------------------------------------------------
  177.   def broken?
  178.     @durability == 0 and self.max_durability > 0
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 可以修理判定
  182.   #--------------------------------------------------------------------------
  183.   def repairable?
  184.     max_durability > repair_wear and repair_efficiency > 0 and allow_repair
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 修理状态检定
  188.   #--------------------------------------------------------------------------
  189.   def repair_state
  190.     return 1 unless broken?
  191.     return 2 unless repairable?
  192.     return 3 unless $game_variables[4] >= repair_cost
  193.     return 0
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ● 执行修理
  197.   #--------------------------------------------------------------------------
  198.   def repair
  199.     $game_variables[i] -= repair_cost
  200.     self.durability = [self.max_durability.factor(repair_efficiency), 1].max
  201.     self.max_durability -= repair_wear
  202.     # 恢复装备的自动状态
  203.     if self.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
  204.       $game_party.actors.each do |actor|
  205.         actor.update_auto_state(nil, self) if actor.equipment.include?(self)
  206.       end
  207.     end
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 获取当前耐久度
  211.   #--------------------------------------------------------------------------
  212.   def durability
  213.     @durability == 0 ? 0 : [@durability / WEAR_FACTOR, 1].max
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● 设置当前耐久度
  217.   #     value : 当前耐久度
  218.   #--------------------------------------------------------------------------
  219.   def durability=(value)
  220.     # 装备可用状态有变化的情况下,清除缓存
  221.     clear_value_cache if @durability * value <= 0
  222.     @durability = value.limit(0, self.max_durability) * WEAR_FACTOR
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 耐久度的消耗
  226.   #     value_lost : 磨损度
  227.   #     flag       : 允许损毁标记
  228.   #--------------------------------------------------------------------------
  229.   def wear(value_lost, flag)
  230.     # 防止战斗中途损坏
  231.     min = [@durability, flag ? 0 : 1].min
  232.     # 耐久度的精算减损
  233.     @durability = [@durability - value_lost, min].max
  234.     # 磨坏了的情况下,清除缓存
  235.     clear_value_cache if broken?
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● 获得残值
  239.   #--------------------------------------------------------------------------
  240.   def remain_value
  241.     sailcat_equipdu_price.factor(REMAINDER_VALUE)
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 获得使用价值
  245.   #--------------------------------------------------------------------------
  246.   def consumable_value
  247.     sailcat_equipdu_price.factor(100 - REMAINDER_VALUE)
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 获得修理费
  251.   #--------------------------------------------------------------------------
  252.   def repair_cost
  253.     consumable_value.factor(REPAIR_COST_FACTOR)
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # ● 前缀(第四部分)
  257.   #--------------------------------------------------------------------------
  258.   def prefix_part4
  259.     broken? ? (repairable? ? Vocab.broken : Vocab.scrapped) : ""
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ● 获得耐久度字符串
  263.   #--------------------------------------------------------------------------
  264.   def durability_s
  265.     if $sailcat_import[:WindowCore]
  266.       if broken?
  267.         color = 18
  268.       elsif durability < max_durability >> 2
  269.         color = 17
  270.       elsif durability == max_durability
  271.         color = 24
  272.       else
  273.         color = 0
  274.       end
  275.       "\\C[#{color}]#{durability}\\C[0]"
  276.     else
  277.       durability.to_s
  278.     end
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 详情信息 耐久度
  282.   #--------------------------------------------------------------------------
  283.   def info_02
  284.     return nil if indestructible?
  285.     text_s(Vocab.durability, sprintf("%s/%d", durability_s, max_durability))
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 详情信息 不可磨损
  289.   #--------------------------------------------------------------------------
  290.   def info_97
  291.     indestructible? && init_durability > 0 ? Vocab.indestructible : nil
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 详情信息 不可修复
  295.   #--------------------------------------------------------------------------
  296.   def info_98
  297.     !indestructible? && !allow_repair ? Vocab.unrepairable : nil
  298.   end
  299. end
  300.  
  301. #==============================================================================
  302. # ■ Game_Weapon
  303. #==============================================================================
  304. class Game_Weapon
  305.   include SailCat::EquipDurability
  306.   #--------------------------------------------------------------------------
  307.   # ● 方法重定义
  308.   #--------------------------------------------------------------------------
  309.   unless method_defined?(:sailcat_equidu_price)
  310.     alias sailcat_equipdu_price price
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 获得磨损值
  314.   #     symbol : 磨损场合的标识符
  315.   #--------------------------------------------------------------------------
  316.   def wear_value(symbol)
  317.     WEAPON_WEAR_FACTORS[symbol] || 0
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 获得价格
  321.   #--------------------------------------------------------------------------
  322.   def price
  323.     if init_durability > 0
  324.       remain_value + consumable_value.factor(durability, init_durability)
  325.     else
  326.       sailcat_equipdu_price
  327.     end
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # ● 说明文字
  331.   #--------------------------------------------------------------------------
  332.   def description
  333.     if max_durability > 0
  334.       super + sprintf(Vocab.durability_a, durability_s, max_durability)
  335.     else
  336.       super
  337.     end
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ● 名称的颜色索引
  341.   #--------------------------------------------------------------------------
  342.   def name_color
  343.     broken? ? 18 : super
  344.   end
  345. end
  346.  
  347. #==============================================================================
  348. # ■ Game_Armor
  349. #==============================================================================
  350. class Game_Armor
  351.   include SailCat::EquipDurability
  352.   #--------------------------------------------------------------------------
  353.   # ● 方法重定义
  354.   #--------------------------------------------------------------------------
  355.   unless method_defined?(:sailcat_equidu_price)
  356.     alias sailcat_equipdu_price price
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 获得磨损值
  360.   #     symbol : 磨损场合的标识符
  361.   #--------------------------------------------------------------------------
  362.   def wear_value(symbol)
  363.     (set = ARMOR_WEAR_FACTORS[symbol]) ? set[kind] || set[-1] : 0
  364.   end
  365.   #--------------------------------------------------------------------------
  366.   # ● 获得价格
  367.   #--------------------------------------------------------------------------
  368.   def price
  369.     if init_durability > 0
  370.       remain_value + consumable_value.factor(durability, init_durability)
  371.     else
  372.       sailcat_equipdu_price
  373.     end
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 说明文字
  377.   #--------------------------------------------------------------------------
  378.   def description
  379.     if max_durability > 0
  380.       super + sprintf(Vocab.durability_a, durability_s, max_durability)
  381.     else
  382.       super
  383.     end
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ● 名称的颜色索引
  387.   #--------------------------------------------------------------------------
  388.   def name_color
  389.     broken? ? 18 : super
  390.   end
  391. end
  392.  
  393. #==============================================================================
  394. # ■ Game_Battler
  395. #==============================================================================
  396. class Game_Battler
  397.   #--------------------------------------------------------------------------
  398.   # ● 攻击收尾扩展方法处理 4000
  399.   #--------------------------------------------------------------------------
  400.   def post_attack_4000(attacker)
  401.     # 不是强制行动的情况下,执行磨损
  402.     unless attacker.current_action.forcing
  403.       # 攻击者是角色的情况下
  404.       if attacker.actor?
  405.         # 击中/打空磨损
  406.         attacker.wear_equipment(@damage == Vocab.miss ? :missing : :striking)
  407.         # 会心磨损
  408.         attacker.wear_equipment(:critical) if @critical
  409.       end
  410.       # 被攻击者是角色的情况下
  411.       if actor?
  412.         # 挨打/闪避磨损
  413.         wear_equipment(@damage == Vocab.miss ? :evaded : :struck)
  414.         # 会心磨损
  415.         wear_equipment(:critical_struck) if @critical
  416.       end
  417.     end   
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 特技收尾扩展方法处理 4000
  421.   #--------------------------------------------------------------------------
  422.   def post_skill_4000(user, skill)
  423.     # 不是强制行动的情况下,执行磨损
  424.     unless user.current_action.forcing
  425.       # 攻击者是角色的情况下
  426.       if user.actor?
  427.         # 击中/打空磨损
  428.         user.wear_equipment(@damage == Vocab.miss ? :skill_miss : :skill_hit)
  429.         # 会心磨损
  430.         user.wear_equipment(:critical) if @critical
  431.       end
  432.       # 被攻击者是角色的情况下
  433.       if actor?
  434.         # 挨打/闪避磨损
  435.         wear_equipment(@damage == Vocab.miss ? :evaded : :struck)
  436.         # 会心磨损
  437.         wear_equipment(:critical_struck) if @critical
  438.       end
  439.     end   
  440.   end
  441. end
  442.  
  443. #==============================================================================
  444. # ■ Game_Actor
  445. #==============================================================================
  446. class Game_Actor
  447.   #--------------------------------------------------------------------------
  448.   # ● 方法重定义
  449.   #--------------------------------------------------------------------------
  450.   unless method_defined?(:sailcat_equidu_weapons)
  451.     alias sailcat_equipdu_weapons weapons
  452.     alias sailcat_equipdu_armors armors
  453.     alias sailcat_equipdu_equipment equipment
  454.     alias sailcat_equipdu_weapon weapon
  455.     alias sailcat_equipdu_update_auto_state update_auto_state
  456.   end
  457.   #--------------------------------------------------------------------------
  458.   # ● 全身的有效装备
  459.   #--------------------------------------------------------------------------
  460.   def equipment
  461.     sailcat_equipdu_equipment.reject {|equip| equip.broken?}
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 装备的有效武器
  465.   #--------------------------------------------------------------------------
  466.   def weapons
  467.     sailcat_equipdu_weapons.reject {|weapon| weapon.broken?}
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # ● 装备的武器(RPG::Weapon)
  471.   #--------------------------------------------------------------------------
  472.   def weapon
  473.     (w = sailcat_equipdu_weapon) && w.broken? ? nil : w
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # ● 装备的有效防具
  477.   #--------------------------------------------------------------------------
  478.   def armors
  479.     sailcat_equipdu_armors.reject {|armor| armor.broken?}
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # ● 获取来自装备的数值
  483.   #--------------------------------------------------------------------------
  484.   def equip_param(scope, symbol, default = 0)
  485.     scope.to_a.sum do |e|
  486.       e.respond_to?(symbol) && !e.broken? ? e.send(symbol) : default
  487.     end
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # ● 磨损装备处理
  491.   #     symbol : 磨损场合标识符
  492.   #--------------------------------------------------------------------------
  493.   def wear_equipment(symbol)
  494.     equipment.each do |e|
  495.       next if e.indestructible? or (value = e.wear_value(symbol)) == 0
  496.       flag = e.broken?
  497.       e.wear(value, WEAROUT_IN_BATTLE || symbol == :combat)
  498.       # 本次磨损损坏的情况下
  499.       if e.broken? and not flag
  500.         if REMOVE_BROKEN_AUTO
  501.           equip(all_equipment.index(e), 0)
  502.         else
  503.           # 取消装备的自动状态效果
  504.           if e.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
  505.             sailcat_equipdu_update_auto_state(e, nil)
  506.           end
  507.           fix_hp
  508.           fix_sp
  509.         end
  510.       end
  511.     end
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ● 更新自动状态
  515.   #     old_equip : 卸下防具/武器
  516.   #     new_equip : 装备防具/武器
  517.   #--------------------------------------------------------------------------
  518.   def update_auto_state(old_equip, new_equip)
  519.     # 取消损坏的装备
  520.     old_equip = nil if old_equip.respond_to?(:broken?) and old_equip.broken?
  521.     new_equip = nil if new_equip.respond_to?(:broken?) and new_equip.broken?
  522.     sailcat_equipdu_update_auto_state(old_equip, new_equip)
  523.   end
  524. end
  525.  
  526. #==============================================================================
  527. # ■ Scene_Battle
  528. #==============================================================================
  529. class Scene_Battle
  530.   #--------------------------------------------------------------------------
  531.   # ● 方法重定义
  532.   #--------------------------------------------------------------------------
  533.   unless method_defined?(:sailcat_equipdu_make_attack_action_result)
  534.     alias sailcat_equipdu_make_attack_action_result make_attack_action_result
  535.     alias sailcat_equipdu_make_guard_action_result make_guard_action_result
  536.     alias sailcat_equipdu_make_skill_action_result make_skill_action_result
  537.     alias sailcat_equipdu_update_phase4_step6 update_phase4_step6
  538.     alias sailcat_equipdu_battle_end battle_end
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # ● 生成攻击行动结果
  542.   #--------------------------------------------------------------------------
  543.   def make_attack_action_result
  544.     sailcat_equipdu_make_attack_action_result
  545.     # 攻击者是角色的情况下,执行攻击行动磨损
  546.     @active_battler.wear_equipment(:attack) if @active_battler.actor?
  547.   end
  548.   #--------------------------------------------------------------------------
  549.   # ● 生成防御行动结果
  550.   #--------------------------------------------------------------------------
  551.   def make_guard_action_result
  552.     sailcat_equipdu_make_guard_action_result
  553.     # 防御者是角色的情况下,执行防御行动磨损
  554.     @active_battler.wear_equipment(:guard) if @active_battler.actor?
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # ● 生成特技行动结果
  558.   #--------------------------------------------------------------------------
  559.   def make_skill_action_result
  560.     sailcat_equipdu_make_skill_action_result
  561.     skill = $data_skills[@active_battler.current_action.skill_id]
  562.     # 特技确实有效的情况下,执行特技行动磨损
  563.     unless @phase4_step == 1 or not @active_battler.actor?
  564.       symbol = skill.atk_f > 0 ? :skill_physical : :skill_magical
  565.       @active_battler.wear_equipment(symbol)
  566.     end
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  570.   #--------------------------------------------------------------------------
  571.   def update_phase4_step6
  572.     sailcat_equipdu_update_phase4_step6
  573.     # 回合磨损
  574.     if @active_battler and @active_battler.actor?
  575.       @active_battler.wear_equipment(:turn)
  576.     end
  577.   end
  578.   #--------------------------------------------------------------------------
  579.   # ● 战斗结束
  580.   #--------------------------------------------------------------------------
  581.   def battle_end(result)
  582.     # 战斗结束磨损
  583.     $game_party.actors.each {|a| a.wear_equipment(:combat)}
  584.     sailcat_equipdu_battle_end(result)
  585.   end
  586. end


铁匠铺界面:
RUBY 代码复制
  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. #==============================================================================
  126. # ■ Vocab
  127. #------------------------------------------------------------------------------
  128. #   所有用语的整合模块。
  129. #==============================================================================
  130. module Vocab
  131.   self.help_text.merge!({
  132.     :smith_repair => HELP_REPAIR,
  133.     :smith_enchant => HELP_ENCHANT,
  134.     :smith_refine => HELP_REFINE,
  135.     :smith_forge => HELP_FORGE,
  136.     :smith_punch => HELP_PUNCH,
  137.     :smith_embed => HELP_EMBED,
  138.     :smith_reroll => HELP_REROLL,
  139.   })
  140. end
  141.  
  142. #==============================================================================
  143. # ■ Window_SmithCommand
  144. #------------------------------------------------------------------------------
  145. #   铁匠铺界面,显示铁匠指令列表的窗口。
  146. #==============================================================================
  147. class Window_SmithCommand < Window_HorzCommand
  148.   #--------------------------------------------------------------------------
  149.   # ● 初期化
  150.   #--------------------------------------------------------------------------
  151.   def initialize
  152.     @commands = []
  153.     @commands.push(Vocab.repair)  if $sailcat_import[:EquipDurability]
  154.     @commands.push(Vocab.enchant) if $sailcat_import[:EquipEnchant]
  155.     @commands.push(Vocab.refine)  if $sailcat_import[:EquipQuality]
  156.     @commands.push(Vocab.forge)   if $sailcat_import[:EquipLevel]
  157.     @commands.push(Vocab.embed)   if $sailcat_import[:EquipSocket]
  158.     @commands.push(Vocab.reroll)  if $sailcat_import[:EquipRandomize]
  159.     super(SCREEN_W, @commands)
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # ● 选中的命令文字
  163.   #--------------------------------------------------------------------------
  164.   def command_text
  165.     @commands[@index]
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 刷新帮助文本
  169.   #--------------------------------------------------------------------------
  170.   def update_help
  171.     case command_text
  172.     when Vocab.repair
  173.       @help_window.set_text(Vocab.help_text[:smith_repair])
  174.     when Vocab.enchant
  175.       @help_window.set_text(Vocab.help_text[:smith_enchant])
  176.     when Vocab.refine
  177.       @help_window.set_text(Vocab.help_text[:smith_refine])
  178.     when Vocab.forge
  179.       @help_window.set_text(Vocab.help_text[:smith_forge])
  180.     when Vocab.embed
  181.       @help_window.set_text(Vocab.help_text[:smith_embed])
  182.     when Vocab.reroll
  183.       @help_window.set_text(Vocab.help_text[:smith_reroll])
  184.     end
  185.   end
  186. end
  187.  
  188. #==============================================================================
  189. # ■ Window_SmithItem
  190. #------------------------------------------------------------------------------
  191. #   铁匠铺界面,显示装备列表的窗口。
  192. #==============================================================================
  193. class Window_SmithItem < Window_Data
  194.   #--------------------------------------------------------------------------
  195.   # ● 定义实例变量
  196.   #--------------------------------------------------------------------------
  197.   attr_reader   :mode                     # 模式
  198.   #--------------------------------------------------------------------------
  199.   # ● 初始化对像
  200.   #--------------------------------------------------------------------------
  201.   def initialize
  202.     @mode = 0
  203.     super(0, window_h << 1, SCREEN_W >> 1, -window_h * 3, nil, 1)
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● 生成数据
  207.   #--------------------------------------------------------------------------
  208.   def make_data
  209.     super
  210.     @data = $game_party.sorted_weapons + $game_party.sorted_armors
  211.     @enable_proc = Proc.new {|item|
  212.       case @mode
  213.       when 0
  214.         true
  215.       when 1
  216.         item.broken? and item.repairable?
  217.       when 2
  218.         item.prototype.available_enchants.size > 0
  219.       when 3
  220.         item.quality < item.max_quality
  221.       when 4
  222.         item.level < item.max_level
  223.       when 5
  224.         item.sockets > 0 and (item.embed_removable or item.empty_sockets > 0)
  225.       end}
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ● 设置模式
  229.   #     mode : 模式
  230.   #--------------------------------------------------------------------------
  231.   def set_mode(mode)
  232.     @mode = mode
  233.     refresh
  234.   end
  235. end
  236.  
  237. #==============================================================================
  238. # ■ Window_SmithGold
  239. #------------------------------------------------------------------------------
  240. #   铁匠铺界面,显示金钱或所需道具的窗口。
  241. #==============================================================================
  242. class Window_SmithGold < Window_Base
  243.   include SailCat::Equip_Config
  244.   #--------------------------------------------------------------------------
  245.   # ● 初始化窗口
  246.   #--------------------------------------------------------------------------
  247.   def initialize
  248.     super(0, SCREEN_H - window_h, SCREEN_W >> 1, window_h)
  249.     self.contents = Bitmap.new(width - 32, height - 32)
  250.     @item_ids = [-1]
  251.     @index = 0
  252.     @frame_count = 0
  253.     refresh
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # ● 刷新
  257.   #--------------------------------------------------------------------------
  258.   def refresh
  259.     contents.clear
  260.     self.contents_opacity = 255
  261.     @frame_count = 0
  262.     if @item_ids[@index] == -1
  263.       draw_currency_value(number, Vocab.gold, 4, 0, width - 40)
  264.     elsif @item_ids[@index] > 0
  265.       rect = contents.rect.inflate(-4, 0)
  266.       number_width = text_size(ITEM_MAX).width.limit(24, 66) + 16
  267.       draw_item_name($data_items[@item_ids[@index]], 4, 0, true,
  268.         rect.width - number_width)
  269.       draw_text(rect.right - number_width, 0, 16, rect.height, ":", 1)
  270.       draw_text(rect.right - number_width + 16, 0,
  271.         number_width - 16, rect.height, number, 2)
  272.     end
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● 设置要显示的道具ID
  276.   #     item_id : 道具ID
  277.   #--------------------------------------------------------------------------
  278.   def set_item_id(item_id)
  279.     if @item_ids != item_id.to_a
  280.       @item_ids = item_id.to_a
  281.       @index = 0
  282.       refresh
  283.     end
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 获取数目
  287.   #--------------------------------------------------------------------------
  288.   def number
  289.     item_id = @item_ids[@index]
  290.     item_id == -1 ? $game_party.gold : $game_party.item_number(item_id)
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ● 刷新画面
  294.   #--------------------------------------------------------------------------
  295.   def update
  296.     super
  297.     if @item_ids.size > 1
  298.       @frame_count += 1
  299.       if @frame_count >= GOLD_WINDOW_DELAY
  300.         self.contents_opacity -= (255.to_f / GOLD_WINDOW_FADE).ceil
  301.         if @frame_count == GOLD_WINDOW_DELAY + GOLD_WINDOW_FADE
  302.           @index = (@index + 1) % @item_ids.size
  303.           refresh
  304.           self.contents_opacity = 0
  305.           @frame_count = -GOLD_WINDOW_FADE
  306.         end
  307.       elsif @frame_count < 0
  308.         self.contents_opacity += (255.to_f / GOLD_WINDOW_FADE).ceil
  309.       end
  310.     end
  311.   end
  312. end
  313.  
  314. #==============================================================================
  315. # ■ Window_SmithEnchant
  316. #------------------------------------------------------------------------------
  317. #   铁匠铺界面,显示附魔词缀的选择窗口。
  318. #==============================================================================
  319. class Window_SmithEnchant < Window_Selectable
  320.   #--------------------------------------------------------------------------
  321.   # ● 初始化窗口
  322.   #--------------------------------------------------------------------------
  323.   def initialize
  324.     super(0, 0, 576, 416)
  325.     center.hide.deactivate.z += 3
  326.     @selected = []
  327.     @column_max = 3
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # ● 设置显示的装备
  331.   #     item : 装备
  332.   #--------------------------------------------------------------------------
  333.   def show_enchant(item)
  334.     return unless item
  335.     @data = item.prototype.available_enchants
  336.     main_set = item.main_set
  337.     sub_set = item.sub_set
  338.     available_set = item.available_enchants
  339.     @selected = @data.map {|k|
  340.       if main_set.include?(k) or main_set.include?(-k)
  341.         1
  342.       elsif sub_set.include?(k) or sub_set.include?(-k)
  343.         3
  344.       elsif not available_set.include?(k)
  345.         2
  346.       else
  347.         0
  348.       end}
  349.     @item_max = @data.size
  350.     @max_sel = item.max_enchant
  351.     refresh
  352.     self.height = [contents.height + 32, 416].min
  353.     center.show.activate.index = 0
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 刷新
  357.   #--------------------------------------------------------------------------
  358.   def refresh
  359.     create_contents
  360.     @item_max.times {|n| draw_state(n)}
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 设置选择状态
  364.   #     index  : 索引
  365.   #     select : 选择状态(0-3)
  366.   #--------------------------------------------------------------------------
  367.   def set_select(index, select)
  368.     @selected[index] = select
  369.     draw_state(index)
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # ● 获得词缀状态
  373.   #     index  : 索引
  374.   #--------------------------------------------------------------------------
  375.   def enchant_state(index = @index)
  376.     n = @selected[index]
  377.     n == 0 ? (selected_enchants.size >= @max_sel ? -1 : 0) : n
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ● 切换所选附魔开关
  381.   #--------------------------------------------------------------------------
  382.   def toggle_enchant
  383.     return unless state = $data_states[@data[@index]]
  384.     if @selected[@index] == 0
  385.       set_select(@index, 1)
  386.       state.chain_enchant_set.each do |x|
  387.         set_select(i, 3) if i = @data.index(x) and x != @data[@index]
  388.       end
  389.       state.reject_enchant_set.each do |x|
  390.         set_select(i, 2) if i = @data.index(x) and x != @data[@index]
  391.       end
  392.     elsif @selected[@index] == 1
  393.       set_select(@index, 0)
  394.       state.chain_enchant_set.each do |x|
  395.         set_select(i, 0) if i = @data.index(x) and x != @data[@index]
  396.       end
  397.       state.reject_enchant_set.each do |x|
  398.         set_select(i, 0) if i = @data.index(x) and x != @data[@index]
  399.       end
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ● 绘制词缀名
  404.   #--------------------------------------------------------------------------
  405.   def draw_state(index)
  406.     contents.clear_rect(item_rect(index))
  407.     text = $data_states[@data[index]].enchant_name
  408.     text = "[" + text + "]" if @selected[index] & 1 == 1
  409.     change_color(@selected[index] > 1 ? disabled_color : normal_color)
  410.     draw_text(item_rect(index), text, 1)
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # ● 获得选中的词缀集
  414.   #--------------------------------------------------------------------------
  415.   def selected_enchants
  416.     (0...@item_max).map {|i| @selected[i] == 1 ? @data[i] : nil}.compact
  417.   end
  418. end
  419.  
  420. #==============================================================================
  421. # ■ Window_SmithForge
  422. #------------------------------------------------------------------------------
  423. #   铁匠铺界面,显示锻造消费情况的确认窗口。
  424. #==============================================================================
  425. class Window_SmithForge < Window_Base
  426.   include Window_Handler
  427.   #--------------------------------------------------------------------------
  428.   # ● 定义实例变量
  429.   #--------------------------------------------------------------------------
  430.   attr_reader   :index                    # 光标位置
  431.   attr_reader   :item_max                 # 项目数
  432.   attr_reader   :gold                     # 变量
  433.   #--------------------------------------------------------------------------
  434.   # ● 初始化窗口
  435.   #--------------------------------------------------------------------------
  436.   def initialize
  437.     super(0, 0, SCREEN_W >> 1, 320)
  438.     @handler = {}
  439.     center.hide.deactivate.z += 3
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # ● 设置显示的装备
  443.   #     item : 装备
  444.   #--------------------------------------------------------------------------
  445.   def show_forge(item)
  446.     # 设置锻造目标
  447.     @target = item
  448.     # 锻造用物品
  449.     @items = item.accept_items
  450.     @sub_items = {}
  451.     # 额外物品
  452.     @bonus_items = $game_party.sorted_items.select {|item|
  453.       item.equip_bonus_rate != 0}.map {|item| item.id}
  454.     @bonus_items.unshift(0)
  455.     @item_max = @items.size + 4
  456.     resize(SCREEN_W >> 1, window_h(@item_max + 2))
  457.     create_contents
  458.     reset_cost
  459.     refresh
  460.     center.show.activate.index = 0
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● 重设消费数值
  464.   #--------------------------------------------------------------------------
  465.   def reset_cost
  466.     @gold = 0
  467.     @items.each {|item_id| @sub_items[item_id] = 0}
  468.     @bonus_item_id = 0
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● 刷新
  472.   #--------------------------------------------------------------------------
  473.   def refresh
  474.     # 清除内容
  475.     contents.clear
  476.     # 绘制各提示语文字
  477.     change_color(system_color)
  478.     w = contents.width
  479.     h = line_height
  480.     x = @items.size
  481.     draw_text(0, 0, w, h, Vocab.forge, 1)
  482.     contents.fill_rect(0, h - 1, w, 1, system_color)
  483.     gold_text = sprintf(Vocab.forge_text_gold, Vocab.gold)
  484.     draw_text(0, line_height(1), w, h, gold_text)
  485.     draw_text(0, line_height(2), w, h, Vocab.forge_text_item)
  486.     draw_text(0, line_height(3 + x), w, h, Vocab.forge_text_bonus)
  487.     draw_text(0, line_height(4 + x), w, h, Vocab.forge_text_rate)
  488.     # 绘制物品名称
  489.     w = text_size(ITEM_MAX).width.limit(24, 66) + 32
  490.     x.times do |i|
  491.       item = $data_items[@items[i]]
  492.       draw_item_name(item, 0, line_height(3 + i), true, contents.width - w)
  493.       change_color(normal_color)
  494.       draw_text(contents.width - w - 32, line_height(3 + i), 24, h, "×", 1)
  495.     end
  496.     # 绘制各项可调数值
  497.     draw_gold
  498.     x.times {|i| draw_item_number(i)}
  499.     draw_bonus_item
  500.     update_rate
  501.     # 绘制确定和取消按钮
  502.     change_color(normal_color)
  503.     w = contents.width - CURSOR_PADDING >> 1
  504.     draw_text(0, line_height(5 + x), w, h, Vocab.ok, 1)
  505.     draw_text(w + CURSOR_PADDING, line_height(5 + x), w, h, Vocab.cancel, 1)
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ● 绘制变量数量
  509.   #--------------------------------------------------------------------------
  510.   def draw_gold
  511.     change_color(normal_color)
  512.     w = text_size(GOLD_MAX).width.limit(48, 100) + 4
  513.     contents.redraw_text(contents.width - w, line_height(1),
  514.       w - 4, line_height, @gold, 2)
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # ● 绘制物品数量
  518.   #--------------------------------------------------------------------------
  519.   def draw_item_number(i = @index - 1)
  520.     change_color(normal_color)
  521.     w = text_size(ITEM_MAX).width.limit(24, 66) + 4
  522.     contents.redraw_text(contents.width - w, line_height(3 + i),
  523.       w - 4, line_height, @sub_items[@items[i]], 2)
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   # ● 绘制额外物品
  527.   #--------------------------------------------------------------------------
  528.   def draw_bonus_item
  529.     x = text_size(Vocab.forge_text_bonus).width + 8
  530.     w = contents.width - x - 4
  531.     rect = Rect.new(x, line_height(3 + @items.size), w, line_height)
  532.     if @bonus_item_id == 0
  533.       change_color(disabled_color)
  534.       contents.redraw_text(rect, Vocab.forge_no_bonus)
  535.     else
  536.       item = $data_items[@bonus_item_id]
  537.       contents.clear_rect(rect)
  538.       draw_item_name(item, rect.x, rect.y, true, rect.width)
  539.     end
  540.   end
  541.   #--------------------------------------------------------------------------
  542.   # ● 刷新画面
  543.   #--------------------------------------------------------------------------
  544.   def update
  545.     super
  546.     update_keypress if self.active
  547.   end
  548.   #--------------------------------------------------------------------------
  549.   # ● 设置光标的位置
  550.   #     index : 新的光标位置
  551.   #--------------------------------------------------------------------------
  552.   def index=(index)
  553.     @index = index
  554.     update_cursor_rect
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # ● 上键处理
  558.   #--------------------------------------------------------------------------
  559.   def update_up(force)
  560.     if @index > 0 or force
  561.       $game_system.se_play($data_system.cursor_se)
  562.       self.index = @index > 0 ? [@index - 1, @item_max - 3].min : @item_max - 2
  563.     end
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # ● 下键处理
  567.   #--------------------------------------------------------------------------
  568.   def update_down(force)
  569.     if @index > @item_max - 3 or force
  570.       $game_system.se_play($data_system.cursor_se)
  571.       self.index = @index > @item_max - 3 ? 0 : @index + 1
  572.     end
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● 左右键、LR键处理
  576.   #--------------------------------------------------------------------------
  577.   def update_left(force); key_num(@index != @item_max - 2 || force, -1);  end
  578.   def update_right(force);key_num(@index != @item_max - 1 || force, +1);  end
  579.   def update_pageup;      key_num(@index != @item_max - 2, -10);          end
  580.   def update_pagedown;    key_num(@index != @item_max - 1, +10);          end
  581.   #--------------------------------------------------------------------------
  582.   # ● 按键变化数值处理
  583.   #     condition   : 变化条件
  584.   #     delta_value : 变化量
  585.   #--------------------------------------------------------------------------
  586.   def key_num(condition, delta_value)
  587.     if condition
  588.       # 演奏光标 SE
  589.       $game_system.se_play($data_system.cursor_se)
  590.       change_value(delta_value * 100 ** Input.modifier)
  591.     end
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ● 增减数量值
  595.   #     delta : 变化量
  596.   #--------------------------------------------------------------------------
  597.   def change_value(delta)
  598.     case @index
  599.     when 0
  600.       set_gold(@gold + delta)
  601.     when 1..@items.size
  602.       item_id = @items[@index - 1]
  603.       set_item(item_id, @sub_items[item_id] + delta)
  604.     when @item_max - 3
  605.       set_bonus(delta <=> 0)
  606.     else
  607.       self.index = (@item_max << 1) - @index - 3
  608.     end
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ● 光标有效判定
  612.   #--------------------------------------------------------------------------
  613.   def cursor_respond?
  614.     true
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # ● 更新光标矩形
  618.   #--------------------------------------------------------------------------
  619.   def update_cursor_rect
  620.     cw = contents.width
  621.     case @index
  622.     when 0
  623.       w = text_size(GOLD_MAX).width.limit(48, 100) + 8
  624.       x, y = cw - w, 1
  625.     when 1..@items.size
  626.       w = text_size(ITEM_MAX).width.limit(24, 66) + 8
  627.       x, y = cw - w, 2
  628.     when @item_max - 3
  629.       w = cw - text_size(Vocab.forge_text_bonus).width - 4
  630.       x, y = cw - w, 2
  631.     when @item_max - 2
  632.       w = cw - CURSOR_PADDING >> 1
  633.       x, y = 0, 3
  634.     when @item_max - 1
  635.       w = cw - CURSOR_PADDING >> 1
  636.       x, y = cw - w, 2
  637.     end
  638.     self.cursor_rect = Rect.new(x, line_height(@index + y), w, line_height)
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 设置金钱数量
  642.   #     gold : 金钱数量
  643.   #--------------------------------------------------------------------------
  644.   def set_gold(gold)
  645.     @gold = gold.limit(0, $game_party.gold)
  646.     draw_gold
  647.     update_rate
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ● 设置物品数量
  651.   #     id     : 物品 ID
  652.   #     number : 物品数量
  653.   #--------------------------------------------------------------------------
  654.   def set_item(id, number)
  655.     @sub_items[id] = number.limit(0, $game_party.item_number(id))
  656.     draw_item_number
  657.     update_rate
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # ● 设置奖励物品
  661.   #     delta : 增减方向
  662.   #--------------------------------------------------------------------------
  663.   def set_bonus(delta)
  664.     bonus_index = @bonus_items.index(@bonus_item_id)
  665.     @bonus_item_id = @bonus_items[(bonus_index + delta) % @bonus_items.size]
  666.     draw_bonus_item
  667.     update_rate
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ● 更新机率显示
  671.   #--------------------------------------------------------------------------
  672.   def update_rate
  673.     rate = @target.preview_chance(money, bonus_rate).to_i
  674.     color = [disabled_color, power_down_color, crisis_color, power_up_color,
  675.       power_up_color, normal_color][(rate / 25 + 1).limit(0, 5)]
  676.     change_color(color)
  677.     text = rate < 0 ? Vocab.forge_no_rate : rate.to_s + "%"
  678.     x = text_size(Vocab.forge_text_rate).width + 8
  679.     contents.redraw_text(x, line_height(4 + @items.size),
  680.       contents.width - x - 4, line_height, text, 2)
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ● 更新消费显示
  684.   #--------------------------------------------------------------------------
  685.   def update_cost
  686.     rate = @target.preview_chance(money, bonus_rate).to_i
  687.     if rate < 0
  688.       new_cost = @target.preview_cost(0, bonus_rate)
  689.     elsif rate < @target.success_rate
  690.       new_cost = @target.preview_cost(@target.success_rate, bonus_rate)
  691.     else
  692.       new_cost = @target.preview_cost(100, bonus_rate)
  693.     end
  694.     if @index == 0
  695.       change_value(new_cost - money)
  696.     else
  697.       price = [$data_items[@items[@index - 1]].price, 1].max
  698.       change_value(((new_cost - money).to_f / price).ceil)
  699.     end
  700.   end
  701.   #--------------------------------------------------------------------------
  702.   # ● 获取要消费的物品
  703.   #--------------------------------------------------------------------------
  704.   def items
  705.     @bonus_item_id > 0 ? @sub_items.merge({@bonus_item_id => 1}) : @sub_items
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # ● 获取总计消费价值
  709.   #--------------------------------------------------------------------------
  710.   def money
  711.     @sub_items.inject(@gold) {|g, i| g + $data_items[i[0]].price * i[1]}
  712.   end
  713.   #--------------------------------------------------------------------------
  714.   # ● 获取奖励机率
  715.   #--------------------------------------------------------------------------
  716.   def bonus_rate
  717.     (item = $data_items[@bonus_item_id]) ? item.equip_bonus_rate : 0
  718.   end
  719. end
  720.  
  721. #==============================================================================
  722. # ■ Window_SmithEmbed
  723. #------------------------------------------------------------------------------
  724. #   铁匠铺界面,镶嵌孔的选择窗口。
  725. #==============================================================================
  726. class Window_SmithEmbed < Window_Data
  727.   #--------------------------------------------------------------------------
  728.   # ● 初始化对像
  729.   #--------------------------------------------------------------------------
  730.   def initialize
  731.     @equipment = nil
  732.     super(0, window_h << 1, SCREEN_W >> 1, window_h, nil, 4)
  733.     self.z += 3
  734.     deactivate.hide.index = -1
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # ● 设置当前镶嵌装备
  738.   #--------------------------------------------------------------------------
  739.   def show_embed(equipment)
  740.     @equipment = equipment
  741.     self.height = window_h([equipment.sockets + 3 >> 2, 4].min)
  742.     refresh
  743.     show.activate.index = 0
  744.   end
  745.   #--------------------------------------------------------------------------
  746.   # ● 生成数据
  747.   #--------------------------------------------------------------------------
  748.   def make_data
  749.     super
  750.     return unless @equipment
  751.     @data.concat(@equipment.socket_items.map {|i| $data_items[i]})
  752.     @enable_proc = Proc.new {|item| item == nil or @equipment.embed_removable}
  753.   end
  754.   #--------------------------------------------------------------------------
  755.   # ● 绘制镶嵌孔
  756.   #--------------------------------------------------------------------------
  757.   def draw_item(index)
  758.     item = @data[index]
  759.     @drawn[index] = true
  760.     enabled = (@enable_proc == nil or @enable_proc.call(item))
  761.     rect = item_rect(index).inflate(-4, 0)
  762.     # 绘制孔外廓
  763.     text_w = text_size("[").width
  764.     change_color(enabled ? normal_color : disabled_color)
  765.     rect = item_rect(index)
  766.     contents.clear_rect(rect)
  767.     draw_text(rect.x, rect.y, text_w, line_height, "[")
  768.     draw_text(rect.right - text_w, rect.y, text_w, line_height, "]")
  769.     # 如果孔内有道具,绘制道具图标
  770.     if item
  771.       draw_icon(item.icon_name, rect.x + (rect.width - ICON_WIDTH >> 1),
  772.         rect.y, true, line_height)
  773.     end
  774.   end
  775.   #--------------------------------------------------------------------------
  776.   # ● 刷新帮助文本
  777.   #--------------------------------------------------------------------------
  778.   def update_help
  779.     if self.item == nil
  780.       @help_window.set_text(Vocab.embed_empty)
  781.     else
  782.       super
  783.     end
  784.   end
  785. end
  786.  
  787. #==============================================================================
  788. # ■ Window_SmithEmbedItem
  789. #------------------------------------------------------------------------------
  790. #   铁匠铺界面,镶嵌用道具的选择窗口。
  791. #==============================================================================
  792. class Window_SmithEmbedItem < Window_Data
  793.   #--------------------------------------------------------------------------
  794.   # ● 初始化对像
  795.   #--------------------------------------------------------------------------
  796.   def initialize
  797.     super(0, window_h * 3, SCREEN_W >> 1, -window_h * 3, nil, 1)
  798.     @equipment = nil
  799.     self.z += 3
  800.     deactivate.hide.index = -1
  801.   end
  802.   #--------------------------------------------------------------------------
  803.   # ● 设置当前镶嵌装备
  804.   #--------------------------------------------------------------------------
  805.   def show_embed(equipment)
  806.     @equipment = equipment
  807.     lines_top = [@equipment.sockets + 3 >> 2, 4].min
  808.     top = window_h(lines_top) + (window_h << 1)
  809.     move(0, top, SCREEN_W >> 1, SCREEN_H - top)
  810.     self.index = -1
  811.     refresh
  812.     show
  813.   end
  814.   #--------------------------------------------------------------------------
  815.   # ● 生成数据
  816.   #--------------------------------------------------------------------------
  817.   def make_data
  818.     super
  819.     # 添加可以镶嵌的道具
  820.     @data.concat($game_party.sorted_items.select {|item| item.socketable})
  821.     # 若允许解除镶嵌则添加空白
  822.     @data.push(nil) if @equipment and @equipment.embed_removable
  823.   end
  824. end
  825.  
  826. #==============================================================================
  827. # ■ Scene_Smith
  828. #------------------------------------------------------------------------------
  829. #   处理铁匠画面的类。
  830. #==============================================================================
  831. class Scene_Smith
  832.   include Scene_Base
  833.   include SailCat::Window_Config
  834.   include SailCat::Equip_Config
  835.   #--------------------------------------------------------------------------
  836.   # ● 建立窗口
  837.   #--------------------------------------------------------------------------
  838.   def create_all_windows
  839.     # 建立帮助窗口
  840.     @help_window = Window_Help.new
  841.     # 建立命令窗口
  842.     @command_window = Window_SmithCommand.new
  843.     # 建立金钱窗口
  844.     @gold_window = Window_SmithGold.new
  845.     # 建立物品窗口
  846.     @item_window = Window_SmithItem.new
  847.     # 建立详情窗口
  848.     height_offset = @help_window.height + @command_window.height
  849.     @info_window = Window_Info.new(SCREEN_W >> 1, height_offset,
  850.       SCREEN_W >> 1, -height_offset)
  851.     # 建立插件独立窗口
  852.     @enchant_window = Window_SmithEnchant.new if $sailcat_import[:EquipEnchant]
  853.     @forge_window = Window_SmithForge.new if $sailcat_import[:EquipLevel]
  854.     if $sailcat_import[:EquipSocket]
  855.       @top_window = Window_SmithEmbed.new
  856.       @bottom_window = Window_SmithEmbedItem.new
  857.     end
  858.   end
  859.   #--------------------------------------------------------------------------
  860.   # ● 设置场景扩展方法处理 1000
  861.   #--------------------------------------------------------------------------
  862.   def post_create_1000
  863.     @help_window.moveto(0, @command_window.height)
  864.     @command_window.help_window = @help_window
  865.     @item_window.index = -1
  866.     @item_window.help_window = @help_window
  867.     @item_window.info_window = @info_window
  868.     @item_window.set_handler(:index_changed, method(:item_index_changed))
  869.     if $sailcat_import[:EquipSocket]
  870.       @top_window.help_window = @help_window
  871.       @bottom_window.help_window = @help_window
  872.     end
  873.   end
  874.   #--------------------------------------------------------------------------
  875.   # ● 设置场景扩展方法处理 9000
  876.   #--------------------------------------------------------------------------
  877.   def post_create_9000
  878.     # 窗口初始状态设置
  879.     @command_window.activate.index = 0
  880.     @item_window.deactivate
  881.   end
  882.   #--------------------------------------------------------------------------
  883.   # ● 更新
  884.   #--------------------------------------------------------------------------
  885.   def update
  886.     # 更新所有窗口
  887.     update_all_windows
  888.   end
  889.   #--------------------------------------------------------------------------
  890.   # ● 更改物品选择处理
  891.   #--------------------------------------------------------------------------
  892.   def item_index_changed
  893.     if @item_window.index == -1 or (item = @item_window.item) == nil
  894.       item_id = -1
  895.     else
  896.       case @item_window.mode
  897.       when 3
  898.         item_id = item.quality_item_id
  899.       when 4
  900.         item_id = [-1].concat(item.accept_items)
  901.       when 5
  902.         item_id = [item.socket_item, item.unsocket_item]
  903.       else
  904.         item_id = -1
  905.       end
  906.     end
  907.     @gold_window.set_item_id(item_id)
  908.   end
  909.   #--------------------------------------------------------------------------
  910.   # ● 命令窗口 B 键处理
  911.   #--------------------------------------------------------------------------
  912.   def command_window_b
  913.     # 演奏取消 SE
  914.     $game_system.se_play($data_system.cancel_se)
  915.     # 返回场景
  916.     SceneManager.return
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ● 命令窗口 C 键处理
  920.   #--------------------------------------------------------------------------
  921.   def command_window_c
  922.     # 演奏确定 SE
  923.     $game_system.se_play($data_system.decision_se)
  924.     # 切换窗口焦点
  925.     @command_window.deactivate
  926.     # 根据所选功能刷新物品窗口
  927.     case @command_window.command_text
  928.     when Vocab.repair
  929.       @item_window.set_mode(1)
  930.     when Vocab.enchant
  931.       @item_window.set_mode(2)
  932.     when Vocab.refine
  933.       @item_window.set_mode(3)
  934.     when Vocab.forge
  935.       @item_window.set_mode(4)
  936.     when Vocab.punch
  937.       @item_window.set_mode(5)
  938.     when Vocab.embed
  939.       @item_window.set_mode(6)
  940.     when Vocab.reroll
  941.       @item_window.set_mode(7)
  942.     when Vocab.destroy
  943.       @item_window.set_mode(8)
  944.     end
  945.     @item_window.activate.index = 0
  946.   end
  947.   #--------------------------------------------------------------------------
  948.   # ● 物品窗口 B 键处理
  949.   #--------------------------------------------------------------------------
  950.   def item_window_b
  951.     # 演奏取消 SE
  952.     $game_system.se_play($data_system.cancel_se)
  953.     # 切换窗口焦点
  954.     @item_window.deactivate.index = -1
  955.     @command_window.activate
  956.     @item_window.set_mode(0)
  957.   end
  958.   #--------------------------------------------------------------------------
  959.   # ● 物品窗口 C 键处理
  960.   #--------------------------------------------------------------------------
  961.   def item_window_c
  962.     # 选中物品无效的情况下
  963.     unless @item_window.item
  964.       # 演奏冻结 SE
  965.       $game_system.se_play($data_system.buzzer_se)
  966.       return
  967.     end
  968.     # 执行物品操作
  969.     method("process_item_#{@item_window.mode}".to_sym).call
  970.   end
  971.   #--------------------------------------------------------------------------
  972.   # ● 物品操作取消
  973.   #--------------------------------------------------------------------------
  974.   def process_item_0
  975.     item_window_b
  976.   end
  977.   #--------------------------------------------------------------------------
  978.   # ● 物品操作修理
  979.   #--------------------------------------------------------------------------
  980.   def process_item_1
  981.     # 获得当前的待操作物品
  982.     item = @item_window.item
  983.     # 修理检定未通过的情况下
  984.     if (error = item.repair_state) > 0
  985.       # 演奏冻结 SE
  986.       $game_system.se_play($data_system.buzzer_se)
  987.       # 显示错误信息
  988.       Window_MessageBox.new(Vocab.send("repair_fail_#{error}"), Vocab.repair)
  989.     # 修理检定通过的情况下
  990.     else
  991.       # 演奏确定 SE
  992.       $game_system.se_play($data_system.decision_se)
  993.       # 询问确认的情况下,执行修理
  994.       msg = sprintf(Vocab.repair_confirm, item.info_00, item.repair_cost)
  995.       if Window_MessageBox.new(msg, Vocab.repair, MB_YN).result == DR_YES
  996.         # 演奏装备 SE
  997.         $game_system.se_play($data_system.equip_se)
  998.         # 执行修理
  999.         item.repair
  1000.         # 更新相关窗口
  1001.         @item_window.refresh
  1002.         @item_window.update_help
  1003.         @item_window.update_info
  1004.         @gold_window.refresh
  1005.         info = sprintf(Vocab.repair_info, item.durability, item.max_durability)
  1006.         Window_MessageBox.new(info, Vocab.repair)
  1007.       end
  1008.     end
  1009.   end
  1010.   #--------------------------------------------------------------------------
  1011.   # ● 物品操作附魔
  1012.   #--------------------------------------------------------------------------
  1013.   def process_item_2
  1014.     # 获得当前的待操作物品
  1015.     item = @item_window.item
  1016.     # 附魔检定未通过的情况下
  1017.     if (error = item.enchant_state) > 0
  1018.       # 演奏冻结 SE
  1019.       $game_system.se_play($data_system.buzzer_se)
  1020.       # 显示错误信息
  1021.       Window_MessageBox.new(Vocab.send("enchant_fail_#{error}"), Vocab.enchant)
  1022.     else
  1023.       # 演奏确定 SE
  1024.       $game_system.se_play($data_system.decision_se)
  1025.       # 切换到附魔词缀窗口
  1026.       @item_window.deactivate
  1027.       @enchant_window.show_enchant(item)
  1028.     end
  1029.   end
  1030.   #--------------------------------------------------------------------------
  1031.   # ● 附魔窗口 B 键处理
  1032.   #--------------------------------------------------------------------------
  1033.   def enchant_window_b
  1034.     # 演奏取消 SE
  1035.     $game_system.se_play($data_system.cancel_se)
  1036.     @enchant_window.deactivate.hide
  1037.     # 获得当前的待操作物品
  1038.     item = @item_window.item
  1039.     # 比较附魔词缀变化
  1040.     old_set = item.main_set
  1041.     new_set = @enchant_window.selected_enchants
  1042.     delete_set = old_set - new_set
  1043.     keep_set = old_set & new_set
  1044.     add_set = new_set - old_set
  1045.     # 词缀有变的情况下
  1046.     unless delete_set.empty? and add_set.empty?
  1047.       # 检查附魔消费
  1048.       cost1 = keep_set.sum {|x| $data_states[x].enchant_effects[:price]}
  1049.       cost1 *= keep_set.size
  1050.       cost2 = new_set.sum {|x| $data_states[x].enchant_effects[:price]}
  1051.       cost2 *= new_set.size
  1052.       cost = [cost2 - cost1, 0].max * item.prototype.price / 100
  1053.       # 消费不足的情况下
  1054.       if $game_party.gold < cost
  1055.         Window_MessageBox.new(Vocab.enchant_fail_4, Vocab.enchant)
  1056.       else
  1057.         # 询问确认的情况下,执行附魔
  1058.         msg = sprintf(Vocab.enchant_confirm, item.info_00, cost)
  1059.         if Window_MessageBox.new(msg, Vocab.enchant, MB_YN).result == DR_YES
  1060.           # 演奏装备 SE
  1061.           $game_system.se_play($data_system.equip_se)
  1062.           # 执行附魔
  1063.           $game_party.lose_gold(cost)
  1064.           delete_set.each {|x| item.remove_enchant(x)}
  1065.           add_set.each {|x| item.add_enchant(x)}
  1066.           # 更新相关窗口
  1067.           @item_window.refresh
  1068.           @item_window.update_info
  1069.           @gold_window.refresh
  1070.           info = sprintf(Vocab.enchant_info, delete_set.size, add_set.size)
  1071.           Window_MessageBox.new(info, Vocab.enchant)
  1072.         end
  1073.       end
  1074.     end
  1075.     # 切换到物品窗口
  1076.     @item_window.activate
  1077.   end
  1078.   #--------------------------------------------------------------------------
  1079.   # ● 附魔窗口 C 键处理
  1080.   #--------------------------------------------------------------------------
  1081.   def enchant_window_c
  1082.     case @enchant_window.enchant_state
  1083.     when -1
  1084.       # 演奏冻结 SE
  1085.       $game_system.se_play($data_system.buzzer_se)
  1086.       Window_MessageBox.new(Vocab.enchant_fail_2, Vocab.enchant)
  1087.     when 0, 1
  1088.       # 演奏确定 SE
  1089.       $game_system.se_play($data_system.decision_se)
  1090.       @enchant_window.toggle_enchant
  1091.     when 2, 3
  1092.       # 演奏冻结 SE
  1093.       $game_system.se_play($data_system.buzzer_se)
  1094.       Window_MessageBox.new(Vocab.enchant_fail_3, Vocab.enchant)
  1095.     end
  1096.   end
  1097.   #--------------------------------------------------------------------------
  1098.   # ● 物品操作锤炼
  1099.   #--------------------------------------------------------------------------
  1100.   def process_item_3
  1101.     # 获得当前的待操作物品
  1102.     item = @item_window.item
  1103.     # 锤炼检定未通过的情况下
  1104.     if (error = item.quality_state) > 0
  1105.       # 演奏冻结 SE
  1106.       $game_system.se_play($data_system.buzzer_se)
  1107.       # 显示错误信息
  1108.       Window_MessageBox.new(Vocab.send("refine_fail_#{error}"), Vocab.refine)
  1109.     else
  1110.       # 演奏确定 SE
  1111.       $game_system.se_play($data_system.decision_se)
  1112.       # 询问确认的情况下,执行锤炼
  1113.       msg = sprintf(Vocab.refine_confirm, item.info_00,
  1114.         item.quality_item_id, item.quality_item_count)
  1115.       if Window_MessageBox.new(msg, Vocab.refine, MB_YN).result == DR_YES
  1116.         # 演奏装备 SE
  1117.         $game_system.se_play($data_system.equip_se)
  1118.         # 执行锤炼
  1119.         item.quality_up
  1120.         # 更新相关窗口
  1121.         @item_window.refresh
  1122.         @item_window.update_info
  1123.         @gold_window.refresh
  1124.         text = Vocab.qualities[item.quality - 1] || Vocab.quality_ex
  1125.         if item.quality_param_rate != 0
  1126.           param = sprintf("(%+d)", item.quality_param_rate)
  1127.         else
  1128.           param = "(--)"
  1129.         end
  1130.         new_quality_text = "\\C[#{item.name_color}]#{text}\\}#{param}\\{\\C[0]"
  1131.         info = sprintf(Vocab.refine_info, new_quality_text)
  1132.         Window_MessageBox.new(info, Vocab.refine)
  1133.       end
  1134.     end
  1135.   end
  1136.   #--------------------------------------------------------------------------
  1137.   # ● 物品操作锻造
  1138.   #--------------------------------------------------------------------------
  1139.   def process_item_4
  1140.     # 获得当前的待操作物品
  1141.     item = @item_window.item
  1142.     # 锻造检定未通过的情况下
  1143.     if (error = item.level_state) > 0
  1144.       # 演奏冻结 SE
  1145.       $game_system.se_play($data_system.buzzer_se)
  1146.       # 显示错误信息
  1147.       Window_MessageBox.new(Vocab.send("forge_fail_#{error}"), Vocab.forge)
  1148.     else
  1149.       # 演奏确定 SE
  1150.       $game_system.se_play($data_system.decision_se)
  1151.       # 切换到锻造窗口
  1152.       @item_window.deactivate
  1153.       @forge_window.show_forge(item)
  1154.     end
  1155.   end
  1156.   #--------------------------------------------------------------------------
  1157.   # ● 锻造窗口 B 键处理
  1158.   #--------------------------------------------------------------------------
  1159.   def forge_window_b
  1160.     # 演奏取消 SE
  1161.     $game_system.se_play($data_system.cancel_se)
  1162.     # 切换到物品窗口
  1163.     @forge_window.deactivate.hide
  1164.     @item_window.activate
  1165.   end
  1166.   #--------------------------------------------------------------------------
  1167.   # ● 锻造窗口 C 键处理
  1168.   #--------------------------------------------------------------------------
  1169.   def forge_window_c
  1170.     # 获得当前的待操作物品
  1171.     item = @item_window.item
  1172.     case @forge_window.index
  1173.     when 0...@forge_window.item_max - 3
  1174.       # 演奏确定 SE
  1175.       $game_system.se_play($data_system.decision_se)
  1176.       @forge_window.update_cost
  1177.     when @forge_window.item_max - 3
  1178.       # 演奏确定 SE
  1179.       $game_system.se_play($data_system.decision_se)
  1180.       @forge_window.change_value(1)
  1181.     when @forge_window.item_max - 2
  1182.       # 执行升级操作
  1183.       result = item.level_up(@forge_window.gold, @forge_window.items,
  1184.         @forge_window.bonus_rate)
  1185.       # 升级成功的情况下
  1186.       if result == 0
  1187.         # 演奏装备 SE
  1188.         $game_system.se_play($data_system.equip_se)
  1189.         info = sprintf(Vocab.forge_info, item.level)
  1190.         Window_MessageBox.new(info, Vocab.forge)
  1191.       # 升级失败的情况下
  1192.       else
  1193.         # 装备等级下降的情况下
  1194.         if result == 5
  1195.           # 演奏受伤 SE
  1196.           $game_system.se_play($data_system.actor_collapse_se)
  1197.         # 无法操作的情况下
  1198.         elsif result <= 2
  1199.           # 演奏冻结 SE
  1200.           $game_system.se_play($data_system.buzzer_se)
  1201.         else
  1202.           # 演奏确定 SE
  1203.           $game_system.se_play($data_system.decision_se)
  1204.         end
  1205.         Window_MessageBox.new(Vocab.send("forge_fail_#{result}"), Vocab.forge)
  1206.       end
  1207.       # 更新相关窗口
  1208.       @item_window.refresh
  1209.       @item_window.update_info
  1210.       @gold_window.refresh
  1211.       if item.level_state == 0
  1212.         @forge_window.reset_cost
  1213.         @forge_window.refresh
  1214.       else
  1215.         # 切换到物品窗口
  1216.         @forge_window.deactivate.hide
  1217.         @item_window.activate
  1218.       end
  1219.     when @forge_window.item_max - 1
  1220.       # 演奏确定 SE
  1221.       $game_system.se_play($data_system.decision_se)
  1222.       # 切换到物品窗口
  1223.       @forge_window.deactivate.hide
  1224.       @item_window.activate
  1225.     end
  1226.   end
  1227.   #--------------------------------------------------------------------------
  1228.   # ● 物品操作打孔
  1229.   #--------------------------------------------------------------------------
  1230.   def process_item_5
  1231.     # 获得当前的待操作物品
  1232.     item = @item_window.item
  1233.     # 打孔检定未通过的情况下
  1234.     if item.max_sockets == 0
  1235.       # 演奏冻结 SE
  1236.       $game_system.se_play($data_system.buzzer_se)
  1237.       # 显示错误信息
  1238.       Window_MessageBox.new(Vocab.punch_fail_1, Vocab.punch)
  1239.     else
  1240.       # 演奏确定 SE
  1241.       $game_system.se_play($data_system.decision_se)
  1242.       # 显示打孔菜单
  1243.       commands = [Vocab.punch_open, Vocab.punch_close]
  1244.       menu = Window_ContextMenu.new(commands)
  1245.       start_index = 0
  1246.       if item.sockets == 0
  1247.         menu.disable_item(1)
  1248.       end
  1249.       if item.sockets == item.max_sockets
  1250.         menu.disable_item(0)
  1251.         start_index = 1
  1252.       end
  1253.       x = @item_window.cursor_rect.right + @item_window.x + 16
  1254.       y = @item_window.cursor_rect.y + @item_window.y + 16
  1255.       case menu.show_menu(x, y, start_index)
  1256.       when 0 # 开孔
  1257.         word = Vocab.punch_open
  1258.         material = item.socket_item
  1259.         sym = :open_socket
  1260.       when 1 # 封孔
  1261.         word = Vocab.punch_close
  1262.         material = item.unsocket_item
  1263.         sym = :close_socket
  1264.       when 2
  1265.         return
  1266.       end
  1267.       # 打孔操作
  1268.       if $game_party.item_number(material) > 0
  1269.         msg = sprintf(Vocab.punch_confirm, word, item.info_00, material)
  1270.         if Window_MessageBox.new(msg, Vocab.punch, MB_YN).result == DR_YES
  1271.           # 演奏装备 SE
  1272.           $game_system.se_play($data_system.equip_se)
  1273.           # 执行打孔
  1274.           item.send(sym)
  1275.           # 更新相关窗口
  1276.           @item_window.refresh
  1277.           @item_window.update_info
  1278.           @gold_window.refresh
  1279.           info = sprintf(Vocab.punch_info, word, item.sockets)
  1280.           Window_MessageBox.new(info, Vocab.punch)
  1281.         end
  1282.       else
  1283.         # 演奏冻结 SE
  1284.         $game_system.se_play($data_system.buzzer_se)
  1285.         # 显示错误信息
  1286.         Window_MessageBox.new(Vocab.punch_fail_2, Vocab.punch)
  1287.       end
  1288.     end
  1289.   end
  1290.   #--------------------------------------------------------------------------
  1291.   # ● 物品操作镶嵌
  1292.   #--------------------------------------------------------------------------
  1293.   def process_item_6
  1294.     # 获得当前的待操作物品
  1295.     item = @item_window.item
  1296.     # 镶嵌检定未通过的情况下
  1297.     if (error = item.embed_state) > 0
  1298.       # 演奏冻结 SE
  1299.       $game_system.se_play($data_system.buzzer_se)
  1300.       # 显示错误信息
  1301.       Window_MessageBox.new(Vocab.send("embed_fail_#{error}"), Vocab.embed)
  1302.     else
  1303.       # 演奏确定 SE
  1304.       $game_system.se_play($data_system.decision_se)
  1305.       # 切换到镶嵌窗口
  1306.       @item_window.deactivate
  1307.       @top_window.show_embed(item)
  1308.       @bottom_window.show_embed(item)
  1309.     end
  1310.   end
  1311.   #--------------------------------------------------------------------------
  1312.   # ● 镶孔窗口 B 键处理
  1313.   #--------------------------------------------------------------------------
  1314.   def top_window_b
  1315.     # 演奏取消 SE
  1316.     $game_system.se_play($data_system.cancel_se)
  1317.     # 切换到物品窗口
  1318.     @top_window.deactivate.hide
  1319.     @bottom_window.hide
  1320.     @item_window.activate
  1321.   end
  1322.   #--------------------------------------------------------------------------
  1323.   # ● 镶孔窗口 C 键处理
  1324.   #--------------------------------------------------------------------------
  1325.   def top_window_c
  1326.     # 镶嵌物不能取下的情况下
  1327.     if @top_window.item and not @item_window.item.embed_removable
  1328.       # 演奏冻结 SE
  1329.       $game_system.se_play($data_system.buzzer_se)
  1330.       Window_MessageBox.new(Vocab.embed_fail_3, Vocab.embed)
  1331.     else
  1332.       # 切换到镶嵌物窗口
  1333.       @top_window.deactivate
  1334.       @bottom_window.activate.index = 0
  1335.     end
  1336.   end
  1337.   #--------------------------------------------------------------------------
  1338.   # ● 镶嵌物窗口 B 键处理
  1339.   #--------------------------------------------------------------------------
  1340.   def bottom_window_b
  1341.     # 演奏取消 SE
  1342.     $game_system.se_play($data_system.cancel_se)
  1343.     # 切换到镶孔窗口
  1344.     @bottom_window.deactivate.index = -1
  1345.     @top_window.activate
  1346.   end
  1347.   #--------------------------------------------------------------------------
  1348.   # ● 镶嵌物窗口 C 键处理
  1349.   #--------------------------------------------------------------------------
  1350.   def bottom_window_c
  1351.     # 取得选中的镶嵌物
  1352.     item = @bottom_window.item
  1353.     # 演奏装备 SE
  1354.     $game_system.se_play($data_system.equip_se)
  1355.     # 执行镶嵌
  1356.     @item_window.item.socket(@top_window.index, item ? item.id : 0)
  1357.     # 刷新相关窗口
  1358.     @item_window.refresh
  1359.     @item_window.update_info
  1360.     @top_window.refresh
  1361.     @bottom_window.refresh
  1362.     # 切换到镶孔窗口
  1363.     @bottom_window.deactivate.index = -1
  1364.     @top_window.activate
  1365.   end
  1366.   #--------------------------------------------------------------------------
  1367.   # ● 物品操作幻化
  1368.   #--------------------------------------------------------------------------
  1369.   def process_item_7
  1370.     # 获得当前的待操作物品
  1371.     item = @item_window.item
  1372.     sym = $sailcat_import[:EquipDurability] ? :sailcat_equipdu_price : :price
  1373.     price = item.send(sym)
  1374.     # 幻化检定未通过的情况下
  1375.     if not item.random_enabled?(:ALL)
  1376.       # 演奏冻结 SE
  1377.       $game_system.se_play($data_system.buzzer_se)
  1378.       # 显示错误信息
  1379.       Window_MessageBox.new(Vocab.reroll_fail_1, Vocab.reroll)
  1380.     # 幻化最低消费不足的情况下
  1381.     elsif $game_party.gold < price.factor(REROLL_COST_RATIO.min)
  1382.       # 演奏冻结 SE
  1383.       $game_system.se_play($data_system.buzzer_se)
  1384.       # 显示错误信息
  1385.       Window_MessageBox.new(Vocab.reroll_fail_2, Vocab.reroll)
  1386.     # 幻化检定通过的情况下
  1387.     else
  1388.       # 演奏确定 SE
  1389.       $game_system.se_play($data_system.decision_se)
  1390.       # 显示幻化菜单
  1391.       commands = [1, 2, 3].map {|n|
  1392.         Vocab.send("reroll_grade_#{n}") + Vocab.nbsp + Vocab.reroll}
  1393.       menu = Window_ContextMenu.new(commands)
  1394.       start_index = 0
  1395.       3.times do |x|
  1396.         if $game_party.gold < price.factor(REROLL_COST_RATIO[x])
  1397.           menu.disable_item(x)
  1398.         end
  1399.       end
  1400.       x = @item_window.cursor_rect.right + @item_window.x + 16
  1401.       y = @item_window.cursor_rect.y + @item_window.y + 16
  1402.       result = menu.show_menu(x, y, start_index)
  1403.       # 菜单被取消的情况下,返回
  1404.       return if result == 3
  1405.       cost = price.factor(REROLL_COST_RATIO[result])
  1406.       ranges = []
  1407.       # 低级或高级需限定幻化范围
  1408.       if result != 1
  1409.         if item.random_enabled?(:QUALITY)
  1410.           min = result == 0 ? item.min_quality : item.quality
  1411.           max = result == 0 ? item.quality : item.max_quality
  1412.           ranges.push(min..max)
  1413.         end
  1414.         if item.random_enabled?(:ENCHANT)
  1415.           min = result == 0 ? 0 : item.enchant_count
  1416.           max = result == 0 ? item.enchant_count : item.max_enchant
  1417.           ranges.push(min..max)
  1418.         end
  1419.         if item.random_enabled?(:LEVEL)
  1420.           min = result == 0 ? 0 : item.level
  1421.           max = result == 0 ? item.level : item.max_level
  1422.           ranges.push(min..max)
  1423.         end
  1424.         if item.random_enabled?(:SOCKET)
  1425.           min = result == 0 ? 1 : [item.sockets, 1].max
  1426.           max = result == 0 ? [item.sockets, 1].max : item.max_sockets
  1427.           ranges.push(min..max)
  1428.         end
  1429.       end
  1430.       # 幻化操作
  1431.       msg = sprintf(Vocab.reroll_confirm, item.info_00, cost)
  1432.       if Window_MessageBox.new(msg, Vocab.reroll, MB_YN).result == DR_YES
  1433.         # 演奏装备 SE
  1434.         $game_system.se_play($data_system.equip_se)
  1435.         # 执行幻化
  1436.         $game_party.lose_gold(cost)
  1437.         item.randomize(*ranges)
  1438.         # 更新相关窗口
  1439.         @item_window.refresh
  1440.         @item_window.update_info
  1441.         @gold_window.refresh
  1442.         info = sprintf(Vocab.reroll_info, item.info_00)
  1443.         Window_MessageBox.new(info, Vocab.reroll)
  1444.       end
  1445.     end
  1446.   end
  1447.   #--------------------------------------------------------------------------
  1448.   # ● 物品操作熔毁
  1449.   #--------------------------------------------------------------------------
  1450.   def process_item_8
  1451.     # 获得当前的待操作物品
  1452.     item = @item_window.item
  1453.     # 演奏确定 SE
  1454.     $game_system.se_play($data_system.decision_se)
  1455.     # 询问确认的情况下,执行熔毁
  1456.     gain = item.price.factor(DESTROY_GAIN_RATIO)
  1457.     msg = sprintf(Vocab.destroy_confirm, item.info_00, gain)
  1458.     if Window_MessageBox.new(msg, Vocab.destroy, MB_YN).result == DR_YES
  1459.       # 演奏销毁 SE
  1460.       $game_system.se_play($data_system.enemy_collapse_se)
  1461.       # 执行熔毁
  1462.       item.unsocket_all if $sailcat_import[:EquipSocket]
  1463.       $game_party.lose_object(item, 1)
  1464.       $game_party.gain_gold(gain)
  1465.       # 更新相关窗口
  1466.       @item_window.refresh
  1467.       @item_window.update_help
  1468.       @item_window.update_info
  1469.       @gold_window.refresh
  1470.       Window_MessageBox.new(Vocab.destroy_info, Vocab.repair)
  1471.     end
  1472.   end
  1473. end


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

点评

已解决  发表于 2020-3-23 23:13
菜得真实但还是想做游戏

Lv2.观梦者

梦石
0
星屑
423
在线时间
37 小时
注册时间
2013-7-1
帖子
27
2
 楼主| 发表于 2020-3-17 16:38:04 | 只看该作者
紧接着不知道什么时候出现的问题。。。

之前还是好的,只修改了一楼提到的那一个外挂脚本(没有发生错误)
之后再进入战斗就这样了……
百思不得其解……
之前也出现了这种情况,我把脚本备份了一下,删除了所有的外挂脚本
再逐个添回并测试游戏,最终全部添回,错误又消失了
摸不着头脑。。。
菜得真实但还是想做游戏
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
413
在线时间
214 小时
注册时间
2011-3-21
帖子
161
3
发表于 2020-3-18 12:32:46 | 只看该作者
查找$game_party.gold替换成$game_variables[4]试试?
签名是什么 好吃么
好吃
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
423
在线时间
37 小时
注册时间
2013-7-1
帖子
27
4
 楼主| 发表于 2020-3-19 12:41:22 | 只看该作者
1095884734 发表于 2020-3-18 12:32
查找$game_party.gold替换成$game_variables[4]试试?

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 18:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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