Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================
- #
- # RESTRICT ITEM FOR ACTOR
- #
- # Mit diesem Script kann man bestimmte Items für bestimmte
- # Helden im Kampf nicht auswählbar machen. Man muss lediglich
- # bei dem entsprechenden Item einen Notetag mit der ID des
- # Helden einfügen.
- #
- # <restrict actor: id>
- #
- # Wenn man ein Item nur dann aus dem Menü heraus nutzen kann,
- # wenn ein bestimmter Held in der Gruppe ist, kann man hierfür
- # diesen Notetag nutzen:
- #
- # <needed actor: id>
- #
- # Falls ein Item nur auf einen bestimmten Helden genutzt werden
- # kann, dann wird dieser Notetag verwendet. ID Entspricht dem
- # Helden in der Datenbank:
- #
- # <only actor: id>
- #
- #==============================================================
- #==============================================================
- # * Initialize BaseItems
- #==============================================================
- module DataManager
- class << self
- alias :load_ffs_db_ri :load_database
- end
- def self.load_database
- load_ffs_db_ri
- load_ffsri_items
- end
- def self.load_ffsri_items
- groups = [$data_items]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_ffs_notetags_ri
- end
- end
- end
- end
- #==============================================================
- # * Content of Recycling Items
- #==============================================================
- class RPG::BaseItem
- attr_accessor :restricted_actors
- attr_accessor :needed_actors
- attr_accessor :only_actors
- def load_ffs_notetags_ri
- @restricted_actors = []
- @needed_actors = []
- @only_actors = []
- self.note.split(/[\r\n]+/).each do |line|
- # Restricts the Actor
- if line =~ /<restrict actor:([\d+,?\s*]+)>/i
- @restricted_actors.push($1.to_i)
- # Requires the Actor
- elsif line =~ /<needed actor:([\d+,?\s*]+)>/i
- @needed_actors.push($1.to_i)
- elsif line =~ /<only actor:([\d+,?\s*]+)>/i
- @only_actors.push($1.to_i)
- end
- end
- end
- end
- #==============================================================================
- # ** Window_ItemList
- #------------------------------------------------------------------------------
- # This window displays a list of party items on the item screen.
- #==============================================================================
- class Window_ItemList < Window_Selectable
- #--------------------------------------------------------------------------
- # * Display in Enabled State?
- #--------------------------------------------------------------------------
- alias :flip_itemList_enable :enable?
- def enable?(item)
- return true if item != nil && $game_party.members.include?(item.needed_actors)
- #~ return false if item != nil && !item.restricted_actors != [] && !$game_party.members.include?(item.needed_actors)
- return flip_itemList_enable(item)
- end
- end
- #==============================================================================
- # ** Window_BattleActor
- #------------------------------------------------------------------------------
- # This window is for selecting an actor's action target on the battle screen.
- #==============================================================================
- class Game_BattlerBase
- #--------------------------------------------------------------------------
- # * Determine Skill/Item Usability
- #--------------------------------------------------------------------------
- alias :usable_ffs_restrict_actor :usable?
- def usable?(item)
- return false if item.is_a?(RPG::Item) && item.restricted_actors.include?(@actor_id)
- return usable_ffs_restrict_actor(item)
- end
- end
- #==============================================================================
- # ** Game_Battler
- #------------------------------------------------------------------------------
- # A battler class with methods for sprites and actions added. This class
- # is used as a super class of the Game_Actor class and Game_Enemy class.
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # * Test Skill/Item Application
- # Used to determine, for example, if a character is already fully healed
- # and so cannot recover anymore.
- #--------------------------------------------------------------------------
- def item_test(user, item)
- if item.for_dead_friend?
- return hp == 0 if SceneManager.scene_is?(Scene_Item)
- return true
- end
- if item.is_a?(RPG::Item)
- return false if item.only_actors != [] && !item.only_actors.include?(self.id)
- end
- return true if $game_party.in_battle
- return true if item.for_opponent?
- return true if item.damage.recover? && item.damage.to_hp? && hp < mhp
- return true if item.damage.recover? && item.damage.to_mp? && mp < mmp
- return true if item_has_any_valid_effects?(user, item)
- return false
- end
- end
- #==============================================================================
- # ** Window_BattleItem
- #------------------------------------------------------------------------------
- # This window is for selecting items to use in the battle window.
- #==============================================================================
- class Window_BattleItem < Window_ItemList
- #--------------------------------------------------------------------------
- # * Include in Item List?
- #--------------------------------------------------------------------------
- def include?(item)
- return false if !item.is_a?(RPG::Item)
- return false if item != nil && (item.restricted_actors.include?(BattleManager.actor.id))
- $game_party.usable?(item)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement