03-08-2008, 01:06 AM 
	
	
	 Script
  			Code:
#==============================================================================
# ** Passive Skills/Abilities
#------------------------------------------------------------------------------
# By Syvkal
# Version 1.1
# 07-04-08
#==============================================================================
#
#  - INTRODUCTION -
#
#  This script can be used to make 'Passive Skills' or 'Abilities'
#  These are skills that will happen constantly and don't need activating
#
#  This script requires my 'Notes Field System' V1.5 or above
#  And has been made to also work with my 'Conditional Skills and Equipment'
#  script V2.6.1 which will allow Passive Skills to be made Conditional too
#
#------------------------------------------------------------------------------
#
#  - USAGE -
#
#  First make a skill in the Database and in it's note box place this:
#
#        <passive>
#          .....
#        <passive>
#
#  You must place any necessary Coding in there (explained below)
#  Anything you place in there must be on a separate line 
#  (including the <passive> tags)
#
#------------------------------------------------------------------------------
#
#  - FEATURES - 
#
#  Passive skills allow you to add a number of different features, all of which
#  be explained here along with how to set them up
#
#  ==Base Stats==
#
#    The Tags can be customised in the Configuration
#
#    These include MaxHP, MaxpMP, Atk, Def, Agi, Spi, Hit, Eva and Cri
#    Simply place on of the Tags into the Skills note box along with a number
#    The Number can be positive '+' negative '-' or even a percentage '%'
#
#    See EXAMPLES if you are unsure  
#
#
#  ==States and Elements==
#
#    These require no Tags what so ever
#
#    They can be altered through the Element and State Changes Sections
#
#    Clicking an Element will make a Passive Skill that adds that Element
#    to your actors attack
#
#    Clicking to add a State '+' will make a Passive Skill that adds that 
#    adds a State Change to your attack            eg. Poison on Strike
#
#    Click to minus a State '-' will make a Passive Skill that adds 
#    resistance to that State                      eg. Resist Poison
#
#
#  ==Battle Effects==
#
#    Reflect Tag can be customised in the Configuration
#
#    Battle Effects are special Abilities that will affect battles giving
#    them a dynamic edge
#    There can only be one Battle Effect per Skill
#    Battle Effect Passive Skills can also be used by Enemies too
#
#    Damage to MP  - By clicking this whilst creating a Passive Skill will make
#      an ability that transfers some of an actors Battle Damage to their MP
#
#    Absorb Damage - By clicking this whilst creating a Passive Skill will make
#      an ability that absorbs some of an actors Battle Damage and Recovers it
#
#    Both (above)  - By clicking both whilst creating a Passive Skill will make
#      an ability that absorbs some of an actors Battle Damage from Enemy
#      skills and Recovers MP
#
#    REFLECT     - By adding this tag whilst creating a Passive Skill will make
#      an ability that reflects some of an actors Battle Damage
#      back to the Enemy
#
#    Each Battle Effect is in a percentage, so 50% will affect 50% of the damage
#    
#    The Percentage is defined through the Skills Variance (in Damage Effect)
#
#  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
#  |  It is advised you not make it possible for players to get over 50% on  |
#  |  any of the effects. This can make them invincible - which is not good  |
#  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
#
#
#  ==Special Features==
#
#    The Tags can be customised in the Configuration
#
#    Special Features allow skills to set things usually set by weapons/armours
#
#    SuperGuard      - Doubles the effectiveness of the 'Defend' Option
#    Pharmocology    - Doubles the amount of Health Recovered from Items/Spells
#    FastAttack      - Makes the actor attack first
#    DualAttack      - Makes the actor attack twice
#    CriticalBonus   - Increases the actor's critical hit percentage
#    PreventCritical - Prevents Critical Attacks being done to teh actor
#    HalfMP          - Halfs the amount of MP consumed when casting a Spell
#    DoubleExp       - Doubles the amount of experience points gained
#    HPRecovery      - The actor gradually recovers HP whilst in Battles/walking
#
#  ==Hide Skill==
#
#    To make a Passive Skill not show up in the Players Skill Menu simply add:
#
#        NOSHOW
#
#    As a Tag into it's Notes Field
#
#------------------------------------------------------------------------------
#
#  - EXAMPLES -
#
#   Here is an example of what the Notes box could look like to show you how 
#   to use some of the Tags:
#
#   <passive>
#   ATK 50                       Increases Atk by 50 points
#   DEF 25%                      Increases Def by 25% (so 125% in total)
#   AGI -50                      Decreases AGI by 50 points
#   SPI -25%                     Decreases SPI by 25% (so 75% in total)
#   <passive>
#
#------------------------------------------------------------------------------
#
#  - CONFIGURATION - 
#
#  The only real configuration necessary is the Tags needed for the Passive
#  Skills and the Battle Messages used with the Passive Battle Effects
#
#  These can all be customized from the extended Vocab Module Seen Below
#  I advised you not to alter anything else unless you know what you are doing
#
#==============================================================================
module Vocab
   #===================================================#
   #  **  C O N F I G U R A T I O N   S Y S T E M  **  #
   #===================================================#
  
  # Passive Skill Paramter Tags
  Parameters = {
   :maxhp => "MAXHP",     # Maximum Hit Points
   :maxmp => "MAXMP",     # Maximum Magic Points
   :atk   => "ATK",       # Attack
   :def   => "DEF",       # Defense
   :spi   => "SPI",       # Spirit
   :agi   => "AGI",       # Agility
   :hit   => "HIT",       # Hit Rate
   :eva   => "EVA",       # Evasive Rate
   :cri   => "CRI"        # Critical Hit Rate
   }
  
  # Passive Skill Battle Effect Tags
  Reflect         = "REFLECT"     # Reflect Damage
  
  # Passive Skill Special Feature Tags
  SuperGuard      = "SGUARD"      # Super Guard
  Pharmocology    = "PHARM"       # Pharmocology
  FastAttack      = "FASTATK"     # Fast Attack
  DualAttack      = "DUALATK"     # Dual Attack
  CriticalBonus   = "CRITBONUS"   # Critical Bouns
  PreventCritical = "PREVENTCRIT" # Prevent Critical
  HalfMP          = "HALFMP"      # Half MP Cost
  DoubleExp       = "DOUBLEEXP"   # Double Experience
  HPRecovery      = "HPRECOVER"   # Auto HP Recovery
  
  # Results for Actions on Actors
  ActorReflect    = "%s reflected %s damage!"
  ActorToMP       = "%1$s's %2$s was damaged!"
  ActorAbsorb     = "%1$s absorbed %3$s %2$s!"
  ActorStopDamage = "%s resisted all damage!"
  # Results for Actions on Enemies
  EnemyReflect    = "%s reflected %s damage!"
  EnemyToMP       = "%3$s damage was transferred to %1$s's %2$s!"
  EnemyAbsorb     = "%1$s absorbed %3$s %2$s!"
  EnemyStopDamage = "%s resisted all damage!"
  
   #===================================================#
   #  **     E N D   C O N F I G U R A T I O N     **  #
   #===================================================#
