#===============================================================================
# ** RGSS.Actor and Party Info
#===============================================================================
#-------------------------------------------------------------------------------
# * MACL Loading
#-------------------------------------------------------------------------------
if Object.const_defined?(:MACL)
 MACL::Loaded << 'RGSS.Actor and Party Info'
end
#===============================================================================
# ** Game_Actor
#===============================================================================
class Game_Actor < Game_Battler
 #-----------------------------------------------------------------------------
 # * Name    : Skill Scopes
 #  Info    : Returns an Array of scopes from all available skills
 #  Author   : Kain Nobel
 #  Call Info : None
 #-----------------------------------------------------------------------------
 def skill_scopes
  scopes = Array.new
  @skills.each do |skill_id|
   skill = $data_skills[skill_id]
   unless scopes.include?(skill.scope)
    scopes << skill.scope
   end
  end
  return scopes
 end
 #-----------------------------------------------------------------------------
 # * Name    : Skills With Scope?
 #  Info    : Returns true if at least one skill has a scope of 'scope'
 #  Author   : Kain Nobel
 #  Call Info : Scope is an Integer representing the scope in question
 #-----------------------------------------------------------------------------
 def skills_with_scope?(scope)
  self.skill_scopes.include?(scope)
 end
 #-----------------------------------------------------------------------------
 # * Name    : Skills With Scopes?
 #  Info    : Iterates over 'skills_with_scope?'
 #  Author   : Kain Nobel
 #  Call Info : An Array of scopes, see 'skills_with_scope?'
 #-----------------------------------------------------------------------------
 def skills_with_scopes?(*scopes)
  pool = Array.new
  scopes.each {|s| pool << skills_with_scope?(s)}
  return !pool.include?(false)
 end
 #-----------------------------------------------------------------------------
 # * Name    : Skills Without Scope?
 #  Info    : Returns true if no skills have a scope of 'scope'
 #  Author   : Kain Nobel
 #  Call Info : Scope is an Integer representing the scope in question
 #-----------------------------------------------------------------------------
 def skills_without_scope?(scope)
  !skills_with_scope?(scope)
 end
 #-----------------------------------------------------------------------------
 # * Name    : Skill Without Scopes?
 #  Info    : Iterates over 'skills_without_scope?'
 #  Author   : Kain Nobel
 #  Call Info : An Array of scopes, see 'skills_without_scope?'
 #-----------------------------------------------------------------------------
 def skills_without_scopes?(*scopes)
  !skills_with_scopes?(*scopes)
 end
