RPG OTAKU
¡Hola! te invitamos a que te unas a RPG-OTAKU,
foro de desarrollo de videojuego con RPG MAKER y ademas de que tenemos del infaltable ocio.

Si deseas disfrutar del foro al 100%,
registrate, en poco minutos, sin confirmación de e-mail y totalmente gratis, si ya estas registrado, solamente conectate, y si lo que quieres es observar el foro como invitado, solo ignora este mensaje.
¡Eres libre de escoger lo que tu quieras!

Earthbound-ish Battle system

Ir abajo

Earthbound-ish Battle system

Mensaje por Neozero el Vie Sep 23, 2011 3:24 pm

Este script cambia la batalla por defecto por la del Earthbound
Screens:


Código:

#===============================================================================
#
# Cozziekuns Earthbound-ish Battle System
# Last Date Updated: 9/8/2011
#
# My first battle system, so I hope it's a half-decent one. It basically a
# remade version of the different Earthbound battle systems. Features from both
# Earthbound and Earthbound 2 come in this battle system, and maybe one or two
# things snuck in from Earthbound Zero. The rest of the battle system is purely
# custom.
#
# There might be a bit of lag from the odometer, but it shouldn't be too bad.
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 8/9/2011 - Added a feature to change the sprite's y offset.
# o 8/8/2011 - Fixed a major bug concerning skill and item targeting.
# o 5/9/2011 - (Hopefully) Fixed a major bug concerning random crashes.
# o 12/21/10 - Fixed a major bug concerning items.
# o 10/24/10 - Added a minor feature of transparency.
# o 10/17/10 - Fixed a major bug of being able to escape when no escape was on.
# o 08/22/10 - Fixed some bugs, like not seeing HP and MP when using skills.
# o 08/20/10 - Fixed a major error
# o 08/13/10 - Started Script.
#===============================================================================
# What's to come?
# -----------------------------------------------------------------------------
# o What's not to come. Any feature that you suggest.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ?\ Materials but above ?\ Main. Remember to save. You can
# edit the modules as you wish.
#===============================================================================

$imported = {} if $imported == nil
$imported["CozOithbound2BattleSystem"] = true

module COZZIEKUNS
  module EARTHBOUND_2_BATTLE_SYSTEM

    USE_SPRITES = true # Whether you want to use sprites or not.
    REFRESH_SPRITES = true # Whether you want your sprites to refresh or not.
    INANIMATE_SPRITES_WHEN_DEAD = true # Whether you want your sprites to refresh when dead.

    NORM_REFRESH_RATE = 20 # How fast you want your sprite to walk. 
    RUN_REFRESH_RATE = 10 # How fast you want your sprite to escape.

    ATTACK_TURN = true # Do you want your sprite to turn when attacking?

    BLACKBACK_TRANSPARENCY = 100 # Transparency for the message window.
    ESCAPE_ANIMATION = true # Do you want the characters to run off screen escaping?
    ESCAPE_ANIMATION_RATE = 5 # How fast do you want the characters to escape?

    ATTACK_ICON = 3 # Icon you want for the attack button
    SKILL_ICON = 21 # Icon you want for the skill button
    GUARD_ICON = 52 # Icon you want for the guard button
    ITEM_ICON = 144 # Icon you want for the item button
    ESCAPE_ICON = 48 # Icon you want for the escape button

    USE_ODOMETER = true # Do you want to use the Odometric system at all?
    LAG_TIME = 15 # Higher number, less lag. But the HP Bar refreshes slower.
    HP_DECREASE = 1 # How fast you want the HP to decrease. Formulas using the actor class are also applicable.
    MP_DECREASE = 1 # How fast you want the MP to decrease. Formulas using the actor class are also applicable.
    ROLL_SOUND = RPG::SE.new("Shop", 80, 100) # The sound you want to make when the odometer rolls.

    SPRITE_TRANSPARENCY = 0 # Transparency of the battle sprite when unactive.
    SPRITEY_OFFSET = -16 # Offset of the Sprite's Y co-ordinate. Negative moves up, positive down.

  end
end

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :norm
  attr_accessor :odometric_hp
  attr_accessor :odometric_mp
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias coz_eartbound_gb_initialize initialize
  def initialize
    @norm = false
    @odometric_hp = 0
    @odometric_mp = 0
    coz_eartbound_gb_initialize
  end
end

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Use Sprites?
  #--------------------------------------------------------------------------
  def use_sprite?
    return COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::USE_SPRITES
  end
  #--------------------------------------------------------------------------
  # * Get Screen X-Coordinates
  #--------------------------------------------------------------------------
  def screen_x
    case $game_party.members.size
    when 1
      n = 272
    when 2
      if $game_party.members[0].name == @name
        n = 208
      else
        n = 336
      end
    when 3
      if $game_party.members[0].name == @name
        n = 112
      elsif $game_party.members[1].name == @name
        n = 240
      else
        n = 368
      end
    when 4
      if $game_party.members[0].name == @name
        n = 80
      elsif $game_party.members[1].name == @name
        n = 208
      elsif $game_party.members[2].name == @name
        n = 336
      else
        n = 464
      end
    end
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Screen Y-Coordinates
  #--------------------------------------------------------------------------
  def screen_y
    return 292 + COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SPRITEY_OFFSET
  end
  #--------------------------------------------------------------------------
  # * Get Screen Z-Coordinates
  #--------------------------------------------------------------------------
  def screen_z
    return 100
  end
  #--------------------------------------------------------------------------
  # * Damage Reflection
  #    user : User of skill or item
  #    @hp_damage, @mp_damage, or @absorbed must be calculated before this
  #    method is called.
  #--------------------------------------------------------------------------
  def execute_damage(user)
    if @hp_damage > 0          # Damage is a positive number
      remove_states_shock      # Remove state due to attack
    end
    if COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::USE_ODOMETER and $game_temp.in_battle
      @odometric_hp += @hp_damage
      @odometric_mp += @mp_damage
      if @absorbed and user == self # If absorbing
        @odometric_hp -= @hp_damage
        @odometric_mp -= @mp_damage
      end
    else
      self.hp -= @hp_damage
      self.mp -= @mp_damage
      if @absorbed                # If absorbing
        user.hp += @hp_damage
        user.mp += @mp_damage
      end
    end
  end
end

#==============================================================================
# ** Sprite Battler
#------------------------------------------------------------------------------
#  Summary of Changes:
#    aliased method - update_effect
#==============================================================================

class Sprite_Battler
  #--------------------------------------------------------------------------
  # * Stop Effect
  #--------------------------------------------------------------------------
  alias coz_eartbound_spb_update_effect update_effect
  def update_effect
    if @battler.norm
      @effect_duration = 1
      @battler.norm = false
    end
    coz_eartbound_spb_update_effect
  end
end

#==============================================================================
# ** Sprite_BattleActor
#------------------------------------------------------------------------------
#  This displays a walking sprite. You know, a sprite that walks?
#==============================================================================

class Sprite_BattleActor < Sprite_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :enabled             
  attr_accessor :pos2
  attr_accessor :running
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor_id, index, viewport)
    super(viewport)
    @actor_id = actor_id
    @char_name = $game_party.members[actor_id].character_name
    @char_index = $game_party.members[actor_id].character_index
    @index = index
    @pos = 1
    @pos2 = 0
    @frames = 0
    @enabled = false
    @running = false
    update
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose
    super
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @running
      self.oy -= (COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ESCAPE_ANIMATION ? COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ESCAPE_ANIMATION_RATE : 0)
    end
    case $game_party.members.size
    when 1
      self.x = 256
    when 2
      self.x = @index * 128 + 192
    when 3
      self.x = @index * 128 + 128
    when 4
      self.x = @index * 128 + 64
    end
    self.y = 260 + COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SPRITEY_OFFSET
    self.bitmap = draw_character(@char_name, @char_index)
    if @frames >= (@running ? COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::RUN_REFRESH_RATE : COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::NORM_REFRESH_RATE)
      return if COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::REFRESH_SPRITES == false
      return if $game_party.members[@actor_id].dead? and COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::INANIMATE_SPRITES_WHEN_DEAD
      @pos += 1
      @pos %= 3
      @frames = 0
    end
    @frames += 1
  end
  #--------------------------------------------------------------------------
  # * Draw Character Graphic
  #    character_name  : Character graphic filename
  #    character_index : Character graphic index
  #    x    : draw spot x-coordinate
  #    y    : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_character(character_name, character_index, enabled = @enabled)
    return if character_name == nil
    return if COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::USE_SPRITES == false
    bitmap = Cache.character(character_name)
    sign = character_name[/^[\!\$]./]
    if sign != nil and sign.include?('$')
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    n = character_index
    src_rect = Rect.new((n % 4 * 3 + @pos) * cw, (n / 4 * 4 + @pos2) * ch, cw, ch)
    bitmap2 = Bitmap.new(32, 32)
    bitmap2.blt(0, 0, bitmap, src_rect, enabled ? 255 : COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SPRITE_TRANSPARENCY)
    return bitmap2
  end
