#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# By Valentine
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Variáveis Públicas
#--------------------------------------------------------------------------
attr_reader :friends
attr_reader :hotkey
attr_reader :exp_list
attr_accessor :skills
attr_accessor :character_hair
attr_accessor :character_name
attr_accessor :character_hue
attr_accessor :class_id
attr_accessor :weapon_id
attr_accessor :armor1_id
attr_accessor :armor2_id
attr_accessor :armor3_id
attr_accessor :armor4_id
attr_accessor :armor5_id
attr_accessor :armor6_id
attr_accessor :armor7_id
attr_accessor :armor8_id
attr_accessor :guild
attr_accessor :guild_position
attr_accessor :guild_flag
attr_accessor :ban
attr_accessor :group
attr_accessor :gender
attr_accessor :points
attr_accessor :respawn_map
attr_accessor :respawn_x
attr_accessor :respawn_y
#--------------------------------------------------------------------------
# * Opções
#
# actor_id : ID do Herói
#--------------------------------------------------------------------------
def setup(actor_id)
actor = $data_actors[actor_id]
@actor_id = actor_id
@name = actor.name
@character_hair = ""
@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
@armor5_id = 0
@armor6_id = 0
@armor7_id = 0
@armor8_id = 0
@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
@guild = ""
@guild_position = 0
@guild_flag = 0
@respawn_map = Config::GAME_OVER_MAP
@respawn_x = Config::GAME_OVER_X
@respawn_y = Config::GAME_OVER_Y
@ban = 0
@group = ""
@gender = 0
@points = 0
@friends = []
@hotkey = []
# Uso de Habilidades
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
# Atualização automática do Status
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])
update_auto_state(nil, $data_armors[@armor5_id])
update_auto_state(nil, $data_armors[@armor6_id])
update_auto_state(nil, $data_armors[@armor7_id])
update_auto_state(nil, $data_armors[@armor8_id])
end
#--------------------------------------------------------------------------
# * Cálculo sobre os Atributos
#
# element_id : ID do elemento
#--------------------------------------------------------------------------
def element_rate(element_id)
# Uso do valor numérico correspondente ao grau do atributo (A,B,C,D,E,F)
table = [0, 200, 150, 100, 50, 0, -100]
result = table[$data_classes[@class_id].element_ranks[element_id]]
# Dividir por 2 se há uma proteção física contra o elemento
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, @armor5_id, @armor6_id, @armor7_id, @armor8_id]
armor = $data_armors[i]
if armor != nil and armor.guard_element_set.include?(element_id)
result /= 2
end
end
# Dividir por 2 se há uma proteção de atributo contra o elemento
for i in @states
if $data_states[i].guard_element_set.include?(element_id)
result /= 2
end
end
# Cálculo final
return result
end
#--------------------------------------------------------------------------
# * Verificação do Status do Defensor
#
# state_id : ID do status
#--------------------------------------------------------------------------
def state_guard?(state_id)
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, @armor5_id, @armor6_id, @armor7_id, @armor8_id]
armor = $data_armors[i]
if armor != nil
if armor.guard_state_set.include?(state_id)
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# * Verificação do Nível
#--------------------------------------------------------------------------
def get_level(id, item_id, viewlevel = false)
case id
when 0 # Arma
return 0 if Config::WEAPON_LEVEL.size == 0
for i in 0..Config::WEAPON_LEVEL.size-1
return Config::WEAPON_LEVEL[i][1] if @level < Config::WEAPON_LEVEL[i][1] or viewlevel and item_id == Config::WEAPON_LEVEL[i][0]
end
when 1..8 # Escudo, elmo, armadura, acessório, capa, luva, amuleto e bota
return 0 if Config::ARMOR_LEVEL.size == 0
for i in 0..Config::ARMOR_LEVEL.size-1
return Config::ARMOR_LEVEL[i][1] if @level < Config::ARMOR_LEVEL[i][1] or viewlevel and item_id == Config::ARMOR_LEVEL[i][0]
end
when 9 # Item
return 0 if Config::ITEM_LEVEL.size == 0
for i in 0..Config::ITEM_LEVEL.size-1
return Config::ITEM_LEVEL[i][1] if @level < Config::ITEM_LEVEL[i][1] or viewlevel and item_id == Config::ITEM_LEVEL[i][0]
end
end
return 0
end
#--------------------------------------------------------------------------
# * Troca de Equipamento
#
# equip_type : tipo de Equipamento
# id : ID das Armas ou Protetores, se for 0 o Equipamento foi removido
#--------------------------------------------------------------------------
def equip(equip_type, id)
if get_level(equip_type, id) > 0
case equip_type
when 0 # Armas
Game_Chat.add("#{Vocab::NOT_REQ_LEVEL} #{$data_weapons[id].name}.", Config::ERROR_COLOR)
when 1..8 # Escudo, elmo, armadura, acessório, capa, luva, amuleto e bota
Game_Chat.add("#{Vocab::NOT_REQ_LEVEL} #{$data_armors[id].name}.", Config::ERROR_COLOR)
end
$game_system.se_play($data_system.buzzer_se)
return
end
case equip_type
when 0 # Armas
if id == 0 or $game_party.weapon_number(id) > 0
$game_party.gain_weapon(@weapon_id, 1)
@weapon_id = id
$game_party.lose_weapon(id, 1)
end
when 1 # Escudo
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor1_id], $data_armors[id])
$game_party.gain_armor(@armor1_id, 1)
@armor1_id = id
$game_party.lose_armor(id, 1)
end
when 2 # Elmo
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor2_id], $data_armors[id])
$game_party.gain_armor(@armor2_id, 1)
@armor2_id = id
$game_party.lose_armor(id, 1)
end
when 3 # Armadura
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor3_id], $data_armors[id])
$game_party.gain_armor(@armor3_id, 1)
@armor3_id = id
$game_party.lose_armor(id, 1)
end
when 4 # Acessório
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor4_id], $data_armors[id])
$game_party.gain_armor(@armor4_id, 1)
@armor4_id = id
$game_party.lose_armor(id, 1)
end
when 5 # Capa
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor5_id], $data_armors[id])
$game_party.gain_armor(@armor5_id, 1)
@armor5_id = id
$game_party.lose_armor(id, 1)
end
when 6 # Bota
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor6_id], $data_armors[id])
$game_party.gain_armor(@armor6_id, 1)
@armor6_id = id
$game_party.lose_armor(id, 1)
end
when 7 # Amuleto
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor7_id], $data_armors[id])
$game_party.gain_armor(@armor7_id, 1)
@armor7_id = id
$game_party.lose_armor(id, 1)
end
when 8 # Luva
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor8_id], $data_armors[id])
$game_party.gain_armor(@armor8_id, 1)
@armor8_id = id
$game_party.lose_armor(id, 1)
end
end
return unless $scene.is_a?(Scene_Map)
$scene.equip_window.refresh
Network.send_visual_equip(equip_type)
$game_system.se_play($data_system.equip_se)
end
#--------------------------------------------------------------------------
# * Troca do ID de Classe
#
# class_id : ID da classe
#--------------------------------------------------------------------------
def class_id=(class_id)
if $data_classes[class_id] != nil
@class_id = class_id
# Equipamento que a classe não permite é removido
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
unless equippable?($data_armors[@armor5_id])
equip(5, 0)
end
unless equippable?($data_armors[@armor6_id])
equip(6, 0)
end
unless equippable?($data_armors[@armor7_id])
equip(7, 0)
end
unless equippable?($data_armors[@armor8_id])
equip(8, 0)
end
end
end
#--------------------------------------------------------------------------
# * Definição da Base de MaxHP
#--------------------------------------------------------------------------
def base_maxhp
restore_parameter if $data_actors[@actor_id].parameters[0, @level] == nil
return $data_actors[@actor_id].parameters[0, @level]
end
#--------------------------------------------------------------------------
# * Definição da Base de MaxSP
#--------------------------------------------------------------------------
def base_maxsp
restore_parameter if $data_actors[@actor_id].parameters[1, @level] == nil
return $data_actors[@actor_id].parameters[1, @level]
end
#--------------------------------------------------------------------------
# * Definição da Base de Ataque
#--------------------------------------------------------------------------
def base_str
restore_parameter if $data_actors[@actor_id].parameters[2, @level] == nil
n = $data_actors[@actor_id].parameters[2, @level]
weapon = $data_weapons[@weapon_id]
n += weapon != nil ? weapon.str_plus : 0
for i in 1..8
eval("armor = $data_armors[@armor#{i}_id]; n += armor != nil ? armor.str_plus : 0")
end
if Config::POINTS
n -= $data_actors[@actor_id].parameters[2, @level]
n += $data_actors[@actor_id].parameters[2, 1]
end
return [[n, 1].max, Config::MAX_STR].min
end
#--------------------------------------------------------------------------
# * Definição da Base de Defesa
#--------------------------------------------------------------------------
def base_dex
restore_parameter if $data_actors[@actor_id].parameters[3, @level] == nil
n = $data_actors[@actor_id].parameters[3, @level]
weapon = $data_weapons[@weapon_id]
n += weapon != nil ? weapon.dex_plus : 0
for i in 1..8
eval("armor = $data_armors[@armor#{i}_id]; n += armor != nil ? armor.dex_plus : 0")
end
if Config::POINTS
n -= $data_actors[@actor_id].parameters[3, @level]
n += $data_actors[@actor_id].parameters[3, 1]
end
return [[n, 1].max, Config::MAX_DEX].min
end
#--------------------------------------------------------------------------
# * Definição da Base de Agilidade
#--------------------------------------------------------------------------
def base_agi
restore_parameter if $data_actors[@actor_id].parameters[4, @level] == nil
n = $data_actors[@actor_id].parameters[4, @level]
weapon = $data_weapons[@weapon_id]
n += weapon != nil ? weapon.agi_plus : 0
for i in 1..8
eval("armor = $data_armors[@armor#{i}_id]; n += armor != nil ? armor.agi_plus : 0")
end
if Config::POINTS
n -= $data_actors[@actor_id].parameters[4, @level]
n += $data_actors[@actor_id].parameters[4, 1]
end
return [[n, 1].max, Config::MAX_AGI].min
end
#--------------------------------------------------------------------------
# * Definição da Base de Inteligência
#--------------------------------------------------------------------------
def base_int
restore_parameter if $data_actors[@actor_id].parameters[5, @level] == nil
n = $data_actors[@actor_id].parameters[5, @level]
weapon = $data_weapons[@weapon_id]
n += weapon != nil ? weapon.int_plus : 0
for i in 1..8
eval("armor = $data_armors[@armor#{i}_id]; n += armor != nil ? armor.int_plus : 0")
end
if Config::POINTS
n -= $data_actors[@actor_id].parameters[5, @level]
n += $data_actors[@actor_id].parameters[5, 1]
end
return [[n, 1].max, Config::MAX_INT].min
end
#--------------------------------------------------------------------------
# * Definição da Base de Defesa Física
#--------------------------------------------------------------------------
def base_pdef
pdef = 0
weapon = $data_weapons[@weapon_id]
pdef += weapon != nil ? weapon.pdef : 0
for i in 1..8
eval("armor = $data_armors[@armor#{i}_id]; pdef += armor != nil ? armor.pdef : 0")
end
return pdef
end
#--------------------------------------------------------------------------
# * Definição da Base de Defesa Mágica
#--------------------------------------------------------------------------
def base_mdef
mdef = 0
weapon = $data_weapons[@weapon_id]
mdef += weapon != nil ? weapon.mdef : 0
for i in 1..8
eval("armor = $data_armors[@armor#{i}_id]; mdef += armor != nil ? armor.mdef : 0")
end
return mdef
end
#--------------------------------------------------------------------------
# * Definição da Base de Esquiva
#--------------------------------------------------------------------------
def base_eva
eva = 0
for i in 1..8
eval("armor = $data_armors[@armor#{i}_id]; eva += armor != nil ? armor.eva : 0")
end
return eva
end
#--------------------------------------------------------------------------
# * Aumentar Parâmetros (By KGC)
#--------------------------------------------------------------------------
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..(Config::MAX_LEVELS + 1)
if i > Config::MAX_LEVELS
@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
#--------------------------------------------------------------------------
# * Troca da EXP
#
# exp : nova EXP
#--------------------------------------------------------------------------
def exp=(exp)
@exp = [[exp, Config::EXP_LIMIT].min, 0].max
last_level = @level
# Melhoramento
while @exp >= @exp_list[@level + 1] and @exp_list[@level + 1] > 0
@level += 1
# Habilidades são aprendidas conforme o nível
if $scene.is_a?(Scene_Map)
for j in $data_classes[@class_id].learnings
if j.level == @level
learn_skill(j.skill_id)
end
end
end
@points += Config::LEVEL_UP_POINTS if @level < Config::MAX_LEVELS and Config::POINTS
end
if last_level != @level
if $scene.is_a?(Scene_Map)
@hp = maxhp
@sp = maxsp
Network.send_animation(Config::ANIMATION) if @level < Config::MAX_LEVELS
$game_player.animation_id = Config::ANIMATION if @level < Config::MAX_LEVELS
if Config::POINTS
if @points > 0
$scene.status_window.refresh
$scene.status_window.visible = true
end
end
self.damage = Vocab::PLAYER_LEVEL_UP if @level < Config::MAX_LEVELS
Network.send_vitals if Network.socket != nil
$game_party.send_info
# Atualizar nível do herói
Network.socket.send("<5>@level = #{@level}</5>\n")
end
end
# Agravante
while @exp < @exp_list[@level]
@level -= 1
end
if @level >= 100
self.restore_parameter
end
# Aumento do HP e SP
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# * Restabelecer Parâmetro (By KGC)
#--------------------------------------------------------------------------
def restore_parameter
return if @level < 100
$data_actors[@actor_id].parameters.resize(6, @level + 1)
for k in 0..5
if $data_actors[@actor_id].parameters[k, @level] == 0
calc_text = Config::LV100_CALC
calc_text.gsub!(/lv/i) {"@level"}
calc_text.gsub!(/p\[(\d+)\]/i) {"$data_actors[@actor_id].parameters[k, #{$1.to_i}]"}
n = $data_actors[@actor_id].parameters[k, 99]
n += eval(calc_text)
$data_actors[@actor_id].parameters[k, @level] = [n, 32767].min
end
end
end
=begin
#--------------------------------------------------------------------------
# * Restabelecer Magias
#--------------------------------------------------------------------------
def restore_skills
@skills = []
# Uso de Habilidades
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
end
#--------------------------------------------------------------------------
# * Restabelecer Exp
#--------------------------------------------------------------------------
def restore_exp(actor_id)
@level = $data_actors[actor_id].initial_level
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
end
=end
#--------------------------------------------------------------------------
# * Definição do MaxHP
#--------------------------------------------------------------------------
def maxhp
n = [[base_maxhp + @maxhp_plus, 1].max, Config::MAX_HP].min
for i in @states
n *= $data_states[i].maxhp_rate / 100.0
end
n = [[Integer(n), 1].max, Config::MAX_HP].min
return n
end
#--------------------------------------------------------------------------
# * Troca de Nível
#
# level : novo Nível
#--------------------------------------------------------------------------
def level=(level)
# Se a quantidade de EXP foi alcançada
level = [[level, Config::MAX_LEVELS].min, 1].max
# Trocar EXP
self.exp = @exp_list[level]
end
#--------------------------------------------------------------------------
# * Troca de Gráficos
#
# character_name : nome do arquivo do novo herói
# character_hue : cor do novo herói (opcional)
# battler_name : nome do arquivo do novo battler (opcional)
# battler_hue : cor do novo battler (opcional)
#--------------------------------------------------------------------------
def set_graphic(character_name, character_hue = 0, battler_name = 0, battler_hue = 0)
@character_name = character_name
@character_hue = character_hue
@battler_name = battler_name
@battler_hue = battler_hue
return unless $scene.is_a?(Scene_Map)
$game_party.send_new_sprite
Network.send_character_name
end
#--------------------------------------------------------------------------
# * Troca de Cabelo
#
# character_hair : nome do arquivo do novo cabelo
#--------------------------------------------------------------------------
def set_hair(character_hair)
@character_hair = character_hair
return unless $scene.is_a?(Scene_Map)
$game_party.send_new_sprite
Network.send_character_name
end
#--------------------------------------------------------------------------
# * Troca de Ponto de Renascimento
#
# map : id do mapa
# x : coordenada x
# y : coordenada y
#--------------------------------------------------------------------------
def set_respawnpoint(map, x, y)
@respawn_map = map
@respawn_x = x
@respawn_y = y
Game_Netplay.autosave
end
#--------------------------------------------------------------------------
# * Atualização dos status
#--------------------------------------------------------------------------
def refresh_states(data)
eval(data)
end
#--------------------------------------------------------------------------
# * EXP atual
#--------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end
#--------------------------------------------------------------------------
# * EXP Necessária para o Próximo Nível.
#
# Definição da Sequência de Caracteres da EXP
#--------------------------------------------------------------------------
def next_exp
return @exp_list[@level + 1] > 0 ? @exp_list[@level + 1] - @exp_list[@level] : 0
end
end