Advertisement
Dekita

capts

Nov 23rd, 2012
1,694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.83 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's Beta
  3. ★ Pokémon Capture™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script replicates the capture feature from pokemon, e.g capture enemies
  9. and add them into the party.
  10.  
  11. NOTE : this script clones actors, therefor ifusing my natures iv and ev script
  12. each captured actor wil gain random ev iv and natures, if using my enemy level
  13. iv and nature script the actor will also repicate the enemy 100%
  14.  
  15. ================================================================================
  16. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  17. ================================================================================
  18. 1. You must give credit to "Dekita"
  19. 2. You are NOT allowed to repost this script.(or modified versions)
  20. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  21. 4. You are NOT allowed to use this script for Commercial games.
  22. 5. ENJOY!
  23.  
  24. "FINE PRINT"
  25. By using this script you hereby agree to the above terms and conditions,
  26. if any violation of the above terms occurs "legal action" may be taken.
  27. Not understanding the above terms and conditions does NOT mean that
  28. they do not apply to you.
  29. If you wish to discuss the terms and conditions in further detail you can
  30. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  31.  
  32. ================================================================================
  33. History:
  34. =========
  35. D /M /Y
  36. 13/11/2o12 - finished,
  37.  
  38. ================================================================================
  39. Credit and Thanks to :
  40. =======================
  41.  
  42. ================================================================================
  43. Known Bugs:
  44. ============
  45. N/A
  46.  
  47. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  48. If a new bug is found please contact me at
  49. http://dekitarpg.wordpress.com/
  50.  
  51. ================================================================================
  52. INSTRUCTIONS:
  53. ==============
  54. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  55. Place this script below "Dekita Pokémon CORE"
  56.  
  57. ================================================================================
  58. Notetags:
  59. ==========
  60. ~ ENEMIES
  61. <poke id: X>
  62. notetag for enemies so the game knows which actor
  63. to aqquire when enemy is captured.
  64. Replace X with the actors id
  65.  
  66. <catch rate: X>
  67. notetag for enemies catch rates
  68. replace X with a value between 0 - 255
  69. Higher = Easier to catch (default is random)
  70.  
  71. ~ SKILLS / ITEMS
  72. <pokeball: X>
  73. replace X with a float value (e.g 1.8) to change that items capture rate
  74. NOTE : capture rates are usually between 1.0 and 3.5 (modern pokemon games)
  75. NOTE 2 : Masterballs have a value of 255 (this guarantees capture)
  76.  
  77. ~ STATUS EFFECTS (states)
  78. <capt rate mod: X>
  79. Notetag for status effects to modify capture rate
  80. replace X with a float value (e.g 1.8)
  81. Note : stat modifiers are usually between 1.0 - 2.0
  82. Default is 1.0
  83.  
  84.  
  85.  
  86. SCRIPT CALLS
  87.  
  88. $game_party.party_can_capture = boolean
  89.  
  90. replace boolean with true or false
  91. true = can capture enemies
  92. false = can't
  93.  
  94. =end #==========================================================================#
  95. module Dekita__Pokémon_Capture
  96. #==============================================================================
  97.  
  98. # This is the animation that happens when a pokemon breaks out
  99. # of the pokeball.
  100. Capture_Fail_Ani = 37
  101.  
  102. # Time to wait before capture success / failure
  103. Capture_Wait_time = 360 # Frames
  104.  
  105. # CUSTOMISATION END
  106.  
  107. end # Dekita__Pokémon_Capture
  108.  
  109. $imported = {} if $imported.nil?
  110. $imported[:Dekita_Pokémon_Capture] = true
  111.  
  112. #==============================================================================
  113. module DataManager
  114. #==============================================================================
  115.  
  116. class <<self; alias load_database_Poké_Capt load_database; end
  117. def self.load_database
  118. load_database_Poké_Capt
  119. load_notetags_Poké_Capt
  120. end
  121.  
  122. def self.load_notetags_Poké_Capt
  123. groups = [$data_items, $data_enemies, $data_states]
  124. for group in groups
  125. for obj in group
  126. next if obj.nil?
  127. obj.load_notetags_Poké_Capt
  128. end
  129. end
  130. end
  131.  
  132. end # DataManager
  133.  
  134. #==============================================================================
  135. module BattleManager
  136. #==============================================================================
  137. class <<self; alias bmanager_Process_Vict_for_Capturez process_victory; end
  138. def self.process_victory
  139. bmanager_Process_Vict_for_Capturez
  140. addthepokemonintoparty
  141. end
  142.  
  143. def self.addthepokemonintoparty
  144. $game_troop.members.each do |member|
  145. next unless $data_enemies[member.enemy_id].note =~ /<poke id: (.*)>/i
  146. next unless member.captured
  147. $game_temp.captured_enemy = member
  148. $game_party.capture_pokemon($data_enemies[member.enemy_id].pokemon_id)
  149. end
  150. $game_temp.captured_enemy = nil
  151. $game_temp.captured_enemyBEFORE = [nil, nil, [nil]]
  152. end
  153.  
  154. end # BattleManager
  155.  
  156. #===============================================================================#
  157. class Game_Temp
  158. #===============================================================================#
  159.  
  160. attr_accessor :captured_enemy
  161. attr_accessor :captured_enemyBEFORE
  162. attr_accessor :pokeball_used
  163.  
  164. attr_accessor :capture_status
  165.  
  166. alias pokecapturegtinit initialize
  167. def initialize
  168. pokecapturegtinit
  169. @captured_enemy = nil
  170. @captured_enemyBEFORE = [nil, nil, [nil]] # [hp , mp, [states]]
  171. @pokeball_used = []
  172. @capture_status = [false, 0]
  173. end
  174.  
  175. end # Game_Temp
  176.  
  177. #==============================================================================
  178. class Game_Party < Game_Unit
  179. #==============================================================================
  180.  
  181. attr_accessor :party_can_capture
  182.  
  183. alias canptureinit initialize
  184. def initialize
  185. canptureinit
  186. @party_can_capture = true
  187. end
  188.  
  189. def capture_pokemon(actor_id)
  190. new_actor = $data_actors[actor_id].clone
  191. new_actor.id = $data_actors.size
  192. $data_actors.push(new_actor)
  193. @actors.push(new_actor.id) unless @actors.include?(new_actor.id)
  194. $game_player.refresh
  195. $game_map.need_refresh = true
  196. get_enemy_stats(new_actor.id)
  197. get_pokeball_aftermod(new_actor.id)
  198. end
  199.  
  200. def get_enemy_stats(actor_id)
  201. _GT = $game_temp.captured_enemy
  202. _GTB = $game_temp.captured_enemyBEFORE
  203. _GA = $game_actors[actor_id]
  204. get_nature_shit(_GA, _GT) if $imported[:Dekita_Pokémon_Enemies]
  205. get_regular_shit(_GA, _GT, _GTB)
  206. end
  207.  
  208. def get_nature_shit(_GA, _GT)
  209. 8.times {|i| _GA.init_ivs[i] = _GT.init_ivs[i] }
  210. _GA.nature = _GT.nature
  211. end
  212.  
  213. def get_regular_shit(_GA, _GT, _GTB)
  214. _GA.change_level(_GT.level, false) if $imported[:Dekita_Pokémon_Enemies]
  215. _GA.hp = _GTB[0]
  216. _GA.mp = _GTB[1]
  217. _GTB[2].each {|state| _GA.add_state(state.id) }
  218. end
  219.  
  220. def get_pokeball_aftermod(actor_id)
  221. _GA = $game_actors[actor_id]
  222. end
  223.  
  224.  
  225. end
  226.  
  227.  
  228. #==============================================================================
  229. class RPG::Enemy < RPG::BaseItem
  230. #==============================================================================
  231.  
  232. attr_accessor :pokemon_id
  233. attr_accessor :catch_rate
  234.  
  235. def load_notetags_Poké_Capt
  236. @pokemon_id = 0
  237. @catch_rate = rand(256)
  238. self.note.split(/[\r\n]+/).each { |line|
  239. case line
  240. when /<poke id: (.*)>/i
  241. @pokemon_id = $1.to_i
  242. #---
  243. when /<catch rate: (.*)>/i
  244. @catch_rate = $1.to_i
  245. #---
  246. end
  247. } # self.note.split
  248. #---
  249. end
  250.  
  251. end # RPG::Enemy
  252.  
  253. #==============================================================================
  254. class RPG::State < RPG::BaseItem
  255. #==============================================================================
  256.  
  257. attr_accessor :capture_modifier
  258.  
  259. def load_notetags_Poké_Capt
  260. @capture_modifier = 1.0
  261. self.note.split(/[\r\n]+/).each { |line|
  262. case line
  263. when /<capt rate mod: (.*)>/i
  264. @capture_modifier = $1.to_f
  265. #---
  266. end
  267. } # self.note.split
  268. #---
  269. end
  270.  
  271. end # RPG::State < RPG::BaseItem
  272.  
  273. #==============================================================================
  274. class RPG::UsableItem < RPG::BaseItem
  275. #==============================================================================
  276.  
  277. attr_accessor :capture_item
  278. attr_accessor :pokeball_capt_rate
  279.  
  280. attr_accessor :pokeball_effect
  281.  
  282. def load_notetags_Poké_Capt
  283. @capture_item = false
  284. @pokeball_capt_rate = 0.0
  285. @pokeball_effect = [false, 0]
  286. self.note.split(/[\r\n]+/).each { |line|
  287. case line
  288. when /<pokeball: (.*)>/i
  289. @pokeball_capt_rate = $1.to_f
  290. @capture_item = true
  291. end
  292. } # self.note.split
  293. #---
  294. end
  295.  
  296. def get_pokeball_type
  297. end
  298.  
  299.  
  300. end # RPG::Enemy
  301.  
  302. #==============================================================================
  303. class Game_Enemy < Game_Battler
  304. #==============================================================================
  305.  
  306. attr_accessor :captured
  307. attr_accessor :pokemon_id
  308. attr_accessor :catch_rate
  309.  
  310. alias gamepokenmyinit initialize
  311. def initialize(index, enemy_id)
  312. gamepokenmyinit(index, enemy_id)
  313. @captured = false
  314. @pokemon_id = $data_enemies[enemy_id].pokemon_id
  315. @catch_rate = $data_enemies[enemy_id].catch_rate
  316. end
  317.  
  318. alias captred_pokemon_xp_rate exp
  319. def exp
  320. return 0 if @captured == true
  321. captred_pokemon_xp_rate
  322. end
  323.  
  324. alias captred_pokemon_gold_rate gold
  325. def gold
  326. return 0 if @captured == true
  327. captred_pokemon_gold_rate
  328. end
  329.  
  330. alias captred_pokemon_drop_items_rate drop_item_rate
  331. def drop_item_rate
  332. return 0 if @captured == true
  333. captred_pokemon_drop_items_rate
  334. end
  335.  
  336. end # Game_Enemy
  337.  
  338. #==============================================================================
  339. class Scene_Battle < Scene_Base
  340. #==============================================================================
  341.  
  342.  
  343. alias capturebattlesstart start
  344. def start
  345. capturebattlesstart
  346. @battle_turn_count = 0
  347. @capturing_now = false
  348. @inside_pokeball = false
  349. @capture_failed = false
  350. end
  351.  
  352. alias invoke_pokemon_captureitem invoke_item
  353. def invoke_item(target, item)
  354. if target.is_a?(Game_Enemy) && !(target.pokemon_id == (nil || 0)) && item.capture_item
  355. capture_pokemon?(target, item)
  356. end
  357. invoke_pokemon_captureitem(target, item)
  358. end
  359.  
  360. def capture_pokemon?(target, item)
  361. if $game_party.party_can_capture
  362. @capturing_now = true
  363. did_capture?(target, item)
  364. else
  365. $game_message.add("Cant Capture This Enemy")
  366. end
  367. end
  368.  
  369. def did_capture?(target, item)
  370. ball_rate = get_pokeball_capture_rate(target, item)
  371. t = target
  372. status_capt_mod = get_states_modifier(t)
  373. catchValue = ((3*t.mhp-2*t.hp)*(t.catch_rate*ball_rate)/(3*t.mhp))*status_capt_mod
  374. catch = (2**20-2**4)/Math.sqrt(Math.sqrt((2**24-2**16)/catchValue))
  375. regular_capture(t, item, catch.round)
  376. p "catchValue = #{catchValue}"
  377. p "catch = #{catch}"
  378. end
  379.  
  380. def get_pokeball_capture_rate(target, item)
  381. value = item.pokeball_capt_rate
  382. return value
  383. end
  384.  
  385. def get_states_modifier(target)
  386. value = 1.0
  387. t = target
  388. t.states.size.times {|i| value *= t.states[i].capture_modifier }
  389. return value
  390. end
  391.  
  392. def masterball_capture(target, item)
  393. amount = Dekita__Pokémon_Capture::Capture_Wait_time
  394. target.captured = true
  395.  
  396. amount.times {|i| update_for_wait }
  397. sucessfullcapture(target, item)
  398. end
  399.  
  400. def regular_capture(target, item, catch)
  401. amount = (Dekita__Pokémon_Capture::Capture_Wait_time).to_i
  402. value = catch
  403. success = rand(65535+1)
  404. target.animation_id = 37
  405. @inside_pokeball = true
  406. 60.times {||update_basic }
  407. target.screen_y -= (Graphics.height * 2)
  408. amount.times {|i| update_for_wait }
  409. if success > value
  410. p "Failed at try 1"
  411. else
  412. success = rand(65535+1)
  413. if success > value
  414. p "Failed at try 2"
  415. else
  416. success = rand(65535+1)
  417. if success > value
  418. p "Failed at try 3"
  419. else
  420. target.captured = true
  421. $game_temp.pokeball_used.push(item)
  422. end
  423. end
  424. end
  425. if target.captured
  426. sucessfullcapture(target, item)
  427. else
  428. capture_failed(target, item)
  429. end
  430. end
  431.  
  432.  
  433. def sucessfullcapture(target, item)
  434. $game_temp.captured_enemyBEFORE[0] = target.hp
  435. $game_temp.captured_enemyBEFORE[1] = target.mp
  436. $game_temp.captured_enemyBEFORE[2] = target.states
  437. target.hp -= target.hp
  438. end
  439.  
  440. def capture_failed(target, item)
  441. @capture_failed = true
  442. target.screen_y += (Graphics.height * 2)
  443. target.animation_id = Dekita__Pokémon_Capture::Capture_Fail_Ani
  444. 20.times {|i| update_for_wait }
  445. end
  446.  
  447. def pokemon_already_captured?(poke_id)
  448. istrue = 0
  449. $game_party.members.size.times{|i|
  450. istrue += 1 if $game_party.members[i].pokemon_database_id == poke_id
  451. }
  452. return true if istrue > 0
  453. return false
  454. end
  455.  
  456. alias turn_end_count_forpoke turn_end
  457. def turn_end
  458. turn_end_count_forpoke
  459. @battle_turn_count += 1
  460. p "#{@battle_turn_count} <= @battle_turn_count"
  461. end
  462.  
  463. end
  464. #===============================================================================#
  465. # - SCRIPT END - #
  466. #===============================================================================#
  467. # http://dekitarpg.wordpress.com/ #
  468. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement