Galv’s Battle Favour V.1.8

Demo – Version 1.8 >

#------------------------------------------------------------------------------#
#  Galv's Battle Favour
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.8
#------------------------------------------------------------------------------#
#  2013-04-25 - version 1.8 - fixed bug when battle ends there is a has full bar
#  2012-12-14 - version 1.7 - option added to change bar widths
#  2012-12-01 - version 1.6 - added a lot more options to tweak bar aesthetics
#  2012-11-18 - version 1.5 - added a switch to disable the favour meter
#                             fixed 'enemy text' positioning
#  2012-11-14 - version 1.4 - fixed a bug where using items would crash the game
#  2012-11-14 - version 1.3 - updated to work better with Yanfly's battle
#  2012-11-12 - version 1.2 - potential bug remedied
#  2012-11-12 - version 1.1 - bug fix
#  2012-11-12 - version 1.0 - release
#------------------------------------------------------------------------------#
#  This scripts adds a 'favour meter' to battle. As the meter fills for each
#  team (enemy or party) they gain a state that can be used to determine the
#  benefits of having higher favour. Upon reaching max favour, a common event
#  can be called to add any additional effects you might like.
#
#  These favour bars increase by causing damage. When one side causes damage, it
#  can also decrease the other side's bar by an amount based on the gain amount.
#
#  Actors and equips can give bonuses to how much these bars increase. Enemies
#  can also have different bonuses for this as well.
#
#  Skills can also be set to modify either side's favour bar without causing
#  damage.
#------------------------------------------------------------------------------#
#  SCRIPT CALLS
#------------------------------------------------------------------------------#
#  You can use script calls to change party or enemy favour during battles.
#
#  $game_party.enemy_favour = x      # set enemy favour to x
#  $game_party.favour = x            # set party favour to x
#
#  $game_actors[y].favour = x        # set actor y's favour bonus to x
#
#  For those with limited scripting knowledge, instead of "=" you can use:
#
#    -=    # minus            +=    # plus            *=    # multiply
#
#  NOTE: The enemy favour and party favour bars are reset each battle.
#  The Actor favour changes remain for the game (and is used for bonuses)
#------------------------------------------------------------------------------#
#  You can use script to get favour amounts (eg. for use in variables 'script')
#
#  $game_party.enemy_favour       # returns the amount the enemy favour bar has
#  $game_party.favour             # returns the amount the party favour bar has
#  $game_actors[x].favour         # returns how much favour actor x has
#  $game_party.members[x].favour  # returns how much favour actor in position x has
#  $game_troop.members[x].favour  # returns how much favour troop x has
#
#------------------------------------------------------------------------------#
#  NOTETAG - ACTORS
#------------------------------------------------------------------------------#
#  <favour: x>          # Where x is the actor's INITIAL favour bonus. This
#                       # bonus can change with above script calls.
#------------------------------------------------------------------------------#
#  NOTETAG - WEAPONS and ARMORS
#------------------------------------------------------------------------------#
#  <favour: x>          # Equips with this notetag will give bonus favour when
#                       # the equipped actor causes damage.
#------------------------------------------------------------------------------#
#  NOTETAG - ENEMIES
#------------------------------------------------------------------------------#
#  <favour: x>          # Enemies tagged with this will get a bonus when they
#                       # cause damage.
#------------------------------------------------------------------------------#
#  NOTETAG - SKILLS
#------------------------------------------------------------------------------#
#  <favour: x>          # Skills with this notetag will give bonus favour when
#                       # the skill used causes damage.
#------------------------------------------------------------------------------#
#
#  HOW DO THE ABOVE NOTETAG BONUSES WORK?
#
#  10% of the total bonuses an actor or enemy has is added to the amount of
#  favour that is generated for their team each time they cause damage.
#
#------------------------------------------------------------------------------#
#  NOTETAG - SKILLS and ITEMS
#------------------------------------------------------------------------------#
#  <mod_pfavour: x>        # How you want to modify party favour
#  <mod_efavour: x>        # How you want to modify enemy favour
#                          # x can be set to:
#                          # 1 for 'add', 2 for 'multiply' or 3 for 'set'.
#                          # If you leave this out, the below won't do anything.
#
#  <do_pfavour: x>         # How much to "add", "mul" or "set" party favour by.
#  <do_efavour: x>         # How much to "add", "mul" or "set" enemy favour by.
#------------------------------------------------------------------------------#
#  EXAMPLE OF TAGS ON A SKILL/ITEM:
#
#  <mod_pfavour: 3>            # This example, the skill would 'set' party
#  <do_pfavour: 50>            # favour to 50 and subtract 30 from enemy.
#  <mod_efavour: 1>            # Only one of each tag will apply.
#  <do_efavour: -30>
#
#------------------------------------------------------------------------------#
 
($imported ||= {})["Galvs_Battle_Favour"] = true
 
module Galv_Favour
#------------------------------------------------------------------------------#
#  SCRIPT SETTINGS
#------------------------------------------------------------------------------#  
 
  DISABLE_SWITCH = 1        # Turn switch ON to disable meters. Do this outside
                            # of combat.
 
#----------------------------#
#   FAVOUR BAR AESTHETICS:   #
#----------------------------#
 
  FONT = "Arial"            # The font for all bar related text
 
  TEXT_SIZE = 22            # The font size of the party/enemy text names.
  TEXT_Y = 0                # Offset ALL bar text vertically different to bars
 
  PARTY_TEXT = "PARTY"      # Text displayed above party favour bar.
  PARTY_TEXT_COLOR = 0      # The colour of the party text
  ENEMY_TEXT = "ENEMY"      # Text displayed above enemy favour bar.
  ENEMY_TEXT_COLOR = 0      # The colour of the enemy text
 
  TURNS_TEXT_SIZE = 22      # Size of the turns text
  TURNS_TEXT = " TURNS"     # Text displayed after remaining special turns
  PARTY_TURNS_COLOR = 4     # Colour of the turns text for party
  ENEMY_TURNS_COLOR = 2    # Colour of the turns text for enemy
 
  SHOW_NUMBERS = true       # Show amount of favour as numbers above the bars.
 
  BAR_WIDTH = 250           # How wide the bars are.
  BAR_HEIGHT = 10           # The height of the actual bars.
  BAR_Y = 0                 # Offset the bars vertically different to text
  BAR_POSITION = "bottom"   # Position of the favour bars. Can be "top" or
                            # "bottom" or put in a number without quotes to
                            # display the bar that many pixels from the top.
 
  PARTY_BAR_COLORS = [4,11]     # Gradient colors of party bar.
  ENEMY_BAR_COLORS = [14,10]    # Gradient colors of enemy bar.
 
  PARTY_ACTIVATE_SE = ["Barrier", 100, 100]  # SE when favours reach MAX
  PARTY_ACTIVATE_COLORS = [4,9,12,16]        # bar cycles these colors randomly
 
  ENEMY_ACTIVATE_SE = ["Barrier", 100, 100]  # ["SE Name", volume, pitch]
  ENEMY_ACTIVATE_COLORS = [2,10,18,21]        # bar cycles these colors randomly
 
