Invité
| Sujet: [VX] Objet utilisable seulement par un/des persos en combat (compatible SBS) Ven 30 Mar 2012 - 20:03 | |
| Bonjour/bonsoir, Il y a quelque temps j'avais demandé un script pour une utilisation d'objet seulement par un ou des persos en combat. S4suk3 en avait fais un qui fonctionne bien mais qui n'est malheureusement pas compatible avec le SBS (chez moi en tout cas). Ne voulant pas trop le déranger encore et encore j'ai fais mes propres recherches en Anglais. Alors voiçi un script qui le permettra en combat. Un script de : Mythran - Code:
-
# Exclude an actor or class from an item effect # By Mithran # Please do not resdistribute without asking! # This restricts item usage of actors. # In battle, this prevents any excluded actors or classes from using or being # targeted by the item. # In the menu screen, this will prevent the item from being used at all if none # of the targets can be affected by it.
# Type <NO ACTOR n> in the notes field of an item where n is the actor id of # the actor you want to exclude from the item effect # Type <REQ ACTOR n> in the notes field of an item where n is the actor id of # the actor you want to REQUIRE for the item effect # Seperate multiple actor ids with commas
# Example: # <NO ACTOR 1, 2, 4> # The item would have no effect on Ralph, Ulrika, and Ylva. # <REQ ACTOR 3> # The item would only effect Bennett.
# Type <NO CLASS n> in the notes field of an item where n is the class id of # the class you want to exclude from the item effect # Type <REQ CLASS n> in the notes field of an item where n is the class id of # the class you want to REQUIRE for the item effect # Seperate class actor ids with commas
# <NO CLASS 1, 3> # The item would have no effect on Paladins or Priests. # <REQ CLASS 6> # The item would only affect Dark Knights.
# If you restrict by both actor and class, BOTH will be required to get the item # to work.
# ALL CAPS is required for these note tags
class Game_Battler alias item_effect_exclude_actor item_effect def item_effect(user, item) if actor? if item.exclude_actor(self) clear_action_results if $game_temp.in_battle @missed = true # so the failure message will display else @skipped = true # so the item will buzz and not be consumed end return end end item_effect_exclude_actor(user, item) end end class RPG::Item def actor_exclude_list if note =~ /<NO\s?ACTOR\s?(\d+(,\s*\d+)?)>/ x = $1.scan(/\d+/) result = [] x.each_index { |i| result[i] = x[i].to_i } return result else return [] end end
def class_exclude_list if note =~ /<NO\s?CLASS\s?(\d+(,\s*\d+)?)>/ x = $1.scan(/\d+/) result = [] x.each_index { |i| result[i] = x[i].to_i } return result else return [] end end def actor_require_list if note =~ /<REQ\s?ACTOR\s?(\d+(,\s*\d+)?)>/ x = $1.scan(/\d+/) result = [] x.each_index { |i| result[i] = x[i].to_i } return result else return [] end end
def class_require_list if note =~ /<REQ\s?CLASS\s?(\d+(,\s*\d+)?)>/ x = $1.scan(/\d+/) result = [] x.each_index { |i| result[i] = x[i].to_i } return result else return [] end end def exclude_actor(actor) return true if !actor.is_a?(Game_Actor) return actor_exclude_list.include?(actor.id) || class_exclude_list.include?(actor.class_id) || (!actor_require_list.empty? && !actor_require_list.include?(actor.id)) || (!class_require_list.empty? && !class_require_list.include?(actor.class_id)) end end
class Scene_Battle < Scene_Base alias update_item_selection_exclude_actor update_item_selection def update_item_selection actor = @active_battler actor = @commander if @commander $game_temp.acs_item_selector = actor if @item_window != nil && @item_window.item != nil && @item_window.item.exclude_actor(actor) && Input.trigger?(Input::C) Sound.play_buzzer $game_temp.acs_item_selector = nil return end update_item_selection_exclude_actor $game_temp.acs_item_selector = nil end alias start_item_selection_exclude_actor start_item_selection def start_item_selection actor = @active_battler actor = @commander if @commander $game_temp.acs_item_selector = actor start_item_selection_exclude_actor $game_temp.acs_item_selector = nil end alias update_target_actor_selection_exclude_actor update_target_actor_selection def update_target_actor_selection if @item_window != nil && @item_window.item != nil && Input.trigger?(Input::C) actor = $game_party.members[@target_actor_window.index] if @item_window.item.exclude_actor(actor) Sound.play_buzzer return end end update_target_actor_selection_exclude_actor end
end
class Window_Item < Window_Selectable alias enable_exclude_actor enable? def enable?(item) return false if item != nil && $game_temp.in_battle && item.exclude_actor($game_temp.acs_item_selector) return enable_exclude_actor(item) end end
class Game_Temp attr_accessor :acs_item_selector end |
|