#==============================================================================
# ** Game_Battler (part 1)
#------------------------------------------------------------------------------
# Questa classe si occupa dei combattenti di gioco. E' figa! xD
# E' considerata come una superclasse per le classi Game_Actor e Game_Enemy
# a cui fanno riferimento.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Variabili di istanza pubblica
#--------------------------------------------------------------------------
attr_reader :battler_name # Nome del file battler #guerriero
attr_reader :battler_hue # tonalità del battler #guerriero
attr_reader :hp # HP #capacità vitale
attr_reader :sp # SP #capacità magica
attr_reader :states # stati
attr_accessor :hidden # mostra stato "nascosto"
attr_accessor :immortal # mostra stato "immortale"
attr_accessor :damage_pop # mostra a video il danno subito
attr_accessor :damage # valore del danno
attr_accessor :critical # mostra "condizione critica"
attr_accessor :animation_id # Codice dell'animazione
attr_accessor :animation_hit # mostra l'animazione del colpo
attr_accessor :white_flash # mostra bagliore bianco
attr_accessor :blink # mostra stato "accecato"
#--------------------------------------------------------------------------
# * Metodo per associare i parametri di base alle variabili appena create
#--------------------------------------------------------------------------
def initialize
@battler_name = ""
@battler_hue = 0
@hp = 0
@sp = 0
@states = []
@states_turn = {}
@maxhp_plus = 0
@maxsp_plus = 0
@str_plus = 0
@dex_plus = 0
@agi_plus = 0
@int_plus = 0
@hidden = false
@immortal = false
@damage_pop = false
@damage = nil
@critical = false
@animation_id = 0
@animation_hit = false
@white_flash = false
@blink = false
@current_action = Game_BattleAction.new
end
#--------------------------------------------------------------------------
# * Metodo per ottenere gli HP massimi
#--------------------------------------------------------------------------
def maxhp
n = [[base_maxhp + @maxhp_plus, 1].max, 999999].min
for i in @states
n *= $data_states[i].maxhp_rate / 100.0
end
n = [[Integer(n), 1].max, 999999].min
return n
end
#--------------------------------------------------------------------------
# * Metodo per ottenere gli SP massimi
#--------------------------------------------------------------------------
def maxsp
n = [[base_maxsp + @maxsp_plus, 0].max, 9999].min
for i in @states
n *= $data_states[i].maxsp_rate / 100.0
end
n = [[Integer(n), 0].max, 9999].min
return n
end
#--------------------------------------------------------------------------
# * Metodo per ottenere la Forza (STR)
#--------------------------------------------------------------------------
def str
n = [[base_str + @str_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].str_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Metodo per ottenere la Destrezza (DEX)
#--------------------------------------------------------------------------
def dex
n = [[base_dex + @dex_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].dex_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Metodo per ottenere l'Agilità (AGI)
#--------------------------------------------------------------------------
def agi
n = [[base_agi + @agi_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].agi_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Metodo per ottenere l'intelligenza (INT)
#--------------------------------------------------------------------------
def int
n = [[base_int + @int_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].int_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Metodo per selezionare gli HP massimi
# maxhp : nuovi HP massimi
#--------------------------------------------------------------------------
def maxhp=(maxhp)
@maxhp_plus += maxhp - self.maxhp
@maxhp_plus = [[@maxhp_plus, -9999].max, 9999].min
@hp = [@hp, self.maxhp].min
end
#--------------------------------------------------------------------------
# * Metodo per selezionare gli SP massimi
# maxsp : nuovi SP massimi
#--------------------------------------------------------------------------
def maxsp=(maxsp)
@maxsp_plus += maxsp - self.maxsp
@maxsp_plus = [[@maxsp_plus, -9999].max, 9999].min
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# * Metodo per selezionare la Forza (STR)
# str : nuova Forza (STR)
#--------------------------------------------------------------------------
def str=(str)
@str_plus += str - self.str
@str_plus = [[@str_plus, -999].max, 999].min
end
#--------------------------------------------------------------------------
# * Metodo per selezionare la Destrezza (DEX)
# dex : nuova Destrezza (DEX)
#--------------------------------------------------------------------------
def dex=(dex)
@dex_plus += dex - self.dex
@dex_plus = [[@dex_plus, -999].max, 999].min
end
#--------------------------------------------------------------------------
# * Metodo per selezionare l'Agilità (AGI)
# agi : nuova Agilità (AGI)
#--------------------------------------------------------------------------
def agi=(agi)
@agi_plus += agi - self.agi
@agi_plus = [[@agi_plus, -999].max, 999].min
end
#--------------------------------------------------------------------------
# * Metodo per selezionare l'intelligenza (INT)
# int : nuova intelligenza (INT)
#--------------------------------------------------------------------------
def int=(int)
@int_plus += int - self.int
@int_plus = [[@int_plus, -999].max, 999].min
end
#--------------------------------------------------------------------------
# * Metodo per ottenere la percentuale del colpo (Hit)
#--------------------------------------------------------------------------
def hit
n = 100
for i in @states
n *= $data_states[i].hit_rate / 100.0
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Metodo per ottenere la potenza d'attacco
#--------------------------------------------------------------------------
def atk
n = base_atk
for i in @states
n *= $data_states[i].atk_rate / 100.0
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Metodo per ottenere la potenza espressa in difesa fisica
#--------------------------------------------------------------------------
def pdef
n = base_pdef
for i in @states
n *= $data_states[i].pdef_rate / 100.0
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Metodo per ottenere la potenza espressa in difesa magica
#--------------------------------------------------------------------------
def mdef
n = base_mdef
for i in @states
n *= $data_states[i].mdef_rate / 100.0
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Metodo per ottenere la possibilità di fuggire da una battaglia
#--------------------------------------------------------------------------
def eva
n = base_eva
for i in @states
n += $data_states[i].eva
end
return n
end
#--------------------------------------------------------------------------
# * Metodo per cambiare HP
# hp : nuovi HP
#--------------------------------------------------------------------------
def hp=(hp)
@hp = [[hp, maxhp].min, 0].max
# aggiunge o esclude l'inabilità
for i in 1...$data_states.size
if $data_states[i].zero_hp
if self.dead?
add_state(i)
else
remove_state(i)
end
end
end
end
#--------------------------------------------------------------------------
# * Metodo per cambiare SP
# sp : nuovi SP
#--------------------------------------------------------------------------
def sp=(sp)
@sp = [[sp, maxsp].min, 0].max
end
#--------------------------------------------------------------------------
# * Metodo che permette di curare tutti i membri del party
#--------------------------------------------------------------------------
def recover_all
@hp = maxhp
@sp = maxsp
for i in @states.clone
remove_state(i)
end
end
#--------------------------------------------------------------------------
# * Metodo che permette di ottenere l'azione corrente
#--------------------------------------------------------------------------
def current_action
return @current_action
end
#--------------------------------------------------------------------------
# * Metodo per determinare la velocità d'azione
#--------------------------------------------------------------------------
def make_action_speed
@current_action.speed = agi + rand(10 + agi / 4)
end
#--------------------------------------------------------------------------
# * Metodo che serve per definire la Morte (incapacità di agire)
#--------------------------------------------------------------------------
def dead?
return (@hp == 0 and not @immortal)
end
#--------------------------------------------------------------------------
# * Metodo che serve per definire l'esistenza (capacità di agire)
#--------------------------------------------------------------------------
def exist?
return (not @hidden and (@hp > 0 or @immortal))
end
#--------------------------------------------------------------------------
# * Metodo che serve per definire HP 0
#--------------------------------------------------------------------------
def hp0?
return (not @hidden and @hp == 0)
end
#--------------------------------------------------------------------------
# * Metodo che definisce se un comando può essere eseguito
#--------------------------------------------------------------------------
def inputable?
return (not @hidden and restriction <= 1)
end
#--------------------------------------------------------------------------
# * Metodo che definisce se un'azione può essere possibile
#--------------------------------------------------------------------------
def movable?
return (not @hidden and restriction < 4)
end
#--------------------------------------------------------------------------
# * Metodo che definisce se si è in guardia
#--------------------------------------------------------------------------
def guarding?
return (@current_action.kind == 0 and @current_action.basic == 1)
end
#--------------------------------------------------------------------------
# * Metodo che definisce se si è capaci di resistere
#--------------------------------------------------------------------------
def resting?
return (@current_action.kind == 0 and @current_action.basic == 3)
end
end