#////////////////////////////////////////////////////////////////////////////// #/// #/// ・FSM様FSG_TargetLimitItem追加機能スクリプト 更新 2011/9/26 #/// 作者 RRR http://oniwakachildren.web.fc2.com/index.html #////////////////////////////////////////////////////////////////////////////// #/// #/// ● FSM様のFSG_TargetLimitItemスクリプトの追加機能です。 #/// アクター、職業に加え、対象のレベルも使用可能判定に含めます。 #/// #/// #/// ◇ 大まかな使い方の説明は省きます。 #/// 追加機能の記述の仕方は以下の通りです。 #/// # 例 1) Lv5以上のアクターが使用可能なアイテム => *TARGET[L5] # 例 2) ID 2 のアクターがLv10以上で使用可能なアイテム => *TARGET[A2|L10] #/// #////////////////////////////////////////////////////////////////////////////// #============================================================================== # ★ FSG_TargetLimitItem ver 0.21β #------------------------------------------------------------------------------ #  アイテムの使用対象者を制限できるようにするスクリプト素材です。 #------------------------------------------------------------------------------ # ※ FSG_LearnSkillItem より下に導入してください。 #============================================================================== #▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽ module FSG module TargetLimitItem # ▼ 使用対象者をするアイテムの指定用文字列 # [メモ] に、指定用文字列 + [A + アクター ID / C + 職業 ID] が含まれている # アイテムを、指定したアクターまたは職業にのみ使用可能なアイテムとして扱います。 # [効果範囲] は [味方単体] とします。 # 例 1) ID 2 のアクターにのみ使用可能なアイテム => *TARGET[A2] # 例 2) ID 3 〜 5 の職業にのみ使用可能なアイテム => *TARGET[C3|C4|C5] # 例 3) ID 2 のアクターと ID 4 の職業にのみ使用可能なアイテム => *TARGET[A2|C4] SIGNATURE = "*TARGET" # ▼ 使用対象が制限されていた場合のメッセージ # メッセージを表示しない場合は "" を指定してください。 VOCAB_DISABLED = "%sには効果がなかった!" end end #▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽ module FSG # スクリプト導入フラグ RGSS = {} unless defined?(RGSS) RGSS["TargetLimitItem"] = 0.21 end #============================================================================== # □ FSG::Regexp #============================================================================== module FSG::Regexp module TargetLimitItem # 使用対象者 SIG = /#{Regexp.quote FSG::TargetLimitItem::SIGNATURE}\[(((A|C|L)\d+\|?)+)\]/ #↑追加部分 |Lを追加 end end #============================================================================== # □ FSG::Vocab #============================================================================== module FSG::Vocab module TargetLimitItem # 使用対象者 DISABLED = FSG::TargetLimitItem::VOCAB_DISABLED end end #〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 #============================================================================== # ■ RPG::Item #============================================================================== class RPG::Item < RPG::UsableItem #------------------------------------------------------------------------ # ☆ 使用対象者情報の準備 #------------------------------------------------------------------------ def fsg_prepare_target_limit @fsg_targetable_actor_ids = [] if @fsg_targetable_actor_ids.nil? @fsg_targetable_class_ids = [] if @fsg_targetable_class_ids.nil? @fsg_targetable_level_ids = 0 if @fsg_targetable_level_ids.nil?#追加部分 if @fsg_targetable_actor_ids.empty? or @fsg_targetable_class_ids.empty? or @fsg_targetable_level_ids.nil? #↑追加部分 #ここをempty?からnil?にした if @note[FSG::Regexp::TargetLimitItem::SIG].to_a[0] for s in $1.split(/\s*\|\s*\|\s*/)#追加部分 \|\s*/ case s when /A(\d+)/ @fsg_targetable_actor_ids.push($1.to_i) when /C(\d+)/ @fsg_targetable_class_ids.push($1.to_i) when /L(\d+)/ #追加部分 @fsg_targetable_level_ids = $1.to_i #追加部分 end end end end end #------------------------------------------------------------------------ # ☆ 使用対象者の判定 # target : 使用対象者 #------------------------------------------------------------------------ def fsg_effective?(target) return true unless target.is_a?(Game_Actor) # アクター以外は制限しない fsg_prepare_target_limit unless @fsg_targetable_actor_ids.empty? return true if @fsg_targetable_actor_ids.include?(target.id) return false end unless @fsg_targetable_class_ids.empty? return true if @fsg_targetable_class_ids.include?(target.class_id) return false end #↓ここから #unless @fsg_targetable_level_ids.nil? #ここをempty?からnil?にした unless @fsg_targetable_level_ids.nil? return true if @fsg_targetable_level_ids <= target.level return false end #↑ここまで追加 return true end end #〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ○ アイテムの適用テスト # user : アイテムの使用者 # item : アイテム #-------------------------------------------------------------------------- alias _FSG_TargetLimitItem_item_test item_test def item_test(user, item) return false unless item.fsg_effective?(user) return _FSG_TargetLimitItem_item_test(user, item) end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ○ 対象アクター選択の更新 #-------------------------------------------------------------------------- alias _FSG_TargetLimitItem_update_target_actor_selection update_target_actor_selection def update_target_actor_selection if Input.trigger?(Input::C) and @active_battler.action.item? user = $game_party.members[@target_actor_window.index] unless @item_window.item.fsg_effective?(user) Sound.play_buzzer return end end _FSG_TargetLimitItem_update_target_actor_selection end #-------------------------------------------------------------------------- # ● 戦闘行動の実行 : アイテム #-------------------------------------------------------------------------- def execute_action_item item = @active_battler.action.item text = sprintf(Vocab::UseItem, @active_battler.name, item.name) @message_window.add_instant_text(text) targets = @active_battler.action.make_targets display_animation(targets, item.animation_id) $game_party.consume_item(item) $game_temp.common_event_id = item.common_event_id for target in targets if @active_battler.item_test(target, item) target.item_effect(@active_battler, item) display_action_effects(target, item) else next if FSG::Vocab::TargetLimitItem::DISABLED == "" text = sprintf(FSG::Vocab::TargetLimitItem::DISABLED, target.name) @message_window.add_instant_text(text) wait(30) end end end end