MINTO Active LV UP 1.2

31 de outubro de 2013

MINTO Active LV UP é um script que implementa um sistema de apresentação animada de upagem de level em um game ou projeto desenvolvido no RPG Maker XP.

Foi desenvolvido por Minto, e para instalar, você precisa de adicionar as figuras na pasta Pictures (baixe o pacote com as figuras aqui) e adicionar o script abaixo acima do Main:

#################################################
#        MINTO Active LV UP  ver 1.2            #
#################################################
#   by ???                                     #
#   by Minto                                    #
#################################################
=begin  (Tradução(PT) e Tutorial By Moghunter) 

 CARACTERÍSTICAS
 - Sistema de apresentação animada de LV UP.

 UTILIZAÇÃO
  É necessário ter os arquivos imagens.
 - Blue_Edge.png
 - gaug_longe.png
 - line_exp.png
 - lvup.png
 - String01.png
  Os arquivos devem ficar na pasta,
  Graphics/Pictures.

=end
module MINTO
  RGSS["Active_Lv_Up"] = true 
end
module MINTO
  #Definição da face do personagem.
  # Face_Name[A] = B
  # A = ID do personagem.
  # B = nome do arquivo imagem da face.
  #Exp
  #------------------------------
  #Face_Name[1] = "Arshes.png"
  #------------------------------
  Face_Name = []
  Face_Name[1] = nil
  Face_Name[2] = nil
  Face_Name[3] = nil
  Face_Name[4] = nil
  #Velocidade da animação.
  LVUP_Frame = 200
  #Definição do Som.
  LVUP_SE = ["056-Right02", 80, 150] 