end

#==============================================================================
# ** Sprite_BlackBack
#------------------------------------------------------------------------------
#  Waaasteful Sprite, but I had no other way to do this.
#==============================================================================

class Sprite_BlackBack < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :dummy_height           
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    viewport : viewport
  #    picture  : picture (Game_Picture)
  #--------------------------------------------------------------------------
  def initialize(viewport)
    super(viewport)
    @dummy_height = 132
    update
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    self.x = 0
    self.y = 0
    self.bitmap = Bitmap.new(544, @dummy_height)
    self.bitmap.fill_rect(0, 0, 544, @dummy_height, Color.new(0, 0, 0))
    self.opacity = COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::BLACKBACK_TRANSPARENCY
  end
end
   
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :showing_battle_message   
  attr_accessor :active_battler
  attr_accessor :running
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @showing_battle_message = false
    @running = false
    create_viewports
    create_battleback
    create_battlefloor
    create_enemies
    create_actors
    create_pictures
    create_timer
    create_blackback
    create_characters
    update
  end
  #--------------------------------------------------------------------------
  # * Create Black Background Sprite
  #--------------------------------------------------------------------------
  def create_blackback
    @blackback_sprite = Sprite_BlackBack.new(@viewport2)
  end
  #--------------------------------------------------------------------------
  # * Create Character Sprites
  #--------------------------------------------------------------------------
  def create_characters
    @character_sprites = []
    for i in 0...$game_party.members.size
      sprite = Sprite_BattleActor.new(i, i, @viewport2)
      @character_sprites.push(sprite)
    end
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  alias coz_earthbound_ssb_dispose dispose
  def dispose
    coz_earthbound_ssb_dispose
    dispose_blackback
    dispose_characters
  end
  #--------------------------------------------------------------------------
  # * Dispose of Black Background Sprite
  #--------------------------------------------------------------------------
  def dispose_blackback
    @blackback_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Dispose of Character Sprites
  #--------------------------------------------------------------------------
  def dispose_characters
    for sprite in @character_sprites
      sprite.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias coz_eartbound_ssb_update update
  def update
    coz_eartbound_ssb_update
    update_blackback
    update_characters
  end
  #--------------------------------------------------------------------------
  # * Update Black Background
  #--------------------------------------------------------------------------
  def update_blackback
    if @showing_battle_message
      @blackback_sprite.dummy_height = 132
    else
      @blackback_sprite.dummy_height = 60
    end
    @blackback_sprite.update
  end
  #--------------------------------------------------------------------------
  # * Update Character Sprites
  #--------------------------------------------------------------------------
  def update_characters
    for sprite in @character_sprites; sprite.pos2 = 0; end
    if @running
      for i in [Tienes que estar registrado y conectado para ver este vínculo]
        @character_sprites[i].enabled = true
        @character_sprites[i].running = true
      end
    end
    case @active_battler
    when 0
      for i in [Tienes que estar registrado y conectado para ver este vínculo]
        @character_sprites[i].enabled = false
      end
    when 1
      case @character_sprites.size
      when 1
        @character_sprites[0].enabled = true
      when 2
        @character_sprites[0].enabled = true
        @character_sprites[1].enabled = false
      when 3
        @character_sprites[0].enabled = true
        @character_sprites[1].enabled = false
        @character_sprites[2].enabled = false
      when 4
        @character_sprites[0].enabled = true
        @character_sprites[1].enabled = false
        @character_sprites[2].enabled = false
        @character_sprites[3].enabled = false
      end
    when 2
      case @character_sprites.size
      when 2
        @character_sprites[0].enabled = false
        @character_sprites[1].enabled = true
      when 3
        @character_sprites[0].enabled = false
        @character_sprites[1].enabled = true
        @character_sprites[2].enabled = false
      when 4
      @character_sprites[0].enabled = false
      @character_sprites[1].enabled = true
      @character_sprites[2].enabled = false
      @character_sprites[3].enabled = false
      end
    when 3
      case @character_sprites.size
      when 3
        @character_sprites[0].enabled = false
        @character_sprites[1].enabled = false
        @character_sprites[2].enabled = true
      when 4
      @character_sprites[0].enabled = false
      @character_sprites[1].enabled = false
      @character_sprites[2].enabled = true
      @character_sprites[3].enabled = false
      end
    when 4
      @character_sprites[0].enabled = false
      @character_sprites[1].enabled = false
      @character_sprites[2].enabled = false
      @character_sprites[3].enabled = true
    when 5
      for i in [Tienes que estar registrado y conectado para ver este vínculo]
        @character_sprites[i].pos2 = (COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ATTACK_TURN ? 3 : 0)
        @character_sprites[i].enabled = true
      end
    end
    for sprite in @character_sprites
      sprite.update
    end
  end
end

#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
#  Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================

class Window_BattleMessage < Window_Message
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias coz_earthbound_wbm_initialize initialize
  def initialize
    coz_earthbound_wbm_initialize
    self.x = 0
    self.y = 0
    self.opacity = 0
  end
end

#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
#  This window is used to select actor commands, such as "Attack" or "Skill".
#==============================================================================

class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Setup
  #    actor : actor
  #--------------------------------------------------------------------------
  def setup(actor)
    s1 = Vocab::attack
    s2 = Vocab::skill
    s3 = Vocab::guard
    s4 = Vocab::item
    s5 = Vocab::escape
    if actor.class.skill_name_valid    # Skill command name is valid?
      s2 = actor.class.skill_name      # Replace command name
    end
    @commands = [s1, s2, s3, s4, s5]
    @item_max = 5
    draw_item(1, $game_troop.can_escape)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if cursor_movable?
      if Input.repeat?(Input::RIGHT)
        cursor_down(Input.trigger?(Input::RIGHT))
      end
      if Input.repeat?(Input::LEFT)
        cursor_up(Input.trigger?(Input::LEFT))
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if cursor is moveable
  #--------------------------------------------------------------------------
  def cursor_movable?
    return false if (not active)
    return false if (index < 0 or index > @item_max or @item_max == 0)
    return false if (@opening or @closing)
    return true
  end
end

#==============================================================================
# ** Window_DummyCommand
#------------------------------------------------------------------------------
#  Creates a dummy command window. Nothing to see here kids.
#==============================================================================

class Window_DummyCommand < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    x : window X coordinate
  #    y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 544, 120)
    refresh
    self.visible = false
    self.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(index = 0)
    self.contents.clear
    if index == 0
      self.contents.draw_text(0, 0, 504, WLH, Vocab::attack, 2)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ATTACK_ICON, 0, 0, true)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SKILL_ICON, 64, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::GUARD_ICON, 128, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ITEM_ICON, 192, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ESCAPE_ICON, 256, 0, false)
    elsif index == 1
      self.contents.draw_text(0, 0, 504, WLH, Vocab::skill, 2)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ATTACK_ICON, 0, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SKILL_ICON, 64, 0, true)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::GUARD_ICON, 128, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ITEM_ICON, 192, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ESCAPE_ICON, 256, 0, false)
    elsif index == 2
      self.contents.draw_text(0, 0, 504, WLH, Vocab::guard, 2)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ATTACK_ICON, 0, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SKILL_ICON, 64, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::GUARD_ICON, 128, 0, true)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ITEM_ICON, 192, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ESCAPE_ICON, 256, 0, false)
    elsif index == 3
      self.contents.draw_text(0, 0, 504, WLH, Vocab::item, 2)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ATTACK_ICON, 0, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SKILL_ICON, 64, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::GUARD_ICON, 128, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ITEM_ICON, 192, 0, true)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ESCAPE_ICON, 256, 0, false)
    elsif index == 4
      self.contents.draw_text(0, 0, 504, WLH, Vocab::escape, 2)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ATTACK_ICON, 0, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::SKILL_ICON, 64, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::GUARD_ICON, 128, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ITEM_ICON, 192, 0, false)
      draw_icon(COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ESCAPE_ICON, 256, 0, true)
    end
  end
end


#==============================================================================
# ** Window_TargetEnemy
#------------------------------------------------------------------------------
#  Window for selecting the enemy who is the action target on the battle
# screen.
#==============================================================================

