#=============================================================================# * Crystal Engine - Enemy Capture#------------------------------------------------------------------------------# Current Version: 1.09#=============================================================================$imported = {} if $imported.nil?$imported["CE-EnemyCapture"] = true=beginthis allows you to capture enemies and create an actor actor out of themto join your party and they work as a full time actor to your partyuse this to set the catch rate. You can make you own custom Pokeballs using thecustom effects configuration at the bottom of the script.--------------------------------------------------------------------------------Notetags:Actor Notes<pokeball: sym> # Sets the Pokeball the actor is caught inClass Notes<catch rate: x> # Sets the mulitplier of the Pokeball<moon stone class> # Signifies Moon Stone Evolution for the Moon BallSkill Notes<pokeball: sym> # Set the Pokeball Effect for the Skill and makes it a PokeballItem Notes<pokeball: sym> # Set the Pokeball Effect for the Item and makes it a PokeballEnemy Notes<no catch> # The enemy can'b be caught under any circumstances.# They can't be selected with a Pokeball. Trainer owned Pokemon are already # applied to this rule.State Notes<net state> # An enemy with this state has an increated catch rate from a Net Ball<state effect: x> # The modifer of the state on the catch rateTileset Notes<dive terain: x, y> # All of the Specified Terrain Tags are WaterMap Notes<dark map> # Makes the Map Boost the effects of the Dark Ball--------------------------------------------------------------------------------Pokeball Types and What They Do::normal | no muliplier:great | times 1.5:ultra | times 2:master | always returns true:premier| no multiplier:level | by level either 1, 2, 4, or 8:lure | if fishing switch is on times 3:moon | if they evolve with a moon stone times 4:friend | sets initial friendship to 200:love | if they are the other gender times 8:heavy | by weight:fast | if base speed exceeds 100 times 4:net | if water of a bug type times 3:nest | times ((40-level)/10) cannot go bellow times 1:repeat | if you have that class in your pokedex times 3:timer | times [(turns/2.5), 4].min:dive | if on water times 3.5:luxury | no multiplier:dusk | if in a cave or at night times 3.5:quick | if on the first turn times 4:park | always returns true:dream | alwasy returns true=endmodule CRYSTALmodule CAPTUREDEFAULT_CATCH_RATE = 255FISHING_SWITCH = 1CAPTURE_BASE = 4 # The actor used as a basis for the captureSTARTING_POINT = 1000CAPTURE_COMMON_EVENT = 1 LOVE_BALL_RULE = :gender_only # :gender_only # Different Gender only # :egg_group # Same Egg Group # :same_line # Same Evolutionary Line # :same_species # Same Class IDPOKEBALL_ICONS = {:normal => 132,:great => 133,:ultra => 134,:master => 135,:safrai => 136,:level => 137,:lure => 138,:moon => 139,:friend => 140,:love => 141,:heavy => 142,:fast => 143,:sport => 144,:primer => 145,:repeat => 146,:timer => 147,:nest => 148,:net => 149,:dive => 150,:luxury => 151,:heal => 152,:quick => 153,:dusk => 154,:cherish => 155,:park => 156,:dream => 157,} #-------------------------------------------------------------------------- # * Custom Poke Ball Effects #-------------------------------------------------------------------------- def self.custom_effects(pokeball, bonus) # Insert Code Here return bonus endendend#==============================================================================# Editing beyond this point may cause stone, zombie, mist frenzy, and/or toad,# so edit at your own risk.#==============================================================================module CRYSTALmodule REGEXPmodule USABLEITEMPOKEBALL = /<(?:POKEBALL|Pokeball|pokeball):[ ](.*)>/iendmodule ACTORPOKEBALL = /<(?:Pokeball|Pokeball|pokeball):[ ](.*)>/iendmodule CLASSCATCH_RATE = /<(?:CATCH_RATE|Catch Rate|catch rate):[ ](\d+)>/iMOON_STONE = /<(?:MOON_STONE_CLASS|Moon Stone Class|moon stone class)>/iendmodule STATENET_STATE = /<(?:NET_STATE|Net State|net state)>/iSTATE_EFFECT = /<(?:STATE_EFFECT|State Effect|state effect):[ ](.*)>/iendmodule TILESETDIVE_TAG = /<(?:DIVE_TERRAIN|Dive Terrain|dive terrain):[ ]*(\d+(?:\s*,\s*\d+)*)>/iendmodule MAPDARK_MAP = /<(?:DARK_MAP|Dark Map|dark map)>/iendendendmodule CRYSTALmodule CHECK#--------------------------------------------------------------------------# * Checks if you have a certain script installed#--------------------------------------------------------------------------def self.require(self_name, script, site = "http://crystalnoel42.wordpress.com")unless $imported["CE-BasicModule"]msg = "The script '#{self_name}' requires the latest\n"msg += "version of 'Crystal Engine - Basic Module' to work properly\n"msg += "Go to [URL="http://crystalnoel42.wordpress.com/"]http://crystalnoel42.wordpress.com/[/URL] to download this script."raise SyntaxError.new(msg)endunless $imported[script]msg = "The script '#{self_name}' requires the latest\n"msg += "version of #{scripts_list(script)} to work properly\n"msg += "Go to #{site} to download this script."raise SyntaxError.new(msg)endendrequire("Crystal Engine - Enemy Capture", "CE-BasicModule")#--------------------------------------------------------------------------# * Script Name Guide#--------------------------------------------------------------------------class <<self; alias scripts_list_ec scripts_list; enddef self.scripts_list(name)scripts_list_ec(name)case namewhen "CE-EnemyClasses"return "Crystal Engine - Enemy Classes and Levels"endendendendCRYSTAL::CHECK.require("Crystal Engine - Enemy Capture", "CE-EnemyClasses")#==============================================================================# ** DataManager#------------------------------------------------------------------------------# This module manages the database and game objects. Almost all of the# global variables used by the game are initialized by this module.#==============================================================================module DataManager#--------------------------------------------------------------------------# alias method: load_database#--------------------------------------------------------------------------class <<self; alias load_database_ec load_database; enddef self.load_database$current_id = CRYSTAL::CAPTURE::STARTING_POINTload_database_ecload_notetags_ecend#--------------------------------------------------------------------------# new method: load_notetags_ehpb#--------------------------------------------------------------------------def self.load_notetags_ecgroups = [$data_actors, $data_classes, $data_skills, $data_items,$data_states, $data_tilesets]for group in groupsfor obj in groupnext if obj.nil?obj.load_notetags_ecendendendend#==============================================================================# ¡ RPG::UsableItem#==============================================================================class RPG::UsableItem < RPG::BaseItem#--------------------------------------------------------------------------# public instance variables#--------------------------------------------------------------------------attr_accessor :pokeballattr_reader :is_a_pokeball#--------------------------------------------------------------------------# common cache: load_notetags_abe#--------------------------------------------------------------------------def load_notetags_ec@is_a_pokeball = false#---self.note.split(/[\r\n]+/).each { |line|case line#---when CRYSTAL::REGEXP::USABLEITEM::POKEBALL@is_a_pokeball = true@pokeball = $1.to_symend} # self.note.split#---endend # RPG::UsableItem#==============================================================================# ■ RPG::Actor#==============================================================================class RPG::Actor < RPG::BaseItem#--------------------------------------------------------------------------# public instance variables#--------------------------------------------------------------------------attr_accessor :pokeball#--------------------------------------------------------------------------# common cache: load_notetags_al#--------------------------------------------------------------------------def load_notetags_ec@pokeball = :normal#---self.note.split(/[\r\n]+/).each { |line|case line#---when CRYSTAL::REGEXP::ACTOR::POKEBALL@pokeball = $1.to_sym#---end} # self.note.split#---endend # RPG::Actor#==============================================================================# ■ RPG::Class#==============================================================================class RPG::Class < RPG::BaseItem#--------------------------------------------------------------------------# public instance variables#--------------------------------------------------------------------------attr_accessor :catch_rateattr_reader :moon_class#--------------------------------------------------------------------------# common cache: load_notetags_tpm#--------------------------------------------------------------------------def load_notetags_ec@catch_rate = CRYSTAL::CAPTURE::DEFAULT_CATCH_RATE@moon_class = false#---self.note.split(/[\r\n]+/).each { |line|case line#---when CRYSTAL::REGEXP::CLASS::CATCH_RATE@catch_rate = $1.to_iwhen CRYSTAL::REGEXP::CLASS::MOON_STONE@moon_class = true#---end} # self.note.split#---endend # RPG::Actor#==============================================================================# ¡ RPG::Enemy#==============================================================================class RPG::State < RPG::BaseItem#--------------------------------------------------------------------------# public instance variables#--------------------------------------------------------------------------attr_accessor :is_a_net_stateattr_accessor :capture_effect#--------------------------------------------------------------------------# common cache: load_notetags_abe#--------------------------------------------------------------------------def load_notetags_ec@is_a_net_state = false@capture_effect = 1#---self.note.split(/[\r\n]+/).each { |line|case line#---when CRYSTAL::REGEXP::STATE::NET_STATE@is_a_net_state = truewhen CRYSTAL::REGEXP::STATE::STATE_EFFECT@capture_effect = eval($1)end} # self.note.split#---endend # RPG::State#==============================================================================# ■ RPG::Tileset#==============================================================================class RPG::Tileset#--------------------------------------------------------------------------# public instance variables#--------------------------------------------------------------------------attr_accessor :water#--------------------------------------------------------------------------# common cache: load_notetags_st#--------------------------------------------------------------------------def load_notetags_ec@water = []#---self.note.split(/[\r\n]+/).each { |line|case line#---when CRYSTAL::REGEXP::TILESET::DIVE_TAG$1.scan(/\d+/).each { |num|@water.push(num.to_i) if num.to_i > 0 }#---end} # self.note.split#---endend # RPG::Tileset#==============================================================================# ■ RPG::Map#==============================================================================class RPG::Map#--------------------------------------------------------------------------# public instance variables#--------------------------------------------------------------------------attr_accessor :dark#--------------------------------------------------------------------------# common cache: load_notetags_ner#--------------------------------------------------------------------------def load_notetags_ec@dark = false#---self.note.split(/[\r\n]+/).each { |line|case line#---when CRYSTAL::REGEXP::MAP::DARK_MAP@dark = true#---end} # self.note.split#---endend # RPG::Map#==============================================================================# ** BattleManager#------------------------------------------------------------------------------# This module manages battle progress.#==============================================================================module BattleManager #-------------------------------------------------------------------------- # * Delete Battler from Action List #-------------------------------------------------------------------------- def self.remove_battler(battler) @action_battlers.delete(battler) endend#==============================================================================# ** SceneManager#------------------------------------------------------------------------------# This module manages scene transitions. For example, it can handle# hierarchical structures such as calling the item screen from the main menu# or returning from the item screen to the main menu.#==============================================================================module SceneManager #-------------------------------------------------------------------------- # * Force Recall #-------------------------------------------------------------------------- def self.force_recall(scene_class) @scene = scene_class endend#==============================================================================# ** Game_Map#------------------------------------------------------------------------------# This class handles maps. It includes scrolling and passage determination# functions. The instance of this class is referenced by $game_map.#==============================================================================class Game_Map#--------------------------------------------------------------------------# alias method: setup#--------------------------------------------------------------------------alias game_map_setup_ec setupdef setup(map_id)game_map_setup_ec(map_id)@map.load_notetags_ecend#--------------------------------------------------------------------------# * Is the Map Dark#--------------------------------------------------------------------------def dark?return @map.darkend#--------------------------------------------------------------------------# * Water Tag#--------------------------------------------------------------------------def water_tag?(dx, dy)return tileset.water.include?(terrain_tag(dx, dy))endend # Game_Map#==============================================================================# ** Game_Player#------------------------------------------------------------------------------# This class handles the player. It includes event starting determinants and# map scrolling functions. The instance of this class is referenced by# $game_player.#==============================================================================class Game_Player < Game_Character#--------------------------------------------------------------------------# * Gets if the Player is on Water#--------------------------------------------------------------------------def on_water_tile?(dx, dy)return water_tag?(@x, @y)endend#==============================================================================# ** Game_Enemy#------------------------------------------------------------------------------# This class handles enemies. It used within the Game_Troop class# ($game_troop).#==============================================================================class Game_Enemy < Game_Battler#--------------------------------------------------------------------------# * Get the Catch Rate#--------------------------------------------------------------------------def catch_rateself.class.catch_rateend #--------------------------------------------------------------------------# * Get the Catch Rate#--------------------------------------------------------------------------def catchable?return false if self.enemy.note =~ /<NO CATCH>/i return false if $imported["CE-Trainers"] && @trained return trueendend#==============================================================================# ** Game_Battler#------------------------------------------------------------------------------# This class deals with battlers. It's used as a superclass of the Game_Actor# and Game_Enemy classes.#==============================================================================class Game_Battler < Game_BattlerBase#--------------------------------------------------------------------------# * Alias method: item_apply#--------------------------------------------------------------------------alias item_apply_capture item_applydef item_apply(user, item)item_apply_capture(user, item)item_capture(user, item) if @result.hit?end#--------------------------------------------------------------------------# * New method: item_tech_point_effect#--------------------------------------------------------------------------def item_capture(user, item)return unless item.is_a_pokeballreturn if actor? sprite.visible = false SceneManager.scene.refresh_spriteset@ball_bonus = 1.0 change = 0 override = falsecase item.pokeballwhen :great@ball_bonus = 1.5when :ultra@ball_bonus = 2.0when :masteroverride = truewhen :safari@ball_bonus = 1.5when :levellevel = user.levelif level <= self.level@ball_bonus = 1.0elsif level / self.level < 2@ball_bonus = 2.0elsif level / self.level < 4@ball_bonus = 4.0else@ball_bonus = 8.0end when :lureif $game_switches[CRYSTAL::CAPTURE::FISHING_SWITCH]@ball_bonus = 3.0end when :heavy if $imported["CE-Pokedex"]if self.weight > 204.8change = -20elsif self.weight > 307.2change = 20elsif self.weight > 409.6change = 30elsechange = 40end endwhen :moonif self.class.moon_class@ball_bonus = 4.0endwhen :loveif $imported["CE-Genders&Forms"]if user.male?if female?case CRYSTAL::CAPTURE::LOVE_BALL_RULE when :same_species @ball_bonus = 8.0 if self.class.id == user.class.id when :same_line if $imported["CE-Daycare&Egg"] @ball_bonus = 8.0 if self.class.egg_makes == user.class.egg_makes end when :egg_group if $imported["CE-Daycare&Egg"] group1 = self.class.egg_groups group2 = user.class.egg_groups @ball_bonus = 8.0 if !(group1 & group2).empty? end when :gender_only @ball_bonus = 8.0 endendelsif user.female?if male? case CRYSTAL::CAPTURE::LOVE_BALL_RULE when :same_species @ball_bonus = 8.0 if self.class.id == user.class.id when :same_line if $imported["CE-Daycare&Egg"] @ball_bonus = 8.0 if self.class.egg_makes == user.class.egg_makes end when :egg_group if $imported["CE-Daycare&Egg"] group1 = self.class.egg_groups group2 = user.class.egg_groups @ball_bonus = 8.0 if !(group1 & group2).empty? end when :gender_only @ball_bonus = 8.0 endendendendwhen :fastif $imported["CE-BSF"]if self.base[6] >= 100@ball_bonus = 4.0endendwhen :park@ball_bonus = 1.5when :net_ballfor state in states@ball_bonus = 3.0 if state.is_a_net_stateendwhen :nest@ball_bonus = [[((40-user.level)/10), 1].max, 4].minwhen :repeat if $imported["CE-Pokedex"] if $game_party.extra_data[:system][:pokedex_data][self.class.id][:owned] @ball_bonus = 3.0 end endwhen :timerturn = $game_troop.turn_count@ball_bonus = [[(turns/2.5), 1].max, 4].minwhen :diveif $game_player.on_water_tile@ball_bonus = 3.5endwhen :duskif $game_map.dark?@ball_bonus = 3.5endwhen :quickif $game_troop.turn_count == 1@ball_bonus = 4.0endwhen :parkoverride = truewhen :dreamoverride = true else @ball_bonus *= CRYSTAL::CAPTURE.custom_effects(item.pokeball, @ball_bonus)end rate = (3 * self.mhp - 2 * self.hp) * (self.class.catch_rate + change) * @ball_bonusrate /= 3 * self.mhpfor state in self.statesrate *= state.capture_effectendcatch = rand(100)if (catch <= rate) || override @result.success = trueif SceneManager.scene_is?(Scene_Battle)SceneManager.scene.display_capture_result(self, true)endprocess_capture(item.pokeball)else sprite.visible = true SceneManager.scene.refresh_spritesetif SceneManager.scene_is?(Scene_Battle)SceneManager.scene.display_capture_result(self, false)endendend#--------------------------------------------------------------------------# * Process Capture#--------------------------------------------------------------------------def process_capture(pokeball)return if actor? @transform_target = nil if $imported["CE-Tranform"] @trainer.current_team.delete(self) if $imported["CE-PBS"] && @trained $game_troop.delete_enemy(self) @trainer.current_team.delete(self) if @trainedbasic_actor = $data_actors[CRYSTAL::CAPTURE::CAPTURE_BASE].dupbasic_actor.id = $data_actors.sizebasic_actor.class_id = class_idbasic_actor.initial_level = levelbasic_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 endbasic_actor.description = self.class.description if $imported["CE-EnemyClasses"] && $imported["YEA-ClassSystem"]basic_actor.pokeball = pokeball if $imported["BubsGenderFunctions"] && !$imported["CE-Genders&Forms"] basic_actor.gender = enemy.gender 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.iv = @iv actor.nature = nature actor.ev = @ev actor.base = @base end actor.hp = [@hp, actor.mhp].min if $imported["CE-Genders&Forms"] actor.gender = @gender end if $imported["CE-Abilities"] actor.ability = ability actor.ability_flag = ability_flag end if $imported["CE-EnemyEquipment"] equips.each_with_index do |index, equip| actor.change_equip(index, equip) end actor.release_unequippable_items(true) end actor.make_shadow if $imported["CE-ShadowPokemon"] && shadow? 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(skill_id, false) 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$game_party.add_actor(actor.id) $game_message.add("Do you want to name captured Pokémon?") create_command_window actor.recover_all unless pokeball = :healactor.pokerus_infect if $imported["CE-Pokerus"] && self.infected? BattleManager.sendout_status = :checking if $imported["CE-PBS"]=begin SceneManager.scene.rename_capture(actor)actor.recover_all unless pokeball = :healactor.pokerus_infect if $imported["CE-Pokerus"] && self.infected? BattleManager.sendout_status = :checking if $imported["CE-PBS"]=endendend#==============================================================================# ** Game_Troop#------------------------------------------------------------------------------# This class handles enemy groups and battle-related data. Also performs# battle events. The instance of this class is referenced by $game_troop.#==============================================================================class Game_Troop < Game_Unit #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def delete_enemy(enemy) @enemies.delete(enemy) BattleManager.remove_battler(enemy) endend#==============================================================================# ** Game_Interpreter#------------------------------------------------------------------------------# An interpreter for executing event commands. This class is used within the# Game_Map, Game_Troop, and Game_Event classes.#==============================================================================class Game_Interpreter#--------------------------------------------------------------------------# * Add Enemy to Party#--------------------------------------------------------------------------def add_enemy(class_id, level, pokeball = :normal)basic_actor = $data_actors[CRYSTAL::CAPTURE::CAPTURE_BASE].dupbasic_actor.id = $data_actors.sizebasic_actor.class_id = class_id basic_actor.name = $data_classes[class_id].namebasic_actor.initial_level = level$data_actors.push(basic_actor) $game_party.extra_data[:actors].push(basic_actor)actor = $game_actors[basic_actor.id]$game_party.add_actor(actor.id)unless $imported["CE-ShadowPokemon"] && actor.shadow? SceneManager.call(RenameOptions) =begin SceneManager.call(Scene_Name)SceneManager.scene.prepare(actor.id, 12)Fiber.yield=end endendend#==============================================================================# ** Window_BattleEnemy#------------------------------------------------------------------------------# This window display a list of enemies on the battle screen.#==============================================================================class Window_BattleEnemy < Window_Selectable #-------------------------------------------------------------------------- # * Get Activation State of Selection Item #-------------------------------------------------------------------------- alias current_item_enabled_ce_enemy_capture? current_item_enabled? def current_item_enabled? return false if BattleManager.actor.input.item.is_a_pokeball && !enemy.catchable? return current_item_enabled_ce_enemy_capture? endend#==============================================================================# ** Window_BattleLog+#------------------------------------------------------------------------------# This window is for displaying battle progress. No frame is displayed, but it# is handled as a window for convenience.#==============================================================================class Window_BattleLog < Window_Selectable#--------------------------------------------------------------------------# * Display a Capture Result#--------------------------------------------------------------------------def display_capture_result(subject, result)if resultadd_text("Gotcha! #{subject.name} was caught!")waitelsemessage = rand(3)case messagewhen 0add_text("Oh no! The Pokémon broke free!")when 1add_text("Aww... It appeared to be caught!")when 2add_text("Aargh! Almost had it!")elseadd_text("Shoot! It was so close, too!")endend 3.times do wait end wait_and_clearendend#==============================================================================# ** Scene_Base#------------------------------------------------------------------------------# This is a super class of all scenes within the game.#==============================================================================class Scene_Base #--------------------------------------------------------------------------# * Rename a Capture#--------------------------------------------------------------------------def rename_capture(actor)return if $imported["CE-ShadowPokemon"] && actor.shadow?Graphics.freeze SceneManager.snapshot_for_background SceneManager.call(Scene_Name)SceneManager.scene.prepare(actor.id, 10) SceneManager.scene.main SceneManager.force_recall(self) perform_transitionendend#==============================================================================# ** Scene_Battle#------------------------------------------------------------------------------# This class performs battle screen processing.#==============================================================================class Scene_Battle < Scene_Base#--------------------------------------------------------------------------# * Display a Capture Result#--------------------------------------------------------------------------def display_capture_result(subject, result)@log_window.display_capture_result(subject, result)endendclass RenameOptions < Scene_MenuBase def start super create_command_window end def create_command_window @command_window = RenameWindow.new @command_window.set_handler(:yes, method(:renaming)) @command_window.set_handler(:no, method(:return_scene)) end def renaming(actor) SceneManager.call(Scene_Name) SceneManager.scene.prepare(actor.id, 12) Fiber.yield end def return_scene SceneManager.return endendclass RenameWindow < Window_Command def initialize super(550, 330) end def window_width return 90 end def window_height return 90 end def make_command_list add_command("Yes", :yes) add_command("No", :no) endend