Batalha Por Trás

6 de novembro de 2011

Script para o RPG Maker XP, feito por パラ戟 que, ao ser adicionado a um projeto, mostra o characters dos heróis de costas, como se estivessemos vendo a batalha por trás do nosso grupo. Para ficar bacana, acho que as posições dos monstros nos grupos de monstros, tem que ser redefinidas para um ponto mais alto na tela.

#==============================================================================
# @ { { @サイドビュ [バトル i歩sグラフィック箔タj @ver. 1.14 @ { {
# @ @Script by パラ戟
# @ @http://para.j-mx.com/
#------------------------------------------------------------------------------
# バトルフィ [ルドu5・sグラフィックり貼ヲk"梳限B
#==============================================================================

module SDVA

  X_LINE = 140        # 堰(武uv{トラ [表ヲ 嵩W
  Y_LINE = 290        #  c・訊v{トラ [表ヲ 嵩W
  X_SPACE = 120        # 堰(武uv{トラ [嶋.mv・・
  Y_SPACE = 0        #  c・訊v{トラ [嶋.mv・・
  X_POSITION = 0     # 隊暮タm前衛 E中衛 E娯)q nv〟*嚠u
  Y_POSITION = 10      # 隊暮タm前衛 E中衛 E娯)q nvc噛・
  PARTY_POS = 3      # キャラクタ [v基€・i 0:燕/ 1: ・/ 2:右 / 3: 簑 j

  ATTACK_MOVE = true  #  U撃桙・O・巣"淆ol"・i true / false  j
  SKILL_MOVE = true   # スキルg用桙・O・巣"淆ol"・i true / false  j
  ITEM_MOVE = false   # アイテムg用桙・O・巣"淆ol"・i true / false  j
  MOVE_STEP = 1       # ・燥内・
  MOVE_PIXEL = 10     # 亥内€ o"艢磨sクセル ・

  PARTY_POS = 3       # キャラクタ [v基€・i 0:燕/ 1: ・/ 2:右 / 3: 簑 j

  WINDOWPOS_CHANGE = true   # コマンドウインドウり{トラ [v〟"・\ヲl"・・i true / false  j

  end

#==============================================================================
#  ・Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  #  ・バトル峨舶X  嵩Wv後聡
  #--------------------------------------------------------------------------
  def screen_x
    if self.index != nil
      # 隊暮"闌繿・
      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
      # ・燥、クションv€凍・
      if self.current_action.move_action == true
        # 堰"・搗・
        scr_x += @shift_x
      end
      return scr_x
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  #  ・バトル峨舶Y  嵩Wv後聡
  #--------------------------------------------------------------------------
  def screen_y
    if self.index != nil
      # 隊暮"闌繿・
      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
      # ・燥、クションv€凍・
      if self.current_action.move_action == true
        #  cu(搗・
        scr_y += @shift_y
      end
      return scr_y
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  #  ・バトル峨舶Z  嵩Wv後聡
  #--------------------------------------------------------------------------
  def screen_z
    if self.index != nil
      return self.index
    else
      return 0
    end
  end
end

#==============================================================================
#  ・Game_Battler (腐・剃荏 1)
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  #  ・誤・インスタンス葺タ・
  #--------------------------------------------------------------------------
  attr_reader   :pattern        # 歩sパタ [ン
  attr_reader   :trans_x        # X俸,蕫昧搗㊨覧く
  attr_reader   :moving         # ・燥炊フラグ
  #--------------------------------------------------------------------------
  #  ・オブジェクト 炎奣鹿
  #--------------------------------------------------------------------------
  alias initialize_sdva initialize
  def initialize
    initialize_sdva
    move_reset
  end
  #--------------------------------------------------------------------------
  #  ・・燥゛ウント
  #--------------------------------------------------------------------------
  def move
    @moving = 1
      if @step < SDVA::MOVE_STEP
        # 歩狽阡桙・・梳・搗・
        @pattern = (@pattern + 1) % 4
        @step += 1
        move_step
      else
        # ・燥I絡ュ
        @pattern = 1
        @moving = 2
      end
  end
  #--------------------------------------------------------------------------
  #  ・・燥・ 
  #--------------------------------------------------------------------------
  def move_step
  # パ [ティv基€・・縲・中搗・嵩Wり祷"ム蟄
  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
  #--------------------------------------------------------------------------
  #  ・・燥€磨潟Zット
  #--------------------------------------------------------------------------
  def move_reset
    @moving = 0
    @pattern = 0
    @step = 0
    @shift_x = 0
    @shift_y = 0
  end
end

#==============================================================================
#  ・Game_BattleAction
#==============================================================================

class Game_BattleAction
  #--------------------------------------------------------------------------
  #  ・誤・インスタンス葺タ・
  #--------------------------------------------------------------------------
  attr_accessor :move_action             # ・燥€・・Aクションeュ
  #--------------------------------------------------------------------------
  #  ・クリア
  #--------------------------------------------------------------------------
  alias clear_sdva clear
  def clear
    clear_sdva
    @move_action = false
  end
end

#==============================================================================
#  ・Sprite_Battler
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  #  ・フレ [ム X V
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    # バトラ [e、クタ [u*梳梳蛟・凍・
    if @battler.is_a?(Game_Actor)
      # ファイル鮪€・F相e且タ・摩烙摩宕・楳蠡・・
      #  s島炊v・・
      if @battler.battler_name != @battler_name or
         @battler.battler_hue != @battler_hue or
         @battler.current_action.basic == 0 or
         @battler.current_action.kind != 3
        # ビットマップり後聡A ・・
        @character_name = @battler.character_name
        @character_hue = @battler.character_hue
        # 歩sグラフィックり伝峨
        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
          # 歩€・・蟄
          @battler.move
        else
          @battler.move_reset
        end
        # 転送穴"哩・`り・・
        sx = @battler.pattern * cw
        sy = SDVA::PARTY_POS * ch
        self.src_rect.set(sx, sy, cw, ch)
        self.ox = @width / 2
        self.oy = @height
        # 隠ょ・噫楳・s塘6書xり0 u"・蟄
        if @battler.hidden
          self.opacity = 0
        end
      end
    end
    update_sdva
  end
end

#==============================================================================
#  ・Scene_Battle
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  #  ・アクタ [コマンドウィンドウv〇ットアップ
  #--------------------------------------------------------------------------
  alias phase3_setup_command_window_sdva phase3_setup_command_window
  def phase3_setup_command_window
    phase3_setup_command_window_sdva
    if SDVA::WINDOWPOS_CHANGE
      # アクタ [コマンドウィンドウv・訊り・・
      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
      # ステ [タスウインドウu)Bょ€楳÷縲・墳
      @actor_command_window.z = 9999
    end
  end
  #--------------------------------------------------------------------------
  #  ・フレ [ム X V (・インフェ [ズ ステップ 3 :  s島盾、ニ・ [ション)
  #--------------------------------------------------------------------------
  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
    # バトラ [e、クタ [u*梳梳・A・燥、クション中
    if @active_battler.is_a?(Game_Actor) and
     @active_battler.current_action.move_action
      # ・燥I絡.・
      if @active_battler.moving == 2
        update_phase4_step3_sdva
      end
    elsif @active_battler.moving == 0
      update_phase4_step3_sdva
    end
  end
  #--------------------------------------------------------------------------
  #  ・フレ [ム X V (・インフェ [ズ ステップ 6 : リフレッシュ)
  #--------------------------------------------------------------------------
  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
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  #  ・オブジェクト 炎奣鹿
  #--------------------------------------------------------------------------
  alias initialize_sdva initialize
  def initialize
    initialize_sdva
    @viewport2.z = 1
  end
end

#==============================================================================
#  ・Arrow_Actor
#==============================================================================

class Arrow_Actor < Arrow_Base
  #--------------------------------------------------------------------------
  #  ・フレ [ム X V
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    update_sdva
    # カ [ソル燕
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      @index += 1
      @index %= $game_party.actors.size
    end
    # カ [ソル 箝
    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
#==============================================================================

class Arrow_Enemy < Arrow_Base
  #--------------------------------------------------------------------------
  #  ・フレ [ム X V
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    update_sdva
    # カ [ソル燕
    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 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

Informações adicionais

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!