Code:
# * KElementRate XP
# Scripter : Kyonides Arkanthes
# v0.3.0 - 022-11-13
# This script replaces the Database's Element Ranks with a Brand New One!
# That means that your hero will now have a blank list of ranks.
# It could be great for further improving a hero's customization process.
# * Enable Custom Element Ranks From the Very Beginning * #
# CUSTOM_RATES_ACTORS = [Add, As, Many, Actor, IDs, As, Deemed, Necessary]
# * Enable / Disable Custom Element Ranks In Game * #
# $game_actors[ActorID].element_ranks_enabled = true
# $game_actors[ActorID].element_ranks_enabled = false
# * Alter a Hero's Element Rank * #
# - Default Table of Resistance: [0,200,150,100,50,0,-100]
# $game_actors[ActorID].element_ranks[ElementID] = Position aka Index
module KElem
module Rate
CUSTOM_RATES_INDEX = 3 # Default Percent: 100
CUSTOM_RATES_ACTORS = [1]
ARMOR_REDUCE_FACTOR = 2
STATE_REDUCE_FACTOR = 2
end
end
class RPG::Armor
def guard_element?(e_id) guard_element_set.include?(e_id) end
end
class RPG::State
def guard_element?(e_id) guard_element_set.include?(e_id) end
end
class Game_Actor
include KElem::Rate
ELEMENT_PERCENTS = [0,200,150,100,50,0,-100]
attr_reader :element_ranks_enabled
alias :kyon_elem_rate_gm_actor_setup :setup
def setup(actor_id)
kyon_elem_rate_gm_actor_setup(actor_id)
self.element_ranks_enabled = CUSTOM_RATES_ACTORS.include?(actor_id)
end
def db_element_ranks
$data_classes[@class_id].element_ranks
end
def element_ranks
@element_ranks_enabled ? @element_ranks : db_element_ranks
end
def element_ranks_enabled=(bool)
return bool if bool == @element_ranks_enabled
if bool
ranks = db_element_ranks
@element_ranks = Array.new(ranks.xsize, CUSTOM_RATES_INDEX)
end
@element_ranks_enabled = bool
end
def element_rate(e_id)
pos = self.element_ranks[e_id]
result = ELEMENT_PERCENTS[pos]
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
next if i == 0
result /= ARMOR_REDUCE_FACTOR if $data_armors[i].guard_element?(e_id)
end
for i in @states
result /= STATE_REDUCE_FACTOR if $data_states[i].guard_element?(e_id)
end
result
end
end