end
Â
#===============================================================================
# ** Game_Party
#===============================================================================
Â
class Game_Party
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :knmacl_gmparty_initialize, :initialize
 #-----------------------------------------------------------------------------
 # * Object Initialization
 #-----------------------------------------------------------------------------
 def initialize
  knmacl_gmparty_initialize
  @items.default   = 0
  @armors.default  = 0
  @weapons.default  = 0
 end
 #-----------------------------------------------------------------------------
 # * Name    : Item Scopes
 #  Info    : Gets the scopes of all available items
 #  Author   : Kain Nobel
 #  Call Info : None
 #-----------------------------------------------------------------------------
 def item_scopes
  scopes = Array.new
  @items.each_key {|key|
  unless @items[key] == 0
   unless scopes.include?($data_items[key].scope)
    scopes << $data_items[key].scope
   end
  end}
  scopes
 end
 #-----------------------------------------------------------------------------
 # * Name    : Items With Scope?
 #  Info    : Returns true if at least one item has a scope of 'scope'
 #  Author   : Kain Nobel
 #  Call Info : Scope is an Integer representing the scope in question
 #-----------------------------------------------------------------------------
 def items_with_scope?(scope)
  self.item_scopes.include?(scope)
 end
 #-----------------------------------------------------------------------------
 # * Name    : Items With Scopes?
 #  Info    : Iterates over 'items_with_scope?'
 #  Author   : Kain Nobel
 #  Call Info : An Array of scopes, see 'items_with_scope?'
 #-----------------------------------------------------------------------------
 def items_with_scopes?(*scopes)
  pool = Array.new
  scopes.each {|s| pool << items_with_scope?(s)}
  return !pool.include?(false)
 end
 #-----------------------------------------------------------------------------
 # * Name    : Items Without Scope?
 #  Info    : Returns true if no items have a scope of 'scope'
 #  Author   : Kain Nobel
 #  Call Info : Scope is an Integer representing the scope in question
 #-----------------------------------------------------------------------------
 def items_without_scope?(scope)
  !items_with_scope?(scope)
 end
 #-----------------------------------------------------------------------------
 # * Name    : Items Without Scopes?
 #  Info    : Iterates over 'skills_without_scope?'
 #  Author   : Kain Nobel
 #  Call Info : An Array of scopes, see 'skills_without_scope?'
 #-----------------------------------------------------------------------------
 def items_without_scopes?(*scopes)
  !items_with_scopes?(*scopes)
 end
 #-----------------------------------------------------------------------------
 # * Name    : Gain All
 #  Info    : Gain all items (depending on type)
 #  Author   : Kain Nobel
 #  Call Info : Type is the type of 'item' to gain
 #         -1 : All Items, Weapons, Armors
 #          0 : All Items
 #          1 : All Weapons
 #          2 : All Armors
 #        Quantity is an integer from 1 to 99 (Optional)
 #-----------------------------------------------------------------------------
 def gain_all(type = -1, quantity = 99)
  if type.is_a?(Fixnum) && type.between?(-1, 2)
   case type
   when -1
    $data_items.each_index   {|i| gain_item(i, quantity.abs)}
    $data_weapons.each_index  {|i| gain_weapon(i, quantity.abs)}
    $data_armors.each_index  {|i| gain_armor(i, quantity.abs)}
   when 0 ; $data_items.each_index  {|i| gain_item(i, quantity.abs)}
   when 1 ; $data_weapons.each_index {|i| gain_weapon(i, quantity.abs)}
   when 2 ; $data_armors.each_index  {|i| gain_armor(i, quantity.abs)}
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Name    : Lose All
 #  Info    : Lose all items (depending on type)
 #  Author   : Kain Nobel
 #  Call Info : Type is the type of 'item' to lose
 #         -1 : All Items, Weapons, Armors
 #          0 : All Items
 #          1 : All Weapons
 #          2 : All Armors
 #        Quantity is an integer from 1 to 99 (Optional)
 #-----------------------------------------------------------------------------
 def lose_all(type, quantity = 99)
  quantity = -quantity.abs if quantity > 0
  gain_all(type, quantity)
 end
end
#===============================================================================
# ** AntiTarget
#===============================================================================
module AntiTarget
 #=============================================================================
 # ** AntiTarget::Actor
 #=============================================================================
 module Actor
  #---------------------------------------------------------------------------
  # * Untargetables : Actors which can't be targeted by enemies.
  #---------------------------------------------------------------------------
  Untargetables = []
  #---------------------------------------------------------------------------
  # * NoTargetActor : Actor ID => Array of Actor IDs that Actor can't target
  #---------------------------------------------------------------------------
  NoTargetActor = {}
  #---------------------------------------------------------------------------
  # * NoTargetEnemy : Actor ID => Array of Enemy IDs that Actor can't target
  #---------------------------------------------------------------------------
  NoTargetEnemy = {}
  #---------------------------------------------------------------------------
  # * Defaults (Do Not Touch)
  #---------------------------------------------------------------------------
  NoTargetActor.default = Array.new
  NoTargetEnemy.default = Array.new
 end
 #=============================================================================
 # ** AntiTarget::Enemy
 #=============================================================================
 module Enemy
  #---------------------------------------------------------------------------
  # * Untargetables : Enemies which can't be targeted by actors.
  #---------------------------------------------------------------------------
  Untargetables = [1]
  #---------------------------------------------------------------------------
  # * NoTargetActor : Enemy ID => Array of Actor IDs that Enemy can't target
  #---------------------------------------------------------------------------
  NoTargetActor = {}
  #---------------------------------------------------------------------------
  # * NoTargetEnemy : Enemy ID => Array of Enemy IDs that Enemy can't target
  #---------------------------------------------------------------------------
  NoTargetEnemy = {}
  #---------------------------------------------------------------------------
  # * Defaults (Do Not Touch)
  #---------------------------------------------------------------------------
  NoTargetActor.default = Array.new
  NoTargetEnemy.default = Array.new
 end
 #=============================================================================
 # ** AntiTarget::States
 #=============================================================================
 module States
  #---------------------------------------------------------------------------
  # * All   : State IDs that prevent attack, skill and items from targetting.
  #---------------------------------------------------------------------------
  All   = []
  #---------------------------------------------------------------------------
  # * Attack : State IDs that prevent attacks from targetting.
  #---------------------------------------------------------------------------
  Attack  = []
  #---------------------------------------------------------------------------
  # * Skills : State IDs that prevent skills from targetting.
  #---------------------------------------------------------------------------
  Skills  = []
  #---------------------------------------------------------------------------
  # * Items  : State IDs that prevent items from targetting.
  #---------------------------------------------------------------------------
  Items  = []
 end
end
Â
#===============================================================================
# ** Game_Battler
#===============================================================================
Â
class Game_Battler
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :antitarget_gmbattler_atkeffect, :attack_effect
 alias_method :antitarget_gmbattler_skleffect, :skill_effect
 alias_method :antitarget_gmbattler_itmeffect, :item_effect
 #-----------------------------------------------------------------------------
 # * Attack Effect
 #-----------------------------------------------------------------------------
 def attack_effect(attacker)
  return if self.battler_cant_target?(attacker)
  antitarget_gmbattler_atkeffect(attacker)
 end
 #-----------------------------------------------------------------------------
 # * Skill Effect
 #-----------------------------------------------------------------------------
 def skill_effect(user, skill)
  return if self.battler_cant_target?(user)
  antitarget_gmbattler_skleffect(user, skill)
 end
 #-----------------------------------------------------------------------------
 # * Attack Effect
 #-----------------------------------------------------------------------------
 def item_effect(user, item)
  return if self.battler_cant_target?(user)
  antitarget_gmbattler_itmeffect(user, item)
 end
 #-----------------------------------------------------------------------------
 # * Can't Target?
 #-----------------------------------------------------------------------------
 def cant_target?(battler)
  return battler.battler_cant_target?(self)
 end
 #-----------------------------------------------------------------------------
 # * Battler Can't Target?
 #-----------------------------------------------------------------------------
 def battler_cant_target?(battler)
  if battler.class == self.class
   return self.ally_cant_target?(battler)
  else
   return self.enemy_cant_target?(battler)
  end
 end
end
Â
#===============================================================================
# ** Game_Actor
#===============================================================================
Â
class Game_Actor < Game_Battler
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :antitarget_gmactor_skill_can_use?, :skill_can_use?
 #-----------------------------------------------------------------------------
 # * Ally Can't Target?
 #-----------------------------------------------------------------------------
 def ally_cant_target?(actor)
  return true if AntiTarget::Actor::NoTargetActor[actor.id].include?(id)
  return true if AntiTarget::Actor::NoTargetActor[0].include?(id)
  return false
 end
 #-----------------------------------------------------------------------------
 # * Enemy Can't Target?
 #-----------------------------------------------------------------------------
 def enemy_cant_target?(enemy)
  return true if AntiTarget::Actor::Untargetables.include?(id)
  return true if AntiTarget::Enemy::NoTargetActor[enemy.id].include?(id)
  return true if AntiTarget::Enemy::NoTargetActor[0].include?(id)
  return false
 end
 #-----------------------------------------------------------------------------
 # * Skill Can Use?
 #-----------------------------------------------------------------------------
 def skill_can_use?(skill_id)
  skill = $data_skills[skill_id]
  if $game_temp.in_battle
   if $game_troop.untargetable?(self)
    return [3, 4].include?(skill.scope)
   end
  end
  antitarget_gmactor_skill_can_use?(skill_id)
 end
