1-Person DBS
#1
1 Person DBS
Version: 1.1

Introduction

A quick request I made.

Features
  • Shows the enemy's name and a small health bar.
  • Supports 640 * 480 big Battlebackgrounds.
Screenshots

[Image: fixnw5.th.png]

Script
Code:
#==============================================================================
# ** Scene_Battle (part 1)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  alias raz_old_main main
  alias raz_old_phase3_setup_command_window phase3_setup_command_window
  alias raz_old_start_phase1 start_phase1
  alias raz_old_start_phase2 start_phase2
  alias raz_old_start_enemy_select start_enemy_select
  alias raz_old_start_actor_select start_actor_select
  alias raz_old_start_skill_select start_skill_select
  alias raz_old_start_item_select start_item_select
  alias raz_old_start_phase4 start_phase4
  alias raz_old_update update
  alias raz_old_update_phase4_step5 update_phase4_step5
  alias raz_old_update_phase5 update_phase5
  alias raz_old_update_phase4_step1 update_phase4_step1
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make actor command window
    @enemy_name = Window_EnemyName.new
    raz_old_main
    @enemy_name.dispose
  end
  
  def start_phase1
    @actor_command_window = Actor_Command.new
    raz_old_start_phase1
  end

  def update
    @enemy_name.update
    raz_old_update
  end
  
  def phase3_setup_command_window
    raz_old_phase3_setup_command_window
    @party_command_window.visible = true
    @actor_command_window.visible = true
    @actor_command_window.x = 160
  end

  def start_phase2
    raz_old_start_phase2
    @party_command_window.visible = true
    @actor_command_window.visible = true
  end
  
  def start_enemy_select
    raz_old_start_enemy_select
    @actor_command_window.visible = true
  end

  def start_actor_select
    raz_old_start_actor_select
    @actor_command_window.visible = true
  end

  def start_skill_select
    raz_old_start_skill_select
    @actor_command_window.visible = true
  end

  def start_item_select
    raz_old_start_item_select
    @actor_command_window.visible = true
  end

  def start_phase4
    raz_old_start_phase4
    @party_command_window.visible = true
    @actor_command_window.visible = true
  end
  
  def update_phase4_step5
    @actor_command_window.refresh
    @enemy_name.refresh
    raz_old_update_phase4_step5
  end

    def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
        @enemy_name.refresh
      end
      return
    end
   raz_old_update_phase5
   end

  def update_phase4_step1
    raz_old_update_phase4_step1
    @enemy_name.refresh
  end

end
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
#  This window is used to select whether to fight or escape on the battle
#  screen.
#==============================================================================

class Window_PartyCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(160, 320, 320, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @commands = ["Fight", "Escape"]
    @item_max = 2
    @column_max = 2
    draw_item(0, normal_color)
    draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
    self.active = false
    self.visible = false
    self.index = 0
  end
    
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(index * 160 + 4, 0, 128 - 10, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end

  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(index * 160, 0, 128, 32)
  end
end


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

class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(480, 320, 160, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    @level_up_flags = [false, false, false, false]
    self.back_opacity = 160
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = 1
    actor = $game_party.actors[0]
    actor_x = 4
    draw_actor_name(actor, actor_x, 0)
    draw_actor_hp(actor, actor_x, 32, 120)
    draw_actor_sp(actor, actor_x, 64, 120)
    if @level_up_flags[1]
      self.contents.font.color = normal_color
      self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
    else
      draw_actor_state(actor, actor_x, 96)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # Slightly lower opacity level during main phase
    if $game_temp.battle_main_phase
      self.contents_opacity -= 4 if self.contents_opacity > 191
    else
      self.contents_opacity += 4 if self.contents_opacity < 255
    end
  end
end

class Spriteset_Battle
  def initialize
    # Make viewports
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 101
    @viewport3.z = 200
    @viewport4.z = 5000
    # Make battleback sprite
    @battleback_sprite = Sprite.new(@viewport1)
    # Make enemy sprites
    @enemy_sprites = []
    for enemy in $game_troop.enemies.reverse
      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    end
    # Make actor sprites
    @actor_sprites = []
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    # Make weather
    @weather = RPG::Weather.new(@viewport1)
    # Make picture sprites
    @picture_sprites = []
    for i in 51..100
      @picture_sprites.push(Sprite_Picture.new(@viewport3,
        $game_screen.pictures[i]))
    end
    # Make timer sprite
    @timer_sprite = Sprite_Timer.new
    # Frame update
    update
  end
  
  def update
    # Update actor sprite contents (corresponds with actor switching)
    @actor_sprites[0].battler = $game_party.actors[0]
    @actor_sprites[1].battler = $game_party.actors[1]
    @actor_sprites[2].battler = $game_party.actors[2]
    @actor_sprites[3].battler = $game_party.actors[3]
    # If battleback file name is different from current one
    if @battleback_name != $game_temp.battleback_name
      @battleback_name = $game_temp.battleback_name
      if @battleback_sprite.bitmap != nil
        @battleback_sprite.bitmap.dispose
      end
      @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
      @battleback_sprite.src_rect.set(0, 0, 640, 480)
    end
    # Update battler sprites
    for sprite in @enemy_sprites + @actor_sprites
      sprite.update
    end
    # Update weather graphic
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.update
    # Update picture sprites
    for sprite in @picture_sprites
      sprite.update
    end
    # Update timer sprite
    @timer_sprite.update
    # Set screen color tone and shake position
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # Set screen flash color
    @viewport4.color = $game_screen.flash_color
    # Update viewports
    @viewport1.update
    @viewport2.update
    @viewport4.update
  end
end

class Actor_Command < Window_Selectable
    def initialize
    super(160, 384, 320, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @item_max = 4
    @column_max = 2
    self.active = false
    self.visible = false
    self.index = 0
    refresh
  end
    
  def refresh
    self.contents.clear
    self.contents.draw_text(4, 0, 118, 32, $data_system.words.attack,1)
    self.contents.draw_text(164, 0, 118, 32, $data_system.words.skill,1)
    self.contents.draw_text(4, 32, 118, 32, $data_system.words.guard,1)
    self.contents.draw_text(164, 32, 118, 32, $data_system.words.item,1)
  end

  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect  
    self.cursor_rect.set(4 + index % 2 * 160, index / 2 * 32, 128, 32)
  end
end

class Window_EnemyName < Window_Base
  def initialize
    super(0, 320, 160, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    refresh
  end
  
  def refresh
   self.contents.clear
   self.contents.font.size = 21
   self.contents.draw_text(4, 0, 110, 32, "Enemies:")
    for i in 0...$game_troop.enemies.size
       x = 4 + i % 2 * 60
       enemy = $game_troop.enemies[i]
       y = i / 2 * 25 + 20
       self.contents.font.size = 16
       unless enemy.hp == 0
       draw_slant_bar(x ,y + 25, enemy.hp, enemy.maxhp, 50, 6)
       self.contents.draw_text(x, y, 130, 32, "#{enemy.name}")
       end
    end
  end

end

class Window_Base < Window  
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
end

class Game_Actor < Game_Battler
    def screen_x
    if self.index != nil
      return self.index * 160 + 550
    else
      return 0
    end
  end
end

class Spriteset_Battle
  alias seph_razdbsfix_ssbtl_update update
  def update
    seph_razdbsfix_ssbtl_update
    if @battleback_sprite.bitmap.height < 480
      src_bitmap = @battleback_sprite.bitmap
      src_rect = Rect.new(0, 0, @battleback_sprite.bitmap.width,
                                @battleback_sprite.bitmap.height)
      @battleback_sprite.bitmap = Bitmap.new(640, 480)
      @battleback_sprite.bitmap.stretch_blt(Rect.new(0, 0, 640, 480),
                                            src_bitmap, src_rect)
      @battleback_sprite.src_rect.set(0, 0, 640, 480)
    end
  end
end

Instructions

Place it above main. If you're using a CBS, put this script below it. I aliased most parts, so it should be compatible.

FAQ

None yet.

Compatibility

May be incompatible with your CBS.

Credits and Thanks

Thanks to Kaze950 for requesting it.
Thanks to SephirothSpawn for the bars script.

Author's Notes

Enjoy.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   FPLE : First Person Labyrinth Explorer MGC 66 143,795 09-29-2017, 03:47 AM
Last Post: DerVVulfman
   L's Simple Main Menu #3 - 1-person Landarma 1 7,733 10-14-2010, 04:25 AM
Last Post: Landarma



Users browsing this thread: 1 Guest(s)