=begin RGSS3 ★ ドロップアイテム数制限 ★ 対象の敵がドロップすることのできるアイテムの数に制限をかけます。 ● 使い方 ●======================================================== 敵キャラのメモ欄に「ドロップ制限:」と記述。 -------------------------------------------------------------------- 【例1】 ドロップ制限:<3> と記述されている場合、その敵はドロップアイテムの 1つ目に設定されているアイテムを計3個 までしか落とさなくなります。 -------------------------------------------------------------------- 【例2】 ドロップ制限:<4,10> と記述されている場合、その敵はドロップアイテムの 1つ目に設定されているアイテムを計4個 2つ目に設定されているアイテムを計10個 までしか落とさなくなります。 -------------------------------------------------------------------- 敵キャラ毎ではなくゲーム全体でのドロップアイテム数に 制限をかけたい場合は、設定箇所を利用してください。 ==================================================================== ● 注意 ●========================================================== ニューゲームから始めないとエラーを吐きます。 ==================================================================== ver1.00 Last Update : 2012/05/13 05/13 : 新規 ろかん   http://kaisou-ryouiki.sakura.ne.jp/ =end #=========================================== # 設定箇所 #=========================================== module Drop_Restriction # ゲーム全体でのドロップ制限 #【形式】 # ① => ②, # ① アイテムのID(数値) # ② ドロップ制限数(数値) # #【設定例】ID:1のアイテムがゲーム中に計3個ドロップされた場合、 # ID:1のアイテムはドロップされなくなる。 # RES_I = { # 1 => 3, # } # アイテム RES_I = { } # 武器 RES_W = { } # 防具 RES_A = { } end #=========================================== # ここまで #=========================================== $rsi ||= {} $rsi["ドロップアイテム制限"] = true class RPG::Enemy < RPG::BaseItem def get_drop_restriction result = [-1, -1, -1] match = self.note.scan(/ドロップ制限:<(.*)>/) if match.first match.first.first.split(",").each_with_index{|rest, index| result[index] = rest.to_i } end result end end module DataManager def self.get_item_kind(item) case item when RPG::Item 1 when RPG::Weapon 2 when RPG::Armor 3 end end end class Game_System #-------------------------------------------------------------------------- # ● インクルード Drop_Restriction #-------------------------------------------------------------------------- include Drop_Restriction #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :drop_restriction # ドロップアイテム管理 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias drop_restriction_initialize initialize def initialize drop_restriction_initialize @drop_restriction = {} set_public_drop_restriction end #-------------------------------------------------------------------------- # ● ゲーム全体でのドロップ制限を初期化 #-------------------------------------------------------------------------- def set_public_drop_restriction @drop_restriction[-1] = {1 => {}, 2 => {}, 3 => {}} RES_I.each_pair{|id, rest| @drop_restriction[-1][1][id] = [rest, 0] } RES_W.each_pair{|id, rest| @drop_restriction[-1][2][id] = [rest, 0] } RES_A.each_pair{|id, rest| @drop_restriction[-1][3][id] = [rest, 0] } end end class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● ドロップアイテムの配列作成 #-------------------------------------------------------------------------- alias drop_restriction_make_drop_items make_drop_items def make_drop_items result = drop_restriction_make_drop_items unless $game_system.drop_restriction[@enemy_id] make_drop_restriction end result.dup.each{|item| kind = DataManager.get_item_kind(item) if $game_system.drop_restriction[-1][kind].has_key?(item.id) a = $game_system.drop_restriction[-1][kind][item.id][0] b = $game_system.drop_restriction[-1][kind][item.id][1] if a == b result.delete(item) next else $game_system.drop_restriction[-1][kind][item.id][1] += 1 end end if $game_system.drop_restriction[@enemy_id][kind].has_key?(item.id) a = $game_system.drop_restriction[@enemy_id][kind][item.id][0] b = $game_system.drop_restriction[@enemy_id][kind][item.id][1] if a == b result.delete(item) else $game_system.drop_restriction[@enemy_id][kind][item.id][1] += 1 end end } result end #-------------------------------------------------------------------------- # ● ドロップ制限情報の作成 #-------------------------------------------------------------------------- def make_drop_restriction result = {1 => {}, 2 => {}, 3 => {}} rest = enemy.get_drop_restriction enemy.drop_items.each_with_index{|drop_data, index| unless drop_data.kind.zero? result[drop_data.kind][drop_data.data_id] = [rest[index], 0] end } $game_system.drop_restriction[@enemy_id] = result end end