Galv’s Actor Duel Mini Game V.1.6

DOWNLOAD DEMO:
Demo – Version 1.6 >
(Script requires graphic from /Graphics/System/ and /Graphics/Battlers/ folders of the demo)

SCRIPT:

#-------------------------------------------------------------------------------
#  Galv's Actor Duel Mini Game
#-------------------------------------------------------------------------------
#  For: RPGMAKER VX ACE
#  Version 1.6
#-------------------------------------------------------------------------------
#  2016-05-02 - Version 1.6 - typo in script documentions for add_fskill
#  2013-09-11 - Version 1.5 - fixed <fse: > tag for skills. Ooops!
#  2013-07-13 - Version 1.4 - fixed a bug with changing music script call
#  2013-07-11 - Version 1.3 - added compatibility with victor's animated battler
#                           - added tag for actor to play victory pose once
#  2013-07-11 - Version 1.2 - fixed (hopefully) a crash with AI battle. Updated
#                             AI to use skills more often.
#  2013-07-10 - Version 1.1 - added state icons, button combo moves, working
#                           - regen, poisons, buffs, projectile attacks.
#  2013-07-08 - Version 1.0 - release
#-------------------------------------------------------------------------------
#  Holder's animated battler spritesheets can be found here:
#  http://animatedbattlers.wordpress.com/
#-------------------------------------------------------------------------------
#  This script adds a scene where you can face two actors against each other in
#  a mini-game duel that plays similar to a fighting game.
#  You can do Player1 VS AI or Player1 VS Player2 (on same computer)
#
#  The actors use their statistics and hp in the duel. They can move, jump,
#  block, attack and use button combo skills that you create using notetags
#  on skills. Normal attack damage formula is taken from skill 1 by default.
#
#  Actors have stamina that regenerates during the fight. Each attack uses a
#  certain amount of stamina and the fighter cannot attack or use a skill if he
#  doesn't have enough left.
#
#  Fighters can be affected by buffs and states, however a few things have no
#  effect in an actor duel such as blinds or stuns. Poisons, regen, parameter
#  boosting stats do work.
#
#-------------------------------------------------------------------------------
#  BASIC INSTRUCTIONS
#-------------------------------------------------------------------------------
#  1. Get holder style battlers (http://animatedbattlers.wordpress.com/)
#  2. Import battlers into /Graphics/Battlers folder
#  3. Copy /Graphics/Battlers/FightSkills.png from the demo into your project
#  4. Copy /Graphics/System/kombat_bar.png from the demo into your project
#  5. Put this script below Materials and above main.
#  6. Read all instructions and settings
#  7. Remember to start a NEW GAME instead of loading a save file that was made
#     prior to adding this script
#-------------------------------------------------------------------------------
 
#-------------------------------------------------------------------------------
#  SCRIPT CALLS
#-------------------------------------------------------------------------------
#
#  set_fighters(id1,id2)         # Starts a kombat between actors with id1 & id2
#
#  set_fbacks("back1","back2")   # Change battlebacks for next kombat. "back1"
#                                # is from /Graphics/Battlebacks1/ and "back2"
#                                # is from /Graphics/Battlebacks2/
#
#  set_fmusic("MusicName")       # Change the kombat music
#
#  set_fmode(x)                  # 0 = P1 vs AI      1 = P1 vs P2    (Default 0)
#
#  add_fskill(a_id,s_id,[btns])  # a_id = actor id... s_id = skill id
#                                # [btns] is the button combo array which can
#                                # include:   :l   :r   :u   :d
#                                # (See explanation below)
#
#-------------------------------------------------------------------------------
#  btn       info
#  -----------------------------
#  :l        Left key for whomever is on the left. 'away from enemy' key.
#  :r        Right key for whomever is on the left. 'toward the enemy' key.
#  :u        Up key
#  :d        Down key
#
#  EXAMPLE OF SCRIPT CALL TO ADD A SKILL:
#  add_fskill(1,80,[:l,:l,:r])     # This will give actor 1 a button combo:
#                                  # Left, Left, Right, Attack (while on left)
#                                  # (Right, Right, Left, Attack while on right)
#                                  # Which will activate skill 80
#
#-------------------------------------------------------------------------------
 
#-------------------------------------------------------------------------------
#  Note tag for ACTORS required
#-------------------------------------------------------------------------------
#
#  <fimage: imagename>       # The name of the holder-style spritesheet
#                            # image from /Graphics/Battlers/
#
#-------------------------------------------------------------------------------
#  Note tag for ACTORS to override Defaults
#-------------------------------------------------------------------------------
#
#  <fatks: x,x,x,x>          # The rows in the spritesheet to use for the
#                            # actor's normal attacks. Default is COMBO below
#
#  <fse miss: sename>        # SE to use for attacking and missing
#
#  <fhit: x>                 # Animation played when hitting enemy with attack
#
#  <frange: x>               # How close need to be to make contact with attack
#
#  <fviconeanim>             # This notetag will mean the actor's victory pose
#                            # will only play once instead of repeat.
#
#-------------------------------------------------------------------------------
 
#-------------------------------------------------------------------------------
#  Note tag for SKILLS
#-------------------------------------------------------------------------------
#
#  <fpose: x>            # The pose row used for actor when using this skill.
#                        # Will default to row 7 if no tag added.
#
#  <fcost: x>            # Stamina required to use skill
#
#  <fse: sename>         # SE that plays when using the skill
#
#  <fp: p,s,a,t,r>       # Use this tag if the skill will be a projectile.
#                        # p = pose row of SKILLIMAGE spritesheet
#                        # s = speed projectile travels
#                        # a = animation_id when projectile is created
#                        # t = time before projectile disappears (60 per second)
#                        # r = How close projectile needs to be to make contact
#                        # Skill's 'scope' must be set to enemy for this to work
#
#
#
#-------------------------------------------------------------------------------
#  BUTTON COMBO NOTE
#  If a skill has scope of ally, the animation in the database skill is played
#  on the user. If not, the animation is played when the skill hits the enemy.
#-------------------------------------------------------------------------------
 
#-------------------------------------------------------------------------------
#  DEFAULT SPRITESHEET POSES (HOLDER SETUP)
#-------------------------------------------------------------------------------
#  ROW     POSE                     USED IN DEFAULT SCRIPT
#
#   0      Idle                     Yes
#   1      Guard                    Yes
#   2      Poor Status              Yes
#   3      Get hit                  Yes
#   4      Normal Attack            Yes
#   5      Use Item
#   6      Use Skill
#   7      Use Magic                Yes
#   8      Move toward              Yes
#   9      Move back                Yes
#   10     Victory                  Yes
#   11     Battle Start
#   12     Dead                     Yes
#   13     Spritesheet Info
#-------------------------------------------------------------------------------
 
($imported ||= {})["Galv_ActorDuel"] = true
module GALVFIGHT
 
#-------------------------------------------------------------------------------
#
#  ** SETTINGS
#
#-------------------------------------------------------------------------------
 
  FONT = "Arial"  # Font used in script
  VICTOR_VAR = 1  # Variable used to store the winner's ID in. 0 if nobody wins.
 
  QUIT_SWITCH = 1 # Turn this swith ON to disable the quit menu. OFF to enable
 
  CMD_QUIT = "Quit Match"  # To quit the fight
  CMD_CANCEL = "Cancel"    # When cancelling the quit menu
 
  # Spritesheet
 
  COLS = 4        # Number of animation columns in spritesheet
  ROWS = 14       # Number of rows in spritesheet
  SIZE = 2        # Size of the battlers (2 = 2x zoom. 1 = normal)
 
  SKILLIMAGE = "FightSkills"  # name of skill spritesheet in /Graphics/Battlers/
  SKILLCOLS = 4   # Number of animation columns in skill spritesheet
  SKILLROWS = 14  # Number of rows in skill spritesheet
 
  # Actor Defaults
 
  COMBO = [4]           # Array of spritesheet rows that cycle with attacks
                        # eg. [4,5,6] will cycle rows 4,5 and 6 when attacking
  MISS_SE = "Wind7"     # "SE_Name" for missing and attack sound
  HIT_ANIM = 115        # Animation played when hitting enemy.
  GUARD_ANIM = 116      # Animation played when guarded a hit
  RANGE = 45            # Distance from opponent before attack makes contact
 
  JUMP_POSE = 8         # Pose used when jumping
 
  SKILLSE = "Wind7"     # "SE_Name" played when using a skill
 
  # Level Defaults
 
  MUSIC = "Battle6"        # Default battle BGM
  VICTORY_ME = "Victory1"  # Default victory ME
 
  BATTLEBACK1 = "Ship"  # Default battleback 1 from /Graphics/Battlebacks1/
  BATTLEBACK2 = "Ship"  # Default battleback 2 from /Graphics/Battlebacks2/
 
  P1_X = 100            # Starting X position of player 1
  P2_X = 455            # Starting X position of player 2
  Y = 310               # Grounded Y position
 
  # Fighting
 
  MAX_STAMINA = 500      # Stamina each fighter has
  STAMINA_COST = 100     # Amount of stamina out of 1000 that attacking uses
  REGEN_RATE = 1.3       # Speed that stamina regenerates
 
  GUARD_DAMAGE = 0.25    # Normal damage is multiplied by this when guarding.
 
  ATTACK_SKILL = 1       # Skill to use for basic attacks
 
  TURNTIMER = 150        # Number of frames before it counts as a new turn for
                         # buffs and states
 
  # Text
 
  START1 = "Ready?"      # Text that appears at the start
  START2 = "FIGHT!"
 
  NOWINNER = "MATCH OVER!"   # Message when player quits from the match
  WINS = " WINS!"            # Message that comes after winner's name
 
#-------------------------------------------------------------------------------
#  CONTROLS - PLAYER 1
#-------------------------------------------------------------------------------
  P1_UP =     :UP        # Jump
  P1_DOWN =   :DOWN      # Block
  P1_LEFT =   :LEFT      # Move left
  P1_RIGHT =  :RIGHT     # Move right
  P1_ACTION = :C         # (Spacebar key) Attack
 
#-------------------------------------------------------------------------------
#  CONTROLS - PLAYER 2
#-------------------------------------------------------------------------------
  P2_UP =     :R         # (W key) Jump
  P2_DOWN =   :Y         # (S key) Block
  P2_LEFT =   :X         # (A key) Move Left
  P2_RIGHT =  :Z         # (D key) Move Right
  P2_ACTION = :CTRL      # Attack
 
#-------------------------------------------------------------------------------
 
end
 
#-------------------------------------------------------------------------------
#
#  ** END SETTINGS
#
#-------------------------------------------------------------------------------
 
    #---------------#
#---|   GFIGHT_AI   |-----------------------------------------------------------
    #---------------#
 
module GFIGHT_AI
  def update_f2_ai
    update_ai_random
    update_ai_decision
    update_ai_action
    update_timer
    update_victorcheck
  end
 
  def p1; @f1; end
  def ai; @f2; end
 
  def update_ai_random
    if !ai_timer_running?
      @chance = (rand(10) + 1).to_i
      @schance = (rand(10) + 1).to_i
    end
  end
 
  def update_ai_decision
    if ai.in_range_x
      update_ai_in_range
    else
      update_ai_out_of_range
    end
  end
 
  def update_ai_in_range
    if p1.attacking?
      # IF PLAYER IS ATTACKING
      if ai.getting_hit? && @chance > 2
        @ai_move = :down
        @ai_action = false
        @ai_timer = rand(50) + 10 if !ai_timer_running?
      else
        if @chance > 5
          @ai_move = :down
          @ai_action = false
          @ai_timer = rand(50) + 10 if !ai_timer_running?
        elsif @chance > 2
          ai_melee_action
          @ai_timer = rand(20) + 5 if !ai_timer_running?
        else
          @ai_move = random_move_in_range
          @ai_timer = rand(50) + 10 if !ai_timer_running?
        end
      end
    else
      # IF PLAYER IS NOT ATTACKING
      if @chance > 4
        ai_melee_action
        @ai_timer = rand(20) + 10 if !ai_timer_running?
      elsif @chance > 2
        @ai_move = :down
        @ai_action = false
        @ai_timer = rand(40) + 20 if !ai_timer_running?
      else
        @ai_move = random_move_in_range
        @ai_timer = rand(40) + 20 if !ai_timer_running?
      end
    end
  end
 
  def update_ai_out_of_range
    @ai_move = random_move_out_of_range
    @ai_action = false
    @ai_raction = true
  end
 
  def ai_jump
    if ai.fjumping?
      @ai_move = :none
    else
      @ai_move = :up
      ai.fight_pose = 0
    end
  end
 
  def random_move_in_range
    if ai.fight_x <= 20 + 10
      return @chance > 7 ? :right : :none
    elsif ai.fight_x >= Graphics.width - 20 - 10
      return @chance > 7 ? :left : :none
    elsif @chance >= 8
      return :right
    elsif @chance >= 5
      return :left
    elsif @chance == 1
      return ai.fjumping? ? :left : :up
    elsif @chance == 2
      return ai.fjumping? ? :right : :up
    else
      return :none
    end
  end
 
  def random_move_out_of_range
    if ai.fight_x <= 20 + 10
      @ai_timer = rand(30) + 10 if !ai_timer_running?
      return @chance > 4 ? :right : :none
    elsif ai.fight_x >= Graphics.width - 20 - 10
      @ai_timer = rand(30) + 10 if !ai_timer_running?
      return @chance > 4 ? :left : :none
    elsif @chance >= 7
      @ai_timer = rand(40) + 10 if !ai_timer_running?
      return ai_advance
    elsif @chance >= 4
      @ai_timer = rand(40) + 10 if !ai_timer_running?
      return ai_retreat
    else
      @ai_timer = rand(30) + 10 if !ai_timer_running?
      return :none
    end
  end
 
  def ai_timer_running?
    @ai_timer > 0
  end
 
  def update_ai_action
    ai.fight_move(@ai_move)
    ai_melee_action if @ai_action
    ai_range_action if @ai_raction
  end
 
  def ai_melee_action
    if @schance <= 2
      bcs = get_ai_random_skill
      ai.fight_combo_skill(bcs) if bcs > 0
    else
      ai.fight_action
    end
  end
 
  def ai_range_action
    if @schance <= 3
      bcs = get_ai_projectile_skill
      ai.fight_combo_skill(bcs) if bcs > 0
    end
  end
 
  def get_ai_projectile_skill
    ai.combo_skills.each { |combo|
      return combo[1] if $data_skills[combo[1]].fproj
    }
    return 0
  end
 
  def get_ai_random_skill
    cskills = ai.combo_skills.to_a
    rskill = cskills.sample
    @ai_raction = false
    return 0 if rskill.nil?
    return rskill[1] <= 0 ? 0 : rskill[1]
  end
 
  def ai_make_attack
    if ai.fstamina < GALVFIGHT::STAMINA_COST
      @ai_move = :down
    else
      @ai_action = true
      @ai_move = random_move_in_range
    end
  end
 
  def ai_retreat
    return ai.fight_x > p1.fight_x ? :right : :left
  end
 
  def ai_advance
    return ai.fight_x < p1.fight_x ? :right : :left
  end
 
  def update_timer
    @ai_timer -= 1
  end
 
  def update_victorcheck
    if p1.dead?
      @phase = 2
      @victor = ai
    end
  end
end # GFIGHT_AI
 
    #----------------------#
#---|   GAME_INTERPRETER   |----------------------------------------------------
    #----------------------#
 
class Game_Interpreter
  def set_fighters(player1,player2)
    $game_system.save_bgm
    command_221
    a = $game_actors[player1]
    b = $game_actors[player2]
    $game_system.fighters = [a,b]
    SceneManager.call(Scene_ActorDuel)
    wait(1)
    command_222
    $game_system.replay_bgm
  end
 
  def set_fbacks(back1,back2)
    $game_system.fbacks = [back1,back2]
  end
 
  def set_fmusic(music)
    $game_system.fmusic[0] = music
  end
 
  def set_fmode(mode)
    $game_system.fmode = mode
  end
 
  def add_skill(a_id,s_id,btns)
    $game_actors[a_id].combo_skills[btns] = s_id
  end
 
  def add_fskill(a_id,s_id,btns)
    $game_actors[a_id].combo_skills[btns] = s_id
  end
end
 
    #------------------#
#---|   RPG BASEITEM   |--------------------------------------------------------
    #------------------#
 
class RPG::BaseItem
  def f_atks
    if @f_atks.nil?
      if @note =~ /<fatks:[ ](.*)>/i
        @f_atks = $1.to_s.split(",").map {|i| i.to_i}
      else
        @f_atks = GALVFIGHT::COMBO
      end
    end
    @f_atks
  end
end # RPG::Item
 
class RPG::Skill
  def fpose
    if @fpose.nil?
      if @note =~ /<fpose:[ ](.*)>/i
        @fpose = $1.to_i
      else
        @fpose = 7
      end
    end
    @fpose
  end
  def fcost
    if @fcost.nil?
      if @note =~ /<fcost:[ ](.*)>/i
        @fcost = $1.to_i
      else
        @fcost = GALVFIGHT::STAMINA_COST
      end
    end
    @fcost
  end
  def fproj
    if @fproj.nil?
      if @note =~ /<fp:[ ](.*)>/i
        @fproj = $1.to_s.split(",").map {|i| i.to_i}
      else
        @fproj = nil
      end
    end
    @fproj
  end
  def fse
    if @fse.nil?
      if @note =~ /<fse:[ ](.*)>/i
        @fse = $1.to_s
      else
        @fse = GALVFIGHT::SKILLSE
      end
    end
    @fse
  end
end # RPG::Skill
 
    #----------------#
#---|   GAME_ACTOR   |----------------------------------------------------------
    #----------------#
 
class Game_Actor < Game_Battler
  attr_reader :fhit_anim
  attr_reader :frange
  attr_accessor :fight_x
  attr_accessor :fight_y
  attr_accessor :fight_pose
  attr_accessor :fight_sprite
  attr_accessor :fight_speed
  attr_accessor :fight_mspeed
  attr_accessor :fstamina
  attr_accessor :combo_skills
  attr_accessor :fprojectiles
  attr_accessor :fvicpose
 
  alias galv_fight_gagb_setup setup
  def setup(actor_id)
    galv_fight_gagb_setup(actor_id)
    init_fight_vars
    @fight_sprite = actor.note =~ /<fimage: (.*)>/i ? $1 : ""
    @combo = actor.f_atks
    @combo_skills = {}
    @fse_miss = actor.note =~ /<fse miss: (.*)>/i ? $1 : GALVFIGHT::MISS_SE
    @fhit_anim = actor.note =~ /<fhit: (.*)>/i ? $1.to_i : GALVFIGHT::HIT_ANIM
    @frange = actor.note =~ /<frange: (.*)>/i ? $1.to_i : GALVFIGHT::RANGE
    @fvicpose = actor.note =~ /<fviconeanim>/i ? true : false # true = one play
  end
 
  def init_fight_vars
    @fight_x = 0
    @fight_y = GALVFIGHT::Y
    @fight_pose = 0
    @fight_speed = 0.to_f
    @fight_mspeed = 4
    @attack_timer = 0
    @skill_timer = 0
    @takehit_timer = 0
    @jump = 0
    @fstamina = GALVFIGHT::MAX_STAMINA
    @btn_combo = []
    @btn_timer = 0
    @fprojectiles = []
  end
 
  def fight_move(direction)
    case direction
    when :up
      fight_jump
      fight_slowing
    when :down
      fight_guard
      fight_slowing
    when :left
      if !attacking?
        if @fight_x < fight_target.fight_x
          @fight_pose = 9
        else
          @fight_pose = 8
        end
      end
      return @fight_speed = 0 if fight_left_limit
      @fight_speed -= 0.4
      @fight_speed = -@fight_mspeed if @fight_speed <= -@fight_mspeed
    when :right
      if !attacking?
        if @fight_x < fight_target.fight_x
          @fight_pose = 8
        else
          @fight_pose = 9
        end
      end
      return @fight_speed = 0 if fight_right_limit
      @fight_speed += 0.4
      @fight_speed = @fight_mspeed if @fight_speed >= @fight_mspeed
    when :none
      if !attacking?
        @fight_pose = fjumping? ? GALVFIGHT::JUMP_POSE : fight_idle_pose
      end
      fight_slowing
    end
  end
 
  def fight_right_limit; @fight_x >= Graphics.width - 20; end
  def fight_left_limit; @fight_x <= 20; end
 
  def fight_idle_pose
    hp < mhp * 0.25 ? 2 : 0
  end
 
  def fight_slowing
    if moving_right?
      return @fight_speed = 0 if @fight_x >= Graphics.width - 20
      @fight_speed -= [0 + @fight_speed,0.3].min
    elsif moving_left?
      return @fight_speed = 0 if @fight_x <= 20
      @fight_speed += [0 - @fight_speed,0.3].min
    end
  end
 
  def fight_action
    return if attacking? || guarding? || getting_hit?
    bcs = get_combo_skill
    if bcs.nil?
      fight_normal_attack
    else
      fight_combo_skill(bcs)
    end
  end
 
  def get_combo_skill
    @combo_skills.each { |combo|
      if @btn_combo.reverse[0..(combo[0].size - 1)] == combo[0].reverse
        return combo[1]
      end
    }
    return nil
  end
 
  def fight_normal_attack
    return if @fstamina < GALVFIGHT::STAMINA_COST
    @fskill_used = nil
    @fstamina -= GALVFIGHT::STAMINA_COST
    se = @fse_miss
    vol = 80 + rand(20)
    pit = 100 + rand(50)
    RPG::SE.new(se,vol,pit).play
    @combo = @combo.rotate
    @fight_pose = @combo[0]
    @attack_timer = 22
  end
 
  def fight_combo_skill(skill)
    sk = $data_skills[skill]
    return if @fstamina < sk.fcost #fight_normal_attack if @fstamina < sk.fcost
    return if attacking?
    @fstamina -= sk.fcost
    se = sk.fse
    vol = 80 + rand(20)
    pit = 100 + rand(50)
    RPG::SE.new(se,vol,pit).play
    if sk.fproj
      # Create Projectile Here
      @fprojectiles << FightProjectile.new(sk,self)
      self.animation_id = sk.fproj[2]
      @skill_timer = 22
    elsif sk.scope >= 7
      self.animation_id = sk.animation_id
      self.fight_item_apply(self, sk)
      @skill_timer = 22
    else
      @fskill_used = sk
      @attack_timer = 22
    end
    @fight_pose = sk.fpose
  end
 
  def fight_item_apply(user, item)
    @result.clear
    @result.used = item_test(user, item)
    @result.missed = (@result.used && rand >= item_hit(user, item))
    @result.evaded = (!@result.missed && rand < item_eva(user, item))
    if @result.hit?
      @result.critical = (rand < item_cri(user, item))
      damage = fight_damage_value(self, $data_skills[item.id])
      fight_target.do_damage(guarding?,item.id,damage)
      item.effects.each {|effect| item_effect_apply(user, item, effect) }
      item_user_effect(user, item)
    end
  end
 
  def fight_guard
    return if attacking?
    @fight_pose = 1
  end
 
  def fight_jump
    return if fjumping? || in_air?
    @jump = -10 - GALVFIGHT::SIZE / 2
  end
 
  def fjumping?; @jump < 0; end
  def in_air?; @fight_y < GALVFIGHT::Y; end
  def attacking?; @attack_timer > 0 || @skill_timer > 0; end
  def guarding?; @fight_pose == 1; end
  def getting_hit?; @takehit_timer > 0; end
  def moving_right?; @fight_speed > 0; end
  def moving_left?; @fight_speed < 0; end
  def away(amount)
    if fight_x < fight_target.fight_x
      return amount
    else
      return -amount
    end
  end
 
  def move_pose(direction)
    return 1 if @fight_x < fight_target.fight_x
  end
 
  def update_fight
    @takehit_timer -= 1
    update_fight_movement
    update_gravity
    return @fight_pose = 12 if dead?
    return @fight_pose = 3 if getting_hit? && !guarding?
    update_btn_combo
    update_stamina
    update_hit
    @attack_timer -= 1
    @skill_timer -= 1
  end
 
  def update_stamina
    @fstamina += GALVFIGHT::REGEN_RATE if @fstamina < GALVFIGHT::MAX_STAMINA
  end
 
  def update_fight_movement
    if moving_right?
      @fight_x += [@fight_speed,@fight_mspeed].min
    elsif moving_left?
      @fight_x += [@fight_speed,-@fight_mspeed].max
    end
  end
 
  def update_gravity
    if fjumping? || in_air?
      @fight_y += @jump + $game_system.gravity
      @jump += 0.2
    else
      @fight_y = GALVFIGHT::Y
      @jump = 0
    end
  end
 
  def fight_target
    if $game_system.fighters[0].id == @actor_id
      return $game_system.fighters[1]
    else
      return $game_system.fighters[0]
    end
  end
 
  def update_hit
    if @attack_timer == 8
      if make_contact?
        if fight_target.guarding?
          fight_target.animation_id = GALVFIGHT::GUARD_ANIM
          s = @fskill_used ? @fskill_used : $data_skills[GALVFIGHT::ATTACK_SKILL]
          damage = fight_damage_value(self,s)
          do_damage(true,s.id,damage)
          @fskill_used = nil
        else
          if @fskill_used
            anim = @fskill_used.animation_id
            s = @fskill_used
          else
            anim = @fhit_anim
            s = $data_skills[GALVFIGHT::ATTACK_SKILL]
          end
          fight_target.animation_id = anim
          damage = fight_damage_value(self,s)
          do_damage(false,GALVFIGHT::ATTACK_SKILL,damage)
          @fskill_used = nil
        end
      end
    end
  end
 
  def proj_hit(skill)
    if fight_target.guarding?
      fight_target.animation_id = GALVFIGHT::GUARD_ANIM
    else
      fight_target.animation_id = skill.animation_id
    end
    fight_target.fight_item_apply(self,skill)
  end
 
  def do_damage(guard,s_id,damage,proj = false)
    if guard
      damage *= GALVFIGHT::GUARD_DAMAGE
      if damage > 0
        fight_target.fight_speed += away(2) * GALVFIGHT::SIZE
        @fight_speed += fight_target.away(2) * GALVFIGHT::SIZE if proj
      end
    else
      fight_target.fight_speed += away(4) * GALVFIGHT::SIZE if damage > 0
    end
    fight_target.fight_damage(damage)
  end
 
  def fight_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_variance(value, item.damage.variance)
    return value
  end
 
  def fight_damage(damage)
    change_hp(-damage.to_i,true) if SceneManager.scene.phase == 1
    @attack_timer = 0
    @skill_timer = 0
    if damage > 0
      @takehit_timer = 18
      remove_states_by_damage
    end
  end
 
  def reach; @frange * GALVFIGHT::SIZE; end
  def range; (fight_target.fight_x - @fight_x).abs; end
  def in_range_x; (fight_target.fight_x - @fight_x).abs < reach; end
  def in_range_y; ((fight_target.fight_y - @fight_y).abs) * 1.2 < reach ;end
  def near_range_x; ((fight_target.fight_x - @fight_x).abs) / 1.5 < reach; end
 
  def make_contact?
    return true if in_range_x && in_range_y
  end
 
  def reset_fight
    erase_state(death_state_id)
    @hp = 1 if @hp <= 0
    init_fight_vars
  end
 
  def end_match
    @fight_pose = 0 if !dead?
  end
 
  def sta_rate
    @fstamina.to_f / GALVFIGHT::MAX_STAMINA
  end
 
  def update_btn_combo
    @btn_combo = [] if @btn_timer == 0
    @btn_timer -= 1
  end
 
  def add_combo(direction)
    @btn_timer = 20
    @btn_combo << direction
  end
end # Game_Actor < Game_Battler
 
    #-----------------#
#---|   GAME_SYSTEM   |---------------------------------------------------------
    #-----------------#
 
class Game_System
  attr_accessor :fighters
  attr_accessor :fmode
  attr_accessor :gravity
  attr_accessor :fbacks
  attr_accessor :fmusic
 
  alias galv_fight_gs_initialize initialize
  def initialize
    galv_fight_gs_initialize
    @gravity = 5
    @fbacks = [GALVFIGHT::BATTLEBACK1,GALVFIGHT::BATTLEBACK2]
    @fmusic = [GALVFIGHT::MUSIC,GALVFIGHT::VICTORY_ME]
    @fmode = 0 #  0 is Player vs AI   1 is Player vs Player
  end
end # Game_System
 
    #---------------------#
#---|   SCENE_ACTORDUEL   |-----------------------------------------------------
    #---------------------#
 
class Scene_ActorDuel < Scene_Base
  attr_accessor :spriteset
  attr_reader :phase
  include GFIGHT_AI
 
  def start
    super
    init_fvariables
    determine_fighters
    create_spriteset
    create_windows
  end
 
  def init_fvariables
    $game_variables[GALVFIGHT::VICTOR_VAR] = 0
    @phase = 0
    @ai_move = :none
    @ai_action = false
    @ai_timer = 0
    @bufftimer = 0
    RPG::BGM.new($game_system.fmusic[0],100,100).play
  end
 
  def determine_fighters
    @f1,@f2 = $game_system.fighters
    @f1.fight_x = GALVFIGHT::P1_X
    @f2.fight_x = GALVFIGHT::P2_X
  end
 
  def create_spriteset
    @spriteset = Spriteset_ActorDuel.new
  end
 
  def create_windows
    @hp_window = Window_FightHealth.new
    @info_window = Window_Fight.new
    @command_window = Window_FightCommand.new
    @command_window.deactivate.hide
    @command_window.set_handler(:ok,     method(:on_ok))
    @command_window.set_handler(:cancel, method(:on_cancel))
  end
 
  def on_ok
    @phase = 2
    @command_window.hide.deactivate
    @f1.end_match
    @f2.end_match
  end
 
  def on_cancel
    @command_window.hide.deactivate
  end
 
#--------|  UPDATE
 
  def update
    super
    update_graphics
    case @phase
    when 0
      update_begin
    when 1
      return if @command_window.active
      update_fighter1
      update_fighter2
      update_other
    when 2
      update_common(@f2)
      update_common(@f1)
      @f1.fight_speed = 0
      @f2.fight_speed = 0
      update_end
    end
  end
 
  def update_begin
    return while @info_window.active
    @phase = 1
  end
 
  def update_end
    RPG::ME.new($game_system.fmusic[1],100,100).play if !@end_timer
    @end_timer ||= 60
    @victor.fight_pose = 10 if @victor
    @end_timer -= 1
    return if @end_timer > 0
    @info_window.victory(@victor) if @end_timer == 0
    return while @info_window.active
    $game_system.fighters.each { |actor| actor.reset_fight }
    $game_variables[GALVFIGHT::VICTOR_VAR] = @victor ? @victor.id : 0
    SceneManager.return
  end
 
  def update_graphics
    @spriteset.update
  end
 
  def update_other
    if Input.trigger?(:B) && !$game_switches[GALVFIGHT::QUIT_SWITCH]
      @command_window.show.activate
    end
    if @bufftimer >= GALVFIGHT::TURNTIMER
      @f1.on_turn_end
      @f2.on_turn_end
      @f1.remove_buffs_auto
      @f2.remove_buffs_auto
      @bufftimer = 0
    end
    @bufftimer += 1
  end
 
  def update_fighter1
    update_f1_movement
    update_f1_action
    update_common(@f1)
  end
 
  def update_f1_movement
    if Input.press?(GALVFIGHT::P1_DOWN)
      @f1.fight_move(:down)
      @f1.add_combo(:d) if Input.trigger?(GALVFIGHT::P1_DOWN)
    elsif Input.trigger?(GALVFIGHT::P1_UP)
      @f1.fight_move(:up)
      @f1.add_combo(:u)
    elsif Input.press?(GALVFIGHT::P1_LEFT)
      @f1.fight_move(:left)
      @f1.add_combo(get_back_dir(@f1)) if Input.trigger?(GALVFIGHT::P1_LEFT)
    elsif Input.press?(GALVFIGHT::P1_RIGHT)
      @f1.fight_move(:right)
      @f1.add_combo(get_forward_dir(@f1)) if Input.trigger?(GALVFIGHT::P1_RIGHT)
    else
      @f1.fight_move(:none)
    end
  end
 
  def get_back_dir(player)
    return player.fight_x < player.fight_target.fight_x ? :l : :r
  end
 
  def get_forward_dir(player)
    return player.fight_x < player.fight_target.fight_x ? :r : :l
  end
 
  def update_f1_action
    @f1.fight_action if Input.trigger?(GALVFIGHT::P1_ACTION) &&
      !@f1.attacking? && !@f1.guarding?
    if @f2.dead?
      @phase = 2
      @victor = @f1
    end
  end
 
  def update_fighter2
    if $game_system.fmode == 1
      update_f2_movement
      update_f2_action
    else
      update_f2_ai
    end
    update_common(@f2)
  end
 
  def update_f2_movement
    if Input.press?(GALVFIGHT::P2_DOWN)
      @f2.fight_move(:down)
      @f2.add_combo(:d) if Input.trigger?(GALVFIGHT::P2_DOWN)
    elsif Input.trigger?(GALVFIGHT::P2_UP)
      @f2.fight_move(:up)
      @f2.add_combo(:u)
    elsif Input.press?(GALVFIGHT::P2_LEFT)
      @f2.fight_move(:left)
      @f2.add_combo(get_back_dir(@f2)) if Input.trigger?(GALVFIGHT::P2_LEFT)
    elsif Input.press?(GALVFIGHT::P2_RIGHT)
      @f2.fight_move(:right)
      @f2.add_combo(get_forward_dir(@f2)) if Input.trigger?(GALVFIGHT::P2_RIGHT)
    else
      @f2.fight_move(:none)
    end
  end
 
  def update_f2_action
    @f2.fight_action if Input.trigger?(GALVFIGHT::P2_ACTION) && !@f2.attacking? && !@f2.guarding?
    if @f1.dead?
      @phase = 2
      @victor = @f2
    end
  end
 
  def update_common(fighter)
    fighter.update_fight
  end
 
#--------|  DESTROY
 
  def dispose_spriteset
    @spriteset.dispose
  end
 
  def terminate
    super
    dispose_spriteset
    @f1.on_battle_end
    @f2.on_battle_end
  end
end # Scene_Kombat < Scene_Base
 
    #-------------------------#
#---|   SPRITESET_ACTORDUEL   |-------------------------------------------------
    #-------------------------#
 
class Spriteset_ActorDuel
  attr_accessor :viewport3
 
  def initialize
    create_viewports
    create_battleback1
    create_battleback2
    create_fighters
    create_face1
    create_face2
    create_bars
    update
  end
 
#-------- |  CREATE STUFF
 
  def create_viewports
    @viewport1 = Viewport.new
    @viewport2 = Viewport.new
    @viewport3 = Viewport.new
    @viewport1.z = 20
    @viewport2.z = 50
    @viewport3.z = 150
  end
 
  def create_battleback1
    return if !$game_system.fbacks[0]
    @back1_sprite = Sprite.new(@viewport1)
    @back1_sprite.bitmap = Cache.battleback1($game_system.fbacks[0])
    @back1_sprite.z = -1
    center_sprite(@back1_sprite)
  end
 
  def create_battleback2
    return if !$game_system.fbacks[1]
    @back2_sprite = Sprite.new(@viewport1)
    @back2_sprite.bitmap = Cache.battleback2($game_system.fbacks[1])
    @back2_sprite.z = 0
    center_sprite(@back2_sprite)
  end
 
  def create_fighters
    @fighters = []
    @shadows = []
    $game_system.fighters.each { |f|
      @shadows << Sprite_FightShadow.new(@viewport2,f)
      @fighters << Sprite_Fighter.new(@viewport2,f)
    }
  end
 
  def create_face1
    face_index = $game_system.fighters[0].face_index
    @face1 = Sprite.new(@viewport2)
    @face1.bitmap = Cache.face($game_system.fighters[0].face_name)
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
    @face1.src_rect.set(rect)
  end
 
  def create_face2
    face_index = $game_system.fighters[1].face_index
    @face2 = Sprite.new(@viewport2)
    @face2.bitmap = Cache.face($game_system.fighters[1].face_name)
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
    @face2.src_rect.set(rect)
    @face2.x = Graphics.width - 96
    @face2.mirror = true
  end
 
  def create_bars
    @bar1 = Sprite.new(@viewport3)
    @bar1.bitmap = Cache.system("kombat_bar") rescue Cache.system("")
    @bar2 = Sprite.new(@viewport3)
    @bar2.bitmap = Cache.system("kombat_bar") rescue Cache.system("")
    @bar2.x = Graphics.width - @bar2.bitmap.width
    @bar2.mirror = true
  end
 
#-------- |  UPDATE STUFF
 
  def update
    @fighters.each { |s| s.update }
    @shadows.each { |s| s.update }
    @viewport1.update
    @viewport2.update
    @viewport3.update
    update_projectiles
  end
 
  def update_projectiles
    $game_system.fighters.each { |f|
      f.fprojectiles.each_with_index { |p,i|
        if p.finished?
          p.dispose if !p.nil?
          p = nil
        else
          p.update
        end
      }
      f.fprojectiles.compact!
    }
  end
 
#-------- |  DESTROY STUFF
 
  def dispose
    dispose_viewports
    dispose_fighters
    dispose_background
    dispose_faces
    dispose_projectiles
  end
 
  def dispose_viewports
    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
  end
 
  def dispose_fighters
    @fighters.each { |s| s.dispose }
    @shadows.each { |s| s.dispose }
    @bar1.dispose
    @bar2.dispose
  end
 
  def dispose_background
    @back1_sprite.dispose if @back1_sprite
    @back2_sprite.dispose if @back2_sprite
  end
 
  def dispose_faces
    @face1.dispose
    @face2.dispose
  end
 
  def dispose_projectiles
    $game_system.fighters.each { |f|
      f.fprojectiles.each { |p| p.dispose }
    }
  end
 
  def center_sprite(sprite)
    sprite.ox = sprite.bitmap.width / 2
    sprite.oy = sprite.bitmap.height / 2
    sprite.x = Graphics.width / 2
    sprite.y = Graphics.height / 2
  end
end # Spriteset_ActorDuel
 
    #-------------------#
#---|   SPRITE_FIGHTER  |-------------------------------------------------------
    #-------------------#
 
class Sprite_Fighter < Sprite_Battler
  def initialize(viewport, battler = nil)
    super(viewport,battler)
    init_fvariables
  end
 
  def init_fvariables
    @pattern = 0
    @speed_timer = 0
    @pose = 0
    if $game_system.fighters[0].id == @battler.id
      player = 0; opponent = 1
    else
      player = 1; opponent = 0
    end
    @player = $game_system.fighters[player]
    @opponent = $game_system.fighters[opponent]
  end
 
  def update
    if @battler.fight_sprite
      update_bitmap
      update_pose
      update_src_rect
      update_anim
      update_position
      update_facing
    end
    super
  end
 
  def update_bitmap
    new_bitmap = Cache.battler(@battler.fight_sprite,
      @battler.battler_hue)
    if bitmap != new_bitmap
      self.bitmap = new_bitmap
      spritesheet_normal
      init_visibility
      self.zoom_x = GALVFIGHT::SIZE
      self.zoom_y = GALVFIGHT::SIZE
    end
  end
 
  def spritesheet_normal
    @cw = bitmap.width / GALVFIGHT::COLS
    @ch = bitmap.height / GALVFIGHT::ROWS
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_pose
    if @pose != @battler.fight_pose
      @pattern = 0
      @pose = @battler.fight_pose
    end
  end
 
  def update_src_rect
    if @pattern >= GALVFIGHT::COLS
      if @battler.fight_pose == 10 && @battler.fvicpose
        @pattern = GALVFIGHT::COLS - 1
      else
        @pattern = 0
      end
    end
    sx = @pattern * @cw
    sy = @battler.fight_pose * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
 
  def update_origin;end
 
  def update_anim
    @speed_timer += 1
    if @speed_timer > 6
      @pattern += 1
      @speed_timer = 0
    end
  end
 
  def update_facing
    self.mirror = @player.fight_x > @opponent.fight_x ? false : true
  end
 
  def update_position
    self.x = @battler.fight_x
    self.y = @battler.fight_y
  end
 
  def make_animation_sprites
    @ani_sprites = []
    if !@@ani_spr_checker.include?(@animation)
      16.times do
        sprite = ::Sprite.new(viewport)
        sprite.visible = false
        @ani_sprites.push(sprite)
      end
      if @animation.position == 3
        @@ani_spr_checker.push(@animation)
      end
    end
    @ani_duplicated = @@ani_checker.include?(@animation)
    if !@ani_duplicated && @animation.position == 3
      @@ani_checker.push(@animation)
    end
  end
end # Sprite_Fighter < Sprite_Battler
 
    #------------------#
#---|   SPRITE_SHADOW  |--------------------------------------------------------
    #------------------#
 
class Sprite_FightShadow < Sprite
  def initialize(viewport, player)
    super(viewport)
    @player = player
    create_shadow
  end
 
  def dispose
    bitmap.dispose if bitmap
    super
  end
 
  def update
    super
    update_position
  end
 
  def create_shadow
    self.bitmap = Cache.system("Shadow")
    self.ox = self.bitmap.width / 2
    self.oy = self.bitmap.height
    self.z = 0
    self.zoom_x = GALVFIGHT::SIZE
    self.zoom_y = GALVFIGHT::SIZE
  end
 
  def update_position
    self.x = @player.fight_x
    self.y = GALVFIGHT::Y
  end
end # Sprite_FightShadow < Sprite
 
    #-----------------------#
#---|   WINDOW_FIGHTHEALTH  |---------------------------------------------------
    #-----------------------#
 
class Window_FightHealth < Window_Base
  def initialize
    super(0, 0, Graphics.width, 140)
    self.opacity = 0
    refresh
  end
 
  def player; $game_system.fighters; end
 
  def update
    super
    refresh
  end
 
  def refresh
    contents.clear
    contents.font.name = GALVFIGHT::FONT
    draw_player1
    draw_player2
  end
 
  def draw_player1
    pl = player[0]
    draw_hp(pl, 100, 15, false)
    draw_stamina(pl, 100, 40, false)
    draw_text(100,0,100,line_height,pl.name,0)
    draw_actor_icons(pl, 100, 65, 240)
  end
 
  def draw_player2
    pl = player[1]
    draw_hp(pl, contents.width - 224, 15, true)
    draw_stamina(pl, contents.width - 224, 40, true)
    draw_text(contents.width - 200,0,100,line_height,pl.name,2)
    draw_actor_icons(pl, contents.width - 224, 65, 240)
  end
 
  def draw_hp(actor, x, y, r)
    draw_gauge(x, y, 124, actor.hp_rate, hp_gauge_color1, hp_gauge_color2, r, 12)
  end
 
  def draw_stamina(actor, x, y, r)
    draw_gauge(x, y, 124, actor.sta_rate, mp_gauge_color1, mp_gauge_color2, r, 6)
  end
 
  def draw_gauge(x, y, width, rate, color1, color2, reverse, height)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8
    contents.fill_rect(x, gauge_y, width, height, gauge_back_color)
    if reverse
      contents.gradient_fill_rect(x + width - fill_w, gauge_y, fill_w, height,
        color1, color2)
    else
      contents.gradient_fill_rect(x, gauge_y, fill_w, height, color1, color2)
    end
  end
end # Window_FightHealth < Window_Base
 
    #-----------------#
#---|   WINDOW_FIGHT  |---------------------------------------------------------
    #-----------------#
 
class Window_Fight < Window_Base
  attr_accessor :phase
  attr_accessor :victor
 
  def initialize
    super(0, 0, Graphics.width, Graphics.height)
    self.opacity = 0
    @phase = 0
    @timer = 0
  end
 
  def update
    case @phase
    when 0
      contents.clear
      contents.font.name = GALVFIGHT::FONT
      contents.font.size += 1
      draw_text(0,0,width,height,GALVFIGHT::START1,1)
    when 2
      contents.clear
      contents.font.name = GALVFIGHT::FONT
      contents.font.size = 80
      draw_text(0,0,width,height,GALVFIGHT::START2,1)
    when 3
      contents.clear
      deactivate
    when 4
      contents.clear
      contents.font.size = 60
      if @victor
        contents.font.name = GALVFIGHT::FONT
        txt = @victor.name.upcase + GALVFIGHT::WINS
        draw_text(0,0,width,height,txt,1)
      else
        contents.font.name = GALVFIGHT::FONT
        draw_text(0,0,width,height,GALVFIGHT::NOWINNER,1)
      end
    when 5
      contents.clear
      deactivate
    end
    @timer += 1
    @phase = 1 if @timer == 40
    @phase = 2 if @timer == 100
    @phase = 3 if @timer == 130
    @phase = 5 if @timer == 300
  end
 
  def victory(victor)
    @victor = victor
    @phase = 4
    @timer = 150
    activate
  end
end # Window_Fight < Window_Base
 
    #------------------------#
#---|   WINDOW_FIGHTCOMMAND  |--------------------------------------------------
    #------------------------#
 
class Window_FightCommand < Window_Command
  def initialize
    super(Graphics.width / 2 - window_width / 2, Graphics.height / 2 - 80)
  end
 
  def window_width; return 160; end
  def visible_line_number; return 2; end
 
  def make_command_list
    add_command(GALVFIGHT::CMD_QUIT, :quit, true)
    add_command(GALVFIGHT::CMD_CANCEL, :cancel, true)
  end
 
  def update; super; end
  def select_last; select(0); end
end # Window_FightCommand < Window_Command
 
    #---------------------------#
#---|   SPRITE_FIGHTPROJECTILE  |-----------------------------------------------
    #---------------------------#
 