#-----------------------#
#   FAVOUR MECHANICS:   #
#-----------------------#
 
  FAVOUR_MAX = 100          # The number used to determine a full favour bar.
 
  INITIAL_PARTY_FAVOUR = [5,20]    # Set amount of favour when battles begin
  INITIAL_ENEMY_FAVOUR = [5,20]    # randomized between the first and second
                                   # numbers.
 
  REDUCE_OPPONENT = 0.5     # When an enemy or party gains favour, the opposing
                            # side loses favour equal to this amount gained
                            # multiplied by this number. ie. 0.5 is 50%
 
  SPECIAL_ACTIVATE = 1          # Common event ID that is activated when
                                # the party reaches MAX favour.
  ENEMY_SPECIAL_ACTIVATE = 2    # Common event ID that is activated when
                                # the enemy reaches MAX favour.
 
  SPECIAL_TURNS = 3         # When MAX favour is reached, the party or enemy
                            # team enter a "Special mode". They retain their
  # MAX favour for this many turns. Once the special is over, the favour returns
  # to 0. While in special mode, the opposing team's favour gains are halved.
 
  # FAVOUR STATES
 
  # Below are lists to set up to determine states to apply for each favour level.
  # They are listed in pairs - a favour amount and a state id.
  # eg.  20 => 21
  # means: when favour amount reaches 20, apply state with id 21 to party/enemy.
  # Each time the next favour level is reached, it removes the previous favour
  # state the party or enemy troop had active.
 
  FAVOUR_STATES = {  # don't touch this.
#------------------------------------------------------------------------------#
 
    # PARTY FAVOUR STATES
 
      0 => 0,           # when less than 20, display no state. Leave as is.
      20 => 21,         # when 20 favour earned, state 21 applied.
      40 => 22,         # when 40 favour earned, state 22 applied.
      60 => 23,         # when 60 favour earned, state 23 applied.
      80 => 24,         # when 80 favour earned, state 24 applied.
      100 => 25,        # when 100 favour earned, state 25 applied.
 
#------------------------------------------------------------------------------#
  } # don't touch this
#------------------------------------------------------------------------------#
 
  ENEMY_FAVOUR_STATES = {  # don't touch this.
#------------------------------------------------------------------------------#
 
    # ENEMY TROOP FAVOUR STATES
 
      0 => 0,           # when less than 20, display no state. Leave as is.
      20 => 21,         # when 20 favour earned, state 21 applied.
      40 => 22,         # when 40 favour earned, state 22 applied.
      60 => 23,         # when 60 favour earned, state 23 applied.
      80 => 24,         # when 80 favour earned, state 24 applied.
      100 => 25,        # when 100 favour earned, state 25 applied.
 
#------------------------------------------------------------------------------#
  } # don't touch this
#------------------------------------------------------------------------------#
#  CHARGING FAVOUR
#------------------------------------------------------------------------------#
#  Below are equations for enemy and party to charge favour on damage caused.
#  You will need some scripting knowledge to modify this. I have set it up to
#  be used with 100 favour as the max in mind.
#------------------------------------------------------------------------------#
 
end # don't touch
module Galv_Favour_Mechanics # don't touch
 
#------------------------------------------------------------------------------#
#  CHARGING PARTY FAVOUR - Equation for gaining favour when causing damage:
#------------------------------------------------------------------------------#
  def charge_favour(damage) # don't touch
#------------------------------------------------------------------------------#  
 
    # Generate random favour depending % of max life damage actor does to enemy.
    # Add 10% of all actor's favour bonuses:
 
    @charge = rand(6) + 5 + (10 * ([damage.to_f,mhp].min / mhp)).to_i
    @charge += (get_actor_favour_bonus * 0.1).to_i
 
#------------------------------------------------------------------------------#
  end # don't touch
#------------------------------------------------------------------------------#
#  CHARGING ENEMY FAVOUR - Equation for gaining favour when causing damage:
#------------------------------------------------------------------------------#
  def charge_enemy_favour(damage) # don't touch
#------------------------------------------------------------------------------#  
 
    # Generate random favour depending % of max life damage enemy does to actor.
    # Add 10% of enemy favour bonus:
 
    @charge = rand(6) + 5 + (10 * ([damage.to_f,mhp].min / mhp)).to_i
    @charge += (get_enemy_favour_bonus * 0.1).to_i
 
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
#  END OF SCRIPT SETTINGS
#------------------------------------------------------------------------------#
  end
 
  def get_actor_favour_bonus
    @bonus = $game_temp.user.favour
    @no_equips = $game_temp.user.equips.count
    @no_equips.times { |i|
      if $game_temp.user.equips[i] != nil
        @bonus += $game_temp.user.equips[i].favour_bonus
      end
    }
    @bonus += $game_temp.skill_used.favour_bonus
    return @bonus
  end
 
  def get_enemy_favour_bonus
    @bonus = $game_temp.user.favour
    @bonus += $game_temp.skill_used.favour_bonus
    return @bonus
  end
 