end
#==============================================================================
# ** Script Import
#------------------------------------------------------------------------------
#  Added to make it work with or without Conditional Skills
#==============================================================================
  
  $imported = {} if $imported == nil
  $imported["PassiveSkill"] = true
#==============================================================================
# ** RPG::Skill
#------------------------------------------------------------------------------
#  Added Passive Check and Set. Aswell as defining Passive Note Field
#==============================================================================
class RPG::Skill < RPG::UsableItem
  #--------------------------------------------------------------------------
  # * Includes The NOTES Module
  #--------------------------------------------------------------------------  
  include NOTES
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias passive_skill_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    passive_skill_initialize
    @passive = false
    @note_passive = ""
  end
  attr_accessor :passive
  attr_accessor :note_passive
  #--------------------------------------------------------------------------
  # * Determine if Passive and set
  #--------------------------------------------------------------------------
  def determine_passive
    if has_tag?(@note,'<passive>')
      set_passive
      set_passive_note
    end
  end
  #--------------------------------------------------------------------------
  # * Set Passive
  #--------------------------------------------------------------------------
   def set_passive
    @passive = true
  end
  #--------------------------------------------------------------------------
  # * Set Passive Note Field
  #--------------------------------------------------------------------------
  def set_passive_note
    @note_passive = get_tag_area(@note, '<passive>')
  end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :passive_parameters
  attr_accessor :passive_parameters_rates
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias passive_state_resist? state_resist?
  alias passive_plus_state_set plus_state_set
  alias passive_element_set element_set
  alias passive_setup setup
  alias passive_base_maxhp base_maxhp
  alias passive_base_maxmp base_maxmp
  alias passive_base_atk base_atk
  alias passive_base_def base_def
  alias passive_base_spi base_spi
  alias passive_base_agi base_agi
  alias passive_base_hit hit
  alias passive_base_eva eva
  alias passive_base_cri cri
  alias passive_learn_skill learn_skill
  alias passive_forget_skill forget_skill
  alias passive_super_guard super_guard
  alias passive_pharmacology pharmacology
  alias passive_fast_attack fast_attack
  alias passive_dual_attack dual_attack
  alias passive_prevent_critical prevent_critical
  alias passive_half_mp_cost half_mp_cost
  alias passive_double_exp_gain double_exp_gain
  alias passive_auto_hp_recover auto_hp_recover  
  alias passive_change_equip_by_id change_equip_by_id
  alias passive_change_equip change_equip
  alias passive_discard_equip discard_equip
  #--------------------------------------------------------------------------
  # * Includes The NOTES Module
  #--------------------------------------------------------------------------  
  include NOTES
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(actor_id)
    passive_setup(actor_id)
    set_passive
  end
  #--------------------------------------------------------------------------
  # * Set Passive on Necessary Skills
  #--------------------------------------------------------------------------
  def set_passive
    for i in @skills
      $data_skills[i].determine_passive
    end
  end
  #--------------------------------------------------------------------------
  # * Get Passive Additional Parameter
  #--------------------------------------------------------------------------
  def passive_parameter(par)
    result = 0
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      if has_tag?(skill.note_passive, Vocab::Parameters[par])
        tags = get_tag(skill.note_passive, Vocab::Parameters[par])
        unless tags[0].include?('%')
          result += tags[0].to_i
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get Passive Additional Parameter Rate
  #--------------------------------------------------------------------------
  def passive_parameter_rate(par)
    result = 0
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      if has_tag?(skill.note_passive, Vocab::Parameters[par])
        tags = get_tag(skill.note_passive, Vocab::Parameters[par])
        if tags[0].include?('%')
          tags[0].slice!('%')
          result += tags[0].to_i
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Determine if State is Resisted
  #     state_id : state ID
  #--------------------------------------------------------------------------
  def state_resist?(state_id)
    return true if passive_resist_states.include?(state_id)
    passive_state_resist?(state_id)
  end
  #--------------------------------------------------------------------------
  # * Get Additional Effect of Normal Attack (state change)
  #--------------------------------------------------------------------------
  def plus_state_set
    return (passive_plus_state_set | passive_plus_state)
  end
  #--------------------------------------------------------------------------
  # * Get Normal Attack Element
  #--------------------------------------------------------------------------
  def element_set
    return (passive_element_set | passive_element)
  end
  #--------------------------------------------------------------------------
  # * Get Basic Maximum HP
  #--------------------------------------------------------------------------
  def base_maxhp
    n = passive_base_maxhp + passive_parameter(:maxhp)
    n += n * passive_parameter_rate(:maxhp) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get basic Maximum MP
  #--------------------------------------------------------------------------
  def base_maxmp
    n = passive_base_maxmp + passive_parameter(:maxmp)
    n += n * passive_parameter_rate(:maxmp) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Attack
  #--------------------------------------------------------------------------
  def base_atk
    n = passive_base_atk + passive_parameter(:atk)
    n += n * passive_parameter_rate(:atk) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Defense
  #--------------------------------------------------------------------------
  def base_def
    n = passive_base_def + passive_parameter(:def)
    n += n * passive_parameter_rate(:def) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Spirit
  #--------------------------------------------------------------------------
  def base_spi 
    n = passive_base_spi + passive_parameter(:spi)
    n += n * passive_parameter_rate(:spi) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Agility
  #--------------------------------------------------------------------------
  def base_agi
    n = passive_base_agi + passive_parameter(:agi)
    n += n * passive_parameter_rate(:agi) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Hit Rate
  #--------------------------------------------------------------------------
  def hit
    n = passive_base_hit + passive_parameter(:hit)
    n += n * passive_parameter_rate(:hit) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Evasion Rate
  #--------------------------------------------------------------------------
  def eva
    n = passive_base_eva + passive_parameter(:eva)
    n += n * passive_parameter_rate(:eva) / 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Critical Ratio
  #--------------------------------------------------------------------------
  def cri
    n = passive_base_cri + passive_parameter(:cri)
    n += n * passive_parameter_rate(:cri) / 100
    n += 4 if get_special_feature_check(Vocab::CriticalBonus)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get [Super Guard] Option
  #--------------------------------------------------------------------------
  def super_guard
    return true if get_special_feature_check(Vocab::SuperGuard)
    passive_super_guard
  end
  #--------------------------------------------------------------------------
  # * Get [Pharmocology] Option
  #--------------------------------------------------------------------------
  def pharmacology
    return true if get_special_feature_check(Vocab::Pharmocology)
    passive_pharmacology
  end
  #--------------------------------------------------------------------------
  # * Get [First attack within turn] weapon option
  #--------------------------------------------------------------------------
  def fast_attack
    return true if get_special_feature_check(Vocab::FastAttack)
    passive_fast_attack
  end
  #--------------------------------------------------------------------------
  # * Get [Chain attack] weapon option
  #--------------------------------------------------------------------------
  def dual_attack
    return true if get_special_feature_check(Vocab::DualAttack)
    passive_dual_attack
  end
  #--------------------------------------------------------------------------
  # * Get [Prevent critical] armor option
  #--------------------------------------------------------------------------
  def prevent_critical
    return true if get_special_feature_check(Vocab::PreventCritical)
    passive_prevent_critical
  end
  #--------------------------------------------------------------------------
  # * Get [half MP cost] armor option
  #--------------------------------------------------------------------------
  def half_mp_cost
    return true if get_special_feature_check(Vocab::HalfMP)
    passive_half_mp_cost
  end
  #--------------------------------------------------------------------------
  # * Get [Double Experience] Armor Option
  #--------------------------------------------------------------------------
  def double_exp_gain
    return true if get_special_feature_check(Vocab::DoubleExp)
    passive_double_exp_gain
  end
  #--------------------------------------------------------------------------
  # * Get [Auto HP Recovery] Armor Option
  #--------------------------------------------------------------------------
  def auto_hp_recover
    return true if get_special_feature_check(Vocab::HPRecovery)
    passive_auto_hp_recover
  end
  #--------------------------------------------------------------------------
  # * Change Equipment (designate ID)
  #--------------------------------------------------------------------------
  def change_equip_by_id(equip_type, item_id, test = false)
    passive_change_equip_by_id(equip_type, item_id, test)
    set_passive
  end
  #--------------------------------------------------------------------------
  # * Change Equipment (designate object)
  #--------------------------------------------------------------------------
  def change_equip(equip_type, item, test = false)
    passive_change_equip(equip_type, item, test)
    set_passive
  end
  #--------------------------------------------------------------------------
  # * Discard Equipment
  #--------------------------------------------------------------------------
  def discard_equip(item)
    passive_discard_equip(item)
    set_passive
  end
  #--------------------------------------------------------------------------
  # * Learn Skill
  #--------------------------------------------------------------------------
  def learn_skill(skill_id)
     passive_learn_skill(skill_id)
     set_passive
  end
  #--------------------------------------------------------------------------
  # * Forget Skill
  #--------------------------------------------------------------------------
  def forget_skill(skill_id)
    passive_forget_skill(skill_id)
    set_passive
  end