class FightProjectile < Sprite_Base
  attr_accessor :skill
  def initialize(skill, owner)
    @owner = owner
    @target = owner.fight_target
    @skill = skill
    super(SceneManager.scene.spriteset.viewport3)
    init_fvariables
    create_bitmap
  end
 
  def init_fvariables
    self.x = @owner.fight_x
    self.y = @owner.fight_y
    self.opacity = 0
    @pattern = 0
    @pose = @skill.fproj[0]
    @speed_timer = 0
    @range_limit = @skill.fproj[3]
    @range = 0
    @reach = @skill.fproj[4]
  end
 
  def update
    update_src_rect
    update_anim
    update_position
    update_hit
    super
  end
 
  def create_bitmap
    self.bitmap = Cache.battler(GALVFIGHT::SKILLIMAGE, 0)
    @cw = bitmap.width / GALVFIGHT::SKILLCOLS
    @ch = bitmap.height / GALVFIGHT::SKILLROWS
    self.ox = @cw / 2
    self.oy = @ch
    self.mirror = @owner.fight_x > @target.fight_x ? false : true
  end
 
  def update_src_rect
    if @pattern >= GALVFIGHT::SKILLCOLS
      @pattern = 0
    end
    sx = @pattern * @cw
    sy = @pose * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
 
  def update_anim
    @speed_timer += 1
    if @speed_timer > 6
      @pattern += 1
      @speed_timer = 0
    end
  end
 
  def update_position
    self.x += self.mirror ? @skill.fproj[1] : -@skill.fproj[1]
    self.opacity += 20
    @range += 1
  end
 
  def make_animation_sprites
    @ani_sprites = []
    if !@@ani_spr_checker.include?(@animation)
      16.times do
        sprite = ::Sprite.new(viewport)
        sprite.visible = false
        @ani_sprites.push(sprite)
      end
      if @animation.position == 3
        @@ani_spr_checker.push(@animation)
      end
    end
    @ani_duplicated = @@ani_checker.include?(@animation)
    if !@ani_duplicated && @animation.position == 3
      @@ani_checker.push(@animation)
    end
  end
 
  def dispose; super; end
 
  def finished?; @range >= @range_limit; end
 
  def in_range_x; (@target.fight_x - self.x).abs < @reach; end
  def in_range_y; (@target.fight_y - self.y).abs < @reach + 60; end
 
  def make_contact?; return true if in_range_x && in_range_y; end
 
  def update_hit
    if make_contact?
      @owner.proj_hit(@skill)
      @range = @range_limit
    end
  end
end # FightProjectile < Sprite_Base

