Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Battle System Script

Jason

Awesome Bro

Hi, I remember once when I was making a game, I had a script which was from this site, which was a sideview battle, but your characters were just their normal sprites, and the enemy was it's battler picture, sadly, since then, I deleted the game files so I lost it.
However, I do have a screenshot on my computer, I will update this post when I can get to it (Not on that particular computer at the moment)
I don't think anyone will understand what I mean until I give them a screenshot, so I'll just hope someone actually does by my brief but suckage description.

Thanks.

Ok, here's the screenshot I was talking about:
http://img81.imageshack.us/img81/722/cbspic1cl8.jpg[/IMG]

Also, is there a way to make it so the Enemy can use a Characterset too instead of looking out of place and being a battler picture ?
 
Did you 'blow up' your charset heroes to double their size? 'Cause they look really big if the system you're using is what I think it is.

ParaDog's SideView Battle (Walking Graphics Edition) v 1.14

I keep an 'English Translated' copy in my Animated Battlers demo for the ParaDog system... just in case.

Remember to change the PARTY_POS value to set which way the heroes are facing.
Code:
#==============================================================================
# ++ Side View Battle (Walking Graphic Edition) ver. 1.14 ++
#  Script by ParaDog
#  http://2d6.parasite.jp/
#------------------------------------------------------------------------------
# Walking graphics are displayed as battlers on the battlefield.
#==============================================================================

module SDVA
  
  X_LINE = 500        # Horizontal coordinates of actor battlers
  Y_LINE = 200        # Vertical coordinates of actor battlers
  X_SPACE = 15        # Horizontal spacing between actor battlers
  Y_SPACE = 40        # Vertical spacing between actor battlers
                      # Formations:
  X_POSITION = 25     # Extra horizontal spacing between frontrow/backrow battlers
  Y_POSITION = 0      # Extra vertical spacing between frontrow/backrow battlers
  
  ATTACK_MOVE = true  # Move when attacking   ( true / false )
  SKILL_MOVE = true   # Move when using skill ( true / false )
  ITEM_MOVE = false   # Move when using item  ( true / false )
  MOVE_STEP = 1       # Number of steps taken
  MOVE_PIXEL = 10     # Number of pixels moved per step (see above)
  
  PARTY_POS = 0       # Direction the characters are facing
                      # (0: Down / 1: To the left / 2: To the right / 3: Up )

  WINDOWPOS_CHANGE = true   # Command Window position changes according to the 
                            # battler (appears under the battler) (true / false)
  
  end
  
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def screen_x
    if self.index != nil
      # Acquiring the formation type
      pos = $data_classes[self.class_id].position
      x_pos = pos * SDVA::X_POSITION
      scr_x = self.index * SDVA::X_SPACE + SDVA::X_LINE + x_pos
      # If battler movement available
      if self.current_action.move_action == true
        # Move the battler
        scr_x += @shift_x
      end
      return scr_x
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Y-Coordinate
  #--------------------------------------------------------------------------
  def screen_y
    if self.index != nil
      # Acquiring the formation type
      pos = $data_classes[self.class_id].position
      y_pos = pos * SDVA::Y_POSITION
      scr_y = self.index * SDVA::Y_SPACE + SDVA::Y_LINE + y_pos
      # If battler movement available
      if self.current_action.move_action == true
        # Move the battler
        scr_y += @shift_y
      end
      return scr_y
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Z-Coordinate
  #--------------------------------------------------------------------------
  def screen_z
    if self.index != nil
      return self.index
    else
      return 0
    end
  end
end

#==============================================================================
# ** Game_Battler (part 1)
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :pattern        # Pattern
  attr_reader   :trans_x        # trans_X
  attr_reader   :moving         # moving
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_sdva initialize
  def initialize
    initialize_sdva
    move_reset
  end
  #--------------------------------------------------------------------------
  # * Move
  #--------------------------------------------------------------------------
  def move
    @moving = 1
      if @step < SDVA::MOVE_STEP
        # Move until steps completed
        @pattern = (@pattern + 1) % 4
        @step += 1
        move_step
      else
        # End movement
        @pattern = 1
        @moving = 2
      end
  end
  #--------------------------------------------------------------------------
  # * Move Step
  #--------------------------------------------------------------------------
  def move_step
  # Branch according to party direction
  case SDVA::PARTY_POS
    when 0
      @shift_y = @step * SDVA::MOVE_PIXEL
    when 1
      @shift_x = -(@step * SDVA::MOVE_PIXEL)
    when 2
      @shift_x = @step * SDVA::MOVE_PIXEL
    when 3
      @shift_y = -(@step * SDVA::MOVE_PIXEL)
    end       
  end
  #--------------------------------------------------------------------------
  # * Move Reset
  #--------------------------------------------------------------------------
  def move_reset
    @moving = 0
    @pattern = 0
    @step = 0
    @shift_x = 0
    @shift_y = 0
  end
end

#==============================================================================
# ** Game_BattleAction
#------------------------------------------------------------------------------
#  This class handles actions in battle. It's used within the Game_Battler 
#  class.
#==============================================================================

class Game_BattleAction
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :move_action             # move action
  #--------------------------------------------------------------------------
  # * Clear
  #--------------------------------------------------------------------------
  alias clear_sdva clear
  def clear
    clear_sdva
    @move_action = false
  end
end

#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
#  This sprite is used to display the battler.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    # If actor which should be displayed
    if @battler.is_a?(Game_Actor)
      # If file name, hue or moving states are different than current ones
      if @battler.battler_name != @battler_name or
         @battler.battler_hue != @battler_hue or
         @battler.current_action.basic == 0 or
         @battler.current_action.kind != 3
        # Get and set bitmap
        @character_name = @battler.character_name
        @character_hue = @battler.character_hue
        # Draw walking graphics
        self.bitmap = RPG::Cache.character(@character_name, @character_hue)
        cw = self.bitmap.width / 4
        ch = self.bitmap.height / 4
        @width = cw
        @height = ch
        if @battler.current_action.move_action == true
          # Make it walk
          @battler.move
        else
          @battler.move_reset
        end
        # Set rectangular transfer
        sx = @battler.pattern * cw
        sy = SDVA::PARTY_POS * ch
        self.src_rect.set(sx, sy, cw, ch)
        self.ox = @width / 2
        self.oy = @height
        # If hidden, set opacity to 0
        if @battler.hidden
          self.opacity = 0
        end
      end
    end
    update_sdva
  end
end
  
#==============================================================================
# ** Scene_Battle 
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  alias phase3_setup_command_window_sdva phase3_setup_command_window
  def phase3_setup_command_window
    phase3_setup_command_window_sdva
    if SDVA::WINDOWPOS_CHANGE
      # Branch and set position of the Actor Command Window
      case SDVA::PARTY_POS
        when 0
          x_pos = @active_battler.screen_x - (@actor_command_window.width/2)
          y_pos = @active_battler.screen_y
        when 1
          x_pos = @active_battler.screen_x - @actor_command_window.width - 16
          y_pos = @active_battler.screen_y - @actor_command_window.height
        when 2
          x_pos = @active_battler.screen_x + 16
          y_pos = @active_battler.screen_y - @actor_command_window.height
        when 3
          x_pos = @active_battler.screen_x - (@actor_command_window.width/2)
          y_pos = @active_battler.screen_y - @actor_command_window.height - 48
      end
      @actor_command_window.x = x_pos >= 0 ? x_pos : 0
      @actor_command_window.x = x_pos+@actor_command_window.width <= 640 ? x_pos : 640-@actor_command_window.width
      @actor_command_window.y = y_pos >= 0 ? y_pos : 0
      @actor_command_window.y = y_pos+@actor_command_window.height <= 480 ? y_pos : 480-@actor_command_window.height
      # Ensure Actor Command Window is in front of BattleStatus window
      @actor_command_window.z = 9999
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 3 : animation for action performer)
  #--------------------------------------------------------------------------
  alias update_phase4_step3_sdva update_phase4_step3
  def update_phase4_step3
    if SDVA::ATTACK_MOVE
      if @active_battler.current_action.basic == 0
        @active_battler.current_action.move_action = true
      end
    end
    if SDVA::SKILL_MOVE
      if @active_battler.current_action.kind == 1
        @active_battler.current_action.move_action = true
      end
    end
    if SDVA::ITEM_MOVE
      if @active_battler.current_action.kind == 2
        @active_battler.current_action.move_action = true
      end
    end
    # If actor is in action
    if @active_battler.is_a?(Game_Actor) and
     @active_battler.current_action.move_action
      # If the actor ends movement
      if @active_battler.moving == 2
        update_phase4_step3_sdva
      end
    elsif @active_battler.moving == 0
      update_phase4_step3_sdva
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 6 : refresh)
  #--------------------------------------------------------------------------
  alias update_phase4_step6_sdva update_phase4_step6
  def update_phase4_step6
    @active_battler.current_action.move_action = false
    @active_battler.move_reset
    update_phase4_step6_sdva
  end
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_sdva initialize
  def initialize
    initialize_sdva
    @viewport2.z = 1
  end