end
Â
#===============================================================================
# ** Game_Enemy
#===============================================================================
Â
class Game_Enemy < Game_Battler
 #-----------------------------------------------------------------------------
 # * Ally Can't Target?
 #-----------------------------------------------------------------------------
 def ally_cant_target?(enemy)
  return true if AntiTarget::Enemy::NoTargetEnemy[enemy.id].include?(id)
  return true if AntiTarget::Enemy::NoTargetEnemy[0].include?(id)
  return false
 end
 #-----------------------------------------------------------------------------
 # * Enemy Can't Target?
 #-----------------------------------------------------------------------------
 def enemy_cant_target?(actor)
  return true if AntiTarget::Enemy::Untargetables.include?(id)
  return true if AntiTarget::Actor::NoTargetEnemy[actor.id].include?(id)
  return true if AntiTarget::Actor::NoTargetEnemy[0].include?(id)
  return false
 end
end
Â
#===============================================================================
# ** Game_Party
#===============================================================================
Â
class Game_Party
 #-----------------------------------------------------------------------------
 # * Targetable?
 #-----------------------------------------------------------------------------
 def targetable?(battler)
  targets = Array.new
  members.each {|member| targets << battler.cant_target?(member)}
  return targets.include?(false)
 end
 #-----------------------------------------------------------------------------
 # * Untargetable?
 #-----------------------------------------------------------------------------
 def untargetable?(battler)
  return !self.targetable?(battler)
 end
end
Â
#===============================================================================
# ** Game_Party
#===============================================================================
Â
class Game_Troop
 #-----------------------------------------------------------------------------
 # * Targetable?
 #-----------------------------------------------------------------------------
 def targetable?(battler)
  targets = Array.new
  members.each {|member| targets << battler.cant_target?(member)}
  return targets.include?(false)
 end
 #-----------------------------------------------------------------------------
 # * Untargetable?
 #-----------------------------------------------------------------------------
 def untargetable?(battler)
  return !self.targetable?(battler)
 end
end
Â
#===============================================================================
# ** Arrow_Actor
#===============================================================================
Â
class Arrow_Actor < Arrow_Base
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :antitarget_arrowactor_update, :update
 #-----------------------------------------------------------------------------
 # * Update
 #-----------------------------------------------------------------------------
 def update
  antitarget_arrowactor_update
  $game_party.actors.size.times do
   break unless actor.battler_cant_target?($scene.active_battler)
   @index += Input.repeat?(Input::RIGHT) ? 1 : -1
   @index %= $game_party.actors.size
  end
  unless self.actor.nil?
   self.x = self.actor.screen_x
   self.y = self.actor.screen_y
  end
 end
end
Â
#===============================================================================
# ** Arrow_Enemy
#===============================================================================
Â
class Arrow_Enemy < Arrow_Base
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :antitarget_arrowenemy_update, :update
 #-----------------------------------------------------------------------------
 # * Update
 #-----------------------------------------------------------------------------
 def update
  antitarget_arrowenemy_update
  $game_troop.enemies.size.times do
   break unless enemy.battler_cant_target?($scene.active_battler)
   @index += Input.repeat?(Input::RIGHT) ? 1 : -1
   @index %= $game_troop.enemies.size
  end
  unless self.enemy.nil?
   self.x = self.enemy.screen_x
   self.y = self.enemy.screen_y
  end
 end
