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

Project1

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

[已经过期] 求人修复下这个脚本。

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
641 小时
注册时间
2015-7-29
帖子
211
跳转到指定楼层
1
发表于 2015-10-19 00:28:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x


  这个日站挖来的脚本,现在里面很多功能不能用,比如耐久度,装备破坏,武器攻击次数为0时也能继续攻击等,求人修复下,万分感谢





这4个脚本是连起来用的。也没有少复制,全部就是这样子。。日站嘛  联系不到作者  所以拜托天朝的大大们了






RUBY 代码复制
  1. #==============================================================================
  2. #    ☆VXAce RGSS3 「個別装備アイテム:設定」☆
  3. #      EnDlEss DREamER
  4. #     URL:[url]http://mitsu-evo.6.ql.bz/[/url]
  5. #     製作者 mitsu-evo
  6. #     Last:2014/4/22
  7. #   武器防具1個ずつに耐久度や弾数・改造度などを設定する。
  8. #     ▼ 装備拡張:武器拡張追加よりも下で「▼ 素材」に近い位置に挿入。
  9. #==============================================================================
  10.  
  11. $ed_rgss3 = {} if $ed_rgss3 == nil
  12. $ed_rgss3["ed_weapon_count"] = true
  13. =begin
  14.  
  15.  
  16.  
  17. ☆☆☆☆☆☆ 機能説明 ☆☆☆☆☆☆
  18.  
  19.  
  20.  
  21.    ★ 装備のメモ欄の使い方 
  22.     <耐久力 1000>   装備の耐久力を設定する。
  23.     <改造レベル 10>  装備改造を指定段階まで行える
  24.     <回数 10>     武器限定で使用回数を設定する
  25.     
  26.     無設定の場合は「装備改造システム」の CUSTOM_LEVEL 設定値まで改造可能
  27.     耐久力と武器回数は無制限に設定されます。
  28.    
  29.    ★ アイテムのメモ欄の使い方 ★ 
  30.     <武器回復:武器ID,装備ヶ所,回復数>  指定箇所の武器の回数を回復する。
  31.     <修理>              指定キャラの装備全てを修復する。
  32.    
  33.  
  34.   ● 武器回数システム
  35.  
  36.   武器のメモ欄に
  37.   <回数 10> 等の記述を入れると設定した数値分だけしか
  38.     その武器で攻撃できなくなります。
  39.     無指定なら回数は指定されません。
  40.     
  41.     二刀流の場合は「両手武器のどちらか」が「ゼロ」に
  42.     なったら攻撃が出来なくなります。
  43.     
  44.     武器の攻撃回数が0になるとその武器では攻撃出来ません。
  45.     でも、その武器が破棄されることもありません。
  46.     以下、イベントコマンドを使用して回復ショップ画面や
  47.     コマンドなどで回復することが可能です。
  48.     
  49.     アイテムのメモ欄に「<武器回復:武器ID,装備ヶ所,回復数>」を記入すると
  50.     対象アクターの装備中の武器回数を回復することができます。
  51.     回復数に「0」を指定すると全回復として処理されます。
  52.     なので「HP回復量」も設定値分指定して下さい。
  53.     なお「武器ID」に「-1」を指定すると武器IDに関係なく
  54.     装備ヶ所の武器を回復出来ます。
  55.     
  56.     ● 耐久力システム
  57.     
  58.     以前に「装備拡張:武器拡張追加」にあった耐久力システムをこちらに移しました。
  59.     メモ欄に「<耐久力 100>」などと入れるとその装備に耐久力が設定されます。
  60.     別途素材「装備破壊システム」の最新版を導入すると装備が破壊されるようになります。
  61.     
  62.     道具「ポーション」などのメモ欄に「<修理>」と入力するとそのアイテムを
  63.     味方に使用した場合、その味方の装備全ての耐久力が復活します。
  64.     
  65.     RGSS3版の新機能として、スキルとアイテムのメモ欄に修理や回数回復が使用でき
  66.     戦闘中のスキル・アイテムによる修理や回復が可能となりました。
  67.     
  68.     
  69.     他、イベントコマンドで耐久力を回復出来ます。
  70.     
  71.     ● 装備破壊システム
  72.     
  73.     攻撃で装備が破壊されます。
  74.     RGSS2版と違い、装備拡張:武器拡張追加導入時はエネミーに設定した
  75.     装備を破壊することが出来ます。
  76.     
  77.     RGSS3版の新機能として「装備破壊属性」の設定がある武器・スキル・アイテム
  78.     などは耐久力へ補正した設定値分のダメージを与えていくことができます。
  79.     
  80.     
  81.     「破損」「大破」の2種類の状態が存在し、破損装備は「黄色」
  82.     大破装備は「赤」で表示されます。
  83.     「大破」した装備は「能力がゼロ」になり装備としての能力が無くなります。
  84.     修復することで元に戻ります。
  85.     
  86.     イベントコマンドでも修復が可能です。
  87.     
  88.     ● 装備改造システム(スクリプト併用時)
  89.     
  90.     武器・防具のメモ欄に「<改造レベル 10>」など任意の値を入れると
  91.     その装備は指定の段階まで改造が可能になります。
  92.     無指定の場合は装備改造・鍛冶屋システムの設定レベルが上限となります。
  93.     この機能により個別に改造レベルの設定が可能となります。
  94.     装備改造項目全体に改造レベルが適用されます。
  95.     
  96.     
  97. ☆☆☆☆☆☆ イベントコマンド ☆☆☆☆☆☆
  98.  
  99.     「start_weapon_repair」
  100.     
  101.     武器回復ショップ画面を呼び出して「装備中」の武器を
  102.     お金を出して回復することが出来る。
  103.     
  104.     「start_armor_repair」
  105.     
  106.     装備回復ショップ画面を呼び出して「装備中」の「装備耐久力」を
  107.     お金を出して回復することが出来る。
  108.     
  109.     
  110.     「weapon_repair(actor_id)」
  111.     
  112.     actor_id   : アクターのID
  113.     
  114.     指定アクターの武器全部の回数を回復する
  115.     
  116.     「party_weapon_repair_all」
  117.     
  118.     パーティ全員の装備中の武器回数を全回復します。
  119.     
  120.     
  121.     「durability_repair(actor_id)」
  122.     
  123.     actor_id   : アクターのID
  124.     
  125.     指定アクターの全装備耐久力を回復します。
  126.     
  127.     「party_durability_repair_all」
  128.     
  129.     パーティ全員の装備耐久力を全回復します。
  130. =end
  131. #☆☆☆☆☆☆☆☆ 「メモ欄」の設定  ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
  132.  
  133.   # メモ欄取得用定数
  134.   WEAPON_ATK_COUNT = /<(?:count|回数)\s*(\d+)>/i
  135.   DURABILITY = /<(?:DURABILITY|耐久力)\s*(\-?\d+)>/i
  136.   INDIVIDUAL_CUSTOM_LEVEL = /<(?:CUSTOM|改造レベル)\s*(\d+)>/i
  137.  
  138. #☆☆☆☆☆☆☆☆ 「装備破壊」の設定  ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
  139.  
  140.   EQUIP_DAMAGE_SE = "Audio/SE/Thunder7"
  141.   EQUIP_BREAK_SE = "Audio/SE/Explosion7"
  142.   # ダメージ除算して耐久力減算に反映
  143.   BREAK_DAMAGE_REVISION = 2
  144.   # 全てのダメージで破壊処理実施するか?
  145.   SMOOTH_DAMAGE = false  
  146.   # SMOOTH_DAMAGEがfalseの時、指定%以下のダメージ処理を行わない。
  147.   BREAK_DAMAGE_PAR = 10
  148.   # 装備破壊属性設定
  149.   EQUIP_BREAK_ID = 19
  150.   # 装備破壊時の乗算補正(100ダメージ攻撃の3倍の耐久力へのダメージなど)
  151.   EQUIP_BREAK_REVISION = 3
  152.  
  153. #☆☆☆☆☆☆☆☆ 「個別武器」の設定  ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
  154.  
  155.   # 武器1の回復単価設定(G)
  156.   # 「0」以外に設定すると武器の回復単価はこの設定が反映される。
  157.   # 二刀流の場合は両手ともこの設定が反映される。
  158.   # 武器拡張追加導入時の「拡張武器」には一切反映されません。
  159.   WEAPON1_REPAIR_UNIT_PRICE = 0
  160.  
  161.   # 武器回数を1回回復の武器価格に対する単価(%)
  162.   # 上の設定が「0」の場合は「武器価格の%」を1回の単価として設定します。
  163.   # 拡張武器は全てこちらの設定が適用されます。
  164.   # 武器価格設定が「0」の場合は武器ステータスから自動算出し、この設定を適用します。
  165.   REPAIR_COUNT_PRICE = 5
  166.  
  167.   # 価格「0G」武器の価格算出方法
  168.   # 価格ゼロは「(攻撃+防御+精神+敏捷) × ZERO_PRICE_RATE」で
  169.   # 価格を一時的に算出し REPAIR_COUNT_PRICE による計算を行っている。
  170.   ZERO_PRICE_RATE = 100
  171.  
  172. #☆☆☆☆☆☆☆☆ 「耐久力」の設定  ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
  173.  
  174.   # 耐久力を全快するのに必要な金額(購入価格の設定%)
  175.   # 「破損」ならこの設定の半額が修復金額となります。
  176.   DURABILITY_REPAIR_PRICE = 50
  177.  
  178.  
  179. #==============================================================================
  180. #==============================================================================
  181. # ■ Vocab
  182. #------------------------------------------------------------------------------
  183. #  用語とメッセージを定義するモジュールです。定数でメッセージなどを直接定義す
  184. # るほか、グローバル変数 $data_system から用語データを取得します。
  185. #==============================================================================
  186.  
  187. module Vocab
  188.  
  189.   # 装備破壊時のメッセージ
  190.   Equip_Break_Text = "%sの %sが %sした!"
  191.   Equip_Repair_Text = "%sの 装備が修復された!"
  192.  
  193.   # メモ欄に表示する攻撃回数の文字表示
  194.   DESCRIPTION_ATK_CNT = "回数"
  195.  
  196.   # 回復単位
  197.   COUNT_UNIT = "回"
  198.  
  199.   # 回復するのに使われる言葉「xx[回][回復]するのにxxゴールドかかるが・・・」
  200.   REPAIR_UNIT = "回復"
  201.   #
  202.   # パーティ全員回復に表示する言葉
  203.   FULL_REPAIR_UNIT = "全員満タン"
  204.  
  205.   # 個別補給時に表示する文章「\x00 == 改行」
  206.  
  207.   # [武器名]を[回復回数][COUNT_UNIT設定文字][REPAIR_UNIT設定文字]すると
  208.   # [回復価格][金額単位]かかりますがよろしいですか?
  209.  
  210.   # という文章表示になる。
  211.   EQUIP_COUNT_TEXT = "%sを%s%s%sすると\x00%s%sかかりますがよろしいですか?"
  212.   # 満タン補給時に表示する文章
  213.  
  214.   # 全員を回復するのに[回復価格][金額単位]
  215.   # かかりますがよろしいですか?
  216.  
  217.   # という文章表示になる。
  218.   EQUIP_FULL_COUNT_TEXT = "全員を%sするのに%s%s\x00かかりますがよろしいですか?"
  219.   # 回復出来ない時の文章
  220.  
  221.   # これでは[REPAIR_UNIT設定文字]できませんね。
  222.  
  223.   # という文章表示になる。
  224.   NOT_EQUIP_REPAIR_TEXT = "これは%sできませんね。"
  225.  
  226.   # [REPAIR_UNIT設定文字]済みのようですね。と表示される。
  227.   FULL_WEAPON_COUNT = "%s済みのようですね。"
  228.  
  229.   NOT_GOLD = "お金が足りないみたいですね。"
  230.  
  231.   # 装備の破壊度表示
  232.   Equip_State      = "状態"   # 説明文に表示する「状態:正常」など
  233.   Equip_Green      = "正常"   # 破損度が正常の状態
  234.   Equip_Damage     = "破損"   # 破損度が耐久力の半分以下の場合
  235.   Equip_Break      = "大破"   # 破損度がゼロの場合
  236.   Equip_Durability = "耐久力" # 装備耐久力の表示文字
  237.  
  238. end
  239. module ED
  240. #==============================================================================
  241. # ■ Command
  242. #------------------------------------------------------------------------------
  243. #  イベントコマンド「スクリプト」で呼び出されるコマンドです。
  244. #==============================================================================
  245.   module Command
  246.     module_function
  247.     #--------------------------------------------------------------------------
  248.     # ● アクターの武器回復
  249.     #--------------------------------------------------------------------------
  250.     def weapon_repair(actor_id)
  251.       $game_actors[actor_id].weapons.compact.each{|item|item.weapon_repair}
  252.     end
  253.     #--------------------------------------------------------------------------
  254.     # ● パーティの武器全回復
  255.     #--------------------------------------------------------------------------
  256.     def party_weapon_repair_all
  257.       for actor in $game_party.members
  258.         weapon_repair(actor.id)
  259.       end
  260.     end
  261.     #--------------------------------------------------------------------------
  262.     # ● アクターの装備耐久力回復
  263.     #--------------------------------------------------------------------------
  264.     def durability_repair(actor_id)
  265.       $game_actors[actor_id].equips.compact.each{|item|item.durability_repair}
  266.     end
  267.     #--------------------------------------------------------------------------
  268.     # ● パーティの全装備耐久力全回復
  269.     #--------------------------------------------------------------------------
  270.     def party_durability_repair_all
  271.       for actor in $game_party.members
  272.         durability_repair(actor.id)
  273.       end
  274.     end  
  275.   end
  276. end
  277. class RPG::BaseItem
  278.   #--------------------------------------------------------------------------
  279.   # ○ 修理のキャッシュを作成(/<武器回復[::](0|-?\d+),(\d+)>/)
  280.   #--------------------------------------------------------------------------
  281.   def create_repair_cache
  282.     self.note.each_line { |line|
  283.       if line =~ /<修理>/
  284.         @repair = true
  285.         next if @repair == nil
  286.       end
  287.     }
  288.     @repair ||= false
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ○ 修理可能スキルやアイテムであるか?
  292.   #--------------------------------------------------------------------------
  293.   def repair?
  294.     create_repair_cache if @repair == nil
  295.     return @repair
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ○ 武器回数修理のキャッシュを作成
  299.   #--------------------------------------------------------------------------
  300.   def create_weapon_repair_cache
  301.     self.note.each_line { |line|
  302.       if line =~ /<武器回復[::](0|-?\d+),(\d+),(\d+)>/
  303.         @weapon_repair = true
  304.         next if @weapon_repair == nil
  305.       end
  306.     }
  307.     @weapon_repair ||= false
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ○ 修理可能スキルやアイテムであるか?
  311.   #--------------------------------------------------------------------------
  312.   def weapon_repair?
  313.     create_weapon_repair_cache if @weapon_repair == nil
  314.     return @weapon_repair
  315.   end
  316. end
  317.  
  318. class RPG::EquipItem < RPG::BaseItem
  319.   attr_accessor :ed_item_key                         # 武器格納ハッシュキー
  320.   attr_accessor :durability                          # 耐久力設定
  321.   attr_accessor :durability_max                      # 最大耐久力
  322.   #--------------------------------------------------------------------------
  323.   # ● オブジェクト初期化
  324.   #--------------------------------------------------------------------------
  325.   alias ed_weapon_count_a_initialize initialize unless $@
  326.   def initialize
  327.     ed_weapon_count_a_initialize
  328.     initialize_add_params
  329.     @ed_item_key = 0
  330.     save_state_value
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # ● データベース純正要素数のパラメータ
  334.   #--------------------------------------------------------------------------
  335.   def org_params; params[0, 7]; end
  336.   #--------------------------------------------------------------------------
  337.   # ● 元のパラメータ
  338.   #--------------------------------------------------------------------------
  339.   def save_state_value
  340.     @save_state_value ||= Marshal.load(Marshal.dump(@params)) # 元のパラメータ保存用
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 追加パラメーターの初期化
  344.   #--------------------------------------------------------------------------
  345.   def initialize_add_params
  346.     create_equip_durability_cache
  347.     @customize_level = Array.new(12) {0}
  348.     create_customize_level_max
  349.     @params[8] = @customize_level[8]              # 改造レベル
  350.     @params[9] = @customize_level_max          # 改造最大レベル
  351.     @params[10] = @durability                  # 耐久度
  352.     @params[11] = @durability_max = @durability   # 最大耐久度
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 装備の価格取得 [価格「0」]
  356.   #--------------------------------------------------------------------------
  357.   def equip_price_set
  358.     return @price if @price > 0
  359.     value = 0
  360.     8.times{|i| value+= @params[i]}
  361.     value *= value *= ZERO_PRICE_RATE
  362.     return value
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 装備武器回数の回復単価
  366.   #--------------------------------------------------------------------------
  367.   def weapon_atk_count_price
  368.     (equip_price_set * REPAIR_COUNT_PRICE) / 100
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ● 装備耐久力の回復単価
  372.   #--------------------------------------------------------------------------
  373.   def durability_price
  374.     value = equip_price_set * DURABILITY_REPAIR_PRICE / 100
  375.     # 破損なら回復価格の半分
  376.     value / 2 if equip_state[2] == Vocab::Equip_Damage
  377.     # 正常なら価格0
  378.     value = 0 if equip_state[2] == Vocab::Equip_Green
  379.     return value
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ○ 大破でパラメータを0にしたり元に戻したり
  383.   # value : true = ゼロに false = ロード
  384.   #--------------------------------------------------------------------------
  385.   def param_save_load(value = true)
  386.     save_state_value
  387.     if @save_state_value == [0,0,0,0,0,0,0,0] and @durability > 0
  388.       # 何らかの原因で大破状態が保持された場合は元の値に戻す。
  389.       temp = self.is_a?(RPG::Weapon) ? $data_weapons[@id] : $data_armors[@id]
  390.       @save_state_value = Marshal.load(Marshal.dump(@params))
  391.     end
  392.     if value
  393.       # ゼロにする
  394.       @params.each_index{|index|
  395.         @params[index] = 0 if @params[index] == 0 and index <= 7}
  396.     else
  397.       # もとに戻す  
  398.       @params.each_index{|index|
  399.         @params[index] = @save_state_value[index] if @params[index] == 0 and index <= 7}
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ○ 耐久力回復
  404.   #--------------------------------------------------------------------------
  405.   def durability_repair(number=0)
  406.     @durability = number == 0 ? @durability_max : number
  407.     equip_state
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ○ 武器回数回復
  411.   #--------------------------------------------------------------------------
  412.   def weapon_repair
  413.  
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ○ 耐久力のキャッシュを作成
  417.   #--------------------------------------------------------------------------
  418.   def create_equip_durability_cache
  419.     @durability = 9999999
  420.     @durability_max = @durability
  421.     self.note.each_line { |line|
  422.       if line =~ DURABILITY
  423.         # 装備種別
  424.         @durability_max = $1.to_i
  425.         @durability = @durability_max
  426.         next if @durability_max == nil
  427.       end
  428.     }
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # ○ 耐久力最大
  432.   #--------------------------------------------------------------------------
  433.   def durability_max
  434.     create_equip_durability_cache if @durability_max == nil
  435.     return @durability_max
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ○ 耐久状態を返す
  439.   # value 0 : 現在の耐久力 1 : 最大耐久力 2 : 現在の状態(文字列表示)
  440.   #--------------------------------------------------------------------------
  441.   def equip_state
  442.     value = []
  443.     create_equip_durability_cache if @durability_max == nil
  444.     now = @durability           # 現在の耐久度
  445.     max = @durability_max       # 最大耐久度
  446.     break_equip = max / 2       # 破損 = 最大 / 2  : 大破 = 耐久力 0
  447.     value[0] = now
  448.     value[1] = max
  449.     if now <= break_equip and now > 0
  450.       value[2] = Vocab::Equip_Damage
  451.       param_save_load(false)
  452.     elsif now == 0
  453.       value[2] = Vocab::Equip_Break
  454.       param_save_load(true)
  455.     else
  456.       value[2] = Vocab::Equip_Green
  457.       param_save_load(false)
  458.     end
  459.     return value
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ○ 改造最大レベルのキャッシュを作成
  463.   #--------------------------------------------------------------------------
  464.   def create_customize_level_max
  465.     self.note.each_line { |line|
  466.       if line =~ INDIVIDUAL_CUSTOM_LEVEL
  467.         @customize_level_max = $1.to_i
  468.         next if @customize_level_max == nil
  469.       end
  470.     }
  471.     @customize_level_max ||= ED::CUSTOM_LEVEL
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ○ 改造最大レベル
  475.   #--------------------------------------------------------------------------
  476.   def customize_level_max
  477.     create_customize_level_max if @customize_level_max == nil
  478.     return @customize_level_max
  479.   end
  480. end
  481.  
  482.  
  483. class RPG::Weapon < RPG::EquipItem
  484.   attr_accessor :weapon_atk_count_max                # 武器の最大攻撃回数
  485.   attr_accessor :weapon_atk_count                    # 武器の攻撃回数
  486.  
  487.   #--------------------------------------------------------------------------
  488.   # ● オブジェクト初期化
  489.   #--------------------------------------------------------------------------
  490.   alias ed_weapon_count_w_initialize initialize unless $@
  491.   def initialize
  492.     ed_weapon_count_w_initialize
  493.     initialize_add_params
  494.     save_state_value # 元のパラメータ保存用
  495.   end
  496.   #--------------------------------------------------------------------------
  497.   # ○ 武器回数回復
  498.   #--------------------------------------------------------------------------
  499.   def weapon_repair(number=0)
  500.     @weapon_atk_count = number == 0 ? @weapon_atk_count_max : number
  501.     equip_state
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # ● 装備の回復単価
  505.   #--------------------------------------------------------------------------
  506.   def weapon_atk_count_price
  507.     if WEAPON1_REPAIR_UNIT_PRICE > 0 and @etype_id == 0
  508.       return WEAPON1_REPAIR_UNIT_PRICE
  509.     else
  510.       # 価格 * 指定% / 100 = 価格の指定%
  511.       return (equip_price_set * REPAIR_COUNT_PRICE) / 100
  512.     end
  513.   end
  514.   #--------------------------------------------------------------------------
  515.   # ● 最強装備値
  516.   #--------------------------------------------------------------------------
  517.   def performance
  518.     params[2] + params[4] + org_params.inject(0) {|r, v| r += v }
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● 追加パラメーターの初期化
  522.   #--------------------------------------------------------------------------
  523.   def initialize_add_params
  524.     super
  525.     create_weapon_atk_count
  526.     @params[12] = @weapon_atk_count            # 武器回数
  527.     @params[13] = @weapon_atk_count_max        # 最大武器回数
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ○ 攻撃回数のキャッシュを作成
  531.   #--------------------------------------------------------------------------
  532.   def create_weapon_atk_count
  533.     @weapon_atk_count_max = 999
  534.  
  535.     self.note.each_line { |line|
  536.       if line =~ WEAPON_ATK_COUNT
  537.         @weapon_atk_count_max = $1.to_i
  538.         @weapon_atk_count = @weapon_atk_count_max if @weapon_atk_count == nil
  539.         next if @weapon_atk_count_max == nil
  540.       end
  541.     }
  542.     @weapon_atk_count = 999 if @weapon_atk_count == nil
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ○ 最大攻撃回数
  546.   #--------------------------------------------------------------------------
  547.   def weapon_atk_count_max
  548.     create_weapon_atk_count if @weapon_atk_count_max == nil
  549.     return @weapon_atk_count_max
  550.   end
  551.  
  552.   unless $@
  553.   #--------------------------------------------------------------------------
  554.   # ○ 武器の説明欄
  555.   #--------------------------------------------------------------------------
  556.   def description
  557.     weapon_atk_count_max
  558.     if @weapon_atk_count_max != 999
  559.       str = Vocab::DESCRIPTION_ATK_CNT + " " + @weapon_atk_count.to_s +
  560.       " / " + @weapon_atk_count_max.to_s + " "
  561.       state = Vocab::Equip_State + ":" + equip_state[2] + " "
  562.       @text = @description if @text == nil # @text には1度だけ説明文を入れる
  563.       @description = @text + str + state
  564.     else
  565.       state = Vocab::Equip_State + ":" + equip_state[2] + " "
  566.       @text = @description if @text == nil # @text には1度だけ説明文を入れる
  567.       @description = @text + state
  568.     end
  569.   end
  570.   end
  571. end
  572.  
  573. #==============================================================================
  574. # ■ RPG::Armor
  575. #==============================================================================
  576.  
  577. class RPG::Armor < RPG::EquipItem
  578.   #--------------------------------------------------------------------------
  579.   # ● 最強装備値
  580.   #--------------------------------------------------------------------------
  581.   def performance
  582.     params[3] + params[5] + org_params.inject(0) {|r, v| r += v }
  583.   end
  584.   unless $@
  585.   #--------------------------------------------------------------------------
  586.   # ○ 防具の説明欄
  587.   #--------------------------------------------------------------------------
  588.   def description
  589.     state = Vocab::Equip_State + ":" + equip_state[2] + " "
  590.     @text = @description if @text == nil # @text には1度だけ説明文を入れる
  591.     @description = @text + state
  592.   end
  593.   end
  594. end












RUBY 代码复制
  1. #==============================================================================
  2. #    ☆VXAce RGSS3 「個別装備アイテム:Game」☆
  3. #      EnDlEss DREamER
  4. #     URL:[url]http://mitsu-evo.6.ql.bz/[/url]
  5. #     製作者 mitsu-evo
  6. #     Last:2014/4/22
  7. #   武器防具1個ずつに耐久度や弾数・改造度などを設定する。
  8. #     ▼ 「個別装備アイテム:設定」「Game」「Window」「Scene」の順で導入
  9. #==============================================================================
  10.  
  11. #==============================================================================
  12. # ■ Game_Action
  13. #------------------------------------------------------------------------------
  14. #  戦闘行動を扱うクラスです。このクラスは Game_Battler クラスの内部で使用され
  15. # ます。
  16. #==============================================================================
  17.  
  18. class Game_Action
  19.   #--------------------------------------------------------------------------
  20.   # ● 防御判定
  21.   #--------------------------------------------------------------------------
  22.   def guard?
  23.     item == $data_skills[subject.guard_skill_id]
  24.   end
  25. end
  26. #==============================================================================
  27. # ■ Game_BaseItem
  28. #------------------------------------------------------------------------------
  29. #  スキル、アイテム、武器、防具を統一的に扱うクラスです。セーブデータに含める
  30. # ことができるように、データベースオブジェクト自体への参照は保持しません。
  31. #==============================================================================
  32.  
  33. class Game_BaseItem
  34.   #--------------------------------------------------------------------------
  35.   # ● オブジェクト初期化
  36.   #--------------------------------------------------------------------------
  37.   alias ed_weapon_count_initialize initialize
  38.   def initialize
  39.     ed_weapon_count_initialize
  40.     @item = nil
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● アイテムオブジェクトの取得
  44.   #--------------------------------------------------------------------------
  45.   alias ed_weapon_count_object_object object
  46.   def object
  47.     return ed_weapon_count_object_object if is_skill? or is_item?
  48.     # 個別装備アイテムの為にアイテムそのものを返す
  49.     return @item if is_weapon? or is_armor?
  50.     return nil
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● アイテムオブジェクトの設定
  54.   #--------------------------------------------------------------------------
  55.   alias ed_weapon_count_object= object=
  56.   def object=(item)
  57.     @class = item ? item.class : nil
  58.     @item_id = item ? item.id : 0
  59.     @item = item    # 個別装備アイテムの為にアイテムそのものを格納
  60.   end
  61. end
  62. #==============================================================================
  63. # ■ Game_ActionResult
  64. #------------------------------------------------------------------------------
  65. #  戦闘行動の結果を扱うクラスです。このクラスは Game_Battler クラスの内部で
  66. # 使用されます。
  67. #==============================================================================
  68.  
  69. class Game_ActionResult
  70.   #--------------------------------------------------------------------------
  71.   # ● 装備ダメージの文章を取得
  72.   #--------------------------------------------------------------------------
  73.   def equip_damage_text
  74.     return @ep_break_text
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● ダメージの作成
  78.   #--------------------------------------------------------------------------
  79.   alias ed_break_equip_make_damage make_damage
  80.   def make_damage(value, item)
  81.     ed_break_equip_make_damage(value, item)
  82.     equip_priority(value) if @success and item.damage.to_hp?
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 装備の耐久力被ダメージ処理
  86.   #--------------------------------------------------------------------------
  87.   def equip_priority(damage)
  88.     return if not @battler.actor? and not $ed_rgss3["ed_equip_extension"]
  89.     # 各種設定
  90.     # ダメージが0以下なら処理しない。
  91.     if damage <= 0 or @missed or @evaded or @effect_test
  92.       @ep_break_text = ""
  93.       return
  94.     end
  95.  
  96.     if @battler.atk_elements.include?(EQUIP_BREAK_ID)
  97.       damage *= EQUIP_BREAK_REVISION # 装備破壊属性ある場合の補正処理
  98.     end
  99.     damage /= BREAK_DAMAGE_REVISION # ダメージを除算して調整する
  100.  
  101.     @equips = @battler.equips.compact
  102.     equip_size = @equips.size                      # 装備要素数の最大サイズ
  103.     loop_size = equip_size - 1                      # 装備配列用の最大サイズ
  104.     # ダメージ÷最大HPで最大HP%を求める
  105.     percent = Float(damage) / Float(@battler.mhp)     
  106.     percent *= 100.0                    # 100乗算して%表記へ
  107.     loop_max = equip_size - 1           # 繰り返す最大数(装備項目の最大数)
  108.     loop_number = 0
  109.     @ep_break_text = ""
  110.  
  111.  
  112.     # 破壊処理
  113.     loop do
  114.       # 破壊部位ランダム選択
  115.       # ランダムで装備部位を選択
  116.       loop_max = rand(loop_size)
  117.       item = @equips[loop_max]
  118.       # この場合の「loop_max」はランダム部位選択の結果
  119.  
  120.       # 耐久度が未設定かnilなら次のループ処理へ
  121.  
  122.       if item == nil or item.durability_max == 9999999 or item.durability == 0
  123.         break if loop_number >= loop_size
  124.         next loop_number += 1
  125.       end
  126.  
  127.  
  128.       #========== ここまでが部位選択処理 ======================================
  129.  
  130.  
  131.       # 既に大破している部位なら次のループ処理へ
  132.       if item.equip_state[2] == Vocab::Equip_Break
  133.         break @ep_break_text = "" if loop_number == loop_size
  134.         next loop_number += 1
  135.       end
  136.  
  137.       # 指定%満たさない場合は処理を行わない(SMOOTH_DAMAGEがfalse時)
  138.       if not percent > BREAK_DAMAGE_PAR and not SMOOTH_DAMAGE
  139.         break if loop_number >= loop_size
  140.         next loop_number += 1
  141.       end
  142.         # 装備耐久度のダメージ割合を算出
  143.  
  144.         eq_dmg_per = Float(damage) / Float(item.durability)
  145.         eq_dmg_per *= 100.0
  146.  
  147.         # 装備耐久力−ダメージを試算
  148.         trial = item.durability
  149.         trial -= damage
  150.  
  151.         # 破損割合を算出。
  152.         if trial < 0
  153.           # 装備耐久力がマイナスなら0を代入
  154.           if item.equip_state[2] == Vocab::Equip_Green and not SMOOTH_DAMAGE
  155.             # 破損していないなら半減
  156.             trial = item.durability_max / 2
  157.             eq_dmg_per = 50.0
  158.           else
  159.             trial = 0
  160.           end
  161.         end
  162.  
  163.         # 装備耐久度の割合別減算処理        
  164.         if eq_dmg_per >= 100
  165.           # SMOOTHDAMAGE時は一気に大破する。
  166.           return equip_break(loop_max, damage) if SMOOTH_DAMAGE
  167.  
  168.           # ダメージに対する耐久度が100%以上
  169.           if item.equip_state[2] == Vocab::Equip_Damage
  170.             # 大破した時の処理
  171.             equip_break(loop_max, damage)
  172.             return
  173.           elsif item.equip_state[2] == Vocab::Equip_Green
  174.             # 100%以上のダメージでもまだ破損してない場合
  175.             equip_half_break(loop_max, damage)
  176.             return
  177.           end
  178.         elsif eq_dmg_per >= 50
  179.           # ダメージに対する耐久度が50%以上で正常の場合
  180.           if item.equip_state[2] == Vocab::Equip_Green
  181.             equip_half_break(loop_max, damage)
  182.             return
  183.           else
  184.             # 正常以外で耐久度へのダメージが50%以上なら大破処理
  185.             equip_break(loop_max, damage)
  186.             return
  187.           end
  188.         else
  189.           # ダメージがどれも当てはまらない
  190.           damage -= item.durability
  191.           item.durability -= damage if SMOOTH_DAMAGE
  192.           break
  193.         end
  194.       # loop doの末端
  195.       break if damage <= 0# 残ダメージが0以下なら終了
  196.       break if loop_number >= loop_size
  197.       loop_number += 1
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 破損処理
  202.   #--------------------------------------------------------------------------
  203.   def equip_half_break(loop_max, damage)
  204.     item = @equips[loop_max]
  205.     return if item.equip_state[2] == Vocab::Equip_Damage
  206.     item.durability -= damage
  207.     item.durability = item.durability_max / 2 unless SMOOTH_DAMAGE
  208.     # ↑ 耐久力ダメージ処理
  209.     @ep_break_text = sprintf(Vocab::Equip_Break_Text, @battler.name, item.name, Vocab::Equip_Damage)
  210.     item.equip_state # 対象装備のパラメーター無効化処理
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 大破処理
  214.   #--------------------------------------------------------------------------
  215.   def equip_break(loop_max, damage)
  216.     item = @equips[loop_max]
  217.     return if item.equip_state[2] == Vocab::Equip_Break
  218.     item.durability = 0
  219.     # ↑ 耐久力ダメージ処理
  220.     @ep_break_text = sprintf(Vocab::Equip_Break_Text, @battler.name, item.name, Vocab::Equip_Break)
  221.     # ダメージ−装備耐久力で残ダメージを算出
  222.     damage -= item.durability
  223.     item.equip_state # 対象装備のパラメーター無効化処理
  224.   end
  225. end
  226. #==============================================================================
  227. # ■ Game_Battler
  228. #------------------------------------------------------------------------------
  229. #  スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
  230. # は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
  231. #==============================================================================
  232.  
  233. class Game_Battler < Game_BattlerBase
  234.   attr_accessor :equip_selected_index
  235.   #--------------------------------------------------------------------------
  236.   # ● オブジェクト初期化
  237.   #--------------------------------------------------------------------------
  238.   alias ed_weapon_count_initialize initialize
  239.   def initialize
  240.     ed_weapon_count_initialize
  241.     # Item の ed_item_key を格納する配列で、equip_slotsと同じ要素数。
  242.     @equip_selected_index = [0,0,0,0,0]
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● メモ欄から装備を取得
  246.   #--------------------------------------------------------------------------
  247.   def get_note_equips(index,item_id)
  248.     @temp_slot ||= equip_slots.clone
  249.     kind = @temp_slot[index]
  250.     kind = 0 if kind == 1 and dual_wield?
  251.     #if ED::Equip_extension::WEAPON_TYPE.include?(kind)
  252.     if self.weapon_type.include?(kind)
  253.       # 武器の場合
  254.       item = $data_weapons[item_id]
  255.     else
  256.       # 防具の場合
  257.       item = $data_armors[item_id]
  258.     end
  259.     t_item = $game_party.make_equip(item,1,true) # 追加部分。
  260.     unless @__equips[index] == nil
  261.       @__equips[index].object = t_item
  262.       @__equips[index].set_equip(is_weapon?(kind), item_id)
  263.     end
  264.     @temp_slot[index] = nil # 装備済みのスロットにはnil
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● 武器攻撃回数消費実行
  268.   #--------------------------------------------------------------------------
  269.   def use_weapon
  270.     index = $ed_rgss3["ed_equip_extension"] ? select_weapon : 0
  271.     use_weapon_count(index)
  272.     # 武器0選択かつ二刀流の場合。
  273.     if dual_wield? and index == 0
  274.       size = $ed_rgss3["ed_equip_extension"] ?  weapon_number - 1 : 1
  275.       use_weapon_count(size)
  276.     end
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 個別装備アイテムの武器攻撃時の回数消費処理(テストにより判別も可能。)
  280.   #--------------------------------------------------------------------------
  281.   def use_weapon_count(index,test=false)
  282.     item = weapons[index]
  283.     # アイテムが nil 素手 か999設定 無制限の場合は消費せず戻る。
  284.     count = item == nil ? 999 : item.weapon_atk_count
  285.     return true if count == 999
  286.     return false if count == 0
  287.     item.weapon_atk_count -= 1 unless test
  288.     return true
  289.   end
  290. end
  291. #==============================================================================
  292. # ■ Game_Actor
  293. #------------------------------------------------------------------------------
  294. #  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
  295. # の内部で使用され、Game_Party クラス($game_party)からも参照されます。
  296. #==============================================================================
  297.  
  298. class Game_Actor < Game_Battler
  299. unless $ed_rgss3["ed_equip_extension"]
  300.   #--------------------------------------------------------------------------
  301.   # ● スロットIDでの武器・防具判定
  302.   #--------------------------------------------------------------------------
  303.   def is_weapon?(kind)
  304.     return kind == 0
  305.     return false if kind == nil
  306.   end
  307.   def is_armor?(kind)
  308.     return kind > 0
  309.     return false if kind == nil
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # ● 装備タイプ
  313.   #--------------------------------------------------------------------------
  314.   def equip_type
  315.     return equip_slots
  316.   end
  317. end
  318.   #--------------------------------------------------------------------------
  319.   # ● 装備品の初期化
  320.   #     equips : 初期装備の配列
  321.   #--------------------------------------------------------------------------
  322.   def init_equips(equips)
  323.     @equips = Array.new(equip_slots.size) { Game_BaseItem.new }
  324.     equips.each_with_index do |item_id, i|
  325.       next if item_id == 0
  326.       i = 0 if dual_wield? and i == 1
  327.       item = is_weapon?(i) ? $data_weapons[item_id] : $data_armors[item_id]
  328.       item = $game_party.make_equip(item,i,true)
  329.  
  330.       kind = $ed_rgss3["ed_equip_extension"] ? item.kind : index_to_etype_id(i)
  331.       slot_id = empty_slot(kind)
  332.       next if slot_id == nil
  333.       #if slot_id
  334.       #  @equips[slot_id].set_equip(is_weapon?(kind), item_id)
  335.         change_equip(slot_id,item) if slot_id
  336.       #end
  337.     end
  338.     create_equips_cache if $ed_rgss3["ed_equip_extension"]
  339.     create_equip_selected_index
  340.     refresh
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 装備の個別ID配列を作成(個別装備アイテム用メソッド)
  344.   #--------------------------------------------------------------------------
  345.   def create_equip_selected_index
  346.     if $ed_rgss3["ed_equip_extension"]
  347.       super
  348.       return
  349.     end
  350.     @equip_selected_index = []
  351.     equip_slots.size.times{|i| @equip_selected_index << 0 }
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 装備の変更
  355.   #     slot_id : 装備スロット ID
  356.   #     item    : 武器/防具(nil なら装備解除)
  357.   #--------------------------------------------------------------------------
  358.   def change_equip(slot_id, item)
  359.     return unless trade_item_with_party(item, equips[slot_id])
  360.     return if item && equip_slots[slot_id] != item.etype_id
  361.     @equips[slot_id].object = item
  362.     @equip_selected_index[slot_id] = item == nil ? 0 : item.ed_item_key
  363.     revision_param if $ed_rgss3["ed_equip_extension"]
  364.     refresh
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ● 装備の強制変更
  368.   #     slot_id : 装備スロット ID
  369.   #     item    : 武器/防具(nil なら装備解除)
  370.   #--------------------------------------------------------------------------
  371.   def force_change_equip(slot_id, item)
  372.     @equips[slot_id].object = item
  373.     equip_selected_index[slot_id] = item == nil ? 0 : item.ed_item_key
  374.     release_unequippable_items(false)
  375.     revision_param if $ed_rgss3["ed_equip_extension"]
  376.     refresh
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 装備の破棄
  380.   #     item : 破棄する武器/防具
  381.   #--------------------------------------------------------------------------
  382.   alias ed_weapon_count_discard_equip discard_equip
  383.   def discard_equip(item)
  384.     slot_id = equips.index(item)
  385.     equip_selected_index[slot_id] = 0 if slot_id
  386.     ed_weapon_count_discard_equip(item)
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ● 個別装備アイテムのインデックスのスロット変化修正
  390.   #--------------------------------------------------------------------------
  391.   def insert_selected_index(index,add=true)
  392.     @weapon_selected_index.insert(index, 0) if add
  393.     @weapon_selected_index.delete_at(index) unless add
  394.     @equip_selected_index = weapon_selected_index + armor_selected_index
  395.   end
  396.  
  397. end
  398. #==============================================================================
  399. # ■ Game_Party
  400. #------------------------------------------------------------------------------
  401. #  パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
  402. # スのインスタンスは $game_party で参照されます。
  403. #==============================================================================
  404.  
  405. class Game_Party < Game_Unit
  406.  
  407.   #--------------------------------------------------------------------------
  408.   # ● 武器オブジェクトの配列取得
  409.   #--------------------------------------------------------------------------
  410.   def weapons
  411.     @weapons.keys.sort.collect {|id| @weapons[id] }
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # ● 防具オブジェクトの配列取得
  415.   #--------------------------------------------------------------------------
  416.   def armors
  417.     @armors.keys.sort.collect {|id| @armors[id] }
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 全ての装備品オブジェクトの配列取得
  421.   #--------------------------------------------------------------------------
  422.   def equip_items
  423.     # 各IDには個別の装備がハッシュとしてあり、それを全て一つの配列データに変換。
  424.     result = []
  425.     equips = weapons + armors
  426.     equips.flatten!
  427.     equips.each {|items|items.each_value {|item| result << item}}
  428.     return result
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # ● 武器個別データ新規作成
  432.   #--------------------------------------------------------------------------
  433.   def make_weapon(id,number,direct=false,enemy=false)
  434.     return nil if $data_weapons[id] == nil
  435.     item = Marshal.load(Marshal.dump($data_weapons[id]))#$data_weapons[id].clone
  436.     # 追加パラメーターの初期化
  437.     item.initialize_add_params
  438.     # 武器の格納ハッシュキーを保持
  439.     if direct
  440.       @weapons[id] ||= {}
  441.       number = @weapons[id].size + 1
  442.       @weapons[id][number] = item
  443.     end
  444.     item.ed_item_key = enemy ? 100 + number : number
  445.     return item
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 防具個別データ新規作成
  449.   #--------------------------------------------------------------------------
  450.   def make_armor(id,number,direct=false,enemy=false)
  451.     return nil if $data_armors[id] == nil
  452.     item = Marshal.load(Marshal.dump($data_armors[id]))#$data_armors[id].clone
  453.     # 追加パラメーターの初期化
  454.     item.initialize_add_params
  455.     # 武器の格納ハッシュキーを保持
  456.     if direct
  457.       @armors[id] ||= {}
  458.       number = @armors[id].size + 1
  459.       @armors[id][number] = item
  460.     end
  461.     item.ed_item_key = enemy ? 100 + number : number
  462.     return item
  463.   end
  464.   #--------------------------------------------------------------------------
  465.   # ● 装備データの作成
  466.   #--------------------------------------------------------------------------
  467.   def make_equip(item,number,direct=false,enemy=false)
  468.     return nil if item == nil
  469.     return make_weapon(item.id, number,direct) if item.is_a?(RPG::Weapon)
  470.     return make_armor(item.id, number,direct) if item.is_a?(RPG::Armor)
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # ● アイテムの増加(減少)
  474.   #     include_equip : 装備品も含める
  475.   #--------------------------------------------------------------------------
  476.   def gain_item(item, amount, include_equip = false)
  477.     container = item_container(item.class)
  478.     return unless container
  479.  
  480.     last_number = item_number(item)
  481.     new_number = last_number + amount
  482.  
  483.     if item.is_a?(RPG::Item)
  484.       # アイテムの増加処理
  485.       container[item.id] = [[new_number, 0].max, max_item_number(item)].min
  486.       container.delete(item.id) if container[item.id] == 0
  487.     else
  488.       if amount > 0
  489.         # 装備の増加処理
  490.         unless item.ed_item_key == nil
  491.           # 装備品などでアイテムキーが有る場合は再格納する。
  492.           container[item.id][item.ed_item_key] = item#.ed_item_key
  493.           return
  494.         end
  495.  
  496.         container[item.id] ||= {} #unless container[item.id].is_a?(Array)
  497.         add_equip = false # 途中追加フラグ
  498.         eq = container[item.id]
  499.  
  500.         # 追加個数分繰り返し
  501.           amount.upto(amount){|i|
  502.             # 売却などで指定の番号[ed_item_key]欠番に新規追加する処理
  503.             num = 0
  504.             loop do
  505.               index = i + num # 一番最初から抜けている箇所へ追加処理
  506.               if eq[index] == nil
  507.                 eq[index] = make_equip(item, index)
  508.                 add_equip = true
  509.                 break
  510.               end
  511.               num += 1
  512.             end
  513.           }
  514.  
  515.         unless add_equip
  516.           # 途中フラグがなく、最後尾に装備を追加する処理。
  517.           amount.upto(amount){|num|
  518.           index = last_number + num
  519.             container[item.id][index] = make_equip(item, index) }
  520.         end
  521.       else
  522.         # 減らす時に番号が割り振られている場合は指定配列をnilにする。
  523.         unless item.ed_item_key == nil
  524.           eq = container[item.id]
  525.           i = item.ed_item_key
  526.           if amount.abs == 1
  527.             eq.delete(i)
  528.           end
  529.         else
  530.           eq = container[item.id]
  531.           amount.abs.times{|num| eq.delete(eq.size) }
  532.         end
  533.       end
  534.     end
  535.  
  536.  
  537.     if include_equip && new_number < 0
  538.       discard_members_equip(item, -new_number)
  539.     end
  540.     $game_map.need_refresh = true
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # ● アイテムの所持数取得
  544.   #--------------------------------------------------------------------------
  545.   def item_number(item)
  546.     container = item_container(item.class)
  547.     if item.class == RPG::Item
  548.       container ? container[item.id] || 0 : 0
  549.     else
  550.       return 0 if item == nil
  551.       # 武器防具の場合は配列で格納しているので配列の要素数を返す。
  552.       container[item.id] ||= {} #unless container[item.id].is_a?(Hash)
  553.       container ? container[item.id].size || 0 : 0
  554.     end
  555.   end
  556.  
  557. end
  558. #==============================================================================
  559. # ■ Game_Interpreter
  560. #------------------------------------------------------------------------------
  561. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  562. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  563. #==============================================================================
  564. class Game_Interpreter
  565.   include ED::Command
  566.   #--------------------------------------------------------------------------
  567.   # ● 武器弾数回復シーンの遷移処理
  568.   #--------------------------------------------------------------------------
  569.   def start_weapon_repair
  570.     return if $game_party.in_battle
  571.     SceneManager.call(Scene_Repair)
  572.     SceneManager.scene.prepare(true)
  573.     Fiber.yield
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # ● 装備耐久力回復シーンの遷移処理
  577.   #--------------------------------------------------------------------------
  578.   def start_armor_repair
  579.     return if $game_party.in_battle
  580.     SceneManager.call(Scene_Repair)
  581.     SceneManager.scene.prepare(false)
  582.     Fiber.yield
  583.   end
  584. end




RUBY 代码复制
  1. #==============================================================================
  2. #    ☆VXAce RGSS3 「個別装備アイテム:Window」☆
  3. #      EnDlEss DREamER
  4. #     URL:[url]http://mitsu-evo.6.ql.bz/[/url]
  5. #     製作者 mitsu-evo
  6. #     Last:2014/4/22
  7. #   武器防具1個ずつに耐久度や弾数・改造度などを設定する。
  8. #     ▼ 「個別装備アイテム:設定」「Game」「Window」「Scene」の順で導入
  9. #==============================================================================
  10. =begin
  11.  
  12.  
  13.  
  14. =end
  15. #==============================================================================
  16. # ■ Window_Base
  17. #------------------------------------------------------------------------------
  18. #  ゲーム中の全てのウィンドウのスーパークラスです。
  19. #==============================================================================
  20.  
  21. class Window_Base < Window
  22.   #--------------------------------------------------------------------------
  23.   # ● 耐久力の状態別の表示文字色変更
  24.   #--------------------------------------------------------------------------
  25.   def equip_state_text_color(item)
  26.     return change_color(normal_color) if item == nil
  27.     # アイテムの文字と設定文字がそれぞれ同じなら分岐
  28.     if item.equip_state[2] == Vocab::Equip_Damage
  29.       # 破損
  30.       change_color(crisis_color)
  31.     elsif item.equip_state[2] == Vocab::Equip_Break
  32.       # 大破
  33.       change_color(knockout_color)
  34.     else
  35.       # 正常
  36.       change_color(normal_color)
  37.     end
  38.   end
  39. end
  40. #==============================================================================
  41. # ■ Window_BattleLog
  42. #------------------------------------------------------------------------------
  43. #  戦闘の進行を実況表示するウィンドウです。枠は表示しませんが、便宜上ウィンド
  44. # ウとして扱います。
  45. #==============================================================================
  46.  
  47. class Window_BattleLog < Window_Selectable
  48.   #--------------------------------------------------------------------------
  49.   # ● 行動結果の表示
  50.   #--------------------------------------------------------------------------
  51.   alias ed_break_equip_display_action_results display_action_results
  52.   def display_action_results(target, item)
  53.     ed_break_equip_display_action_results(target, item)
  54.     if (target.result.used and item.repair?) or
  55.       (target.result.used and item.weapon_repair?)
  56.       target.equips.compact.each{|equip| equip.durability_repair} if item.repair?
  57.       item_weapon_repair(target, item) if item.weapon_repair?
  58.       d_text = sprintf(Vocab::Equip_Repair_Text, target.name)
  59.       add_text(d_text)
  60.     end
  61.     wait
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● アイテムによる武器回数回復の実行
  65.   #--------------------------------------------------------------------------
  66.   def item_weapon_repair(target, item)
  67.     e_item = item.note.scan(/<武器回復[::](0|-?\d+),(\d+),(\d+)>/)
  68.     e_item.flatten!#配列をフラットにする[1,[2]]を[1,2]へ
  69.     unless e_item == nil or e_item.empty?
  70.       weapon_id = e_item[0].to_i          # メモ欄の武器ID
  71.       weapon_index = e_item[1].to_i       # メモ欄の装備ヶ所
  72.       repair_num = e_item[2].to_i       # メモ欄の回復数
  73.  
  74.       # 同じ武器が装備中かどうかチェック
  75.       i = 0    # 装備ヶ所
  76.       for equip in target.weapons
  77.         # 武器IDが同じで装備ヶ所も同じなら回復処理
  78.         if equip.id == weapon_id and i == weapon_index
  79.           equip.weapon_repair(repair_num)
  80.           return true
  81.         elsif weapon_id == -1 and i == weapon_index
  82.           # 武器ID指定がないなら指定量だけ装備ヶ所の武器回数を回復
  83.           equip.weapon_repair(repair_num)
  84.           return true
  85.         end
  86.         i += 1
  87.       end
  88.     end
  89.     return false
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● HP ダメージ表示
  93.   #--------------------------------------------------------------------------
  94.   alias ed_break_equip_display_hp_damage display_hp_damage
  95.   def display_hp_damage(target, item)
  96.     ed_break_equip_display_hp_damage(target, item)
  97.     return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
  98.     if target.result.hp_damage > 0 && target.result.hp_drain == 0
  99.       # 装備破壊テキストを追加
  100.       d_text = target.result.equip_damage_text
  101.       if d_text =~ /#{Vocab::Equip_Damage}/
  102.         $game_troop.screen.start_flash(Color.new(255,255,0),10)
  103.         Audio.se_play(EQUIP_DAMAGE_SE,100,100)
  104.       elsif d_text =~ /#{Vocab::Equip_Break}/
  105.         $game_troop.screen.start_flash(Color.new(255,50,50),10)
  106.         Audio.se_play(EQUIP_BREAK_SE,100,100)
  107.       end
  108.       add_text(d_text) unless d_text.empty?
  109.     end
  110.     wait
  111.   end
  112.  
  113. end
  114. #==============================================================================
  115. # ■ Window_ActorName
  116. #------------------------------------------------------------------------------
  117. #  アクター名を表示するウィンドウです。
  118. #==============================================================================
  119.  
  120. class Window_ActorName < Window_Base
  121.   #--------------------------------------------------------------------------
  122.   # ● オブジェクト初期化
  123.   #--------------------------------------------------------------------------
  124.   def initialize(x, y, width, height, actor)
  125.     super(x, y, width, height)
  126.     @actor = actor
  127.     refresh
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● アクターの設定
  131.   #--------------------------------------------------------------------------
  132.   def actor=(actor)
  133.     return if @actor == actor
  134.     @actor = actor
  135.     refresh
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● リフレッシュ
  139.   #--------------------------------------------------------------------------
  140.   def refresh
  141.     contents.clear
  142.     draw_actor_name(@actor, 0, 0)
  143.   end
  144. end
  145. #==============================================================================
  146. # ■ Window_YesNoCommand
  147. #------------------------------------------------------------------------------
  148. #  はい・いいえを選択するウィンドウです。
  149. #==============================================================================
  150.  
  151. class Window_YesNoCommand < Window_HorzCommand
  152.   #--------------------------------------------------------------------------
  153.   # ● オブジェクト初期化
  154.   #--------------------------------------------------------------------------
  155.   def initialize(x, y, window_width)
  156.     @window_width = window_width
  157.     super(x, y)
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● ウィンドウ幅の取得
  161.   #--------------------------------------------------------------------------
  162.   def window_width
  163.     @window_width
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 桁数の取得
  167.   #--------------------------------------------------------------------------
  168.   def col_max
  169.     return 2
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● コマンドリストの作成
  173.   #--------------------------------------------------------------------------
  174.   def make_command_list
  175.     add_command("はい",     :ok)
  176.     add_command("いいえ",   :cancel)
  177.   end
  178. end
  179. #==============================================================================
  180. # ■ Window_ItemList
  181. #------------------------------------------------------------------------------
  182. #  アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
  183. #==============================================================================
  184.  
  185. class Window_ItemList < Window_Selectable
  186.   #--------------------------------------------------------------------------
  187.   # ● 項目の描画
  188.   #--------------------------------------------------------------------------
  189.   alias ed_weapon_count_draw_item draw_item
  190.   def draw_item(index)
  191.     item = @data[index]
  192.     unless item.is_a?(RPG::Item)
  193.       if item
  194.         rect = item_rect(index)
  195.         rect.width -= 4
  196.         draw_item_name(item, rect.x, rect.y, enable?(item))
  197.         #draw_item_number(rect, item)
  198.       end
  199.     else
  200.       ed_weapon_count_draw_item(index)
  201.     end
  202.   end
  203. end
  204. #==============================================================================
  205. # ■ Window_RepairEquipSlot
  206. #------------------------------------------------------------------------------
  207. #  装備画面で、アクターが現在装備している武器を表示するウィンドウです。
  208. #==============================================================================
  209.  
  210. class Window_RepairEquipSlot < Window_EquipSlot
  211.   #--------------------------------------------------------------------------
  212.   # ● オブジェクト初期化
  213.   #--------------------------------------------------------------------------
  214.   def initialize(x, y, width, atk_count = false)
  215.     super(x, y, width)
  216.     @actor = nil
  217.     @atk_count = atk_count
  218.     refresh
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● 項目数の取得
  222.   #--------------------------------------------------------------------------
  223.   def item_max
  224.     if @atk_count
  225.       return @actor ? @actor.weapons.size : 0
  226.     else
  227.       return @actor ? @actor.equip_slots.size : 0
  228.     end
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ● アイテムの取得
  232.   #--------------------------------------------------------------------------
  233.   def item
  234.     if @atk_count
  235.       return @actor ? @actor.weapons[index] : nil
  236.     else
  237.       return @actor ? @actor.equips[index] : nil
  238.     end
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 項目の描画
  242.   #--------------------------------------------------------------------------
  243.   def draw_item(index)
  244.     return unless @actor
  245.     rect = item_rect_for_text(index)
  246.     change_color(system_color, enable?(index))
  247.     draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
  248.     if @atk_count
  249.       draw_item_name(@actor.weapons[index], rect.x + 92, rect.y, enable?(index))
  250.     else
  251.       draw_item_name(@actor.equips[index], rect.x + 92, rect.y, enable?(index))
  252.     end
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● アイテム名の描画
  256.   #     enabled : 有効フラグ。false のとき半透明で描画
  257.   #--------------------------------------------------------------------------
  258.   def draw_item_name(item, x, y, enabled = true, width = 172)
  259.     return unless item
  260.     draw_icon(item.icon_index, x, y, enabled)
  261.     change_color(normal_color, enabled)
  262.     draw_text(x + 24, y, width, line_height, item.name)
  263.     if @atk_count
  264.       # 武器回数回復の場合は回数を
  265.       now = item.weapon_atk_count == 999 ? "------" : item.weapon_atk_count.to_s
  266.       max = item.weapon_atk_count_max == 999 ? "------" : item.weapon_atk_count_max.to_s
  267.       draw_text(x + 48 + width , y, width, line_height, now)
  268.       draw_text(x + 112 + width, y, 22, line_height, "/", 1)
  269.       draw_text(x + 144 + width , y, width, line_height, max)
  270.     else
  271.       # 回数回復じゃない場合は状態を
  272.       equip_state_text_color(item)
  273.       draw_text(x + 48 + width , y, width, line_height, item.equip_state[2])
  274.     end
  275.   end
  276. end
  277.  
  278. #==============================================================================
  279. # ■ Window_WeaponRepairCommand
  280. #------------------------------------------------------------------------------
  281. #  ショップ画面で、購入/売却を選択するウィンドウです。
  282. #==============================================================================
  283.  
  284. class Window_WeaponRepairCommand < Window_HorzCommand
  285.   #--------------------------------------------------------------------------
  286.   # ● オブジェクト初期化
  287.   #--------------------------------------------------------------------------
  288.   def initialize(window_width, purchase_only)
  289.     @window_width = window_width
  290.     @purchase_only = purchase_only
  291.     super(0, 0)
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● ウィンドウ幅の取得
  295.   #--------------------------------------------------------------------------
  296.   def window_width
  297.     @window_width
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● 桁数の取得
  301.   #--------------------------------------------------------------------------
  302.   def col_max
  303.     return 3
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● コマンドリストの作成
  307.   #--------------------------------------------------------------------------
  308.   def make_command_list
  309.     add_command(Vocab::FULL_REPAIR_UNIT,    :all)
  310.     add_command(Vocab::REPAIR_UNIT,   :select,   !@purchase_only)
  311.     add_command(Vocab::ShopCancel, :cancel)
  312.   end
  313. end
  314. #==============================================================================
  315. # ■ Window_RepairShopNumber
  316. #------------------------------------------------------------------------------
  317. #  リペアショップ画面で、個数を入力するウィンドウです。
  318. #==============================================================================
  319.  
  320. class Window_RepairShopNumber < Window_ShopNumber
  321.  
  322.   #--------------------------------------------------------------------------
  323.   # ● アイテム、最大個数、価格、通貨単位の設定
  324.   #--------------------------------------------------------------------------
  325.   def set(item, max, price, currency_unit = nil)
  326.     super(item, max, price, currency_unit)
  327.     @number = 0
  328.     refresh
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   # ● 個数の変更
  332.   #--------------------------------------------------------------------------
  333.   def change_number(amount)
  334.     @number = [[@number + amount, @max].min, 0].max
  335.   end
  336. end
  337.  
  338. if $ed_rgss3["ed_equip_extension"]
  339. #==============================================================================
  340. # ■ Window_BattleWeapon
  341. #------------------------------------------------------------------------------
  342. #  戦闘画面で武器を一覧を表示するウィンドウです。
  343. #==============================================================================
  344.  
  345. class Window_BattleWeapon < Window_Command
  346.   #--------------------------------------------------------------------------
  347.   # ● 武器コマンドをリストに追加
  348.   #--------------------------------------------------------------------------
  349.   def add_weapon_command
  350.     @actor.weapon_number.times{|i|
  351.     item = @actor.weapons[i]
  352.     name = item == nil ? "" : item.name
  353.     # 武器回数を追加表示。
  354.     unless item == nil
  355.       name += item.weapon_atk_count == 999 ? "" : " : " + item.weapon_atk_count.to_s
  356.       enabled = @actor.attack_usable? ? item.weapon_atk_count > 0 ? true : false : false
  357.     else
  358.       enabled = true
  359.     end
  360.  
  361.     add_command(name, :attack, enabled)}
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● 決定ボタンが押されたときの処理
  365.   #--------------------------------------------------------------------------
  366.   alias ed_weapon_count_process_ok process_ok
  367.   def process_ok
  368.     unless @actor.use_weapon_count(index,true)
  369.       # 武器を使用可能かテストしてダメなら戻る。
  370.       Sound.play_buzzer
  371.     else
  372.       ed_weapon_count_process_ok
  373.     end
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● SHIFTボタンが押されたときの処理
  377.   #--------------------------------------------------------------------------
  378.   alias ed_weapon_count_process_shift process_shift
  379.   def process_shift
  380.     unless @actor.use_weapon_count(index,true)
  381.       # 武器を使用可能かテストしてダメなら戻る。
  382.       Sound.play_buzzer
  383.     else
  384.       ed_weapon_count_process_shift
  385.     end
  386.   end
  387. end
  388. end#$ed_rgss3["ed_equip_extension"]
  389. #==============================================================================
  390. # ■ Window_Repair
  391. #------------------------------------------------------------------------------
  392. #  ショップ画面で回復する武器弾数や防具耐久度の装備一覧表示のウィンドウです。
  393. #==============================================================================
  394.  
  395.  
  396.  
  397. class Window_Repair < Window_Selectable
  398.  
  399.   #--------------------------------------------------------------------------
  400.   # ● オブジェクト初期化
  401.   #--------------------------------------------------------------------------
  402.   def initialize(x,y,height,actor,atk_count=false)
  403.     super(x, y, window_width, height)
  404.     @actor = actor
  405.     @atk_count = atk_count
  406.     clear_list
  407.     unselect
  408.     activate
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # ● アクターの設定
  412.   #--------------------------------------------------------------------------
  413.   def actor=(actor)
  414.     return if @actor == actor
  415.     @actor = actor
  416.     refresh
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● リストに追加
  420.   #--------------------------------------------------------------------------
  421.   def add_list(value)
  422.     @repair_list << value
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● リストをクリア
  426.   #--------------------------------------------------------------------------
  427.   def clear_list
  428.     @repair_list = []
  429.     @number = 0
  430.     @item = nil
  431.     @all_repair = false
  432.     all_weapon_repair_price if @atk_count
  433.     all_equips_repair_price unless @atk_count
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 全装備回復フラグ
  437.   #--------------------------------------------------------------------------
  438.   def all_repair=(value)
  439.     @all_repair = value
  440.     refresh
  441.   end
  442.   def all_repair; @all_repair; end
  443.   #--------------------------------------------------------------------------
  444.   # ● ウィンドウ幅の取得
  445.   #--------------------------------------------------------------------------
  446.   def window_width
  447.     return Graphics.width
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● スロットウィンドウの設定
  451.   #--------------------------------------------------------------------------
  452.   def slot_window=(slot_window)
  453.     @slot_window = slot_window
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● ナンバーウィンドウの設定
  457.   #--------------------------------------------------------------------------
  458.   def number_window=(number_window)
  459.     @number_window = number_window
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● ナンバーウィンドウの回復弾数取得
  463.   #--------------------------------------------------------------------------
  464.   def number
  465.     @number = @atk_count ? @number_window.number : 1
  466.     @item = @slot_window.item
  467.     @all_repair = false
  468.     if @atk_count
  469.       t_price = @item == nil ? 0 : @item.weapon_atk_count_price
  470.     else
  471.       t_price = @item == nil ? 0 : @item.durability_price
  472.     end
  473.     @repair_list[@slot_window.index] = [@number, t_price * @number]
  474.     refresh
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   # ● リフレッシュ
  478.   #--------------------------------------------------------------------------
  479.   def refresh
  480.     contents.clear
  481.     draw_equipments(0,0)
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ● 装備品詳細の描画
  485.   #--------------------------------------------------------------------------
  486.   def draw_equipments(x, y)
  487.     i = 0 # 装備のインデックス
  488.     y2 = 0 # 表示座標の行数
  489.  
  490.     @actor.equips.each do |item|
  491.       next if item == nil
  492.       # 武器回数回復の場合は防具を処理しない。
  493.       next if not item.is_a?(RPG::Weapon) and @atk_count
  494.       # 個別回復でスロットウィンドウのアイテムと装備のアイテムが違う場合
  495.       next if not @all_repair and @item != item
  496.       j = y + (line_height * y2)
  497.       draw_item_name(item, x, j)
  498.       draw_price(item, x + Graphics.width / 2, j, i)
  499.       i += 1
  500.       y2 += 1
  501.     end
  502.     # 合計の描画
  503.     draw_text(x, y + line_height * (y2 + 1), 44, line_height, "合計", 1)
  504.     draw_currency_value(price,currency_unit,x,y + line_height * (y2 + 1),
  505.     window_width - (standard_padding * 2))
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ● 回復個数及び価格描画
  509.   #--------------------------------------------------------------------------
  510.   def draw_price(item, x, y, index)
  511.     return if @repair_list.empty?
  512.     return if @repair_list[index] == nil
  513.     return unless item
  514.     change_color(normal_color)
  515.     count = @repair_list[index][0] if @atk_count
  516.     price = @repair_list[index][1]
  517.     if @atk_count
  518.       # 武器の場合は回復回数を描画
  519.       draw_text(x, y, 44, line_height, count.to_s + Vocab::COUNT_UNIT, 1)
  520.     else
  521.       # 他は耐久力の状態を描画
  522.       text = item.equip_state[2]
  523.       equip_state_text_color(item)
  524.       draw_text(x, y, 44, line_height, text, 1)
  525.       change_color(normal_color)
  526.     end
  527.     draw_text(x + 88, y, 44, line_height, price.to_s + currency_unit, 2)
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ● 商品の値段を取得
  531.   #--------------------------------------------------------------------------
  532.   def price
  533.     @repair_list ||= []
  534.     return 0 if @repair_list.empty?
  535.     @repair_list.inject(0) {|r,item|
  536.     next unless item
  537.     r ||= 0
  538.     r + item[1]}
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # ● 全武装回復の弾数の価格取得
  542.   #--------------------------------------------------------------------------
  543.   def all_weapon_repair_price
  544.     result = 0
  545.     @actor.weapons.each do |item|
  546.       i = item == nil ? 0 : item.weapon_atk_count_max - item.weapon_atk_count
  547.       r = item == nil ? 0 : i * item.weapon_atk_count_price
  548.       result += r
  549.       add_list([i, r])
  550.     end
  551.     refresh
  552.     return result
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # ● 全装備の耐久力の価格取得
  556.   #--------------------------------------------------------------------------
  557.   def all_equips_repair_price
  558.     result = 0
  559.     @actor.equips.each do |item|
  560.       i = 0
  561.       r = item == nil ? 0 : item.durability_price
  562.       result += r
  563.       add_list([i, r])
  564.     end
  565.     refresh
  566.     return result
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # ● 選択項目の有効状態を取得
  570.   #--------------------------------------------------------------------------
  571.   def current_item_enabled?
  572.     return $game_party.gold >= self.price && self.price > 0
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● 通貨単位の取得
  576.   #--------------------------------------------------------------------------
  577.   def currency_unit
  578.     Vocab::currency_unit
  579.   end
  580. end
  581. #==============================================================================
  582. # ■ Window_Equip_Contents_Custom
  583. #------------------------------------------------------------------------------
  584. #  改造するアイテムの詳細を表示するヘルプウィンドウです。
  585. #==============================================================================
  586.  
  587. class Window_Equip_Contents_Custom < Window_Selectable
  588.   #--------------------------------------------------------------------------
  589.   # ● 公開インスタンス変数
  590.   #--------------------------------------------------------------------------
  591.   attr_reader   :slot_window            # スロットウィンドウ
  592.   attr_reader   :number_window          # ナンバーウィンドウ
  593.   #--------------------------------------------------------------------------
  594.   # ● オブジェクト初期化
  595.   #--------------------------------------------------------------------------
  596.   def initialize(x, y)
  597.     super(x, y, window_width, Graphics.height - y)
  598.     @new_item = nil
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ● ウィンドウ幅の取得
  602.   #--------------------------------------------------------------------------
  603.   def window_width
  604.     return 208
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ● 表示行数の取得
  608.   #--------------------------------------------------------------------------
  609.   def visible_line_number
  610.     return 4
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   # ● 項目数の取得
  614.   #--------------------------------------------------------------------------
  615.   def item_max
  616.     return 4
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● フォントを小さくする
  620.   #--------------------------------------------------------------------------
  621.   def make_font_smaller
  622.     contents.font.size -= 4 if contents.font.size >= 16
  623.   end
  624.   #--------------------------------------------------------------------------
  625.   # ● アイテム詳細の描画
  626.   #--------------------------------------------------------------------------
  627.   def draw_item_contents(item, new_param=false)
  628.     return unless item
  629.     draw_item_name(item, 0, 0) unless new_param
  630.     draw_right_arrow(new_param_x) if new_param
  631.  
  632.     draw_equip_all_param(new_param)
  633.     draw_equip_durability(0, line_height * 9,item, new_param)
  634.     draw_equip_weapon_atk_count(0, line_height * 10,item, new_param)
  635.     if $ed_rgss3["ed_equip_extension"]
  636.       draw_item_weight(0, line_height * 11,item, new_param)
  637.       draw_equipment_ep_cost(item, 0 , line_height * 12, new_param)
  638.     end
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 全能力値の描画
  642.   #--------------------------------------------------------------------------
  643.   def draw_equip_all_param(new_param=false)
  644.     item = new_param ? @new_item : @item
  645.     8.times{|i|# 8 はtimesが0からself -1までだから。
  646.     h = (i + 1) * line_height
  647.     draw_equip_param(item, 0, h, i, new_param)}
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ● 能力値の描画
  651.   #--------------------------------------------------------------------------
  652.   def draw_equip_param(item, x, y, param_id, new_param=false)
  653.     x += new_param_x if new_param
  654.     plus_x = new_param ? 36 : 50
  655.     change_color(system_color)
  656.     draw_text(x, y, 42, line_height, params_text_short(param_id)) unless new_param
  657.     change_color(normal_color)
  658.     draw_text(x + plus_x, y, 42, line_height, item.params[param_id], 2)
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # ● 装備重量の描画
  662.   #--------------------------------------------------------------------------
  663.   def draw_item_weight(x, y, item, new_param=false)
  664.     x += new_param_x if new_param
  665.     plus_x = new_param ? 36 : 50
  666.     change_color(system_color)
  667.     draw_text(x, y, 42, line_height, ED::Equip_extension::VOCAB_WEIGHT) unless new_param
  668.     change_color(normal_color)
  669.     draw_text(x + plus_x, y, 42, line_height, item.equip_weight, 2)
  670.   end
  671.   #--------------------------------------------------------------------------
  672.   # ● 消費 EP の描画
  673.   #     item    : 武器 or 防具
  674.   #     rect    : 描画する領域
  675.   #     enabled : 許可状態
  676.   #--------------------------------------------------------------------------
  677.   def draw_equipment_ep_cost(item, x, y, new_param=false)
  678.     return unless ED::Equip_extension::USE_EP_SYSTEM
  679.     return if item == nil
  680.     x += new_param_x if new_param
  681.     plus_x = new_param ? 36 : 50
  682.     change_color(system_color)
  683.     draw_text(x, y, 42, line_height, ED::Equip_extension::VOCAB_EP) unless new_param
  684.     change_color(normal_color)
  685.     draw_text(x + plus_x , y, 42, line_height, item.ep_cost, 2)
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # ● 装備レベルの描画
  689.   #     x     : 描画先 X 座標
  690.   #     y     : 描画先 Y 座標
  691.   #     item  : 装備品
  692.   #--------------------------------------------------------------------------
  693.   def draw_equip_level(x,y,item, new_param=false)
  694.     return unless ED::Equip_extension::USE_EQUIP_LEVEL_SYSTEM
  695.     x += new_param_x if new_param
  696.     plus_x = new_param ? 36 : 50
  697.     change_color(system_color)
  698.     draw_text(x, y, 36, line_height, Vocab::equip_level) unless new_param
  699.     change_color(normal_color)
  700.     draw_text(x + plus_x, y, 42, line_height, item.equip_level, 2)
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # ● 装備耐久力の描画
  704.   #     x     : 描画先 X 座標
  705.   #     y     : 描画先 Y 座標
  706.   #     item  : 装備品
  707.   #--------------------------------------------------------------------------
  708.   def draw_equip_durability(x,y,item, new_param=false)
  709.     x += new_param_x if new_param
  710.     plus_x = new_param ? 36 : 50
  711.     change_color(system_color)
  712.     draw_text(x, y, 36, line_height, Vocab::Equip_Durability) unless new_param
  713.     change_color(normal_color)
  714.     text = item.durability_max >= 9999999 ? "------" : item.durability_max
  715.     draw_text(x + plus_x, y, 42, line_height, text, 2)
  716.   end
  717.   #--------------------------------------------------------------------------
  718.   # ● 武器攻撃回数の描画
  719.   #     x     : 描画先 X 座標
  720.   #     y     : 描画先 Y 座標
  721.   #     item  : 装備品
  722.   #--------------------------------------------------------------------------
  723.   def draw_equip_weapon_atk_count(x,y,item, new_param=false)
  724.     x += new_param_x if new_param
  725.     plus_x = new_param ? 36 : 50
  726.     change_color(system_color)
  727.     draw_text(x, y, 36, line_height, Vocab::DESCRIPTION_ATK_CNT) unless new_param
  728.     return unless item.is_a?(RPG::Weapon)
  729.     change_color(normal_color)
  730.     text = item.weapon_atk_count_max >= 999 ? "------" : item.weapon_atk_count_max
  731.     draw_text(x + plus_x, y, 42, line_height, text, 2)
  732.   end
  733.   #--------------------------------------------------------------------------
  734.   # ● 項目の描画
  735.   #--------------------------------------------------------------------------
  736.   def draw_item(x, y, item)
  737.     draw_current_param(item)
  738.     draw_right_arrow(x + 126, y)
  739.     draw_current_param(@new_item, true) if @new_item
  740.   end
  741.   #--------------------------------------------------------------------------
  742.   # ● 能力値の名前を描画
  743.   #--------------------------------------------------------------------------
  744.   def draw_param_name(x, y, param_id)
  745.     change_color(system_color)
  746.     draw_text(x, y, 80, line_height, Vocab::param(param_id))
  747.   end
  748.   #--------------------------------------------------------------------------
  749.   # ● 右向き矢印を描画
  750.   #--------------------------------------------------------------------------
  751.   def draw_right_arrow(x=0)
  752.     change_color(system_color)
  753.     13.times{|i|
  754.     next if i == 0
  755.     next if i > 10 unless $ed_rgss3["ed_equip_extension"]
  756.     y = i * line_height
  757.     draw_text(x, y, 22, line_height, "→", 1)}
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # ● 新しいパラメータの表示基準X座標
  761.   #--------------------------------------------------------------------------
  762.   def new_param_x
  763.     return window_width / 2
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● アイテムの取得
  767.   #--------------------------------------------------------------------------
  768.   def item
  769.     @item = @slot_window.item
  770.     refresh
  771.   end
  772.   #--------------------------------------------------------------------------
  773.   # ● ナンバーウィンドウの改造レベル取得
  774.   #--------------------------------------------------------------------------
  775.   def number
  776.     @number = @number_window.number
  777.     refresh
  778.   end
  779.   #--------------------------------------------------------------------------
  780.   # ● 改造後用アイテムの設定
  781.   #--------------------------------------------------------------------------
  782.   def set_new_item(item)
  783.     @new_item = item
  784.     refresh
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # ● 改造後用アイテムの取得
  788.   #--------------------------------------------------------------------------
  789.   def new_item
  790.     @new_item = @number_window.item
  791.     refresh
  792.   end
  793.   #--------------------------------------------------------------------------
  794.   # ● スロットウィンドウの設定
  795.   #--------------------------------------------------------------------------
  796.   def slot_window=(slot_window)
  797.     @slot_window = slot_window
  798.   end
  799.   #--------------------------------------------------------------------------
  800.   # ● ナンバーウィンドウの設定
  801.   #--------------------------------------------------------------------------
  802.   def number_window=(number_window)
  803.     @number_window = number_window
  804.   end
  805.   #--------------------------------------------------------------------------
  806.   # ● リフレッシュ
  807.   #--------------------------------------------------------------------------
  808.   def refresh
  809.     contents.clear
  810.     draw_item_contents(@item,false)
  811.     draw_item_contents(@new_item,true) if @new_item
  812.   end
  813.   #--------------------------------------------------------------------------
  814.   # ● カーソルが移動しているか?
  815.   #--------------------------------------------------------------------------
  816.   def other_window_cursor_movable?
  817.     return true if @slot_window and @slot_window.cursor_movable?
  818.     return true if @number_window and @number_window.cursor_movable?
  819.     return false
  820.   end
  821.   #--------------------------------------------------------------------------
  822.   # ● フレーム更新
  823.   #--------------------------------------------------------------------------
  824.   def update
  825.     super
  826.     item if other_window_cursor_movable?
  827.   end
  828.   #--------------------------------------------------------------------------
  829.   # ● 装備変更後の一時アクター設定
  830.   #--------------------------------------------------------------------------
  831.   def set_temp_actor(temp_actor)
  832.     return
  833.   end
  834. end
  835.  
  836. if $ed_rgss3["ed_equip_extension"]
  837. #==============================================================================
  838. # ■ Window_BattleWeapon
  839. #------------------------------------------------------------------------------
  840. #  戦闘画面で武器を一覧を表示するウィンドウです。
  841. #==============================================================================
  842.  
  843. class Window_BattleWeapon < Window_Command
  844.   #--------------------------------------------------------------------------
  845.   # ● 項目の描画
  846.   #--------------------------------------------------------------------------
  847.   def draw_item(index)
  848.     equip_state_text_color(item)
  849.     draw_text(item_rect_for_text(index), command_name(index), alignment)
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # ● 選択項目の有効状態を取得
  853.   #--------------------------------------------------------------------------
  854.   def current_item_enabled?
  855.     return (item == nil ? true : item.equip_state[2] != Vocab::Equip_Break)
  856.   end
  857.   #--------------------------------------------------------------------------
  858.   # ● 決定ボタンが押されたときの処理
  859.   #--------------------------------------------------------------------------
  860.   def process_ok
  861.     if current_item_enabled?
  862.       Sound.play_ok
  863.       Input.update
  864.       deactivate
  865.       call_ok_handler
  866.     else
  867.       Sound.play_buzzer
  868.       activate
  869.     end
  870.   end
  871.   #--------------------------------------------------------------------------
  872.   # ● SHIFTボタンが押されたときの処理
  873.   #--------------------------------------------------------------------------
  874.   def process_shift
  875.     if wp_skill_enabled?
  876.       select(@index)
  877.       Sound.play_ok
  878.       Input.update
  879.       deactivate
  880.       call_handler(:wp_skill)
  881.     else
  882.       Sound.play_buzzer
  883.       activate
  884.     end
  885.   end
  886. end
  887. end#$ed_rgss3["ed_equip_extension"]




RUBY 代码复制
  1. #==============================================================================
  2. #    ☆VXAce RGSS3 「個別装備アイテム:Scene」☆
  3. #      EnDlEss DREamER
  4. #     URL:[url]http://mitsu-evo.6.ql.bz/[/url]
  5. #     製作者 mitsu-evo
  6. #     Last:2014/4/22
  7. #   武器防具1個ずつに耐久度や弾数・改造度などを設定する。
  8. #     ▼ 「個別装備アイテム:設定」「Game」「Window」「Scene」の順で導入
  9. #==============================================================================
  10.  
  11. #==============================================================================
  12. # ■ Scene_Shop
  13. #------------------------------------------------------------------------------
  14. #  ショップ画面の処理を行うクラスです。
  15. #==============================================================================
  16.  
  17. class Scene_Shop < Scene_MenuBase
  18.  
  19.   #--------------------------------------------------------------------------
  20.   # ● 売却の実行
  21.   #--------------------------------------------------------------------------
  22.   alias ed_weapon_count_do_sell do_sell
  23.   def do_sell(number)
  24.     ed_weapon_count_do_sell(number)
  25.     repair(number)
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 最大売却可能個数の取得
  29.   #--------------------------------------------------------------------------
  30.   def max_sell
  31.     # 武器防具なら1個ずつ売却していく。
  32.     return 1 if @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
  33.     return $game_party.item_number(@item)
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 売却時に装備を回復しておく
  37.   #--------------------------------------------------------------------------
  38.   def repair(number)
  39.     items = @item.is_a?(RPG::Weapon) ?
  40.     $game_party.weapons[@item.id] : $game_party.armors[@item.id]
  41.     unless @item.ed_item_key == nil
  42.       # 指定アイテムがキーを保持しているなら優先処理
  43.       @item.param_save_load(false)
  44.       @item.initialize_add_params
  45.       return
  46.     end
  47.     # キーを保持していない場合の処理は末尾のアイテムから処理。
  48.     item_number = items.size
  49.     min = item_number - number
  50.     # 最大所持数から売却個数を引いて残りを算出。所持最大数から最小まで処理。
  51.     item_number.downto(min){|num|
  52.     eq = item[num]
  53.     next if eq == nil
  54.     eq.param_save_load(false)
  55.     eq.initialize_add_params }
  56.   end
  57. end
  58. #==============================================================================
  59. # ■ Scene_ItemBase
  60. #------------------------------------------------------------------------------
  61. #  アイテム画面とスキル画面の共通処理を行うクラスです。
  62. #==============================================================================
  63.  
  64. class Scene_ItemBase < Scene_MenuBase
  65.  
  66.   #--------------------------------------------------------------------------
  67.   # ● アイテムをアクターに対して使用
  68.   #--------------------------------------------------------------------------
  69.   def use_item_to_actors
  70.     item_target_actors.each do |target|
  71.       item.repeats.times { target.item_apply(user, item)
  72.       item_repair(target)
  73.       item_weapon_repair(target) }
  74.     end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 修理の実行
  78.   #--------------------------------------------------------------------------
  79.   def item_repair(target)
  80.     # ターゲットがアクターでないなら処理を中断
  81.     return unless target.is_a?(Game_Actor)
  82.     e_item = item.note.scan(/<修理>/)
  83.     e_item.flatten!#配列をフラットにする[1,[2]]を[1,2]へ
  84.     unless e_item == nil or e_item.empty?
  85.       # 修理アイテムなら壊れていない装備の耐久力を元に戻す。
  86.       target.equips.each{|item| item.durability_repair}
  87.     end
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● アイテムによる武器回数回復の実行
  91.   #--------------------------------------------------------------------------
  92.   def item_weapon_repair(target)
  93.     e_item = item.note.scan(/<武器回復[::](0|-?\d+),(\d+)>/)
  94.     e_item.flatten!#配列をフラットにする[1,[2]]を[1,2]へ
  95.     unless e_item == nil or e_item.empty?
  96.       weapon_id = e_item[0].to_i          # メモ欄の武器ID
  97.       weapon_index = e_item[1].to_i       # メモ欄の装備ヶ所
  98.  
  99.       # 同じ武器が装備中かどうかチェック
  100.       i = 0    # 装備ヶ所
  101.       for equip in target.weapons
  102.         # 武器IDが同じで装備ヶ所も同じなら回復処理
  103.         if equip.id == weapon_id and i == weapon_index
  104.           equip.weapon_repair(item.base_damage)
  105.           return true
  106.         elsif weapon_id == -1 and i == weapon_index
  107.           # 武器ID指定がないなら指定量だけ装備ヶ所の武器回数を回復
  108.           equip.weapon_repair(item.damage)
  109.           return true
  110.         end
  111.         i += 1
  112.       end
  113.     end
  114.     return false
  115.   end
  116. end
  117.  
  118. #==============================================================================
  119. # ■ Scene_Battle
  120. #------------------------------------------------------------------------------
  121. #  バトル画面の処理を行うクラスです。
  122. #==============================================================================
  123.  
  124. class Scene_Battle < Scene_Base
  125.   #--------------------------------------------------------------------------
  126.   # ● 武器スロット選択判定(エネミー専用)
  127.   #--------------------------------------------------------------------------
  128.   def use_slot_attack?(item)
  129.     return false unless item
  130.     return false unless item.is_a?(RPG::Skill)
  131.     return false if @subject.actor?
  132.     return false if @subject.using_weapon == nil
  133.     return true if item.ed_slot_attack?
  134.     if @subject.using_weapon.weapon_atk_count == 0
  135.       # 選択スロットの武器使用回数が0の場合はメイン武器を使用する。
  136.       @subject.select_weapon = 0
  137.       @subject.set_attack
  138.       return false
  139.     end
  140.     return false
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● スキル/アイテムの使用
  144.   #--------------------------------------------------------------------------
  145.   alias ed_weapon_count_use_item use_item
  146.   def use_item
  147.     ed_weapon_count_use_item
  148.     index = $ed_rgss3["ed_equip_extension"] ? @subject.select_weapon : 0
  149.     item = @subject.current_action.item
  150.     weapon_count_attack(item)
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 個別装備武器攻撃処理
  154.   #--------------------------------------------------------------------------
  155.   def weapon_count_attack(item)
  156.     # アイテムか防御ならば武器回数消費を行わない。
  157.     # スキルの場合はスキル使用でも回数を消費する。
  158.     flag = use_slot_attack(item) if $ed_rgss3["ed_equip_extension"]
  159.     flag = false if item.is_a?(RPG::Item) or @subject.current_action.guard?
  160.     @subject.use_weapon unless flag
  161.   end
  162. end
  163. #==============================================================================
  164. # ■ Scene_Repair
  165. #------------------------------------------------------------------------------
  166. #  武器回数や耐久力回復の処理を行うクラスです。
  167. #==============================================================================
  168. class Scene_Repair < Scene_MenuBase
  169.  
  170.   #--------------------------------------------------------------------------
  171.   # ● 準備
  172.   #--------------------------------------------------------------------------
  173.   def prepare(atk_count=true)
  174.     @atk_count = atk_count # 武器回数が有効か?無効なら耐久力回復
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ● 開始処理
  178.   #--------------------------------------------------------------------------
  179.   def start
  180.     super
  181.     create_help_window
  182.     create_gold_window
  183.     create_command_window
  184.     create_dummy_window
  185.     create_name_window
  186.     create_number_window
  187.     create_slot_window
  188.     create_status_window
  189.     create_repair_window
  190.     create_choice_window
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● アクターの名前ウィンドウの作成
  194.   #--------------------------------------------------------------------------
  195.   def create_name_window
  196.     wx = Graphics.width - @gold_window.width
  197.     wy = @help_window.height
  198.     ww = Graphics.width - @command_window.width
  199.     wh = @gold_window.height
  200.     @name_window = Window_ActorName.new(wx, wy, ww, wh, @actor)
  201.     @name_window.viewport = @viewport
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● ゴールドウィンドウの作成
  205.   #--------------------------------------------------------------------------
  206.   def create_gold_window
  207.     @gold_window = Window_Gold.new
  208.     @gold_window.viewport = @viewport
  209.     @gold_window.x = Graphics.width - @gold_window.width
  210.     @gold_window.y = Graphics.height - @gold_window.height
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 修復決定ウィンドウの作成
  214.   #--------------------------------------------------------------------------
  215.   def create_choice_window
  216.     wx = 0
  217.     wy = Graphics.height - @gold_window.height
  218.     ww = Graphics.width - @gold_window.width
  219.     @choice_window =  Window_YesNoCommand.new(wx, wy, ww)
  220.     @choice_window.set_handler(:ok,   method(:on_repair_ok))
  221.     @choice_window.set_handler(:cancel, method(:on_repair_cancel))
  222.     @choice_window.hide.deactivate
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● コマンドウィンドウの作成
  226.   #--------------------------------------------------------------------------
  227.   def create_command_window
  228.     @command_window = Window_WeaponRepairCommand.new(@gold_window.x, @purchase_only)
  229.     @command_window.viewport = @viewport
  230.     @command_window.y = @help_window.height
  231.     @command_window.set_handler(:all,    method(:command_full_repair))
  232.     @command_window.set_handler(:select,   method(:command_slot_repair))
  233.     @command_window.set_handler(:cancel, method(:return_scene))
  234.     @command_window.set_handler(:pagedown, method(:next_actor))
  235.     @command_window.set_handler(:pageup,   method(:prev_actor))
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● ダミーウィンドウの作成
  239.   #--------------------------------------------------------------------------
  240.   def create_dummy_window
  241.     wy = @command_window.y + @command_window.height
  242.     wh = Graphics.height - wy - @gold_window.height
  243.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  244.     @dummy_window.viewport = @viewport
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● 個数入力ウィンドウの作成
  248.   #--------------------------------------------------------------------------
  249.   def create_number_window
  250.     wy = @dummy_window.y
  251.     wh = @dummy_window.height
  252.     @number_window = Window_RepairShopNumber.new(0, wy, wh)
  253.     @number_window.viewport = @viewport
  254.     @number_window.hide
  255.     @number_window.set_handler(:ok,     method(:on_number_ok))
  256.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 修復ウィンドウの作成
  260.   #--------------------------------------------------------------------------
  261.   def create_repair_window
  262.     # 装備修復ウィンドウも作成。
  263.     wy = @dummy_window.y
  264.     wh = @dummy_window.height
  265.     @repair_window = Window_Repair.new(0,wy,wh,@actor, @atk_count)
  266.     @repair_window.viewport = @viewport
  267.     @repair_window.hide
  268.     @repair_window.number_window = @number_window
  269.     @repair_window.slot_window = @slot_window
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● ステータスウィンドウの作成
  273.   #--------------------------------------------------------------------------
  274.   def create_status_window
  275.     wx = @slot_window.width
  276.     wy = @dummy_window.y
  277.     @status_window = Window_Equip_Contents_Custom.new(wx, wy)#, ww, wh)
  278.     @status_window.viewport = @viewport
  279.     @status_window.hide
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # ● 装備スロットウィンドウの作成
  283.   #--------------------------------------------------------------------------
  284.   def create_slot_window
  285.     wx = @number_window.width
  286.     ww = Graphics.width
  287.     wy = @dummy_window.y
  288.     @slot_window = Window_RepairEquipSlot.new(0, wy, ww, @atk_count)#wh, @goods)
  289.     @slot_window.actor = @actor
  290.     @slot_window.viewport = @viewport
  291.     @slot_window.help_window = @help_window
  292.     @slot_window.status_window = @status_window
  293.     @slot_window.hide
  294.     @slot_window.set_handler(:ok,     method(:on_slot_repair_ok))
  295.     @slot_window.set_handler(:cancel, method(:on_slot_repair_cancel))
  296.     @slot_window.set_handler(:pagedown, method(:next_actor))
  297.     @slot_window.set_handler(:pageup,   method(:prev_actor))
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● 装備スロットウィンドウのアクティブ化
  301.   #--------------------------------------------------------------------------
  302.   def activate_slot_window
  303.     @slot_window.show.activate
  304.     @status_window.show
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ● ウィンドウの非アクティブ化
  308.   #--------------------------------------------------------------------------
  309.   def deactivate_all_window
  310.     @gold_window.refresh
  311.     @status_window.refresh
  312.     @slot_window.hide.deactivate
  313.     @number_window.hide.deactivate
  314.     @repair_window.hide.deactivate
  315.     @choice_window.hide.deactivate
  316.     @command_window.activate
  317.     @help_window.clear
  318.     @number_window.hide
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● コマンド[全武装満タン]
  322.   #--------------------------------------------------------------------------
  323.   def command_full_repair
  324.     @dummy_window.hide
  325.     activate_full_repair_window
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # ● コマンド[個別に回復]
  329.   #--------------------------------------------------------------------------
  330.   def command_slot_repair
  331.     @dummy_window.hide
  332.     @slot_window.show.activate
  333.     @slot_window.select(0)
  334.     @repair_window.all_repair = false
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 個別回復スロット[決定]
  338.   #--------------------------------------------------------------------------
  339.   def on_slot_repair_ok
  340.     @item = @slot_window.item
  341.     if max_atk_count == 0 or @item == nil
  342.       Sound.play_buzzer
  343.       @dummy_window.show
  344.       @slot_window.hide.deactivate
  345.       @command_window.activate
  346.       return
  347.     end
  348.     if @atk_count
  349.       @number_window.set(@item, max_atk_count, buying_price, currency_unit)
  350.       @number_window.show.activate
  351.     else
  352.       on_number_ok
  353.     end
  354.     @slot_window.hide.deactivate
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ● 個別回復スロット[キャンセル]
  358.   #--------------------------------------------------------------------------
  359.   def on_slot_repair_cancel
  360.     @command_window.activate
  361.     @dummy_window.show
  362.     @slot_window.hide.deactivate
  363.     @status_window.hide
  364.     @help_window.clear
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ● 個数入力[決定]
  368.   #--------------------------------------------------------------------------
  369.   def on_number_ok
  370.     case @command_window.current_symbol
  371.     when :select
  372.       @slot_window.hide.deactivate
  373.       @repair_window.number
  374.       @repair_window.show
  375.       @repair_window.unselect
  376.       @choice_window.show.activate
  377.     end
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ● 個数入力[キャンセル]
  381.   #--------------------------------------------------------------------------
  382.   def on_number_cancel
  383.     Sound.play_cancel
  384.     end_number_input
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 個数入力の終了
  388.   #--------------------------------------------------------------------------
  389.   def end_number_input
  390.     @number_window.hide
  391.     case @command_window.current_symbol
  392.     when :all
  393.       activate_full_repair_window
  394.     when :select
  395.       activate_slot_window
  396.     end
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● 修復ウィンドウ[決定]
  400.   #--------------------------------------------------------------------------
  401.   def on_repair_ok
  402.     if @repair_window.price == 0
  403.       Sound.play_buzzer
  404.       deactivate_all_window
  405.       return
  406.     end
  407.     Sound.play_shop
  408.     case @command_window.current_symbol
  409.     when :all
  410.       do_all_repair
  411.     when :select
  412.       do_repair(@number_window.number)
  413.     end
  414.     deactivate_all_window
  415.   end
  416.   #--------------------------------------------------------------------------
  417.   # ● 修復ウィンドウ[キャンセル]
  418.   #--------------------------------------------------------------------------
  419.   def on_repair_cancel
  420.     #Sound.play_cancel
  421.     @repair_window.clear_list
  422.     @repair_window.hide.deactivate
  423.     case @command_window.current_symbol
  424.     when :all
  425.       on_slot_repair_cancel
  426.       @choice_window.hide.deactivate
  427.     when :select
  428.       on_slot_repair_ok
  429.       @repair_window.hide.deactivate
  430.       @choice_window.hide.deactivate
  431.       end_number_input
  432.     end
  433.     @dummy_window.show
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 個別回復の実行
  437.   #--------------------------------------------------------------------------
  438.   def do_repair(number=0)
  439.  
  440.     $game_party.lose_gold(number * buying_price)
  441.     if @atk_count
  442.       @item.weapon_atk_count += number
  443.       if @item.weapon_atk_count > @item.weapon_atk_count_max
  444.         @item.weapon_atk_count = @item.weapon_atk_count_max
  445.       end
  446.     else
  447.       # 耐久力
  448.       @item.durability_repair
  449.     end
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● 全回復の実行
  453.   #--------------------------------------------------------------------------
  454.   def do_all_repair
  455.     if @atk_count
  456.       do_weapon_atk_all_repair
  457.     else
  458.       do_durability_all_repair
  459.     end
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● コマンド選択画面で全員満タンを選択した時
  463.   #--------------------------------------------------------------------------
  464.   def activate_full_repair_window
  465.     @repair_window.show
  466.     @repair_window.unselect
  467.     @choice_window.show.activate
  468.     @repair_window.all_repair = true
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● 全武装回数回復処理
  472.   #--------------------------------------------------------------------------
  473.   def do_weapon_atk_all_repair
  474.     @actor.weapons.each do |item|
  475.       next unless item
  476.       item.weapon_repair end
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ● 全装備耐久力回復処理
  480.   #--------------------------------------------------------------------------
  481.   def do_durability_all_repair
  482.     @actor.equips.each do |item|
  483.       next unless item
  484.       item.durability_repair end
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● 最大購入可能個数の取得
  488.   #--------------------------------------------------------------------------
  489.   def max_buy
  490.     max = @item == nil ? 0 : @item.weapon_atk_count_max
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● 最大回復弾数
  494.   #--------------------------------------------------------------------------
  495.   def max_atk_count
  496.     return -1 unless @atk_count
  497.     max = @item == nil ? 0 : @item.weapon_atk_count_max
  498.     max -= @item == nil ? 0 : @item.weapon_atk_count
  499.     return max
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # ● 所持金の取得
  503.   #--------------------------------------------------------------------------
  504.   def money
  505.     @gold_window.value
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ● 通貨単位の取得
  509.   #--------------------------------------------------------------------------
  510.   def currency_unit
  511.     @gold_window.currency_unit
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ● 買値の取得
  515.   #--------------------------------------------------------------------------
  516.   def buying_price
  517.     @item == nil ? 0 : @item.weapon_atk_count_price
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ● アクターの切り替え
  521.   #--------------------------------------------------------------------------
  522.   def on_actor_change
  523.     @slot_window.actor = @actor
  524.     @name_window.actor = @actor
  525.     @repair_window.clear_list
  526.     @repair_window.actor = @actor
  527.     deactivate_all_window
  528.   end
  529. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2025-7-24 05:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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