Mundo Maker
¡Bienvenid@ a Mundo Maker!

¿Quieres aprender todo sobre el RPG Maker?



Regístrate y forma parte de Mundo Maker.
Conectarse

Recuperar mi contraseña

Últimos temas
» Gameplay - Mansión Rybi - RMVXA.
por Miky Joe 2018-12-10, 08:36

» The Town of The Lost Witch [Horror/Suspense] - Enero 2019
por rstudios 2018-12-10, 01:20

» muchas dudas
por DiegoArancibia 2018-12-09, 16:55

» Galería Miky Art [Bocetos y más]
por Miky Joe 2018-12-09, 09:16

» Hemos vuelto
por alex1633 2018-12-08, 23:17

» [MV] Precognition
por franciscojapones 2018-12-08, 07:06

» (AJUDA) Conpatibilidade de 2 scripts simples
por orochii 2018-12-08, 03:14

» ("TCG") Que RPG Maker es el recomendado?
por orochii 2018-12-08, 03:03

» BOAS VINDAS
por orochii 2018-12-08, 02:58

» Script de mensaje de Wecoc
por orochii 2018-12-07, 23:43

Afiliados

[XP] ERON module

Ver el tema anterior Ver el tema siguiente Ir abajo

RPG Maker XP [XP] ERON module

Mensaje por Eron el 2013-09-08, 03:52

Este script por si solo no hace nada, pero da la posibilidad de crear otros scripts más fácilmente, tipo SDK =DD Sus ampliaciones internas se aplican principalmente en Game_Battler y sus subclases Game_Actor y Game_Enemy. Quien quiera puede hacer scripts que requieran éste, pero dadme créditos si lo usáis. Quien quiera mejorarlo que lo haga también, y le añadiré a los créditos, pero el nombre del módulo se queda así x'DDD

Yo mismo más adelante haré unos "scripts de ejemplo" que serán puras modificaciones del RTP usando el módulo, pero repito, solo seran ejemplos.

No debería tener demasiados problemas de incompatibilidad, pero alguno puede que haya.

Código: Ponedlo encima de main y encima de los scripts que lo requieran.

Código:
#==============================================================================
# [XP] ERON module
# Version 1.0
#------------------------------------------------------------------------------
# by Eron
#==============================================================================

module ERON
  VERSION = 1.0
  EMPTY_ACTOR_ID = 9
  EMPTY_ENEMY_ID = 33
end

module RPG
  class Item
    attr_accessor :hp_req
    attr_accessor :sp_req
    attr_accessor :str_req
    attr_accessor :dex_req
    attr_accessor :agi_req
    attr_accessor :int_req
    attr_accessor :switch_req
    attr_accessor :class_req
    attr_accessor :level_req
    attr_accessor :skill_req
    attr_accessor :item_req
    attr_accessor :weapon_req
    attr_accessor :armor_req
  end
 
  class Weapon
    attr_accessor :str_req
    attr_accessor :dex_req
    attr_accessor :agi_req
    attr_accessor :int_req
    attr_accessor :switch_req
    attr_accessor :class_req
    attr_accessor :level_req
    attr_accessor :skill_req
    attr_accessor :item_req
    attr_accessor :armor_req
  end
 
  class Armor
    attr_accessor :str_req
    attr_accessor :dex_req
    attr_accessor :agi_req
    attr_accessor :int_req
    attr_accessor :switch_req
    attr_accessor :class_req
    attr_accessor :level_req
    attr_accessor :skill_req
    attr_accessor :item_req
    attr_accessor :weapon_req
    attr_accessor :armor_req
  end
end

class Array
  def sort_by_array(other)
    new_array = []
    self_array = []
    return self if self.size != other.size
    for i in 0...self.size
      self_array.push self[i]
    end
    while other.size > 0
      for i in 0...other.size
        if other[i] == other.min
          min = i
        end
      end
      new_array.push self_array[min]
      other.delete_at(min)
      self_array.delete_at(min)
    end
    return new_array
  end
 
  def sort_by_array!(other)
    self.replace(sort_by_array(other))
  end
end

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  attr_reader  :exp_list
  attr_reader  :states_turn
  attr_reader  :current_action
  attr_accessor :maxhp_plus
  attr_accessor :maxsp_plus
  attr_accessor :str_plus
  attr_accessor :dex_plus
  attr_accessor :agi_plus
  attr_accessor :int_plus

  def rpg
    return $data_actors[@actor_id]
  end
  def rpg_class
    return $data_classes[@class_id]
  end
 
  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
    @exp_list = Array.new(101)
    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 $data_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
 
  def ini_equip
    return [rpg.weapon_id, rpg.armor1_id,
            rpg.armor2_id, rpg.armor3_id, rpg.armor4_id]
  end
  def actual_equip
    return [@weapon_id, @armor1_id, @armor2_id, @armor3_id, @armor4_id]
  end

  def learnings(lv=99)
    return rpg_class.learnings.select {|x| x.level <= lv }
  end
  def level_learnings(lv=1)
    return rpg_class.learnings.select {|x| x.level == lv }
  end
 
  def ini_skills(lv=1)
    return learnings(lv).collect {|x| x.skill_id}
  end
  def actual_skills
    return @skills
  end
 
  def ini_atk
    weapon = $data_weapons[ini_equip[0]]
    return weapon != nil ? weapon.atk : 0
  end
 
  def ini_pdef
    weapon = $data_weapons[ini_equip[0]]
    armor1 = $data_armors[ini_equip[1]]
    armor2 = $data_armors[ini_equip[2]]
    armor3 = $data_armors[ini_equip[3]]
    armor4 = $data_armors[ini_equip[4]]
    pdef1 = weapon != nil ? weapon.pdef : 0
    pdef2 = armor1 != nil ? armor1.pdef : 0
    pdef3 = armor2 != nil ? armor2.pdef : 0
    pdef4 = armor3 != nil ? armor3.pdef : 0
    pdef5 = armor4 != nil ? armor4.pdef : 0
    return pdef1 + pdef2 + pdef3 + pdef4 + pdef5
  end
 
  def ini_mdef
    weapon = $data_weapons[ini_equip[0]]
    armor1 = $data_armors[ini_equip[1]]
    armor2 = $data_armors[ini_equip[2]]
    armor3 = $data_armors[ini_equip[3]]
    armor4 = $data_armors[ini_equip[4]]
    mdef1 = weapon != nil ? weapon.mdef : 0
    mdef2 = armor1 != nil ? armor1.mdef : 0
    mdef3 = armor2 != nil ? armor2.mdef : 0
    mdef4 = armor3 != nil ? armor3.mdef : 0
    mdef5 = armor4 != nil ? armor4.mdef : 0
    return mdef1 + mdef2 + mdef3 + mdef4 + mdef5
  end

  def ini_eva
    armor1 = $data_armors[ini_equip[1]]
    armor2 = $data_armors[ini_equip[2]]
    armor3 = $data_armors[ini_equip[3]]
    armor4 = $data_armors[ini_equip[4]]
    eva1 = armor1 != nil ? armor1.eva : 0
    eva2 = armor2 != nil ? armor2.eva : 0
    eva3 = armor3 != nil ? armor3.eva : 0
    eva4 = armor4 != nil ? armor4.eva : 0
    return eva1 + eva2 + eva3 + eva4
  end
 
  def equip_fix(equip_type)
    case equip_type
    when 0  # Weapon
      $data_actors[@actor_id].weapon_fix = true
    when 1  # Shield
      $data_actors[@actor_id].armor1_fix = true
    when 2  # Head
      $data_actors[@actor_id].armor2_fix = true
    when 3  # Body
      $data_actors[@actor_id].armor3_fix = true
    when 4  # Accessory
      $data_actors[@actor_id].armor4_fix = true
    end
  end

  def equip_unfix(equip_type)
    case equip_type
    when 0  # Weapon
      $data_actors[@actor_id].weapon_fix = false
    when 1  # Shield
      $data_actors[@actor_id].armor1_fix = false
    when 2  # Head
      $data_actors[@actor_id].armor2_fix = false
    when 3  # Body
      $data_actors[@actor_id].armor3_fix = false
    when 4  # Accessory
      $data_actors[@actor_id].armor4_fix = false
    end
  end
 
  def equip_fix?(equip_type)
    case equip_type
    when 0  # Weapon
      return $data_actors[@actor_id].weapon_fix
    when 1  # Shield
      return $data_actors[@actor_id].armor1_fix
    when 2  # Head
      return $data_actors[@actor_id].armor2_fix
    when 3  # Body
      return $data_actors[@actor_id].armor3_fix
    when 4  # Accessory
      return $data_actors[@actor_id].armor4_fix
    end
    return false
  end
 
  def equip_unfix?(equip_type)
    return !equip_fix?(equip_type)
  end
 
  def to_ltr(value)
    case value
      when 1, 200 then return 'A'
      when 2, 150 then return 'B'
      when 3, 100 then return 'C'
      when 4, 50  then return 'D'
      when 5, 0  then return 'E'
      when 6,-100 then return 'F'
      else ; return value
    end
  end
 
  def to_elmnt(value) # ltr_to_elmnt(value)
    case value
      when 'A', 200 then return 1
      when 'B', 150 then return 2
      when 'C', 100 then return 3
      when 'D', 50  then return 4
      when 'E', 0  then return 5
      when 'F',-100 then return 6
      else ; return value
    end
  end
 
  def to_table(value)
    case value
      when 1, 'A' then return 200
      when 2, 'B' then return 150
      when 3, 'C' then return 100
      when 4, 'D' then return 50
      when 5, 'E' then return 0
      when 6, 'F' then return -100
      else ; return value
    end
  end
 
  def get_elmnt(element, letter=false)
    element = rpg_class.element_ranks[element]
    return letter == true ? to_ltr(element) : element
  end
 
  def set_elmnt(element, value)
    value = to_elmnt(value)
    rpg_class.element_ranks[element] = value
  end
 
  def elmnt_up(index)
    value = get_elmnt(index)
    return 1 if value == 1
    set_elmnt(index, value-1)
  end
 
  def elmnt_down(index)
    value = get_elmnt(index)
    return 6 if value == 6
    set_elmnt(index, value+1)
  end
 
  def actual_elmnts
    array = []
    for i in 0...rpg_class.element_ranks.xsize
      array.push rpg_class.element_ranks[i]
    end
    return array
  end
 
  def get_state(state, letter=false)
    state = rpg_class.state_ranks[state]
    return letter == true ? to_ltr(state) : state
  end

  def set_state(state, value)
    value = to_elmnt(value)
    rpg_class.state_ranks[state] = value
  end
 
  def state_up(index)
    value = get_state(index)
    return 1 if value == 1
    set_state(index, value-1)
  end
 
  def state_down(index)
    value = get_state(index)
    return 6 if value == 6
    set_state(index, value+1)
  end
 
  def actual_states
    array = []
    for i in 0...rpg_class.state_ranks.xsize
      array.push rpg_class.state_ranks[i]
    end
    return array
  end
 
  def get_weak_elmnt(element, letter=false)
    element = $data_enemies[@enemy_id].element_ranks[element]
    return letter == true ? to_ltr(element) : element
  end
 
  def set_weak_elmnt(element, value)
    value = to_elmnt(value)
    $data_enemies[@enemy_id].element_ranks[element] = value
  end
 
  def elmnt_weak_up(index)
    value = get_weak_elmnt(index)
    return 1 if value == 1
    set_weak_elmnt(index, value-1)
  end
 
  def elmnt_weak_down(index)
    value = get_weak_elmnt(index)
    return 6 if value == 6
    set_weak_elmnt(index, value+1)
  end
 
  def actual_weak_elmnts
    array = []
    for i in 0...$data_enemies[@enemy_id].element_ranks.xsize
      array.push $data_enemies[@enemy_id].element_ranks[i]
    end
    return array
  end
 
  def get_weak_state(state, letter=false)
    state = $data_enemies[@enemy_id].state_ranks[state]
    return letter == true ? to_ltr(state) : state
  end

  def set_weak_state(state, value)
    value = to_elmnt(value)
    $data_enemies[@enemy_id].state_ranks[state] = value
  end
 
  def state_weak_up(index)
    value = get_weak_state(index)
    return 1 if value == 1
    set_weak_state(index, value-1)
  end
 
  def state_weak_down(index)
    value = get_weak_state(index)
    return 6 if value == 6
    set_weak_state(index, value+1)
  end
 
  def actual_weak_states
    array = []
    for i in 0...$data_enemies[@enemy_id].state_ranks.xsize
      array.push $data_enemies[@enemy_id].state_ranks[i]
    end
    return array
  end
 
  def item_can_use?(item_id)
    item = $data_items[item_id]
    return false if item == nil
    if item.hp_req != nil
      if @hp > item.hp_req
        return false
      end
    end
    if item.sp_req != nil
      if @sp > item.sp_req
        return false
      end
    end
    if item.str_req != nil
      if str < item.str_req
        return false
      end
    end
    if item.dex_req != nil
      if dex < item.dex_req
        return false
      end
    end
    if item.agi_req != nil
      if agi < item.agi_req
        return false
      end
    end
    if item.int_req != nil
      if int < item.int_req
        return false
      end
    end
    if item.switch_req != nil
      if $game_switches[item.switch_req] == false
        return false
      end
    end
    if item.class_req != nil
      if item.class_req.is_a?(Array)
        if not item.class_req.include?(@class_id)
          return false
        end
      else # Integer
        if @class_id != item.class_req
          return false
        end
      end
    end
    if item.level_req != nil
      if @level < item.level_req
        return false
      end
    end
    if item.skill_req != nil
      if item.skill_req.is_a?(Array)
        for i in 0...item.skill_req.size
          if not @skills.include?(item.skill_req[i])
            return false
          end
        end
      else # Integer
        if not @skills.include?(item.skill_req)
          return false
        end
      end
    end
    if (item.item_req != nil and self.is_a?(Game_Actor))
      if item.item_req.is_a?(Array)
        for i in 0...item.item_req.size
          if not $game_party.item_number(item.item_req[i]) > 0
            return false
          end
        end
      else # Integer
        if not $game_party.item_number(item.item_req) > 0
          return false
        end
      end
    end
    if item.weapon_req != nil
      if item.weapon_req.is_a?(Array)
        if not item.weapon_req.include?(@weapon_id)
          return false
        end
      else # Integer
        if @weapon_id != item.weapon_req
          return false
        end
      end
    end
    if item.armor_req != nil
      if item.armor_req.is_a?(Array)
        if not (item.armor_req.include?(@armor1_id) or
          item.armor_req.include?(@armor2_id) or
          item.armor_req.include?(@armor3_id) or
          item.armor_req.include?(@armor4_id) )
          return false
        end
      else # Integer
        if @armor1_id != item.weapon_req and @armor2_id != item.weapon_req and
          @armor3_id != item.weapon_req and @armor4_id != item.weapon_req
          return false
        end
      end
    end
    return true
  end
 
  def weapon_equippable?(id)
    weapon = $data_weapons[id]
    return equippable?(weapon)
  end
 
  def armor_equippable?(id)
    armor = $data_armors[id]
    return equippable?(armor)
  end
 
  def equippable?(item)
    if item.is_a?(RPG::Item)
      return false
    end
    if item.is_a?(RPG::Weapon)
      if not $data_classes[@class_id].weapon_set.include?(item.id)
        return false
      end
    end
    if item.is_a?(RPG::Armor)
      if not $data_classes[@class_id].armor_set.include?(item.id)
        return false
      end
      if item.weapon_req != nil
        if item.weapon_req.is_a?(Array)
          if not item.weapon_req.include?(@weapon_id)
            return false
          end
        else # Integer
          if @weapon_id != item.weapon_req
            return false
          end
        end
      end
    end
    if item.str_req != nil
      if str < item.str_req
        return false
      end
    end
    if item.dex_req != nil
      if dex < item.dex_req
        return false
      end
    end
    if item.agi_req != nil
      if agi < item.agi_req
        return false
      end
    end
    if item.int_req != nil
      if int < item.int_req
        return false
      end
    end
    if item.switch_req != nil
      if $game_switches[item.switch_req] == false
        return false
      end
    end
    if item.level_req != nil
      if @level < item.level_req
        return false
      end
    end
    if item.skill_req != nil
      if item.skill_req.is_a?(Array)
        for i in 0...item.skill_req.size
          if not @skills.include?(item.skill_req[i])
            return false
          end
        end
      else # Integer
        if not @skills.include?(item.skill_req)
          return false
        end
      end
    end
    if (item.item_req != nil and self.is_a?(Game_Actor))
      if item.item_req.is_a?(Array)
        for i in 0...item.item_req.size
          if not $game_party.item_number(item.item_req[i]) > 0
            return false
          end
        end
      else # Integer
        if not $game_party.item_number(item.item_req) > 0
          return false
        end
      end
    end
    if item.armor_req != nil
      if item.armor_req.is_a?(Array)
        if not (item.armor_req.include?(@armor1_id) or
          item.armor_req.include?(@armor2_id) or
          item.armor_req.include?(@armor3_id) or
          item.armor_req.include?(@armor4_id) )
          return false
        end
      else # Integer
        if @armor1_id != item.weapon_req and @armor2_id != item.weapon_req and
          @armor3_id != item.weapon_req and @armor4_id != item.weapon_req
          return false
        end
      end
    end
    return true
  end
 
  def animation1_id
    weapon = $data_weapons[@weapon_id]
    if weapon != nil
      return weapon.animation1_id
    end
    return $data_enemies[@enemy_id].animation1_id
  end

  def animation2_id
    weapon = $data_weapons[@weapon_id]
    if weapon != nil
      return weapon.animation2_id
    end
    return $data_enemies[@enemy_id].animation2_id
  end
 
  def base_atk
    weapon = $data_weapons[@weapon_id]
    new_atk = weapon != nil ? weapon.atk : 0
    return [$data_enemies[@enemy_id].atk, new_atk].max
  end

  def base_pdef
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    pdef1 = weapon != nil ? weapon.pdef : 0
    pdef2 = armor1 != nil ? armor1.pdef : 0
    pdef3 = armor2 != nil ? armor2.pdef : 0
    pdef4 = armor3 != nil ? armor3.pdef : 0
    pdef5 = armor4 != nil ? armor4.pdef : 0
    return [$data_enemies[@enemy_id].pdef, pdef1+pdef2+pdef3+pdef4+pdef5].max
  end

  def base_mdef
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    mdef1 = weapon != nil ? weapon.mdef : 0
    mdef2 = armor1 != nil ? armor1.mdef : 0
    mdef3 = armor2 != nil ? armor2.mdef : 0
    mdef4 = armor3 != nil ? armor3.mdef : 0
    mdef5 = armor4 != nil ? armor4.mdef : 0
    return [$data_enemies[@enemy_id].mdef, mdef1+mdef2+mdef3+mdef4+mdef5].max
  end

  def base_eva
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    eva1 = armor1 != nil ? armor1.eva : 0
    eva2 = armor2 != nil ? armor2.eva : 0
    eva3 = armor3 != nil ? armor3.eva : 0
    eva4 = armor4 != nil ? armor4.eva : 0
    return [$data_enemies[@enemy_id].eva, eva1 + eva2 + eva3 + eva4].max
  end
end

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
 
  def setup(actor_id)
    super(actor_id)
    @enemy_id = get_enemy_id
  end

  def get_enemy_id
    return ERON::EMPTY_ENEMY_ID
  end
 
  def base_maxhp(level=@level)
    return $data_actors[@actor_id].parameters[0, level]
  end

  def base_maxsp(level=@level)
    return $data_actors[@actor_id].parameters[1, level]
  end
 
  unless $@
    alias module_eron_str base_str
    alias module_eron_dex base_dex
    alias module_eron_agi base_agi
    alias module_eron_int base_int
  end
 
  def base_str(level=0)
    return $data_actors[@actor_id].parameters[2, level] if level != 0
    module_eron_str
  end

  def base_dex(level=0)
    return $data_actors[@actor_id].parameters[3, level] if level != 0
    module_eron_dex
  end
 
  def base_agi(level=0)
    return $data_actors[@actor_id].parameters[4, level] if level != 0
    module_eron_agi
  end

  def base_int(level=0)
    return $data_actors[@actor_id].parameters[5, level] if level != 0
    module_eron_int
  end
 
  def req_exp(level)
    return @exp_list[level]
  end
 
  def req_exp_rest(level)
    req_exp = req_exp(level)
    return 0 if req_exp < @exp
    return req_exp - @exp
  end
 
  def equippable?(item)
    super(item)
  end
 
  def enemy_element_rate(element_id)
    table = [0,200,150,100,50,0,-100]
    result = table[$data_enemies[@enemy_id].element_ranks[element_id]]
    for i in @states
      if $data_states[i].guard_element_set.include?(element_id)
        result /= 2
      end
    end
    return result
  end
 
  def enemy_state_ranks
    return $data_enemies[@enemy_id].state_ranks
  end
 
  def base_atk
    super
  end

  def base_pdef
    super
  end

  def base_mdef
    super
  end

  def base_eva
    super
  end
 
  def animation1_id
    super
  end

  def animation2_id
    super
  end
end

#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemies. It's used within the Game_Troop class
#  ($game_troop).
#==============================================================================

class Game_Enemy < Game_Battler
 
  attr_reader  :actor_id
  attr_reader  :character_name
  attr_reader  :character_hue
  attr_reader  :class_id
  attr_reader  :weapon_id
  attr_reader  :armor1_id
  attr_reader  :armor2_id
  attr_reader  :armor3_id
  attr_reader  :armor4_id
  attr_reader  :level
  attr_reader  :skills
  attr_reader  :troop_id
  attr_reader  :member_index
  attr_reader  :enemy_id
 
  def initialize(troop_id, member_index, level=1)
    @troop_id = troop_id
    @member_index = member_index
    troop = $data_troops[@troop_id]
    @enemy_id = troop.members[@member_index].enemy_id
    enemy = $data_enemies[@enemy_id]
    @actor_id = get_actor_id
    super()
    setup(@actor_id)
    @level = level
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @hidden = troop.members[@member_index].hidden
    @immortal = troop.members[@member_index].immortal
    @hp = maxhp
    @sp = maxsp
  end

  def get_actor_id
    return ERON::EMPTY_ACTOR_ID
  end

  def setup(actor_id)
    super(actor_id)
  end
 
  def make_exp_list
    actor = $data_actors[@actor_id]
    @exp_list[1] = 0
    pow_i = 2.4 + actor.exp_inflation / 100.0
    for i in 2..100
      if i > actor.final_level
        @exp_list[i] = 0
      else
        n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)
        @exp_list[i] = @exp_list[i-1] + Integer(n)
      end
    end
  end

  def class_name
    return $data_classes[@class_id].name
  end
 
  def class_element_rate(element_id)
    table = [0,200,150,100,50,0,-100]
    result = table[$data_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
 
  def class_state_ranks
    return $data_classes[@class_id].state_ranks
  end
 
  def state_guard?(state_id)
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
      armor = $data_armors[i]
      if armor != nil
        if armor.guard_state_set.include?(state_id)
          return true
        end
      end
    end
    return false
  end
 
  def element_set
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.element_set : []
  end

  def plus_state_set
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.plus_state_set : []
  end

  def minus_state_set
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.minus_state_set : []
  end

  def base_maxhp(level=@level)
    return $data_enemies[@enemy_id].maxhp if level == 1
    return $data_actors[@actor_id].parameters[0, level]
  end
 
  def base_maxsp(level=@level)
    return $data_enemies[@enemy_id].maxsp if level == 1
    return $data_actors[@actor_id].parameters[1, level]
  end
 
  def base_str(level=0)
    if @level == 1
      n = $data_enemies[@enemy_id].str
    else
      n = $data_actors[@actor_id].parameters[2, @level]
    end
    return $data_actors[@actor_id].parameters[2, level] if level != 0
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.str_plus : 0
    n += armor1 != nil ? armor1.str_plus : 0
    n += armor2 != nil ? armor2.str_plus : 0
    n += armor3 != nil ? armor3.str_plus : 0
    n += armor4 != nil ? armor4.str_plus : 0
    return [[n, 1].max, 999].min
  end
 
  def base_dex(level=0)
    if @level == 1
      n = $data_enemies[@enemy_id].dex
    else
      n = $data_actors[@actor_id].parameters[3, @level]
    end
    return $data_actors[@actor_id].parameters[3, level] if level != 0
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.dex_plus : 0
    n += armor1 != nil ? armor1.dex_plus : 0
    n += armor2 != nil ? armor2.dex_plus : 0
    n += armor3 != nil ? armor3.dex_plus : 0
    n += armor4 != nil ? armor4.dex_plus : 0
    return [[n, 1].max, 999].min
  end

  def base_agi(level=0)
    if @level == 1
      n = $data_enemies[@enemy_id].agi
    else
      n = $data_actors[@actor_id].parameters[4, @level]
    end
    return $data_actors[@actor_id].parameters[4, level] if level != 0
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.agi_plus : 0
    n += armor1 != nil ? armor1.agi_plus : 0
    n += armor2 != nil ? armor2.agi_plus : 0
    n += armor3 != nil ? armor3.agi_plus : 0
    n += armor4 != nil ? armor4.agi_plus : 0
    return [[n, 1].max, 999].min
  end

  def base_int(level=0)
    if @level == 1
      n = $data_enemies[@enemy_id].int
    else
      n = $data_actors[@actor_id].parameters[5, @level]
    end
    return $data_actors[@actor_id].parameters[5, level] if level != 0
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.int_plus : 0
    n += armor1 != nil ? armor1.int_plus : 0
    n += armor2 != nil ? armor2.int_plus : 0
    n += armor3 != nil ? armor3.int_plus : 0
    n += armor4 != nil ? armor4.int_plus : 0
    return [[n, 1].max, 999].min
  end
 
  def base_atk
    super
  end

  def base_pdef
    super
  end

  def base_mdef
    super
  end

  def base_eva
    super
  end
 
  def animation1_id
    super
  end

  def animation2_id
    super
  end

  def update_auto_state(old_armor, new_armor)
    if old_armor != nil and old_armor.auto_state_id != 0
      remove_state(old_armor.auto_state_id, true)
    end
    if new_armor != nil and new_armor.auto_state_id != 0
      add_state(new_armor.auto_state_id, true)
    end
  end

  def equip(equip_type, id)
    case equip_type
    when 0  # Weapon
      @weapon_id = id
    when 1  # Shield
      update_auto_state($data_armors[@armor1_id], $data_armors[id])
      @armor1_id = id
    when 2  # Head
      update_auto_state($data_armors[@armor2_id], $data_armors[id])
      @armor2_id = id
    when 3  # Body
      update_auto_state($data_armors[@armor3_id], $data_armors[id])
      @armor3_id = id
    when 4  # Accessory
      update_auto_state($data_armors[@armor4_id], $data_armors[id])
      @armor4_id = id
    end
  end
 
  def level=(level)
    @level = [[level, $data_actors[@actor_id].final_level].min, 1].max
  end

  def learn_skill(skill_id)
    if skill_id > 0 and not skill_learn?(skill_id)
      @skills.push(skill_id)
      @skills.sort!
    end
  end
 
  def forget_skill(skill_id)
    @skills.delete(skill_id)
  end

  def skill_learn?(skill_id)
    return @skills.include?(skill_id)
  end

  def skill_can_use?(skill_id)
    if not skill_learn?(skill_id)
      return false
    end
    return super
  end

  def name=(name)
    @name = name
  end

  def class_id=(class_id)
    if $data_classes[class_id] != nil
      @class_id = class_id
    end
  end

  def set_graphic(character_name, character_hue, battler_name, battler_hue)
    @character_name = character_name
    @character_hue = character_hue
    @battler_name = battler_name
    @battler_hue = battler_hue
  end

  def exp
    return $data_enemies[@enemy_id].exp if @level == 1
    return @exp_list[@level]
  end

  def gold
    return $data_enemies[@enemy_id].gold
  end

  def item_id
    item_array = [$data_enemies[@enemy_id].item_id]
    return item_array
  end

  def weapon_id
    weapon_array = [@weapon_id, $data_enemies[@enemy_id].weapon_id]
    return weapon_array
  end

  def armor_id
    armor_array = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
    armor_array.push($data_enemies[@enemy_id].armor_id)
    return armor_array
  end

  def treasure_prob
    return $data_enemies[@enemy_id].treasure_prob
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  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.size > 0
            enemy.item_id.each {|id| treasures.push($data_items[id])}
          end
          if enemy.weapon_id.size > 0
            enemy.weapon_id.each {|id| treasures.push($data_weapons[id])}
          end
          if enemy.armor_id.size > 0
            enemy.armor_id.each {|id| treasures.push($data_armors[id])}
          end
        end
      end
    end
    treasures.compact!
    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
        if actor.level > last_level
          @status_window.level_up(i)
        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

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================

class Game_Party
  attr_reader :items
  attr_reader :weapons
  attr_reader :armors
 
  unless $@
    alias module_eron_add_actor add_actor
    alias module_eron_remove_actor remove_actor
    alias module_eron_item_number item_number
    alias module_eron_weapon_number weapon_number
    alias module_eron_armor_number armor_number
    alias module_eron_gain_item gain_item
    alias module_eron_gain_weapon gain_weapon
    alias module_eron_gain_armor gain_armor
  end
   
  def add_actor(actor)
    actor_id = actor.is_a?(Game_Actor) ? actor.id : actor
    module_eron_add_actor(actor_id)
  end
 
  def remove_actor(actor)
    actor_id = actor.is_a?(Game_Actor) ? actor.id : actor
    module_eron_remove_actor(actor_id)
  end
 
  def item_number(item)
    item_id = item.is_a?(RPG::Item) ? item.id : item
    module_eron_item_number(item_id)
  end
 
  def weapon_number(weapon)
    weapon_id = weapon.is_a?(RPG::Weapon) ? weapon.id : weapon
    module_eron_weapon_number(weapon_id)
  end

  def armor_number(armor)
    armor_id = armor.is_a?(RPG::Armor) ? armor.id : armor
    module_eron_armor_number(armor_id)
  end

  def weapon_total_number(weapon)
    weapon_id = weapon.is_a?(RPG::Weapon) ? weapon.id : weapon
    number = weapon_number(weapon_id)
    for actor in @actors
      number += 1 if actor.weapon_id == weapon_id
    end
    return number
  end
 
  def armor_total_number(armor)
    armor_id = armor.is_a?(RPG::Armor) ? armor.id : armor
    number = armor_number(armor_id)
    armor = $data_armors[armor_id]
    for actor in @actors
      number += 1 if actor.send("armor#{armor.kind+1}_id") == armor_id
    end
    return number
  end
 
  def gain_item(item, n)
    item_id = item.is_a?(RPG::Item) ? item.id : item
    module_eron_gain_item(item_id, n)
  end

  def gain_weapon(weapon, n)
    weapon_id = weapon.is_a?(RPG::Weapon) ? weapon.id : weapon
    module_eron_gain_weapon(weapon_id, n)
  end

  def gain_armor(armor, n)
    armor_id = armor.is_a?(RPG::Armor) ? armor.id : armor
    module_eron_gain_armor(armor_id, n)
  end
 
  def item_keys
    keys = []
    for i in 0...@items.to_a.sort.size
      keys.push @items.to_a.sort[i][0]
    end
    return keys
  end
   
  def item_values
    values = []
    for i in 0...@items.to_a.sort.size
      values.push @items.to_a.sort[i][0]
    end
    return values
  end
 
  def weapon_keys
    keys = []
    for i in 0...@weapons.to_a.sort.size
      keys.push @weapons.to_a.sort[i][0]
    end
    return keys
  end
 
  def weapon_values
    values = []
    for i in 0...@weapons.to_a.sort.size
      values.push @weapons.to_a.sort[i][0]
    end
    return values
  end
 
  def armor_keys
    keys = []
    for i in 0...@armors.to_a.sort.size
      keys.push @armors.to_a.sort[i][0]
    end
    return keys
  end
   
  def armor_values
    values = []
    for i in 0...@armors.to_a.sort.size
      values.push @armors.to_a.sort[i][0]
    end
    return values
  end
end
Edito: Lo he cambiado un poco pero nada importante =D
Doy las gracias a Wecoc que me ayudó con un método por MP.
avatar
Eron
Principiante
Principiante

0/3

Créditos 3599

Gracias : 60

Volver arriba Ir abajo

RPG Maker XP Re: [XP] ERON module

Mensaje por Eron el 2013-10-11, 07:47

He vuelto a cambiar un poco el código, había algún error pero cosas insignificantes x'D

Por cierto me preguntaron para qué sirve ésto, se ve que no quedó demasiado claro.

La idea era dar soporte de IDs y éstas cosas para hacer otros scripts, luego editaré y os comentaré más exactamente los scripts que tenía pensado que se podrían lograr partiendo de éste, ahora no tengo la copia donde puse esos ejemplos, pero igualmente algunos ya los hice.

La idea era poder hacer que objetos pudieran funcionar por ID de una manera similar a los actor. También, que los Actor tuvieran un atajo hacia los Enemy y los Enemy hacia los Actor, es laborioso pero para montar bien ERON module con lo que tenía pensado lo ideal sería dejar un hueco en la Database - Actors para cada uno de los monstruos o tipos de monstruo, y dejar un hueco en la Database - Enemies para cada uno de los Actors.

¿Qué conseguimos con eso?

- Enemigos con equipo. Equipo inicial, clase (que define lo que pueden equipar y lo que no), etc.
- Enemigos con posibilidad de tener distintos niveles, y parámetros según esos niveles como cualquier Actor.
- Items, Weapons y Armors con requerimientos extra.

- Treasures de los enemigos dependiendo de su treasure normal, su nivel y su equipo, o incluso específicos para el enemigo en concreto.
- Debilidad a estados ampliada tanto en Actors como en Enemies; ataque y defensa. Me explico; las de Database - Class podrían ser las usadas en la fórmula de ataque (por ejemplo el actor A puede ser muy fuerte haciendo ataques de Fuego) y las de Database - Enemy podrían ser las de la fórmula de defensa (por ejemplo al mismo actor A le hacen mucho daño los ataques de Hielo)
- Items con durabilidad u otros parámetros propios de cada uno. (Se podría hacer un sistema de herrería)


Verde - El module por sí solo ya soporta éso.
Azul - Requiere hacer otro script pero el module le da la base para poder hacerlo más fácilmente.


Vendrían a ser más o menos éstas mejoras, entre otras.
Espero que se entienda un poco mejor el por qué de éste código ahora.
Quizá aún le falte sacarle brillo en algunos aspectos pero es solo un módulo con el que usar otros scripts encima x'D
avatar
Eron
Principiante
Principiante

0/3

Créditos 3599

Gracias : 60

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba


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