#==============================================================================
# New Resistance Sustem
# By Atoa
#==============================================================================
# This script allows you to set an new style for elemental and status
# resistance.
# You can set resistances direct to actors (and not only to classes),
# and set increases/decreases of resistance to equipments and states.
# You can also set how the resistances will stack.
#==============================================================================
module Atoa
# Do not remove or change these lines
State_Resist = {}
Element_Resist = {}
# Do not remove or change these lines
# Resistance values.
# A , B , C , D , E , F
States_Table = [0, 100, 100, 80, 40, 0, 0]
# A , B , C , D , E, F
Element_Table = [0, 200, 150, 100, 50, 0, -100]
# Style of the resistance acumulation
Addition_Type = 0
# 0 = The values are added, considering all values
# 1 = The values are added, considering only the higher and the lower values
# 2 = The value used are the average, considering all values
# 3 = The value used are the average, considering only the higher and the lower values
# Element_Resist[Type] = {Type_ID => {Element_ID => Resist_Value}
# Type = type of the object that gives the resistance
# 'Actor' = actor's natural resistance
# 'State' = resistance given by states
# 'Armor' = resistance given by armors
# 'Weapon' = resistance given by weapons
# Type_ID = id of the actor, state, armor or weapon
# Element_ID = ID of the element that will have the value change
# Resist_Value = Resistance change value, must be an Integer.
# positive values are increases in resistance, negative are reductions.
# E.g.: an actor imune to fire equips an armor that gives -1 fire resistance
# will have the fire resistance changed from imune to resistant.
Element_Resist['Actor'] = {}
Element_Resist['State'] = {}
Element_Resist['Armor'] = {}
Element_Resist['Weapon'] = {}
# State_Resist[Type] = {Type_ID => {State_ID => Resist_Value}
# Type = type of the object that gives the resistance
# 'Actor' = actor's natural resistance
# 'State' = resistance given by states
# 'Armor' = resistance given by armors
# 'Weapon' = resistance given by weapons
# Type_ID = id of the actor, state, armor or weapon
# State_ID = ID of the state that will have the value change
# Resist_Value = Resistance change value, must be an Integer.
# positive values are increases in resistance, negative are reductions.
State_Resist['Actor'] = {}
State_Resist['State'] = {}
State_Resist['Armor'] = {}
State_Resist['Weapon'] = {}
#=============================================================================
end
#==============================================================================
# ■ Atoa Module
#==============================================================================
$atoa_script = {} if $atoa_script.nil?
$atoa_script['Atoa New Resistances'] = true
#==============================================================================
# ■ RPG::Weapon
#------------------------------------------------------------------------------
# Classe que gerencia as armas
#==============================================================================
class RPG::Weapon
#--------------------------------------------------------------------------
# Incluir modulo de configuração
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
# Resistencias elementais
#--------------------------------------------------------------------------
def element_resist
resist = Element_Resist.dup
set_element_resist = []
for i in 1...$data_system.elements.size
if resist['Weapon'] != nil && resist['Weapon'][@id] != nil &&
resist['Weapon'][@id][i] != nil
set_element_resist[i] = resist['Weapon'][@id][i]
else
set_element_resist[i] = 0
end
end
return set_element_resist
end
#--------------------------------------------------------------------------
# Resistencias contra efeitos
#--------------------------------------------------------------------------
def state_resist
resist = State_Resist.dup
set_state_resist = []
for i in 1...$data_states.size
if resist['Weapon'] != nil && resist['Weapon'][@id] != nil &&
resist['Weapon'][@id][i] != nil
set_state_resist[i] = resist['Weapon'][@id][i]
else
set_state_resist[i] = 0
end
end
return set_state_resist
end
end
#==============================================================================
# ■ RPG::Armor
#------------------------------------------------------------------------------
# Classe que gerencia as armaduras
#==============================================================================
class RPG::Armor
#--------------------------------------------------------------------------
# Incluir modulo de configuração
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
# Resistencias elementais
#--------------------------------------------------------------------------
def element_resist
resist = Element_Resist.dup
set_element_resist = []
for i in 1...$data_system.elements.size
if resist['Armor'] != nil && resist['Armor'][@id] != nil &&
resist['Armor'][@id][i] != nil
set_element_resist[i] = resist['Armor'][@id][i]
else
set_element_resist[i] = 0
end
end
return set_element_resist
end
#--------------------------------------------------------------------------
# Resistencias contra efeitos
#--------------------------------------------------------------------------
def state_resist
resist = State_Resist.dup
set_state_resist = []
for i in 1...$data_states.size
if resist['Armor'] != nil && resist['Armor'][@id] != nil &&
resist['Armor'][@id][i] != nil
set_state_resist[i] = resist['Armor'][@id][i]
else
set_state_resist[i] = 0
end
end
return set_state_resist
end
end
#==============================================================================
# ■ RPG::State
#------------------------------------------------------------------------------
# Classe que gerencia os efeitos
#==============================================================================
class RPG::State
#--------------------------------------------------------------------------
# Incluir modulo de configuração
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
# Resistencias elementais
#--------------------------------------------------------------------------
def element_resist
resist = Element_Resist.dup
set_element_resist = []
for i in 1...$data_system.elements.size
if resist['State'] != nil && resist['State'][@id] != nil &&
resist['State'][@id][i] != nil
set_element_resist[i] = resist['State'][@id][i]
else
set_element_resist[i] = 0
end
end
return set_element_resist
end
#--------------------------------------------------------------------------
# Resistencias contra efeitos
#--------------------------------------------------------------------------
def state_resist
resist = State_Resist.dup
set_state_resist = []
for i in 1...$data_states.size
if resist['State'] != nil && resist['State'][@id] != nil &&
resist['State'][@id][i] != nil
set_state_resist[i] = resist['State'][@id][i]
else
set_state_resist[i] = 0
end
end
return set_state_resist
end
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
# Esta classe gerencia os jogadores da batalha.
# Esta classe identifica os Aliados ou Heróis como (Game_Actor) e
# os Inimigos como (Game_Enemy).
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# Incluir modulo de configuração
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
# Definir chances base e sucesso dos efeitos
# state_id : ID do efeito
#--------------------------------------------------------------------------
def state_rate(state_id)
result = state_rate_ranks(state_id)
return result
end
#--------------------------------------------------------------------------
# Aplicar Troca de Status (+)
# plus_state_set : Trocar Status (+)
#--------------------------------------------------------------------------
def states_plus(plus_state_set)
effective = false
for i in plus_state_set
unless self.state_guard?(i)
effective |= self.state_full?(i) == false
if $data_states[i].nonresistance
@state_changed = true
add_state(i)
elsif self.state_full?(i) == false
state = state_rate(i)
if rand(100) < state
@state_changed = true
add_state(i)
end
end
end
end
return effective
end
#--------------------------------------------------------------------------
# Cálculo do Dano do Atributo
# element_set : atributo
#--------------------------------------------------------------------------
def elements_correct(element_set)
value = 100
absorb = false
for i in element_set
element = element_rate_rank(i)
element *= -1 if element < 0 and absorb == true
value *= element / 100.0
absorb = true if element < 0 and absorb == false
end
return value.to_i
end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# Esta é a classe que trata dos Heróis na Batalha.
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# Configuração
# actor_id : ID do Herói
#--------------------------------------------------------------------------
alias setup_newresist setup
def setup(actor_id)
setup_newresist(actor_id)
@element_resist = element_resist
@state_resist = state_resist
end
#--------------------------------------------------------------------------
# Definição de armas
#--------------------------------------------------------------------------
def weapons
return [$data_weapons[@weapon_id]]
end
#--------------------------------------------------------------------------
# Definição de armaduras
#--------------------------------------------------------------------------
def armors
result = []
result << $data_armors[@armor1_id]
result << $data_armors[@armor2_id]
result << $data_armors[@armor3_id]
result << $data_armors[@armor4_id]
return result.compact
end
#--------------------------------------------------------------------------
# Definição de equipamentos
#--------------------------------------------------------------------------
def equips
return weapons + armors
end
#--------------------------------------------------------------------------
# Resistencias elementais
#--------------------------------------------------------------------------
def element_resist
resist = Element_Resist.dup
set_element_resist = []
for i in 1...$data_system.elements.size
if resist['Actor'] != nil && resist['Actor'][@actor_id] != nil &&
resist['Actor'][@actor_id][i] != nil
set_element_resist[i] = resist['Actor'][@actor_id][i]
else
set_element_resist[i] = 0
end
end
return set_element_resist
end
#--------------------------------------------------------------------------
# Mudar Resistencias elementais
# elements : novas resistencias
#--------------------------------------------------------------------------
def element_resist=(elements)
return @element_resist unless elements.is_a?(Hash)
resist = elements.dup
@element_resist = []
for i in 1...$data_system.elements.size
if resist != nil && resist[i] != nil
@element_resist[i] = resist[i]
else
@element_resist[i] = 0
end
end
return @element_resist
end
#--------------------------------------------------------------------------
# Resistencias contra efeitos
#--------------------------------------------------------------------------
def state_resist
resist = State_Resist.dup
set_state_resist = []
for i in 1...$data_states.size
if resist['Actor'] != nil && resist['Actor'][@actor_id] != nil &&
resist['Actor'][@actor_id][i] != nil
set_state_resist[i] = resist['Actor'][@actor_id][i]
else
set_state_resist[i] = 0
end
end
return set_state_resist
end
#--------------------------------------------------------------------------
# Resistencias contra efeitos
# elements : novas resistencias
#--------------------------------------------------------------------------
def state_resist=(states)
return @state_resist unless states.is_a?(Hash)
resist = states.dup
@state_resist = []
for i in 1...$data_states.size
if resist != nil && resist[i] != nil
@state_resist[i] = resist[i]
else
@state_resist[i] = 0
end
end
return @state_resist
end
#--------------------------------------------------------------------------
# Definir Resistencia elemental
#--------------------------------------------------------------------------
def elemental_resist(element_id)
@element_resist[element_id] = 0 if @element_resist[element_id].nil?
value = $data_classes[@class_id].element_ranks[element_id]
case Addition_Type
when 0,2
value += @element_resist[element_id]
element_size = 1
for eqp in equips
value += eqp.element_resist[element_id]
element_size += 1 if eqp.element_resist[element_id] != 0
end
for state in @states
value += $data_states[state].element_resist[element_id]
element_size += 1 if $data_states[state].element_resist[element_id] != 0
end
if $atoa_script['Atoa Equip Set']
for set in @set_elemental_resist
value += set[element_id] if set[element_id] != nil
element_size += 1 if set[element_id] != nil and set[element_id] != 0
end
end
value /= element_size if Addition_Type == 2
when 1,3
base_resist = set_base_elemental_resist(value, element_id)
base_resist.sort! {|a,b| b <=> a}
h = base_resist.first.nil? ? 0 : base_resist.first
l = base_resist.last.nil? ? 0 : base_resist.last
addition = h + l
addition /= 2 if h > 0 and l < 0 and Addition_Type == 3
value = 3 + addition
end
return [[value.to_i, 6].min, 1].max
end
#--------------------------------------------------------------------------
# Definir valores base de resistencia elemental
#--------------------------------------------------------------------------
def set_base_elemental_resist(value, element_id)
base_resist = [value - 3, @element_resist[element_id]]
for eqp in equips
base_resist << eqp.element_resist[element_id]
end
for state in @states
base_resist << $data_states[state].element_resist[element_id]
end
if $atoa_script['Atoa Equip Set']
for set in @set_elemental_resist
base_resist << set[element_id] if set[element_id] != nil
end
end
return base_resist
end
#--------------------------------------------------------------------------
# Definir Resistencia contra efeitos
#--------------------------------------------------------------------------
def states_resist(state_id)
@state_resist[state_id] = 0 if @state_resist[state_id].nil?
value = $data_classes[@class_id].state_ranks[state_id]
case Addition_Type
when 0,2
value += @state_resist[state_id]
state_size = 1
for eqp in equips
value += eqp.state_resist[state_id]
state_size += 1 if eqp.state_resist[state_id] != 0
end
for state in @states
value += $data_states[state].state_resist[state_id]
state_size += 1 if $data_states[state].state_resist[state_id] != 0
end
if $atoa_script['Atoa Equip Set']
for set in @set_state_resist
value += set[state_id] if set[state_id] != nil
element_size += 1 if set[state_id] != nil and set[state_id] != 0
end
end
value /= state_size if Addition_Type == 2
when 1,3
base_resist = set_base_state_resist(value, state_id)
base_resist.sort! {|a,b| b <=> a}
h = base_resist.first.nil? ? 0 : base_resist.first
l = base_resist.last.nil? ? 0 : base_resist.last
addition = h + l
addition /= 2 if h > 0 and l < 0 and Addition_Type == 3
value = 3 + addition
end
return [[value.to_i, 6].min, 1].max
end
#--------------------------------------------------------------------------
# Definir valores base de resistencia elemental
#--------------------------------------------------------------------------
def set_base_state_resist(value, state_id)
base_resist = [value - 3, @state_resist[state_id]]
for eqp in equips
base_resist << eqp.state_resist[state_id]
end
for state in @states
base_resist << $data_states[state].state_resist[state_id]
end
if $atoa_script['Atoa Equip Set']
for set in @set_state_resist
base_resist << set[state_id] if set[state_id] != nil
end
end
return base_resist
end
#--------------------------------------------------------------------------
# Definir multiplicador base do dano
# element_id : ID do elemento
#--------------------------------------------------------------------------
def element_rate_rank(element_id)
table = Element_Table
result = table[elemental_resist(element_id)]
return result
end
#--------------------------------------------------------------------------
# Definir chances base e sucesso dos efeitos
# state_id : ID do efeito
#--------------------------------------------------------------------------
def state_rate_ranks(state_id)
table = States_Table
result = table[states_resist(state_id)]
return result
end
#--------------------------------------------------------------------------
# Definir Defesa contra Status
# state_id : ID do status
#--------------------------------------------------------------------------
def state_guard?(state_id)
for eqp in equips
next if eqp.is_a?(RPG::Weapon)
return true if eqp.guard_state_set.include?(state_id)
end
return false
end
end
#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
# Este é a classe que trata dos inimigos. Esta classe é usada juntamente com
# a classe Game_Troop ($game_troop)
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# Definir multiplicador base do dano
# element_id : ID do elemento
#--------------------------------------------------------------------------
def element_rate_rank(element_id)
table = Element_Table
result = table[$data_enemies[@enemy_id].element_ranks[element_id]]
value = $data_enemies[@enemy_id].element_ranks[element_id]
case Addition_Type
when 0,2
element_size = 1
for i in @states
value += $data_states[i].element_resist[element_id]
element_size += 1 if $data_states[i].element_resist[element_id] != 0
end
value /= element_size if Addition_Type == 2
when 1,3
base_resist = [value - 3]
for i in @states
base_resist << $data_states[i].element_resist[element_id]
end
base_resist.sort! {|a,b| b <=> a}
h = base_resist.first.nil? ? 0 : base_resist.first
l = base_resist.last.nil? ? 0 : base_resist.last
addition = h + l
addition /= 2 if h > 0 and l < 0 and Addition_Type == 3
value = 3 + addition
end
result = table[[[value.to_i, 6].min,1].max]
return result
end
#--------------------------------------------------------------------------
# Definir chances base e sucesso dos efeitos
# state_id : ID do efeito
#--------------------------------------------------------------------------
def state_rate_ranks(state_id)
table = States_Table
result = table[$data_enemies[@enemy_id].state_ranks[state_id]]
value = $data_enemies[@enemy_id].state_ranks[state_id]
case Addition_Type
when 0,2
state_size = 1
for i in @states
value += $data_states[i].state_resist[state_id]
state_size += 1 if $data_states[i].state_resist[state_id] != 0
end
value /= state_size if Addition_Type == 2
when 1,3
base_resist = [value - 3]
for i in @states
base_resist << $data_states[i].state_resist[state_id]
end
base_resist.sort! {|a,b| b <=> a}
h = base_resist.first.nil? ? 0 : base_resist.first
l = base_resist.last.nil? ? 0 : base_resist.last
addition = h + l
addition /= 2 if h > 0 and l < 0 and Addition_Type == 3
value = 3 + addition
end
result = table[[[value.to_i, 6].min,1].max]
return result
end
end