end # Galv_Favour_Mechanics
 
class RPG::BaseItem
 
  def favour_bonus
    if @favour_bonus.nil?
      if @note =~ /<favour: (.*)>/i
        @favour_bonus = $1.to_i
      else
        @favour_bonus = 0
      end
    end
    @favour_bonus
  end
 
  def mod_pfavour
    if @mod_pfavour.nil?
      if @note =~ /<mod_pfavour: (.*)>/i
        @mod_pfavour = $1.to_i
      else
        @mod_pfavour = 0
      end
    end
    @mod_pfavour
  end
  def mod_efavour
    if @mod_efavour.nil?
      if @note =~ /<mod_efavour: (.*)>/i
        @mod_efavour = $1.to_i
      else
        @mod_efavour = 0
      end
    end
    @mod_efavour
  end
 
  def do_pfavour
    if @do_pfavour.nil?
      if @note =~ /<do_pfavour: (.*)>/i
        @do_pfavour = $1.to_i
      else
        @do_pfavour = 0
      end
    end
    @do_pfavour
  end
  def do_efavour
    if @do_efavour.nil?
      if @note =~ /<do_efavour: (.*)>/i
        @do_efavour = $1.to_i
      else
        @do_efavour = 0
      end
    end
    @do_efavour
  end
end # RPG::BaseItem
 
class Window_Favour < Window_Base
 
  def initialize
    super(0, 0, Graphics.width, Graphics.height)
    @cycle = 0
    contents.font.name = Galv_Favour::FONT
    update_location
    draw_favour_bars
    self.opacity = 0
  end
 
  def bar_width
    return Galv_Favour::BAR_WIDTH
  end
 
  def update
    self.refresh if $game_party.favour == Galv_Favour::FAVOUR_MAX || $game_party.enemy_favour == Galv_Favour::FAVOUR_MAX || $imported["YEA-BattleEngine"]
  end
 
  def refresh
    contents.clear
    draw_favour_bars
  end
 
  def open
    refresh
    super
  end
 
  def update_location
    case Galv_Favour::BAR_POSITION
    when "top"
      self.y = 0
    when "bottom"
      self.y = Graphics.height - 170
    else
      self.y = Galv_Favour::BAR_POSITION
    end
    self.z = 0
  end
 
  def party_random_color
    @cycle = rand(Galv_Favour::PARTY_ACTIVATE_COLORS.count)
    return Galv_Favour::PARTY_ACTIVATE_COLORS[@cycle]
  end
 
  def enemy_random_color
    @cycle = rand(Galv_Favour::ENEMY_ACTIVATE_COLORS.count)
    return Galv_Favour::ENEMY_ACTIVATE_COLORS[@cycle]
  end
 
  def draw_favour_bars
    draw_party_favour(Graphics.width / 2, 0, bar_width)
    draw_enemy_favour(Graphics.width / 2 - bar_width - 20, 0, bar_width)
  end
 
  def draw_party_favour(x, y, width)
    if $game_party.favour < Galv_Favour::FAVOUR_MAX
      draw_favour_gauge(x, y, width, favour_rate, text_color(Galv_Favour::PARTY_BAR_COLORS[0]), text_color(Galv_Favour::PARTY_BAR_COLORS[1]))
    else
      draw_favour_gauge(x, y, width, favour_rate, text_color(party_random_color), text_color(party_random_color))
      change_color(text_color(Galv_Favour::PARTY_TURNS_COLOR))
      xr = x + width
      contents.font.size = Galv_Favour::TURNS_TEXT_SIZE
      draw_text(xr - 100, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.p_special.to_s + Galv_Favour::TURNS_TEXT, 2)
 
    end
    change_color(text_color(Galv_Favour::PARTY_TEXT_COLOR))
    contents.font.size = Galv_Favour::TEXT_SIZE
 
    draw_text(x, y + Galv_Favour::TEXT_Y, bar_width, contents.font.size, party_text)
    if Galv_Favour::SHOW_NUMBERS && $game_party.p_special <= 0
      xr = x + width
      draw_text(xr - 100, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.favour.to_s, 2)
    end
  end
 
  def draw_enemy_favour(x, y, width)
 
    if $game_party.enemy_favour < Galv_Favour::FAVOUR_MAX
      draw_reverse_gauge(x, y, width, enemy_favour_rate, text_color(Galv_Favour::ENEMY_BAR_COLORS[0]), text_color(Galv_Favour::ENEMY_BAR_COLORS[1]))
    else
      draw_reverse_gauge(x, y, width, enemy_favour_rate, text_color(enemy_random_color), text_color(enemy_random_color))
      change_color(text_color(Galv_Favour::ENEMY_TURNS_COLOR))
      contents.font.size = Galv_Favour::TURNS_TEXT_SIZE
      draw_text(x + 2, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.e_special.to_s + Galv_Favour::TURNS_TEXT, 0)
    end
    change_color(text_color(Galv_Favour::ENEMY_TEXT_COLOR))
    contents.font.size = Galv_Favour::TEXT_SIZE
 
    draw_text(x + 2, y + Galv_Favour::TEXT_Y, bar_width, contents.font.size, enemy_text,2)
    if Galv_Favour::SHOW_NUMBERS && $game_party.e_special <= 0
      xr = x + width
      draw_text(x + 2, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.enemy_favour.to_s, 0)
    end
  end
 
  def enemy_text
    Galv_Favour::ENEMY_TEXT
  end
  def enemy_favour_rate
    [$game_party.enemy_favour.to_f, Galv_Favour::FAVOUR_MAX].min / Galv_Favour::FAVOUR_MAX
  end
 
  def party_text
    Galv_Favour::PARTY_TEXT
  end
  def favour_rate
    [$game_party.favour.to_f, Galv_Favour::FAVOUR_MAX].min / Galv_Favour::FAVOUR_MAX
  end
 
  def draw_favour_gauge(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8 + Galv_Favour::BAR_Y
    contents.fill_rect(x, gauge_y, width, Galv_Favour::BAR_HEIGHT, gauge_back_color)
    contents.gradient_fill_rect(x, gauge_y, fill_w, Galv_Favour::BAR_HEIGHT, color1, color2)
  end
 
  def draw_reverse_gauge(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8 + Galv_Favour::BAR_Y
    contents.fill_rect(x, gauge_y, width, Galv_Favour::BAR_HEIGHT, gauge_back_color)
    contents.gradient_fill_rect(x + width - fill_w, gauge_y, fill_w, Galv_Favour::BAR_HEIGHT, color1, color2)
  end
 
end # Window_Favour < Window_Base
 
class Scene_Battle < Scene_Base
 
  alias galv_favour_sb_start start
  def start
    set_initial_favour
    galv_favour_sb_start
  end
 
  alias galv_favour_sb_terminate terminate
  def terminate
    clear_favour
    galv_favour_sb_terminate
  end
 
  alias galv_favour_create_all_windows create_all_windows
  def create_all_windows
    galv_favour_create_all_windows
    @favour_window = Window_Favour.new if !$game_switches[Galv_Favour::DISABLE_SWITCH]
  end
 
  alias galv_favour_refresh_status refresh_status
  def refresh_status
    galv_favour_refresh_status
    @favour_window.refresh if !$game_switches[Galv_Favour::DISABLE_SWITCH]
  end
 
if $imported["YEA-BattleEngine"]
    def apply_item_effects(target, item)
    if $imported["YEA-LunaticObjects"]
      lunatic_object_effect(:prepare, item, @subject, target)
    end
    target.item_apply(@subject, item)
    status_redraw_target(@subject)
    status_redraw_target(target) unless target == @subject
    @log_window.display_action_results(target, item)
    if $imported["YEA-LunaticObjects"]
      lunatic_object_effect(:during, item, @subject, target)
    end
    @status_window.refresh if !$game_switches[Galv_Favour::DISABLE_SWITCH]
    perform_collapse_check(target)
  end
end
 
  def set_initial_favour
    $game_party.p_special = 0
    $game_party.e_special = 0
    min = Galv_Favour::INITIAL_PARTY_FAVOUR[0]
    max = Galv_Favour::INITIAL_PARTY_FAVOUR[1]
    $game_party.favour = rand(max - min) + min
    min = Galv_Favour::INITIAL_ENEMY_FAVOUR[0]
    max = Galv_Favour::INITIAL_ENEMY_FAVOUR[1]
    $game_party.enemy_favour = rand(max - min) + min
    if $game_switches[Galv_Favour::DISABLE_SWITCH]
      $game_party.favour = 0
      $game_party.enemy_favour = 0
    end
  end
 
  def clear_favour
    $game_party.favour = 0
    $game_party.enemy_favour = 0
  end
 
end # Scene_Battle < Scene_Base
 
class Game_Party < Game_Unit
  attr_accessor :favour
  attr_accessor :enemy_favour
  attr_accessor :p_special
  attr_accessor :e_special
 
  alias galv_favour_initialize initialize
  def initialize
    galv_favour_initialize
    @favour = 0
    @enemy_favour = 0
    @p_special = 0
    @e_special = 0
  end
end # Game_Party < Game_Unit
 
class Game_BattlerBase
 
  def apply_state
    # get hash with KEYS: favour required and VALUES: state ids
    @list = Galv_Favour::FAVOUR_STATES
 
    # get state_id required:
    @get_state = (@list.select {|k,v| k <= $game_party.favour}).max[1]
 
    # add state_id required. Remove all other state_id's in list
    Galv_Favour::FAVOUR_STATES.each {|key, value|
      $game_party.alive_members.each do |mem|
 
        if value == @get_state
          if !mem.state?(@get_state) && value != 0
            mem.add_favour_state(@get_state)
          end
        else
          mem.remove_state(value)
        end
      end
    }
  end
 
  def apply_enemy_state
    # get hash with KEYS: favour required and VALUES: state ids
    @enemy_list = Galv_Favour::ENEMY_FAVOUR_STATES
 
    # get state_id required:
    @get_enemy_state = (@enemy_list.select {|k,v| k <= $game_party.enemy_favour}).max[1]
 
    # add state_id required. Remove all other state_id's in list
    Galv_Favour::ENEMY_FAVOUR_STATES.each {|key, value|
      $game_troop.alive_members.each do |enemy|
 
        if value == @get_enemy_state
          if !enemy.state?(@get_enemy_state) && value != 0
            enemy.add_favour_state(@get_enemy_state)
          end
        else
          enemy.remove_state(value)
        end
      end
    }
  end
 
  def check_favour
    return if $game_switches[Galv_Favour::DISABLE_SWITCH]
    if $game_party.favour >= Galv_Favour::FAVOUR_MAX
      $game_party.favour = Galv_Favour::FAVOUR_MAX
      if $game_party.p_special == 0 && $game_party.favour == Galv_Favour::FAVOUR_MAX
        RPG::SE.new(Galv_Favour::PARTY_ACTIVATE_SE[0], Galv_Favour::PARTY_ACTIVATE_SE[1], Galv_Favour::PARTY_ACTIVATE_SE[2]).play
        $game_party.p_special = Galv_Favour::SPECIAL_TURNS
        $game_temp.reserve_common_event(Galv_Favour::SPECIAL_ACTIVATE)
      end
    elsif $game_party.favour <= 0
      $game_party.favour = 0
      $game_party.p_special = 0
    end
 
    if $game_party.enemy_favour >= Galv_Favour::FAVOUR_MAX
      $game_party.enemy_favour = Galv_Favour::FAVOUR_MAX
      if $game_party.e_special == 0 && $game_party.enemy_favour == Galv_Favour::FAVOUR_MAX
        RPG::SE.new(Galv_Favour::ENEMY_ACTIVATE_SE[0], Galv_Favour::ENEMY_ACTIVATE_SE[1], Galv_Favour::ENEMY_ACTIVATE_SE[2]).play
        $game_party.e_special = Galv_Favour::SPECIAL_TURNS
        $game_temp.reserve_common_event(Galv_Favour::ENEMY_SPECIAL_ACTIVATE)
      end
    elsif $game_party.enemy_favour <= 0
      $game_party.enemy_favour = 0
      $game_party.e_special = 0
    end
  end
end # Game_BattlerBase
 
class Game_Battler < Game_BattlerBase
  include Galv_Favour_Mechanics
 
  alias galv_favour_execute_damage execute_damage
  def execute_damage(user)
    $game_temp.user = user
    galv_favour_execute_damage(user)
  end
 
  alias galv_favour_on_damage on_damage
  def on_damage(value)
    galv_favour_on_damage(value)
    return if $game_switches[Galv_Favour::DISABLE_SWITCH]
    if $game_temp.user.actor?
      # When enemy is damaged
      if $game_party.e_special > 0
        charge = charge_favour(value)
        $game_party.favour += charge / 2
      else
        charge = charge_favour(value)
        $game_party.favour += charge
        $game_party.enemy_favour -= (charge * Galv_Favour::REDUCE_OPPONENT).to_i
      end
    else
      # When party is damaged
      if $game_party.p_special > 0
        charge = charge_enemy_favour(value)
        $game_party.enemy_favour += charge / 2
      else
        charge = charge_enemy_favour(value)
        $game_party.enemy_favour += charge
        $game_party.favour -= (charge * Galv_Favour::REDUCE_OPPONENT).to_i
      end
    end
    check_favour
    apply_state
    apply_enemy_state
  end
 
  def add_favour_state(state_id)
    add_new_state(state_id) unless state?(state_id)
    reset_state_counts(state_id)
    @result.added_states.push(state_id).uniq!
  end
 
  alias galv_favour_use_item use_item
  def use_item(item)
    $game_temp.skill_used = item
    galv_favour_use_item(item)
    change_party_favour if $game_temp.skill_used.mod_pfavour != 0
    change_enemy_favour if $game_temp.skill_used.mod_efavour != 0
    apply_state
    apply_enemy_state
    check_favour
  end
 
  def change_party_favour
    case $game_temp.skill_used.mod_pfavour
    when 1
      $game_party.favour += $game_temp.skill_used.do_pfavour
    when 2
      $game_party.favour *= $game_temp.skill_used.do_pfavour
    when 3
      $game_party.favour = $game_temp.skill_used.do_pfavour
    end
  end
 
  def change_enemy_favour
    case $game_temp.skill_used.mod_efavour
    when 1
      $game_party.enemy_favour += $game_temp.skill_used.do_efavour
    when 2
      $game_party.enemy_favour *= $game_temp.skill_used.do_efavour
    when 3
      $game_party.enemy_favour = $game_temp.skill_used.do_efavour
    end
  end
 
end # Game_Battler < Game_BattlerBase
 
class Game_Enemy < Game_Battler
  attr_accessor :favour
 
  alias galv_favour_enemy_initialize initialize
  def initialize(index, enemy_id)
    galv_favour_enemy_initialize(index, enemy_id)
    @favour = $data_enemies[enemy_id].favour_bonus
  end
 
end # Game_Enemy < Game_Battler
 
class Game_Actor < Game_Battler
  attr_accessor :favour
 
  alias galv_favour_actor_initialize initialize
  def initialize(actor_id)
    galv_favour_actor_initialize(actor_id)
    @favour = $data_actors[actor_id].favour_bonus
  end
 
end # Game_Actor < Game_Battler
 
class Game_Temp
  attr_accessor :user
  attr_accessor :skill_used
end # Game_Temp
 
module BattleManager
 
  class << self
    alias galv_favour_bm_turn_end turn_end
 
    def turn_end
      galv_favour_bm_turn_end
      return if $game_switches[Galv_Favour::DISABLE_SWITCH]
      if $game_party.p_special >= 0 && $game_party.favour == Galv_Favour::FAVOUR_MAX
        $game_party.p_special -= 1
        if $game_party.p_special == 0
          $game_party.favour = 0
          rem_party_state
        end
      end
 
      if $game_party.e_special >= 0 && $game_party.enemy_favour == Galv_Favour::FAVOUR_MAX
        $game_party.e_special -= 1
        if $game_party.e_special == 0
          $game_party.enemy_favour = 0
          rem_enemy_state
        end
      end
    end
 
    def rem_party_state
      @list = Galv_Favour::FAVOUR_STATES
 
      Galv_Favour::FAVOUR_STATES.each {|key, value|
        $game_party.alive_members.each do |mem|
          mem.remove_state(value)
        end
      }
    end
 
    def rem_enemy_state
      @enemy_list = Galv_Favour::ENEMY_FAVOUR_STATES
 
      Galv_Favour::ENEMY_FAVOUR_STATES.each {|key, value|
        $game_troop.alive_members.each do |enemy|
          enemy.remove_state(value)
        end
      }
    end
  end
 
end # BattleManager

13 thoughts on “Galv’s Battle Favour V.1.8

  1. Baqiao Liu says:

    Hey, I was just looking for this! Thanks a lot, Galv.

  2. Hairomi says:

    wow!!! I like it!!
    thankz galv-san!!! ^^

  3. Mikes Pobl says:

    Dude Awesome ass script. there’s just one thing I wish u could do if its possible.U have settings that could have skills and items to only appear during maxed favor mode and disappear when the x amount of turns have been used…My question is that could you make a note tag/mini script for the event editor in general so that anything in the event editor could wait the “x” amount of turns during favor? and then once the favor is done. The rest of the event ( if any) would continue down its respective list(s)?

    I’m asking for this because I have made the enemy favor do different things ( or react differently I should say) when it comes to normal enemies or bosses reaching there favors. Yes that’s right! you heard me! making the enemy favors react differently for certain enemies. It is do-able within ur script and I love the fact that it can.

    in my current situation of what I have been trying to do with these different favors is that once the enemies have reached there favor. It would also change the music (in this case something ominous or bad to help show/enhance how screwed u are) during their favor mode, and then return back to the normal battle music once the “x” amount of turns is used up.

    However I can’t do that. because the event editor doesn’t know how to wait the “x” amount of favor turns with ur script. In fact I don’t think there’s a way to make the event editor wait by turns or by button presses instead of frames/seconds.

    Please Reply as soon as possible. I’m looking forward to this script and I’m already having so many ideas go through my mind.

    • Galv says:

      Unfortunately I am very busy and cannot do requests at the time, sorry.

      • Mikes Pobl says:

        Its all good man. I’ll continue on configuring the hell out of this script.lol.

        ohh and i Just realized that I can only have 2 different favor reactions for the enemy even though I made it sound infinite. play testing my theories bitch slapped me both mentally, and in game towards my party cuz every favor that I made up was activated at once. LOL!

      • Galv says:

        Haha, I haven’t looked at this script in months so not really sure what you mean. But good luck with what you are trying to do!

  4. EXEC says:

    Thank you very much! I like it.

  5. AdamSakuru says:

    I noticed in the most recent update of this you mentioned that you fixed a bug where there is a full bar upon the battle ending. I noticed another bug and am not sure if it’s related to that;

    If you set a common event to run upon a full bar and the battle ends at the same time it filled up (like if you killed the last enemy and the bar hit 100), the common event will run outside of the battle on the map. Is there a way to fix this? I wanted to have an in battle event occur, but in making an event there is a chance it will occur outside of the battle where it shouldn’t.

  6. Dee says:

    Hey! Is there a way to toggle this script on and off, so for example it’s only active during boss encounters?

    • Galv says:

      Yeah, look in the script settings for:

      DISABLE_SWITCH = 1 # Turn switch ON to disable meters. Do this outside
      # of combat.

      The number is the switch you choose and use “Control Switches” to turn ON to disable the script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s