Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI More Battle Scope
- # -- Last Updated: 2017.07.27
- # -- Author: dsiver144
- # -- Level: Easy
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-MoreBattleScope"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.07.27 - Finish first version.
- # 2017.08.09 - Add compalibity with Yanfly Custom Scope.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼Materials but above ▼Main. Remember to save.
- # * You should put this script below all script relate to drawing enemy state
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Skill's, Item's Notetags:
- # + <scope: random ally>
- # + <scope: random all but user>
- # + <scope: all but user>
- #==============================================================================
- module DSIVER144
- module BATTLE_SCOPE
- REGEXP = /<scope:\s*(.+)>/i
- end # BATTLE_SCOPE
- end # DSIVER144
- class Game_System
- alias_method(:load_notetag_item_skills, :initialize)
- def initialize
- ($data_items+$data_skills).each do |item|
- next if item.nil?
- item.load_scope_notetags
- end
- load_notetag_item_skills
- end
- end # Game_System
- class RPG::UsableItem < RPG::BaseItem
- include DSIVER144::BATTLE_SCOPE
- #--------------------------------------------------------------------------
- # * new method: load_scope_notetags
- #--------------------------------------------------------------------------
- def load_scope_notetags
- @dsi_scope = :none
- if self.note =~ REGEXP
- if $1 == "random ally"
- @dsi_scope = :random_ally
- end
- if $1 == "random all but user"
- @dsi_scope = :random_all_but_user
- end
- if $1 == "all but user"
- @dsi_scope = :all_but_user
- end
- end
- end
- #--------------------------------------------------------------------------
- # * new method: is_custom_scope?
- #--------------------------------------------------------------------------
- def is_custom_scope?
- return @dsi_scope != :none
- end
- #--------------------------------------------------------------------------
- # * new method: is_random_ally?
- #--------------------------------------------------------------------------
- def is_random_ally?
- @dsi_scope == :random_ally
- end
- #--------------------------------------------------------------------------
- # * new method: is_random_all_but_user?
- #--------------------------------------------------------------------------
- def is_random_all_but_user?
- @dsi_scope == :random_all_but_user
- end
- #--------------------------------------------------------------------------
- # * new method: is_random_all_but_user?
- #--------------------------------------------------------------------------
- def is_all_but_user?
- @dsi_scope == :all_but_user
- end
- end # RPG::UsableItem
- class Game_Action
- #--------------------------------------------------------------------------
- # * Create Target Array
- #--------------------------------------------------------------------------
- alias_method(:dsi_game_action_make_targets, :make_targets)
- def make_targets
- if !forcing && subject.confusion?
- targets = [confusion_target]
- elsif item.is_custom_scope?
- targets = make_custom_targets
- else
- targets = dsi_game_action_make_targets
- end
- return targets
- end
- #--------------------------------------------------------------------------
- # * new method: make_custom_targets
- #--------------------------------------------------------------------------
- alias_method(:dsi_make_custom_targets, :make_custom_targets)
- def make_custom_targets
- target = []
- if item.is_random_ally?
- target << friends_unit.random_target_ex(subject)
- target.compact!
- end
- if item.is_random_all_but_user?
- if rand(3) == 1
- target << opponents_unit.random_target
- else
- target << friends_unit.random_target_ex(subject)
- end
- end
- if item.is_all_but_user?
- target = opponents_unit.alive_members + friends_unit.other_members(subject)
- end
- return target + dsi_make_custom_targets()
- end
- end # Game_Action
- class Game_Unit
- #--------------------------------------------------------------------------
- # * new method: random_target_ex
- #--------------------------------------------------------------------------
- def random_target_ex(subject)
- rand_array = other_members(subject)
- rand_array[0]
- end
- #--------------------------------------------------------------------------
- # * new method: other_members
- #--------------------------------------------------------------------------
- def other_members(subject)
- return (alive_members - [subject]).shuffle
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement