질문과 답변

Extra Form

#==============================================================================
# +++ MOG - Advanced Battle Hud (v2.2) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Sistema de hud avançado de batalha.
#==============================================================================

#==============================================================================
# ● Histórico (Version History)
#==============================================================================
# v 2.2 - Correção na prioridade da face.
# v 2.1 - Corrigido o Bug de não apresentar a animação de reviver.
# v 2.0 - Sprite de Face independente do sprite do battler, agora é possível
#         usar sprites do battlers sem apagar a imagem da face.
#       - Script do cursor independente do script da Hud.
# v 1.6 - Corrigido o erro quando o MP ou TP maximo é iguál a zero.
# v 1.5 - Corrigido a animação da face quando uma skill tem a função charge.
# v 1.4 - Corrigido o erro de crash randômico. (relativo a dispose de imagem.)
# v 1.3 - Script 100% independente do sistema de AT System.
#       - Correção da posição inicial da janela de Fuga.
#       - Correção da posição do cursor nos aliados quando a face está
#         desabilitada.
# v 1.2 - Corrigido a prioridade das condições.
# v 1.1 - Corrigido o glitch inicial da prioridade da face.
# v 1.0 - Primeiro lançamento.
#==============================================================================

#==============================================================================
# ■ - FACE ANIMADAS DOS PERSONAGENS - (Opcional)
#==============================================================================
# 1 - Grave as imagens das faces dos personagens na pasta.
#
# GRAPHICS/BATTLERS/
#
# 2 - Nomeie a imagem com o mesmo nome do personagem. (EG - Hertor.png)
# 3 - A largura da imagem deverá ser dividido por 5. (A escolha do tamanho
#     da face é livre desde que a lagura dividido pela altura seja igual a 5 )
#
#==============================================================================

#==============================================================================
# ■ BATTLE HUD SETTING
#==============================================================================
module MOG_BATTLE_HUD
  # Ativar Battlers dos personagens em faces, deixe desativado em caso de haver
  # outros scripts que usam battlers dos personagens em seu projeto.
  BATTLER_FACE_ENABLE = false
  #Definição geral da posição da HUD.
  HUD_POSITION = [107,326]
  #Definição da posição da face
  FACE_POSITION = [-50,85]
  #Definição da posição do numero de HP.
  HP_NUMBER_POSITION = [85,28]
  #Definição da posição do medidor de HP.
  HP_METER_POSITION = [27,37]
  #Definição da posição do numero de MP.
  MP_NUMBER_POSITION = [101,46]
  #Definição da posição do medidor de MP.
  MP_METER_POSITION = [43,55] 
  #Definição da posição do numero de TP.
  TP_NUMBER_POSITION = [85,64]
  #Definição da posição do medidor de TP.
  TP_METER_POSITION = [27,73]  
  #Definição da posição das condições
  STATES_POSITION = [5,1]
  #Definição da posição do comando de batalha.
  COMMAND_POSITION = [-100,-145] 
  #Definição da posição do espaço da HUD entre os membros do grupo.
  MEMBERS_SPACE = [212,0]
  #Definição da prioridade da HUD.
  BATTLE_HUD_Z = 0
  #Definição da velocidade de animação dos medidores.
  METER_FLOW_SPEED = 2
  #Ativa o layout mais limpo nas janelas de item e skill.
  ITEM_SKILL_WINDOWS_CLEAN_STYLE = true
  #Definição da opacidade das janelas.
  ITEM_SKILL_WINDOW_OPACITY = 0
end

 

#==============================================================================
# ■ Battle_Hud
#==============================================================================
class Battle_Hud
  include MOG_BATTLE_HUD
 
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------   
  def initialize(actor)
      dispose
      @actor = actor
      @x = HUD_POSITION[0] + (MEMBERS_SPACE[0] * @actor.index)
      @y = HUD_POSITION[1] + (MEMBERS_SPACE[1] * @actor.index)
      pre_cache
      create_layout
      create_hp_number
      create_hp_meter
      create_mp_number
      create_mp_meter
      create_tp_number
      create_tp_meter
      create_states
  end
 
  #--------------------------------------------------------------------------
  # ● Pre Cache
  #--------------------------------------------------------------------------     
  def pre_cache
      @number = Cache.system("Battle_Hud_Number")
      @number_cw = @number.width / 10
      @number_ch = @number.height / 4
      @meter = Cache.system("Battle_Hud_Meter")
      @meter_cw = @meter.width / 3
      @meter_ch = @meter.height / 3
      @icon = Cache.system("Iconset")
  end
 
  #--------------------------------------------------------------------------
  # ● Create Layout
  #--------------------------------------------------------------------------     
  def create_layout
      @layout = Sprite.new
      @layout.bitmap = Cache.system("Battle_Hud_Layout")
      @layout.z = BATTLE_HUD_Z
      @layout.x = @x
      @layout.y = @y
  end
 
  #--------------------------------------------------------------------------
  # ● Create HP Number
  #--------------------------------------------------------------------------       
  def create_hp_number
      @hp = @actor.hp
      @hp_old = @actor.hp
      @hp_ref = @hp_old
      @hp_refresh = false
      @hp_number = Sprite.new
      @hp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
      @hp_number.z = BATTLE_HUD_Z + 2
      @hp_number.x = @x + HP_NUMBER_POSITION[0]
      @hp_number.y = @y + HP_NUMBER_POSITION[1]
      refresh_hp_number
  end
 
  #--------------------------------------------------------------------------
  # ● Create HP Meter
  #--------------------------------------------------------------------------     
  def create_hp_meter
      @hp_meter = Sprite.new
      @hp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
      @hp_meter.z =  BATTLE_HUD_Z + 1
      @hp_meter.x = @x + HP_METER_POSITION[0]
      @hp_meter.y = @y + HP_METER_POSITION[1]
      @hp_flow = rand(@meter_cw * 2)
      @hp_width_old = @meter_cw * @actor.hp / @actor.mhp
      hp_flow_update
  end 
 
  #--------------------------------------------------------------------------
  # ● Hp Flow Update
  #--------------------------------------------------------------------------
  def hp_flow_update
      @hp_meter.bitmap.clear
      hp_width = @meter_cw * @actor.hp / @actor.mhp
      hp_src_rect = Rect.new(@hp_flow, 0,hp_width, @meter_ch)
      @hp_meter.bitmap.blt(0,0, @meter, hp_src_rect)
      @hp_flow += METER_FLOW_SPEED
      @hp_flow = 0 if @hp_flow >=  @meter_cw * 2     
  end
   
  #--------------------------------------------------------------------------
  # ● Execute Damage Flow
  #--------------------------------------------------------------------------
  def execute_damage_flow(hp_width)
     n = (@hp_width_old - hp_width).abs * 3 / 100
     damage_flow = [[n, 2].min,0.5].max
     @hp_width_old -= damage_flow        
     @hp_width_old = hp_width if @hp_width_old < hp_width
     src_rect_old = Rect.new(@hp_flow, @meter_ch * 3,@hp_width_old, @meter_ch)
     @hp_meter.bitmap.blt(0,0, @meter, src_rect_old)      
  end 
 
  #--------------------------------------------------------------------------
  # ● Update HP Number
  #--------------------------------------------------------------------------     
  def update_hp_number
      @hp_refresh = true
      n =  2 * (@actor.hp - @hp_old).abs / 100
      hp_ref = [[n, 100].min,1].max
      if @hp_old < @actor.hp
          @hp += hp_ref    
          if @hp >= @actor.hp
             @hp_old = @actor.hp
             @hp = @actor.hp  
             @hp_ref = 0
          end             
        elsif @hp_old > @actor.hp  
           @hp -= hp_ref               
           if @hp <= @actor.hp
              @hp_old = @actor.hp
              @hp = @actor.hp  
              @hp_ref = 0
           end           
        end     
   
  end 
 
  #--------------------------------------------------------------------------
  # ● Refresh HP Number
  #--------------------------------------------------------------------------     
  def refresh_hp_number
      @hp_number.bitmap.clear
      number_value = @hp.abs.to_s.split(//)
      hp_color = @hp < @actor.mhp * 30 / 100 ? @number_ch : 0
      center_x = 0
      for r in 0..number_value.size - 1        
         number_value_abs = number_value[r].to_i
         src_rect = Rect.new(@number_cw * number_value_abs, hp_color, @number_cw, @number_ch)
         @hp_number.bitmap.blt((@number_cw + 1) *  r, 0, @number, src_rect)
         center_x += 1
      end
      @hp_number.x = @x + HP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
      @hp_refresh = false if @hp == @actor.hp     
  end 
 
  #--------------------------------------------------------------------------
  # ● Create MP Number
  #--------------------------------------------------------------------------       
  def create_mp_number
      @mp = @actor.mp
      @mp_old = @actor.mp
      @mp_ref = @mp_old
      @mp_refresh = false
      @mp_number = Sprite.new
      @mp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
      @mp_number.z = BATTLE_HUD_Z + 2
      @mp_number.x = @x + MP_NUMBER_POSITION[0]
      @mp_number.y = @y + MP_NUMBER_POSITION[1]
      refresh_mp_number
  end
 
  #--------------------------------------------------------------------------
  # ● Create MP Meter
  #--------------------------------------------------------------------------     
  def create_mp_meter
      @mp_meter = Sprite.new
      @mp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
      @mp_meter.z =  BATTLE_HUD_Z + 1
      @mp_meter.x = @x + MP_METER_POSITION[0]
      @mp_meter.y = @y + MP_METER_POSITION[1]
      @mp_flow = rand(@meter_cw * 2)
      @mp_width_old = @meter_cw * @actor.mp / @actor.mmp rescue 0
      mp_flow_update
  end 
 
  #--------------------------------------------------------------------------
  # ● Mp Flow Update
  #--------------------------------------------------------------------------
  def mp_flow_update
      return if @actor.mmp == 0
      @mp_meter.bitmap.clear
      mp_width = @meter_cw * @actor.mp / @actor.mmp rescue 0
      src_rect = Rect.new(@mp_flow, @meter_ch,mp_width, @meter_ch)
      @mp_meter.bitmap.blt(0,0, @meter, src_rect)
      @mp_flow += METER_FLOW_SPEED
      @mp_flow = 0 if @mp_flow >=  @meter_cw * 2     
    end
   
  #--------------------------------------------------------------------------
  # ● Update MP Number
  #--------------------------------------------------------------------------     
  def update_mp_number
      @mp_refresh = true
      n =  2 * (@actor.mp - @mp_old).abs / 100
      mp_ref = [[n, 100].min,1].max
      if @mp_old < @actor.mp
          @mp += mp_ref    
          if @mp >= @actor.mp
             @mp_old = @actor.mp
             @mp = @actor.mp  
             @mp_ref = 0
          end             
        elsif @mp_old > @actor.mp  
           @mp -= mp_ref               
           if @mp <= @actor.mp
              @mp_old = @actor.mp
              @mp = @actor.mp  
              @mp_ref = 0
           end           
        end         
  end 
 
  #--------------------------------------------------------------------------
  # ● Refresh MP Number
  #--------------------------------------------------------------------------     
  def refresh_mp_number
      @mp_number.bitmap.clear
      number_value = @mp.abs.to_s.split(//)
      center_x = 0
      for r in 0..number_value.size - 1        
         number_value_abs = number_value[r].to_i
         src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 2, @number_cw, @number_ch)
         @mp_number.bitmap.blt((@number_cw + 1) *  r, 0, @number, src_rect)
         center_x += 1
      end
      @mp_number.x = @x + MP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
      @mp_refresh = false if @mp == @actor.mp     
  end 
 
  #--------------------------------------------------------------------------
  # ● Create TP Number
  #--------------------------------------------------------------------------       
  def create_tp_number
      @tp = @actor.tp
      @tp_old = @actor.tp
      @tp_ref = @tp_old
      @tp_refresh = false
      @tp_number = Sprite.new
      @tp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
      @tp_number.z = BATTLE_HUD_Z + 2
      @tp_number.x = @x + TP_NUMBER_POSITION[0]
      @tp_number.y = @y + TP_NUMBER_POSITION[1]
      refresh_tp_number
  end
 
  #--------------------------------------------------------------------------
  # ● Create TP Meter
  #--------------------------------------------------------------------------     
  def create_tp_meter
      @tp_meter = Sprite.new
      @tp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
      @tp_meter.z =  BATTLE_HUD_Z + 1
      @tp_meter.x = @x + TP_METER_POSITION[0]
      @tp_meter.y = @y + TP_METER_POSITION[1]
      @tp_flow = rand(@meter_cw * 2)
      @tp_width_old = @meter_cw * @actor.tp / @actor.max_tp rescue 0
      tp_flow_update
  end 
 
  #--------------------------------------------------------------------------
  # ● TP Flow Update
  #--------------------------------------------------------------------------
  def tp_flow_update
      return if @actor.max_tp == 0
      @tp_meter.bitmap.clear
      tp_width = @meter_cw * @actor.tp / @actor.max_tp rescue 0
      src_rect = Rect.new(@tp_flow, @meter_ch * 2,tp_width, @meter_ch)
      @tp_meter.bitmap.blt(0,0, @meter, src_rect)
      @tp_flow += METER_FLOW_SPEED
      @tp_flow = 0 if @tp_flow >=  @meter_cw * 2     
  end
   
  #--------------------------------------------------------------------------
  # ● Update TP Number
  #--------------------------------------------------------------------------     
  def update_tp_number
      @tp_refresh = true
      n =  2 * (@actor.tp - @tp_old).abs / 100
      tp_ref = [[n, 100].min,1].max
      if @tp_old < @actor.tp
          @tp += tp_ref    
          if @tp >= @actor.tp
             @tp_old = @actor.tp
             @tp = @actor.tp  
             @tp_ref = 0
          end             
        elsif @tp_old > @actor.tp  
           @tp -= tp_ref               
           if @tp <= @actor.tp
              @tp_old = @actor.tp
              @tp = @actor.tp  
              @tp_ref = 0
           end          
         end           
  end     
   
  #--------------------------------------------------------------------------
  # ● Refresh TP Number
  #--------------------------------------------------------------------------     
  def refresh_tp_number
      @tp_number.bitmap.clear
      number_value = @tp.truncate.to_s.split(//)
      center_x = 0
      for r in 0..number_value.size - 1       
         number_value_abs = number_value[r].to_i
         src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 3, @number_cw, @number_ch)
         @tp_number.bitmap.blt((@number_cw + 1) *  r, 0, @number, src_rect)
         center_x += 1
      end
      @tp_number.x = @x + TP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
      @tp_refresh = false if @tp == @actor.tp
  end   
 
  #--------------------------------------------------------------------------
  # ● Create_States
  #--------------------------------------------------------------------------     
  def create_states
      refresh_states
      @status = Sprite.new
      @status.bitmap = Bitmap.new(24,24)
      @status.x = @x + STATES_POSITION[0]
      @status.y = @y + STATES_POSITION[1]     
      @status_flow = -24
      @states_speed = 50
      @status.z = BATTLE_HUD_Z + 2
      @old_states = @actor.states
      flow_states
  end 
 
  #--------------------------------------------------------------------------
  # ● Flow_Status
  #--------------------------------------------------------------------------         
  def flow_states
      return if @actor.states.size == 0 and !@status.visible
      @states_speed = 0
      @status.bitmap.clear
      src_rect = Rect.new(@status_flow,0, 24,24)
      @status.bitmap.blt(0,0, @actor_status, src_rect)
      @status.visible = @actor.states.size == 0 ? false : true
      @status_flow += 1
      @status_flow = -24 if @status_flow >= @states_size - 24
  end   
 
  #--------------------------------------------------------------------------
  # ● Refresh States
  #--------------------------------------------------------------------------       
  def refresh_states
      refresh_icon if @icon == nil or @icon.disposed?
      @old_states = @actor.states
      if @actor_status != nil
         @actor_status.dispose
         @actor_status = nil
      end
      @states_size = @actor.states.size > 0 ? (48 * @actor.states.size) : 24
      @actor_status = Bitmap.new(@states_size,24)
      index = 0
      for i in  @actor.states
         rect = Rect.new(i.icon_index % 16 * 24, i.icon_index / 16 * 24, 24, 24)
         @actor_status.blt(48 * index , 0, @icon, rect)
         index += 1
      end
  end 
 
  #--------------------------------------------------------------------------
  # ● Refresh Icon
  #--------------------------------------------------------------------------     
  def refresh_icon     
      if @icon != nil
         if !@icon.disposed?
             @icon.dispose
         end
         @icon = nil
      end 
      @icon = Cache.system("Iconset")
  end
 
  #--------------------------------------------------------------------------
  # ● Dispose
  #--------------------------------------------------------------------------   
  def dispose
      return if @meter == nil
      @meter.dispose
      @meter = nil
      @number.dispose
      if @icon != nil
         if !@icon.disposed?
             @icon.dispose
         end
         @icon = nil
      end    
      @layout.bitmap.dispose
      @layout.dispose
      @hp_number.bitmap.dispose
      @hp_number.dispose
      @hp_meter.bitmap.dispose
      @hp_meter.dispose
      @mp_number.bitmap.dispose
      @mp_number.dispose
      @mp_meter.bitmap.dispose
      @mp_meter.dispose     
      @tp_number.bitmap.dispose
      @tp_number.dispose
      @tp_meter.bitmap.dispose
      @tp_meter.dispose
      @status.bitmap.dispose
      @status.dispose
      if @actor_status != nil
         @actor_status.dispose
         @actor_status = nil
      end       
  end
 
  #--------------------------------------------------------------------------
  # ● Update
  #--------------------------------------------------------------------------   
  def update
      return if @meter == nil
      update_hp_number if @hp_old != @actor.hp
      refresh_hp_number if @hp_refresh
      update_mp_number if @mp_old != @actor.mp
      refresh_mp_number if @mp_refresh
      update_tp_number if @tp_old != @actor.tp
      refresh_tp_number if @tp_refresh
      refresh_states if @old_states != @actor.states
      hp_flow_update
      tp_flow_update
      mp_flow_update
      flow_states
  end
 
end

#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
 
  attr_accessor :battler_hud
 
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------   
  alias mog_adv_battle_hud_initialize initialize
  def initialize      
      @battler_hud = false
      mog_adv_battle_hud_initialize
  end 
 
end

#==============================================================================
# ■ Spriteset Battle
#==============================================================================
class Spriteset_Battle
 
  #--------------------------------------------------------------------------
  # ● Initialize
  #-------------------------------------------------------------------------- 
  alias mog_battle_hud_initialize initialize
  def initialize
      mog_battle_hud_initialize
      create_battle_hud     
  end
 
  #--------------------------------------------------------------------------
  # ● Create Battle Hud
  #--------------------------------------------------------------------------   
  def create_battle_hud
      dispose_battle_hud
      @battle_hud = []     
      for i in $game_party.members
          @battle_hud.push(Battle_Hud.new(i))
      end
  end
 
  #--------------------------------------------------------------------------
  # ● Dispose
  #--------------------------------------------------------------------------     
  alias mog_battle_hud_dispose dispose
  def dispose
      mog_battle_hud_dispose
      dispose_battle_hud
  end 
 
  #--------------------------------------------------------------------------
  # ● Dispose Battle Hud
  #--------------------------------------------------------------------------       
  def dispose_battle_hud
      return if @battle_hud == nil
      @battle_hud.each {|sprite| sprite.dispose }
      @battle_hud.clear
      @battle_hud = nil
  end
 
  #--------------------------------------------------------------------------
  # ● Update
  #--------------------------------------------------------------------------       
  alias mog_battle_hud_update update
  def update
      mog_battle_hud_update
      update_battle_hud
  end
 
  #--------------------------------------------------------------------------
  # ● Update Battle Hud
  #--------------------------------------------------------------------------         
  def update_battle_hud
      return if @battle_hud == nil
      @battle_hud.each {|sprite| sprite.update }
  end
   
end

#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  include MOG_BATTLE_HUD
  
   attr_accessor :hud_x
   attr_accessor :hud_y

  #--------------------------------------------------------------------------
  # ● HUD X
  #--------------------------------------------------------------------------    
  def hud_x
      return HUD_POSITION[0] + (MEMBERS_SPACE[0] * index)
  end
 
  #--------------------------------------------------------------------------
  # ● HUD Y
  #--------------------------------------------------------------------------   
  def hud_y
      return HUD_POSITION[1] + (MEMBERS_SPACE[1] * index)
  end
   
end 

#==============================================================================
# ■ Scene Battle
#==============================================================================
class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # ● Create Party Command Window
  #--------------------------------------------------------------------------   
  alias mog_battle_hud_create_party_command_window create_party_command_window
  def create_party_command_window
      mog_battle_hud_create_party_command_window
      set_party_window_position
  end 
 
  #--------------------------------------------------------------------------
  # ● Set Party Window Position
  #--------------------------------------------------------------------------     
  def set_party_window_position
      @party_command_window.viewport = nil 
      return if $mog_rgss3_at_system != nil
      a_index = []
      for actor in $game_party.alive_members
          a_index = [actor.hud_x, actor.hud_y]
          break
      end
      return if a_index.empty?
      @party_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + a_index[0]
      @party_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + a_index[1]     
  end 
 
  #--------------------------------------------------------------------------
  # ● Set Party Window Position
  #--------------------------------------------------------------------------       
  alias mog_battle_hud_start_party_command_selection start_party_command_selection
  def start_party_command_selection
      set_party_window_position
      mog_battle_hud_start_party_command_selection
  end 
 
  #--------------------------------------------------------------------------
  # ● Update
  #-------------------------------------------------------------------------- 
  alias mog_battle_hud_update_basic update_basic
  def update_basic
      mog_battle_hud_update_basic
      update_command_window_visible
  end 
 
  #--------------------------------------------------------------------------
  # ● Update Command Window Visible
  #--------------------------------------------------------------------------   
  def update_command_window_visible
      @status_window.visible = @status_window.active ? true : false
      @actor_command_window.visible = @actor_command_window.active ? true : false
      @skill_window.visible = @skill_window.active ? true : false
      @item_window.visible = @item_window.active ? true : false     
  end
 
  #--------------------------------------------------------------------------
  # ● Start Actor Command Selection
  #--------------------------------------------------------------------------   
  alias mog_battle_hud_start_actor_command_selection start_actor_command_selection
  def start_actor_command_selection
      mog_battle_hud_start_actor_command_selection
      @actor_command_window.viewport = nil
      @actor_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + $game_party.members[BattleManager.actor.index].hud_x
      @actor_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + $game_party.members[BattleManager.actor.index].hud_y
      @party_command_window.x = @actor_command_window.x
      @party_command_window.y = @actor_command_window.y 
  end 

end

#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  include MOG_BATTLE_HUD
 
  attr_accessor :battler_face
  attr_accessor :battler_face_name
  attr_accessor :screen_x
  attr_accessor :screen_y
  attr_accessor :screen_z
 
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  alias mog_battle_hud_initialize setup
  def setup(actor_id)
      mog_battle_hud_initialize(actor_id)
      battler_sprite_setup
  end 
   
  #--------------------------------------------------------------------------
  # ● Battler Sprite Setup
  #-------------------------------------------------------------------------- 
  def battler_sprite_setup
      @battler_face = [0,0,0]
      @battler_face_name = @name + "_Face"
  end

  if BATTLER_FACE_ENABLE
  #--------------------------------------------------------------------------
  # ● Use Sprite?
  #--------------------------------------------------------------------------
  def use_sprite?
      return true
  end
  end
 
end

#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
  include MOG_BATTLE_HUD
 
  #--------------------------------------------------------------------------
  # ● Dispose
  #--------------------------------------------------------------------------   
  alias mog_battler_face_dispose dispose
  def dispose
      mog_battler_face_dispose
      dispose_battler_face
  end 
 
  #--------------------------------------------------------------------------
  # ● Update
  #--------------------------------------------------------------------------  
  alias mog_battler_face_update update
  def update
      refresh_face_battler
      mog_battler_face_update
      update_battler_face
  end
   
  #--------------------------------------------------------------------------
  # ● Refresh Face Battler
  #--------------------------------------------------------------------------    
  def refresh_face_battler
      return if @face_sprite != nil
      return if @battler == nil
      return if @battler.is_a?(Game_Enemy)
      setup_battler_screen if @battler.screen_x == nil or $game_system.battler_hud
      @face_sprite = Battler_Face_Sprite.new(self.viewport, @battler)
  end 
 
  #--------------------------------------------------------------------------
  # ● Setup Battler Screen
  #--------------------------------------------------------------------------      
  def setup_battler_screen
      $game_system.battler_hud = true
      @battler.screen_x = FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * @battler.index)
      @battler.screen_y = FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * @battler.index)
      @battler.screen_z = 103 if @battler.screen_z == nil
  end 
 
  #--------------------------------------------------------------------------
  # ● Dispose Battler Face
  #--------------------------------------------------------------------------      
  def dispose_battler_face
      return if @face_sprite == nil
      @face_sprite.dispose 
  end
 
  #--------------------------------------------------------------------------
  # ● Update Battler Face
  #--------------------------------------------------------------------------      
  def update_battler_face
      return if @face_sprite == nil
      @face_sprite.update_actor_battler
  end 
 
  #--------------------------------------------------------------------------
  # ● Update Posiion
  #--------------------------------------------------------------------------        
  alias mog_battler_face_update_position update_position
  def update_position
      mog_battler_face_update_position
      update_face_z
  end 
 
  #--------------------------------------------------------------------------
  # ● Update Face Z
  #--------------------------------------------------------------------------        
  def update_face_z
      return if @face_sprite == nil
      @face_sprite.update_face_z(self.z)
  end

  #--------------------------------------------------------------------------
  # ● Update Collapse
  #--------------------------------------------------------------------------                         
   alias mog_battle_hud_update_collapse update_collapse
   def update_collapse
       if face_can_cancel_method?
         self.opacity = 255
         self.visible = true
         return
      end
       mog_battle_hud_update_collapse
   end 
  
  #--------------------------------------------------------------------------
  # ● Update Instant Collapse
  #--------------------------------------------------------------------------                            
   alias mog_battle_hud_update_instant_collapse update_instant_collapse
   def update_instant_collapse
      if face_can_cancel_method?
         self.opacity = 255
         self.visible = true
         return
      end
       mog_battle_hud_update_instant_collapse
   end 
 
  #--------------------------------------------------------------------------
  # ● Init Visibility
  #--------------------------------------------------------------------------                               
  alias mog_battle_face_init_visibility init_visibility
  def init_visibility
      if face_can_cancel_method?
         self.opacity = 255
         self.visible = true
         return
      end
      mog_battle_face_init_visibility
  end
  
  #--------------------------------------------------------------------------
  # ● Face Can Cancel Method
  #--------------------------------------------------------------------------                                 
  def face_can_cancel_method?
      return false if !BATTLER_FACE_ENABLE
      return false if @battler.is_a?(Game_Enemy)
      return false if !$game_system.battler_hud
      return true
  end 
 
