| 赞 | 3 |
| VIP | |
| 好人卡 | |
| 积分 | 4 |
| 经验 | |
| 最后登录 | 2022-2-5 |
| 在线时间 | 37 小时 |
- 梦石
- 0
- 星屑
- 423
- 在线时间
- 37 小时
- 注册时间
- 2013-7-1
- 回帖
- 16
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 774204155 于 2020-3-17 16:29 编辑
在用SailCat大神写的铁匠铺脚本,其中进行修理操作的时候[消耗金钱]
我想把它修改成[消耗4号变量]
在依赖插件《装备穿戴耐久》中做了一部分修改:
- #--------------------------------------------------------------------------
- # ● 修理状态检定
- #--------------------------------------------------------------------------
- def repair_state
- return 1 unless broken?
- return 2 unless repairable?
- return 3 unless $game_variables[4] >= repair_cost
- return 0
- end
- #--------------------------------------------------------------------------
- # ● 执行修理
- #--------------------------------------------------------------------------
- def repair
- $game_variables[4] -= repair_cost
- self.durability = [self.max_durability.factor(repair_efficiency), 1].max
- self.max_durability -= repair_wear
- # 恢复装备的自动状态
- if self.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
- $game_party.actors.each do |actor|
- actor.update_auto_state(nil, self) if actor.equipment.include?(self)
- end
- end
- end
复制代码
修理的时候应该是可以改成消耗变量了,
但是铁匠铺的界面不知道该怎么修改,贴上两个脚本的完整代码:
装备穿戴耐久
- #==============================================================================
- # ■ 装备增强-装备穿戴耐久 v1.0 by SailCat
- #------------------------------------------------------------------------------
- # 方法:本脚本插入到Main之前、并在所有依赖项之后使用
- # 依赖:
- # 1. 数据库通用备注接口插件(2.1版以上)
- # 2. 装备实体接口(1.0版以上)
- # 版本:v1.0 (Build 180217)
- # 效果:装备具有耐久度,随装备经战斗逐渐减少,不装备不会减少耐久
- # 配置:装备耐久度默认数值,修理行为,耐久减损行为,相关用语
- # 冲突:同类功能脚本
- # 说明:
- # 0. 备注均写在描述里,具体格式见依赖的通用备注接口插件相关说明
- # (当[XX集]内容只有一条时,方括号可省略)
- # (备注太长写不下时,可用超长备注法)
- # 1. 装备的初始耐久度:du=值,若不设定的话,取配置中的默认值。
- # 2. 装备的耐久分散度:dv=值,若不设定取配置值。
- # 3. 装备是否允许修理:dr+(允许)或dr-(不允许),默认允许修理。
- # 4. 装备的最大耐久和当前耐久均为可读写属性。
- # 可以用装备.max_durability和装备.durability来读写耐久属性。
- # 5. 装备的耐久度会影响其价格。
- # 6. 当装备耐久度为0时,其所有属性均无效,但仍然可以如常装备。
- # 7. 装备的耐久减损行为主要兼顾主流,过于细节和非主流的设置并未包含。
- # 8. 本脚本中,装备的耐久减损是一个固定行为,而非随机行为。
- #==============================================================================
- #==============================================================================
- # ■ SailCat's 插件公用
- #==============================================================================
- module SailCat
- $sailcat_import ||= {}
- #--------------------------------------------------------------------------
- # ● 脚本配置区
- #--------------------------------------------------------------------------
- module Equip_Config
- DURABILITY_DEFAULT = 50 # 默认耐久度
- DURABILITY_VARIANCE = 0 # 耐久度分散度
- SPAWN_MAX_DURABILITY = true # 初始满耐久(true/false/开关ID)
- REMOVE_BROKEN_AUTO = false # 是否自动解除损坏的装备
- REPAIR_EFFICIENCY = 100 # 修复效率(设为0全局禁用修理)
- REPAIR_WEAR_OUT = 0 # 修复后最大耐久的减损值
- REMAINDER_VALUE = 0 # 装备耐久用完后的残值
- REPAIR_COST_FACTOR = 70 # 修复所需金钱比率
- WEAR_FACTOR = 100 # 耐久减损的精算系数,不能为0
- WEAROUT_IN_BATTLE = false # 战斗中是否允许当场损毁
- WEAPON_WEAR_FACTORS = { # 武器不同场合下耐久的减损因子
- :attack => 25, # 执行攻击指令时
- :guard => 0, # 执行防御指令时
- :skill_physical => 75, # 执行物理特技时
- :skill_magical => 25, # 执行魔法特技时
- :striking => 25, # 击中目标时
- :missing => 5, # 打空时
- :skill_hit => 25, # 特技击中时
- :skill_miss => 5, # 特技打空时
- :critical => 100, # 造成会心一击时
- :turn => 1, # 每回合后
- :combat => 5, # 每场战斗后
- }
- ARMOR_WEAR_FACTORS = { # 防具不同场合下耐久的减损因子
- # 以下每组4个值分别对应盾、头部、身体、饰品
- # 如果扩展了栏位,可以增加此处的值;若不增加,扩展栏位全视为饰品
- :attack => [0, 0, 0, 0], # 执行攻击指令时
- :guard => [100, 0, 0, 0], # 执行防御指令时
- :skill_physical => [0, 0, 0, 0], # 执行物理特技时
- :skill_magical => [0, 0, 0, 0], # 执行魔法特技时
- :struck => [25, 25, 50, 25], # 被击中时
- :evaded => [100, 0, 0, 0], # 被回避时
- :critical_struck => [0, 50, 100, 50], # 被会心一击时
- :turn => [1, 1, 1, 1], # 每回合后
- :combat => [5, 5, 5, 5], # 每场战斗后
- }
- VOCAB_DURABILITY = "耐久度" # 耐久度 用语
- VOCAB_DURABILITY_A = "[%s/%d]" # 耐久度 用语 简写
- VOCAB_BROKEN = "损坏的" # 损坏的 用语
- VOCAB_SCRAPPED = "损毁的" # 损毁的 用语
- VOCAB_INDESTRUCTIBLE = "不可磨损" # 不可磨损 用语
- VOCAB_UNREPAIRABLE = "不可修复" # 不可修复 用语
- end
- #--------------------------------------------------------------------------
- # ● 植入与依赖检查
- #--------------------------------------------------------------------------
- dependency = []
- unless $sailcat_import[:DataNoteCore].to_f >= 2.1
- dependency.push "[DataNoteCore] 通用数据库备注接口(v2.1以上版本)"
- end
- unless $sailcat_import[:EquipInstantiate].to_f >= 1.0
- dependency.push "[EquipInstantiate] 装备实体接口(v1.0以上版本)"
- end
- raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
- $sailcat_import[:EquipDurability] = 1.0
- end
- module RPG
- #============================================================================
- # ■ EquipDurability
- #----------------------------------------------------------------------------
- # 备注定义通用模块。
- #============================================================================
- module EquipDurability
- include SailCat::Equip_Config
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def init_durability; _du(DURABILITY_DEFAULT); end
- def var_durability; _dv(DURABILITY_VARIANCE); end
- def allow_repair; _dr(true); end
- def repair_efficiency;_de(REPAIR_EFFICIENCY); end
- def repair_wear; _dw(REPAIR_WEAR_OUT); end
- end
- #============================================================================
- # ■ RPG::Weapon
- #----------------------------------------------------------------------------
- # 数据库的武器类扩展。
- #============================================================================
- class Weapon
- include EquipDurability
- end
- #============================================================================
- # ■ RPG::Armor
- #----------------------------------------------------------------------------
- # 数据库的防具类扩展。
- #============================================================================
- class Armor
- include EquipDurability
- end
- end
- #==============================================================================
- # ■ EquipDurability
- #------------------------------------------------------------------------------
- # 耐久处理模块。
- #==============================================================================
- module SailCat::EquipDurability
- include SailCat::Equip_Config
- #--------------------------------------------------------------------------
- # ● 后续设置扩展方法处理 9000
- #--------------------------------------------------------------------------
- def post_setup_9000
- unless @max_durability
- @max_durability = init_durability.variance(var_durability, 100)
- @max_durability_plus = 0
- if @max_durability > 0
- if SPAWN_MAX_DURABILITY.is_a?(Numeric)
- full = $game_switches[SPAWN_MAX_DURABILITY]
- else
- full = SPAWN_MAX_DURABILITY
- end
- @durability = full ? max_durability : rand(max_durability) + 1
- @durability *= WEAR_FACTOR
- else
- @durability = 0
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 无法损毁判定
- #--------------------------------------------------------------------------
- def indestructible?
- self.max_durability == 0
- end
- #--------------------------------------------------------------------------
- # ● 获取最大耐久度
- #--------------------------------------------------------------------------
- def max_durability
- get_value(@max_durability, :durability) + @max_durability_plus
- end
- #--------------------------------------------------------------------------
- # ● 设置最大耐久度
- # value : 最大耐久度
- #--------------------------------------------------------------------------
- def max_durability=(value)
- @max_durability_plus += value - self.max_durability
- @durability = [@durability, value * WEAR_FACTOR].min
- end
- #--------------------------------------------------------------------------
- # ● 损坏的判定
- #--------------------------------------------------------------------------
- def broken?
- @durability == 0 and self.max_durability > 0
- end
- #--------------------------------------------------------------------------
- # ● 可以修理判定
- #--------------------------------------------------------------------------
- def repairable?
- max_durability > repair_wear and repair_efficiency > 0 and allow_repair
- end
- #--------------------------------------------------------------------------
- # ● 修理状态检定
- #--------------------------------------------------------------------------
- def repair_state
- return 1 unless broken?
- return 2 unless repairable?
- return 3 unless $game_variables[4] >= repair_cost
- return 0
- end
- #--------------------------------------------------------------------------
- # ● 执行修理
- #--------------------------------------------------------------------------
- def repair
- $game_variables[i] -= repair_cost
- self.durability = [self.max_durability.factor(repair_efficiency), 1].max
- self.max_durability -= repair_wear
- # 恢复装备的自动状态
- if self.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
- $game_party.actors.each do |actor|
- actor.update_auto_state(nil, self) if actor.equipment.include?(self)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取当前耐久度
- #--------------------------------------------------------------------------
- def durability
- @durability == 0 ? 0 : [@durability / WEAR_FACTOR, 1].max
- end
- #--------------------------------------------------------------------------
- # ● 设置当前耐久度
- # value : 当前耐久度
- #--------------------------------------------------------------------------
- def durability=(value)
- # 装备可用状态有变化的情况下,清除缓存
- clear_value_cache if @durability * value <= 0
- @durability = value.limit(0, self.max_durability) * WEAR_FACTOR
- end
- #--------------------------------------------------------------------------
- # ● 耐久度的消耗
- # value_lost : 磨损度
- # flag : 允许损毁标记
- #--------------------------------------------------------------------------
- def wear(value_lost, flag)
- # 防止战斗中途损坏
- min = [@durability, flag ? 0 : 1].min
- # 耐久度的精算减损
- @durability = [@durability - value_lost, min].max
- # 磨坏了的情况下,清除缓存
- clear_value_cache if broken?
- end
- #--------------------------------------------------------------------------
- # ● 获得残值
- #--------------------------------------------------------------------------
- def remain_value
- sailcat_equipdu_price.factor(REMAINDER_VALUE)
- end
- #--------------------------------------------------------------------------
- # ● 获得使用价值
- #--------------------------------------------------------------------------
- def consumable_value
- sailcat_equipdu_price.factor(100 - REMAINDER_VALUE)
- end
- #--------------------------------------------------------------------------
- # ● 获得修理费
- #--------------------------------------------------------------------------
- def repair_cost
- consumable_value.factor(REPAIR_COST_FACTOR)
- end
- #--------------------------------------------------------------------------
- # ● 前缀(第四部分)
- #--------------------------------------------------------------------------
- def prefix_part4
- broken? ? (repairable? ? Vocab.broken : Vocab.scrapped) : ""
- end
- #--------------------------------------------------------------------------
- # ● 获得耐久度字符串
- #--------------------------------------------------------------------------
- def durability_s
- if $sailcat_import[:WindowCore]
- if broken?
- color = 18
- elsif durability < max_durability >> 2
- color = 17
- elsif durability == max_durability
- color = 24
- else
- color = 0
- end
- "\\C[#{color}]#{durability}\\C[0]"
- else
- durability.to_s
- end
- end
- #--------------------------------------------------------------------------
- # ● 详情信息 耐久度
- #--------------------------------------------------------------------------
- def info_02
- return nil if indestructible?
- text_s(Vocab.durability, sprintf("%s/%d", durability_s, max_durability))
- end
- #--------------------------------------------------------------------------
- # ● 详情信息 不可磨损
- #--------------------------------------------------------------------------
- def info_97
- indestructible? && init_durability > 0 ? Vocab.indestructible : nil
- end
- #--------------------------------------------------------------------------
- # ● 详情信息 不可修复
- #--------------------------------------------------------------------------
- def info_98
- !indestructible? && !allow_repair ? Vocab.unrepairable : nil
- end
- end
- #==============================================================================
- # ■ Game_Weapon
- #==============================================================================
- class Game_Weapon
- include SailCat::EquipDurability
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equidu_price)
- alias sailcat_equipdu_price price
- end
- #--------------------------------------------------------------------------
- # ● 获得磨损值
- # symbol : 磨损场合的标识符
- #--------------------------------------------------------------------------
- def wear_value(symbol)
- WEAPON_WEAR_FACTORS[symbol] || 0
- end
- #--------------------------------------------------------------------------
- # ● 获得价格
- #--------------------------------------------------------------------------
- def price
- if init_durability > 0
- remain_value + consumable_value.factor(durability, init_durability)
- else
- sailcat_equipdu_price
- end
- end
- #--------------------------------------------------------------------------
- # ● 说明文字
- #--------------------------------------------------------------------------
- def description
- if max_durability > 0
- super + sprintf(Vocab.durability_a, durability_s, max_durability)
- else
- super
- end
- end
- #--------------------------------------------------------------------------
- # ● 名称的颜色索引
- #--------------------------------------------------------------------------
- def name_color
- broken? ? 18 : super
- end
- end
- #==============================================================================
- # ■ Game_Armor
- #==============================================================================
- class Game_Armor
- include SailCat::EquipDurability
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equidu_price)
- alias sailcat_equipdu_price price
- end
- #--------------------------------------------------------------------------
- # ● 获得磨损值
- # symbol : 磨损场合的标识符
- #--------------------------------------------------------------------------
- def wear_value(symbol)
- (set = ARMOR_WEAR_FACTORS[symbol]) ? set[kind] || set[-1] : 0
- end
- #--------------------------------------------------------------------------
- # ● 获得价格
- #--------------------------------------------------------------------------
- def price
- if init_durability > 0
- remain_value + consumable_value.factor(durability, init_durability)
- else
- sailcat_equipdu_price
- end
- end
- #--------------------------------------------------------------------------
- # ● 说明文字
- #--------------------------------------------------------------------------
- def description
- if max_durability > 0
- super + sprintf(Vocab.durability_a, durability_s, max_durability)
- else
- super
- end
- end
- #--------------------------------------------------------------------------
- # ● 名称的颜色索引
- #--------------------------------------------------------------------------
- def name_color
- broken? ? 18 : super
- end
- end
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # ● 攻击收尾扩展方法处理 4000
- #--------------------------------------------------------------------------
- def post_attack_4000(attacker)
- # 不是强制行动的情况下,执行磨损
- unless attacker.current_action.forcing
- # 攻击者是角色的情况下
- if attacker.actor?
- # 击中/打空磨损
- attacker.wear_equipment(@damage == Vocab.miss ? :missing : :striking)
- # 会心磨损
- attacker.wear_equipment(:critical) if @critical
- end
- # 被攻击者是角色的情况下
- if actor?
- # 挨打/闪避磨损
- wear_equipment(@damage == Vocab.miss ? :evaded : :struck)
- # 会心磨损
- wear_equipment(:critical_struck) if @critical
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 特技收尾扩展方法处理 4000
- #--------------------------------------------------------------------------
- def post_skill_4000(user, skill)
- # 不是强制行动的情况下,执行磨损
- unless user.current_action.forcing
- # 攻击者是角色的情况下
- if user.actor?
- # 击中/打空磨损
- user.wear_equipment(@damage == Vocab.miss ? :skill_miss : :skill_hit)
- # 会心磨损
- user.wear_equipment(:critical) if @critical
- end
- # 被攻击者是角色的情况下
- if actor?
- # 挨打/闪避磨损
- wear_equipment(@damage == Vocab.miss ? :evaded : :struck)
- # 会心磨损
- wear_equipment(:critical_struck) if @critical
- end
- end
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equidu_weapons)
- alias sailcat_equipdu_weapons weapons
- alias sailcat_equipdu_armors armors
- alias sailcat_equipdu_equipment equipment
- alias sailcat_equipdu_weapon weapon
- alias sailcat_equipdu_update_auto_state update_auto_state
- end
- #--------------------------------------------------------------------------
- # ● 全身的有效装备
- #--------------------------------------------------------------------------
- def equipment
- sailcat_equipdu_equipment.reject {|equip| equip.broken?}
- end
- #--------------------------------------------------------------------------
- # ● 装备的有效武器
- #--------------------------------------------------------------------------
- def weapons
- sailcat_equipdu_weapons.reject {|weapon| weapon.broken?}
- end
- #--------------------------------------------------------------------------
- # ● 装备的武器(RPG::Weapon)
- #--------------------------------------------------------------------------
- def weapon
- (w = sailcat_equipdu_weapon) && w.broken? ? nil : w
- end
- #--------------------------------------------------------------------------
- # ● 装备的有效防具
- #--------------------------------------------------------------------------
- def armors
- sailcat_equipdu_armors.reject {|armor| armor.broken?}
- end
- #--------------------------------------------------------------------------
- # ● 获取来自装备的数值
- #--------------------------------------------------------------------------
- def equip_param(scope, symbol, default = 0)
- scope.to_a.sum do |e|
- e.respond_to?(symbol) && !e.broken? ? e.send(symbol) : default
- end
- end
- #--------------------------------------------------------------------------
- # ● 磨损装备处理
- # symbol : 磨损场合标识符
- #--------------------------------------------------------------------------
- def wear_equipment(symbol)
- equipment.each do |e|
- next if e.indestructible? or (value = e.wear_value(symbol)) == 0
- flag = e.broken?
- e.wear(value, WEAROUT_IN_BATTLE || symbol == :combat)
- # 本次磨损损坏的情况下
- if e.broken? and not flag
- if REMOVE_BROKEN_AUTO
- equip(all_equipment.index(e), 0)
- else
- # 取消装备的自动状态效果
- if e.is_a?(Game_Armor) or $sailcat_import[:EquipStatBonus]
- sailcat_equipdu_update_auto_state(e, nil)
- end
- fix_hp
- fix_sp
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新自动状态
- # old_equip : 卸下防具/武器
- # new_equip : 装备防具/武器
- #--------------------------------------------------------------------------
- def update_auto_state(old_equip, new_equip)
- # 取消损坏的装备
- old_equip = nil if old_equip.respond_to?(:broken?) and old_equip.broken?
- new_equip = nil if new_equip.respond_to?(:broken?) and new_equip.broken?
- sailcat_equipdu_update_auto_state(old_equip, new_equip)
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipdu_make_attack_action_result)
- alias sailcat_equipdu_make_attack_action_result make_attack_action_result
- alias sailcat_equipdu_make_guard_action_result make_guard_action_result
- alias sailcat_equipdu_make_skill_action_result make_skill_action_result
- alias sailcat_equipdu_update_phase4_step6 update_phase4_step6
- alias sailcat_equipdu_battle_end battle_end
- end
- #--------------------------------------------------------------------------
- # ● 生成攻击行动结果
- #--------------------------------------------------------------------------
- def make_attack_action_result
- sailcat_equipdu_make_attack_action_result
- # 攻击者是角色的情况下,执行攻击行动磨损
- @active_battler.wear_equipment(:attack) if @active_battler.actor?
- end
- #--------------------------------------------------------------------------
- # ● 生成防御行动结果
- #--------------------------------------------------------------------------
- def make_guard_action_result
- sailcat_equipdu_make_guard_action_result
- # 防御者是角色的情况下,执行防御行动磨损
- @active_battler.wear_equipment(:guard) if @active_battler.actor?
- end
- #--------------------------------------------------------------------------
- # ● 生成特技行动结果
- #--------------------------------------------------------------------------
- def make_skill_action_result
- sailcat_equipdu_make_skill_action_result
- skill = $data_skills[@active_battler.current_action.skill_id]
- # 特技确实有效的情况下,执行特技行动磨损
- unless @phase4_step == 1 or not @active_battler.actor?
- symbol = skill.atk_f > 0 ? :skill_physical : :skill_magical
- @active_battler.wear_equipment(symbol)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (主回合步骤 6 : 刷新)
- #--------------------------------------------------------------------------
- def update_phase4_step6
- sailcat_equipdu_update_phase4_step6
- # 回合磨损
- if @active_battler and @active_battler.actor?
- @active_battler.wear_equipment(:turn)
- end
- end
- #--------------------------------------------------------------------------
- # ● 战斗结束
- #--------------------------------------------------------------------------
- def battle_end(result)
- # 战斗结束磨损
- $game_party.actors.each {|a| a.wear_equipment(:combat)}
- sailcat_equipdu_battle_end(result)
- end
- end
复制代码
铁匠铺界面:
- #==============================================================================
- # ■ 装备增强-铁匠铺界面 v1.0 by SailCat
- #------------------------------------------------------------------------------
- # 方法:本脚本插入到Main之前、并在所有依赖项之后使用
- # 依赖:
- # 1. 装备实体接口(1.0版以上)
- # 2. 消息对话框(1.0版以上)
- # 3. 上下文菜单(1.0版以上)
- # 4. 详情窗口(1.0版以上)
- # 5. 以下装备实体增强至少其一:
- # 穿戴耐久、质量分等、附魔词缀、锻造升级、镶嵌道具、随机生成
- # 版本:v1.0 (Build 180716)
- # 效果:支持装备实体化的可视化功能操作
- # 配置:界面的表现和用语设置
- # 冲突:同类功能脚本
- # 说明:
- # 1. 使用$scene = Scene_Smith.new来开启铁匠界面。
- #==============================================================================
- #==============================================================================
- # ■ SailCat's 插件公用
- #==============================================================================
- module SailCat
- $sailcat_import ||= {}
- #--------------------------------------------------------------------------
- # ● 脚本配置区
- #--------------------------------------------------------------------------
- module Equip_Config
- GOLD_WINDOW_DELAY = 60 # 金钱窗口的切换延迟
- GOLD_WINDOW_FADE = 10 # 金钱窗口的淡入速度
- REROLL_COST_RATIO = [0, 33, 300] # 幻化消费比例(低/中/高级)
- DESTROY_GAIN_RATIO = 33 # 熔毁回收比例
- VOCAB_REPAIR = "修理" # 修理 用语
- VOCAB_ENCHANT = "附魔" # 附魔 用语
- VOCAB_REFINE = "锤炼" # 锤炼 用语
- VOCAB_FORGE = "锻造" # 锻造 用语
- VOCAB_PUNCH = "打孔" # 打孔 用语
- VOCAB_EMBED = "镶嵌" # 镶嵌 用语
- VOCAB_REROLL = "幻化" # 幻化 用语
- VOCAB_DESTROY = "熔毁" # 熔毁 用语
- HELP_REPAIR = "修理损坏的装备。" # 修理 帮助文字
- HELP_ENCHANT = "为装备加持魔法。" # 附魔 帮助文字
- HELP_REFINE = "锤炼装备提升质量。"# 锤炼 帮助文字
- HELP_FORGE = "锻造装备提高等级。"# 锻造 帮助文字
- HELP_PUNCH = "在装备上开镶孔。" # 打孔 帮助文字
- HELP_EMBED = "在镶孔中镶嵌道具。"# 镶嵌 帮助文字
- HELP_REROLL = "将装备随机幻化。" # 幻化 帮助文字
- HELP_DESTROY = "熔毁装备回收金钱。"# 熔毁 帮助文字
- # 修理部分的提示用语
- VOCAB_REPAIR_FAIL_1 = "装备状态良好。"
- VOCAB_REPAIR_FAIL_2 = "无法修理。"
- VOCAB_REPAIR_FAIL_3 = "所需零件不足。"
- VOCAB_REPAIR_CONFIRM = "修理装备:%s\n需要零件:%d\\C[16]\枚\n要修理吗?"
- VOCAB_REPAIR_INFO = "修理完成。\n现耐久度为:%d/%d。"
- # 附魔部分的提示用语
- VOCAB_ENCHANT_FAIL_1 = "无法附魔这个装备。"
- VOCAB_ENCHANT_FAIL_2 = "附魔词缀数已达上限。"
- VOCAB_ENCHANT_FAIL_3 = "该词缀已被锁定。"
- VOCAB_ENCHANT_FAIL_4 = "附魔费用不足。"
- VOCAB_ENCHANT_CONFIRM = "附魔装备:%s\n附魔费用:%d\\C[16]\\$\n要附魔吗?"
- VOCAB_ENCHANT_INFO = "附魔完成。\n删除词缀%d个,新增词缀%d个。"
- # 锤炼部分的提示用语
- VOCAB_REFINE_FAIL_1 = "装备质量已达极致。"
- VOCAB_REFINE_FAIL_2 = "技术所限,无法进一步锤炼。"
- VOCAB_REFINE_FAIL_3 = "锤炼材料不足。"
- VOCAB_REFINE_CONFIRM = "锤炼装备:%s\n所用材料:\\D[I%d] × %d\n继续吗?"
- VOCAB_REFINE_INFO = "锤炼完成。\n现质量为:%s。"
- # 锻造部分的提示用语
- VOCAB_FORGE_FAIL_1 = "装备等级已达上限。"
- VOCAB_FORGE_FAIL_2 = "消费过低,无法锻造。"
- VOCAB_FORGE_FAIL_3 = "锻造失败。\n返还了消费的一半。"
- VOCAB_FORGE_FAIL_4 = "锻造失败。\n装备等级没有变化。"
- VOCAB_FORGE_FAIL_5 = "锻造失败。\n装备的等级下降了。"
- VOCAB_FORGE_INFO = "锻造成功。\n现等级为:%+d。"
- VOCAB_FORGE_TEXT_GOLD = "消费%s"
- VOCAB_FORGE_TEXT_ITEM = "消费道具"
- VOCAB_FORGE_TEXT_BONUS= "额外道具"
- VOCAB_FORGE_TEXT_RATE = "锻造成功率"
- VOCAB_FORGE_NO_BONUS = "(不使用额外道具)"
- VOCAB_FORGE_NO_RATE = "无法锻造"
- # 打孔部分的提示用语
- VOCAB_PUNCH_FAIL_1 = "装备无法打孔。"
- VOCAB_PUNCH_FAIL_2 = "打孔材料不足。"
- VOCAB_PUNCH_OPEN = "开启镶孔"
- VOCAB_PUNCH_CLOSE = "封闭镶孔"
- VOCAB_PUNCH_CONFIRM = "%s:%s\n所用材料:\\D[I%d] × 1\n继续吗?"
- VOCAB_PUNCH_INFO = "%s成功。\n现镶孔数为:%d个。"
- # 镶嵌部分的提示用语
- VOCAB_EMBED_FAIL_1 = "装备没有镶孔。"
- VOCAB_EMBED_FAIL_2 = "装备镶嵌已满。"
- VOCAB_EMBED_FAIL_3 = "这个装备不允许拆解镶嵌物。"
- VOCAB_EMBED_EMPTY = "这个镶嵌孔是空的。"
- # 幻化部分的提示用语
- VOCAB_REROLL_FAIL_1 = "无法幻化这个装备。"
- VOCAB_REROLL_FAIL_2 = "幻化消费不足。"
- VOCAB_REROLL_GRADE_1 = "基础"
- VOCAB_REROLL_GRADE_2 = "普通"
- VOCAB_REROLL_GRADE_3 = "专家"
- VOCAB_REROLL_CONFIRM = "幻化装备:%s\n幻化费用:%d\\C[16]\\$\n" +
- "\\C[18]\\*警告\\*\\C[0]:装备将丢失原先所有属性!\n继续吗?"
- VOCAB_REROLL_INFO = "幻化成功。\n新装备为:%s"
- # 熔毁部分的提示用语
- VOCAB_DESTROY_CONFIRM = "熔毁装备:%s\n回收金钱:%d\\C[16]\\$\n继续吗?"
- VOCAB_DESTROY_INFO = "熔毁完成。"
- end
- #--------------------------------------------------------------------------
- # ● 植入与依赖检查
- #--------------------------------------------------------------------------
- dependency = []
- unless $sailcat_import[:EquipInstantiate].to_f >= 1.0
- dependency.push "[EquipInstantiate] 装备实体接口(v1.0以上版本)"
- end
- unless $sailcat_import[:WindowMessageBox].to_f >= 1.0
- dependency.push "[WindowMessageBox] 消息对话框(v1.0以上版本)"
- end
- unless $sailcat_import[:WindowContextMenu].to_f >= 1.0
- dependency.push "[WindowContextMenu] 上下文菜单(v1.0以上版本)"
- end
- unless $sailcat_import[:WindowInfo].to_f >= 1.0
- dependency.push "[WindowInfo] 详情窗口(v1.0以上版本)"
- end
- raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
- $sailcat_import[:EquipSmithery] = 1.0
- end
- #==============================================================================
- # ■ Vocab
- #------------------------------------------------------------------------------
- # 所有用语的整合模块。
- #==============================================================================
- module Vocab
- self.help_text.merge!({
- :smith_repair => HELP_REPAIR,
- :smith_enchant => HELP_ENCHANT,
- :smith_refine => HELP_REFINE,
- :smith_forge => HELP_FORGE,
- :smith_punch => HELP_PUNCH,
- :smith_embed => HELP_EMBED,
- :smith_reroll => HELP_REROLL,
- })
- end
- #==============================================================================
- # ■ Window_SmithCommand
- #------------------------------------------------------------------------------
- # 铁匠铺界面,显示铁匠指令列表的窗口。
- #==============================================================================
- class Window_SmithCommand < Window_HorzCommand
- #--------------------------------------------------------------------------
- # ● 初期化
- #--------------------------------------------------------------------------
- def initialize
- @commands = []
- @commands.push(Vocab.repair) if $sailcat_import[:EquipDurability]
- @commands.push(Vocab.enchant) if $sailcat_import[:EquipEnchant]
- @commands.push(Vocab.refine) if $sailcat_import[:EquipQuality]
- @commands.push(Vocab.forge) if $sailcat_import[:EquipLevel]
- @commands.push(Vocab.embed) if $sailcat_import[:EquipSocket]
- @commands.push(Vocab.reroll) if $sailcat_import[:EquipRandomize]
- super(SCREEN_W, @commands)
- end
- #--------------------------------------------------------------------------
- # ● 选中的命令文字
- #--------------------------------------------------------------------------
- def command_text
- @commands[@index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- case command_text
- when Vocab.repair
- @help_window.set_text(Vocab.help_text[:smith_repair])
- when Vocab.enchant
- @help_window.set_text(Vocab.help_text[:smith_enchant])
- when Vocab.refine
- @help_window.set_text(Vocab.help_text[:smith_refine])
- when Vocab.forge
- @help_window.set_text(Vocab.help_text[:smith_forge])
- when Vocab.embed
- @help_window.set_text(Vocab.help_text[:smith_embed])
- when Vocab.reroll
- @help_window.set_text(Vocab.help_text[:smith_reroll])
- end
- end
- end
- #==============================================================================
- # ■ Window_SmithItem
- #------------------------------------------------------------------------------
- # 铁匠铺界面,显示装备列表的窗口。
- #==============================================================================
- class Window_SmithItem < Window_Data
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :mode # 模式
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- @mode = 0
- super(0, window_h << 1, SCREEN_W >> 1, -window_h * 3, nil, 1)
- end
- #--------------------------------------------------------------------------
- # ● 生成数据
- #--------------------------------------------------------------------------
- def make_data
- super
- @data = $game_party.sorted_weapons + $game_party.sorted_armors
- @enable_proc = Proc.new {|item|
- case @mode
- when 0
- true
- when 1
- item.broken? and item.repairable?
- when 2
- item.prototype.available_enchants.size > 0
- when 3
- item.quality < item.max_quality
- when 4
- item.level < item.max_level
- when 5
- item.sockets > 0 and (item.embed_removable or item.empty_sockets > 0)
- end}
- end
- #--------------------------------------------------------------------------
- # ● 设置模式
- # mode : 模式
- #--------------------------------------------------------------------------
- def set_mode(mode)
- @mode = mode
- refresh
- end
- end
- #==============================================================================
- # ■ Window_SmithGold
- #------------------------------------------------------------------------------
- # 铁匠铺界面,显示金钱或所需道具的窗口。
- #==============================================================================
- class Window_SmithGold < Window_Base
- include SailCat::Equip_Config
- #--------------------------------------------------------------------------
- # ● 初始化窗口
- #--------------------------------------------------------------------------
- def initialize
- super(0, SCREEN_H - window_h, SCREEN_W >> 1, window_h)
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_ids = [-1]
- @index = 0
- @frame_count = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- self.contents_opacity = 255
- @frame_count = 0
- if @item_ids[@index] == -1
- draw_currency_value(number, Vocab.gold, 4, 0, width - 40)
- elsif @item_ids[@index] > 0
- rect = contents.rect.inflate(-4, 0)
- number_width = text_size(ITEM_MAX).width.limit(24, 66) + 16
- draw_item_name($data_items[@item_ids[@index]], 4, 0, true,
- rect.width - number_width)
- draw_text(rect.right - number_width, 0, 16, rect.height, ":", 1)
- draw_text(rect.right - number_width + 16, 0,
- number_width - 16, rect.height, number, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置要显示的道具ID
- # item_id : 道具ID
- #--------------------------------------------------------------------------
- def set_item_id(item_id)
- if @item_ids != item_id.to_a
- @item_ids = item_id.to_a
- @index = 0
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取数目
- #--------------------------------------------------------------------------
- def number
- item_id = @item_ids[@index]
- item_id == -1 ? $game_party.gold : $game_party.item_number(item_id)
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @item_ids.size > 1
- @frame_count += 1
- if @frame_count >= GOLD_WINDOW_DELAY
- self.contents_opacity -= (255.to_f / GOLD_WINDOW_FADE).ceil
- if @frame_count == GOLD_WINDOW_DELAY + GOLD_WINDOW_FADE
- @index = (@index + 1) % @item_ids.size
- refresh
- self.contents_opacity = 0
- @frame_count = -GOLD_WINDOW_FADE
- end
- elsif @frame_count < 0
- self.contents_opacity += (255.to_f / GOLD_WINDOW_FADE).ceil
- end
- end
- end
- end
- #==============================================================================
- # ■ Window_SmithEnchant
- #------------------------------------------------------------------------------
- # 铁匠铺界面,显示附魔词缀的选择窗口。
- #==============================================================================
- class Window_SmithEnchant < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化窗口
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 576, 416)
- center.hide.deactivate.z += 3
- @selected = []
- @column_max = 3
- end
- #--------------------------------------------------------------------------
- # ● 设置显示的装备
- # item : 装备
- #--------------------------------------------------------------------------
- def show_enchant(item)
- return unless item
- @data = item.prototype.available_enchants
- main_set = item.main_set
- sub_set = item.sub_set
- available_set = item.available_enchants
- @selected = @data.map {|k|
- if main_set.include?(k) or main_set.include?(-k)
- 1
- elsif sub_set.include?(k) or sub_set.include?(-k)
- 3
- elsif not available_set.include?(k)
- 2
- else
- 0
- end}
- @item_max = @data.size
- @max_sel = item.max_enchant
- refresh
- self.height = [contents.height + 32, 416].min
- center.show.activate.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- create_contents
- @item_max.times {|n| draw_state(n)}
- end
- #--------------------------------------------------------------------------
- # ● 设置选择状态
- # index : 索引
- # select : 选择状态(0-3)
- #--------------------------------------------------------------------------
- def set_select(index, select)
- @selected[index] = select
- draw_state(index)
- end
- #--------------------------------------------------------------------------
- # ● 获得词缀状态
- # index : 索引
- #--------------------------------------------------------------------------
- def enchant_state(index = @index)
- n = @selected[index]
- n == 0 ? (selected_enchants.size >= @max_sel ? -1 : 0) : n
- end
- #--------------------------------------------------------------------------
- # ● 切换所选附魔开关
- #--------------------------------------------------------------------------
- def toggle_enchant
- return unless state = $data_states[@data[@index]]
- if @selected[@index] == 0
- set_select(@index, 1)
- state.chain_enchant_set.each do |x|
- set_select(i, 3) if i = @data.index(x) and x != @data[@index]
- end
- state.reject_enchant_set.each do |x|
- set_select(i, 2) if i = @data.index(x) and x != @data[@index]
- end
- elsif @selected[@index] == 1
- set_select(@index, 0)
- state.chain_enchant_set.each do |x|
- set_select(i, 0) if i = @data.index(x) and x != @data[@index]
- end
- state.reject_enchant_set.each do |x|
- set_select(i, 0) if i = @data.index(x) and x != @data[@index]
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制词缀名
- #--------------------------------------------------------------------------
- def draw_state(index)
- contents.clear_rect(item_rect(index))
- text = $data_states[@data[index]].enchant_name
- text = "[" + text + "]" if @selected[index] & 1 == 1
- change_color(@selected[index] > 1 ? disabled_color : normal_color)
- draw_text(item_rect(index), text, 1)
- end
- #--------------------------------------------------------------------------
- # ● 获得选中的词缀集
- #--------------------------------------------------------------------------
- def selected_enchants
- (0...@item_max).map {|i| @selected[i] == 1 ? @data[i] : nil}.compact
- end
- end
- #==============================================================================
- # ■ Window_SmithForge
- #------------------------------------------------------------------------------
- # 铁匠铺界面,显示锻造消费情况的确认窗口。
- #==============================================================================
- class Window_SmithForge < Window_Base
- include Window_Handler
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :index # 光标位置
- attr_reader :item_max # 项目数
- attr_reader :gold # 变量
- #--------------------------------------------------------------------------
- # ● 初始化窗口
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, SCREEN_W >> 1, 320)
- @handler = {}
- center.hide.deactivate.z += 3
- end
- #--------------------------------------------------------------------------
- # ● 设置显示的装备
- # item : 装备
- #--------------------------------------------------------------------------
- def show_forge(item)
- # 设置锻造目标
- @target = item
- # 锻造用物品
- @items = item.accept_items
- @sub_items = {}
- # 额外物品
- @bonus_items = $game_party.sorted_items.select {|item|
- item.equip_bonus_rate != 0}.map {|item| item.id}
- @bonus_items.unshift(0)
- @item_max = @items.size + 4
- resize(SCREEN_W >> 1, window_h(@item_max + 2))
- create_contents
- reset_cost
- refresh
- center.show.activate.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 重设消费数值
- #--------------------------------------------------------------------------
- def reset_cost
- @gold = 0
- @items.each {|item_id| @sub_items[item_id] = 0}
- @bonus_item_id = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- # 清除内容
- contents.clear
- # 绘制各提示语文字
- change_color(system_color)
- w = contents.width
- h = line_height
- x = @items.size
- draw_text(0, 0, w, h, Vocab.forge, 1)
- contents.fill_rect(0, h - 1, w, 1, system_color)
- gold_text = sprintf(Vocab.forge_text_gold, Vocab.gold)
- draw_text(0, line_height(1), w, h, gold_text)
- draw_text(0, line_height(2), w, h, Vocab.forge_text_item)
- draw_text(0, line_height(3 + x), w, h, Vocab.forge_text_bonus)
- draw_text(0, line_height(4 + x), w, h, Vocab.forge_text_rate)
- # 绘制物品名称
- w = text_size(ITEM_MAX).width.limit(24, 66) + 32
- x.times do |i|
- item = $data_items[@items[i]]
- draw_item_name(item, 0, line_height(3 + i), true, contents.width - w)
- change_color(normal_color)
- draw_text(contents.width - w - 32, line_height(3 + i), 24, h, "×", 1)
- end
- # 绘制各项可调数值
- draw_gold
- x.times {|i| draw_item_number(i)}
- draw_bonus_item
- update_rate
- # 绘制确定和取消按钮
- change_color(normal_color)
- w = contents.width - CURSOR_PADDING >> 1
- draw_text(0, line_height(5 + x), w, h, Vocab.ok, 1)
- draw_text(w + CURSOR_PADDING, line_height(5 + x), w, h, Vocab.cancel, 1)
- end
- #--------------------------------------------------------------------------
- # ● 绘制变量数量
- #--------------------------------------------------------------------------
- def draw_gold
- change_color(normal_color)
- w = text_size(GOLD_MAX).width.limit(48, 100) + 4
- contents.redraw_text(contents.width - w, line_height(1),
- w - 4, line_height, @gold, 2)
- end
- #--------------------------------------------------------------------------
- # ● 绘制物品数量
- #--------------------------------------------------------------------------
- def draw_item_number(i = @index - 1)
- change_color(normal_color)
- w = text_size(ITEM_MAX).width.limit(24, 66) + 4
- contents.redraw_text(contents.width - w, line_height(3 + i),
- w - 4, line_height, @sub_items[@items[i]], 2)
- end
- #--------------------------------------------------------------------------
- # ● 绘制额外物品
- #--------------------------------------------------------------------------
- def draw_bonus_item
- x = text_size(Vocab.forge_text_bonus).width + 8
- w = contents.width - x - 4
- rect = Rect.new(x, line_height(3 + @items.size), w, line_height)
- if @bonus_item_id == 0
- change_color(disabled_color)
- contents.redraw_text(rect, Vocab.forge_no_bonus)
- else
- item = $data_items[@bonus_item_id]
- contents.clear_rect(rect)
- draw_item_name(item, rect.x, rect.y, true, rect.width)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_keypress if self.active
- end
- #--------------------------------------------------------------------------
- # ● 设置光标的位置
- # index : 新的光标位置
- #--------------------------------------------------------------------------
- def index=(index)
- @index = index
- update_cursor_rect
- end
- #--------------------------------------------------------------------------
- # ● 上键处理
- #--------------------------------------------------------------------------
- def update_up(force)
- if @index > 0 or force
- $game_system.se_play($data_system.cursor_se)
- self.index = @index > 0 ? [@index - 1, @item_max - 3].min : @item_max - 2
- end
- end
- #--------------------------------------------------------------------------
- # ● 下键处理
- #--------------------------------------------------------------------------
- def update_down(force)
- if @index > @item_max - 3 or force
- $game_system.se_play($data_system.cursor_se)
- self.index = @index > @item_max - 3 ? 0 : @index + 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 左右键、LR键处理
- #--------------------------------------------------------------------------
- def update_left(force); key_num(@index != @item_max - 2 || force, -1); end
- def update_right(force);key_num(@index != @item_max - 1 || force, +1); end
- def update_pageup; key_num(@index != @item_max - 2, -10); end
- def update_pagedown; key_num(@index != @item_max - 1, +10); end
- #--------------------------------------------------------------------------
- # ● 按键变化数值处理
- # condition : 变化条件
- # delta_value : 变化量
- #--------------------------------------------------------------------------
- def key_num(condition, delta_value)
- if condition
- # 演奏光标 SE
- $game_system.se_play($data_system.cursor_se)
- change_value(delta_value * 100 ** Input.modifier)
- end
- end
- #--------------------------------------------------------------------------
- # ● 增减数量值
- # delta : 变化量
- #--------------------------------------------------------------------------
- def change_value(delta)
- case @index
- when 0
- set_gold(@gold + delta)
- when 1..@items.size
- item_id = @items[@index - 1]
- set_item(item_id, @sub_items[item_id] + delta)
- when @item_max - 3
- set_bonus(delta <=> 0)
- else
- self.index = (@item_max << 1) - @index - 3
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标有效判定
- #--------------------------------------------------------------------------
- def cursor_respond?
- true
- end
- #--------------------------------------------------------------------------
- # ● 更新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- cw = contents.width
- case @index
- when 0
- w = text_size(GOLD_MAX).width.limit(48, 100) + 8
- x, y = cw - w, 1
- when 1..@items.size
- w = text_size(ITEM_MAX).width.limit(24, 66) + 8
- x, y = cw - w, 2
- when @item_max - 3
- w = cw - text_size(Vocab.forge_text_bonus).width - 4
- x, y = cw - w, 2
- when @item_max - 2
- w = cw - CURSOR_PADDING >> 1
- x, y = 0, 3
- when @item_max - 1
- w = cw - CURSOR_PADDING >> 1
- x, y = cw - w, 2
- end
- self.cursor_rect = Rect.new(x, line_height(@index + y), w, line_height)
- end
- #--------------------------------------------------------------------------
- # ● 设置金钱数量
- # gold : 金钱数量
- #--------------------------------------------------------------------------
- def set_gold(gold)
- @gold = gold.limit(0, $game_party.gold)
- draw_gold
- update_rate
- end
- #--------------------------------------------------------------------------
- # ● 设置物品数量
- # id : 物品 ID
- # number : 物品数量
- #--------------------------------------------------------------------------
- def set_item(id, number)
- @sub_items[id] = number.limit(0, $game_party.item_number(id))
- draw_item_number
- update_rate
- end
- #--------------------------------------------------------------------------
- # ● 设置奖励物品
- # delta : 增减方向
- #--------------------------------------------------------------------------
- def set_bonus(delta)
- bonus_index = @bonus_items.index(@bonus_item_id)
- @bonus_item_id = @bonus_items[(bonus_index + delta) % @bonus_items.size]
- draw_bonus_item
- update_rate
- end
- #--------------------------------------------------------------------------
- # ● 更新机率显示
- #--------------------------------------------------------------------------
- def update_rate
- rate = @target.preview_chance(money, bonus_rate).to_i
- color = [disabled_color, power_down_color, crisis_color, power_up_color,
- power_up_color, normal_color][(rate / 25 + 1).limit(0, 5)]
- change_color(color)
- text = rate < 0 ? Vocab.forge_no_rate : rate.to_s + "%"
- x = text_size(Vocab.forge_text_rate).width + 8
- contents.redraw_text(x, line_height(4 + @items.size),
- contents.width - x - 4, line_height, text, 2)
- end
- #--------------------------------------------------------------------------
- # ● 更新消费显示
- #--------------------------------------------------------------------------
- def update_cost
- rate = @target.preview_chance(money, bonus_rate).to_i
- if rate < 0
- new_cost = @target.preview_cost(0, bonus_rate)
- elsif rate < @target.success_rate
- new_cost = @target.preview_cost(@target.success_rate, bonus_rate)
- else
- new_cost = @target.preview_cost(100, bonus_rate)
- end
- if @index == 0
- change_value(new_cost - money)
- else
- price = [$data_items[@items[@index - 1]].price, 1].max
- change_value(((new_cost - money).to_f / price).ceil)
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取要消费的物品
- #--------------------------------------------------------------------------
- def items
- @bonus_item_id > 0 ? @sub_items.merge({@bonus_item_id => 1}) : @sub_items
- end
- #--------------------------------------------------------------------------
- # ● 获取总计消费价值
- #--------------------------------------------------------------------------
- def money
- @sub_items.inject(@gold) {|g, i| g + $data_items[i[0]].price * i[1]}
- end
- #--------------------------------------------------------------------------
- # ● 获取奖励机率
- #--------------------------------------------------------------------------
- def bonus_rate
- (item = $data_items[@bonus_item_id]) ? item.equip_bonus_rate : 0
- end
- end
- #==============================================================================
- # ■ Window_SmithEmbed
- #------------------------------------------------------------------------------
- # 铁匠铺界面,镶嵌孔的选择窗口。
- #==============================================================================
- class Window_SmithEmbed < Window_Data
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- @equipment = nil
- super(0, window_h << 1, SCREEN_W >> 1, window_h, nil, 4)
- self.z += 3
- deactivate.hide.index = -1
- end
- #--------------------------------------------------------------------------
- # ● 设置当前镶嵌装备
- #--------------------------------------------------------------------------
- def show_embed(equipment)
- @equipment = equipment
- self.height = window_h([equipment.sockets + 3 >> 2, 4].min)
- refresh
- show.activate.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 生成数据
- #--------------------------------------------------------------------------
- def make_data
- super
- return unless @equipment
- @data.concat(@equipment.socket_items.map {|i| $data_items[i]})
- @enable_proc = Proc.new {|item| item == nil or @equipment.embed_removable}
- end
- #--------------------------------------------------------------------------
- # ● 绘制镶嵌孔
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- @drawn[index] = true
- enabled = (@enable_proc == nil or @enable_proc.call(item))
- rect = item_rect(index).inflate(-4, 0)
- # 绘制孔外廓
- text_w = text_size("[").width
- change_color(enabled ? normal_color : disabled_color)
- rect = item_rect(index)
- contents.clear_rect(rect)
- draw_text(rect.x, rect.y, text_w, line_height, "[")
- draw_text(rect.right - text_w, rect.y, text_w, line_height, "]")
- # 如果孔内有道具,绘制道具图标
- if item
- draw_icon(item.icon_name, rect.x + (rect.width - ICON_WIDTH >> 1),
- rect.y, true, line_height)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- if self.item == nil
- @help_window.set_text(Vocab.embed_empty)
- else
- super
- end
- end
- end
- #==============================================================================
- # ■ Window_SmithEmbedItem
- #------------------------------------------------------------------------------
- # 铁匠铺界面,镶嵌用道具的选择窗口。
- #==============================================================================
- class Window_SmithEmbedItem < Window_Data
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, window_h * 3, SCREEN_W >> 1, -window_h * 3, nil, 1)
- @equipment = nil
- self.z += 3
- deactivate.hide.index = -1
- end
- #--------------------------------------------------------------------------
- # ● 设置当前镶嵌装备
- #--------------------------------------------------------------------------
- def show_embed(equipment)
- @equipment = equipment
- lines_top = [@equipment.sockets + 3 >> 2, 4].min
- top = window_h(lines_top) + (window_h << 1)
- move(0, top, SCREEN_W >> 1, SCREEN_H - top)
- self.index = -1
- refresh
- show
- end
- #--------------------------------------------------------------------------
- # ● 生成数据
- #--------------------------------------------------------------------------
- def make_data
- super
- # 添加可以镶嵌的道具
- @data.concat($game_party.sorted_items.select {|item| item.socketable})
- # 若允许解除镶嵌则添加空白
- @data.push(nil) if @equipment and @equipment.embed_removable
- end
- end
- #==============================================================================
- # ■ Scene_Smith
- #------------------------------------------------------------------------------
- # 处理铁匠画面的类。
- #==============================================================================
- class Scene_Smith
- include Scene_Base
- include SailCat::Window_Config
- include SailCat::Equip_Config
- #--------------------------------------------------------------------------
- # ● 建立窗口
- #--------------------------------------------------------------------------
- def create_all_windows
- # 建立帮助窗口
- @help_window = Window_Help.new
- # 建立命令窗口
- @command_window = Window_SmithCommand.new
- # 建立金钱窗口
- @gold_window = Window_SmithGold.new
- # 建立物品窗口
- @item_window = Window_SmithItem.new
- # 建立详情窗口
- height_offset = @help_window.height + @command_window.height
- @info_window = Window_Info.new(SCREEN_W >> 1, height_offset,
- SCREEN_W >> 1, -height_offset)
- # 建立插件独立窗口
- @enchant_window = Window_SmithEnchant.new if $sailcat_import[:EquipEnchant]
- @forge_window = Window_SmithForge.new if $sailcat_import[:EquipLevel]
- if $sailcat_import[:EquipSocket]
- @top_window = Window_SmithEmbed.new
- @bottom_window = Window_SmithEmbedItem.new
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置场景扩展方法处理 1000
- #--------------------------------------------------------------------------
- def post_create_1000
- @help_window.moveto(0, @command_window.height)
- @command_window.help_window = @help_window
- @item_window.index = -1
- @item_window.help_window = @help_window
- @item_window.info_window = @info_window
- @item_window.set_handler(:index_changed, method(:item_index_changed))
- if $sailcat_import[:EquipSocket]
- @top_window.help_window = @help_window
- @bottom_window.help_window = @help_window
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置场景扩展方法处理 9000
- #--------------------------------------------------------------------------
- def post_create_9000
- # 窗口初始状态设置
- @command_window.activate.index = 0
- @item_window.deactivate
- end
- #--------------------------------------------------------------------------
- # ● 更新
- #--------------------------------------------------------------------------
- def update
- # 更新所有窗口
- update_all_windows
- end
- #--------------------------------------------------------------------------
- # ● 更改物品选择处理
- #--------------------------------------------------------------------------
- def item_index_changed
- if @item_window.index == -1 or (item = @item_window.item) == nil
- item_id = -1
- else
- case @item_window.mode
- when 3
- item_id = item.quality_item_id
- when 4
- item_id = [-1].concat(item.accept_items)
- when 5
- item_id = [item.socket_item, item.unsocket_item]
- else
- item_id = -1
- end
- end
- @gold_window.set_item_id(item_id)
- end
- #--------------------------------------------------------------------------
- # ● 命令窗口 B 键处理
- #--------------------------------------------------------------------------
- def command_window_b
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 返回场景
- SceneManager.return
- end
- #--------------------------------------------------------------------------
- # ● 命令窗口 C 键处理
- #--------------------------------------------------------------------------
- def command_window_c
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换窗口焦点
- @command_window.deactivate
- # 根据所选功能刷新物品窗口
- case @command_window.command_text
- when Vocab.repair
- @item_window.set_mode(1)
- when Vocab.enchant
- @item_window.set_mode(2)
- when Vocab.refine
- @item_window.set_mode(3)
- when Vocab.forge
- @item_window.set_mode(4)
- when Vocab.punch
- @item_window.set_mode(5)
- when Vocab.embed
- @item_window.set_mode(6)
- when Vocab.reroll
- @item_window.set_mode(7)
- when Vocab.destroy
- @item_window.set_mode(8)
- end
- @item_window.activate.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 物品窗口 B 键处理
- #--------------------------------------------------------------------------
- def item_window_b
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换窗口焦点
- @item_window.deactivate.index = -1
- @command_window.activate
- @item_window.set_mode(0)
- end
- #--------------------------------------------------------------------------
- # ● 物品窗口 C 键处理
- #--------------------------------------------------------------------------
- def item_window_c
- # 选中物品无效的情况下
- unless @item_window.item
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 执行物品操作
- method("process_item_#{@item_window.mode}".to_sym).call
- end
- #--------------------------------------------------------------------------
- # ● 物品操作取消
- #--------------------------------------------------------------------------
- def process_item_0
- item_window_b
- end
- #--------------------------------------------------------------------------
- # ● 物品操作修理
- #--------------------------------------------------------------------------
- def process_item_1
- # 获得当前的待操作物品
- item = @item_window.item
- # 修理检定未通过的情况下
- if (error = item.repair_state) > 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.send("repair_fail_#{error}"), Vocab.repair)
- # 修理检定通过的情况下
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 询问确认的情况下,执行修理
- msg = sprintf(Vocab.repair_confirm, item.info_00, item.repair_cost)
- if Window_MessageBox.new(msg, Vocab.repair, MB_YN).result == DR_YES
- # 演奏装备 SE
- $game_system.se_play($data_system.equip_se)
- # 执行修理
- item.repair
- # 更新相关窗口
- @item_window.refresh
- @item_window.update_help
- @item_window.update_info
- @gold_window.refresh
- info = sprintf(Vocab.repair_info, item.durability, item.max_durability)
- Window_MessageBox.new(info, Vocab.repair)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品操作附魔
- #--------------------------------------------------------------------------
- def process_item_2
- # 获得当前的待操作物品
- item = @item_window.item
- # 附魔检定未通过的情况下
- if (error = item.enchant_state) > 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.send("enchant_fail_#{error}"), Vocab.enchant)
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到附魔词缀窗口
- @item_window.deactivate
- @enchant_window.show_enchant(item)
- end
- end
- #--------------------------------------------------------------------------
- # ● 附魔窗口 B 键处理
- #--------------------------------------------------------------------------
- def enchant_window_b
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- @enchant_window.deactivate.hide
- # 获得当前的待操作物品
- item = @item_window.item
- # 比较附魔词缀变化
- old_set = item.main_set
- new_set = @enchant_window.selected_enchants
- delete_set = old_set - new_set
- keep_set = old_set & new_set
- add_set = new_set - old_set
- # 词缀有变的情况下
- unless delete_set.empty? and add_set.empty?
- # 检查附魔消费
- cost1 = keep_set.sum {|x| $data_states[x].enchant_effects[:price]}
- cost1 *= keep_set.size
- cost2 = new_set.sum {|x| $data_states[x].enchant_effects[:price]}
- cost2 *= new_set.size
- cost = [cost2 - cost1, 0].max * item.prototype.price / 100
- # 消费不足的情况下
- if $game_party.gold < cost
- Window_MessageBox.new(Vocab.enchant_fail_4, Vocab.enchant)
- else
- # 询问确认的情况下,执行附魔
- msg = sprintf(Vocab.enchant_confirm, item.info_00, cost)
- if Window_MessageBox.new(msg, Vocab.enchant, MB_YN).result == DR_YES
- # 演奏装备 SE
- $game_system.se_play($data_system.equip_se)
- # 执行附魔
- $game_party.lose_gold(cost)
- delete_set.each {|x| item.remove_enchant(x)}
- add_set.each {|x| item.add_enchant(x)}
- # 更新相关窗口
- @item_window.refresh
- @item_window.update_info
- @gold_window.refresh
- info = sprintf(Vocab.enchant_info, delete_set.size, add_set.size)
- Window_MessageBox.new(info, Vocab.enchant)
- end
- end
- end
- # 切换到物品窗口
- @item_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 附魔窗口 C 键处理
- #--------------------------------------------------------------------------
- def enchant_window_c
- case @enchant_window.enchant_state
- when -1
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- Window_MessageBox.new(Vocab.enchant_fail_2, Vocab.enchant)
- when 0, 1
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- @enchant_window.toggle_enchant
- when 2, 3
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- Window_MessageBox.new(Vocab.enchant_fail_3, Vocab.enchant)
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品操作锤炼
- #--------------------------------------------------------------------------
- def process_item_3
- # 获得当前的待操作物品
- item = @item_window.item
- # 锤炼检定未通过的情况下
- if (error = item.quality_state) > 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.send("refine_fail_#{error}"), Vocab.refine)
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 询问确认的情况下,执行锤炼
- msg = sprintf(Vocab.refine_confirm, item.info_00,
- item.quality_item_id, item.quality_item_count)
- if Window_MessageBox.new(msg, Vocab.refine, MB_YN).result == DR_YES
- # 演奏装备 SE
- $game_system.se_play($data_system.equip_se)
- # 执行锤炼
- item.quality_up
- # 更新相关窗口
- @item_window.refresh
- @item_window.update_info
- @gold_window.refresh
- text = Vocab.qualities[item.quality - 1] || Vocab.quality_ex
- if item.quality_param_rate != 0
- param = sprintf("(%+d)", item.quality_param_rate)
- else
- param = "(--)"
- end
- new_quality_text = "\\C[#{item.name_color}]#{text}\\}#{param}\\{\\C[0]"
- info = sprintf(Vocab.refine_info, new_quality_text)
- Window_MessageBox.new(info, Vocab.refine)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品操作锻造
- #--------------------------------------------------------------------------
- def process_item_4
- # 获得当前的待操作物品
- item = @item_window.item
- # 锻造检定未通过的情况下
- if (error = item.level_state) > 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.send("forge_fail_#{error}"), Vocab.forge)
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到锻造窗口
- @item_window.deactivate
- @forge_window.show_forge(item)
- end
- end
- #--------------------------------------------------------------------------
- # ● 锻造窗口 B 键处理
- #--------------------------------------------------------------------------
- def forge_window_b
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到物品窗口
- @forge_window.deactivate.hide
- @item_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 锻造窗口 C 键处理
- #--------------------------------------------------------------------------
- def forge_window_c
- # 获得当前的待操作物品
- item = @item_window.item
- case @forge_window.index
- when 0...@forge_window.item_max - 3
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- @forge_window.update_cost
- when @forge_window.item_max - 3
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- @forge_window.change_value(1)
- when @forge_window.item_max - 2
- # 执行升级操作
- result = item.level_up(@forge_window.gold, @forge_window.items,
- @forge_window.bonus_rate)
- # 升级成功的情况下
- if result == 0
- # 演奏装备 SE
- $game_system.se_play($data_system.equip_se)
- info = sprintf(Vocab.forge_info, item.level)
- Window_MessageBox.new(info, Vocab.forge)
- # 升级失败的情况下
- else
- # 装备等级下降的情况下
- if result == 5
- # 演奏受伤 SE
- $game_system.se_play($data_system.actor_collapse_se)
- # 无法操作的情况下
- elsif result <= 2
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- end
- Window_MessageBox.new(Vocab.send("forge_fail_#{result}"), Vocab.forge)
- end
- # 更新相关窗口
- @item_window.refresh
- @item_window.update_info
- @gold_window.refresh
- if item.level_state == 0
- @forge_window.reset_cost
- @forge_window.refresh
- else
- # 切换到物品窗口
- @forge_window.deactivate.hide
- @item_window.activate
- end
- when @forge_window.item_max - 1
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到物品窗口
- @forge_window.deactivate.hide
- @item_window.activate
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品操作打孔
- #--------------------------------------------------------------------------
- def process_item_5
- # 获得当前的待操作物品
- item = @item_window.item
- # 打孔检定未通过的情况下
- if item.max_sockets == 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.punch_fail_1, Vocab.punch)
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 显示打孔菜单
- commands = [Vocab.punch_open, Vocab.punch_close]
- menu = Window_ContextMenu.new(commands)
- start_index = 0
- if item.sockets == 0
- menu.disable_item(1)
- end
- if item.sockets == item.max_sockets
- menu.disable_item(0)
- start_index = 1
- end
- x = @item_window.cursor_rect.right + @item_window.x + 16
- y = @item_window.cursor_rect.y + @item_window.y + 16
- case menu.show_menu(x, y, start_index)
- when 0 # 开孔
- word = Vocab.punch_open
- material = item.socket_item
- sym = :open_socket
- when 1 # 封孔
- word = Vocab.punch_close
- material = item.unsocket_item
- sym = :close_socket
- when 2
- return
- end
- # 打孔操作
- if $game_party.item_number(material) > 0
- msg = sprintf(Vocab.punch_confirm, word, item.info_00, material)
- if Window_MessageBox.new(msg, Vocab.punch, MB_YN).result == DR_YES
- # 演奏装备 SE
- $game_system.se_play($data_system.equip_se)
- # 执行打孔
- item.send(sym)
- # 更新相关窗口
- @item_window.refresh
- @item_window.update_info
- @gold_window.refresh
- info = sprintf(Vocab.punch_info, word, item.sockets)
- Window_MessageBox.new(info, Vocab.punch)
- end
- else
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.punch_fail_2, Vocab.punch)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品操作镶嵌
- #--------------------------------------------------------------------------
- def process_item_6
- # 获得当前的待操作物品
- item = @item_window.item
- # 镶嵌检定未通过的情况下
- if (error = item.embed_state) > 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.send("embed_fail_#{error}"), Vocab.embed)
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到镶嵌窗口
- @item_window.deactivate
- @top_window.show_embed(item)
- @bottom_window.show_embed(item)
- end
- end
- #--------------------------------------------------------------------------
- # ● 镶孔窗口 B 键处理
- #--------------------------------------------------------------------------
- def top_window_b
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到物品窗口
- @top_window.deactivate.hide
- @bottom_window.hide
- @item_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 镶孔窗口 C 键处理
- #--------------------------------------------------------------------------
- def top_window_c
- # 镶嵌物不能取下的情况下
- if @top_window.item and not @item_window.item.embed_removable
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- Window_MessageBox.new(Vocab.embed_fail_3, Vocab.embed)
- else
- # 切换到镶嵌物窗口
- @top_window.deactivate
- @bottom_window.activate.index = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 镶嵌物窗口 B 键处理
- #--------------------------------------------------------------------------
- def bottom_window_b
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到镶孔窗口
- @bottom_window.deactivate.index = -1
- @top_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 镶嵌物窗口 C 键处理
- #--------------------------------------------------------------------------
- def bottom_window_c
- # 取得选中的镶嵌物
- item = @bottom_window.item
- # 演奏装备 SE
- $game_system.se_play($data_system.equip_se)
- # 执行镶嵌
- @item_window.item.socket(@top_window.index, item ? item.id : 0)
- # 刷新相关窗口
- @item_window.refresh
- @item_window.update_info
- @top_window.refresh
- @bottom_window.refresh
- # 切换到镶孔窗口
- @bottom_window.deactivate.index = -1
- @top_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 物品操作幻化
- #--------------------------------------------------------------------------
- def process_item_7
- # 获得当前的待操作物品
- item = @item_window.item
- sym = $sailcat_import[:EquipDurability] ? :sailcat_equipdu_price : :price
- price = item.send(sym)
- # 幻化检定未通过的情况下
- if not item.random_enabled?(:ALL)
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.reroll_fail_1, Vocab.reroll)
- # 幻化最低消费不足的情况下
- elsif $game_party.gold < price.factor(REROLL_COST_RATIO.min)
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- # 显示错误信息
- Window_MessageBox.new(Vocab.reroll_fail_2, Vocab.reroll)
- # 幻化检定通过的情况下
- else
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 显示幻化菜单
- commands = [1, 2, 3].map {|n|
- Vocab.send("reroll_grade_#{n}") + Vocab.nbsp + Vocab.reroll}
- menu = Window_ContextMenu.new(commands)
- start_index = 0
- 3.times do |x|
- if $game_party.gold < price.factor(REROLL_COST_RATIO[x])
- menu.disable_item(x)
- end
- end
- x = @item_window.cursor_rect.right + @item_window.x + 16
- y = @item_window.cursor_rect.y + @item_window.y + 16
- result = menu.show_menu(x, y, start_index)
- # 菜单被取消的情况下,返回
- return if result == 3
- cost = price.factor(REROLL_COST_RATIO[result])
- ranges = []
- # 低级或高级需限定幻化范围
- if result != 1
- if item.random_enabled?(:QUALITY)
- min = result == 0 ? item.min_quality : item.quality
- max = result == 0 ? item.quality : item.max_quality
- ranges.push(min..max)
- end
- if item.random_enabled?(:ENCHANT)
- min = result == 0 ? 0 : item.enchant_count
- max = result == 0 ? item.enchant_count : item.max_enchant
- ranges.push(min..max)
- end
- if item.random_enabled?(:LEVEL)
- min = result == 0 ? 0 : item.level
- max = result == 0 ? item.level : item.max_level
- ranges.push(min..max)
- end
- if item.random_enabled?(:SOCKET)
- min = result == 0 ? 1 : [item.sockets, 1].max
- max = result == 0 ? [item.sockets, 1].max : item.max_sockets
- ranges.push(min..max)
- end
- end
- # 幻化操作
- msg = sprintf(Vocab.reroll_confirm, item.info_00, cost)
- if Window_MessageBox.new(msg, Vocab.reroll, MB_YN).result == DR_YES
- # 演奏装备 SE
- $game_system.se_play($data_system.equip_se)
- # 执行幻化
- $game_party.lose_gold(cost)
- item.randomize(*ranges)
- # 更新相关窗口
- @item_window.refresh
- @item_window.update_info
- @gold_window.refresh
- info = sprintf(Vocab.reroll_info, item.info_00)
- Window_MessageBox.new(info, Vocab.reroll)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品操作熔毁
- #--------------------------------------------------------------------------
- def process_item_8
- # 获得当前的待操作物品
- item = @item_window.item
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 询问确认的情况下,执行熔毁
- gain = item.price.factor(DESTROY_GAIN_RATIO)
- msg = sprintf(Vocab.destroy_confirm, item.info_00, gain)
- if Window_MessageBox.new(msg, Vocab.destroy, MB_YN).result == DR_YES
- # 演奏销毁 SE
- $game_system.se_play($data_system.enemy_collapse_se)
- # 执行熔毁
- item.unsocket_all if $sailcat_import[:EquipSocket]
- $game_party.lose_object(item, 1)
- $game_party.gain_gold(gain)
- # 更新相关窗口
- @item_window.refresh
- @item_window.update_help
- @item_window.update_info
- @gold_window.refresh
- Window_MessageBox.new(Vocab.destroy_info, Vocab.repair)
- end
- end
- end
复制代码
因为SailCat大神的脚本之间有依赖关系,可能单看这两个脚本还不是特别明朗吧。。 |
|