¡Bienvenid@ a Mundo Maker!

¿Quieres aprender todo sobre el RPG Maker?



Regístrate y forma parte de Mundo Maker.
Conectarse

Recuperar mi contraseña

Temas importantes
----------------------------------------
Páginas con recursos RPG Maker
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
Afiliados
Estadísticas
Tenemos 3397 miembros registrados.
El último usuario registrado es LucasGF.

Nuestros miembros han publicado un total de 79808 mensajes en 11257 argumentos.
Navega con Google Chrome
[DESCARGA]

[XP] Wecoc's Class Script Core v1.0

 :: RPG Maker :: Scripts

Ver el tema anterior Ver el tema siguiente Ir abajo

RPG Maker XP [XP] Wecoc's Class Script Core v1.0

Mensaje por Wecoc el 2016-04-16, 16:39

Información general

Éste script implementa la nueva clase Game_Class, que permite mejor control de las clases de los actores, por ejemplo cambiarles los parámetros a medio juego (nombre, armas equipables, estados), añadir y quitar learnings (que son las skills que se aprenden por nivel) y definir nivel a la clase. Lo más importante no es eso, si no el hecho de ser un Core, es decir una base que permite hacer nuevos scripts sobre clases más fácilmente.

El nivel de clase funciona similar al nivel de actor normal, sube en la batalla mediante experiéncia, pero tiene sus propios parámetros de aprendizaje, sube más lento que los niveles normales. Todo eso, así como el máximo de niveles, es configurable por cada clase y por cada actor manualmente mediante llamadas de script. Eso significa que conviene tener un mínimo conocimiento de scripts para poder usar éste sistema.

Como el script es un Core el hecho de que la habilidad tenga más nivel no implica ningún cambio en los parámetros del actor. Esa parte del funcionamiento de los niveles de clase se deberá programar dependiendo de lo que se busque en el juego (y de su mecánica), por ende necesita otro script personalizado.

Instrucciones

En el script podéis encontrar las más básicas. Si tenéis dudas más concretas, comentadlas en el topic.

Compatibilidad

El script reescribe toda una série de métodos que citaré a continuación. No usa alias en ningún momento.
Si hay otro script que reescriba por su parte alguno de los métodos habrá que arreglar la incompatibilidad, lo cual el principio no debería ser nada complicado.

Game_Actor:initialize
Game_Actor:setup
Game_Actor:make_exp_list
Game_Actor:element_rate
Game_Actor:state_ranks
Game_Actor:class_name
Game_Actor:equippable?
Game_Actor:level=
Game_Actor:exp=
Game_Actor:class_id=

Game_Party:random_target_actor

Window_EquipItem:refresh

Scene_Battle:start_phase5

Window_BattleStatus:initialize
Window_BattleStatus:level_up


Script

Ponedlo encima de main:
Código:
#==============================================================================
# ** Wecoc's Class Script Core v1.0
#------------------------------------------------------------------------------
# Autor: Wecoc
#------------------------------------------------------------------------------
#  Asignar nivel a las clases y modificar sus propiedades in-game por actor.
#  Éste nivel tiene su propia curva de exp, que se gana junto a la normal.
#  Esos niveles no sirven de nada solo con éste script puesto que es el Core,
#  necesitarás implementar a parte lo que supone subir de nivel cada clase.
#
#  El nivel máximo de clase por defecto es 4.
#
# * Método (acceder a la clase actual de ese actor en concreto)
#    $game_actors[ID actor].actor_class
#
#  A partir de éste se pueden cambiar muchas características de la clase.
#
#  * A continuación pongo una lista de métodos para controlar la clase.
#    Hay más, pongo los importantes.
#
#  $game_actors[ID].class_id = [ID clase]
#  $game_actors[ID].actor_class.name = (NOMBRE)
#  $game_actors[ID].actor_class.level = (NIVEL de la clase)
#  $game_actors[ID].actor_class.add_learning([ID skill], [NIVEL actor])
#  $game_actors[ID].actor_class.delete_learning([ID skill])
#
#==============================================================================

#==============================================================================
# ** Game_Class
#==============================================================================

class Game_Class
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :name
  attr_accessor :position
  attr_accessor :weapon_set
  attr_accessor :armor_set
  attr_accessor :element_ranks
  attr_accessor :state_ranks
  attr_accessor :learnings
  attr_reader :level
  attr_reader :final_level
  attr_reader :exp
  attr_reader :exp_basis
  attr_reader :exp_inflation
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(class_id)
    setup(class_id)
  end
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(class_id)
    @class_id = class_id
    c = $data_classes[class_id]
    @name = c.name
    @position = c.position
    @weapon_set = c.weapon_set
    @armor_set = c.armor_set
    @element_ranks = c.element_ranks
    @state_ranks = c.state_ranks
    @learnings = c.learnings
    @level = 1
    @final_level = 4
    @exp_list = Array.new(101)
    @exp_basis = 100
    @exp_inflation = 100
    make_exp_list
    @exp = @exp_list[@level]
  end
  #--------------------------------------------------------------------------
  # * Id
  #--------------------------------------------------------------------------
  def id
    return @class_id
  end
  #--------------------------------------------------------------------------
  # * Make Experience List
  #--------------------------------------------------------------------------
  def make_exp_list
    @exp_list[1] = 0
    pow_i = 2.4 + @exp_inflation / 100.0
    for i in 2..100
      if i > @final_level
        @exp_list[i] = 0
      else
        n = @exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)
        @exp_list[i] = @exp_list[i-1] + Integer(n)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set Experience Basis
  #--------------------------------------------------------------------------
  def exp_basis=(value)
    @exp_basis = value
    make_exp_list
    self.exp = @exp
  end
  #--------------------------------------------------------------------------
  # * Set Experience Inflation
  #--------------------------------------------------------------------------
  def exp_inflation=(value)
    @exp_inflation = value
    make_exp_list
    self.exp = @exp
  end
  #--------------------------------------------------------------------------
  # * Set Final Level
  #--------------------------------------------------------------------------
  def final_level=(level)
    @final_level = value
    make_exp_list
    self.exp = @exp
  end
  #--------------------------------------------------------------------------
  # * Change Experience
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
    end
    while @exp < @exp_list[@level]
      @level -= 1
    end
  end
  #--------------------------------------------------------------------------
  # * Change Level
  #--------------------------------------------------------------------------
  def level=(level)
    level = [[level, @final_level].min, 1].max
    self.exp = @exp_list[level]
  end
  #--------------------------------------------------------------------------
  # * Get EXP String
  #--------------------------------------------------------------------------
  def exp_s
    return @exp_list[@level+1] > 0 ? @exp.to_s : "-------"
  end
  #--------------------------------------------------------------------------
  # * Get Next Level EXP String
  #--------------------------------------------------------------------------
  def next_exp_s
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1].to_s : "-------"
  end
  #--------------------------------------------------------------------------
  # * Get Until Next Level EXP String
  #--------------------------------------------------------------------------
  def next_rest_exp_s
    return @exp_list[@level+1] > 0 ?
      (@exp_list[@level+1] - @exp).to_s : "-------"
  end
  #--------------------------------------------------------------------------
  # * Add Learning
  #--------------------------------------------------------------------------
  def add_learning(skill_id, level)
    delete_learning(skill_id)
    learn = RPG::Class::Learning.new
    learn.skill_id = skill_id
    learn.level = level
    @learnings.push(learn)
    @learnings.sort!{|a, b| a.level <=> b.level}
    return learn
  end
  #--------------------------------------------------------------------------
  # * Delete Learning
  #--------------------------------------------------------------------------
  def delete_learning(skill_id)
    forget = @learnings.select{|x| x.skill_id == skill_id}
    @learnings.delete(forget[0])
    return forget
  end 
end

#==============================================================================
# ** Game_Classes
#==============================================================================

class Game_Classes
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @data = []
  end
  #--------------------------------------------------------------------------
  # * Get Class
  #--------------------------------------------------------------------------
  def [](class_id)
    if class_id > 999 or $data_classes[class_id] == nil
      return nil
    end
    if @data[class_id] == nil
      @data[class_id] = Game_Class.new(class_id)
    end
    return @data[class_id]
  end
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :classes
  attr_reader :final_level
  attr_reader :exp_basis
  attr_reader :exp_inflation
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor_id)
    super()
    @classes = Game_Classes.new
    setup(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(actor_id)
    actor = $data_actors[actor_id]
    @actor_id = actor_id
    @name = actor.name
    @character_name = actor.character_name
    @character_hue = actor.character_hue
    @battler_name = actor.battler_name
    @battler_hue = actor.battler_hue
    @class_id = actor.class_id
    @weapon_id = actor.weapon_id
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id
    @level = actor.initial_level
    @final_level = actor.final_level
    @exp_list = Array.new(101)
    @exp_basis = actor.exp_basis
    @exp_inflation = actor.exp_inflation
    make_exp_list
    @exp = @exp_list[@level]
    @skills = []
    @hp = maxhp
    @sp = maxsp
    @states = []
    @states_turn = {}
    @maxhp_plus = 0
    @maxsp_plus = 0
    @str_plus = 0
    @dex_plus = 0
    @agi_plus = 0
    @int_plus = 0
    # Learn skill
    for i in 1..@level
      for j in @classes[@class_id].learnings
        if j.level == i
          learn_skill(j.skill_id)
        end
      end
    end
    # Update auto state
    update_auto_state(nil, $data_armors[@armor1_id])
    update_auto_state(nil, $data_armors[@armor2_id])
    update_auto_state(nil, $data_armors[@armor3_id])
    update_auto_state(nil, $data_armors[@armor4_id])
  end
  #--------------------------------------------------------------------------
  # * Make Experience List
  #--------------------------------------------------------------------------
  def make_exp_list
    @exp_list[1] = 0
    pow_i = 2.4 + @exp_inflation / 100.0
    for i in 2..100
      if i > @final_level
        @exp_list[i] = 0
      else
        n = @exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)
        @exp_list[i] = @exp_list[i-1] + Integer(n)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set Experience Basis
  #--------------------------------------------------------------------------
  def exp_basis=(value)
    @exp_basis = value
    make_exp_list
    self.exp = @exp
  end
  #--------------------------------------------------------------------------
  # * Set Experience Inflation
  #--------------------------------------------------------------------------
  def exp_inflation=(value)
    @exp_inflation = value
    make_exp_list
    self.exp = @exp
  end
  #--------------------------------------------------------------------------
  # * Set Final Level
  #--------------------------------------------------------------------------
  def final_level=(level)
    @final_level = value
    make_exp_list
    self.exp = @exp
  end
  #--------------------------------------------------------------------------
  # * Change Level
  #--------------------------------------------------------------------------
  def level=(level)
    level = [[level, @final_level].min, 1].max
    self.exp = @exp_list[level]
  end
  #--------------------------------------------------------------------------
  # * Get Element Revision Value
  #--------------------------------------------------------------------------
  def element_rate(element_id)
    table = [0,200,150,100,50,0,-100]
    result = table[@classes[@class_id].element_ranks[element_id]]
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
      armor = $data_armors[i]
      if armor != nil and armor.guard_element_set.include?(element_id)
        result /= 2
      end
    end
    for i in @states
      if $data_states[i].guard_element_set.include?(element_id)
        result /= 2
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Get State Effectiveness
  #--------------------------------------------------------------------------
  def state_ranks
    return @classes[@class_id].state_ranks
  end
  #--------------------------------------------------------------------------
  # * Get Class Name
  #--------------------------------------------------------------------------
  def class_name
    return @classes[@class_id].name
  end
  #--------------------------------------------------------------------------
  # * Determine if Equippable
  #--------------------------------------------------------------------------
  def equippable?(item)
    if item.is_a?(RPG::Weapon)
      if @classes[@class_id].weapon_set.include?(item.id)
        return true
      end
    end
    if item.is_a?(RPG::Armor)
      if @classes[@class_id].armor_set.include?(item.id)
        return true
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      for j in @classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    while @exp < @exp_list[@level]
      @level -= 1
    end
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
  #--------------------------------------------------------------------------
  # * Change Class ID
  #--------------------------------------------------------------------------
  def class_id=(class_id)
    if @classes[class_id] != nil
      @class_id = class_id
      # Remove items that are no longer equippable
      unless equippable?($data_weapons[@weapon_id])
        equip(0, 0)
      end
      unless equippable?($data_armors[@armor1_id])
        equip(1, 0)
      end
      unless equippable?($data_armors[@armor2_id])
        equip(2, 0)
      end
      unless equippable?($data_armors[@armor3_id])
        equip(3, 0)
      end
      unless equippable?($data_armors[@armor4_id])
        equip(4, 0)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Get Current Class
  #--------------------------------------------------------------------------
  def actor_class
    return @classes[@class_id]
  end
end

#==============================================================================
# ** Game_Party
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Random Selection of Target Actor
  #--------------------------------------------------------------------------
  def random_target_actor(hp0 = false)
    roulette = []
    for actor in @actors
      if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
        position = actor.classes[actor.class_id].position
        n = 4 - position
        n.times do
          roulette.push(actor)
        end
      end
    end
    if roulette.size == 0
      return nil
    end
    return roulette[rand(roulette.size)]
  end
end

#==============================================================================
# ** Window_EquipItem
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add equippable weapons
    if @equip_type == 0
      weapon_set = @actor.classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons[i])
        end
      end
    end
    # Add equippable armor
    if @equip_type != 0
      armor_set = @actor.classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors[i].kind == @equip_type-1
            @data.push($data_armors[i])
          end
        end
      end
    end
    @data.push(nil)
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    @phase = 5
    $game_system.me_play($game_system.battle_end_me)
    $game_system.bgm_play($game_temp.map_bgm)
    exp = 0
    gold = 0
    treasures = []
    for enemy in $game_troop.enemies
      unless enemy.hidden
        exp += enemy.exp
        gold += enemy.gold
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    treasures = treasures[0..5]
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        last_class_level = actor.actor_class.level
        actor.actor_class.exp += exp
        level_up = actor.level > last_level
        class_level_up = actor.actor_class.level > last_class_level
        if (level_up or class_level_up)
          @status_window.level_up(i, level_up, class_level_up)
        end
      end
    end
    $game_party.gain_gold(gold)
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    @phase5_wait_count = 100
  end
end

#==============================================================================
# ** Window_BattleStatus
#==============================================================================

class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(0, 320, 640, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    @level_up_flags =      [false, false, false, false]
    @class_level_up_flags = [false, false, false, false]
    refresh
  end
  #--------------------------------------------------------------------------
  # * Set Level Up & Class Level Up Flags
  #--------------------------------------------------------------------------
  def level_up(actor_index, level_up = true, class_level_up = false)
    @level_up_flags[actor_index] = level_up
    @class_level_up_flags[actor_index] = class_level_up
  end
end

Wecoc
Administrador
Administrador



Créditos 8272

Gracias : 372

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba


 :: RPG Maker :: Scripts

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