end
Â
#===============================================================================
# ** Scene_Battle
#===============================================================================
Â
class Scene_Battle < SDK::Scene_Base
 #-----------------------------------------------------------------------------
 # * Public Instance Variables
 #-----------------------------------------------------------------------------
 attr_reader :active_battler
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :antitarget_scnbattle_p3setupcomwin, :phase3_setup_command_window
 alias_method :antitarget_scnbattle_p3commandatk,  :phase3_command_attack
 alias_method :antitarget_scnbattle_p3commandskl,  :phase3_command_skill
 alias_method :antitarget_scnbattle_p3commanditm,  :phase3_command_item
 #-----------------------------------------------------------------------------
 # * Phase 3 : Setup Command Window
 #-----------------------------------------------------------------------------
 def phase3_setup_command_window
  antitarget_scnbattle_p3setupcomwin
  phase3_antitarget_command_attack
  phase3_antitarget_command_skill
  phase3_antitarget_command_item
 end
 #-----------------------------------------------------------------------------
 # * Check AntiTarget Attack
 #-----------------------------------------------------------------------------
 def check_antitarget_attack
  $game_troop.untargetable?(@active_battler)
 end
 #-----------------------------------------------------------------------------
 # * Check AntiTarget Skill
 #-----------------------------------------------------------------------------
 def check_antitarget_skill
  $game_troop.untargetable?(@active_battler) &&
  @active_battler.skills_without_scopes?(1, 2)
 end
 #-----------------------------------------------------------------------------
 # * Check AntiTarget Item
 #-----------------------------------------------------------------------------
 def check_antitarget_item
  $game_troop.untargetable?(@active_battler) &&
  $game_party.items_without_scopes?(1, 2)
 end
 #-----------------------------------------------------------------------------
 # * Phase 3 : Anti-Target Command Attack
 #-----------------------------------------------------------------------------
 def phase3_antitarget_command_attack
  if check_antitarget_attack
   @actor_command_window.disable_command(SDK::Vocab::Scene_Battle::Attack)
  else
   @actor_command_window.enable_command(SDK::Vocab::Scene_Battle::Attack)
  end
 end
 #-----------------------------------------------------------------------------
 # * Phase 3 : Anti-Target Command Skill
 #-----------------------------------------------------------------------------
 def phase3_antitarget_command_skill
  if check_antitarget_skill
   @actor_command_window.disable_command(SDK::Vocab::Scene_Battle::Skill)
  else
   @actor_command_window.enable_command(SDK::Vocab::Scene_Battle::Skill)
  end
 end
 #-----------------------------------------------------------------------------
 # * Phase 3 : Anti-Target Command Item
 #-----------------------------------------------------------------------------
 def phase3_antitarget_command_item
  if check_antitarget_item
   @actor_command_window.disable_command(SDK::Vocab::Scene_Battle::Item)
  else
   @actor_command_window.enable_command(SDK::Vocab::Scene_Battle::Item)
  end
 end
 #-----------------------------------------------------------------------------
 # * Phase 3 : Command Attack
 #-----------------------------------------------------------------------------
 def phase3_command_attack
  if check_antitarget_attack
   $game_system.se_play($data_system.buzzer_se)
   return
  end
  antitarget_scnbattle_p3commandatk
 end
 #-----------------------------------------------------------------------------
 # * Phase 3 : Command Skill
 #-----------------------------------------------------------------------------
 def phase3_command_skill
  if check_antitarget_skill
   $game_system.se_play($data_system.buzzer_se)
   return
  end
  antitarget_scnbattle_p3commandskl
 end
 #-----------------------------------------------------------------------------
 # * Phase 3 : Command Item
 #-----------------------------------------------------------------------------
 def phase3_command_item
  if check_antitarget_item
   $game_system.se_play($data_system.buzzer_se)
   return
  end
  antitarget_scnbattle_p3commanditm
 end
end