90 thoughts on “Galv’s Actor Duel Mini Game V.1.6

  1. Nosleinad says:

    Hello Galv,
    I am using the high fantasy holder sheets, and the shadows of the sprites (which mean the actual hit box) is way ahead the sprite graphics, which means the hit collision is ahead its graphic, totally messing the fight. Is there a way to solve this?

    • Galv says:

      I don’t know what they look like, but I will add something to allow an offset for spritesheets that would fix that in the next update

      • Nosleinad says:

        Thanks Galv, if you want i can make you a screenshot or a video. They look pretty nice, gives a feel of a mortal kombat game =).

    • Galv says:

      Hmm, interested in seeing the sheets you are using. Unless I am mistaken it should be centered, so unless they are not centered in the spritesheet?

      • Nosleinad says:

        Sorry for the late reply Galv. Yeah it doesn’t happen only with your script, it happens also in symphony. They are a bit more to the left. You can test them by picking the latest free resources of PV games (the one who made the high gantasy series), or if you prefer i can pass only the sheets for you via PM in the official forum. Here’s the link: http://www.pioneervalleygames.com/free-resources.html

      • Galv says:

        Ahh, I see. Their animated battlers are not centered. I’ll get to this one day, but pretty busy so not sure when.

  2. Legault says:

    Genius!

  3. Pikalyze says:

    For some reason, I feel like 1.2’s AI is ALOT easier :P.

  4. Romoku says:

    Galv help!Since i have no knowledge in scripting!I try using “set_fmusic(“Duel minigame”) and it says the error exact quote:”Unable to find file: Audio/BGM/d” and if i change the music to “d” then it says:”Unable to find file: Audio/BGM/Duel minigame” can you please find me a solution?

    • Romoku says:

      And while we are at it i cant make it that when i get defeated it brings up the game over screen.

      • Galv says:

        By default actors will not die from a duel, they go to 1 hp afterward. You could use eventing to make a game over if that’s what you want it to do but I might add in that option later to make it easier.

        The music changing issue was a bug – I have fixed that now in version 1.4. Thanks for letting me know.

  5. dan says:

    maybe you can add something like, get experience and gold when hero win battle

  6. Damani Brown says:

    Is there any way I can disable jumping?

  7. Bedjoe says:

    Thank you so much for sharing this script Galv ^^
    It worked perfectly until I tried putting it together with Mog adv battle HUD.
    When I try to initiate the duel, I get an error message.

    Script ‘MOG_Adv_Battle_hud’ line 772: TypeError occured.
    nil can’t be coerced into Fixnum

    I have also tried putting only these 2 scripts together in a fresh project
    and the same error message still pops out
    I’m wondering if there’s a way to fix this.
    Thank you for any response in advance.

  8. Tyler Borgeson says:

    Hi, Galv. I was wonder how I could add more fighters into the mini game? I downloaded a few of the battlers from the website listed above, and I can’t figure out how to actually add them into the game.

    • Galv says:

      Download the demo and look at how it’s set up.
      The battlers you download are in /Graphics/Battlers/ folder

      • Tyler Borgeson says:

        I put the battlers in the folder, but when I set it up for the new characters to be usable, this happens.

        I’m also not that good at reading script, so I couldn’t find where the characters were.

      • Galv says:

        I’m not sure what is happening there – Is one character invisible?

        Make sure the note tag is the same name as the battler image file.
        Also run through this error checklist to try to find the problem:

        Errors Using VX/VX Ace Scripts

  9. Tyler Borgeson says:

    The character on the left is completely invisible, What’s a note tag exactly? I’m not all that educated with scripting.

    • Galv says:

      A note tag is a tag of code that goes in the notes field of certain things like actors, items, etc.

      Download the demo and check out all the notes fields to see how it’s done and compare to the instructions. I don’t know how to help anymore than that, they are very comprehensive instructions :)

  10. I’ve been tweaking some abilities in the demo, trying to figure out how this script works, and I just couldn’t find a way to change the “fire” animation from the projectile…I’m not talking about when it hits (right now he fires a fire ball and when it hits ice appears (i wanted him to fire ice)), I mean the real projectile that travels…Is there a way to change it? Where can I set its animation?

  11. zerphoon says:

    I love this script and I’m running into a problem with it and another script. The problem seems really simple the other script I’m using is called Jets Animated Battles and where the problem is that I see is when I have he note tag for jets script it clashes with your duels though they use the same sprite sheets if one of them is tagged the other won’t work his causes yours to stop updating the animation changes and yours doesn’t affect his script at all :( but dueling with 2 chars ‘ice skating and just numbing into each other isn’t very appealing… so my question is is there a simple way I can either change something in your script which will coincide with his (I’ve already tried changing the fimage within the script to search for anim battler it seemed to have no effect but maybe i didn’t change enough) or is there a way to use events in game to change the note tags while playing so I can switch them out as needed?

  12. Project Eternity says:

    Hey there Galv, is it possible to put a timer in battle? I’m plan on using this as my main battle system for my game.

  13. Project Eternity says:

    Also, is there a way where if player loses, bring the Game Over scene?

    • Galv says:

      Do that using eventing after the battle. Download the demo to see examples of eventing conditions on who wins or loses.

      • Project Eternity says:

        There’s a problem with that however, the variable doesn’t distinguish Player 1 from Player 2/AI, so if Player 1 was to win it would still be Game Over.

      • Galv says:

        The variable stores the Victor’s actor ID.
        You need to input the actor ID’s to start the fight.

        You can use conditional branches to check if the variable is equal to the id you entered.

  14. Project Eternity says:

    Thank you. I was able to get it to work correctly. Much appreciated.

  15. gingahninja47 says:

    What is the License on this script, and if you need permission to use it commercially, may I?

  16. John says:

    Hey dude, how do I set it up so that it works like an arcade game? So there’s a prize when the player wins the AI battle but their health doesn’t deteriorate when they lose?

    • Galv says:

      You’ll need to use eventing for that. Recommend asking in a forum if others can help if you can’t work it out :)
      (unfortunately I’m too busy at the moment)

  17. Eduardp says:

    Nice job Galv, this script is amazing. I wanted to know if its possible to rearrage the position of life and stamina bars, If it is, i would like to know how. Thanks and keep up the good work!

  18. Eduardp says:

    Galve, here I’am again to ask you a question, Is it possible to have and overlay picture in the battle ? I wanted to make a battle in a forest, and by moving, sometimes the characters would be hidden by the trees. If there is a way please, tell me how to do it. Thanks again!

  19. ShawnHVK says:

    Hey galv. Awesome script. I’m using it to create a coliseum type game, but I am not completely familiar with the scripting part. Was wondering if there is a way to distinguish who would be fighting in the fights with variables.

    • Galv says:

      Replace the ID of the actor in the fight with $game_variables[x] … the x being the number of the variable in-game you want to use to store the actor ID. To learn more about variables I recommend asking in a forum :)

      • ShawnHVk says:

        I know how to use variables. Just didn’t know if they would work for your script. I have used a variety scripts to learn how to write scripts and understand how everything works. But I did have one more question in regards to this script. I am doing a game where there are CPU vs CPU and was wondering if there was a setting in the script that would allow that. I know its set up right now as 0-p1vscpu and 1-p1 vs p2

      • Galv says:

        Unfortunately there’s no cpu vs cpu setup for the script

  20. Rain777 says:

    I’m having a hard time understanding the skills on the note tags. Could you possibly take a screenshot of the skill notes, so I can see for myself how this works lol. I love your script, you’re awesome thank you!

  21. Galv Rocks! says:

    I wanted to say thank you for your hard work on these awesome scripts!
    You truly are my favorite scripter. Anyways, I couldn’t help but agree with Rain
    I have the demo and even with the intructions I can’t seem to figure it out.
    Here’s a example of the skills in the note tags:

    add_fskill(7,26,[:l,:l,:r]) <— (character is the 7th actor in the game, and 26 meaning the Skill ID for heal)

    What am I doing wrong? I mainly just want to know how to heal, and poison, like status effect moves.

    I understand you’re busy, but if you or anyone on here that can help that would be so helpful! <3

  22. Shiku_San says:

    Hi Galv, Is it possible to put a individual sprite for the projectile? so if it is posssible, please tell me how :v Thanks.

    • Galv says:

      What do you mean individual sprite? All projectile sprites are taken from the skillimage spritesheet.

      You need to use a notetag in a skill to define which row of that spritesheet the projectile will use

      • Shiku_San says:

        Sorry for late reply, you were right xD, may u odify the script for the following actions? jump/ jump foward/ jump backward and jump attack/ jump foward attack/ jump backward attack. I want to put different sprite for these actions, cancel projectile in the air. I really need this, and I’m willing to pay for a reasonable price. please contact me, Bye c:

  23. Galv says:

    Unfortunately I have way too much to do already for this. I will, however, when I have time be remaking this for RPG Maker MV and it will be much more advanced.
    If you’re interested in helping support me and give me more time to work, I have a patreon set up for supporters :)
    https://www.patreon.com/Galv

  24. Hyde233 says:

    I can’t seem to get my projectile attack to work. I tried looking into the notetags in the demo, but I don’t really understand it.

    • Galv says:

      All the information is there – don’t give up! Make sure to read the script help documentation.

      • Hyde233 says:

        I think I may have found the source of the problem. Originally when I tried testing the skills, I often close out of the game while in the middle of a battle when going back to RPG Maker. This morning, I decided to just randomly play around. I lost a battle. Instead of closing out of it, I continued on. Upon going back to the overworld, the game crashed and showed an error involving the “add_fskill” notetag. So basically, the main reason as to why the skill wasn’t working is because the event was set up so that the skill wasn’t added until after the battle. You’ll also notice that another problem has arose; the “add_fskill” notetag causes the game to crash. Here’s the error message given:

        “Script ‘Game_Interpreter’ line 1411: NoMethodError occurred.
        undefined method ‘add_fskill’ for #”

      • Galv says:

        It seems there was a typo in the script command for add_fskill. It has been add_skill (as could be seen used in the demo). I updated to v.1.6 to fix that.

      • Hyde233 says:

        Upon attempting to sue the skill, I have this error:

        “Script ” line 692: NoMethodError occurred.
        undefined method ‘fcost’ for nil:NilClass”

        I’m fairly certain that this is a script-based error.

      • Galv says:

        Does this happen in the demo? I’ve had people create entire games from this script without issue… please compare what you have done with the demo and use the demo to try to recreate the issue.

      • Galv says:

        The line the error references thinks there is no existing skill. Make sure your skill exists in the database with the ID you used and check the note tag for it

      • Hyde233 says:

        Ok, so apparently you’re supposed to put the notetags in a skill in the database. Originally, I put the notetags in the character itself. That took me a while to figure that out. Upon trying to use the skill, it’ll play the Hit Physical animation and its sound effect for some reason. The skill is completely empty of information except for the Name, Description, Notes, and the Damage section, but it still plays the hit animation. Also, it causes no damage and I don’t know how to adjust its power.

      • Galv says:

        Please read the script instructions. The note tags for skills are under the heading “Note tag for SKILLS”.
        Please also examine the demo and see how the skills are set up… I write instructions and make a demo for this reason :(

      • Hyde233 says:

        I’ve managed to get it to cause damage. I’m still having problems with the hit animation appearing for no reason. If I had more time, I would invest more into trying to fix these on my own, but school is taking up a bit too much time for me.

      • Hyde233 says:

        Never mind. Apparently, changing the A in the notetag to 0 fixed the animation problem that I’m talking about.

        I’ve got MUGEN on my mind while working on this. MUGEN is a fighting game engine, you see. In your script, A is referred to as “animation_id.” When programming in MUGEN, animation_id refers to the number assigned to an animation to help identify it, so I thought it was referring to the sprite that I wanted to use for the projectile.

        Sorry for asking so many questions. I have a tendency to do this sometimes.

      • Hyde233 says:

        Ok, so I’ve been having problems adding sound using the tag “. It works, but it plays the sounds with random different pitches each time. Is there any way to remove this?

        I originally used the tag “” to circumnavigate the problem. I created animations with nothing in them except for sound, and assigned those animations to that tag; that’s how I got the sounds. Since the tag only applies for projectiles, I cannot use this workaround for melee attacks and would be forced to use the tag.

      • Hyde233 says:

        The tags would not show up in my comment probably due to the use of greater than/lesser than signs (Whatever you want to call them). The first tag mentioned was “fse:” and the second being “fp: p,s,a,t,r”

      • Galv says:

        I’m sorry, but I am way too busy to make any changes to this script for you or to teach you how to use it.

        The script comes as is – feel free to modify it yourself or to ask in a forum if others would modify it for you.

  25. The_Many says:

    Gonna try posting one more time…I just wanted to know if there is a way to add a slight delay in the script. Preferrably this would happen once the screen fades in but before START1 (Get Ready text). The idea is to be able to play some sound effects during this time before the fight begins. I have no scripting knowledge and tried the graphics.wait command but it just freezes the game at start up instead of when the script is actually being used. I’m hoping it’s a matter of just adding in some delay command in the script and doesn’t require some major overhaul. Thanks, it’s amazing either way

  26. celceta500 says:

    Hey Galv i only have one little issue, and can’t figure out how to fix it. If you jump, and move to the left or the right, the “run” animation is playing instead of the jump animation. (So you only have jump animation while not moving :( )
    Is there a way to have jump animation only while in air? Kinda crazy to walk in the air. XD
    Other than that i love this script thank you for that! :D

  27. Amyrakunejo says:

    This little mini game I thought to be rather kyuute (though I keep getting my butt kicked in vs. AI mode lol).

    I noticed that for vs. 2P, using a game controller caused me to control both players, but not effectively.

  28. Martin Vláčil says:

    Hi Galv,

    are you currently working on MV version of this awesome script?

    thanks

  29. Mattia says:

    Hi! How can i trigger a Common Event when using a skill?
    Or alternately, how can i create a character that uses bullets and he have to recharge after some attacks?

  30. Minh Doan says:

    Hi Galv! Love your scripts, but can I ask how do you add additional skills for the enemy instead of just having both sides shooting fire. For example: you are the fire type and the opponent is water type. Thanks!

  31. Laimy says:

    Hi, I was wondering if this you could make this compatible with mv or mz

Leave a comment