=begin ================================================================================ CrimsonSeas Ultimate series; Core script ================================================================================ This script lists all methods that are shared by more than one Ultimate series script part. This script's purpose is to ensure perfect compatibility with each Ultimate series part, making each part usable by itself or with other Ultimate series. This script also loads the additional database properties at the start of the game. No configuration is needed. Method list: Game_Battler: make_attack_damage_value make_obj_damage_value get_critical calculate_element_damage calc_mp_cost skill_can_use? Game_Enemy level Game_Actor base_maxhp base_maxmp base_atk base_def base_agi base_spi base_mdf base_luck Scene_Equip update_equip_selection update_item_selection Window_Skill initialize refresh draw_item Scene_Battle update_actor_command_selection start_skill_selection ================================================================================ =end class Game_Battler def make_attack_damage_value(user) if CSU::SCRIPTLIST.include?("Ultimate Algorithm") if user.is_a?(Game_Actor) if user.weapons.compact.size > 0 eval(user.weapons.compact[0].damage_formula) else eval(user.unarmed_damage_formula) end else eval(user.damage_formula) end critical_multiplier = user.critical_multiplier ignore_guard = user.ignore_guard ignore_prev_crit = user.ignore_prev_crit if user.is_a?(Game_Actor) if user.weapons.compact.size > 0 var = user.weapons.compact[0].variance else var = user.unarmed_variance end else var = user.variance end else damage = user.atk * 4 - self.def * 2 var = 20 critical_multiplier = 300 no_variance = false ignore_guard = false ignore_prev_crit = false end damage = 0 if damage < 0 damage = calculate_element_damage(damage, user, nil) if damage == 0 damage = rand(2) elsif damage > 0 @critical = (rand(100) < get_critical(user)) @critical = false if prevent_critical && !ignore_prev_crit damage = damage * critical_multiplier / 100 if @critical end damage = apply_variance(damage, var) damage = apply_guard(damage) unless ignore_guard if CSU::SCRIPTLIST.include?("Ultimate States") damage = apply_state_damage_multiplier(damage, user) end if CSU::SCRIPTLIST.include?("Ultimate Algorithm") if user.is_a?(Game_Actor) if user.weapons.compact.size > 0 eval(user.weapons.compact[0].additional_process) else eval(user.unarmed_additional_process) end else eval(user.additional_process) end end @hp_damage = damage.to_i end def make_obj_damage_value(user, obj) if CSU::SCRIPTLIST.include?("Ultimate Algorithm") eval(obj.damage_formula) else damage = obj.base_damage if damage > 0 damage += user.atk * 4 * obj.atk_f / 100 damage += user.spi * 2 * obj.spi_f / 100 unless obj.ignore_defense damage -= self.def * 2 * obj.atk_f / 100 if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") && CSU::Stat::USE_MDF damage -= self.mdf * 1 * obj.spi_f else damage -= self.spi * 1 * obj.spi_f / 100 end end damage = 0 if damage < 0 elsif damage < 0 damage -= user.atk * 4 * obj.atk_f / 100 damage -= user.spi * 2 * obj.spi_f / 100 end end damage = calculate_element_damage(damage, user, obj) if CSU::SCRIPTLIST.include?("Ultimate States") damage = apply_state_damage_multiplier(damage, user, obj) end if CSU::SCRIPTLIST.include?("Ultimate Skills") if obj.is_a?(RPG::Skill) && obj.variable_cost && user.actor? && user.variable_cost != nil eval(CSU::Skill::VARIABLE_COST_ALGORITHM) end end if CSU::SCRIPTLIST.include?("Ultimate Algorithm") @critical = (rand(100) < get_critical(user, obj)) @critical = false if prevent_critical && !obj.ignore_prev_crit damage = damage * obj.critical_multiplier / 100 if @critical damage = apply_variance(damage, obj.variance) damage = apply_guard(damage) unless obj.ignore_guard eval(obj.additional_process) else damage = apply_variance(damage, obj.variance) # variance damage = apply_guard(damage) end if obj.damage_to_mp @mp_damage = damage.to_i else @hp_damage = damage.to_i end end def get_critical(user, obj = nil) if CSU::SCRIPTLIST.include? ("Ultimate Algorithm") && CSU::SCRIPTLIST.include? ("Ultimate Battler Stat") if obj == nil critical = user.cri else critical = obj.critical_rate end return eval(CSU::Stat::CUSTOM_CRITICAL_RATE) elsif CSU::SCRIPTLIST.include? ("Ultimate Algorithm") if obj == nil return user.cri else return obj.critical_rate end elsif CSU::SCRIPTLIST.include? ("Ultimate Battler Stat") if obj == nil critical = user.cri else critical = 0 end return eval(CSU::Stat::CUSTOM_CRITICAL_RATE) else if obj == nil return user.cri else return 0 end end end def calculate_element_damage(damage, user, obj) unless CSU::SCRIPTLIST.include?("Ultimate Elements") if obj == nil element_set = user.element_set else element_set = obj.element_set end damage *= elements_max_rate(element_set) damage /= 100 else if obj == nil || obj.same_as_user_element elemental_damages = user.elemental_damages.clone else elemental_damages = obj.element_dmg_val.clone user.states.each{|state| state.element_dmg_val.each{|k, v| elemental_damages[k] = elemental_damages[k] + v} } end eval(CSU::Elements::ELEMENTAL_DAMAGE_FORMULA) end return damage end alias csu_skill_calc_mp_cost calc_mp_cost unless $@ def calc_mp_cost(skill) cost = csu_skill_calc_mp_cost(skill) if CSU::SCRIPTLIST.include?("Ultimate Skills") case skill.cost_type when "hp" cost += self.maxhp * skill.cost_percent / 100 when "mp" cost += self.maxmp * skill.cost_percent / 100 when "gold" cost += $game_party.gold * skill.cost_percent / 100 end end if CSU::SCRIPTLIST.include?("Ultimate States") addition = 0 states.each{|state| addition += state.fixed_cost_add addition += cost * state.percent_cost_add / 100 } cost += addition end return cost end def skill_can_use?(skill) return false unless skill.is_a?(RPG::Skill) return false unless movable? if CSU::SCRIPTLIST.include?("Ultimate Overdrive") return false if skill.overdrive? && (self.overdrive < self.max_overdrive || self.od_level < skill.od_level) end return false if silent? and skill.spi_f > 0 if CSU::SCRIPTLIST.include?("Ultimate Skills") unless self.actor? && skill.variable_cost case skill.cost_type when "hp" return false if calc_mp_cost(skill) > hp when "mp" return false if calc_mp_cost(skill) > mp when "gold" return false if calc_mp_cost(skill) > $game_party.gold end end if self.actor? skill.item_consume.each{|k, v| return false if $game_party.item_number($data_items[k]) < v} skill.weapon_consume.each{|k, v| return false if $game_party.item_number($data_weapons[k]) < v} skill.armor_consume.each{|k, v| return false if $game_party.item_number($data_armors[k]) < v} end return false if @turns_cooldown[skill.id] > 0 return false if @time_cooldown[skill.id] > Graphics.frame_count return false if !skill.limit.nil? && @battle_usage_count[skill.id] >= skill.limit else return false if calc_mp_cost > mp end if CSU::SCRIPTLIST.include?("Ultimate States") return false if silence_physical? && skill.physical_attack return false if silence_magical? && !skill.physical_attack end if $game_temp.in_battle return skill.battle_ok? else return skill.menu_ok? end end end class Game_Enemy def level if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") if @level == nil make_level end else @level = 1 end return @level end end class Game_Actor def base_maxhp n = actor.parameters[0, @level] if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") n += actor.integer_limit_returning[0, @level] * 32767 end if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.maxhp_percent n += equip.maxhp end n += n * rate / 100 end return n.to_i end def base_maxmp n = actor.parameters[1, @level] if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") n += actor.integer_limit_returning[1, @level] * 32767 end if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.maxmp_percent n += equip.maxmp end n += n * rate / 100 end return n.to_i end def base_atk n = actor.parameters[2, @level] if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") n += actor.integer_limit_returning[2, @level] * 32767 end if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.atk_percent n += equip.atk end n += n * rate / 100 end return n.to_i end def base_def n = actor.parameters[3, @level] if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") n += actor.integer_limit_returning[3, @level] * 32767 end if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.def_percent n += equip.def end n += n * rate / 100 end return n.to_i end def base_spi n = actor.parameters[4, @level] if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") n += actor.integer_limit_returning[4, @level] * 32767 end if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.spi_percent n += equip.spi end n += n * rate / 100 end return n.to_i end def base_agi n = actor.parameters[5, @level] if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") n += actor.integer_limit_returning[5, @level] * 32767 end if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.agi_percent n += equip.agi end n += n * rate / 100 end return n.to_i end def base_mdf return self.spi if !CSU::SCRIPTLIST.include?("Ultimate Stats") n = actor.parameters[6, @level] n += actor.integer_limit_returning[6, @level] * 32767 if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.mdf_percent n += equip.mdf end n += n * rate / 100 end return n.to_i end def base_luck return 0 if !CSU::SCRIPTLIST.include?("Ultimate Stats") n = actor.parameters[7, @level] n += actor.integer_limit_returning[7, @level] * 32767 if CSU::SCRIPTLIST.include?("Ultimate Equip") rate = 0 for equip in equips.compact rate += equip.luck_percent n += equip.luck end n += n * rate / 100 end return n.to_i end end class Scene_Equip def update_equip_selection if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::R) Sound.play_cursor next_actor elsif Input.trigger?(Input::L) Sound.play_cursor prev_actor elsif Input.trigger?(Input::C) if @actor.fix_equipment Sound.play_buzzer elsif CSU::SCRIPTLIST.include?("Ultimate Equip") && @actor.cursed && @actor.equips[@equip_window.index]!=nil && @actor.equips[@equip_window.index].cursed Sound.play_buzzer elsif CSU::SCRIPTLIST.include?("Ultimate SceneEquip") && (CSU::SceneEquip::EQUIP_CHANGING_RESTRICTION[@actor.id][@equip_window.index] == 2 || @item_window.item_max == 0) Sound.play_buzzer else Sound.play_decision @equip_window.active = false @item_window.active = true @item_window.index = 0 end elsif CSU::SCRIPTLIST.include?("Ultimate SceneEquip") && Input.trigger?(CSU::SceneEquip::EQUIP_REMOVE_KEY) if @actor.fix_equipment Sound.play_buzzer elsif CSU::SCRIPTLIST.include?("Ultimate Equip") && @actor.cursed && @actor.equips[@equip_window.index]!=nil && @actor.equips[@equip_window.index].cursed Sound.play_buzzer elsif CSU::SCRIPTLIST.include?("Ultimate SceneEquip") && CSU::SceneEquip::EQUIP_CHANGING_RESTRICTION[@actor.id][@equip_window.index] == 2 Sound.play_buzzer elsif CSU::SCRIPTLIST.include?("Ultimate SceneEquip") && @item_window.item_max == 0 && CSU::SceneEquip::EQUIP_CHANGING_RESTRICTION[@actor.id][@equip_window.index] == 1 Sound.play_buzzer else Sound.play_equip @actor.change_equip(@equip_window.index, nil) @equip_window.refresh @status_window.refresh for window in @item_windows window.refresh end end end end def update_item_selection if Input.trigger?(Input::B) Sound.play_cancel @equip_window.active = true @item_window.active = false @item_window.index = -1 elsif Input.trigger?(Input::C) item = @item_window.item if item != nil & CSU::SCRIPTLIST.include?("Ultimate Equip") if item.maxhp_cap != nil && (@actor.maxhp < item.maxhp_cap[0] || @actor.maxhp > item.maxhp_cap[1]) Sound.play_buzzer return end if item.maxmp_cap != nil && (@actor.maxmp < item.maxmp_cap[0] || @actor.maxmp > item.maxmp_cap[1]) Sound.play_buzzer return end if item.atk_cap != nil && (@actor.atk < item.atk_cap[0] || @actor.atk > item.atk_cap[1]) Sound.play_buzzer return end if item.def_cap != nil && (@actor.def < item.def_cap[0] || @actor.def > item.def_cap[1]) Sound.play_buzzer return end if item.spi_cap != nil && (@actor.spi < item.spi_cap[0] || @actor.spi > item.spi_cap[1]) Sound.play_buzzer return end if item.agi_cap != nil && (@actor.agi < item.agi_cap[0] || @actor.agi > item.agi_cap[1]) Sound.play_buzzer return end if item.mdf_cap != nil && (@actor.mdf < item.mdf_cap[0] || @actor.mdf > item.mdf_cap[1]) Sound.play_buzzer return end if item.luck_cap != nil && (@actor.luck < item.luck_cap[0] || @actor.luck > item.luck_cap[1]) Sound.play_buzzer return end if item.level_cap != nil && (@actor.level < item.level_cap[0] || @actor.level > item.level_cap[1]) Sound.play_buzzer return end end Sound.play_equip @actor.change_equip(@equip_window.index, @item_window.item) if CSU::SCRIPTLIST.include?("Ultimate Equip") if @item_window.item != nil && @item_window.item.cursed Audio.se_play("Audio/SE/" + CSU::Equip::SOUND_ON_CURSE) if CSU::Equip::SHOW_CURSED_MESSAGE @item_window.refresh @equip_window.refresh @status_window.refresh text = @actor.name + CSU::Equip::CURSED_MESSAGE @message_window = Window_EquipMessage.new(text) for i in 1..90 @message_window.update Graphics.update Input.update break if Input.trigger?(Input::C) && i > 1 end @message_window.dispose end end end @equip_window.active = true @item_window.active = false @item_window.index = -1 @equip_window.refresh for item_window in @item_windows item_window.refresh end end end end class Window_ActorCommand attr_accessor :commands end class Window_Skill def initialize(x, y, width, height, actor, od_window = false) super(x, y, width, height) @actor = actor @column_max = 2 self.index = 0 @od_window = od_window self.windowskin = Cache.system("Window") unless @od_window and $game_temp.in_battle refresh end def refresh @data = [] for skill in @actor.skills if CSU::SCRIPTLIST.include?("Ultimate Overdrive") next if skill.overdrive? ^ @od_window end @data.push(skill) if skill.id == @actor.last_skill_id self.index = @data.size - 1 end end @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) skill = @data[index] if skill != nil rect.width -= 4 enabled = @actor.skill_can_use?(skill) if CSU::SCRIPTLIST.include?("Ultimate Overdrive") enabled = true if skill.overdrive? && @actor.od_level >= skill.od_level end if CSU::SCRIPTLIST.include?("Ultimate SceneStatus") enabled = true if $scene.is_a?(Scene_Status) end draw_item_name(skill, rect.x, rect.y, enabled) cost = @actor.calc_mp_cost(skill) if cost > 0 cost_text = cost.to_s if CSU::SCRIPTLIST.include?("Ultimate Skills") case skill.cost_type when "hp" self.contents.font.color = CSU::Skill::HP_COST_COLOR when "mp" self.contents.font.color = CSU::Skill::MP_COST_COLOR when "gold" self.contents.font.color = CSU::Skill::GOLD_COST_COLOR end cost_text += eval("Vocab::" + skill.cost_type.downcase) end self.contents.draw_text(rect, cost_text, 2) end end end end class Scene_Battle def display_normal_animation(targets, animation_id, mirror = false) animation = $data_animations[animation_id] if animation != nil to_screen = (animation.position == 3) # Is the positon "screen"? for target in targets.uniq if CSU::SCRIPTLIST.include?("Ultimate Skills") && @active_battler.action.skill? && reflect(target, @active_battler.action.skill) target.animation_id = CSU::Skill::REFLECT_ANIM_ID else target.animation_id = animation_id end target.animation_mirror = mirror wait(20, true) unless to_screen # If for one, wait break if to_screen end wait(20, true) if to_screen # If for all, wait end end alias ultimate_update_actor_command_selection update_actor_command_selection unless $@ def update_actor_command_selection if CSU::SCRIPTLIST.include?("Ultimate Equip") if Input.trigger?(Input::C) && @actor_command_window.index == 0 && !@active_battler.attack_usable? Sound.play_buzzer return end end if CSU::SCRIPTLIST.include?("Ultimate Overdrive") && CSU::Overdrive::USE_OD_CMD_WINDOW if @actor_command_window.index != 0 && @actor_command_window.commands[0] != Vocab::attack @actor_command_window.commands[0] = Vocab::attack @actor_command_window.refresh end if Input.trigger?(Input::B) Sound.play_cancel prior_actor elsif Input.trigger?(Input::RIGHT) if @active_battler.in_overdrive? if @actor_command_window.commands[@actor_command_window.index] == Vocab::attack @actor_command_window.commands[0] = CSU::Overdrive::OD_NAME @actor_command_window.refresh Sound.play_cursor end end elsif Input.trigger?(Input::LEFT) if @actor_command_window.commands[@actor_command_window.index] == CSU::Overdrive::OD_NAME @actor_command_window.commands[0] = Vocab::attack @actor_command_window.refresh Sound.play_cursor end elsif Input.trigger?(Input::C) case @actor_command_window.index when 0 # Attack if @actor_command_window.commands[@actor_command_window.index] == CSU::Overdrive::OD_NAME Sound.play_decision start_skill_selection(true) else Sound.play_decision @active_battler.action.set_attack start_target_enemy_selection end when 1 # Skill Sound.play_decision start_skill_selection when 2 # Guard Sound.play_decision @active_battler.action.set_guard next_actor when 3 # Item Sound.play_decision start_item_selection end end else ultimate_update_actor_command_selection end end alias ultimate_start_skill_selection start_skill_selection unless $@ def start_skill_selection(od_window = false) ultimate_start_skill_selection @skill_window.dispose @skill_window = Window_Skill.new(0, 56, 544, 232, @active_battler, od_window) @skill_window.help_window = @help_window end end class Scene_Title alias crimsonseas_ultimate_load_db load_database unless $@ def load_database crimsonseas_ultimate_load_db create_crimsonseas_ultimate_caches end alias csu_load_bt_db load_bt_database unless $@ def load_bt_database csu_load_bt_db create_crimsonseas_ultimate_caches end def create_crimsonseas_ultimate_caches for actor in $data_actors next if actor == nil if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") actor.create_actor_cache_ultimate_stat end end for skill in $data_skills next if skill == nil if CSU::SCRIPTLIST.include?("Ultimate Algorithm") skill.create_usableitem_cache_ultimate_algorithm end if CSU::SCRIPTLIST.include?("Ultimate Elements") skill.create_usableitem_cache_ultimate_elements end if CSU::SCRIPTLIST.include?("Ultimate Overdrive") skill.create_skill_cache_ultimate_overdrive skill.create_usableitem_cache_ultimate_overdrive end if CSU::SCRIPTLIST.include?("Ultimate States") skill.create_usableitem_cache_ultimate_state end if CSU::SCRIPTLIST.include?("Ultimate Skills") skill.create_skill_cache_ultimate_skills end end for item in $data_items next if item == nil if CSU::SCRIPTLIST.include?("Ultimate Algorithm") item.create_usableitem_cache_ultimate_algorithm end if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") item.create_item_cache_ultimate_stat end if CSU::SCRIPTLIST.include?("Ultimate Elements") item.create_usableitem_cache_ultimate_elements end if CSU::SCRIPTLIST.include?("Ultimate Overdrive") item.create_usableitem_cache_ultimate_overdrive end if CSU::SCRIPTLIST.include?("Ultimate Equip") item.create_item_cache_ultimate_equip end if CSU::SCRIPTLIST.include?("Ultimate States") item.create_usableitem_cache_ultimate_state end end for weapon in $data_weapons next if weapon == nil if CSU::SCRIPTLIST.include?("Ultimate Algorithm") weapon.create_weapon_cache_ultimate_algorithm end if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") weapon.create_weapon_cache_ultimate_stat end if CSU::SCRIPTLIST.include?("Ultimate Elements") weapon.create_weapon_cache_ultimate_elements end if CSU::SCRIPTLIST.include?("Ultimate Equip") weapon.create_weapon_cache_ultimate_equip end if CSU::SCRIPTLIST.include?("Ultimate States") weapon.create_weapon_cache_ultimate_state end end for armor in $data_armors next if armor == nil if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") armor.create_armor_cache_ultimate_stat end if CSU::SCRIPTLIST.include?("Ultimate Elements") armor.create_armor_cache_ultimate_elements end if CSU::SCRIPTLIST.include?("Ultimate Equip") armor.create_armor_cache_ultimate_equip end if CSU::SCRIPTLIST.include?("Ultimate States") armor.create_armor_cache_ultimate_state end end for enemy in $data_enemies next if enemy == nil if CSU::SCRIPTLIST.include?("Ultimate Algorithm") enemy.create_enemy_cache_ultimate_algorithm end if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") enemy.create_enemy_cache_ultimate_stat end if CSU::SCRIPTLIST.include?("Ultimate Elements") enemy.create_enemy_cache_ultimate_elements end if CSU::SCRIPTLIST.include?("Ultimate Overdrive") enemy.create_enemy_cache_ultimate_overdrive end if CSU::SCRIPTLIST.include?("Ultimate Equip") enemy.create_enemy_cache_ultimate_equip end if CSU::SCRIPTLIST.include?("Ultimate States") enemy.create_enemy_cache_ultimate_state end if CSU::SCRIPTLIST.include?("Ultimate Skills") enemy.create_enemy_cache_ultimate_skills end end for state in $data_states next if state == nil if CSU::SCRIPTLIST.include?("Ultimate Battler Stat") state.create_state_cache_ultimate_stat end if CSU::SCRIPTLIST.include?("Ultimate Elements") state.create_state_cache_ultimate_elements end if CSU::SCRIPTLIST.include?("Ultimate Overdrive") state.create_state_cache_ultimate_overdrive end if CSU::SCRIPTLIST.include?("Ultimate States") state.create_state_cache_ultimate_state end if CSU::SCRIPTLIST.include?("Ultimate Skills") state.create_state_cache_ultimate_skills end end end end