Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin =========================================================================
- Dekita's Beta
- ★ Pokémon Capture™ ★
- ================================================================================
- Script Information:
- ====================
- This script replicates the capture feature from pokemon, e.g capture enemies
- and add them into the party.
- NOTE : this script clones actors, therefor ifusing my natures iv and ev script
- each captured actor wil gain random ev iv and natures, if using my enemy level
- iv and nature script the actor will also repicate the enemy 100%
- ================================================================================
- ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- ================================================================================
- 1. You must give credit to "Dekita"
- 2. You are NOT allowed to repost this script.(or modified versions)
- 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
- 4. You are NOT allowed to use this script for Commercial games.
- 5. ENJOY!
- "FINE PRINT"
- By using this script you hereby agree to the above terms and conditions,
- if any violation of the above terms occurs "legal action" may be taken.
- Not understanding the above terms and conditions does NOT mean that
- they do not apply to you.
- If you wish to discuss the terms and conditions in further detail you can
- contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
- ================================================================================
- History:
- =========
- D /M /Y
- 13/11/2o12 - finished,
- ================================================================================
- Credit and Thanks to :
- =======================
- ================================================================================
- Known Bugs:
- ============
- N/A
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- If a new bug is found please contact me at
- http://dekitarpg.wordpress.com/
- ================================================================================
- INSTRUCTIONS:
- ==============
- Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
- Place this script below "Dekita Pokémon CORE"
- ================================================================================
- Notetags:
- ==========
- ~ ENEMIES
- <poke id: X>
- notetag for enemies so the game knows which actor
- to aqquire when enemy is captured.
- Replace X with the actors id
- <catch rate: X>
- notetag for enemies catch rates
- replace X with a value between 0 - 255
- Higher = Easier to catch (default is random)
- ~ SKILLS / ITEMS
- <pokeball: X>
- replace X with a float value (e.g 1.8) to change that items capture rate
- NOTE : capture rates are usually between 1.0 and 3.5 (modern pokemon games)
- NOTE 2 : Masterballs have a value of 255 (this guarantees capture)
- ~ STATUS EFFECTS (states)
- <capt rate mod: X>
- Notetag for status effects to modify capture rate
- replace X with a float value (e.g 1.8)
- Note : stat modifiers are usually between 1.0 - 2.0
- Default is 1.0
- SCRIPT CALLS
- $game_party.party_can_capture = boolean
- replace boolean with true or false
- true = can capture enemies
- false = can't
- =end #==========================================================================#
- module Dekita__Pokémon_Capture
- #==============================================================================
- # This is the animation that happens when a pokemon breaks out
- # of the pokeball.
- Capture_Fail_Ani = 37
- # Time to wait before capture success / failure
- Capture_Wait_time = 360 # Frames
- # CUSTOMISATION END
- end # Dekita__Pokémon_Capture
- $imported = {} if $imported.nil?
- $imported[:Dekita_Pokémon_Capture] = true
- #==============================================================================
- module DataManager
- #==============================================================================
- class <<self; alias load_database_Poké_Capt load_database; end
- def self.load_database
- load_database_Poké_Capt
- load_notetags_Poké_Capt
- end
- def self.load_notetags_Poké_Capt
- groups = [$data_items, $data_enemies, $data_states]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_notetags_Poké_Capt
- end
- end
- end
- end # DataManager
- #==============================================================================
- module BattleManager
- #==============================================================================
- class <<self; alias bmanager_Process_Vict_for_Capturez process_victory; end
- def self.process_victory
- bmanager_Process_Vict_for_Capturez
- addthepokemonintoparty
- end
- def self.addthepokemonintoparty
- $game_troop.members.each do |member|
- next unless $data_enemies[member.enemy_id].note =~ /<poke id: (.*)>/i
- next unless member.captured
- $game_temp.captured_enemy = member
- $game_party.capture_pokemon($data_enemies[member.enemy_id].pokemon_id)
- end
- $game_temp.captured_enemy = nil
- $game_temp.captured_enemyBEFORE = [nil, nil, [nil]]
- end
- end # BattleManager
- #===============================================================================#
- class Game_Temp
- #===============================================================================#
- attr_accessor :captured_enemy
- attr_accessor :captured_enemyBEFORE
- attr_accessor :pokeball_used
- attr_accessor :capture_status
- alias pokecapturegtinit initialize
- def initialize
- pokecapturegtinit
- @captured_enemy = nil
- @captured_enemyBEFORE = [nil, nil, [nil]] # [hp , mp, [states]]
- @pokeball_used = []
- @capture_status = [false, 0]
- end
- end # Game_Temp
- #==============================================================================
- class Game_Party < Game_Unit
- #==============================================================================
- attr_accessor :party_can_capture
- alias canptureinit initialize
- def initialize
- canptureinit
- @party_can_capture = true
- end
- def capture_pokemon(actor_id)
- new_actor = $data_actors[actor_id].clone
- new_actor.id = $data_actors.size
- $data_actors.push(new_actor)
- @actors.push(new_actor.id) unless @actors.include?(new_actor.id)
- $game_player.refresh
- $game_map.need_refresh = true
- get_enemy_stats(new_actor.id)
- get_pokeball_aftermod(new_actor.id)
- end
- def get_enemy_stats(actor_id)
- _GT = $game_temp.captured_enemy
- _GTB = $game_temp.captured_enemyBEFORE
- _GA = $game_actors[actor_id]
- get_nature_shit(_GA, _GT) if $imported[:Dekita_Pokémon_Enemies]
- get_regular_shit(_GA, _GT, _GTB)
- end
- def get_nature_shit(_GA, _GT)
- 8.times {|i| _GA.init_ivs[i] = _GT.init_ivs[i] }
- _GA.nature = _GT.nature
- end
- def get_regular_shit(_GA, _GT, _GTB)
- _GA.change_level(_GT.level, false) if $imported[:Dekita_Pokémon_Enemies]
- _GA.hp = _GTB[0]
- _GA.mp = _GTB[1]
- _GTB[2].each {|state| _GA.add_state(state.id) }
- end
- def get_pokeball_aftermod(actor_id)
- _GA = $game_actors[actor_id]
- end
- end
- #==============================================================================
- class RPG::Enemy < RPG::BaseItem
- #==============================================================================
- attr_accessor :pokemon_id
- attr_accessor :catch_rate
- def load_notetags_Poké_Capt
- @pokemon_id = 0
- @catch_rate = rand(256)
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<poke id: (.*)>/i
- @pokemon_id = $1.to_i
- #---
- when /<catch rate: (.*)>/i
- @catch_rate = $1.to_i
- #---
- end
- } # self.note.split
- #---
- end
- end # RPG::Enemy
- #==============================================================================
- class RPG::State < RPG::BaseItem
- #==============================================================================
- attr_accessor :capture_modifier
- def load_notetags_Poké_Capt
- @capture_modifier = 1.0
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<capt rate mod: (.*)>/i
- @capture_modifier = $1.to_f
- #---
- end
- } # self.note.split
- #---
- end
- end # RPG::State < RPG::BaseItem
- #==============================================================================
- class RPG::UsableItem < RPG::BaseItem
- #==============================================================================
- attr_accessor :capture_item
- attr_accessor :pokeball_capt_rate
- attr_accessor :pokeball_effect
- def load_notetags_Poké_Capt
- @capture_item = false
- @pokeball_capt_rate = 0.0
- @pokeball_effect = [false, 0]
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<pokeball: (.*)>/i
- @pokeball_capt_rate = $1.to_f
- @capture_item = true
- end
- } # self.note.split
- #---
- end
- def get_pokeball_type
- end
- end # RPG::Enemy
- #==============================================================================
- class Game_Enemy < Game_Battler
- #==============================================================================
- attr_accessor :captured
- attr_accessor :pokemon_id
- attr_accessor :catch_rate
- alias gamepokenmyinit initialize
- def initialize(index, enemy_id)
- gamepokenmyinit(index, enemy_id)
- @captured = false
- @pokemon_id = $data_enemies[enemy_id].pokemon_id
- @catch_rate = $data_enemies[enemy_id].catch_rate
- end
- alias captred_pokemon_xp_rate exp
- def exp
- return 0 if @captured == true
- captred_pokemon_xp_rate
- end
- alias captred_pokemon_gold_rate gold
- def gold
- return 0 if @captured == true
- captred_pokemon_gold_rate
- end
- alias captred_pokemon_drop_items_rate drop_item_rate
- def drop_item_rate
- return 0 if @captured == true
- captred_pokemon_drop_items_rate
- end
- end # Game_Enemy
- #==============================================================================
- class Scene_Battle < Scene_Base
- #==============================================================================
- alias capturebattlesstart start
- def start
- capturebattlesstart
- @battle_turn_count = 0
- @capturing_now = false
- @inside_pokeball = false
- @capture_failed = false
- end
- alias invoke_pokemon_captureitem invoke_item
- def invoke_item(target, item)
- if target.is_a?(Game_Enemy) && !(target.pokemon_id == (nil || 0)) && item.capture_item
- capture_pokemon?(target, item)
- end
- invoke_pokemon_captureitem(target, item)
- end
- def capture_pokemon?(target, item)
- if $game_party.party_can_capture
- @capturing_now = true
- did_capture?(target, item)
- else
- $game_message.add("Cant Capture This Enemy")
- end
- end
- def did_capture?(target, item)
- ball_rate = get_pokeball_capture_rate(target, item)
- t = target
- status_capt_mod = get_states_modifier(t)
- catchValue = ((3*t.mhp-2*t.hp)*(t.catch_rate*ball_rate)/(3*t.mhp))*status_capt_mod
- catch = (2**20-2**4)/Math.sqrt(Math.sqrt((2**24-2**16)/catchValue))
- regular_capture(t, item, catch.round)
- p "catchValue = #{catchValue}"
- p "catch = #{catch}"
- end
- def get_pokeball_capture_rate(target, item)
- value = item.pokeball_capt_rate
- return value
- end
- def get_states_modifier(target)
- value = 1.0
- t = target
- t.states.size.times {|i| value *= t.states[i].capture_modifier }
- return value
- end
- def masterball_capture(target, item)
- amount = Dekita__Pokémon_Capture::Capture_Wait_time
- target.captured = true
- amount.times {|i| update_for_wait }
- sucessfullcapture(target, item)
- end
- def regular_capture(target, item, catch)
- amount = (Dekita__Pokémon_Capture::Capture_Wait_time).to_i
- value = catch
- success = rand(65535+1)
- target.animation_id = 37
- @inside_pokeball = true
- 60.times {||update_basic }
- target.screen_y -= (Graphics.height * 2)
- amount.times {|i| update_for_wait }
- if success > value
- p "Failed at try 1"
- else
- success = rand(65535+1)
- if success > value
- p "Failed at try 2"
- else
- success = rand(65535+1)
- if success > value
- p "Failed at try 3"
- else
- target.captured = true
- $game_temp.pokeball_used.push(item)
- end
- end
- end
- if target.captured
- sucessfullcapture(target, item)
- else
- capture_failed(target, item)
- end
- end
- def sucessfullcapture(target, item)
- $game_temp.captured_enemyBEFORE[0] = target.hp
- $game_temp.captured_enemyBEFORE[1] = target.mp
- $game_temp.captured_enemyBEFORE[2] = target.states
- target.hp -= target.hp
- end
- def capture_failed(target, item)
- @capture_failed = true
- target.screen_y += (Graphics.height * 2)
- target.animation_id = Dekita__Pokémon_Capture::Capture_Fail_Ani
- 20.times {|i| update_for_wait }
- end
- def pokemon_already_captured?(poke_id)
- istrue = 0
- $game_party.members.size.times{|i|
- istrue += 1 if $game_party.members[i].pokemon_database_id == poke_id
- }
- return true if istrue > 0
- return false
- end
- alias turn_end_count_forpoke turn_end
- def turn_end
- turn_end_count_forpoke
- @battle_turn_count += 1
- p "#{@battle_turn_count} <= @battle_turn_count"
- end
- end
- #===============================================================================#
- # - SCRIPT END - #
- #===============================================================================#
- # http://dekitarpg.wordpress.com/ #
- #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement