[XP]-Sistema de BP-

Ir abajo

[XP]-Sistema de BP-

Mensaje por Night Shade el Sáb Ago 03, 2013 4:41 am

Este script añade un sistema BP que permite ser usado como costo en el uso de habilidades.
Caracteristicas:
El bp solo se recupera con el paso de los turnos y no con ningun objeto.

Aquí el script:

Código:
################################################################################
################################# CODE CRUSH ###################################
################################################################################
=begin
                                  BP SYSTEM                             

--------------------------------------------------------------------------------
Script criado pelo Claimh.
Created by Claimh.
Versão - 2.1.0
--------------------------------------------------------------------------------

CARACTERí?STICAS
 Adiciona o sistema restritivo BP.
 BP é um custo para acionar habilidades assim como o SP.
 O valor de BP não pode ser recuperado com itens ele é automaticamente
 recuperado a cada turno, sistema semelhante ao do Wild Arms.

CUSTOMIZAÇÃO
=end
#-------------------------------------------------------------------------------
module SysSkill_BP
  # Usar o custo SP.
  BATTLE_SP_USE = true   
  # Ativar a janela de BP.
  WINDOW_BP_USE = true 
  # Ativar o valor do BP por ícones.
  USE_BP_ICON = false   
  # Nome do arquivo BP.
  BP_ICON = "036-Item05"
  SKILL_BP = {
  # Definição do custo de BP para cada habilidade.
  #
  # A => B
  #----------------------------------
  # A = ID da habilidade.
  # B = Custo de BP.
  #----------------------------------
    1 => 2, 2 => 5, 3 =>7,
    4 => 2, 5 => 5,
    6 => 5,
    7 => 2, 8 => 4, 9 => 6,
    10 => 2, 11 => 4, 12 => 6,
    13 => 2, 14 => 4, 15 => 6,
    16 => 2, 17 => 4, 18 => 6,
    19 => 2, 20 => 4, 21 => 6,
    22 => 2, 23 => 4, 24 => 6,
    25 => 2, 26 => 4, 27 => 6,
    28 => 2, 29 => 4, 30 => 6,
    31 => 3, 32 => 7,
    33 => 1, 34 => 4,
    35 => 1, 36 => 4,
    37 => 1, 38 => 4,
    39 => 1, 40 => 4,
    41 => 1, 42 => 4,
    43 => 1, 44 => 4,
    45 => 1, 46 => 4,
    47 => 1, 48 => 4,
    49 => 1, 50 => 4,
    51 => 1, 52 => 4,
    53 => 3, 54 => 3, 55 => 3, 56 => 3,
    57 => 2, 58 => 4, 59 => 6, 60 => 9,
    61 => 2, 62 => 4, 63 => 6, 64 => 9,
    65 => 2, 66 => 4, 67 => 6, 68 => 9,
    69 => 2, 70 => 4, 71 => 6, 72 => 9,
    73 => 2, 74 => 4, 75 => 6, 76 => 9,
    77 => 2, 78 => 4, 79 => 6, 80 => 9
  }
  # Definição dos parí¢metros iniciais de BP para cada personagem.
    ACT_BP = {
  #------------------------------------------------------
  # A => [B, C, D]
  #------------------------------------------------------
  # A = ID do personagem.
  # B = Valor de BP inicial do personagem.
  # C = Valor de BP maximo do personagem.
  # D = Valor de BP recuperado a cada turno.
  #------------------------------------------------------
    1 => [5, 10, 3],
    2 => [4, 9, 4],
    3 => [2, 13, 3],
    4 => [4, 9, 2],
    5 => [2, 10, 4],
    6 => [3, 10, 2],
    7 => [4, 12, 3],
    8 => [4, 15, 2]
  }
  # Definindo em que Level o personagem aumentará o valor inicial de BP.
  ACT_INIT_BP_LVUP = {
  #------------------------------------------------------
  # A  => [B,B,B,B,B,B],
  #------------------------------------------------------
  # A = ID do personagem.
  # B = Level
    1 => [5,10,15,25,30,40],
    2 => [5,10,15,25,30,40],
    3 => [5,10,15,25,30,40],
    4 => [5,10,15,25,30,40],
    5 => [5,10,15,25,30,40],
    6 => [5,10,15,25,30,40],
    7 => [5,10,15,25,30,40],
    8 => [5,10,15,25,30,40]
  }
  # Definindo em que Level o personagem aumentará o valor maximo de BP.
  ACT_MAX_BP_LVUP = {
  #------------------------------------------------------
  # A  => [B,B,B,B,B,B],
  #------------------------------------------------------
  # A = ID do personagem.
  # B = Level
    1 => [5,10,15,25,30,40],
    2 => [5,10,15,25,30,40],
    3 => [5,10,15,25,30,40],
    4 => [5,10,15,25,30,40],
    5 => [5,10,15,25,30,40],
    6 => [5,10,15,25,30,40],
    7 => [5,10,15,25,30,40],
    8 => [5,10,15,25,30,40]
  }
  # Definindo em que Level o personagem aumentará o valor de BP ganho por turno.
  ACT_REST_BP_LVUP = {
  #------------------------------------------------------
  # A  => [B,B,B,B,B,B],
  #------------------------------------------------------
  # A = ID do personagem.
  # B = Level

    1 => [5,10,15,25,30,40],
    2 => [5,10,15,25,30,40],
    3 => [5,10,15,25,30,40],
    4 => [5,10,15,25,30,40],
    5 => [5,10,15,25,30,40],
    6 => [5,10,15,25,30,40],
    7 => [5,10,15,25,30,40],
    8 => [5,10,15,25,30,40]
  }
end
#-------------------------------------------------------------------------------

class Game_Actor
  attr_accessor  :bp     
  attr_accessor  :init_bp
  attr_accessor  :max_bp 
  attr_accessor  :rest_bp
  alias initialize_use_limit initialize
  def initialize(actor_id)
    initialize_use_limit(actor_id)
    act_bp = SysSkill_BP::ACT_BP[actor_id]
    @bp = act_bp[0]
    @init_bp = act_bp[0]
    @max_bp = act_bp[1]
    @rest_bp = act_bp[2]
  end
  alias exp_bp= exp=
  def exp=(exp)
    cp_level = @level 
    self.exp_bp = exp
    if cp_level < @level 
      counter_num = 1
    elsif cp_level > @level
      counter_num = -1
    else                 
      return
    end
    for lv_index in cp_level...@level
      if SysSkill_BP::ACT_INIT_BP_LVUP[self.id].include?(lv_index)
        @init_bp += counter_num
      end
      if SysSkill_BP::ACT_MAX_BP_LVUP[self.id].include?(lv_index)
        @max_bp += counter_num
      end
      if SysSkill_BP::ACT_REST_BP_LVUP[self.id].include?(lv_index)
        @rest_bp += counter_num
      end
    end
  end
end

class Game_Battler
  alias skill_limit_can_use? skill_can_use?
  def skill_can_use?(skill_id)
    ret = skill_limit_can_use?(skill_id)
    if self.is_a?(Game_Actor) and $scene.is_a?(Scene_Battle)
      bp = SysSkill_BP::SKILL_BP[skill_id]
      skill_bp = ( bp == nil ? 1 : bp)
      if ret 
        if self.bp < skill_bp
          return false
        end
      else
        if !SysSkill_BP::BATTLE_SP_USE
          if $data_skills[skill_id].sp_cost > self.sp
            cp_sp = $data_skills[skill_id].sp_cost.dup
            $data_skills[skill_id].sp_cost = 0
            ret_sp = skill_limit_can_use?(skill_id)
            $data_skills[skill_id].sp_cost = cp_sp
            if ret_sp
              if self.bp < skill_bp
                # if FlashSystem::FLASH_COST and self.flash_flg
                #  return true
                # end
                return false
              end
            end
          end
        end
      end
    end
    return ret
  end
end


class Scene_Battle
  alias main_use_limit main
  def main
    for i in 0..$game_party.actors.size-1
      actor = $game_party.actors[i]
      actor.bp = actor.init_bp
    end
    main_use_limit
  end
  alias start_skill_select_limit start_skill_select
  def start_skill_select
    start_skill_select_limit
    if SysSkill_BP::WINDOW_BP_USE
      @actor_bp_window = Window_Battle_Point.new
      @actor_bp_window.x = @actor_index * 160
      @actor_bp_window.y = 300
      @actor_bp_window.back_opacity =160
      @actor_bp_window.set_actor_bp(@active_battler)
    end
  end
  alias end_skill_select_limit end_skill_select
  def end_skill_select
    if SysSkill_BP::WINDOW_BP_USE
      @actor_bp_window.dispose
      @actor_bp_window = nil
    end
    end_skill_select_limit
  end
  alias make_skill_action_result_limit make_skill_action_result
  def make_skill_action_result
    make_skill_action_result_limit
    if @active_battler.is_a?(Game_Actor)
      bp = SysSkill_BP::SKILL_BP[@skill.id]
      skill_bp = (bp==nil ? 1 : bp)
      @active_battler.bp -= skill_bp
      if !SysSkill_BP::BATTLE_SP_USE
        @active_battler.sp += @skill.sp_cost
      end
    end
  end
  alias update_phase4_step6_limit update_phase4_step6
  def update_phase4_step6
    update_phase4_step6_limit
    if @active_battler.is_a?(Game_Actor)
      @active_battler.bp += @active_battler.rest_bp
      if @active_battler.bp > @active_battler.max_bp
        @active_battler.bp = @active_battler.max_bp
      end
    end
  end
end
class Window_Base < Window
  def draw_actor_bp(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, "BP")
    width = 144
    if width - 32 >= 108
      sp_x = x + width - 124
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.bp == 0 ? knockout_color :
      actor.bp <= actor.max_bp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 36, 32, actor.bp.to_s, 2)
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 36, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 48, y, 48, 32, actor.max_bp.to_s)
      self.contents.font.color = knockout_color
      self.contents.draw_text(sp_x + 72, y, 12, 32, "+", 1)
      self.contents.draw_text(sp_x + 84, y, 48, 32, actor.rest_bp.to_s)
      self.contents.font.color = normal_color
    end
  end
  def draw_actor_bp_icon(actor, x, y)
    bitmap = RPG::Cache.icon(SysSkill_BP::BP_ICON)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    for i in 0...actor.bp
      self.contents.blt(x + cw - bitmap.width, y - ch + 30, bitmap, src_rect)
      cw += bitmap.width
    end
  end
end

class Window_Battle_Point < Window_Base
  def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  def set_actor_bp(actor)
    if SysSkill_BP::USE_BP_ICON
      draw_actor_bp_icon(actor, 4, 0)
    else
      draw_actor_bp(actor, 4, 0)
    end
  end
end


#==============================================================================
# ? Window_Skill
#==============================================================================
class Window_Skill < Window_Selectable
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    if SysSkill_BP::BATTLE_SP_USE
      self.contents.draw_text(x + 196, y, 48, 32, skill.sp_cost.to_s, 2)
    end
    bp = SysSkill_BP::SKILL_BP[skill.id]
    skill_bp = (bp == nil ? 1 : bp)
    self.contents.font.color = crisis_color
    self.contents.draw_text(x + 232, y, 48, 32, skill_bp.to_s, 2)
  end
end


#==============================================================================
# ? Window_BattleStatus
#==============================================================================
class Window_BattleStatus < Window_Base
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      actor_x = i * 160 + 4
      draw_actor_name(actor, actor_x, 0)
      if SysSkill_BP::BATTLE_SP_USE
        draw_actor_hp(actor, actor_x, 30, 120)
        draw_actor_sp(actor, actor_x, 50, 120)
      else
        draw_actor_hp(actor, actor_x, 32, 120)
      end
      if SysSkill_BP::BATTLE_SP_USE
        bp_y = 70
      else
        bp_y = 64
      end
      if SysSkill_BP::USE_BP_ICON
        draw_actor_bp_icon(actor, actor_x, bp_y)
      else
        draw_actor_bp(actor, actor_x, bp_y)
      end
      if @level_up_flags[i]
        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
  end
end

Las instrucciones estan dentro del script, están en portugués pero se le puede entender fácilmente, o usen el google traductor.

Saludos.
avatar
Night Shade
Emu-aprendiz
Emu-aprendiz

Mensajes : 106
Fecha de inscripción : 19/07/2013

Ver perfil de usuario

Volver arriba Ir abajo

Volver arriba

- Temas similares

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