end
if MINTO::RGSS["Active_Lv_Up"]
class Picture_Number_Sprite
  attr_accessor :string_pop_duration     
  def initialize(x, y, index, text = "")
    @number = RPG::Cache.picture("String01")
    @string = RPG::Cache.picture("lvup")
    @x = x
    @y = y
    @index = index
    @string_pop_sprite = []
    @string_pop_duration = []
    @width = @number.rect.width / 10.0
    @sprite = []
    for i in 0..@index
      @sprite[i] = Sprite.new
      @sprite[i].x = x.abs + (i * @width)
      @sprite[i].y = y.abs
      @sprite[i].z = 999
    end
    @picture_number = []
    rect = Rect.new(0, 0, @width, @number.rect.height)
    for i in 0..9
      rect.x = i * @width
      bitmap = Bitmap.new(@width, @number.rect.height)
      bitmap.blt(0, 0, @number, rect)
      @picture_number[i] = bitmap
    end
  end
  def clear
    for i in 0..@index
      @sprite[i].bitmap = nil
    end   
  end
  def set_text(number)
    text = number.to_s.split(//)
    clear_index = text.size == 1 ? 1 : 0
    x_size = @index - text.size
    for i in 0..@index
      if clear_index == 0 && text[i].to_i == 0 ||
        text[i] == nil
        @sprite[i].bitmap = nil
        next
      end
      @sprite[i].x = @x.abs + (i * @width) + (x_size * @width)
      clear_index += 1
      @sprite[i].bitmap = @picture_number[text[i].to_i]
    end
  end
  def string_pop
    @string_pop_sprite.compact!
    @string_pop_duration.compact!
    dispose_string_pop
    string_pop_sprite = Sprite.new
    string_pop_sprite.bitmap = Bitmap.new(@string.rect.width,
    @string.rect.height)
    string_pop_sprite.bitmap.blt(0, 0, @string, @string.rect)
    string_pop_sprite.x = @x.abs + 64
    string_pop_sprite.y = @y.abs
    string_pop_sprite.z = 999
    @string_pop_sprite.unshift(string_pop_sprite)
    @string_pop_duration.unshift(40)     
  end
  def dispose_string_pop(i = nil)
    return if !i
    if i == -1
      for id in 0...@string_pop_sprite.size
        if id >= 0 && @string_pop_sprite[id]
          @string_pop_sprite[id].bitmap.dispose
          @string_pop_sprite[id].dispose
          @string_pop_sprite[id] = nil
          @string_pop_duration[id] = nil
        end
      end
    else
      if i >= 0 && @string_pop_sprite[i]
        @string_pop_sprite[i].bitmap.dispose
        @string_pop_sprite[i].dispose
        @string_pop_sprite[i] = nil
        @string_pop_duration[i] = nil
      end
    end
  end
  def update
    if @string_pop_sprite.size > 0
      for i in 0...@string_pop_sprite.size
        string = @string_pop_sprite[i]
        string.update
        if @string_pop_duration[i] == 0
          dispose_string_pop(i)
          next
        end
        @string_pop_duration[i] -= 1
        case @string_pop_duration[i]
        when 36..39
          string.y -= 4
        when 33..37
          string.y -= 2
        when 32..34
          string.y += 2
        when 25..32
          string.y += 4
        end
        string.opacity = 256 - (12 - @string_pop_duration[i]) * 32
      end
      @string_pop_sprite.compact!
      @string_pop_duration.compact!
    end
  end
  def dispose
    for s in @sprite
      s.dispose     
      s = nil
    end
    dispose_string_pop(-1)
  end 
end
class Window_BattleResult < Window_Base
  def initialize(exp, gold, treasures, ap = 0)
    super(0, 0, 640, 480)
    @exp = exp
    @gold = gold
    @treasures = treasures
    @ap = ap
    @text = []
    @lv = []
    @gauge = RPG::Cache.picture("line_exp")
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 224
    self.z = 500
    self.visible = false
  end
  def draw_item_name(item, x, y)
    if item == nil
      return
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = Color.new(5, 5, 5)
    self.contents.draw_text(x + 28-1, y-1, 212, 32, item.name)
    self.contents.draw_text(x + 28-1, y+1, 212, 32, item.name)
    self.contents.draw_text(x + 28+1, y+1, 212, 32, item.name)
    self.contents.draw_text(x + 28+1, y-1, 212, 32, item.name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name)
  end
  def set_picture
    edge = RPG::Cache.picture("Blue_Edge")
    gauge_b = RPG::Cache.picture("gaug_longe")
    face = []
    self.contents.font.name = ["Georgia", "MS UI Gothic"]
    self.contents.font.italic = true
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if MINTO::Face_Name[actor.id]
        face[i] = RPG::Cache.picture(MINTO::Face_Name[actor.id])
      else
        battler_name = actor.battler_name
        battler_hue = actor.battler_hue
        face[i] = RPG::Cache.battler(battler_name, battler_hue)
      end
      self.contents.blt(0, i * 112, edge, edge.rect)
      self.contents.blt(32, 90 + (i * 112), gauge_b, gauge_b.rect)
      if face[i].width > face[i].height
        bw = 96.0 / (face[i].width * 1.0)
        ow = face[i].width * bw
        bh = face[i].height * bw
      else
        oh = 96.0 / (face[i].height * 1.0)
        bh = face[i].height * oh
        ow = face[i].width * oh
      end
      dest_rect = Rect.new(172, 6 + (i * 112), ow, bh)
      self.contents.stretch_blt(dest_rect, face[i], face[i].rect)
      self.contents.font.color = Color.new(5, 5, 5)
      if i == 0
        if @ap >= 1
          plus = 0
        else
          plus = 16
        end
        gold = Data_System.data.words.gold
        self.contents.draw_text(288-1, 1-1, 320, 32, "Adquiriu", 1)
        self.contents.draw_text(288+1, 1+1, 320, 32, "Adquiriu", 1)
        self.contents.draw_text(288+1, 1-1, 320, 32, "Adquiriu", 1)
        self.contents.draw_text(288-1, 1+1, 320, 32, "Adquiriu", 1)
        self.contents.draw_text(0-1, plus + 32-1, 592, 32, "EXP", 2)
        self.contents.draw_text(0+1, plus + 32+1, 592, 32, "EXP", 2)
        self.contents.draw_text(0-1, plus + 32+1, 592, 32, "EXP", 2)
        self.contents.draw_text(0+1, plus + 32-1, 592, 32, "EXP", 2)
        if @ap >= 1
          self.contents.draw_text(0-1, 64-1, 592, 32, "AP", 2)
          self.contents.draw_text(0+1, 64+1, 592, 32, "AP", 2)
          self.contents.draw_text(0-1, 64+1, 592, 32, "AP", 2)
          self.contents.draw_text(0+1, 64-1, 592, 32, "AP", 2)
        end
        self.contents.draw_text(288-1, 97-1, 320, 32, "Gold", 1)
        self.contents.draw_text(288+1, 97+1, 320, 32, "Gold", 1)
        self.contents.draw_text(288+1, 97-1, 320, 32, "Gold", 1)
        self.contents.draw_text(288-1, 97+1, 320, 32, "Gold", 1)
        self.contents.draw_text(0-1, 146-1, 592, 32, gold, 2)
        self.contents.draw_text(0+1, 146+1, 592, 32, gold, 2)
        self.contents.draw_text(0-1, 146+1, 592, 32, gold, 2)
        self.contents.draw_text(0+1, 146-1, 592, 32, gold, 2)
        x = 416
        y = 16
        @text[0] = Picture_Number_Sprite.new(x, y + plus + 32, 7)
        @text[0].set_text(@exp)
        @text[1] = Picture_Number_Sprite.new(x, y + 146, 7)
        @text[1].set_text(@gold)
        if @ap >= 1
          @text[2] = Picture_Number_Sprite.new(x, y + 64, 7)
          @text[2].set_text(@ap)
        end
        if @treasures != []
          i_y = 240
          self.contents.draw_text(288-1, 193-1, 320, 32, "Item", 1)
          self.contents.draw_text(288+1, 193+1, 320, 32, "Item", 1)
          self.contents.draw_text(288+1, 193-1, 320, 32, "Item", 1)
          self.contents.draw_text(288-1, 193+1, 320, 32, "Item", 1)
          for item in @treasures
            draw_item_name(item, 384, i_y)
            i_y += 32
          end
        end
      end
      self.contents.font.color = Color.new(5, 5, 5)
      self.contents.draw_text(48-1, 48 - (i * 112-1), 128, 32, "Next")
      self.contents.draw_text(48+1, 48 + (i * 112+1), 128, 32, "Next")
      self.contents.draw_text(48+1, 48 + (i * 112-1), 128, 32, "Next")
      self.contents.draw_text(48-1, 48 + (i * 112+1), 128, 32, "Next")
      self.contents.draw_text(48-1, 24 - (i * 112-1), 128, 32, "Lv")
      self.contents.draw_text(48+1, 24 + (i * 112+1), 128, 32, "Lv")
      self.contents.draw_text(48+1, 24 + (i * 112-1), 128, 32, "Lv")
      self.contents.draw_text(48-1, 24 + (i * 112+1), 128, 32, "Lv")
      self.contents.draw_text(48-1, i * 112-1, 128, 32, actor.name)
      self.contents.draw_text(48+1, i * 112+1, 128, 32, actor.name)
      self.contents.draw_text(48-1, i * 112+1, 128, 32, actor.name)
      self.contents.draw_text(48+1, i * 112-1, 128, 32, actor.name)
      self.contents.font.color = normal_color
      self.contents.draw_text(48, i * 112, 128, 32, actor.name)
      self.contents.font.color = system_color
      self.contents.draw_text(48, 48 + (i * 112), 128, 32, "Next")
      self.contents.draw_text(48, 24 + (i * 112), 128, 32, "Lv")
      if @treasures != []
        self.contents.draw_text(288, 193, 320, 32, "Tesouro", 1)
      end
      if i == 0
        self.contents.draw_text(288, 1, 320, 32, "Adquiriu", 1)
        self.contents.draw_text(0, plus + 32, 592, 32, "EXP", 2)
        if @ap >= 1
          self.contents.draw_text(0, 64, 592, 32, "AP", 2)
        end
        self.contents.draw_text(288, 97, 320, 32, "Gold", 1)
        self.contents.draw_text(0, 146, 592, 32, gold, 2)
      end
    end
  end
  def dispose
    for s in @text
      s.dispose
    end
    super
  end
  def refresh
  end
end
class Window_Active_Exp < Window_Base
  def initialize(exp)
    super(0, 0, 640, 480)
    @exp = exp
    @text = []
    @lv = []
    @gauge = RPG::Cache.picture("line_exp")
    @skip = false
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.z = 600
    self.visible = false
  end
  def refresh_exp
    self.visible = true
    thyme = @exp < MINTO::LVUP_Frame ? @exp.abs : MINTO::LVUP_Frame
    rate_p = @exp < MINTO::LVUP_Frame ? @exp.abs : MINTO::LVUP_Frame
    exp = []
    last_lv = []
    last_exp = []
    line = RPG::Cache.picture("line_exp")
    for i in 0...$game_party.actors.size
      x = self.x + 64
      y = self.y + 90 + (i * 112)
      @lv[i] = Picture_Number_Sprite.new(x + 64, 44 + (i * 112), 3)
      @text[i] = Picture_Number_Sprite.new(x, y, 7, "LvUp")
      @text[i].clear
      @lv[i].clear
      last_lv[i] = $scene.last_level[i].abs
      last_exp[i] = $scene.last_exp[i].abs
      if @exp > MINTO::LVUP_Frame
        last_exp[i] += @exp % MINTO::LVUP_Frame
      end
    end
    while thyme >= 1
      if Input.trigger?(Input::C)
        @skip = true
      end
      self.contents.clear
      for i in 0...$game_party.actors.size
        actor = $game_party.actors[i]
        x = self.x + 64
        y = self.y + 90 + (i * 112)
        if !actor.dead? && actor.exist?
          last_exp[i] += (@exp / rate_p)
        end
        next_p = actor.next_rest_exp2(last_lv[i], last_exp[i])
        if next_p.is_a?(Numeric)
          next_p = [next_p, 0].max
          if next_p == 0
            last_lv[i] += 1
            data = MINTO::LVUP_SE
            Audio.se_play("Audio/SE/#{data[0]}", data[1], data[2])
            d_actor = Data_Actors.data[actor.id]
            last_lv[i] = [last_lv[i], d_actor.final_level].min
            @lv[i].string_pop
          end
        end
        n = actor.next_rest_exp2(last_lv[i], last_exp[i])
        rate = [[actor.next_exp(last_lv[i], last_exp[i]), 0].max, 100].min
        gw = (128 * rate) / 100
        dest_rect = Rect.new(32, 90 + (i * 112), gw, 8)
        self.contents.stretch_blt(dest_rect, @gauge, @gauge.rect)
        @text[i].set_text([n, 0].max)
        @lv[i].set_text(last_lv[i])
        @lv[i].update
      end
      thyme -= 1
      if @skip == false
        Graphics.update
        Input.update
      end     
    end
    thyme = 0
    for i in 0...$game_party.actors.size
      count = @lv[i].string_pop_duration[0].to_i
      if count > thyme
        thyme = count.abs
      end
    end
    while thyme >= 1
      for i in 0...$game_party.actors.size
        @lv[i].update
      end
      thyme -= 1
      Graphics.update
    end
  end
  def dispose
    for s in @text + @lv
      s.dispose
    end
    super
  end
end
class Game_Actor < Game_Battler
  def exp_list
    return @exp_list
  end
  def next_exp(lv, exp)
    if lv >= 99
      lv = 99
    end
    exp_rate = @exp_list[lv+1] - @exp_list[lv]
    next_exp = @exp_list[lv+1] - exp
    rate = (next_exp * 100) / exp_rate
    if @exp_list[lv+1] == 0
      rate = 100
    end
    return 100 - rate
  end
  def next_rest_exp2(lv, exp)
    if lv >= 99
      lv = 99
    end
    return @exp_list[lv+1] > 0 ? (@exp_list[lv+1] - exp) : 0
  end
end
class Scene_Battle
  attr_reader   :last_exp               
  attr_reader   :last_level             
  alias main_Active_Lv_Up main
  def main
    main_Active_Lv_Up
    @active_gauge_window.dispose if @active_gauge_window != nil
  end
end
class Scene_Battle
  alias start_phase5_Active_Lv_Up start_phase5
  def start_phase5
    @last_exp = []
    @last_level = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      @last_exp[i] = actor.exp.abs
      @last_level[i] = actor.level.abs     
    end
    exp = 0
    for enemy in $game_troop.enemies
      unless enemy.hidden
        exp += enemy.exp
      end
    end
    @active_gauge_window = Window_Active_Exp.new(exp)
    start_phase5_Active_Lv_Up
  end 
  def update_phase5
    if @phase5_wait_count > 0
      @phase5_wait_count -= 1
      if @phase5_wait_count == 0
        @result_window.visible = true
        @result_window.set_picture
        @active_gauge_window.refresh_exp
        $game_temp.battle_main_phase = false
        @status_window.refresh
      end
      return
    end
    if Input.trigger?(Input::C)
      battle_end(0)
    end
  end
end
end

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. Clique aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!