| 赞 | 32 |
| VIP | |
| 好人卡 | |
| 积分 | 27 |
| 经验 | |
| 最后登录 | 2022-6-14 |
| 在线时间 | 227 小时 |
- 梦石
- 0
- 星屑
- 2724
- 在线时间
- 227 小时
- 注册时间
- 2016-3-27
- 回帖
- 557
|
发表于 2016-5-20 18:05:18
|
显示全部楼层
本帖最后由 WantMy蕙 于 2016-5-20 18:07 编辑
如果可以在脚本上囫囵,就可以使用.
用装备修理画面,可以进行装备的修理.
把装备修理画面用地图画面从活动的脚本实行以下的公式.
call _ repair _ equipment ED .
在默认的情况下,在修理中消耗金钱,但是通过参数的一整数,可以通过对其ID的变量值进行修理.
以变量为消费修理装备
ED . call _ repair _ equipment(1)
同时,耐久度变化的武器,防具的得到的从各自的活动的脚本开始实行以下的公式.
ED . gain _ durability _ weapon(id,durability,amount)
ED . gain _ durability _ armor(id,durability,amount)
上述方法的引数是装备的ID,设定耐久度,得到的件数为引数.
详细设定可以进行装备耐久度的设定.
ENABLE _ DURABILITY
装备的耐久度是否有效的默认的设定
以下的设定设定为寻求耐久度的条款的性能的式.
eval评价为造型通常式可以画。
这个时候,可以参照对象的装备的参数.
各种评价式中使用的特殊的变量
变量说明
dur道具的现在的耐久度
mdur道具的最大耐久度
price原创的物品的价格
atk原创的道具的攻击力上升值
_ def原创的道具的防御力上升价值
mat原创的道具的魔法力增加值
mdf原创的条款的魔法防御力增加值
agi原创的道具的敏捷性增加值
luk原创的道具的运上升值
mhp原创的道具的最大HP的上升价值
mmp原创的道具的最大MP增加值
etype _ id道具装备型ID
一个是一个
REPAIR _ PRICE
装备修理费用(钱的时候)。
REPAIR _ POINT
装备修理费用的费用的(变数的时候)。
PRICE
装备的价格的公式
SUC
加强成功率
攻击
攻击力上升值的公式
防御
防御力上升值的公式
MAT
魔法力上升值的公式
中密度
魔法防御力上升值的公式
AGI
敏捷性上升值的公式
LUK
上升值的公式
MHP
最大HP上升公式
MMP
最大MP的公式
_ DURABILITY DEFAULT
耐久度的初期值
MAX _ DURABILITY
最大耐久度
REPAIR _ DURABILITY
修理后的耐久度
DESTROY
true的时候耐久度为0,装备被废弃
PENALTY
在修理中设置失败时的惩罚.
惩罚是由以下种类选择的.
: none
点球
: break
装备的破坏
自然,自然
耐久度(自然数)。
DISPLAY _ SUCCESS
在装备强化画面强化成功率
DISPLAY _ PENALTY
用装备强化画面来表示惩罚
POINT _ UNIT
在消费变数的时候的货币单位?是的.
键: default模板单位的指定。
以自然数为键设定单位,利用那个ID的变量的时候那个单位被表示.
BROKEN _ MESSAGE
true的时候战斗中装备坏了的意思
MESSAGE _ FMT
装备破坏时显示的信息.
演员的名字,装备名被置换。
DEGRADE _ EXPS
在以后的伤害活动利用耐久度变动的场合使用耐久度减少式.
任意的键将式设定为文字列,指定装备耐久度活动内设定的键.
这个时候,对象的装备的参数及各种伤害活动可以参照可能的信息.
耐久度在减少式中使用的特殊的变量
变量说明
dur道具的现在的耐久度
mdur道具的最大耐久度
price原创的物品的价格
atk原创的道具的攻击力上升值
_ def原创的道具的防御力上升价值
mat原创的道具的魔法力增加值
mdf原创的条款的魔法防御力增加值
agi原创的道具的敏捷性增加值
luk原创的道具的运上升值
mhp原创的道具的最大HP的上升价值
mmp原创的道具的最大MP增加值
etype _ id道具装备型ID
一个是一个
伤害事件的各种变量subject,target等类型的
DRAW _ GAUGE
true的时候装备图标描画耐久度规
GAUGE _ MAX _ DURABILITY
这是最大耐久度的耐久度.
装备的最大耐久度小,耐久度120%的装备
会表现什么. .
GAUGE _ EDGECOLOR
槽的缘分的颜色(不)在nil绘图
GAUGE _ BACKCOLOR
规的背景色(不)在nil绘图
GAUGE _ COLOR
规的颜色
GAUGE _ MAXCOLOR
最大时的颜色
GAUGE _ OVERCOLOR
规界限突破时的颜色
BROKENCOLOR
耐久度0时的装备名称的文字颜色(nil变更不)
以下的设定设定为装备修理画面发出的效果音.
REPAIR _ SOUND
修理执行时效果音的文件名
REPAIR _ VOLUME
修理运行时效果音的卷
REPAIR _ PITCH
修理运行时效果音
SUCCESS _ SOUND
修理成功时效果音的文件名
SUCCESS _ VOLUME
修理成功时效果音
SUCCESS _ PITCH
修理成功时效果音
MISS _ SOUND
修理失败时效果音的文件名
MISS _ VOLUME
修理失败时效果音
MISS _ PITCH
修理失败时效果在声音的螺距
另外,在条款的笔记栏中可以进行一个项目进行耐久度的设定.
= = = = : xxx EnableDurability装备耐久度
指定为xxx,指定一个联保,是否有耐久度的一个项目。
= = = = : xxx RepairPrice装备耐久度
设置了金钱的修理费用.
= = = = : xxx RepairPoint装备耐久度
设置变量的修理费用.
= = = = : xxx Price装备耐久度
设定价格的公式.
= = = = : xxx Success装备耐久度
设置修理成功率.
= = = = : xxx Atk装备耐久度
设置攻击力的式.
= = = = : xxx Def装备耐久度
设定防御力的公式.
= = = = : xxx Mat装备耐久度
设定魔法力的式.
= = = = : xxx Mdf装备耐久度
设定魔法防御力的式.
= = = = : xxx Agi装备耐久度
设定敏捷性的式.
= =装备耐久度而体力: xxx = =
设定运气的公式.
= = = = : xxx MaxHP装备耐久度
设定最大HP的公式.
= = = = : xxx MaxMP装备耐久度
设置最大MP式的式.
= = = = : xxx DefaultDurability装备耐久度
初期耐久度设定.
= = = = : xxx MaxDurability装备耐久度
设定最大耐久度.
= = = = : xxx RepairDurability装备耐久度
设置修理成功时的耐久度.
= = = = : xxx GaugeMax装备耐久度
设定规的最大耐久度.
= = = = : xxx Destroy装备耐久度
指定为xxx,指定为联保,耐久度为0的时候,装备会被废弃.
装备强化Penalty xxx = = = = :
设定惩罚.
xxx是break,none ,(自然数)的任意指定。
伤害活动利用耐久度的减少
基本上和伤害活动的共同活动的方法一样,以下的点不一样.
一行注释
= =装备耐久度活动:% types %:% timing %==
条件注释的最后追加耐久度变动注释
耐久度变动#% args %
% args %是以下的格式转换成。
: actor,xxx,: exp,xxx,%选项%,xxx,...
: actor
耐久度受影响的演员,或是演员排列的指定。
: exp
DEGRADE _ EXPS键的指定。
这式的评价结果的部分耐久度下降.
没有期权的人也没有关系,但是设定的话会有影响的装备更加细致的设定.
在期权的选择%以下的项目.
: slot _ id
用装备的插槽ID或者是插槽ID的排列指定.
在这里指定的插槽ID的装备只耐久度变动.
省略和所有的插槽ID的装备耐久度减少.
: equip _ type
装备类型的ID或者装备类型的ID的排列指定.
在这里指定的装备型ID的装备只耐久度变动.
省略和所有装备型ID的装备耐久度下降.
: id
用装备的道具ID或者条款ID的排列指定.
在这里设定的道具ID的装备的耐久度变动.
省略和所有的条款ID的装备耐久度变动.
耐久度变动注释% args %的中途换行进入也没关系。
这些的差异以外的活动和同样的举动,伤害活动的条件注释和耐久度变动注释,使装备的耐久度下降.
同时,装备耐久度活动的活动内容本身也被实行.
例子・ID 001的技能被使用了的演员的防具(装备类型1,2,3,4)对,耐久度减少式: armor适用
注释:==装备耐久度活动: HP :表示前= =
注释:action id = = 1 .
注释:耐久度变动#: actor,target,: exp : armor,密度
: equip _ type,[ 1,2,3,4 ]
- #==============================================================================
- # ■ BMSP 装備耐久度[EQUIPMENTDURABILITY] Ver1.11 2013/11/25
- #------------------------------------------------------------------------------
- # 装備に耐久度性を導入します.
- #==============================================================================
- #------------------------------------------------------------------------------
- # ■内容
- # 装備に耐久度性を導入します.
- # 装備の様々な条件で耐久度を変更させたり,
- # 耐久度によって装備の性能を変動させることができます.
- #
- # 位置:「BMSP ダメージイベント」より下
- # 「BMSP アイテムセグメント」より下
- # 「BMSP 装備強化システム」より下
- # 「BMSP ショップアイテム試着」より上
- #
- # ■必須
- # 「BMSP アイテムセグメントver1.12以上」が必須です.
- #
- # ■併用
- # 「BMSP ダメージイベントver1.02以上」と併用することで戦闘時に装備の耐久度を
- # 様々な条件で自動的に変動させることができます.
- #
- # ■使用方法
- # スクリプトに丸ごと貼り付けていただければ使用できます。
- #
- # 装備修理画面を呼び出すことで,装備の修理を行うことができます.
- # 装備修理画面を呼び出すにはマップ画面でイベントのスクリプトから
- # ED.call_repair_equipment
- # を実行します.
- # デフォルトでは修理にお金を消費しますが,引数に整数を渡すことでそのIDに対応する
- # 変数の値を消費して修理することができます.
- # 例・変数001を消費して装備を修理する
- # ED.call_repair_equipment(1)
- # また,耐久度を変化させた武器,防具の入手についてはイベントのスクリプトから
- # ED.gain_durability_eapon(id, durability, amount)
- # ED.gain_durability_armor(id, durability, amount)
- # を実行します.装備のID,設定耐久度,入手個数を引数に指定します.
- #
- # 詳細設定にて装備耐久度の設定を行うことができます.
- # ○ENABLE_DURABILITY : 装備の耐久度が有効かどうかのデフォルトの設定です.
- #
- # 以下の設定では耐久度によるアイテムの性能を求めるための式を設定します.
- # evalで評価されるためRubyの通常の式を描くことができます・
- # このとき,対象の装備のパラメータを参照することができます.
- # ・dur :アイテムの現在の耐久度
- # ・mdur :アイテムの最大耐久度
- # ・price :オリジナルのアイテムの価格
- # ・atk :オリジナルのアイテムの攻撃力の上昇値
- # ・_def :オリジナルのアイテムの防御力の上昇値
- # ・mat :オリジナルのアイテムの魔法力の上昇値
- # ・mdf :オリジナルのアイテムの魔法防御力の上昇値
- # ・agi :オリジナルのアイテムの敏捷性の上昇値
- # ・luk :オリジナルのアイテムの運の上昇値
- # ・mhp :オリジナルのアイテムの最大HPの上昇値
- # ・mmp :オリジナルのアイテムの最大MPの上昇値
- # ・etype_id:アイテムの装備タイプID
- # ・id :アイテムのid
- # ○REPAIR_PRICE : 装備修理にかかる費用の式(お金の時)
- # ○REPAIR_POINT : 装備修理にかかる費用の式(変数の時)
- # ○PRICE:装備の価格の式
- # ○SUC:修理成功率の式
- # ○ATK:攻撃力上昇値の式
- # ○DEF:防御力上昇値の式
- # ○MAT:魔法力上昇値の式
- # ○MDF:魔法防御力上昇値の式
- # ○AGI:敏捷性上昇値の式
- # ○LUK:運上昇値の式
- # ○MHP:最大HP上昇値の式
- # ○MMP:最大MP上昇値の式
- #
- # ○DEFAULT_DURABILITY:耐久度の初期値
- # ○MAX_DURABILITY:最大耐久度
- # ○REPAIR_DURABILITY:修理後の耐久度
- # ○DESTROY:trueのとき耐久度が0になると装備が破棄されます
- #
- # ○PENALTY:修理に失敗したときのペナルティを設定します.
- # ペナルティには以下の種類から選択します.
- # :none :ペナルティなし
- # :break :装備の破壊
- # (自然数) :耐久度が(自然数)になる
- #
- # ○DISPLAY_SUCCESS:装備修理画面で強化成功率を表示するか
- # ○DISPLAY_PENALTY:装備修理画面でペナルティを表示するか
- # ○POINT_UNIT:変数を消費して修理する時の通貨単位?です
- # キー:defaultにはデフォルトの単位を指定します.
- # 自然数をキーにして単位を設定すると,そのIDの変数を利用する時その単位が表示されます.
- # ○BROKEN_MESSAGE:trueのとき戦闘中装備が壊れた旨を表示します
- # ○MESSAGE_FMT:装備破壊時に表示されるメッセージです.
- # アクターの名前,装備名が置換される
- #
- # ○DEGRADE_EXPS:ダメージイベントを利用して耐久度を変動させる場合に使用する耐久度減少式です.
- # 任意のキーに対して式を文字列で設定し,装備耐久度イベント内で設定したキーを指定します.
- # このとき,対象の装備のパラメータおよび各種ダメージイベントで参照可能な
- # 情報を参照することができます.
- # ・dur :アイテムの現在の耐久度
- # ・mdur :アイテムの最大耐久度
- # ・price :オリジナルのアイテムの価格
- # ・atk :オリジナルのアイテムの攻撃力の上昇値
- # ・_def :オリジナルのアイテムの防御力の上昇値
- # ・mat :オリジナルのアイテムの魔法力の上昇値
- # ・mdf :オリジナルのアイテムの魔法防御力の上昇値
- # ・agi :オリジナルのアイテムの敏捷性の上昇値
- # ・luk :オリジナルのアイテムの運の上昇値
- # ・mhp :オリジナルのアイテムの最大HPの上昇値
- # ・mmp :オリジナルのアイテムの最大MPの上昇値
- # ・etype_id:アイテムの装備タイプID
- # ・id :アイテムのid
- # ・ダメージイベントの変数(subject, targetなど)
- #
- # ○DRAW_GAUGE:装備アイコンに耐久度ゲージを描画するか
- # ○GAUGE_MAX_DURABILITY:ゲージが最大になる耐久度
- # 装備の最大耐久度より小さくすることで
- # 例えば耐久度120%の装備などを表現することができます.
- # ○GAUGE_EDGECOLOR:ゲージの縁の色(nilで描画しない)
- # ○GAUGE_BACKCOLOR:ゲージの背景色(nilで描画しない)
- # ○GAUGE_COLOR:ゲージの色
- # ○GAUGE_MAXCOLOR:ゲージ最大時の色
- # ○GAUGE_OVERCOLOR:ゲージ限界突破時の色
- # ○BROKENCOLOR:耐久度が0のときの装備名の文字色(nilで変更しない)
- #
- # 以下の設定では装備修理画面で鳴らす効果音を指定できます.
- # ○REPAIR_SOUND:修理実行時効果音のファイル名
- # ○REPAIR_VOLUME:修理実行時効果音のボリューム
- # ○REPAIR_PITCH:修理実行時効果音のピッチ
- # ○SUCCESS_SOUND:修理成功時効果音のファイル名
- # ○SUCCESS_VOLUME:修理成功時効果音のボリューム
- # ○SUCCESS_PITCH:修理成功時効果音のピッチ
- # ○MISS_SOUND:修理失敗時効果音のファイル名
- # ○MISS_VOLUME:修理失敗時効果音のボリューム
- # ○MISS_PITCH:修理失敗時効果音のピッチ
- #
- # また,アイテムのメモ欄にてアイテムごとに耐久度の設定を行うことができます.
- # ==装備耐久度EnableDurability:xxx==
- # xxxにtrueかfalseを指定して,耐久度のあるアイテムかどうか設定します.
- # ==装備耐久度RepairPrice:xxx==
- # お金による修理費用の式を設定します.
- # ==装備耐久度RepairPoint:xxx==
- # 変数による修理費用の式を設定します.
- # ==装備耐久度Price:xxx==
- # 価格の式を設定します.
- # ==装備耐久度Success:xxx==
- # 修理成功率の式を設定します.
- # ==装備耐久度Atk:xxx==
- # 攻撃力の式を設定します.
- # ==装備耐久度Def:xxx==
- # 防御力の式を設定します.
- # ==装備耐久度Mat:xxx==
- # 魔法力の式を設定します.
- # ==装備耐久度Mdf:xxx==
- # 魔法防御の式を設定します.
- # ==装備耐久度Agi:xxx==
- # 敏捷性の式を設定します.
- # ==装備耐久度Luk:xxx==
- # 運の式を設定します.
- # ==装備耐久度MaxHP:xxx==
- # 最大HPの式を設定します.
- # ==装備耐久度MaxMP:xxx==
- # 最大MPの式を設定します.
- # ==装備耐久度DefaultDurability:xxx==
- # 初期耐久度を設定します.
- # ==装備耐久度MaxDurability:xxx==
- # 最大耐久度を設定します.
- # ==装備耐久度RepairDurability:xxx==
- # 修理成功時の耐久度を設定します.
- # ==装備耐久度GaugeMax:xxx==
- # ゲージの最大耐久度を設定します.
- # ==装備耐久度Destroy:xxx==
- # xxxにtrueかfalseを指定して耐久度が0になったとき装備が破棄されるか設定します.
- # ==装備耐久度Penalty:xxx==
- # ペナルティを設定します.xxxにはbreak,none,(自然数)のいずれかを指定します.
- #
- # ● ダメージイベントを利用した耐久度の減少
- # 基本的にはダメージイベントのコモンイベントの作り方と同様ですが,
- # 以下の点が異なります.
- # ・一行目の注釈
- # ==装備耐久度イベント:%types%:%timing%==
- # ・条件注釈の最後に耐久度変動注釈を追加
- # 耐久度変動#%args%
- # %args%は以下のフォーマットで置き換えます.
- # :actor => xxx, :exp => xxx, %オプション% => xxx, ...
- # :actorは耐久度の影響を受けるアクター,もしくはアクターの配列を指定します.
- # :expはDEGRADE_EXPSのキーを指定します.この式の評価結果の分だけ耐久度が減少します.
- # %オプション%は無くても構いませんが,設定するとより影響を受ける装備についてより細かい設定を行うことができます.
- # %オプション%には以下の項目があります.
- # :slot_idは装備のスロットIDもしくはスロットIDの配列で指定します.
- # ここで指定したスロットIDの装備のみ耐久度が変動します.
- # 省略すると全てのスロットIDの装備耐久度が減少します.
- # :equip_typeは装備タイプIDもしくは装備タイプIDの配列で指定します.
- # ここで指定した装備タイプIDの装備のみ耐久度が変動します.
- # 省略すると全ての装備タイプIDの装備耐久度が減少します.
- # :idは装備のアイテムIDもしくはアイテムIDの配列で指定します.
- # ここで設定したアイテムIDの装備の耐久度が変動します.
- # 省略すると全てのアイテムIDの装備耐久度が変動します.
- #
- # 耐久度変動注釈は%args%の途中に改行が入っても構いません.
- #
- # これらの違い以外はダメージイベントと同じ挙動をするので,
- # ダメージイベントの条件注釈および耐久度変動注釈でうまく条件を設定し,
- # 装備の耐久度を減少させます.
- # 装備耐久度イベントのイベント内容自体も実行されます.
- #
- # ■注意
- # このスクリプトでは
- # 「RPG::BaseItem」「RPG::EquipItem」「Game_Actor」「Game_Party」
- # 「Scene_Battle」「Window_BattleLog」「Window_Base」「Window_ShopBuy」
- # のメソッドを改変しています。
- # ■情報
- # このスクリプトはgentlawkによって作られたものです。
- # 利用規約は[url]http://blueredzone.com[/url]をご覧ください。
- #------------------------------------------------------------------------------
- module BMSP
- @@includes ||= {}
- @@includes[:EquipmentDurability] = 1.11
- module EquipmentDurability
- #▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
- #詳細設定
- ENABLE_DURABILITY = true # trueのときデフォルトで耐久度がON
- REPAIR_PRICE = "price / 2" # 修理費用式
- REPAIR_POINT = "price / 4" # 変数消費による修理費用式
- PRICE = "price" # 耐久度による価格変動式
- SUC = "100" # 修理成功率式
- ATK = "dur == 0 ? 0 : atk" # 攻撃力変動式
- DEF = "dur == 0 ? 0 : _def" # 防御力変動式
- MAT = "dur == 0 ? 0 : mat" # 魔法力変動式
- MDF = "dur == 0 ? 0 : mdf" # 魔法防御変動式
- AGI = "dur == 0 ? 0 : agi" # 敏捷性変動式
- LUK = "dur == 0 ? 0 : luk" # 運変動式
- MHP = "dur == 0 ? 0 : mhp" # 最大HP変動式
- MMP = "dur == 0 ? 0 : mmp" # 差大MP変動式
- DEFAULT_DURABILITY = 100 # 耐久度の初期値
- MAX_DURABILITY = 100 # 最大耐久度
- REPAIR_DURABILITY = 100 # 修理後の耐久度
- DESTROY = false # trueのとき耐久度が0になると装備が破棄
- PENALTY = 0 # 修理失敗時のペナルティ
- # :break で装備が破棄
- # :none でペナルティなし
- # (自然数) で 指定の耐久度になる
- DISPLAY_SUCCESS = false # 修理成功率を表示するか
- DISPLAY_PENALTY = false # ペナルティを表示するか
-
- POINT_UNIT = {} # 変数による修理の時表示される単位
- POINT_UNIT[:default] = "P" # デフォルトの単位
- POINT_UNIT[1] = "RP" # 変数ID001による修理画面のとき,"RP"と表示
-
- BROKEN_MESSAGE = true # trueのとき戦闘中装備が壊れた旨を表示
- MESSAGE_FMT = "%s の %s が壊れた!" # 装備破壊時に表示されるメッセージ
- # アクターの名前,装備名が置換される
-
- DEGRADE_EXPS = {}
- DEGRADE_EXPS[:weapon] = # 武器の耐久度減少式1
- "1"
- DEGRADE_EXPS[:weapon2] = # 武器の耐久度減少式2(ダメージイベント:HPを想定)
- "target.result.hp_damage < 100 ? 0 : 1" # 与えたダメージが100未満なら耐久度は減らない
- DEGRADE_EXPS[:armor] = # 防具の耐久度減少式1
- "1"
- DEGRADE_EXPS[:armor2] = # 防具の耐久度減少式2(ダメージイベントHPを想定)
- "equip.atype_id == 4 ? 1 : 2" # 防具タイプ4(重装防具)なら耐久度は減りにくい
-
- DRAW_GAUGE = true # 耐久度ゲージを描画するか
- GAUGE_MAX_DURABILITY = 100 # ゲージが最大になる耐久度
- GAUGE_EDGECOLOR = 7 # ゲージの縁の色(nilで描画しない)
- GAUGE_BACKCOLOR = 19 # ゲージの背景色(nilで描画しない)
- GAUGE_COLOR = 3 # ゲージの色
- GAUGE_MAXCOLOR = 1 # ゲージ最大時の色
- GAUGE_OVERCOLOR = 2 # ゲージ限界突破時の色
- BROKENCOLOR = 18 # 耐久度が0のときの装備名の文字色(nilで変更しない)
-
- # 修理実行時の効果音
- REPAIR_SOUND = "Hammer" # ファイル名
- REPAIR_VOLUME = 80 # ボリューム
- REPAIR_PITCH = 100 # ピッチ
- # 修理成功時の効果音
- SUCCESS_SOUND = "Chime2" # ファイル名
- SUCCESS_VOLUME = 80 # ボリューム
- SUCCESS_PITCH = 100 # ピッチ
- # 強化失敗時の効果音
- MISS_SOUND = "Buzzer2" # ファイル名
- MISS_VOLUME = 80 # ボリューム
- MISS_PITCH = 100 # ピッチ
- #▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
- # メモ欄から設定を抽出する正規表現
- MATCH = /==装備耐久度(.+):(.*)==/o
- NAME_LIST = [
- :EnableDurability, :RepairPrice, :RepairPoint,
- :Price, :Success, :Atk, :Def, :Mat, :Mdf, :Agi, :Luk,
- :MaxHP, :MaxMP, :DefaultDurability, :MaxDurability,
- :RepairDurability,:GaugeMax,
- :Destroy, :Penalty
- ]
- #--------------------------------------------------------------------------
- # ● 正規表現とのマッチ
- #--------------------------------------------------------------------------
- def self.match(str)
- data = Hash.new
- NAME_LIST.each{|name| data[name] = nil }
- str.scan(MATCH).each do |name, value|
- symname = name.to_sym
- next unless data.key?(symname)
- case symname
- when :Penalty
- if /\d+/ =~ value
- data[symname] = value.to_u
- elsif /break|none/ =~ value
- data[symname] = value.to_sym
- end
- when :EnableDurability, :Destroy
- data[symname] = Kernel.eval(value) ? true : false
- when :DefaultDurability, :MaxDurability, :RepairDurability, :GaugeMax
- data[symname] = value.to_i
- else
- data[symname] = value
- end
- end
- return data
- end
- #--------------------------------------------------------------------------
- # ● 式の評価の本体
- #--------------------------------------------------------------------------
- def self.eval(exp,dur,mdur,mhp,mmp,atk,_def,mat,mdf,agi,luk,price,etype_id,id)
- Kernel.eval(exp)
- end
- #--------------------------------------------------------------------------
- # ● 装備耐久度の変動
- #--------------------------------------------------------------------------
- def self.degrade_durability(bind, params)
- unless params[:actor] && params[:exp]
- raise ArgumentError, "耐久度変動の必須パラメータがありません."
- end
- actors = params[:actor].is_a?(Array) ? params[:actor] : [params[:actor]]
- if params[:slot_id]
- slot_id = params[:slot_id].is_a?(Array) ? params[:slot_id] : [params[:slot_id]]
- else
- slot_id = false
- end
- if params[:equip_type]
- equip_type = params[:equip_type].is_a?(Array) ? params[:equip_type] : [params[:equip_type]]
- else
- equip_type = false
- end
- if params[:id]
- id = params[:id].is_a?(Array) ? params[:id] : [params[:id]]
- else
- id = false
- end
- actors.each do |actor|
- next unless actor.actor?
- actor.degrade_durability(DEGRADE_EXPS[params[:exp]], bind, slot_id, equip_type, id)
- end
- end
- #--------------------------------------------------------------------------
- # ● 装備破壊メッセージバッファの初期化
- #--------------------------------------------------------------------------
- def self.init_message_buffer
- @message_buffer = []
- end
- #--------------------------------------------------------------------------
- # ● 装備破壊メッセージの取得
- #--------------------------------------------------------------------------
- def self.get_message
- return nil unless @message_buffer
- @message_buffer.shift
- end
- #--------------------------------------------------------------------------
- # ● 装備破壊メッセージの追加
- #--------------------------------------------------------------------------
- def self.push_message(message)
- @message_buffer ||= []
- @message_buffer.push message
- end
- #--------------------------------------------------------------------------
- # ● 導入スクリプトの例外クラス
- #--------------------------------------------------------------------------
- class REQUIRE < StandardError
- end
- end
- #--------------------------------------------------------------------------
- # ● 必須スクリプトのチェック
- #--------------------------------------------------------------------------
- class << self
- if method_defined?(:check_require)
- alias equipmentdurability_check_require check_require
- end
- end
- def self.check_require(require, version)
- if methods.include?(:equipmentdurability_check_require)
- equipmentdurability_check_require(require, version)
- end
- if !@@includes[require]
- message =
- sprintf("BMSPスクリプト%sが導入されていません.\n%s Ver%1.2f以上を導入してください.",
- require,require,version)
- raise EquipmentDurability::REQUIRE, message
- elsif @@includes[require] < version
- message =
- sprintf("BMSPスクリプト%s Ver%1.2fは古いバージョンです.\n%s Ver%1.2f以上を導入してください.",
- require,@@includes[require],require,version)
- raise EquipmentDurability::REQUIRE, message
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 導入スクリプトのチェック
- #--------------------------------------------------------------------------
- def self.check_include(include, version)
- return false unless @@includes[include]
- @@includes[include] >= version
- end
- module Interface
- ::ED = self
- #--------------------------------------------------------------------------
- # ● 耐久度指定武器の追加
- #--------------------------------------------------------------------------
- def self.gain_durability_weapon(id, durability, amount)
- $game_party.gain_durability_weapon(id, durability, amount)
- end
- #--------------------------------------------------------------------------
- # ● 耐久度指定防具の追加
- #--------------------------------------------------------------------------
- def self.gain_durability_armor(id, durability, amount)
- $game_party.gain_durability_armor(id, durability, amount)
- end
- #--------------------------------------------------------------------------
- # ● 装備修理画面の呼び出し
- #--------------------------------------------------------------------------
- def self.call_repair_equipment(point = false)
- return if $game_party.in_battle
- BMSP::Scene_RepairEquipment.point = point
- SceneManager.call(BMSP::Scene_RepairEquipment)
- Fiber.yield
- end
- end
- end
- BMSP.check_require(:ItemSegment, 1.12)
- #==============================================================================
- # ■ Sound
- #==============================================================================
- module Sound
- # 装備強化実行
- def self.play_repair_equipment
- Audio.se_play("Audio/SE/" + BMSP::EquipmentDurability::REPAIR_SOUND,
- BMSP::EquipmentDurability::REPAIR_VOLUME,
- BMSP::EquipmentDurability::REPAIR_PITCH)
- end
- # 装備強化成功
- def self.play_repair_equipment_success
- Audio.se_play("Audio/SE/" + BMSP::EquipmentDurability::SUCCESS_SOUND,
- BMSP::EquipmentDurability::SUCCESS_VOLUME,
- BMSP::EquipmentDurability::SUCCESS_PITCH)
- end
- # 装備強化失敗
- def self.play_repair_equipment_miss
- Audio.se_play("Audio/SE/" + BMSP::EquipmentDurability::MISS_SOUND,
- BMSP::EquipmentDurability::MISS_VOLUME,
- BMSP::EquipmentDurability::MISS_PITCH)
- end
- end
- #==============================================================================
- # ■ BMSP::DamageEvent
- #==============================================================================
- if BMSP.check_include(:DamageEvent, 1.02)
- module BMSP
- module DamageEvent
- #--------------------------------------------------------------------------
- # ● 条件にマッチするコモンイベントを取得
- #--------------------------------------------------------------------------
- instance_eval{ alias bmsp_equipmentdurability_commons commons }
- def self.commons(type, timing, binding)
- commons = bmsp_equipmentdurability_commons(type, timing, binding)
- init_equipmentdurability_commons if @equipmentdurability_commons.nil?
- return commons + @equipmentdurability_commons[type][timing].select{ |common,cond|
- check_condition(cond, binding)
- }.map{|cc| cc.first }
- end
- #--------------------------------------------------------------------------
- # ● 装備耐久度:対象コモンイベントの初期化
- #--------------------------------------------------------------------------
- def self.init_equipmentdurability_commons
- # オリジナルの対象コモンイベントの退避
- original_commons = @commons
- # 初期化
- types = [:counter, :reflection, :substitute, :failure, :critical, :miss, :evasion,
- :hp_damage, :mp_damage, :tp_damage, :added_st, :removed_st]
- @commons = {}
- types.each do |type|
- @commons[type] = {:before=>[], :after=>[]}
- end
- # 一時的に装備耐久度用のチェッカーをバインド
- class << self
- alias original_check_damageevent check_damageevent
- define_method(:check_damageevent, instance_method(:check_equipmentdurability_damageevent))
- end
- # 装備耐久度のダメージイベントを取得
- init_commons
- # チェッカーのバインドを戻す
- class << self
- define_method(:check_damageevent, instance_method(:original_check_damageevent))
- remove_method(:original_check_damageevent)
- end
- # 対象コモンイベントの再配置
- @equipmentdurability_commons = @commons
- @commons = original_commons
- end
- #--------------------------------------------------------------------------
- # ● 装備耐久度:ダメージイベントかチェックして情報を取得
- #--------------------------------------------------------------------------
- def self.check_equipmentdurability_damageevent(common_event)
- list = common_event.list
- index = 0
- return nil if list[index].code != 108 # 注釈じゃない
- define_comment = list[index].parameters[0]
- index += 1
- while list[index].code == 408
- index += 1
- end
- return nil unless define_comment =~ /==装備耐久度イベント:(.+):(表示前|表示後)==/o
- types = $1.split('|')
- timing = $2 == "表示前" ? :before : :after
- # 対象タイプを変換
- types.map!{|type| self.translate_type(type)}.compact!
- return nil if types.empty?
- # 条件文を抽出
- cond = []
- size = -1
- while list[index].code == 108
- size += 1
- line = list[index].parameters[0]
- if line =~ /耐久度変動#(.+)/ # 耐久度変動
- params = $1
- index += 1
- while list[index].code == 408
- params += list[index].parameters[0]
- index += 1
- end
- condition = "BMSP::EquipmentDurability.degrade_durability(binding, #{params})"
- cond[size] = [condition]
- else # 条件文
- cond[size] = [line]
- index += 1
- while list[index].code == 408
- cond[size].push(list[index].parameters[0])
- index += 1
- end
- end
- end
- return types,timing,cond
- end
- end
- end
- end
- #==============================================================================
- # ■ BMSP::DurabilityData
- #------------------------------------------------------------------------------
- # 装備耐久度情報のクラスです.
- #==============================================================================
- class BMSP::DurabilityData
- #--------------------------------------------------------------------------
- # ● 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_reader :durability # 耐久度
- attr_reader :max_durability # 最大耐久度
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(data)
- @durability = 0
- ed = BMSP::EquipmentDurability
- @repair_price_exp = data[:RepairPrice] ? data[:RepairPrice] : ed::REPAIR_PRICE
- @repair_point_exp = data[:RepairPoint] ? data[:RepairPoint] : ed::REPAIR_POINT
- @price_exp = data[:Price] ? data[:Price] : ed::PRICE
- @suc_exp = data[:Success] ? data[:Success] : ed::SUC
- @atk_exp = data[:Atk] ? data[:Atk] : ed::ATK
- @def_exp = data[:Def] ? data[:Def] : ed::DEF
- @mat_exp = data[:Mat] ? data[:Mat] : ed::MAT
- @mdf_exp = data[:Mdf] ? data[:Mdf] : ed::MDF
- @agi_exp = data[:Agi] ? data[:Agi] : ed::AGI
- @luk_exp = data[:Luk] ? data[:Luk] : ed::LUK
- @mhp_exp = data[:MaxHP] ? data[:MaxHP] : ed::MHP
- @mmp_exp = data[:MaxMP] ? data[:MaxMP] : ed::MMP
- @default_durability = data[:DefaultDurability] ? data[:DefaultDurability] : ed::DEFAULT_DURABILITY
- @max_durability = data[:MaxDurability] ? data[:MaxDurability] : ed::MAX_DURABILITY
- @repair_durability = data[:RepairDurability] ? data[:RepairDurability] : ed::REPAIR_DURABILITY
- @gauge_max_durability = data[:GaugeMax] ? data[:GaugeMax] : ed::GAUGE_MAX_DURABILITY
- @destroy = data[:Destroy] ? data[:Destroy] : ed::DESTROY
- @penalty = data[:Penalty] ? data[:Penalty] : ed::PENALTY
- @penalty = :break if @destroy && @penalty == 0
- if @destroy && @default_durability == 0 # 最初から壊れているような装備は許可しない
- @max_durability = 1 if @max_durability == 0
- @default_durability = 1
- end
- self.durability = @default_durability
- @params_cache = []
- @price_cache = []
- @repair_price_cache = []
- @repair_point_cache = []
- @success_cache = []
- end
- #--------------------------------------------------------------------------
- # ● 耐久度の設定
- #--------------------------------------------------------------------------
- def durability=(dur)
- # min = @destroy ? 1 : 0
- min = 0
- @durability = [[dur, min].max, @max_durability].min
- end
- #--------------------------------------------------------------------------
- # ● パラメータ式の取得
- #--------------------------------------------------------------------------
- def params_exp
- [
- @mhp_exp, @mmp_exp, @atk_exp, @def_exp,
- @mat_exp, @mdf_exp, @agi_exp, @luk_exp
- ]
- end
- #--------------------------------------------------------------------------
- # ● パラメータの取得
- #--------------------------------------------------------------------------
- def params(item)
- return @params_cache[@durability] if @params_cache[@durability]
- @params_cache[@durability] = params_exp.map{|exp|
- exp_eval(item, exp)
- }
- end
- #--------------------------------------------------------------------------
- # ● 価格の取得
- #--------------------------------------------------------------------------
- def price(item)
- return 0 if item.bmsp_equipmentdurability_price == 0
- return @price_cache[@durability] if @price_cache[@durability]
- @price_cache[@durability] = [exp_eval(item, @price_exp), 1].max
- end
- #--------------------------------------------------------------------------
- # ● 修理価格の取得
- #--------------------------------------------------------------------------
- def repair_price(item)
- return @repair_price_cache[@durability] if @repair_price_cache[@durability]
- @repair_price_cache[@durability] = [exp_eval(item, @repair_price_exp), 0].max
- end
- #--------------------------------------------------------------------------
- # ● 変数修理価格の取得
- #--------------------------------------------------------------------------
- def repair_point(item)
- return @repair_point_cache[@durability] if @repair_point_cache[@durability]
- @repair_point_cache[@durability] = [exp_eval(item, @repair_point_exp), 0].max
- end
- #--------------------------------------------------------------------------
- # ● 成功率の取得
- #--------------------------------------------------------------------------
- def success(item)
- return @success_cache[@durability] if @success_cache[@durability]
- @success_cache[@durability] = [[exp_eval(item, @suc_exp), 0].max, 100].min
- end
- #--------------------------------------------------------------------------
- # ● 各種式の評価
- #--------------------------------------------------------------------------
- def exp_eval(item, exp)
- base_params = item.bmsp_equipmentdurability_params.dup
- price = item.bmsp_equipmentdurability_price
- BMSP::EquipmentDurability.eval(exp,@durability,@max_durability,*base_params,price,item.etype_id,item.id)
- end
- #--------------------------------------------------------------------------
- # ● ゲージ最大値の取得
- #--------------------------------------------------------------------------
- def gauge_max_durability
- @gauge_max_durability
- end
- #--------------------------------------------------------------------------
- # ● ペナルティの取得
- #--------------------------------------------------------------------------
- def penalty
- @penalty
- end
- #--------------------------------------------------------------------------
- # ● 耐久度0で壊れるかどうか
- #--------------------------------------------------------------------------
- def destroy?
- @destroy
- end
- #--------------------------------------------------------------------------
- # ● 修理可能かどうか
- #--------------------------------------------------------------------------
- def repairable?
- @durability < @repair_durability
- end
- #--------------------------------------------------------------------------
- # ● 修理
- #--------------------------------------------------------------------------
- def repair
- self.durability = @repair_durability
- end
- #--------------------------------------------------------------------------
- # ● 修理の実行
- #--------------------------------------------------------------------------
- def execute_repair(item)
- old_dur = self.durability
- if rand(100) < success(item) # 成功
- self.durability = @repair_durability
- return old_dur
- end
- # 失敗
- case @penalty
- when :break # 消失
- # 消失処理は呼び出し元で行う
- when :none # なし
- else # 耐久度指定
- self.durability = @penalty
- end
- return [old_dur, @penalty]
- end
- end
- #==============================================================================
- # ■ BMSP::ItemExtend
- #==============================================================================
- class BMSP::ItemExtend
- #--------------------------------------------------------------------------
- # ● 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_reader :durability_data # 装備耐久度
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- alias equipdurability_initialize initialize
- def initialize(item)
- equipdurability_initialize(item)
- init_durability
- end
- #--------------------------------------------------------------------------
- # ● 装備耐久度の初期化
- #--------------------------------------------------------------------------
- def init_durability
- if is_weapon? || is_armor?
- data = BMSP::EquipmentDurability.match(original.note)
- if data[:EnableDurability].nil?
- durability = BMSP::EquipmentDurability::ENABLE_DURABILITY
- else
- durability = data[:EnableDurability]
- end
- @durability_data = durability ? BMSP::DurabilityData.new(data) : nil
- else
- @durability_data = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 耐久度があるかどうか
- #--------------------------------------------------------------------------
- def has_durability?
- extend? && !@durability_data.nil?
- end
- end
- #==============================================================================
- # ■ RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # ● 装備耐久度情報の取得
- #--------------------------------------------------------------------------
- def durability_data
- return nil unless has_durability?
- self.extend.durability_data
- end
- #--------------------------------------------------------------------------
- # ● 装備強化可能かどうか
- #--------------------------------------------------------------------------
- def has_durability?
- extend? && self.extend.has_durability?
- end
- end
- #==============================================================================
- # ■ RPG::EquipItem
- #==============================================================================
- class RPG::EquipItem
- #--------------------------------------------------------------------------
- # ● パラメータの取得
- #--------------------------------------------------------------------------
- alias bmsp_equipmentdurability_params params
- def params
- return bmsp_equipmentdurability_params unless has_durability?
- durability_data.params(self)
- end
- #--------------------------------------------------------------------------
- # ● 価格の取得
- #--------------------------------------------------------------------------
- alias bmsp_equipmentdurability_price price
- def price
- return bmsp_equipmentdurability_price unless has_durability?
- durability_data.price(self)
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 装備耐久度の変動
- #--------------------------------------------------------------------------
- def degrade_durability(exp, bind = binding, slot_id = false, equip_type = false, id = false)
- equips = @equips.dup
- # 装備していないスロットの削除
- equips.map!{|equip| equip.object.nil? ? nil : equip}
- # 装備スロットの限定
- if slot_id
- slot_id.each do |i|
- equips[i] = nil
- end
- end
- # 装備タイプの限定
- if equip_type
- equips.map!{|equip|
- next nil if equip.nil?
- equip_type.include?(equip.object.etype_id) ? equip : nil
- }
- end
- # 装備IDの限定
- if id
- equips.select!{|equip|
- next nil if equip.nil?
- id.include?(equip.object.id) ? equip : nil
- }
- end
- equips.each.with_index do |equipbase, slot|
- next if equipbase.nil?
- equip = equipbase.object
- next unless equip.has_durability?
- # 追加のローカル変数バインド
- $bmsp_equipmentdurability_localvars = {
- :actor => self,
- :equip => equip,
- :dur => equip.durability_data.durability,
- :mdur => equip.durability_data.max_durability,
- :mhp => equip.params[0],
- :mmp => equip.params[1],
- :atk => equip.params[2],
- :_def => equip.params[3],
- :mat => equip.params[4],
- :mdf => equip.params[5],
- :agi => equip.params[6],
- :luk => equip.params[7],
- :price => equip.price,
- :etype_id => equip.etype_id,
- :id => equip.id
- }
- exps = []
- $bmsp_equipmentdurability_localvars.keys.each do |var|
- exps.push("#{var} = $bmsp_equipmentdurability_localvars[:#{var}]")
- end
- exps.push(exp)
- # 評価
- value = bind.eval(exps.join(";"))
- # 変動
- equip.durability_data.durability -= value
- # 破壊の処理
- if equip.durability_data.destroy? && equip.durability_data.durability == 0
- force_change_equip(slot, nil) # 装備の強制解除
- if $game_party.in_battle && BMSP::EquipmentDurability::BROKEN_MESSAGE
- mes = sprintf(BMSP::EquipmentDurability::MESSAGE_FMT, actor.name, equip.name)
- BMSP::EquipmentDurability.push_message(mes)
- end
- end
- end
- end
- end
- #==============================================================================
- # ■ Game_Party
- #==============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ● 耐久度指定武器の追加
- #--------------------------------------------------------------------------
- def gain_durability_weapon(id, durability, amount)
- item = $data_weapons[id]
- gain_durability_equip(@weapons, item, durability, amount)
- end
- #--------------------------------------------------------------------------
- # ● 耐久度指定防具の追加
- #--------------------------------------------------------------------------
- def gain_durability_armor(id, durability, amount)
- item = $data_armors[id]
- gain_durability_equip(@armors, item, durability, amount)
- end
- #--------------------------------------------------------------------------
- # ● 耐久度指定装備の追加
- #--------------------------------------------------------------------------
- def gain_durability_equip(container, item, durability, amount)
- extenditems = []
- amount.times do
- extend = BMSP::ItemExtend.new(item)
- if extend.has_durability?
- # 最初から壊れていたらそもそも追加しない
- return if extend.durability_data.destroy? && durability == 0
- extend.durability_data.durability = durability
- end
- extenditems.push extend if BMSP::ItemSegmentSystem::NEW_SEGMENT
- gain_extend(container, extend.item, extend) unless BMSP::ItemSegmentSystem::NEW_SEGMENT
- end
- return unless BMSP::ItemSegmentSystem::NEW_SEGMENT
- segments = []
- extenditems.each do |extend|
- if segments.empty?
- segments.push(BMSP::ItemSegment.new(extend))
- elsif !segments.last.push(extend)
- segments.push(BMSP::ItemSegment.new(extend))
- end
- end
- segments.each do |segment|
- gain_segment(container, item, segment)
- end
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # ● 戦闘行動の実行
- #--------------------------------------------------------------------------
- alias bmsp_equipmentdurability_execute_action execute_action
- def execute_action
- # 装備破壊メッセージの初期化
- BMSP::EquipmentDurability.init_message_buffer
- bmsp_equipmentdurability_execute_action
- # 装備破壊メッセージの表示
- @log_window.display_equipment_broken
- end
- end
- #==============================================================================
- # ■ Window_BattleLog
- #==============================================================================
- class Window_BattleLog < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 装備破壊の表示
- #--------------------------------------------------------------------------
- def display_equipment_broken
- while message = BMSP::EquipmentDurability::get_message
- add_text(message)
- wait
- end
- end
- end
- #==============================================================================
- # ■ BMSP::Window_RepairGold
- #------------------------------------------------------------------------------
- # 装備修理画面で所持金を表示するウィンドウです。
- #==============================================================================
- class BMSP::Window_RepairGold < Window_Gold
- #--------------------------------------------------------------------------
- # ● ウィンドウ幅の取得
- #--------------------------------------------------------------------------
- def window_width
- return 272
- end
- #--------------------------------------------------------------------------
- # ● 所持金の取得
- #--------------------------------------------------------------------------
- def value
- if BMSP::Scene_RepairEquipment.point # ポイント
- $game_variables[BMSP::Scene_RepairEquipment.point]
- else # お金
- $game_party.gold
- end
- end
- #--------------------------------------------------------------------------
- # ● 通貨単位の取得
- #--------------------------------------------------------------------------
- def currency_unit
- if BMSP::Scene_RepairEquipment.point # ポイント
- unit = BMSP::EquipmentDurability::POINT_UNIT[BMSP::Scene_RepairEquipment.point]
- unit ? unit : BMSP::EquipmentDurability::POINT_UNIT[:default]
- else # お金
- Vocab::currency_unit
- end
- end
- end
- #==============================================================================
- # ■ BMSP::Window_RepairStatus
- #------------------------------------------------------------------------------
- # 装備強化画面で、アイテムの能力値変化を表示するウィンドウです。
- #==============================================================================
- class BMSP::Window_RepairStatus < Window_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(x, y, height)
- super(x, y, window_width, height)
- @item = nil
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウ幅の取得
- #--------------------------------------------------------------------------
- def window_width
- return 272
- end
- #--------------------------------------------------------------------------
- # ● アイテムの設定
- #--------------------------------------------------------------------------
- def item=(item)
- return if @item == item
- @item = item
- refresh
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- return if @item.is_a?(Game_Actor)
- return if @item.is_a?(String)
- return if @item.nil? || !@item.extend?
- draws = [:durability, :mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk]
- draws.push :success if BMSP::EquipmentDurability::DISPLAY_SUCCESS
- draws.push :penalty if BMSP::EquipmentDurability::DISPLAY_PENALTY
- draws.each_with_index do |param, i|
- draw_item(0, i * line_height, param)
- end
- end
- #--------------------------------------------------------------------------
- # ● 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(x, y, param)
- draw_param_name(x + 4, y, param)
- draw_current_param(x + 114, y, param)
- return if param == :success || param == :penalty
- draw_right_arrow(x + 168, y)
- draw_new_param(x + 192, y, param) if @item.durability_data.repairable?
- end
- #--------------------------------------------------------------------------
- # ● 能力値の名前を描画
- #--------------------------------------------------------------------------
- def draw_param_name(x, y, param)
- change_color(system_color)
- label =
- case param
- when :durability then "耐久度"
- when :mhp then Vocab::param(0)
- when :mmp then Vocab::param(1)
- when :atk then Vocab::param(2)
- when :def then Vocab::param(3)
- when :mat then Vocab::param(4)
- when :mdf then Vocab::param(5)
- when :agi then Vocab::param(6)
- when :luk then Vocab::param(7)
- when :success then "成功率"
- when :penalty then "ペナルティ"
- end
- draw_text(x, y, 100, line_height, label)
- end
- #--------------------------------------------------------------------------
- # ● 現在の能力値を描画
- #--------------------------------------------------------------------------
- def draw_current_param(x, y, param)
- durability_data = @item.durability_data
- change_color(normal_color)
- durability = durability_data.durability
- case param
- when :durability then draw_text(x, y, 48, line_height, durability.to_s, 2)
- when :mhp then draw_text(x, y, 48, line_height, durability_data.params(@item)[0], 2)
- when :mmp then draw_text(x, y, 48, line_height, durability_data.params(@item)[1], 2)
- when :atk then draw_text(x, y, 48, line_height, durability_data.params(@item)[2], 2)
- when :def then draw_text(x, y, 48, line_height, durability_data.params(@item)[3], 2)
- when :mat then draw_text(x, y, 48, line_height, durability_data.params(@item)[4], 2)
- when :mdf then draw_text(x, y, 48, line_height, durability_data.params(@item)[5], 2)
- when :agi then draw_text(x, y, 48, line_height, durability_data.params(@item)[6], 2)
- when :luk then draw_text(x, y, 48, line_height, durability_data.params(@item)[7], 2)
- when :success then
- success = durability_data.success(@item)
- draw_text(x, y, 126, line_height, success, 2)
- when :penalty then
- case pena = durability_data.penalty
- when :break
- penalty = "破壊"
- when :none
- penalty = "なし"
- else
- penalty = "耐久度が#{pena}に"
- end
- # penalty = "" if forgedata.maxlevel?
- draw_text(x, y, 126, line_height, penalty, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 右向き矢印を描画
- #--------------------------------------------------------------------------
- def draw_right_arrow(x, y)
- change_color(system_color)
- draw_text(x, y, 22, line_height, "→", 1)
- end
- #--------------------------------------------------------------------------
- # ● 装備修理後の能力値を描画
- #--------------------------------------------------------------------------
- def draw_new_param(x, y, param)
- durability_data = @item.durability_data
- repair_data = durability_data.dup
- repair_data.repair
- new_value, old_value =
- case param
- when :durability
- [repair_data.durability,durability_data.durability]
- when :mhp
- [repair_data.params(@item)[0], durability_data.params(@item)[0]]
- when :mmp
- [repair_data.params(@item)[1], durability_data.params(@item)[1]]
- when :atk
- [repair_data.params(@item)[2], durability_data.params(@item)[2]]
- when :def
- [repair_data.params(@item)[3], durability_data.params(@item)[3]]
- when :mat
- [repair_data.params(@item)[4], durability_data.params(@item)[4]]
- when :mdf
- [repair_data.params(@item)[5], durability_data.params(@item)[5]]
- when :agi
- [repair_data.params(@item)[6], durability_data.params(@item)[6]]
- when :luk
- [repair_data.params(@item)[7], durability_data.params(@item)[7]]
- else
- return
- end
- change_color(param_change_color(new_value - old_value))
- draw_text(x, y, 48, line_height, new_value, 2)
- end
- end
- #==============================================================================
- # ■ BMSP::Window_RepairCommand
- #==============================================================================
- class BMSP::Window_RepairCommand < Window_HorzCommand
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(x, y, width)
- @window_width = width
- super(x, y)
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウ幅の取得
- #--------------------------------------------------------------------------
- def window_width
- @window_width
- end
- #--------------------------------------------------------------------------
- # ● 桁数の取得
- #--------------------------------------------------------------------------
- def col_max
- return 2
- end
- #--------------------------------------------------------------------------
- # ● コマンドリストの作成
- #--------------------------------------------------------------------------
- def make_command_list
- enable = @item_window ? !@item_window.repairable_equips.empty? : false
- add_command("個別修理", :select)
- add_command("一括修理", :all, enable)
- end
- #--------------------------------------------------------------------------
- # ● アイテムウインドウの設定
- #--------------------------------------------------------------------------
- def item_window=(item_window)
- @item_window = item_window
- end
- end
- #==============================================================================
- # ■ BMSP::Window_RepairList
- #------------------------------------------------------------------------------
- # 装備修理画面で、装備アイテムの一覧を表示するウィンドウです。
- #==============================================================================
- class BMSP::Window_RepairList < Window_ItemList
- #--------------------------------------------------------------------------
- # ● ステータスウインドウの設定
- #--------------------------------------------------------------------------
- def status_window=(window)
- @status_window = window
- end
- #--------------------------------------------------------------------------
- # ● 桁数の取得
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # ● アイテムリストの作成
- #--------------------------------------------------------------------------
- def make_item_list
- @data = []
- @equip_data = {}
- $game_party.members.each do |actor|
- item_actor = actor.dup
- def item_actor.description
- "#{self.name}の装備品です。"
- end
- @data.push item_actor
- equips = actor.equips
- equips.each.with_index do |equip, slot_id|
- @equip_data[equip] = [actor, slot_id]
- end
- @data.concat equips.compact
- end
- label = "所持装備アイテム"
- def label.description
- "所持している装備品です。"
- end
- @data.push label
- @data.concat $game_party.equip_items
- end
- #--------------------------------------------------------------------------
- # ● アイテムを許可状態で表示するかどうか
- #--------------------------------------------------------------------------
- def enable?(item)
- return false if item.nil?
- return false if item.is_a?(Game_Actor)
- return false if item.is_a?(String)
- return true if item.segment?
- return false unless item.extend?
- return false unless item.has_durability?
- item.durability_data.repairable?
- end
- #--------------------------------------------------------------------------
- # ● 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- case item
- when Game_Actor
- draw_item_actor_name(index, item)
- when String
- draw_item_label(index, item)
- else
- super
- end
- end
- #--------------------------------------------------------------------------
- # ● アクター名の描画
- #--------------------------------------------------------------------------
- def draw_item_actor_name(index, actor)
- rect = item_rect(index)
- change_color(system_color)
- draw_text(rect, actor.name, 1)
- end
- #--------------------------------------------------------------------------
- # ● ラベルの描画
- #--------------------------------------------------------------------------
- def draw_item_label(index, label)
- rect = item_rect(index)
- change_color(system_color)
- draw_text(rect, label, 1)
- end
- #--------------------------------------------------------------------------
- # ● アイテムの個数を描画
- #--------------------------------------------------------------------------
- def draw_item_number(rect, item)
- if item.segment?
- number = @data[@data.index(item)].extend.size
- draw_text(rect, sprintf(":%2d", number), 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- @status_window.item = item if self.active && @status_window
- end
- #--------------------------------------------------------------------------
- # ● アイテムの消失
- #--------------------------------------------------------------------------
- def lose_item(item)
- return unless item
- return if item.is_a?(Game_Actor)
- return if item.is_a?(String)
- actor, slot_id = @equip_data[item]
- if actor # 装備の強制解除(消失)
- actor.force_change_equip(slot_id, nil)
- else # アイテムの消失
- $game_party.lose_item(item, 1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 修理可能な装備一覧の取得
- #--------------------------------------------------------------------------
- def repairable_equips
- @data.select { |item|
- enable?(item)
- }.map{ |item|
- next item unless item.segment?
- item.extend.select { |item|
- enable?(item)
- }
- }.flatten
- end
- end
- #==============================================================================
- # ■ BMSP::Window_RepairExtendItem
- #------------------------------------------------------------------------------
- # 装備修理画面で,セグメントの中身を表示するウインドウです.
- #==============================================================================
- class BMSP::Window_RepairExtendItem < BMSP::Window_ExtendItem
- #--------------------------------------------------------------------------
- # ● ステータスウインドウの設定
- #--------------------------------------------------------------------------
- def status_window=(window)
- @status_window = window
- end
- #--------------------------------------------------------------------------
- # ● アイテムを許可状態で表示するかどうか
- #--------------------------------------------------------------------------
- def enable?(item)
- return false if item.nil?
- return false if item.is_a?(Game_Actor)
- return false if item.is_a?(String)
- return false unless item.extend?
- return false unless item.has_durability?
- item.durability_data.repairable?
- end
- #--------------------------------------------------------------------------
- # ● アイテムをリストに含めるかどうか
- #--------------------------------------------------------------------------
- def include?(item)
- return false if item.nil?
- true
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- @status_window.item = item if self.active && @status_window
- end
- end
- #==============================================================================
- # ■ BMSP::Window_RepairDecide
- #------------------------------------------------------------------------------
- # 装備修理画面で,修理の実行の最終確認のウインドウです.
- #==============================================================================
- class BMSP::Window_RepairDecide < Window_Command
- #--------------------------------------------------------------------------
- # ● 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :just_mode # お金が足りなくても修理を選択可能
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super(0,0)
- self.openness = 0
- self.deactivate
- @just_mode = false
- end
- #--------------------------------------------------------------------------
- # ● 標準パディングサイズの取得
- #--------------------------------------------------------------------------
- def standard_padding
- return 18
- end
- #--------------------------------------------------------------------------
- # ● コマンドリストの作成
- #--------------------------------------------------------------------------
- def make_command_list
- # 金額が足りるか
- price_list = self.repair_price_list
- price = price_list.inject(0, :+)
- if BMSP::Scene_RepairEquipment.point # ポイント
- enable = $game_variables[BMSP::Scene_RepairEquipment.point] >= price
- else # お金
- enable = $game_party.gold >= price
- end
- if !enable && @just_mode
- # ひとつでも修理できるものがあれば修理を許可
- if BMSP::Scene_RepairEquipment.point # ポイント
- enable = price_list.any? {|price|
- $game_variables[BMSP::Scene_RepairEquipment.point] >= price
- }
- else # お金
- enable = price_list.any? {|price|
- $game_party.gold >= price
- }
- end
- end
- add_command("修理する", :repair, enable)
- add_command("やめる", :back)
- end
- #--------------------------------------------------------------------------
- # ● 通貨単位の取得
- #--------------------------------------------------------------------------
- def currency_unit
- if BMSP::Scene_RepairEquipment.point # ポイント
- unit = BMSP::EquipmentDurability::POINT_UNIT[BMSP::Scene_RepairEquipment.point]
- unit ? unit : BMSP::EquipmentDurability::POINT_UNIT[:default]
- else # お金
- Vocab::currency_unit
- end
- end
- #--------------------------------------------------------------------------
- # ● 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(index)
- change_color(normal_color, command_enabled?(index))
- draw_text(item_rect_for_text(index), command_name(index), 0)
- if index == 0 && @item # 金額の表示
- price_list = self.repair_price_list
- price = price_list.inject(0, :+)
- return if price == 0
- width = contents.width - 4
- cx = text_size(currency_unit).width
- draw_text(0, 0, width - cx - 2, line_height, price, 2)
- change_color(system_color)
- draw_text(0, 0, width, line_height, currency_unit, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● アイテム一覧の設定
- #--------------------------------------------------------------------------
- def item=(item)
- return if @item == item
- @item = item.is_a?(Array) ? item : [item]
- set if @item
- end
- #--------------------------------------------------------------------------
- # ● アイテム一覧の取得
- #--------------------------------------------------------------------------
- def item
- return @item
- end
- #--------------------------------------------------------------------------
- # ● 修理金額一覧の取得
- #--------------------------------------------------------------------------
- def repair_price_list
- if @item
- if BMSP::Scene_RepairEquipment.point # ポイント
- @item.map { |item|
- item.durability_data.repair_point(item)
- }
- else # お金
- @item.map { |item|
- item.durability_data.repair_price(item)
- }
- end
- else
- []
- end
- end
- #--------------------------------------------------------------------------
- # ● 呼び出し元の設定
- #--------------------------------------------------------------------------
- def last_window=(window)
- return if @last_window == window
- @last_window = window
- end
- #--------------------------------------------------------------------------
- # ● 呼び出し元の取得
- #--------------------------------------------------------------------------
- def last_window
- return @last_window
- end
- #--------------------------------------------------------------------------
- # ● ウインドウのセット
- #--------------------------------------------------------------------------
- def set
- # ウインドウの幅を描画文字幅から算出
- # コマンドの文字幅
- command_width = @list.size.times.map{|i|
- text_size(command_name(i)).width
- }
- command_width[0] += 24 # パディング
- unit_width = contents.text_size(currency_unit).width
- price_list = self.repair_price_list
- price = price_list.inject(0, :+)
- if price > 0
- price_width = contents.text_size(price).width
- command_width[0] += price_width + 2 + unit_width # 金額
- command_width[0] += 4 # 右余白
- end
- self.width = command_width.max + standard_padding * 2
- self.height = fitting_height(@list.size)
- self.x = (Graphics.width - self.width) / 2
- self.y = (Graphics.height - self.height) / 2
- # リフレッシュ
- refresh
- self.select(command_enabled?(0) ? 0 : 1)
- end
- end
- #==============================================================================
- # ■ BMSP::Window_RepairResult
- #------------------------------------------------------------------------------
- # 装備修理画面で、修理結果を表示するウインドウです.
- #==============================================================================
- class BMSP::Window_RepairResult < Window_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- y = (Graphics.height - window_height) / 2
- super(0, y, 48, window_height)
- self.openness = 0
- self.deactivate
- end
- #--------------------------------------------------------------------------
- # ● ウインドウの高さ
- #--------------------------------------------------------------------------
- def window_height
- self.fitting_height(3)
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh(data)
- contents.clear
- change_color(system_color)
- width = contents.width
- y = 0
- draw_text(0,y,width,line_height,data[:label],1)
- y += line_height
- x = (contents.width - (text_size(data[:item].name).width + 24)) / 2
- draw_item_name(data[:item], x, y, !data[:lost], width-24)
- change_color(data[:penalty] ? power_down_color : power_up_color)
- y += line_height
- draw_text(0,y,width,line_height,data[:message],1)
- end
- #--------------------------------------------------------------------------
- # ● ウインドウのセット
- #--------------------------------------------------------------------------
- def set(item, old_dur, penalty = nil)
- data = {}
- # 描画内容の設定
- data[:label] = "修理結果"
- data[:item] = item
- data[:penalty] = penalty
- data[:lost] = true if penalty == :break
- if penalty.nil?
- data[:message] = "耐久度が#{item.durability_data.durability}になった!"
- elsif penalty == :none
- data[:message] = "修理に失敗した"
- elsif penalty == :break
- data[:message] = "壊れてしまった"
- else
- data[:message] = "耐久度が#{item.durability_data.durability}になってしまった!"
- end
- # ウインドウ幅の設定
- line_widths = []
- line_widths.push(text_size(data[:label]).width + 24)
- line_widths.push(24 + text_size(item.name).width + 24)
- line_widths.push(text_size(data[:message]).width + 24)
- self.width = line_widths.max + standard_padding * 2
- self.create_contents
- # 位置の設定
- self.x = (Graphics.width - self.width) / 2
- # 内容の描画
- refresh(data)
- end
- end
- #==============================================================================
- # ■ BMSP::Scene_RepairEquipment
- #------------------------------------------------------------------------------
- # 装備の修理を行う画面です.
- #==============================================================================
- class BMSP::Scene_RepairEquipment < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 費用の設定
- #--------------------------------------------------------------------------
- def self.point; @@point; end
- def self.point=(point); @@point = point; end
- #--------------------------------------------------------------------------
- # ● 開始処理
- #--------------------------------------------------------------------------
- def start
- super
- create_help_window
- create_gold_window
- create_status_window
- create_command_windo
- create_item_window
- create_extend_window
- create_repair_window
- create_result_window
- @command_window.item_window = @item_window
- @command_window.refresh
- @command_window.activate
- @buffer = []
- end
- #--------------------------------------------------------------------------
- # ● ゴールドウィンドウの作成
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = BMSP::Window_RepairGold.new
- @gold_window.x = 272
- @gold_window.y = Graphics.height - @gold_window.height
- end
- #--------------------------------------------------------------------------
- # ● ステータスウィンドウの作成
- #--------------------------------------------------------------------------
- def create_status_window
- wx = Graphics.width - 272
- wy = @help_window.height
- wh = Graphics.height - @help_window.height - @gold_window.height
- @status_window = BMSP::Window_RepairStatus.new(wx, wy, wh)
- @status_window.viewport = @viewport
- end
- #--------------------------------------------------------------------------
- # ● コマンドウィンドウの作成
- #--------------------------------------------------------------------------
- def create_command_windo
- wy = @help_window.height
- ww = Graphics.width - @status_window.width
- @command_window = BMSP::Window_RepairCommand.new(0, wy, ww)
- @command_window.help_window = @help_window
- @command_window.set_handler(:select, method(:on_command_select))
- @command_window.set_handler(:all, method(:on_command_all))
- @command_window.set_handler(:cancel, method(:on_command_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 拡張アイテムウィンドウの作成
- #--------------------------------------------------------------------------
- def create_extend_window
- @extend_window = BMSP::Window_RepairExtendItem.new
- @extend_window.viewport = @viewport
- @extend_window.status_window = @status_window
- @extend_window.item_window = @item_window
- @extend_window.help_window = @help_window
- @extend_window.set_handler(:ok, method(:on_extend_ok))
- @extend_window.set_handler(:cancel, method(:on_extend_cancel))
- @extend_window.init
- end
- #--------------------------------------------------------------------------
- # ● アイテムウィンドウの作成
- #--------------------------------------------------------------------------
- def create_item_window
- wy = @help_window.height + @command_window.height
- ww = Graphics.width - @status_window.width
- wh = Graphics.height - @help_window.height - @command_window.height
- @item_window = BMSP::Window_RepairList.new(0, wy, ww, wh)
- @item_window.viewport = @viewport
- @item_window.status_window = @status_window
- @item_window.help_window = @help_window
- @item_window.set_handler(:ok, method(:on_item_ok))
- @item_window.set_handler(:cancel, method(:on_item_cancel))
- @item_window.refresh
- end
- #--------------------------------------------------------------------------
- # ● 確認ウィンドウの作成
- #--------------------------------------------------------------------------
- def create_repair_window
- @repair_window = BMSP::Window_RepairDecide.new
- @repair_window.z = @viewport.z
- @repair_window.set_handler(:repair, method(:on_repair))
- @repair_window.set_handler(:cancel, method(:on_repair_cancel))
- @repair_window.set_handler(:back, method(:on_repair_back))
- end
- #--------------------------------------------------------------------------
- # ● 結果ウィンドウの作成
- #--------------------------------------------------------------------------
- def create_result_window
- @result_window = BMSP::Window_RepairResult.new
- @result_window.z = @viewport.z
- end
- #--------------------------------------------------------------------------
- # ● 選択の開始
- #--------------------------------------------------------------------------
- def start_select
- activate_item_window(@item_window.index == -1 ? true : false)
- @status_window.item = @item_window.item
- end
- #--------------------------------------------------------------------------
- # ● 修理待ち状態か?
- #--------------------------------------------------------------------------
- def wait_for_repairing?
- !@command_window.active and
- !@item_window.active and
- !@extend_window.active and
- !@repair_window.active and @repair_window.openness == 0
- !@result_window.active and @result_window.openness == 0
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- # 結果ウインドウを閉じる動作
- if @result_window.active && Input.repeat?(:C)
- @result_window.close.deactivate
- repair_end if @buffer.empty?
- end
- if !@buffer.empty? && wait_for_repairing?
- # バッファにアイテムがあれば修理を実行する
- if !execute_repair(@buffer.shift) && @buffer.empty?
- # アイテムを修理せず終わった(お金が足りない)
- repair_end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 修理フェイズの終了
- #--------------------------------------------------------------------------
- def repair_end
- case @repair_window.last_window
- when @item_window
- activate_item_window
- when @extend_window
- activate_extend_window
- if @extend_window.item_max == 0
- # 拡張ウインドウが空ならウインドウを閉じる
- @extend_window.close.deactivate
- activate_item_window
- else
- @item_window.refresh
- end
- when @command_window
- refresh_item_window
- @command_window.activate
- end
- @command_window.refresh # コマンドウインドウのリフレッシュ
- end
- #--------------------------------------------------------------------------
- # ● コマンド[個別修理]
- #--------------------------------------------------------------------------
- def on_command_select
- @command_window.deactivate
- start_select
- end
- #--------------------------------------------------------------------------
- # ● コマンド[一括修理]
- #--------------------------------------------------------------------------
- def on_command_all
- @repair_window.just_mode = true
- @repair_window.item = @item_window.repairable_equips
- @repair_window.last_window = @command_window
- @repair_window.open.activate
- @command_window.deactivate
- end
- #--------------------------------------------------------------------------
- # ● コマンド[キャンセル]
- #--------------------------------------------------------------------------
- def on_command_cancel
- return_scene
- end
- #--------------------------------------------------------------------------
- # ● アイテム[決定]
- #--------------------------------------------------------------------------
- def on_item_ok
- if @item_window.item.extend? # 拡張アイテム
- @repair_window.just_mode = false
- @repair_window.item = @item_window.item
- @repair_window.last_window = @item_window
- @repair_window.open.activate
- else # セグメント
- activate_extend_window(true)
- end
- end
- #--------------------------------------------------------------------------
- # ● アイテム[キャンセル]
- #--------------------------------------------------------------------------
- def on_item_cancel
- @item_window.deactivate
- @command_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 拡張アイテム[決定]
- #--------------------------------------------------------------------------
- def on_extend_ok
- @repair_window.just_mode = false
- @repair_window.item = @extend_window.item
- @repair_window.last_window = @extend_window
- @repair_window.open.activate
- end
- #--------------------------------------------------------------------------
- # ● 拡張アイテム[キャンセル]
- #--------------------------------------------------------------------------
- def on_extend_cancel
- @extend_window.close.deactivate
- activate_item_window
- end
- #--------------------------------------------------------------------------
- # ● 確認[修理]
- #--------------------------------------------------------------------------
- def on_repair
- @buffer.concat @repair_window.item
- @repair_window.openness = 0
- @repair_window.close.deactivate
- end
- #--------------------------------------------------------------------------
- # ● 確認[やめる]
- #--------------------------------------------------------------------------
- def on_repair_back
- on_repair_cancel
- end
- #--------------------------------------------------------------------------
- # ● 確認[キャンセル]
- #--------------------------------------------------------------------------
- def on_repair_cancel
- @repair_window.close.deactivate
- case @repair_window.last_window
- when @item_window
- activate_item_window
- when @extend_window
- activate_extend_window
- when @command_window
- @command_window.activate
- end
- end
- #--------------------------------------------------------------------------
- # ● 修理の実行
- #--------------------------------------------------------------------------
- def execute_repair(item)
- # 所持金の減少
- if @@point # ポイント
- return false if $game_variables[@@point] < item.durability_data.repair_point(item)
- $game_variables[@@point] -= item.durability_data.repair_point(item)
- $game_variables[@@point] = 0 if $game_variables[@@point] < 0
- else # お金
- return false if $game_party.gold < item.durability_data.repair_point(item)
- $game_party.lose_gold(item.durability_data.repair_price(item))
- end
- Sound.play_repair_equipment
- @gold_window.refresh
- # 強化実行
- old_dur,penalty = item.durability_data.execute_repair(item)
- penalty ? Sound.play_forge_equipment_miss : Sound.play_forge_equipment_success
- if penalty == :break # 消失
- @item_window.lose_item(item)
- end
- # 結果の表示
- @result_window.set(item,old_dur,penalty)
- @result_window.openness = 255
- @result_window.open.activate
- true
- end
- #--------------------------------------------------------------------------
- # ● アイテムウインドウのアクティブ化
- #--------------------------------------------------------------------------
- def activate_item_window(init_index = false)
- refresh_item_window(init_index)
- @item_window.activate
- end
- #--------------------------------------------------------------------------
- # ● アイテムウインドウのリフレッシュ
- #--------------------------------------------------------------------------
- def refresh_item_window(init_index = false)
- @item_window.refresh
- # インデックスの修正
- if @item_window.index >= @item_window.item_max
- if @item_window.item_max > 0
- @item_window.select(@item_window.item_max - 1)
- else
- @item_window.select(0)
- end
- end
- @item_window.index = 0 if init_index
- end
- #--------------------------------------------------------------------------
- # ● 拡張アイテムウインドウのアクティブ化
- #--------------------------------------------------------------------------
- def activate_extend_window(init_index = false)
- # セグメントの設定
- @extend_window.segment = @item_window.item.extend
- # 表示位置と高さの変更
- @extend_window.set
-
- @extend_window.refresh
- @extend_window.open.activate
- @extend_window.index = 0 if init_index
- end
- end
- #==============================================================================
- # ■ Window_Base
- #==============================================================================
- class Window_Base < Window
- if BMSP::EquipmentDurability::BROKENCOLOR
- #--------------------------------------------------------------------------
- # ● アイテム名の描画(再定義)
- # enabled : 有効フラグ。false のとき半透明で描画
- #--------------------------------------------------------------------------
- def draw_item_name(item, x, y, enabled = true, width = 172)
- return unless item
- draw_icon(item.icon_index, x, y, enabled)
- if item.has_durability? && item.durability_data.durability == 0
- change_color(knockout_color, enabled)
- else
- change_color(normal_color, enabled)
- end
- draw_text(x + 24, y, width, line_height, item.name)
- end
- end
- #--------------------------------------------------------------------------
- # ● アイテム名の描画
- # enabled : 有効フラグ。false のとき半透明で描画
- #--------------------------------------------------------------------------
- alias bmsp_equipmentdurability_draw_item_name draw_item_name
- def draw_item_name(item, x, y, enabled = true, width = 172)
- bmsp_equipmentdurability_draw_item_name(item, x, y, enabled, width)
- return unless item
- return unless item.has_durability?
- return unless BMSP::EquipmentDurability::DRAW_GAUGE
- # 装備耐久度ゲージの描画
- max = item.extend.durability_data.gauge_max_durability
- dur = item.extend.durability_data.durability
- if dur > max
- rate = 1.0
- color = text_color(BMSP::EquipmentDurability::GAUGE_OVERCOLOR)
- elsif dur == max
- rate = 1.0
- color = text_color(BMSP::EquipmentDurability::GAUGE_MAXCOLOR)
- else
- rate = dur.to_f / max
- color = text_color(BMSP::EquipmentDurability::GAUGE_COLOR)
- end
- edgecolor = BMSP::EquipmentDurability::GAUGE_EDGECOLOR
- edgecolor = edgecolor.nil? ? nil : text_color(edgecolor)
- bgcolor = BMSP::EquipmentDurability::GAUGE_BACKCOLOR
- bgcolor = bgcolor.nil? ? nil : text_color(bgcolor)
- unless enabled
- color.alpha = translucent_alpha
- bgcolor.alpha = translucent_alpha unless bgcolor.nil?
- end
- bmsp_equipmentdurability_draw_durability_gauge(x, y, rate, color, edgecolor, bgcolor)
- end
- #--------------------------------------------------------------------------
- # ● 装備耐久度ゲージの描画
- #--------------------------------------------------------------------------
- def bmsp_equipmentdurability_draw_durability_gauge(x, y, rate, color, edgecolor, bgcolor)
- gauge_width = edgecolor ? 18 : 20
- gauge_x = x + 2
- gauge_y = y + (edgecolor ? 19 : 20)
- width = rate * gauge_width
- width = 1 if rate > 0 && width == 0
- contents.fill_rect(gauge_x-1, gauge_y-1, gauge_width + 2, 4, edgecolor) if edgecolor
- contents.fill_rect(gauge_x, gauge_y, gauge_width, 2, bgcolor) if bgcolor
- contents.fill_rect(gauge_x, gauge_y, width, 2, color)
- end
- end
- #==============================================================================
- # ■ Window_ShopBuy
- #==============================================================================
- class Window_ShopBuy < Window_Selectable
- #--------------------------------------------------------------------------
- # ● アイテムの取得
- #--------------------------------------------------------------------------
- alias bmsp_equipmentdurability_item item
- def item
- item = bmsp_equipmentdurability_item
- return item unless item.extended?
- item.extend.original
- end
- #--------------------------------------------------------------------------
- # ● アイテムリストの作成
- #--------------------------------------------------------------------------
- alias bmsp_equipmentdurability_make_item_list make_item_list
- def make_item_list
- bmsp_equipmentdurability_make_item_list
- map_proc = proc { |item, type|
- extend = BMSP::ItemExtend.new(item)
- extended_item = extend.item
- goods = @shop_goods.find{ |goods|
- goods[0] == type && goods[1] == item.id
- }
- @price[extend] = goods[2] == 0 ? extend.item.price : goods[3]
- extend.item
- }
- @data.map! do |item|
- case item
- when RPG::Weapon
- map_proc.call(item, 1)
- when RPG::Armor
- map_proc.call(item, 2)
- else
- item
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 商品の値段を取得
- #--------------------------------------------------------------------------
- alias bmsp_equipmentdurability_price price
- def price(item)
- price = bmsp_equipmentdurability_price(item)
- return price if price
- @price[item.extend]
- end
- #--------------------------------------------------------------------------
- # ● 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- rect = item_rect(index)
- draw_item_name(item, rect.x, rect.y, enable?(item))
- rect.width -= 4
- draw_text(rect, price(item), 2)
- end
- end
-
复制代码 |
|