end

#==============================================================================
# ** Arrow_Actor
#------------------------------------------------------------------------------
#  This arrow cursor is used to choose an actor. This class inherits from the
#  Arrow_Base class.
#==============================================================================

class Arrow_Actor < Arrow_Base
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    update_sdva
    # If the down directional button was pressed
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      @index += 1
      @index %= $game_party.actors.size
    end
    # If the up directional button was pressed
    if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      @index += $game_party.actors.size - 1
      @index %= $game_party.actors.size
    end
  end
end

#==============================================================================
# ** Arrow_Enemy
#------------------------------------------------------------------------------
#  This arrow cursor is used to choose enemies. This class inherits from the 
#  Arrow_Base class.
#==============================================================================

class Arrow_Enemy < Arrow_Base
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    update_sdva
    # If the down directional button was pressed
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
        @index += 1
        @index %= $game_troop.enemies.size
        break if self.enemy.exist?
      end
    end
    # If the up directional button was pressed
    if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
        @index += $game_troop.enemies.size - 1
        @index %= $game_troop.enemies.size
        break if self.enemy.exist?
      end
    end
  end
end
 

Jason

Awesome Bro

Oh wait, I found the project on my computer, hurray !
Here it is:

Code:
#--------------------------------------------------------------------------
# ??Sideview battle simple English version 
#
#    (C) copyright by [url=http://rye.jp/]http://rye.jp/[/url]     Date 2007/01/10    Ver 1.03
#--------------------------------------------------------------------------
#  Side view battle script walking graphic version      Special Thanks by blz
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
#  Standard of graphic file
#--------------------------------------------------------------------------
#  battler graphics
#  
#  ?@Walking graphic is used as it is.
#  ?@ 
#  weapon graphics
#  
#  ?@The icon graphic of arms is used as it is.       
#      

  
module Side_view
  #--------------------------------------------------------------------------
  # ?? Using together RTAB?@??Automatic recognition
  #--------------------------------------------------------------------------
  if Scene_Battle.method_defined?("synthe?")
    RTAB = true
  else
    RTAB = false
  end
  #--------------------------------------------------------------------------
  # ?? Using together RTAB cam ??Automatic recognition
  #--------------------------------------------------------------------------
  def camera_correctness
    return false if !RTAB
    begin 
      return $scene.drive
    rescue
      return false
    end
  end
  #--------------------------------------------------------------------------
  # ?? The maximum number of parties
  #--------------------------------------------------------------------------
  Party_max = 4
  #--------------------------------------------------------------------------
  # ?? Expansion rate of Battler graphic(actor exclusive use)
  #--------------------------------------------------------------------------
  CHAR_ZOOM = 1.8
  #--------------------------------------------------------------------------
  # ?? Arrow cursor position correction
  #--------------------------------------------------------------------------
  ARROW_OX = 0
  ARROW_OY = 64
  #--------------------------------------------------------------------------
  # ?? State name treated as flight (Array)
  #--------------------------------------------------------------------------
  FLY_STATES = ["fly"]
  #--------------------------------------------------------------------------
  # ?? Positional correction of combat screen party
  #--------------------------------------------------------------------------
  PARTY_X = 480     # X position of party
  PARTY_Y = 190     # Y position of party
  FORMATION_X = 32  # actor's interval X
  FORMATION_Y = 35  # actor's interval Y
  #--------------------------------------------------------------------------
  # ?? ?J?X?^?}?C?Y??
  #--------------------------------------------------------------------------
  NORMAL   = "NORMAL"
  WALK_R   = "WALK_R"
  WALK_L   = "WALK_L"
  ATTACK   = "ATTACK"
  ATTACK_R = "ATTACK_R"
  ATTACK_L = "ATTACK_L"
  MAGIC    = "MAGIC"
  ITEM     = "ITEM"
  # ?A?j??????
  ANIME = { 
    # [id,Loop?,speed,weapon visible,pattern freeze,Weapon Right or Left(using RTAB)]
    NORMAL            => [1,true , 0,false, true ,""    ], # Standby usually
    WALK_R            => [2,true , 6,false, false,""    ], # move Right
    WALK_L            => [1,true , 6,false, false,""    ], # move Left
    ATTACK_R          => [1,false, 6,true , false,"Right"],# attack by Right hand
    ATTACK_L          => [1,false, 6,true , false,"Left"], # attack by Left hand
    MAGIC             => [1,false, 6,false, false,""    ], # spell Magic
    ITEM              => [1,false, 6,false, false,""    ], # using Item
    }
    
  # default (Do not change it)  
  ANIME.default = [1,false,12,false,"",""]
  
  # ?A?N?V??????????A?t??
  ACTION_LIB = { 
    "Hero Move"            => "moving_setup",
    "Hero Graphic Change"  => "change",
    "Throw Animation"      => "flying",
    "main phase step 3"    => "animation1",
    "main phase step 4"    => "animation2",
    "Waiting"              => "wait",
    "Graphic Reverse"      => "reverse",
    "Afterimage ON"        => "shadow_on",
    "Afterimage OFF"       => "shadow_off",
    "Freeze ON"            => "freeze",
    "Freeze OFF"           => "freeze_lifting",
    "Display Animation"    => "animation_start",
    "Play Sound Effect"    => "play_se",
  }
  ACTION_LIB.default = "finish"

  # (Do not change it)
  DUAL_WEAPONS_ANIME = [ATTACK]
  


  # Arms display X coordinates
  BLZ_X = {
  0=>[0,0,0,0],   # NO MOTION
  1=>[2,2,2,2],   # Shake lowering
  2=>[15,10,0,0], # Piercing
  3=>[2,2,2,2],   # Raising
  4=>[0,0,3,3],   # Bow and gun
  5=>[0,0,0,0],   # For addition
  6=>[0,0,0,0],   # For addition
  7=>[0,0,0,0],   # For addition
  8=>[0,0,0,0],   # For addition
  }
  # Arms display Y coordinates
  BLZ_Y = {
  0=>[0,0,0,0], # NO MOTION
  1=>[6,6,6,6], # Shake lowering
  2=>[6,6,6,6], # Piercing
  3=>[6,6,6,6], # Raising
  4=>[8,8,8,8], # Bow and gun
  5=>[0,0,0,0], # For addition
  6=>[0,0,0,0], # For addition
  7=>[0,0,0,0], # For addition
  8=>[0,0,0,0], # For addition
  }
  # Arms display Angle
  BLZ_ANGLE = {
  0=>[0,0,0,0],                            # NO MOTION
  1=>[75-45*3,75-45*2,75-45*1,75-45*1],    # Shake lowering
  2=>[45,45,45,45],                        # Piercing
  3=>[100-45*1,100-45*2,100-45*3,00-45*4], # Raising
  4=>[45,45,45,45],                        # Bow and gun
  5=>[0,0,0,0],                            # For addition
  6=>[0,0,0,0],                            # For addition
  7=>[0,0,0,0],                            # For addition
  8=>[0,0,0,0],                            # For addition
  }
  
  #--------------------------------------------------------------------------
  # ?? SHAKE
  #--------------------------------------------------------------------------
  SHAKE_FILE = "SHAKE"  # filename
  SHAKE_POWER = 5       # POWER
  SHAKE_SPEED = 5       # SPEED
  SHAKE_DURATION = 5    # DURATION
  #--------------------------------------------------------------------------
  # ?? UPSIDE_DOWN
  #--------------------------------------------------------------------------
  UPSIDE_DOWN_FILE = "UPSIDE_DOWN" # filename
  #--------------------------------------------------------------------------
  # ?? REVERSE
  #--------------------------------------------------------------------------
  REVERSE_FILE = "REVERSE" # filename
  #--------------------------------------------------------------------------
  # ?? ???]????
  #--------------------------------------------------------------------------
  TURNING_FILE = "ROTATION" # filename
  TURNING_DIRECTION = 1     # Direction?i1.Anti-clockwise, -1.clockwise)
  TURNING_SPEED = 40        # Speed
  TURNING_DURATION = 1      # Rotation frequency
  #--------------------------------------------------------------------------
  # ?? ???????
  #--------------------------------------------------------------------------
  MOVE_FILE = "MOVE"             # filename
  MOVE_RETURN = 1                # Do you return to former position?
  MOVE_SPEED = 32                # Speed
  MOVE_COORDINATES = [0,-640]    # Relative coordinates from former position
  #--------------------------------------------------------------------------
  # ?? Add Animation (using RTAB)
  #--------------------------------------------------------------------------
  ADD_ANIME_FILE = "Add_ANIME"   # filename
  ADD_ANIME_ID = 0               # Animation ID 
  #--------------------------------------------------------------------------
  # ?? using RTAB (Do not change it)
  #--------------------------------------------------------------------------
  def convert_battler
    return RTAB ? @active_actor : @active_battler
  end
  #--------------------------------------------------------------------------
  # ?? using RTAB (Do not change it)
  #--------------------------------------------------------------------------
  def convert_battler2(*arg)
    return RTAB ? arg[0] : @active_battler
  end
end

#--------------------------------------------------------------------------
# ?? action performer
#--------------------------------------------------------------------------
module BattleActions
  
  # Because the one below is one example to the last
  # Please make it originally. 

  Actions = {

  "Normal Attack" => [
  
  "main phase step 3",
  "Hero Graphic Change#WALK_L",
  "Hero Move#target,32,0,12,0",
  "Hero Graphic Change#NORMAL",
  "Waiting#5",
  "Hero Graphic Change#ATTACK",
  "Throw Animation",
  "main phase step 4",
  "Hero Graphic Change#WALK_L",
  "Play Sound Effect#016-Jump02,80,100",
  "Hero Move#self,0,0,36,5",
  "end"
  ],

 
  "One step advancement Attack" => [
  
  "main phase step 3",
  "Hero Graphic Change#WALK_L",
  "Hero Move#target,32,0,12,0",
  "Hero Graphic Change#NORMAL",
  "Waiting#5",
  "Hero Graphic Change#ATTACK",
  "Throw Animation",
  "main phase step 4",
  "Hero Graphic Change#WALK_L",
  "Play Sound Effect#016-Jump02,80,100",
  "Hero Move#self,0,0,12,0",
  "end"
  ],

  "Enemy Attack" => [
  
  "main phase step 3",
  "Hero Graphic Change#WALK_L",
  "Hero Move#self,-36,0,12,0",
  "Hero Graphic Change#NORMAL",
  "Waiting#5",
  "Hero Graphic Change#ATTACK",
  "Throw Animation",
  "main phase step 4",
  "Hero Graphic Change#WALK_L",
  "Hero Move#self,0,0,12,0",
  "end"
  ],
  
  
  "Spell Magic" => [
  
  "main phase step 3",
  "Hero Graphic Change#WALK_L",
  "Hero Move#self,-32,0,4,0",
  "Hero Graphic Change#MAGIC",
  "Waiting#15",
  "Throw Animation",
  "main phase step 4",
  "Hero Graphic Change#WALK_L",
  "Hero Move#self,0,0,4,2",
  "end"
  ],

  "Using Item" => [
  
  "Hero Graphic Change#WALK_L",
  "Hero Move#self,-32,0,4,0",
  "main phase step 3",
  "Hero Graphic Change#ITEM",
  "Waiting#15",
  "Throw Animation",
  "main phase step 4",
  "Hero Graphic Change#WALK_L",
  "Hero Move#self,0,0,4,2",
  "end"
  ],
  
  "Using Skill" => [
  
  "Hero Graphic Change#WALK_L",
  "Hero Move#target_near,50,0,48,6",  
  "Graphic Reverse",
  "Freeze ON#ATTACK#3",
  "main phase step 3",
  "Play Sound Effect#135-Light01,100,100",
  "Display Animation#self,42",
  "Waiting#15",
  "Graphic Reverse",
  "Afterimage ON",
  "Hero Move#target_far,-50,0,48,0",
  "main phase step 4",
  "Afterimage OFF",
  "Freeze OFF",
  "Hero Graphic Change#WALK_L",
  "Hero Move#self,0,0,48,1,0",
  "end"
  ],
  }

end
  
module RPG

  # Because the one below is one example to the last
  # Please make it originally. 

  class Weapon
    #--------------------------------------------------------------------------
    # ?? action performer
    #--------------------------------------------------------------------------
    def battle_actions
      case @id
      when 1 # Bronze Sword
        return BattleActions::Actions["One step advancement Attack"]
      end 
      return BattleActions::Actions["Normal Attack"] # default
    end
  end
  class Skill
    #--------------------------------------------------------------------------
    # ?? action performer
    #--------------------------------------------------------------------------
    def battle_actions
      if self.magic?
        return BattleActions::Actions["Spell Magic"] # default
      else
        return BattleActions::Actions["Using Skill"] # default
      end
    end
  end
  class Item
    #--------------------------------------------------------------------------
    # ?? action performer
    #--------------------------------------------------------------------------
    def battle_actions
      return BattleActions::Actions["Using Item"] # default
    end
  end
end
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ?? action performer
  #--------------------------------------------------------------------------
  def battle_actions
    return BattleActions::Actions["Enemy Attack"] # default
  end
end
module RPG
=begin
  
  ?? Setting of arms type
    
    The attribute of the name "WeaponType" is made, and it is applied to arms. 
    The figure is written behind "WeaponType". 
?@?@
    Example.?@WeaponType1?@
    
=end
  class Weapon
    #--------------------------------------------------------------------------
    # ?? WeaponType
    #--------------------------------------------------------------------------
    def anime
      # Elemental
      element_name = "WeaponType"
      for i in @element_set
        if $data_system.elements[i] =~ /#{element_name}([+-]?[0-9]+)?(%)?/
          return $1.to_i
        end
      end
      # Weapon ID

  # Because the one below is one example to the last
  # Please make it originally. 

      case @id
      when 1,2,3,4
        return 1 # (WeaponType) Refer from the 115th line to the 150th line. 
      when 5,6,7,8
        return 2 # (WeaponType) Refer from the 115th line to the 150th line. 
      end
      return 1 # defaut
    end
  end
end
=begin
#--------------------------------------------------------------------------
# ?? Throw Animation
#--------------------------------------------------------------------------
  
?@  Animation is thrown out from performar to target. 
    Please make animation from the data base. 

   [ Animation ID, Speed, Do you shuttle?, Straight line (false) or curve(true)]        
=end
module RPG
  class Weapon
    #--------------------------------------------------------------------------
    # ?? Throw Animation
    #--------------------------------------------------------------------------
    def flying_anime
      # Example
      #case @id
      #when 34 # Boomerang
      #  return [10,32,true,true]
      #when 17,18,19,20 # Arrow
      #  return [40,32,false,false]
      #end
      return [0,0,false,false] # No throw
    end
  end
  class Skill
    #--------------------------------------------------------------------------
    # ?? Throw Animation
    #--------------------------------------------------------------------------
    def flying_anime
      # Example
      #case @id
      #when 34 # Boomerang
      #  return [10,32,true,true]
      #when 17,18,19,20 # Arrow
      #  return [40,32,false,false]
      #end
      return [0,0,false,false] # No throw
    end
  end
  class Item
    #--------------------------------------------------------------------------
    # ?? Throw Animation
    #--------------------------------------------------------------------------
    def flying_anime
      # Example
      #case @id
      #when 34 # Boomerang
      #  return [10,32,true,true]
      #when 17,18,19,20 # Arrow
      #  return [40,32,false,false]
      #end
      return [0,0,false,false] # No throw
    end
  end
end

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ?? Throw Animation
  #--------------------------------------------------------------------------
  def flying_anime
      # Example
      #case @id
      #when 34 # Boomerang
      #  return [10,32,true,true]
      #when 17,18,19,20 # Arrow
      #  return [40,32,false,false]
      #end
    return [0,0,false,false] # No throw
  end
end
#==============================================================================
# ?? Game_Battler
#==============================================================================
class Game_Battler
  include Side_view
  #--------------------------------------------------------------------------
  # ?? ????E???J?C???X?^???X???
  #--------------------------------------------------------------------------
  attr_accessor :height                  # ???????
  attr_accessor :real_x                  # X???W??
  attr_accessor :real_y                  # Y???W??
  attr_accessor :real_zoom               # ?g??
  attr_accessor :wait_count              # ?A?j???[?V???? ???????
  attr_accessor :wait_count2             # ?A?j???[?V???? ???????2
  attr_accessor :pattern                 # ?A?j???[?V???? ?J?E???g?i?L????)
  attr_accessor :shake                   # ?V?F?C?N?J?n?t???b?O
  attr_accessor :reverse                 # ???E???]?t???b?O
  attr_accessor :shadow                  # ?c???t???b?O
  attr_accessor :flash_flag              # ?M???t???b?O
  attr_reader   :ox                      # X???W??
  attr_reader   :oy                      # Y???W??
  attr_reader   :flying_x                # ???????A?j??X???W
  attr_reader   :flying_y                # ???????A?j??Y???W
  attr_reader   :flying_anime            # ???????A?j??
  attr_reader   :animation1_on           # ?s???A?j???J?n?t???b?O
  attr_reader   :animation2_on           # ???A?j???J?n?t???b?O
  #--------------------------------------------------------------------------
  # ?? ?f?t?H???g??A?j???[?V??????????????
  #--------------------------------------------------------------------------
  def animation_duration=(animation_duration)
    @_animation_duration = animation_duration
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g???J?n????Z?b?g?A?b?v
  #--------------------------------------------------------------------------
  def start_battle
    @height = 0
    @real_x = 0
    @real_y = 0
    @real_zoom = 1.0
    @battler_condition = ""
    @action = nil
    @battle_actions = []
    @battler_action = false
    @step = 0
    @anime_on = false
    @wait_count = 0
    @wait_count2 = 0
    @ox = 0
    @oy = 0
    @pattern = 0
    @pattern_log = true
    @pattern_freeze = false
    @condition_freeze = false
    @active = false
    @move_distance = nil
    @move_wait = 0
    @move_coordinates = [0,0,0,0]
    @flying_distance = nil
    @flying_wait = 0
    @flying_x = 0
    @flying_y = 0
    @flash_flag = {}
    self.flying_clear
  end
  #--------------------------------------------------------------------------
  # ?? ?????????
  #--------------------------------------------------------------------------
  def moving?
    # X???W???????AY???W????0????????A?????
    return (@ox != 0 or @oy != 0)
  end
  #--------------------------------------------------------------------------
  # ?? ????I??????
  #--------------------------------------------------------------------------
  def move_end?
    return (@ox == @move_coordinates[0] and @oy == @move_coordinates[1])
  end
  #--------------------------------------------------------------------------
  # ?? ?A?N?V?????J?n???
  #--------------------------------------------------------------------------
  def action(flag = true)
    @battler_action = flag
    @animation1_on = false
    @animation2_on = false
    @step = "setup"
  end    
  #--------------------------------------------------------------------------
  # ?? ?A?N?V??????????
  #--------------------------------------------------------------------------
  def action?
    return @battler_action 
  end
  #--------------------------------------------------------------------------
  # ?? ?M??????
  #--------------------------------------------------------------------------
  def flash?
    return @flash_flg
  end
  #--------------------------------------------------------------------------
  # ?? ???s?\????
  #--------------------------------------------------------------------------
  def anime_dead?
    if $game_temp.in_battle and !RTAB
      if [2,3,4,5].include?($scene.phase4_step)
        return @last_dead
      end
    end
    return @last_dead = self.dead?
  end
  #--------------------------------------------------------------------------
  # ?? ?s???`???????
  #--------------------------------------------------------------------------
  def crisis?
    if $game_temp.in_battle and !RTAB
      if [2,3,4,5].include?($scene.phase4_step)
        return @last_crisis
      end
    end
    return @last_crisis = (self.hp <= self.maxhp / 4 or badstate?)
  end
  #--------------------------------------------------------------------------
  # ?? ?o?b?h?X?e?[?g????
  #--------------------------------------------------------------------------
  def badstate?
    for i in @states
      unless $data_states[i].nonresistance
        return true
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ?? ???s
  #--------------------------------------------------------------------------
  def fly
    if @fly != nil
      return @fly
    end
    for id in @states
      if FLY_STATES.include?($data_states[id].name)
        return 60
      end
    end
    return 0
  end
  #--------------------------------------------------------------------------
  # ?? ???????A?j????W???W??v?Z
  #--------------------------------------------------------------------------
  def flying_setup
    # ???x?????s?????
    return if @flying_distance != nil && !camera_correctness
    if RTAB
      targets = @target
    else
      targets = $scene.target_battlers
    end
    # ??I???W???v?Z
    @f_target_x = 0
    @f_target_y = 0
    for t in targets
      @f_target_x += t.screen_x 
      @f_target_y += t.screen_y
    end
    if targets != []
      @f_target_x /= targets.size
      @f_target_y /= targets.size
    else
      @flying_distance = 0
      return
    end
    # ??????v?Z
    @flying_distance = (self.screen_x - @f_target_x).abs + (self.screen_y - @f_target_y).abs
    @flying_end = false
  end
  #--------------------------------------------------------------------------
  # ?? ???????A?j??
  #--------------------------------------------------------------------------
  def flying_animation
    # ???
    if @step != "flying" or @flying_distance.nil?
      return [false,true]
    end
    # ? ??????v?Z
    self_x = self.screen_x
    self_y = self.screen_y
    @flying_distance = @flying_distance == 0 ? 1 : @flying_distance
    n1 = @flying_wait / @flying_distance.to_f
    if @flying_distance - @flying_wait > @flying_distance / 2
      n2 = 1.0 + 10.0 * @flying_wait / @flying_distance.to_f
    else
      n2 = 1.0 + 10.0 * (@flying_distance - @flying_wait) / @flying_distance.to_f
    end
    if !@flying_anime[4]
      # ???????
      x = (self_x + 1.0 * (@f_target_x - self_x) * n1).to_i
      y = (self_y + 1.0 * (@f_target_y - self_y) * n1).to_i
    else
      # ??????
      if !@flying_proceed_end
        x = (self_x + 1.0 * (@f_target_x - self_x) * n1).to_i
        y = (self_y + 1.0 * (@f_target_y - self_y) * n1 - n2**2).to_i
      else
        x = (self_x + 1.0 * (@f_target_x - self_x) * n1).to_i
        y = (self_y + 1.0 * (@f_target_y - self_y) * n1 + n2**2).to_i
      end
    end
    # ???W????
    @flying_x = x
    @flying_y = y
    # ?E?G?C?g
    if !@flying_proceed_end
      # ?J?n
      @flying_proceed_start = @flying_wait == 0
      @flying_wait += @flying_anime[1]
      @flying_wait = [@flying_wait,@flying_distance].min
      @flying_proceed_end = @flying_wait == @flying_distance
    else
      # ?J?n
      @flying_return_start = @flying_wait == @flying_distance
      @flying_wait -= @flying_anime[1]
      @flying_wait = [@flying_wait,0].max
      @flying_return_end = @flying_wait == 0
    end
    if @flying_anime[1] == 0
      @flying_end = true
    elsif !@flying_anime[2]
      @flying_end = @flying_proceed_end
    else
      @flying_end = @flying_return_end
    end
    # ?l??????i?A?j???J?n,?A?j???I??)
    return [@flying_proceed_start,@flying_end]
  end
  #--------------------------------------------------------------------------
  # ?? ???????A?j????????
  #--------------------------------------------------------------------------
  def flying_clear
    @flying_proceed_start = false
    @flying_proceed_end = false
    @flying_return_start = false
    @flying_return_end = false
    @flying_end = true
    @flying_anime = [0,0,false,false]
  end
  #--------------------------------------------------------------------------
  # ?? ???
  #--------------------------------------------------------------------------
  def move
    # ??????v?Z
    @move_distance = (@move_coordinates[2] - @move_coordinates[0]).abs +
                     (@move_coordinates[3] - @move_coordinates[1]).abs
    if @move_distance > 0
      return if @ox == @move_coordinates[0] and @oy == @move_coordinates[1]
      array = @move_coordinates
      # ?W?????v???l??v?Z
      n = 100.0 * @move_wait / @move_distance 
      jump = -@move_action[4] * n * (100 - n) / 100.0
      @ox = (array[2] + 1.0 * (array[0] - array[2]) * (@move_distance - @move_wait) / @move_distance.to_f).to_i
      @oy = (array[3] + 1.0 * (array[1] - array[3]) * (@move_distance - @move_wait) / @move_distance.to_f + jump).to_i
      # ?E?G?C?g
      @move_wait -= @move_action[3]
      @move_wait = [@move_wait,0].max
    end
  end
  #--------------------------------------------------------------------------
  # ?? ????A?N?V???????
  #--------------------------------------------------------------------------
  def get_move_action
    string = @action.split(/#/)[1]
    string = string.split(/,/)
    @move_action = [string[0],string[1].to_i,string[2].to_i,string[3].to_i,string[4].to_i,string[5].to_i]
  end
  #--------------------------------------------------------------------------
  # ?? ?A?N?V???????
  #--------------------------------------------------------------------------
  def get_step
    if @action.nil?
      @step = "finish"
      return 
    end
    return ACTION_LIB[@action.split(/#/)[0]]
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (????A?N?V??????)
  #--------------------------------------------------------------------------
  def update_next
    @action = @battle_actions.shift
    @step = get_step
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (??????)
  #--------------------------------------------------------------------------
  def update_setup
    # ?A?N?V???????
    self.get_actions
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?????)
  #--------------------------------------------------------------------------
  def update_moving_setup
    # ????A?N?V???????
    self.get_move_action
    # ?????W????
    self.move_setup
    @step = "moving"
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (???)
  #--------------------------------------------------------------------------
  def update_moving
    # ???
    self.move
    self.condition = @battler_condition
    # ???????????????X?e?b?v??
    if move_end?
      update_next
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?A?j?????s)
  #--------------------------------------------------------------------------
  def update_action
    con = @action.split(/#/)[1]
    # ?E???E????????????
    if DUAL_WEAPONS_ANIME.include?(con)
      if !@first_weapon and @second_weapon
        con = con + "_L"
      else
        con = con + "_R"
      end
    end
    # ?A?j????X
    self.condition = con
    # ???[?v?????
    if !ANIME[@battler_condition][1]
      self.anime_on
    end
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (???????A?j??)
  #--------------------------------------------------------------------------
  def update_flying
    # ??W????
    self.flying_setup
    # ???????A?j???I??
    if @flying_end or @flying_anime == [0,0,false,false]
      self.flying_clear
      update_next
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?A?j????X)
  #--------------------------------------------------------------------------
  def update_change
    con = @action.split(/#/)[1]
    # ?E???E????????????
    if DUAL_WEAPONS_ANIME.include?(con)
      if !@first_weapon and @second_weapon
        con = con + "_L"
      else
        con = con + "_R"
      end
    end
    # ?A?j????X
    self.condition = con
    # ???[?v?????
    if !ANIME[@battler_condition][1]
      self.anime_on
    end
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?s???A?j??)
  #--------------------------------------------------------------------------
  def update_animation1
    @animation1_on = true
    # ?s???A?j???????s?????J?n????
    if $scene.phase4_step == 3
      id = RTAB ? @anime1 : $scene.animation1_id
      animation = $data_animations[id]
      frame_max = animation != nil ? animation.frame_max : 0
      @wait_count2 = frame_max * 2
      return
    end
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (???A?j??)
  #--------------------------------------------------------------------------
  def update_animation2
    @animation2_on = true
    # ?s???A?j???????s?????J?n????
    if $scene.phase4_step == 4
      id = RTAB ? @anime2 : $scene.animation2_id
      animation = $data_animations[id]
      frame_max = animation != nil ? animation.frame_max : 0
      @wait_count2 = frame_max * 2
      return
    end
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?E?G?C?g)
  #--------------------------------------------------------------------------
  def update_wait
    @wait_count2 = @action.split(/#/)[1].to_i
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?c???\??)
  #--------------------------------------------------------------------------
  def update_shadow_on
    @shadow = true
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?c??????)
  #--------------------------------------------------------------------------
  def update_shadow_off
    @shadow = false
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (???E???])
  #--------------------------------------------------------------------------
  def update_reverse
    @reverse = @reverse ? false : true
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?M???A?j??)
  #--------------------------------------------------------------------------
  def update_flash
    # ?M???A?j???????s?????J?n????
    if @flash_flag["normal"]
      @wait_count = $scene.flash_duration
      @flash_flag["normal"] = false
      return
    end
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (SE????t)
  #--------------------------------------------------------------------------
  def update_play_se
    data = @action.split(/#/)[1]
    data = data.split(/,/)
    # SE ?????t
    Audio.se_play("Audio/SE/" + data[0], data[1].to_i, data[2].to_i)
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?A?N?^?[?A?j????’?)
  #--------------------------------------------------------------------------
  def update_freeze
    con = @action.split(/#/)[1]
    # ?E???E????????????
    if DUAL_WEAPONS_ANIME.include?(con)
      if !@first_weapon and @second_weapon
        con = con + "_L"
      else
        con = con + "_R"
      end
    end
    # ?A?j????X
    self.condition = con
    @pattern = @action.split(/#/)[2].to_i
    @pattern_freeze = true
    @condition_freeze = true
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?A?N?^?[?A?j????’?????)
  #--------------------------------------------------------------------------
  def update_freeze_lifting
    @pattern_freeze = false
    @condition_freeze = false
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?A?j???[?V??????\??)
  #--------------------------------------------------------------------------
  def update_animation_start
    data = @action.split(/#/)[1]
    data = data.split(/,/)
    target = data[0] 
    animation_id = data[1].to_i
    if RTAB
      case target
      when "self"
        @animation.push([animation_id,true])
      when "target"
        for tar in @target
          tar.animation.push([animation_id, true])
        end
      end
    else
      case target
      when "self"
        @animation_id = animation_id
        @animation_hit = true
      when "target"
        for tar in $scene.target_battlers
          tar.animation_id = animation_id
          tar.animation_hit = true
        end
      end
    end
    update_next
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (?????I??)
  #--------------------------------------------------------------------------
  def update_finish
    # ?????I??
    @battler_action = false
    @step = "setup"
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g???[?????i?o?g???[?O???t?B?b?N??^?C?v)
  #--------------------------------------------------------------------------
  def condition
    return @battler_condition
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g???[????? ??X?i?o?g???[?O???t?B?b?N??^?C?v)
  #--------------------------------------------------------------------------
  def condition=(condition)
    return if @condition_freeze
    if @battler_condition != condition
      @wait_count = ANIME[condition][2]
      @pattern = 0
    end
    @battler_condition = condition
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V
  #--------------------------------------------------------------------------
  def update
    # ?E?F?C?g?????
    if @wait_count == 0
      # ?p?^?[???X?V
      self.char_animation
      @wait_count = ANIME[@battler_condition][2]
    end
    # ?p?^?[???X?V
    self.char_animation
    # ?E?F?C?g?????
    if @wait_count2 > 0
      return
    end
    
    # ?s???A?j???[?V????
    if @battler_action
      method("update_" + @step).call
      return
    end
    
    # ?f?[?^??????
    @animation1_on = false
    @animation2_on = false
    @action = nil
    @battle_actions = []
    @move_wait = 0
    @move_distance = nil
    @flying_wait = 0
    @flying_distance = nil
    @flash = false

    # ????E??@
    return self.condition = NORMAL
  end
  #--------------------------------------------------------------------------
  # ?? ?A?N?V???????
  #--------------------------------------------------------------------------
  def get_actions
    skill = $data_skills[self.current_action.skill_id]
    item = $data_items[self.current_action.item_id]
    kind = self.current_action.kind
    # ??????
    @battle_actions = []
    # ?X?L??
    if skill != nil && kind == 1
      @battle_actions = skill.battle_actions.dup
      @flying_anime = skill.flying_anime
    # ?A?C?e??
    elsif item != nil && kind == 2
      @battle_actions = item.battle_actions.dup
      @flying_anime = item.flying_anime
    # ?????U??
    elsif !@first_weapon and @second_weapon and self.is_a?(Game_Actor)
      @battle_actions = self.battle_actions2.dup
      @flying_anime = self.flying_anime2
    # ?E???U??
    elsif self.current_action.basic == 0 and
      self.is_a?(Game_Actor) and self.current_action.kind == 0
      @battle_actions = self.battle_actions1.dup
      @flying_anime = self.flying_anime1
    # ????U??
    elsif self.current_action.basic == 0 and self.current_action.kind == 0
      @battle_actions = self.battle_actions.dup
      @flying_anime = self.flying_anime
    else
      @battle_actions = ["?I??"]
      @flying_anime = [0,0,false,false]
    end
  end
  #--------------------------------------------------------------------------
  # ?? ???[?v??????A?j????Z?b?g
  #--------------------------------------------------------------------------
  def anime_on
    @pattern = 0
    @pattern_log = true
    return
  end
  #--------------------------------------------------------------------------
  # ?? ?p?^?[???X?V
  #--------------------------------------------------------------------------
  def char_animation
    # ?p?^????’?????????
    return if @pattern_freeze
    # ???[?v??????A?j????? 1234 ??~???
    if !ANIME[@battler_condition][1] && @pattern == 3
      return
    end
    # ?A?j??????????? 1 ??~???
    if ANIME[@battler_condition][4]
      @pattern = 0
      return
    end
    @pattern = (@pattern + 1) % 4
  end
  #--------------------------------------------------------------------------
  # ?? ?A?j???^?C?v
  #--------------------------------------------------------------------------
  def anime_type
    return ANIME[@battler_condition] != nil ? ANIME[@battler_condition][0] : 0
  end
end
#==============================================================================
# ?? Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  include Side_view
  #--------------------------------------------------------------------------
  # ?? ?Z?b?g?A?b?v
  #--------------------------------------------------------------------------
  alias side_view_setup setup
  def setup(actor_id)
    side_view_setup(actor_id)
    start_battle
  end
  #--------------------------------------------------------------------------
  # ?? ??????????ID???@???G???[?????p
  #--------------------------------------------------------------------------
  def weapon2_id
    return @weapon2_id != nil ? @weapon2_id : 0
  end
  #--------------------------------------------------------------------------
  # ?? X???? ?|?W?V???? ??
  #--------------------------------------------------------------------------
  def position
    return $data_classes[@class_id].position
  end
  #--------------------------------------------------------------------------
  # ?? Y???? ?|?W?V???? ??
  #--------------------------------------------------------------------------
  def position2
    return self.index
  end
  #--------------------------------------------------------------------------
  # ?? ?????A?j???^?C?v
  #--------------------------------------------------------------------------
  def weapon_anime_type(type = @battler_condition)
    file_name  = weapon_anime_type0(type)
    visible   = weapon_anime_type1(type)
    z         = weapon_anime_type2(type)
    motion    = weapon_anime_type3(type)
    return [file_name,visible,z,motion]
  end
  # ?????A?C?R????
  def weapon_anime_type0(type = @battler_condition)
    type = ANIME[type][5]
    return weapon_anime1 if type == "Right"
    return weapon_anime2 if type == "Left"
    return nil
  end
  # ?\???E???\?????
  def weapon_anime_type1(type = @battler_condition)
    return ANIME[type][3]
  end
  # ?o?g???[????????\???????????
  def weapon_anime_type2(type = @battler_condition)
    type = ANIME[type][5]
    return true if type == "Left"
    return false
  end
  # ?????????No?D??
  def weapon_anime_type3(type = @battler_condition)
    type = ANIME[type][5]
    return extend_weapon_anime1 if type == "Right"
    return extend_weapon_anime2 if type == "Left"
    return 0
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? X ???W???(?J??????????)
  #--------------------------------------------------------------------------
  def true_x
    return PARTY_X + position * FORMATION_X + @ox
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? Y ???W???(?J??????????)
  #--------------------------------------------------------------------------
  def true_y
    # ?p?[?e?B???????????? Y ???W???v?Z??????
    if self.index != nil
      y = position2 * FORMATION_Y + PARTY_Y + @oy - @height / 2
      return y
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? X ???W???
  #--------------------------------------------------------------------------
  def screen_x(true_x = self.true_x)
    return 320 + (true_x - 320) * @real_zoom + @real_x
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? Y ???W???
  #--------------------------------------------------------------------------
  def screen_y(true_y = self.true_y)
    return true_y * @real_zoom + @real_y
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? Z ???W???
  #--------------------------------------------------------------------------
  def screen_z
    return screen_y + 1000
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? X ???W???(???????????????)
  #--------------------------------------------------------------------------
  def base_x
    return 320 + (true_x - @ox - 320) * @real_zoom + @real_x
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? Y ???W???
  #--------------------------------------------------------------------------
  def base_y
    return (true_y - @oy) * @real_zoom + @real_y
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? ?g?????
  #--------------------------------------------------------------------------
  def zoom
    return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
                          (true_x + @fly) / 480 + $scene.zoom_rate[0]
  end
  #--------------------------------------------------------------------------
  # ?? ?U???p?A?o?g?????? X ???W???
  #--------------------------------------------------------------------------
  def attack_x(z)
    return (320 - true_x) * z * 0.75
  end
  #--------------------------------------------------------------------------
  # ?? ?U???p?A?o?g?????? Y ???W???
  #--------------------------------------------------------------------------
  def attack_y(z)
    return (160 - (true_y + fly / 4) * z + @height * zoom * z / 2) * 0.75
  end
  #--------------------------------------------------------------------------
  # ?? ?M?????????
  #--------------------------------------------------------------------------
  def flash_duration
    return $scene.flash_duration
  end
  #--------------------------------------------------------------------------
  # ?? ?A?j???[?V??????
  #--------------------------------------------------------------------------
  def battle_actions1
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.battle_actions : BattleActions::Actions["????U??"]
  end
  #--------------------------------------------------------------------------
  # ?? ?A?j???[?V??????
  #--------------------------------------------------------------------------
  def battle_actions2
    weapon = $data_weapons[@weapon2_id]
    return weapon != nil ? weapon.battle_actions : BattleActions::Actions["????U??"]
  end
  #--------------------------------------------------------------------------
  # ?? ?????A?j???[?V???? ?????? ??
  #--------------------------------------------------------------------------
  def extend_weapon_anime1
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.anime : 0
  end
  #--------------------------------------------------------------------------
  # ?? ?????A?j???[?V???? ?????? ??
  #--------------------------------------------------------------------------
  def extend_weapon_anime2
    weapon = $data_weapons[@weapon2_id]
    return weapon != nil ? weapon.anime : 0
  end
  #--------------------------------------------------------------------------
  # ?? ?????A?j???[?V??????
  #--------------------------------------------------------------------------
  def weapon_anime1
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.icon_name : ""
  end
  #--------------------------------------------------------------------------
  # ?? ?????A?j???[?V??????
  #--------------------------------------------------------------------------
  def weapon_anime2
    weapon = $data_weapons[@weapon2_id]
    return weapon != nil ? weapon.icon_name : ""
  end
  #--------------------------------------------------------------------------
  # ?? ???????A?j???[?V??????
  #--------------------------------------------------------------------------
  def flying_anime1
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.flying_anime : [0,0,false,false]
  end
  #--------------------------------------------------------------------------
  # ?? ???????A?j???[?V??????
  #--------------------------------------------------------------------------
  def flying_anime2
    weapon = $data_weapons[@weapon2_id]
    return weapon != nil ? weapon.flying_anime : [0,0,false,false]
  end
  #--------------------------------------------------------------------------
  # ?? ?????W???W??v?Z
  #--------------------------------------------------------------------------
  def move_setup
    if RTAB
      targets = @target
    else
      targets = $scene.target_battlers
    end
    case @move_action[0]
    when "self" # ????
      @target_x = self.base_x
      @target_y = self.base_y
    when "target_near" # ?????*??^?[?Q?b?g
      targets.sort!{|a,b| a.screen_x<=>b.screen_x }
      targets.reverse!
      if targets != []
        @target_x = targets[0].screen_x
        @target_y = targets[0].screen_y
      else
        @target_x = self.base_x
        @target_y = self.base_y
      end
    when "target_far" # ??????*??^?[?Q?b?g
      targets.sort!{|a,b| a.screen_x<=>b.screen_x }
      if targets != []
        @target_x = targets[0].screen_x
        @target_y = targets[0].screen_y
      else
        @target_x = self.base_x
        @target_y = self.base_y
      end
    when "target" # ?^?[?Q?b?g????
      @target_x = 0
      @target_y = 0
      for t in targets
        @target_x += t.screen_x
        @target_y += t.screen_y
      end
      if targets != []
        @target_x /= targets.size
        @target_y /= targets.size
      end
    when "troop" # "?g???[?v????"
      @target_x = 0
      @target_y = 0
      for t in $game_troop.enemies
        @target_x += t.screen_x
        @target_y += t.screen_y
      end
      if $game_troop.enemies != []
        @target_x /= $game_troop.enemies.size
        @target_y /= $game_troop.enemies.size
      end
    when "party" # "?p?[?e?B????"
      @target_x = 0
      @target_y = 0
      for t in $game_party.actors
        @target_x += t.screen_x
        @target_y += t.screen_y
      end
      if $game_party.actors != []
        @target_x /= $game_party.actors.size
        @target_y /= $game_party.actors.size
      end
    when "screen" # "????"
      @target_x = self.base_x
      @target_y = self.base_y
    end
    # ??
    @target_x += @move_action[1] - self.base_x
    @target_y += @move_action[2] - self.base_y
    # ?????W????W???Z?b?g
    @move_coordinates = [@target_x.to_i,@target_y.to_i,@move_coordinates[0],@move_coordinates[1]]
    # ??????v?Z(?E?G?C?g????)
    @move_wait     = (@move_coordinates[2] - @move_coordinates[0]).abs +
                     (@move_coordinates[3] - @move_coordinates[1]).abs
  end
end
#==============================================================================
# ?? Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ?? ?Z?b?g?A?b?v
  #--------------------------------------------------------------------------
  alias side_view_initialize initialize
  def initialize(troop_id, member_index)
    side_view_initialize(troop_id, member_index)
    start_battle
  end
  #--------------------------------------------------------------------------
  # ?? ???
  #--------------------------------------------------------------------------
  def move
    # ??????v?Z
    @move_distance = (@move_coordinates[2] - @move_coordinates[0]).abs +
                     (@move_coordinates[3] - @move_coordinates[1]).abs
    if @move_distance > 0
      return if @ox == @move_coordinates[0] and @oy == @move_coordinates[1]
      array = @move_coordinates
      # ?W?????v???l??v?Z
      n = 100.0 * @move_wait / @move_distance 
      jump = -@move_action[4] * n * (100 - n) / 100.0
      @ox = (array[2] + 1.0 * (array[0] - array[2]) * (@move_distance - @move_wait) / @move_distance.to_f).to_i
      @oy = (array[3] + 1.0 * (array[1] - array[3]) * (@move_distance - @move_wait) / @move_distance.to_f + jump).to_i
      # ?E?G?C?g
      @move_wait -= @move_action[3]
      @move_wait = [@move_wait,0].max
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?????W???W??v?Z
  #--------------------------------------------------------------------------
  def move_setup
    if RTAB
      targets = @target
    else
      targets = $scene.target_battlers
    end
    case @move_action[0]
    when "self" # ????
      @target_x = self.base_x
      @target_y = self.base_y
    when "target_near" # ?????*??^?[?Q?b?g
      targets.sort!{|a,b| a.screen_x<=>b.screen_x }
      if targets != []
        @target_x = targets[0].screen_x
        @target_y = targets[0].screen_y
      else
        @target_x = self.base_x
        @target_y = self.base_y
      end
    when "target_far" # ??????*??^?[?Q?b?g
      targets.sort!{|a,b| a.screen_x<=>b.screen_x }
      targets.reverse!
      if targets != []
        @target_x = targets[0].screen_x
        @target_y = targets[0].screen_y
      else
        @target_x = self.base_x
        @target_y = self.base_y
      end
    when "target" # ?^?[?Q?b?g????
      @target_x = 0
      @target_y = 0
      for t in targets
        @target_x += t.screen_x
        @target_y += t.screen_y
      end
      if targets != []
        @target_x /= targets.size
        @target_y /= targets.size
      end
    when  "party" # "?g???[?v????"
      @target_x = 0
      @target_y = 0
      for t in $game_troop.enemies
        @target_x += t.screen_x
        @target_y += t.screen_y
      end
      if $game_troop.enemies != []
        @target_x /= $game_troop.enemies.size
        @target_y /= $game_troop.enemies.size
      end
    when "troop" # "?p?[?e?B????"
      @target_x = 0
      @target_y = 0
      for t in $game_party.actors
        @target_x += t.screen_x
        @target_y += t.screen_y
      end
      if $game_party.actors != []
        @target_x /= $game_party.actors.size
        @target_y /= $game_party.actors.size
      end
    when "screen" # "????"
      @target_x = self.base_x
      @target_y = self.base_y
    end
    # ??
    @target_x -= @move_action[1] + self.base_x
    @target_y -= @move_action[2] + self.base_y
    # ?????W????W???Z?b?g
    @move_coordinates = [@target_x.to_i,@target_y.to_i,@move_coordinates[0],@move_coordinates[1]]
    # ??????v?Z(?E?G?C?g????)
    @move_wait     = (@move_coordinates[2] - @move_coordinates[0]).abs +
                     (@move_coordinates[3] - @move_coordinates[1]).abs
  end
  if RTAB
  alias original_x true_x
  alias original_y true_y
  else
  alias original_x screen_x
  alias original_y screen_y
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? X ???W???(?J??????????)
  #--------------------------------------------------------------------------
  def true_x
    return original_x + @ox
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? Y ???W???(?J??????????)
  #--------------------------------------------------------------------------
  def true_y
    return original_y - @height / 2 + @oy
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? X ???W???
  #--------------------------------------------------------------------------
  def screen_x(true_x = self.true_x)
    return true_x * @real_zoom + @real_x 
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? Y ???W???
  #--------------------------------------------------------------------------
  def screen_y(true_y = self.true_y)
    return true_y * @real_zoom + @real_y
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? X ???W???(???????????????)
  #--------------------------------------------------------------------------
  def base_x(true_x = self.true_x)
    return (true_x - @ox) * @real_zoom + @real_x
  end
  #--------------------------------------------------------------------------
  # ?? ?o?g?????? Y ???W???(???????????????)
  #--------------------------------------------------------------------------
  def base_y(true_y = self.true_y)
    return (true_y - @oy) * @real_zoom + @real_y
  end
end
#==============================================================================
# ?? Game_Party
#==============================================================================
class Game_Party
  #--------------------------------------------------------------------------
  # ?? ?A?N?^?[????????
  #     actor_id : ?A?N?^?[ ID
  #--------------------------------------------------------------------------
  alias side_view_add_actor add_actor
  def add_actor(actor_id)
    # ?A?N?^?[????
    actor = $game_actors[actor_id]
    # ?T?C?h?r???[?f?[?^???????
    actor.start_battle
    # ???
    side_view_add_actor(actor_id)
  end
end
#==============================================================================
# ?? Scene_Battle
#==============================================================================
class Scene_Battle
  include Side_view
  #--------------------------------------------------------------------------
  # ?? ???J?C???X?^???X???
  #--------------------------------------------------------------------------
  attr_reader   :phase            # ?t?F?[?Y
  attr_reader   :phase4_step      # ?t?F?[?Y?S?X?e?b?v
  attr_reader   :active_battler   # ????z??
  attr_reader   :target_battlers  # ????z??
  attr_reader   :animation1_id    # ?s???A?j??ID
  attr_reader   :animation2_id    # ???A?j??ID
  #--------------------------------------------------------------------------
  # ?? ???C??????
  #--------------------------------------------------------------------------
  alias side_view_main main
  def main
    # ?o?g???[??????
    for battler in $game_party.actors + $game_troop.enemies
      battler.start_battle
    end
    # ???
    side_view_main
  end
  #--------------------------------------------------------------------------
  # ?? ?M??????
  #--------------------------------------------------------------------------
  def flash?
    return @flash_flag ? true : false
  end  
  #--------------------------------------------------------------------------
  # ?? ?M???A?j??????????
  #--------------------------------------------------------------------------
  def flash_duration
    animation = nil
    if FLASH_ANIME
      animation = $data_animations[FLASH_ANIMATION_ID]
    end
    return animation != nil ? animation.frame_max * 2 + 2 : 0
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (???C???t?F?[?Y ?X?e?b?v 2 : ?A?N?V?????J?n)
  #--------------------------------------------------------------------------
  alias side_view_update_phase4_step2 update_phase4_step2
  def update_phase4_step2(*arg)
    battler = convert_battler2(*arg)
    battler.action
    side_view_update_phase4_step2(*arg)
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (???C???t?F?[?Y ?X?e?b?v 3 : ?s?????A?j???[?V????)
  #--------------------------------------------------------------------------
  alias side_view_update_phase4_step3 update_phase4_step3
  def update_phase4_step3(*arg)
    battler = convert_battler2(*arg)
    return if !battler.animation1_on and battler.action? and !battler.flash?
    if battler.flash? and FLASH_ANIME
      battler.flash_flag["normal"] = true
    end
    side_view_update_phase4_step3(*arg)
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V (???C???t?F?[?Y ?X?e?b?v 4 : ?????A?j???[?V????)
  #--------------------------------------------------------------------------
  alias side_view_update_phase4_step4 update_phase4_step4
  def update_phase4_step4(*arg)
    battler = convert_battler2(*arg)
    targets = RTAB ? battler.target : @target_battlers
    return if !battler.animation2_on and battler.action?
    side_view_update_phase4_step4(*arg)
    for target in targets
      if RTAB
        value = nil
        if target.damage_sp.include?(battler)
          value = target.damage_sp[battler]
        end
        if target.damage.include?(battler)
          if value == nil or value == "Miss"
            value = target.damage[battler]
          elsif value.is_a?(Numeric) && value > 0
            value = target.damage[battler] == "Miss" ? value : target.damage[battler]
          end
        end
      else
        value = target.damage
      end
      if target.is_a?(Game_Actor)
        # ?_???[?W???
        if value.is_a?(Numeric) && value > 0
          # ?V?F?C?N???J?n
          target.shake = true
        end
      elsif target.is_a?(Game_Enemy)
        # ?_???[?W???
        if value.is_a?(Numeric) && value > 0
          # ?V?F?C?N???J?n
          target.shake = true
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?v???o?g???t?F?[?Y?J?n
  #--------------------------------------------------------------------------
  alias start_phase1_correct start_phase1 
  def start_phase1
    # ?J????????
    # ???X?t?????g?r???[????????l???????????
    @zoom_rate = [1.0, 1.0]
    start_phase1_correct
  end
  #--------------------------------------------------------------------------
  # ?? ?A?N?^?[?R?}???h?t?F?[?Y?J?n
  #--------------------------------------------------------------------------
  alias start_phase3_correct start_phase3 
  def start_phase3
    battler = convert_battler
    start_phase3_correct
    if RTAB
      # ?J????????
      # ???X?t?????g?r???[????????l???????????
      @camera = "command"
      @spriteset.screen_target(0, 0, 1.0)
    end
  end
end

class Spriteset_Battle
  include Side_view
  #--------------------------------------------------------------------------
  # ?? ?I?u?W?F?N?g??????
  #--------------------------------------------------------------------------
  alias side_veiw_initialize initialize
  def initialize
    side_veiw_initialize
    # ?A?N?^?[?X?v???C?g??????
    for sprite in @actor_sprites
      sprite.dispose
    end
    # ?A?N?^?[?X?v???C?g????
    @actor_sprites = []
    for i in 1..Party_max
      @actor_sprites.push(Sprite_Battler.new(@viewport1))
    end
    update
  end
  #--------------------------------------------------------------------------
  # ?? ?????X?N???[??
  #--------------------------------------------------------------------------
  if method_defined?("screen_scroll")
  alias side_view_screen_scroll screen_scroll
  def screen_scroll
    side_view_screen_scroll
    # ?A?N?^?[???u??
    for actor in $game_party.actors
      actor.real_x = @real_x
      actor.real_y = @real_y
      actor.real_zoom = @real_zoom
    end
  end
  end
end

class Sprite_Battler < RPG::Sprite
  include Side_view
  #--------------------------------------------------------------------------
  # ?? ?I?u?W?F?N?g??????
  #     viewport : ?r???[?|?[?g
  #     battler  : ?o?g???[ (Game_Battler)
  #--------------------------------------------------------------------------
  def initialize(viewport, battler = nil)
    super(viewport)
    @battler = battler
    @battler_visible = false
    @weapon = Sprite_Weapon.new(viewport, battler)
    @flying = Sprite_Flying.new(viewport, battler)
    @shadow = []
    @fly = 0
    @fly_direction = 1
    @rand = rand(10)
    @bitmaps = {}
    self.effect_clear
  end
  #--------------------------------------------------------------------------
  # ?? ????
  #--------------------------------------------------------------------------
  alias side_view_dispose dispose
  def dispose
    side_view_dispose
    @weapon.dispose if @weapon != nil
    @flying.dispose if @flying != nil
    if @_target_sprite != nil
      @_target_sprite.bitmap.dispose
      @_target_sprite.dispose
      @_target_sprite = nil
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?t???[???X?V
  #--------------------------------------------------------------------------
  def update
    super
    # ?o?g???[?? nil ???
    if @battler == nil
      self.bitmap = nil
      @weapon.bitmap = nil
      loop_animation(nil)
      return
    end
    # ?o?g???[?X?V
    @battler.update 
    # ?o?g???[?A?j????f?[?^??
    @anime_type = @battler.anime_type
    # bitmap ???L???b?V????
    path = @anime_type[0].to_s + "#" + @battler.pattern.to_s
    if not @bitmaps.include?(path) or @bitmaps[path].disposed?
      # ?t?@?C???????F??????????????????
      if @battler.is_a?(Game_Actor) 
        change = (@battler.character_name != @battler_name or @battler.character_hue != @battler_hue)
      elsif @battler.is_a?(Game_Enemy)
        change = (@battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue)
      end
      if change
        # ?r?b?g?}?b?v?????A???
        if @battler.is_a?(Game_Actor)
          @battler_name = @battler.character_name
          @battler_hue = @battler.character_hue
          @bitmap = RPG::Cache.character(@battler_name, @battler_hue)
          @width = @bitmap.width / 4
          @height = @bitmap.height / 4
        els
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top