end

#==============================================================================
# ■ Battler Face Sprite
#==============================================================================
class Battler_Face_Sprite < Sprite
  include MOG_BATTLE_HUD
 
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------               
   def initialize(viewport = nil,battler)
       super(viewport)
       @battler = battler
       @f_im = Cache.battler(@battler.battler_face_name, 0)
       @f_cw = @f_im.width / 5
       @f_ch = @f_im.height
       self.bitmap = Bitmap.new(@f_cw,@f_ch)
       x = -(@f_cw / 2) + FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * @battler.index)
       y = -@f_ch + FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * @battler.index)
       @org_pos = [x,y]
       @battler.battler_face = [0,0,0]
       @battler_visible = true
       @low_hp = @battler.mhp * 0 / 100
       @old_face_index = 0
       self.z = @battler.screen_z
       make_face(true)
   end
  
  #--------------------------------------------------------------------------
  # ● Dispose
  #--------------------------------------------------------------------------                      
  def dispose
      super
      dispose_battler_face_sprite
  end   

  #--------------------------------------------------------------------------
  # ● Dispose Battler Face Sprite
  #--------------------------------------------------------------------------                   
  def dispose_battler_face_sprite
       self.bitmap.dispose
       @f_im.dispose
  end 
  
  #--------------------------------------------------------------------------
  # ● Update
  #-------------------------------------------------------------------------- 
  def update_face_sprite(battler)
      @battler = battler
      update_face_reset_time
      update_face_effect
  end
  
  #--------------------------------------------------------------------------
  # ● Face Base Setting
  #--------------------------------------------------------------------------                
  def face_base_setting
      self.x = @org_pos[0]
      self.y = @org_pos[1]
      self.zoom_x = 1
      self.zoom_y = 1
      self.mirror = false  
  end
 
  #--------------------------------------------------------------------------
  # ● Check Base Face
  #--------------------------------------------------------------------------             
   def check_base_face(reset)
       face_base_setting
       return if @battler.battler_face[2] > 0
       @battler.battler_face = [0,0,0] if reset and @battler.battler_face[1] != 2 
       @battler.battler_face[0] = 3 if @battler.hp < @low_hp
       @battler.battler_face[0] = 4 if @battler.hp == 0
   end 
  
  #--------------------------------------------------------------------------
  # ● Make Face
  #--------------------------------------------------------------------------             
   def make_face(reset = true)
       self.bitmap.clear
       check_base_face(reset)
       src_rect_back = Rect.new(@f_cw * @battler.battler_face[0], 0, @f_cw, @f_ch)
       self.bitmap.blt(0,0, @f_im, src_rect_back)
       @old_face_index = @battler.battler_face[0]
   end 

  #--------------------------------------------------------------------------
  # ● Update Actor Battler
  #--------------------------------------------------------------------------          
   def update_actor_battler
       return if self.bitmap == nil
       update_face_effect
       update_face_reset_time
       make_face if @old_face_index != @battler.battler_face[0]             
   end
  
  #--------------------------------------------------------------------------
  # ● Update Face Z
  #--------------------------------------------------------------------------                
  def update_face_z(value)
      self.z = value + 2
  end 
  
  #--------------------------------------------------------------------------
  # ● Update Face Reset Time
  #--------------------------------------------------------------------------             
   def update_face_reset_time
       return if @battler.battler_face[2] == 0
       @battler.battler_face[2] -= 1
       if @battler.battler_face[2] == 0 or
         (@battler.hp < @low_hp and @battler.battler_face[0] == 0)
          make_face(true)
       end  
   end

  #--------------------------------------------------------------------------
  # ● Update Face Effect
  #--------------------------------------------------------------------------                
   def update_face_effect
       return if @battler.battler_face[2] == 0
       case @battler.battler_face[1]
          when 0
             face_damage
          when 1..2
             face_heal
          when 3
             face_action
       end
   end 
  
  #--------------------------------------------------------------------------
  # ● Face Damage
  #--------------------------------------------------------------------------                   
   def face_damage
       self.x = (@org_pos[0] - (@battler.battler_face[2] /2)) + rand(@battler.battler_face[2])
   end 
  
  #--------------------------------------------------------------------------
  # ● Face Heal
  #--------------------------------------------------------------------------                   
   def face_heal
       case  @battler.battler_face[2]
         when 20..40
             self.zoom_x += 0.00
             self.zoom_y = self.zoom_x
         when 0..20
             self.zoom_x -= 0.00
             self.zoom_y = self.zoom_x      
       end
   end    
  
  #--------------------------------------------------------------------------
  # ● Face Action
  #--------------------------------------------------------------------------                   
   def face_action
       case  @battler.battler_face[2]
         when 25..50
             self.zoom_x += 0.01
             self.zoom_y = self.zoom_x
             self.mirror = false
         when 0..25
             self.zoom_x -= 0.01
             self.zoom_y = self.zoom_x
             self.mirror = false
       end
       self.zoom_x = self.zoom_x > 1.0 ? self.zoom_x = 1.0 : self.zoom_x < 1 ? 1 : self.zoom_x
       self.zoom_y = self.zoom_y > 1.0 ? self.zoom_y = 1.0 : self.zoom_y < 1 ? 1 : self.zoom_y
   end
     
 end
 
 #==============================================================================
# ■ Battle Manager
#==============================================================================
class << BattleManager
 
  #--------------------------------------------------------------------------
  # ● Battle End
  #--------------------------------------------------------------------------                   
  alias mog_battle_hud_battle_process_victory process_victory
  def process_victory
      execute_face_effect   
      mog_battle_hud_battle_process_victory
  end
 
  #--------------------------------------------------------------------------
  # ● Prepare
  #--------------------------------------------------------------------------                 
  def execute_face_effect
      for i in $game_party.members
          if i.hp > 0
             i.battler_face = [1,2,40]        
          end 
      end 
  end
 
end

#==============================================================================
# ■ Game Action
#==============================================================================
class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # ● Show Animations
  #--------------------------------------------------------------------------    
  alias mog_battle_hud_show_animation show_animation
  def show_animation(targets, animation_id)
      make_face_action_battle
      mog_battle_hud_show_animation(targets, animation_id)
  end
 
  #--------------------------------------------------------------------------
  # ● Make Face Action
  #--------------------------------------------------------------------------                 
  def make_face_action_battle
      return if !@subject.is_a?(Game_Actor)
      @subject.battler_face = [2,3,50]
  end   
 
end 

#==============================================================================
# ■ Game Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
 
  #--------------------------------------------------------------------------
  # ● Item Apply
  #--------------------------------------------------------------------------               
  alias mog_battle_hud_item_apply item_apply
  def item_apply(user, item)
      old_hp = self.hp
      old_mp = self.mp
      mog_battle_hud_item_apply(user, item)
      check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
  end
 
  #--------------------------------------------------------------------------
  # ● Check Face Effect
  #-------------------------------------------------------------------------- 
  def check_face_effect(old_hp,old_mp)
      if self.hp > old_hp or self.mp > old_mp
         self.battler_face = [1,1,40]
      elsif self.hp < old_hp
         self.battler_face = [3,0,40]
      end 
  end 
 
  #--------------------------------------------------------------------------
  # ● Added New State
  #-------------------------------------------------------------------------- 
  alias mog_battle_hud_add_new_state add_new_state
  def add_new_state(state_id)
      mog_battle_hud_add_new_state(state_id)
      if self.is_a?(Game_Actor)
         self.battler_face = [1,1,40] if $data_states[state_id].note =~ /<Good State>/
         self.battler_face = [3,0,40] if $data_states[state_id].note =~ /<Bad State>/
      end  
  end   
 
  #--------------------------------------------------------------------------
  # ● Regenerate HP
  #--------------------------------------------------------------------------
  alias mog_battle_hud_regenerate_hp regenerate_hp
  def regenerate_hp
      old_hp = self.hp
      old_mp = self.mp   
      mog_battle_hud_regenerate_hp
      check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
  end

  #--------------------------------------------------------------------------
  # ● Regenerate MP
  #--------------------------------------------------------------------------
  alias mog_battle_hud_regenerate_mp regenerate_mp
  def regenerate_mp
      old_hp = self.hp
      old_mp = self.mp   
      mog_battle_hud_regenerate_mp
      check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
  end 

  #--------------------------------------------------------------------------
  # ● Can Check Face Effect
  #--------------------------------------------------------------------------                 
  def can_check_face_effect?(old_hp,old_mp)
      return false if self.is_a?(Game_Enemy)
      return true if old_hp != self.hp
      return true if old_mp != self.mp
      return false
  end
 
end

#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # ● Invoke Counter Attack
  #--------------------------------------------------------------------------       
  alias mog_battle_hud_invoke_counter_attack invoke_counter_attack
  def invoke_counter_attack(target, item)
      mog_battle_hud_invoke_counter_attack(target, item)
      if target.is_a?(Game_Actor) and target.battler_face[0] != 2       
         target.battler_face = [2,3,50]
      end 
  end 
 
  #--------------------------------------------------------------------------
  # ● Invoke Magic Reflection
  #--------------------------------------------------------------------------       
  alias mog_battle_hud_invoke_magic_reflection invoke_magic_reflection
  def invoke_magic_reflection(target, item)
      mog_battle_hud_invoke_magic_reflection(target, item)
      if target.is_a?(Game_Actor) and target.battler_face[0] != 2       
         target.battler_face = [2,3,50]
      end 
  end   
 
end

#==============================================================================
# ■ Scene Battle
#============================================================================== 
class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # ● select_enemy_selection
  #--------------------------------------------------------------------------
  alias mog_battle_cursor_select_enemy_selection select_enemy_selection
  def select_enemy_selection
      mog_battle_cursor_select_enemy_selection
      if $mog_rgss3_battle_cursor != nil
         @enemy_window.visible = false
         @info_viewport.rect.width = 0
      end  
  end
 
  #--------------------------------------------------------------------------
  # ● select_enemy_selection
  #--------------------------------------------------------------------------
  alias mog_battle_cursor_select_actor_selection select_actor_selection
  def select_actor_selection
      mog_battle_cursor_select_actor_selection
      if $mog_rgss3_battle_cursor != nil
         @actor_window.visible = false
         @info_viewport.rect.width = 0
      end  
  end
 
