| class RPG::EquipItem < RPG::BaseItem | |
| def extra_evs(stat) | |
| @note =~ /<EXTRA EVS #{original_param_name(stat)}: (\d+)>/i ? $1.to_i : 0 | |
| end | |
| def original_param_name(stat) | |
| case stat | |
| when 0 | |
| return "MHP" | |
| when 1 | |
| return "MMP" | |
| when 2 | |
| return "ATK" | |
| when 3 | |
| return "DEF" | |
| when 4 | |
| return "MAT" | |
| when 5 | |
| return "MDF" | |
| when 6 | |
| return "AGI" | |
| when 7 | |
| return "LUK" | |
| end | |
| end | |
| def no_status_moves? | |
| @note =~ /<NO STATUS MOVES>/i | |
| end | |
| end | |
| class RPG::Item < RPG::UsableItem | |
| def no_status_moves? | |
| @note =~ /<NO STATUS MOVES>/i | |
| end | |
| end | |
| #============================================================================== | |
| # ** BattleManager | |
| #------------------------------------------------------------------------------ | |
| # This module manages battle progress. | |
| #============================================================================== | |
| module BattleManager | |
| #-------------------------------------------------------------------------- | |
| # * Escape Processing | |
| #-------------------------------------------------------------------------- | |
| def self.process_escape | |
| $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name)) | |
| success = @preemptive ? true : (rand < @escape_ratio) | |
| $game_party.battling_members.each do |actor| | |
| success = true if actor.equips.include?($data_armors[10]) | |
| end | |
| Sound.play_escape | |
| if success | |
| process_abort | |
| else | |
| @escape_ratio += 0.1 | |
| $game_message.add('\.' + Vocab::EscapeFailure) | |
| $game_party.clear_actions | |
| end | |
| wait_for_message | |
| return success | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Create Action Order | |
| #-------------------------------------------------------------------------- | |
| def self.make_action_orders | |
| if CRYSTAL::PBS.imported_other_battle_system? | |
| make_action_orders_ce_pbs | |
| else | |
| @action_battlers = [] | |
| action_battlers = [] | |
| @priority_brackets = {} | |
| action_battlers += $game_party.alive_members unless @surprise | |
| action_battlers += $game_troop.alive_members unless @preemptive | |
| action_battlers.select! {|battler| battler.current_action.is_a?(Game_Action)} | |
| if $imported["YSE-ChargeSkill"] | |
| action_battlers.select! {|battler| battler.charging? ? | |
| battler.current_charging.item.is_a?(RPG::UsableItem) : | |
| battler.current_action.item.is_a?(RPG::UsableItem)} | |
| action_battlers.sort_by! {|battler| battler.charging? ? | |
| battler.current_charging.item.priority : battler.current_action.item.priority}.reverse! | |
| else | |
| action_battlers.select! {|battler| battler.current_action.item.is_a?(RPG::UsableItem)} | |
| action_battlers.sort_by! {|battler| | |
| battler.current_action.item.priority}.reverse! | |
| end | |
| action_battlers.each do |battler| | |
| if battler.pursuing? | |
| @priority_brackets[CRYSTAL::PBS::PURSUIT_PRIORITY] ||= [] | |
| @priority_brackets[CRYSTAL::PBS::PURSUIT_PRIORITY].push(battler) | |
| else | |
| item = battler.highest_priority_action.item | |
| if item.hit_type == 0 && is_const?(battler.ability, POKE_ABILITIES, :PRANKSTER) | |
| extra_priority = 1 | |
| elsif item.icon_index == 648 && is_const?(battler.ability, POKE_ABILITIES, :GALE_WINGS) | |
| extra_priority = 1 | |
| else | |
| extra_priority = 0 | |
| end | |
| priority = item.priority + extra_priority | |
| @priority_brackets[priority] ||= [] | |
| @priority_brackets[priority].push(battler) | |
| end | |
| end | |
| @priority_brackets.keys.sort.reverse.each do |key| | |
| bracket = @priority_brackets[key] | |
| next if bracket.nil? | |
| bracket.each {|battler| battler.make_speed } | |
| bracket.sort! {|a,b| b.speed - a.speed } | |
| bracket.each do |battler| | |
| if field_state?(94) | |
| bracket.reverse! | |
| end | |
| if is_const?(battler.ability, POKE_ABILITIES, :STALL) | |
| bracket.delete(battler) | |
| bracket.push(battler) | |
| end | |
| if has_const?(battler.equips, $data_armors, POKE_ARMORS, :LAGGING_TAIL) | |
| bracket.delete(battler) | |
| bracket.push(battler) | |
| end | |
| if has_const?(battler.equips, $data_armors, POKE_ARMORS, :QUICK_CLAW) && rand < 0.20 | |
| bracket.unshift(battler) | |
| end | |
| end | |
| @action_battlers += bracket | |
| end | |
| end | |
| end | |
| end | |
| #============================================================================== | |
| # ** Game_ActionResult | |
| #------------------------------------------------------------------------------ | |
| # This class handles the results of battle actions. It is used internally for | |
| # the Game_Battler class. | |
| #============================================================================== | |
| class Game_ActionResult | |
| #-------------------------------------------------------------------------- | |
| # * Create Damage | |
| #-------------------------------------------------------------------------- | |
| def th_action_history_make_damage(value, item) | |
| @critical = false if value == 0 | |
| @hp_damage = value if item.damage.to_hp? | |
| @mp_damage = value if item.damage.to_mp? | |
| @mp_damage = [@battler.mp, @mp_damage].min | |
| @hp_drain = @hp_damage / 2 if item.damage.drain? | |
| @mp_drain = @mp_damage / 2 if item.damage.drain? | |
| @hp_drain = [@battler.hp, @hp_drain].min | |
| @success = true if item.damage.to_hp? || @mp_damage != 0 | |
| @hp_drain *= 1.30 if has_const?(@battler.equips, $data_armors, POKE_ARMORS, :BIG_ROOT) | |
| @mp_drain *= 1.30 if has_const?(@battler.equips, $data_armors, POKE_ARMORS, :BIG_ROOT) | |
| if has_const?(@battler.equips, $data_armors, POKE_ARMORS, :SHELL_BELL) | |
| @hp_drain += @hp_damage / 8 | |
| @mp_drain += @mp_damage / 8 | |
| end | |
| end | |
| end | |
| #============================================================================== | |
| # ** Game_BattlerBase | |
| #------------------------------------------------------------------------------ | |
| # This base class handles battlers. It mainly contains methods for calculating | |
| # parameters. It is used as a super class of the Game_Battler class. | |
| #============================================================================== | |
| class Game_BattlerBase | |
| attr_accessor :choice_skill | |
| #-------------------------------------------------------------------------- | |
| # * Object Initialization | |
| #-------------------------------------------------------------------------- | |
| alias init_pokemon_ace_items initialize | |
| def initialize | |
| init_pokemon_ace_items | |
| @choice_skill = 0 | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Determine Skill/Item Usability | |
| #-------------------------------------------------------------------------- | |
| alias usable_pokemon_ace_items usable? | |
| def usable?(item) | |
| return false if item.skill? && state?(20) && last_action && last_action.item == item | |
| return false if item.skill? && state?(81) && state_origin?(81).learn_skill?(item) | |
| return false if item.skill? && !item.switch? && $data_skills[@choice_skill] && item.id != @choice_skill | |
| return false if item.skill? && !item.switch? && (equips.compact.any? {|equip| equip.no_status_moves?} || state?(18)) && item.hit_type == 0 | |
| return usable_pokemon_ace_items(item) | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Get Array of All Feature Objects | |
| #-------------------------------------------------------------------------- | |
| alias all_features_pokemon_ace_items all_features | |
| def all_features | |
| set = all_features_pokemon_ace_items | |
| if has_const?(equips, $data_armors, POKE_ARMORS, :RING_TARGET) | |
| r = set.select {|f| f.code == FEATURE_ELEMENT_RATE && f.value == 0} | |
| set -= r | |
| end | |
| if opponents_unit.members.any? {|a| a && is_const?(a.ability, POKE_ABILITIES, :SCRAPPY)} && $game_party.in_battle | |
| r = set.select {|f| f.code == FEATURE_ELEMENT_RATE && ([1, 7].include?(f.data_id) && f.value == 0)} | |
| set -= r | |
| end | |
| set | |
| end | |
| end | |
| #============================================================================== | |
| # ** Game_Battler | |
| #------------------------------------------------------------------------------ | |
| # A battler class with methods for sprites and actions added. This class | |
| # is used as a super class of the Game_Actor class and Game_Enemy class. | |
| #============================================================================== | |
| class Game_Battler < Game_BattlerBase | |
| attr_accessor :attacking_item | |
| attr_accessor :captured | |
| def extra_evs(stat) | |
| equips.inject(0) {|r, equip| r += equip.extra_evs(stat)} | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Apply Effect of Skill/Item | |
| #-------------------------------------------------------------------------- | |
| alias item_apply_pokemon_ace_items item_apply | |
| def item_apply(user, item) | |
| item_apply_pokemon_ace_items(user, item) | |
| user.choice_skill = item.id if has_const?(user.equips, $data_armors, POKE_ARMORS, :CHOICE_BAND) && item.skill? | |
| user.choice_skill = item.id if has_const?(user.equips, $data_armors, POKE_ARMORS, :CHOICE_SPECS) && item.skill? | |
| user.choice_skill = item.id if has_const?(user.equips, $data_armors, POKE_ARMORS, :CHOICE_SCARF) && item.skill? | |
| if @result.hit? && item.skill? | |
| case item.id | |
| # Bind, Wrap, Fire Spin, Clamp Whirlpool, Sand Tomb, Magma Storm | |
| when get_const(POKE_SKILLS, :BIND), get_const(POKE_SKILLS, :WRAP) | |
| @state_turns[16] = 5 if has_const?(user.equips, $data_armors, POKE_ARMORS, :GRIP_CLAW) | |
| when get_const(POKE_SKILLS, :FIRE_SPIN), get_const(POKE_SKILLS, :CLAMP) | |
| @state_turns[16] = 5 if has_const?(user.equips, $data_armors, POKE_ARMORS, :GRIP_CLAW) | |
| when get_const(POKE_SKILLS, :WHIRLPOOL), get_const(POKE_SKILLS, :SAND_TOMB) | |
| @state_turns[16] = 5 if has_const?(user.equips, $data_armors, POKE_ARMORS, :GRIP_CLAW) | |
| when get_const(POKE_SKILLS, :MAGMA_STORM) | |
| @state_turns[16] = 5 if has_const?(user.equips, $data_armors, POKE_ARMORS, :GRIP_CLAW) | |
| when get_const(POKE_SKILLS, :LIGHT_SCREEN) | |
| if has_const?(user.equips, $data_armors, POKE_ARMORS, :LIGHT_CLAY) | |
| if actor? | |
| $game_party.party_state_turns[136] += 3 | |
| elsif enemy? | |
| $game_troop.party_state_turns[136] += 3 | |
| end | |
| end | |
| when get_const(POKE_SKILLS, :REFLECT) | |
| if has_const?(user.equips, $data_armors, POKE_ARMORS, :LIGHT_CLAY) | |
| if actor? | |
| $game_party.party_state_turns[137] += 3 | |
| elsif enemy? | |
| $game_troop.party_state_turns[137] += 3 | |
| end | |
| end | |
| end | |
| end | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Weight | |
| #-------------------------------------------------------------------------- | |
| alias weight_pokemon_ace_items weight | |
| def weight | |
| total = weight_pokemon_ace_items | |
| total /= 2 if has_const?(user.equips, $data_armors, POKE_ARMORS, :FLOAT_STONE) | |
| return total | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Can't Switch | |
| #-------------------------------------------------------------------------- | |
| alias on_switch_pokemon_ace_items no_switch? | |
| def no_switch? | |
| return true if has_const?(equips, $data_armors, POKE_ARMORS, :SHED_SHELL) | |
| if actor? | |
| if $game_troop.alive_members.any? {|battler| is_const?(battler.ability, POKE_ABILITIES, :MAGNET_PULL) } | |
| return !state?(56) | |
| end | |
| elsif enemy? | |
| if $game_party.alive_members.any? {|battler| is_const?(battler.ability, POKE_ABILITIES, :MAGNET_PULL) } | |
| return !state?(56) | |
| end | |
| end | |
| return on_switch_pokemon_ace_items | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Processing at End of Battle | |
| #-------------------------------------------------------------------------- | |
| alias on_battle_end_pokemon_ace_item on_battle_end | |
| def on_battle_end | |
| on_battle_end_pokemon_ace_item | |
| @choice_skill = 0 | |
| end | |
| #-------------------------------------------------------------------------- | |
| # * Process Capture | |
| #-------------------------------------------------------------------------- | |
| def process_capture(pokeball) | |
| return if actor? | |
| new_hp = self.hp | |
| new_states = self.states.collect {|state| state.id } | |
| @captured = true | |
| $game_troop.captured[index] = true unless trained | |
| die | |
| BattleManager.sendout_status = :checking | |
| basic_actor = $data_actors[CRYSTAL::CAPTURE::CAPTURE_BASE].dup | |
| basic_actor.id = $data_actors.size | |
| basic_actor.class_id = self.class.id | |
| basic_actor.initial_level = level | |
| basic_actor.base_equip_slots = @equip_slots if $imported["CE-EnemyEquipment"] && $imported["YEA-AceEquipEngine"] | |
| if enemy.take_class_name | |
| basic_actor.name = self.class.name | |
| else | |
| basic_actor.name = old_name | |
| end | |
| basic_actor.description = self.class.description if $imported["CE-EnemyClasses"] && $imported["YEA-ClassSystem"] | |
| basic_actor.pokeball = pokeball | |
| if $imported["BubsGenderFunctions"] | |
| basic_actor.gender = enemy.gender | |
| end | |
| if $imported["CE-BSF"] | |
| basic_actor.iv = iv | |
| basic_actor.nature = nature | |
| end | |
| if $imported["CE-Abilities"] | |
| basic_actor.ability = ability | |
| end | |
| $data_actors.push(basic_actor) | |
| $game_party.extra_data[:actors].push(basic_actor) | |
| actor = $game_actors[basic_actor.id] | |
| if $imported["CE-BSF"] | |
| actor.ev = ev | |
| actor.base = @base | |
| end | |
| if $imported["CE-EnemyEquipment"] | |
| equips.each_with_index do |index, equip| | |
| actor.change_equip(index, equip) | |
| end | |
| actor.release_unequippable_items(true) | |
| end | |
| if $imported["CE-MoveLimits"] | |
| if $imported["CE-ShadowPokemon"] && shadow? | |
| @moves = @old_moves.dup | |
| end | |
| if $imported["YES-SkillEquip"] | |
| @moves.each do |skill_id| | |
| actor.learn_skill_ce_move_limit(skill_id) | |
| end | |
| actor.equip_skills = @moves[0...actor.skill_slots] | |
| actor.equip_skills.each_with_index do |skill_id, index| | |
| actor.equip_skills[index] = 0 if skill_id.nil? | |
| end | |
| else | |
| @moves.each do |skill_id| | |
| actor.learn_skill(skill_id) | |
| end | |
| end | |
| end | |
| actor.make_shadow if $imported["CE-ShadowPokemon"] && shadow? | |
| $game_party.add_actor(actor.id) | |
| actor.hp = new_hp | |
| new_states.each {|state| actor.add_new_state(state) } | |
| actor.refresh | |
| if shadow? && @trained | |
| fmt = "Snagged from %s." | |
| text = sprintf(fmt, trainer.name) | |
| $game_party.extra_data[:system][:shadow_pokemon][self.class.id][:snagged] = true | |
| $game_party.extra_data[:system][:shadow_pokemon][self.class.id][:message] += text | |
| end | |
| SceneManager.scene.rename_capture(actor) | |
| actor.recover_all unless pokeball = :heal | |
| actor.pokerus_infect if $imported["CE-Pokerus"] && self.infected? | |
| actor.refresh | |
| BattleManager.sendout_status = :checking if $imported["CE-PBS"] | |
| end | |
| end | |
| #============================================================================== | |
| # ** Game_Unit | |
| #------------------------------------------------------------------------------ | |
| # This class handles units. It's used as a superclass of the Game_Party and | |
| # and Game_Troop classes. | |
| #============================================================================== | |
| class Game_Unit | |
| #-------------------------------------------------------------------------- | |
| # * Public Instance Variables | |
| #-------------------------------------------------------------------------- | |
| attr_accessor :party_state_turns | |
| end | |
| class Game_Trainer < Game_Battler | |
| def equips | |
| [] | |
| end | |
| end |