class Window_TargetEnemy < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    commands = []
    @enemies = []
    for enemy in $game_troop.members
      next unless enemy.exist?
      commands.push(enemy.name)
      @enemies.push(enemy)
    end
    super(416, commands, 2, 4)
    self.visible = false
  end
  #--------------------------------------------------------------------------
  # * Get Enemy Object
  #--------------------------------------------------------------------------
  def enemy
    return @enemies[@index]
  end
  #--------------------------------------------------------------------------
  # * Determine if cursor is moveable
  #--------------------------------------------------------------------------
  def cursor_movable?
    return false if (not active)
    return false if (index < 0 or index > @item_max or @item_max == 0)
    return false if (@opening or @closing)
    return true
  end
end


#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
#  This window displays the status of all party members on the battle screen.
#==============================================================================

class Window_BattleStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, $game_party.members.size * 128 + 32, 128)
    refresh
    self.active = false
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if cursor_movable?
      if Input.repeat?(Input::RIGHT)
        cursor_down(Input.trigger?(Input::RIGHT))
      end
      if Input.repeat?(Input::LEFT)
        cursor_up(Input.trigger?(Input::LEFT))
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #    index : Item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = Rect.new(0, 0, 128, 96)
    rect.x = index * 128
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    actor = $game_party.members[index]
    draw_face_graphic(actor.face_name, actor.face_index, rect.x + 16, rect.y, 96)
    draw_actor_name(actor, rect.x + (128 - self.contents.text_size(actor.name).width) / 2, 0)
    draw_actor_state(actor, rect.x, 24, 48)
  end
  #--------------------------------------------------------------------------
  # * Draw Face Graphic
  #    face_name  : Face graphic filename
  #    face_index : Face graphic index
  #    x    : draw spot x-coordinate
  #    y    : draw spot y-coordinate
  #    size      : Display size
  #--------------------------------------------------------------------------
  def draw_face_graphic(face_name, face_index, x, y, size = 96)
    bitmap = Cache.face(face_name)
    rect = Rect.new(0, 0, 0, 0)
    rect.x = face_index % 4 * 96 + (96 - size) / 2
    rect.y = face_index / 4 * 96 + (96 - size) / 2
    rect.width = size
    rect.height = size
    self.contents.blt(x, y, bitmap, rect, 100)
    bitmap.dispose
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(@index * 128, 0, 128, 96)
    end
  end
end

#==============================================================================
# ** Window_BattleHP
#------------------------------------------------------------------------------
#  This window displays the status of all party members on the battle screen.
#==============================================================================

