]#===============================================================================
# 
# Craze's Script Asylum - Gold/EXP Boost
# Last Date Updated: 2010.05.25
# Level: Easy
# 
# Allow certain states and pieces of equipment to raise the amount of gold
# and experience that enemies grant. Similar to KGC's version, but expanded
# and definitely compatible with Battle Engine Zealous.
#===============================================================================
# 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.
# 
# <gold bonus: x%> 
# For equipment and states. Alters the amount of gold dropped by enemies
# after battle by x%.
#
# <exp bonus: x%> 
# For equipment and states. Alters the amount of experience earned from enemies
# after battle by x%.
#
# Note that these states will do nothing if inflicted on enemies! If somebody
# would like that for some reason, I would be willing to make that work, but
# for now I don't see the point.
# 
#===============================================================================
# Examples
# -----------------------------------------------------------------------------
# <gold bonus: 125%>  
# The equipment would cause 25% more gold to be found after battle.
# 
# <exp bonus: 90%> 
# Enemies would grant 10% less of their normal EXP earnings.
# 
# This is for equipment and state noteboxes only.
#===============================================================================
# Compatibility
# -----------------------------------------------------------------------------
# There should be no compatibity issues. Works with Melody's Victory Aftermath.
# Just to be safe, place this script under any that modify the amount of gold
# and experience a monster hands out.
#===============================================================================
 
$imported = {} if $imported == nil
$imported["GoldEXPBoost"] = true


 
#==============================================================================
# RPG::BaseItem
#==============================================================================
 
class RPG::BaseItem
 
  #--------------------------------------------------------------------------
  # goldboosts 
  #--------------------------------------------------------------------------

  def goldboosts
    return @gboosts if @gboosts != nil
    @gboosts = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:GOLD_BONUS|gold bonus):[ ]*(\d+)([%%])>/i
          @gboosts.push($1.to_i)
      end
    }
    return @gboosts
  end
 
  #--------------------------------------------------------------------------
  # xpboosts 
  #--------------------------------------------------------------------------

  def xpboosts
    return @xboosts if @xboosts != nil
    @xboosts = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:EXP_BONUS|exp bonus|XP_BONUS|xp bonus):[ ]*(\d+)([%%])>/i
          @xboosts.push($1.to_i)
      end
    }
    return @xboosts
  end
 
end
 
#==============================================================================
# RPG::State
#==============================================================================
 
class RPG::State
 
  #--------------------------------------------------------------------------
  # goldboosts 
  #--------------------------------------------------------------------------

  def goldboosts
    return @gboosts if @gboosts != nil
    @gboosts = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:GOLD_BONUS|gold bonus):[ ]*(\d+)([%%])>/i
          @gboosts.push($1.to_i)
      end
    }
    return @gboosts
  end
 
  #--------------------------------------------------------------------------
  # xpboosts 
  #--------------------------------------------------------------------------

  def xpboosts
    return @xboosts if @xboosts != nil
    @xboosts = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:EXP_BONUS|exp bonus|XP_BONUS|xp bonus):[ ]*(\d+)([%%])>/i
          @xboosts.push($1.to_i)
      end
    }
    return @xboosts
  end
 
end
 
#==============================================================================
# Game_Party
#==============================================================================
 
class Game_Party
  
  #--------------------------------------------------------------------------
  # new method: party_gold_rate
  #--------------------------------------------------------------------------
  
  def party_gold_rate
    n = 100
    for actor in members
      g_rate = 100
      for equip in actor.equips.compact
        next if equip == nil
        e_g_rate = 100
        equip.goldboosts.each { |gb| e_g_rate = e_g_rate * gb / 100 unless gb == nil }
        g_rate = g_rate * e_g_rate / 100
      end
      for state in actor.states
        e_g_rate = 100
        state.goldboosts.each { |gb| e_g_rate = e_g_rate * gb / 100 unless gb == nil }
        g_rate = g_rate * e_g_rate / 100
      end
      n = n * g_rate / 100 unless g_rate == 100
    end
    return 0 if n < 0
    return n
  end
  
  #--------------------------------------------------------------------------
  # new method: party_exp_rate
  #--------------------------------------------------------------------------
  
  def party_exp_rate
    n = 100
    for actor in members
      x_rate = 100
      for equip in actor.equips.compact
        next if equip == nil
        e_x_rate = 100
        equip.xpboosts.each { |xb| e_x_rate = e_x_rate * xb / 100 unless xb == nil }
        x_rate = x_rate * e_x_rate / 100
      end
      for state in actor.states
        e_x_rate = 100
        state.xpboosts.each { |xb| e_x_rate = e_x_rate * xb / 100 unless xb == nil }
        x_rate = x_rate * e_x_rate / 100
      end
      n = n * x_rate / 100 unless x_rate == 100
    end
    return 0 if n < 0
    return n
  end
  
end
 
#==============================================================================
# Game_Enemy
#==============================================================================
 
class Game_Enemy < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias: gold
  #--------------------------------------------------------------------------
  
  alias csa_gxpb_gold gold unless $@
  def gold
    n = csa_gxpb_gold
    n = n * $game_party.party_gold_rate / 100
    return Integer(n)
  end
  
  #--------------------------------------------------------------------------
  # alias: exp
  #--------------------------------------------------------------------------
  
  alias csa_gxpb_exp exp unless $@
  def exp
    n = csa_gxpb_exp
    n = n * $game_party.party_exp_rate / 100
    return Integer(n)
  end

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