end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemy characters. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias passive_enemy_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(index, enemy_id)
    passive_enemy_initialize(index, enemy_id)
    set_passive
  end
  #--------------------------------------------------------------------------
  # * Set Passive on Necessary Skills
  #--------------------------------------------------------------------------
  def set_passive
    for skill in skills
      skill.determine_passive
    end
  end
  #--------------------------------------------------------------------------
  # * Get Skill Object Array
  #--------------------------------------------------------------------------
  def skills
    result = []
    for i in enemy.actions
      next unless i.kind == 1
      result.push($data_skills[i.skill_id])
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get Additional Effect of Normal Attack (state change)
  #--------------------------------------------------------------------------
  def plus_state_set
    return passive_plus_state
  end
  #--------------------------------------------------------------------------
  # * Get Normal Attack Element
  #--------------------------------------------------------------------------
  def element_set
    return passive_element
  end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  Added the main bulk of Passive Skill Calculations
#==============================================================================
class Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :real_dmg              # action results: Final HP damage
  attr_accessor :mp_dmg                # action results: Additional MP damage
  attr_accessor :reflect_dmg           # action results: Reflected HP damage
  attr_accessor :absorbed_dmg          # action results: Absorbed MP damage
  attr_accessor :absorbed_mp           # action results: Absorbed MP damage
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias passive_battler_initialize initialize
  alias passive_battler_skill_can_use? skill_can_use?
  alias passive_show_skill? show_skill? if $imported["ConditionalSkill"]
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @real_dmg = 0
    @mp_dmg = 0
    @reflect_dmg = 0
    @absorbed_dmg = 0
    @absorbed_mp = 0
    passive_battler_initialize
  end
  #--------------------------------------------------------------------------
  # * Determine Usable Skills
  #--------------------------------------------------------------------------
  def skill_can_use?(skill)
    return false if skill.passive
    passive_battler_skill_can_use?(skill)
  end
  #--------------------------------------------------------------------------
  # * Determine Usable Passive Skills
  #--------------------------------------------------------------------------
  def passive_skill_can_use?(skill)
    if $imported["ConditionalSkill"]
      return false unless skill_condition_can_use?(skill)
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Determine Hidden Skills
  #--------------------------------------------------------------------------
  def show_skill?(skill)
    if skill.passive
      return false if has_tag?(skill.note,'NOSHOW')
    end
    return true if skill_can_use?(skill)
    if $imported["ConditionalSkill"]
      passive_show_skill?(skill)
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Get Passive Resisted States
  #--------------------------------------------------------------------------
  def passive_resist_states
    result = []
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = result | skill.minus_state_set 
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get Passive Additional States
  #--------------------------------------------------------------------------
  def passive_plus_state
    result = []
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = result | skill.plus_state_set
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get Passive Additional Elements
  #--------------------------------------------------------------------------
  def passive_element
    result = []
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = result | skill.element_set
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get Special Feature Check
  #--------------------------------------------------------------------------
  def get_special_feature_check(tag)
    result = false
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = true if has_tag?(skill.note_passive, tag)
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Check for Passive Absorb MP
  #--------------------------------------------------------------------------
  def passive_absorb_mp?
    result = false
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = true if skill.absorb_damage and skill.damage_to_mp
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Check for Passive Absorb Damage
  #--------------------------------------------------------------------------
  def passive_absorb_damage?
    result = false
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = true if skill.absorb_damage and not skill.damage_to_mp
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Check for Passive Damage to MP
  #--------------------------------------------------------------------------
  def passive_damage_to_mp?
    result = false
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = true if skill.damage_to_mp and not skill.absorb_damage
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Check for Passive Reflect Damage
  #--------------------------------------------------------------------------
  def passive_damage_reflect?
    result = false
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      result = true if skill.note_passive.include?(Vocab::Reflect) and not (skill.absorb_damage or skill.damage_to_mp)
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get Passive Absorb MP Percentage Rate
  #--------------------------------------------------------------------------
  def absorb_mp_percent
    result = 0
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      next unless skill.absorb_damage and skill.damage_to_mp
      result += skill.variance
    end
    return [result, 100].min
  end
  #--------------------------------------------------------------------------
  # * Get Passive Absorb Damage Percentage Rate
  #--------------------------------------------------------------------------
  def absorb_damage_percent
    result = 0
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      next unless skill.absorb_damage and not skill.damage_to_mp
      result += skill.variance
    end
    return [result, 100].min
  end
  #--------------------------------------------------------------------------
  # * Get Passive Damage to MP Percentage Rate
  #--------------------------------------------------------------------------
  def damage_to_mp_percent
    result = 0
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      next unless skill.damage_to_mp and not skill.absorb_damage
      result += skill.variance
    end
    return [result, 100].min
  end
  #--------------------------------------------------------------------------
  # * Get Passive Reflect Damage Percentage Rate
  #--------------------------------------------------------------------------
  def damage_reflect_percent
    result = 0
    for skill in skills
      next unless skill.passive
      next unless passive_skill_can_use?(skill)
      next unless skill.note_passive.include?(Vocab::Reflect) and not (skill.absorb_damage or skill.damage_to_mp)
      result += skill.variance
    end
    return [result, 100].min
  end
  #--------------------------------------------------------------------------
  # * Damage Reflection
  #--------------------------------------------------------------------------
  def execute_damage(user, skill = false)
    if @hp_damage > 0           # Damage is a positive number
      remove_states_shock       # Remove state due to attack
    end
    @real_dmg = @hp_damage      # Make Real Damage Value
    @mp_dmg = 0
    if passive_damage_reflect?  # If damage is reflected
      @reflect_dmg = (@hp_damage*damage_reflect_percent / 100)
      if (@reflect_dmg/2) < 1
        @reflect_dmg = rand(2) +1
      end
      @real_dmg -= @reflect_dmg
    end
    if passive_damage_to_mp?    # If damage to MP
      unless self.mp == 0
        @mp_dmg = (@hp_damage*damage_to_mp_percent / 100)
        if self.mp < @mp_dmg/2
          @mp_dmg -= self.mp*2
        end
        @mp_dmg = [@mp_dmg, @real_dmg].min
        @real_dmg -= @mp_dmg
      end
    end
    if skill
      if passive_absorb_mp?     # If gaining MP
        @absorbed_mp = (@hp_damage*absorb_mp_percent / 100)
        @absorbed_mp = [@absorbed_mp, @real_dmg].min
        @real_dmg -= @absorbed_mp
      end
      @absorbed_dmg = 0
    else
      if passive_absorb_damage? # If gaining HP
        @absorbed_dmg = (@hp_damage*absorb_damage_percent / 100)
        @absorbed_dmg = [@absorbed_dmg, @real_dmg].min
        @real_dmg -= @absorbed_dmg
      end
      @absorbed_mp = 0
    end
    @real_dmg = [@real_dmg, 0].max
    self.hp -= [@real_dmg,@hp_damage].min
    self.mp -= @mp_damage + (@mp_dmg/2)
    if passive_absorb_damage?   # If gaining HP
      self.hp += @absorbed_dmg/2
    end
    if passive_absorb_mp?       # If gaining MP
      unless @hp_damage < 0
        self.mp += @absorbed_mp/2
      end
    end
    if passive_damage_reflect?  # If damage is reflected
      user.hp -= @reflect_dmg/2
    end
    if @absorbed                # If absorbing
      user.hp += @hp_damage
      user.mp += @mp_damage
    end
  end
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : Skill user
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    clear_action_results
    unless skill_effective?(user, skill)
      @skipped = true
      return
    end
    if rand(100) >= calc_hit(user, skill)         # determine hit ratio
      @missed = true
      return
    end
    if rand(100) < calc_eva(user, skill)          # determine evasion rate
      @evaded = true
      return
    end
    make_obj_damage_value(user, skill)            # calculate damage
    make_obj_absorb_effect(user, skill)           # calculate absorption effect
    execute_damage(user, true)                 #### damage reflection
    if skill.physical_attack and @hp_damage == 0  # physical no damage?
      return                                    
    end
    apply_state_changes(skill)                    # state change
  end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  Added BattleMessage Changes
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Show State Change
  #--------------------------------------------------------------------------
  def display_state_changes(target, obj = nil)
    return if target.missed or target.evaded
    return unless target.states_active?
    display_added_states(target, obj)
    display_removed_states(target, obj)
    display_remained_states(target, obj)
    if @message_window.last_instant_text.empty?
      @message_window.back_one
    else
      wait(10)
    end
  end
  #--------------------------------------------------------------------------
  # * Show Added State
  #--------------------------------------------------------------------------
  def display_added_states(target, obj = nil)
    for state in target.added_states
      if target.actor?
        next if state.message1.empty?
        text = target.name + state.message1
      else
        next if state.message2.empty?
        text = target.name + state.message2
      end
      if state.id == 1                      # Incapacitated
        target.perform_collapse
      end
      @message_window.add_instant_text(text)
      wait(20)
    end
  end
  #--------------------------------------------------------------------------
  # * Show Removed State
  #--------------------------------------------------------------------------
  def display_removed_states(target, obj = nil)
    for state in target.removed_states
      next if state.message4.empty?
      text = target.name + state.message4
      @message_window.add_instant_text(text)
      wait(20)
    end
  end
  #--------------------------------------------------------------------------
  # * Show Unchanged State
  #--------------------------------------------------------------------------
  def display_remained_states(target, obj = nil)
    for state in target.remained_states
      next if state.message3.empty?
      text = target.name + state.message3
      @message_window.add_instant_text(text)
      wait(20)
    end
  end
  #--------------------------------------------------------------------------
  # * Show HP Damage
  #     target : Target
  #     obj    : Skill or item
  #--------------------------------------------------------------------------
  def display_hp_damage(target, obj = nil)
    extra_text = []
    if target.hp_damage == 0 # No damage
      return if obj != nil and obj.damage_to_mp
      return if obj != nil and obj.base_damage == 0
      fmt = target.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
      text = sprintf(fmt, target.name)
    elsif target.absorbed                   # Absorb
      fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
      text = sprintf(fmt, target.name, Vocab::hp, target.real_dmg)
    elsif target.hp_damage > 0              # Damage
      if target.actor?
        unless target.real_dmg == 0
          text = sprintf(Vocab::ActorDamage, target.name, target.real_dmg)
          Sound.play_actor_damage
        else
          text = sprintf(Vocab::ActorStopDamage, target.name)
        end
        $game_troop.screen.start_shake(5, 5, 10)
        if target.passive_absorb_damage?   # Absorb Damage
          unless (target.absorbed_dmg/2) < 1
            extra_text.push(sprintf(Vocab::ActorAbsorb, target.name, Vocab::hp, target.absorbed_dmg))
            extra_text.push(sprintf(Vocab::ActorRecovery, target.name, Vocab::hp, target.absorbed_dmg/2))
          end
        end
        if target.passive_absorb_mp?       # Absorb MP
          unless (target.absorbed_mp/2) < 1
            extra_text.push(sprintf(Vocab::ActorAbsorb, target.name, Vocab::mp, target.absorbed_mp))
            extra_text.push(sprintf(Vocab::ActorRecovery, target.name, Vocab::mp, target.absorbed_mp/2))
          end
        end
        if target.passive_damage_to_mp?    # Damage to MP
          unless (target.mp_dmg/2) < 1
            extra_text.push(sprintf(Vocab::ActorToMP, target.name, Vocab::mp))
            extra_text.push(sprintf(Vocab::ActorLoss, target.name, Vocab::mp, target.mp_dmg/2))
          end
        end
        if target.passive_damage_reflect?  # Reflect Damage
          extra_text.push(sprintf(Vocab::ActorReflect, target.name, target.reflect_dmg))
          unless (target.reflect_dmg/2) < 1
            extra_text.push(sprintf(Vocab::EnemyDamage, @active_battler.name, target.reflect_dmg/2))
            wait(15)
            Sound.play_enemy_damage
            @active_battler.blink = true
          else
            extra_text.push(sprintf(Vocab::EnemyNoDamage, @active_battler.name))
          end
        end
      else
        text = sprintf(Vocab::EnemyDamage, target.name, target.real_dmg)
        Sound.play_enemy_damage
        target.blink = true
        if target.passive_absorb_damage?   # Absorb Damage
          unless (target.absorbed_dmg/2) < 1
            extra_text.push(sprintf(Vocab::EnemyAbsorb, target.name, Vocab::hp, target.absorbed_dmg))
            extra_text.push(sprintf(Vocab::EnemyRecovery, target.name, Vocab::hp, target.absorbed_dmg/2))
          end
        end
        if target.passive_absorb_mp?       # Absorb MP
          unless (target.absorbed_mp/2) < 1
            extra_text.push(sprintf(Vocab::EnemyAbsorb, target.name, Vocab::mp, target.absorbed_mp))
            extra_text.push(sprintf(Vocab::EnemyRecovery, target.name, Vocab::mp, target.absorbed_mp/2))
          end
        end
        if target.passive_damage_to_mp?    # Damage to MP
          unless (target.mp_dmg/2) < 1
            extra_text.push(sprintf(Vocab::EnemyToMP, target.name, Vocab::mp))
            extra_text.push(sprintf(Vocab::EnemyLoss, target.name, Vocab::mp, target.mp_dmg/2))
          end
        end
        if target.passive_damage_reflect?  # Reflect Damage
          extra_text.push(sprintf(Vocab::EnemyReflect, target.name, target.reflect_dmg))
          unless (target.reflect_dmg/2) < 1
            extra_text.push(sprintf(Vocab::ActorDamage, @active_battler.name, (target.reflect_dmg)/2))
            wait(15)
            Sound.play_actor_damage
            $game_troop.screen.start_shake(5, 5, 10)
          else
            extra_text.push(sprintf(Vocab::ActorNoDamage, @active_battler.name))
          end
        end
      end
    else                                    # Recovery
      fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
      text = sprintf(fmt, target.name, Vocab::hp, -target.hp_damage)
      Sound.play_recovery
    end
    @message_window.add_instant_text(text)
    wait(30)
    for etext in extra_text
      @message_window.add_instant_text(etext)
      wait(30)
    end
  end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
#  Made it easier to use for this purpose
#==============================================================================
class Window_BattleMessage < Window_Message
  #--------------------------------------------------------------------------
  # * Add Text
  #--------------------------------------------------------------------------
  def add_instant_text(text)
    unless line_number > 3
      @lines.push(text)
      refresh
    else
      replace_instant_text(text)
    end
  end
  #--------------------------------------------------------------------------
  # * Replace Text
  #--------------------------------------------------------------------------
  def replace_instant_text(text)
    @lines.delete_at(0)
    @lines.push(text)
    refresh
  end
end
#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
#  Edited to hide certain skills
#==============================================================================
class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    for skill in @actor.skills
      @data.push(skill) if @actor.show_skill?(skill) # Added 'If' statement
      if skill.id == @actor.last_skill_id
        self.index = @data.size - 1
      end
    end
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
end
 
 
 Passive Skills VX
 Passive Skills VX
 

 
 
 