end 

$mog_rgss3_battle_hud = true

 

 

 

 

 

이 스크립트가 캐릭터 디폴트 이름을 기준으로 전투시 나오는 페이스칩이 정해지는데, 캐릭터 이름이 바뀌면 전투시 나올 페이스칩도 바뀌게 좀 만들어주세요. 상황에 따른 다채로운 전투장면을 연출하고싶은데, 스크립트 능력이 안되서 불가능하네요.

스크립트 능력자분들, 저 좀 도와주시면 정말 감사하겠습니다.

Comment '7'
  • ?
    일단 2013.07.21 04:24
    이 스크립트를 분석할 시간은 없는데, 대충 봤을 때,
    @battler_face_name = @name + "_Face"
    @f_im = Cache.battler(@battler.battler_face_name, 0)
    즉 "캐릭터 이름"+"_Face" 파일을 항상 로드하도록 되어있는 거 아닌가요?

    예컨대, '뮤' 캐릭터라면 '뮤_Face' 파일이 페이스칩으로 나오는데,
    '뮤' 캐릭터의 이름을 '뮤22'라고 바꾸면 '뮤22_Face' 파일이 페이스칩으로 나올 거 같은데..
    그리고 이 페이스칩 파일이 battler 폴더에 있어야하는 거 같네요.

    잘 모르지만 댓글 달아봅니다.
  • ?
    일단 2013.07.21 04:24
    사실 스크립트 분석할 능력이 없네요. ㅠ
  • ?
    구리더 2013.07.21 04:29

    저도 시도는 해봤습니다만, 게임 내에서 캐릭터 이름을 바꿔도 페이스는 그대로였습니다.

    아마 데이터베이스 내의 캐릭터이름을 기반으로 페이스칩이 나오는 것 같네요.

  • ?
    일단 2013.07.21 12:07
    혹시 전투 중에 이름을 바꾸신다는 건가요? 아니면 전투 시작 전에?

    만약 전투 시작 전에 이벤트 명령을 통해 이름을 바꿨는데 페이스칩이 바뀌지 않았고, 디폴트 값 때문이라고 생각되신다면, 이벤트 명령을 통해 이름을 바꿀 때 스크립트 명령도 하나 추가해주세요.

    $data_actors[XXX].name = "YYY"

    XXX를 지우고 이름을 바꾼 액터의 id 번호를 넣어주시고, YYY를 지우고 바뀌어진 캐릭터 이름을 넣어주시면 됩니다.

    11번 캐릭터 '철수'를 '영희'로 바꾼다면,
    $data_actors[11].name = "영희"라는 식으로 바꿔주시면 됩니다.
  • ?
    구리더 2013.07.21 15:54


    $data_actors[1].name = "테스트페이스"

    이렇게 전투전에 스크립트 명령을 확실히 넣고해도 그대로네요.

    으으 이거 스크립트 수정말고다는 다른 방법이 없을것같습니다.

  • profile
    하늘바라KSND 2013.07.21 13:29
    Kia! 원문이라늬
    본문에 넣으시면 아니되옵니다.

    텟스트 파일에 첨부해서 올리시던가 하여야 합니다.
  • ?
    아이미르 2013.07.25 08:33

    이름을 이벤트 명령어로 변경할때 전투원 얼굴 이름은 변경하지 않아서 생기는 문제 같습니다.

     

     

    #==============================================================================
    # ■ Game_Interpreter
    #------------------------------------------------------------------------------
    #  이벤트 커멘드를 실행하는 interpreter입니다.이 클래스는 Game_Map 클래스,
    # Game_Troop 클래스, Game_Event 클래스의 내부에서 사용됩니다.
    #==============================================================================

    class Game_Interpreter
      #--------------------------------------------------------------------------
      # ● 이름의 변경
      #--------------------------------------------------------------------------

      def command_320

        actor = $game_actors[@params[0]]
        if actor
          actor.name = @params[1]
          actor.battler_face_name = @params[1] + "_Face"
        end
      end
    end

     

    이 스크립트를 붙여넣어 전투원 얼굴 이름을 변경하면 될 거 같네요.

     

    VXAce 스크립트에 있는 MOG 스크립트에서는 제대로 작동했는데 약간 변수 이름이 다른 관계로

     

    실험은 못해봤습니다.