class Window_BattleHP < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, $game_party.members.size * 128 + 32, 128)
    refresh
    self.active = false
    self.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.members.size
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #    index : Item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = Rect.new(0, 0, 128, 96)
    rect.x = index * 128
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    actor = $game_party.members[index]
    draw_actor_hp(actor, rect.x + 3, 48, 120)
    draw_actor_mp(actor, rect.x + 3, 72, 120)
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    $game_temp.in_battle = true
    @message_window = Window_BattleMessage.new
    @dummy_command_window = Window_DummyCommand.new
    @spriteset = Spriteset_Battle.new
    @action_battlers = []
    @frames = 0
    create_info_viewport
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_info_viewport
    @message_window.dispose
    @dummy_command_window.dispose
    @spriteset.dispose
    unless $scene.is_a?(Scene_Gameover)
      $scene = nil if $BTEST
    end
  end
  #--------------------------------------------------------------------------
  # * Basic Update Processing
  #    main : Call from main update method
  #--------------------------------------------------------------------------
  def update_basic(main = false)
    Graphics.update unless main    # Update game screen
    Input.update unless main        # Update input information
    $game_system.update            # Update timer
    $game_troop.update              # Update enemy group
    @spriteset.update              # Update sprite set
    @message_window.update          # Update message window
    @dummy_command_window.update
    odometer_update unless main
    odometer_update
  end
  #--------------------------------------------------------------------------
  # * Odometer Update
  #--------------------------------------------------------------------------
  def odometer_update
    return if COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::USE_ODOMETER == false
    for actor in $game_party.existing_members
      if actor.odometric_hp > 0
        if @frames % 2 == 1
          actor.hp -= 1
          actor.odometric_hp -= 1
        end
        if @frames >= COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::LAG_TIME
          COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ROLL_SOUND.play
          @hp_window.refresh
          @frames = 0
        end
      elsif actor.odometric_hp < 0
        actor.hp += 2
        actor.odometric_hp += 2
        if @frames >= COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::LAG_TIME
          COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ROLL_SOUND.play
          @hp_window.refresh
          @frames = 0
        end
      end
      if actor.odometric_mp > 0
        if @frames % 2 == 1
          actor.mp -= 1
          actor.odometric_mp -= 1
        end
        if @frames >= COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::LAG_TIME
          COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ROLL_SOUND.play
          @hp_window.refresh
          @frames = 0
        end
      elsif actor.odometric_mp < 0
        actor.mp += 2
        actor.odometric_mp += 2
        if @frames >= COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::LAG_TIME
          COZZIEKUNS::EARTHBOUND_2_BATTLE_SYSTEM::ROLL_SOUND.play
          @hp_window.refresh
          @frames = 0
        end
      end
    end
    @frames += 1
  end
  #--------------------------------------------------------------------------
  # * Wait a set amount of time
  #    duration : Wait time (number of frames)
  #    no_fast  : Fast forward disabled
  #    A method for inserting a wait during scene class update processing.
  #    As a rule, update is called once for each frame, but during battle it
  #    can be difficult to grasp the processing flow, so this method is used
  #    as an exception.
  #--------------------------------------------------------------------------
  def wait(duration, no_fast = false)
    for i in 0...duration
      update_basic
      break if not no_fast and i >= duration / 2 and show_fast?
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    odometer_update
    update_basic(true)
    update_info_viewport                  # Update information viewport
    unless @message_window.visible
      @spriteset.showing_battle_message = false
    end
    if $game_message.visible
      @spriteset.showing_battle_message = true
      @info_viewport.visible = false
      @dummy_command_window.visible = false
      @message_window.visible = true
    end
    if @message_window.visible
      @dummy_command_window.visible = false
      @spriteset.showing_battle_message = true
      @info_viewport.visible = true
    end
    unless $game_message.visible          # Unless displaying a message
      return if judge_win_loss            # Determine win/loss results
      update_scene_change
      if @target_enemy_window != nil
        update_target_enemy_selection    # Select target enemy
      elsif @target_actor_window != nil
        update_target_actor_selection    # Select target actor
      elsif @skill_window != nil
        update_skill_selection            # Select skill
      elsif @item_window != nil
        update_item_selection            # Select item
      elsif @actor_command_window.active
        update_actor_command_selection    # Select actor command
      else
        process_battle_event              # Battle event processing
        process_action                    # Battle action
        process_battle_event              # Battle event processing
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Create Information Display Viewport
  #--------------------------------------------------------------------------
  def create_info_viewport
    @info_viewport = Viewport.new(0, 288, 544, 128)
    @info_viewport.z = 100
    @status_window = Window_BattleStatus.new
    @actor_command_window = Window_ActorCommand.new
    @status_window.viewport = @info_viewport
    @actor_command_window.viewport = @info_viewport
    case $game_party.members.size
    when 1
      @status_window.x = 192
    when 2
      @status_window.x = 128
    when 3
      @status_window.x = 64
    when 4
      @status_window.x = 0
    end
    @hp_window = Window_BattleHP.new
    @hp_window.x = @status_window.x
    @hp_window.viewport = @info_viewport
    @actor_command_window.x = 416
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # * Dispose of Information Display Viewport
  #--------------------------------------------------------------------------
  def dispose_info_viewport
    @status_window.dispose
    @actor_command_window.dispose
    @info_viewport.dispose
  end
  #--------------------------------------------------------------------------
  # * Update Information Display Viewport
  #--------------------------------------------------------------------------
  def update_info_viewport
    @actor_command_window.update
    @dummy_command_window.update
    @status_window.update
  end
  #--------------------------------------------------------------------------
  # * Go to Command Input for Next Actor
  #--------------------------------------------------------------------------
  def next_actor
    loop do
      if @actor_index == $game_party.members.size - 1
        start_main
        return
      end
      @status_window.index = @actor_index += 1
      @active_battler = $game_party.members[@actor_index]
      @spriteset.active_battler += 1
      if @active_battler.auto_battle
        @active_battler.make_action
        next
      end
      break if @active_battler.inputable?
    end
    start_actor_command_selection
  end
  #--------------------------------------------------------------------------
  # * Go to Command Input of Previous Actor
  #--------------------------------------------------------------------------
  def prior_actor
    loop do
      if @actor_index == 0
        @spriteset.active_battler -= 1
        start_party_command_selection
        return
      end
      @status_window.index = @actor_index -= 1
      @active_battler = $game_party.members[@actor_index]
      next if @active_battler.auto_battle
      break if @active_battler.inputable?
      @spriteset.active_battler -= 1
    end
    start_actor_command_selection
  end
  #--------------------------------------------------------------------------
  # * Start Party Command Selection
  #--------------------------------------------------------------------------
  def start_party_command_selection
    if $game_temp.in_battle
      @hp_window.refresh
      @status_window.refresh
      @status_window.index = @actor_index = -1
      @active_battler = nil
      @info_viewport.visible = true
      @message_window.visible = false
      $game_party.clear_actions
      if $game_troop.surprise or not $game_party.inputable?
        start_main
      end
      next_actor
    end
  end
  #--------------------------------------------------------------------------
  # * Start Actor Command Selection
  #--------------------------------------------------------------------------
  def start_actor_command_selection
    @actor_command_window.setup(@active_battler)
    @actor_command_window.active = true
    @actor_command_window.index = 0
  end
  #--------------------------------------------------------------------------
  # * Update Actor Command Selection
  #--------------------------------------------------------------------------
  def update_actor_command_selection
    odometer_update
    @dummy_command_window.visible = true
    @dummy_command_window.refresh(@actor_command_window.index)
    if Input.trigger?(Input::B)
      Sound.play_cancel
      prior_actor
    elsif Input.trigger?(Input::C)
      case @actor_command_window.index
      when 0  # Attack
        Sound.play_decision
        @active_battler.action.set_attack
        start_target_enemy_selection
      when 1  # Skill
        Sound.play_decision
        start_skill_selection
      when 2  # Guard
        Sound.play_decision
        @active_battler.action.set_guard
        next_actor
      when 3  # Item
        Sound.play_decision
        start_item_selection
      when 4  # Escape
        if $game_troop.can_escape == false
          Sound.play_buzzer
          return
        end
        Sound.play_decision
        process_escape
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Battle Start Processing
  #--------------------------------------------------------------------------
  alias coz_earthbound_sb_process_battle_start process_battle_start
  def process_battle_start
    @spriteset.showing_battle_message = true
    @spriteset.active_battler = 0
    coz_earthbound_sb_process_battle_start
  end
  #--------------------------------------------------------------------------
  # * Start Target Enemy Selection
  #--------------------------------------------------------------------------
  def start_target_enemy_selection
    @help_window.visible = false if not @help_window == nil
    @skill_window.visible = false if not @skill_window == nil
    @item_window.visible = false if not @item_window == nil
    @target_enemy_window = Window_TargetEnemy.new
    @actor_command_window.active = false
  end
  #--------------------------------------------------------------------------
  # * End Target Enemy Selection
  #--------------------------------------------------------------------------
  def end_target_enemy_selection
    @target_enemy_window.dispose
    @target_enemy_window = nil
    if @actor_command_window.index == 0
      @actor_command_window.active = true
    end
    @skill_window.visible = true if not @skill_window == nil
    @item_window.visible = true if not @item_window == nil
    @help_window.visible = false if not @help_window == nil
  end
  #--------------------------------------------------------------------------
  # * Update Target Enemy Selection
  #--------------------------------------------------------------------------
  alias coz_eartbound_sb_update_target_enemy_selection update_target_enemy_selection
  def update_target_enemy_selection
    enemy_dump = @target_enemy_window.enemy
    coz_eartbound_sb_update_target_enemy_selection
    if @target_enemy_window.nil? || enemy_dump != @target_enemy_window.enemy
      enemy_dump.norm = true
      return if @target_enemy_window.nil?
    end
    @target_enemy_window.enemy.white_flash = true
  end
  #--------------------------------------------------------------------------
  # * Start Target Actor Selection
  #--------------------------------------------------------------------------
  alias coz_earthbound_sb_start_target_actor_selection start_target_actor_selection
  def start_target_actor_selection
    @target_actor_hp_window = Window_BattleHP.new
    coz_earthbound_sb_start_target_actor_selection
    case $game_party.members.size
    when 1; @target_actor_window.x = 192
    when 2; @target_actor_window.x = 128
    when 3; @target_actor_window.x = 64
    when 4; @target_actor_window.x = 0
    end
    @target_actor_hp_window.x = @target_actor_window.x
    @target_actor_hp_window.y = @target_actor_window.y
    @target_actor_hp_window.z = 9001
  end
  #--------------------------------------------------------------------------
  # * End Target Actor Selection
  #--------------------------------------------------------------------------
  alias coz_earthbound_sb_end_target_actor_selection end_target_actor_selection
  def end_target_actor_selection
    coz_earthbound_sb_end_target_actor_selection
    @target_actor_hp_window.dispose
    @target_actor_hp_window = nil
  end
  #--------------------------------------------------------------------------
  # * Start Execution of Battle Processing
  #--------------------------------------------------------------------------
  def start_main
    @spriteset.active_battler = 5
    $game_troop.increase_turn
    @message_window.visible = true
    @actor_command_window.active = false
    @status_window.index = @actor_index = -1
    @active_battler = nil
    @message_window.clear
    $game_troop.make_actions
    make_action_orders
    wait(20)
  end
  #--------------------------------------------------------------------------
  # * End Turn
  #--------------------------------------------------------------------------
  def turn_end
    $game_troop.turn_ending = true
    $game_party.slip_damage_effect
    $game_troop.slip_damage_effect
    $game_party.do_auto_recovery
    $game_troop.preemptive = false
    $game_troop.surprise = false
    process_battle_event
    $game_troop.turn_ending = false
    @spriteset.active_battler = 0
    start_party_command_selection
  end
  #--------------------------------------------------------------------------
  # * Victory Processing
  #--------------------------------------------------------------------------
  def process_victory
    @info_viewport.visible = true
    @message_window.visible = true
    RPG::BGM.stop
    $game_system.battle_end_me.play
    unless $BTEST
      $game_temp.map_bgm.play
      $game_temp.map_bgs.play
    end
    display_exp_and_gold
    display_drop_items
    display_level_up
    battle_end(0)
  end
  #--------------------------------------------------------------------------
  # * Escape Processing
  #--------------------------------------------------------------------------
  def process_escape
    @info_viewport.visible = false
    @dummy_command_window.visible = false
    @message_window.visible = true
    text = sprintf(Vocab::EscapeStart, $game_party.name)
    $game_message.texts.push(text)
    if $game_troop.preemptive
      success = true
    else
      success = (rand(100) < @escape_ratio)
    end
    Sound.play_escape
    if success
      @spriteset.running = true
      wait_for_message
      battle_end(1)
    else
      @escape_ratio += 10
      $game_message.texts.push('\.' + Vocab::EscapeFailure)
      wait_for_message
      $game_party.clear_actions
      start_main
    end
  end
  #--------------------------------------------------------------------------
  # * Show Action Results
  #    target : Target
  #    obj    : Skill or item
  #--------------------------------------------------------------------------
  def display_action_effects(target, obj = nil)
    @hp_window.refresh
    @status_window.refresh
    unless target.skipped
      line_number = @message_window.line_number
      wait(5)
      display_critical(target, obj)
      display_damage(target, obj)
      display_state_changes(target, obj)
      if line_number == @message_window.line_number
        display_failure(target, obj) unless target.states_active?
      end
      if line_number != @message_window.line_number
        wait(30)
      end
      @message_window.back_to(line_number)
    end
  end
  #--------------------------------------------------------------------------
  # * End Skill Selection
  #--------------------------------------------------------------------------
  alias coz_earthbound_sb_end_skill_selection end_skill_selection
  def end_skill_selection
    coz_earthbound_sb_end_skill_selection
    @dummy_command_window.visible = true
  end
  #--------------------------------------------------------------------------
  # * End Item Selection
  #--------------------------------------------------------------------------
  alias coz_eartbound_sb_end_item_selection end_item_selection
  def end_item_selection
    coz_eartbound_sb_end_item_selection
    @dummy_command_window.visible = true
  end
end
Creditos:
cozziekuns


[Tienes que estar registrado y conectado para ver este vínculo]
avatar
Neozero
Moderador
Moderador

Mensajes : 366
Fecha de inscripción : 07/09/2011
Creditos : 644

Ver perfil de usuario

Volver arriba Ir abajo

Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.