#===============================================================================
# 
# Craze's Script Asylum - State Infliction Rates
# Last Date Updated: 2010.05.26
# Level: Normal
# 
# Now you can affect the chance that a skill inflicts its states.
#
# This is a very low-calorie version of this script, due to personal time
# constraints. Expect updates for this one soon. Note that this script currently
# and will always require Battle Engine Melody; look for Mithran's Advanced
# State Probability if you're interested in this script's effects without the
# BEM requirement.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials and Battle Engine Melody but above ▼ Main. 
# Remember to save. 
#                                                                          
# <st rate: x%> 
# For skills. All of this skill's potential states' chance of being inflicted
# is altered by x%.
#===============================================================================
# Example
# -----------------------------------------------------------------------------
# <st rate: 25%> 
# The skill has 25% of its base chance to inflict the ticked "+" state, Poison.
#
# <st rate: 300%> 
# The skill has 300% of its base chance to inflict Blind and Sleep.
#===============================================================================
# Compatibility
# -----------------------------------------------------------------------------
# Note: This script requires Yanfly's Battle Engine Melody. Make sure to place
# this script below BEM. If you're using Craze's Boss Options script, place this
# above it as well.
#===============================================================================
 
$imported = {} if $imported == nil
$imported["StInflictRates"] = true

module CRAZE
  module STATE_INFLICT
    
    # This value is a percent (so, the default is 300, which is 300%).
    # If a skill gets a critical strike, its states' chance to be inflicted
    # is altered by this amount.
    CRITICAL_ST_MOD = 300
    
  end
end

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, or horrible Mousie-based death. Edit at your own risk.
#===============================================================================

if $imported["BattleEngineMelody"]

#==============================================================================
# RPG::Skill
#==============================================================================
 
class RPG::Skill < RPG::UsableItem
 
  #--------------------------------------------------------------------------
  # all_state_taken_rate
  #--------------------------------------------------------------------------

  def all_state_taken_rate
    return @st_inf if @st_inf != nil
    @st_inf = 100
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:ST_RATE|st rate|ST_PROB|st prob):[ ]*(\d+)([%%])>/i
        @st_inf = $1.to_i
      end
    }
    return @st_inf
  end
  
end
 
#==============================================================================
# Game_Battler
#==============================================================================
 
class Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: state_probability_table
  #--------------------------------------------------------------------------
  #alias csa_stinf_state_probability_table state_probability_table unless $@
  #def state_probability_table(state_id, rank)
  alias csa_stinf_state_probability state_probability unless $@
  def state_probability(state_id)
    rate = csa_stinf_state_probability(state_id)
    rate = rate * CRAZE::STATE_INFLICT::CRITICAL_ST_MOD / 100 if @critical
    return rate if $data_states[state_id].nonresistance
    return rate unless $scene.is_a?(Scene_Battle)
    return rate if $scene.active_battler == nil
    if $scene.active_battler.action.skill?
      obj = $data_skills[$scene.active_battler.action.skill_id]
      rate = rate * obj.all_state_taken_rate / 100
    end
    return [rate, 0].max
  end

end

end # imported["BattleEngineMelody"]

#===============================================================================
# 
# END OF FILE
# 
#===============================================================================