List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 13192
RMVXA 전투 화면 질문 1 file 건전한PC방 2013.07.21 605
RMVXA 그림(픽쳐) 우선순위 어떻게 바꾸나요? 접속스킬 2013.07.21 598
RMVXA MOG BATTLE HUD 캐릭터 이름바뀌면 전투용 페이스칩도 바뀌게좀 도와주세요 7 구리더 2013.07.21 531
RMVXA 공백이 이상하게 나와요 2 file 길현석 2013.07.21 652
RMXP 페렐님이 해주신 아오오니 강좌에 대해서 7 file 지혈이 2013.07.20 810
RMVX 그림표시제한 20개 푸는 스크립트가 어디있나요? 3 라네타 2013.07.20 549
RMVXA 폰트가 적용되질 않습니다. 7 file 뿌잉뿌잉쨔응 2013.07.20 1750
RMVX 무기를 장비 하지 않은 맨손 상태에서 속성,내성 부여가 가능한가요? 12 빡새 2013.07.20 570
RMVX 무기를 장비할 수 밖에 없게 하려면 어떻게 해야할까요? 13 file 빡새 2013.07.20 610
RMVXA 스크립트 내의 생성자 [initialize와 start]의 차이는? 3 일단 2013.07.19 822
RMVXA VXA 스킬 애니메이션 바꾸기. 로브남 2013.07.19 851
RMVX 발소리 스크립트에 관하여 2 지혈이 2013.07.19 793
RMVX 이름입력으로 주관식퀴즈를 낼때 질문입니다.. file 라네타 2013.07.19 788
RMXP ESC눌렀을때 나오는 메뉴창에 대해서.... 1 붉은갈색 2013.07.19 771
RMXP 8방향 이동 스크립트 삭제 후 오류 11 file 블리츠 2013.07.19 860
RMXP 열쇠 이펙트 질문 ! 9 file 파덕 2013.07.19 1038
RMVXA vx ace 기본스크립트 Window_Command의 분석 중 일부 질문.. 2 일단 2013.07.19 941
RMVXA MOG배틀 스크립트에 대해 질문 구리더 2013.07.18 608
RMVX 스타트시에 영상 만들기 3 dlstkd710 2013.07.18 868
RMVXA 전투중 상태메세지 표기가 너무 빨리 지나갑니다. 1 kind~!! 2013.07.18 822
Board Pagination Prev 1 ... 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 ... 517 Next
/ 517