1. ################################################################################
  2. #
  3. # GameData::Species changes.
  4. #
  5. ################################################################################
  6.  
  7.  
  8. module GameData
  9. class Species
  10. #---------------------------------------------------------------------------
  11. # Aliased so that moves can be set as learnable at Lvl -1.
  12. # This is used for Move Reminder-exclusive moves.
  13. #---------------------------------------------------------------------------
  14. Species.singleton_class.alias_method :paldea_schema, :schema
  15. def self.schema(compiling_forms = false)
  16. ret = self.paldea_schema(compiling_forms)
  17. ret["Moves"] = [:moves, "*ie", nil, :Move]
  18. return ret
  19. end
  20.  
  21. #---------------------------------------------------------------------------
  22. # Aliased so that Incense is no longer required for hatching baby Pokemon.
  23. #---------------------------------------------------------------------------
  24. alias paldea_get_baby_species get_baby_species
  25. def get_baby_species(*args)
  26. if Settings::MECHANICS_GENERATION >= 9
  27. return paldea_get_baby_species(false, nil, nil)
  28. end
  29. return paldea_get_baby_species(*args)
  30. end
  31. end
  32. end
  33.  
  34.  
  35. ################################################################################
  36. #
  37. # Pokemon class additions.
  38. #
  39. ################################################################################
  40.  
  41.  
  42. class Pokemon
  43. alias paldea_initialize initialize
  44. def initialize(species, level, owner = $player, withMoves = true, recheck_form = true)
  45. paldea_initialize(species, level, owner, withMoves, recheck_form)
  46. @evo_move_count = {}
  47. @evo_crest_count = {}
  48. @evo_recoil_count = 0
  49. @evo_step_count = 0
  50. if @species == :BASCULEGION && recheck_form
  51. f = MultipleForms.call("getFormOnCreation", self)
  52. if f
  53. self.form = f
  54. reset_moves if withMoves
  55. end
  56. end
  57. end
  58.  
  59. #-----------------------------------------------------------------------------
  60. # Move count evolution utilities.
  61. #-----------------------------------------------------------------------------
  62. def init_evo_move_count(move)
  63. @evo_move_count = Hash.new if !@evo_move_count
  64. @evo_move_count[move] = 0 if !@evo_move_count[move]
  65. end
  66.  
  67. def move_count_evolution(move, qty = 1)
  68. species_data.get_evolutions.each do |evo|
  69. if evo[1] == :LevelUseMoveCount && evo[2] == move
  70. init_evo_move_count(move)
  71. @evo_move_count[move] += qty
  72. break
  73. end
  74. end
  75. end
  76.  
  77. def evo_move_count(move)
  78. init_evo_move_count(move)
  79. return @evo_move_count[move]
  80. end
  81.  
  82. def set_evo_move_count(move, value)
  83. init_evo_move_count(move)
  84. @evo_move_count[move] = value
  85. end
  86.  
  87. #-----------------------------------------------------------------------------
  88. # Leader's crest evolution utilities.
  89. #-----------------------------------------------------------------------------
  90. def init_evo_crest_count(item)
  91. @evo_crest_count = Hash.new if !@evo_crest_count
  92. @evo_crest_count[item] = 0 if !@evo_crest_count[item]
  93. end
  94.  
  95. def leaders_crest_evolution(item, qty = 1)
  96. species_data.get_evolutions.each do |evo|
  97. if evo[1] == :LevelDefeatItsKindWithItem && evo[2] == item
  98. init_evo_crest_count(item)
  99. @evo_crest_count[item] += qty
  100. break
  101. end
  102. end
  103. end
  104.  
  105. def evo_crest_count(item)
  106. init_evo_crest_count(item)
  107. return @evo_crest_count[item]
  108. end
  109.  
  110. def set_evo_crest_count(item, value)
  111. init_evo_crest_count(item)
  112. @evo_crest_count[item] = value
  113. end
  114.  
  115. #-----------------------------------------------------------------------------
  116. # Recoil damage evolution utilities.
  117. #-----------------------------------------------------------------------------
  118. def recoil_evolution(qty = 1)
  119. species_data.get_evolutions.each do |evo|
  120. if evo[1] == :LevelRecoilDamage
  121. @evo_recoil_count = 0 if !@evo_recoil_count
  122. @evo_recoil_count += qty
  123. break
  124. end
  125. end
  126. end
  127.  
  128. def evo_recoil_count
  129. return @evo_recoil_count || 0
  130. end
  131.  
  132. def evo_recoil_count=(value)
  133. @evo_recoil_count = value
  134. end
  135.  
  136. #-----------------------------------------------------------------------------
  137. # Walking evolution utilities.
  138. #-----------------------------------------------------------------------------
  139. def walking_evolution(qty = 1)
  140. species_data.get_evolutions.each do |evo|
  141. if evo[1] == :LevelWalk
  142. @evo_step_count = 0 if !@evo_step_count
  143. @evo_step_count += qty
  144. break
  145. end
  146. end
  147. end
  148.  
  149. def evo_step_count
  150. return @evo_step_count || 0
  151. end
  152.  
  153. def evo_step_count=(value)
  154. @evo_step_count = value
  155. end
  156.  
  157. #-----------------------------------------------------------------------------
  158. # Edited for Move Relearner-exclusive moves.
  159. #-----------------------------------------------------------------------------
  160. def reset_moves
  161. this_level = self.level
  162. moveset = self.getMoveList
  163. knowable_moves = []
  164. moveset.each { |m| knowable_moves.push(m[1]) if (0..this_level).include?(m[0]) }
  165. knowable_moves = knowable_moves.reverse
  166. knowable_moves |= []
  167. knowable_moves = knowable_moves.reverse
  168. @moves.clear
  169. first_move_index = knowable_moves.length - MAX_MOVES
  170. first_move_index = 0 if first_move_index < 0
  171. (first_move_index...knowable_moves.length).each do |i|
  172. @moves.push(Pokemon::Move.new(knowable_moves[i]))
  173. end
  174. end
  175. end
  176.  
  177.  
  178. ################################################################################
  179. #
  180. # New evolution methods.
  181. #
  182. ################################################################################
  183.  
  184.  
  185. GameData::Evolution.register({
  186. :id => :CollectItems,
  187. :parameter => :Item,
  188. :any_level_up => true, # Needs any level up
  189. :level_up_proc => proc { |pkmn, parameter|
  190. next $bag.quantity(parameter) >= 999
  191. },
  192. :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
  193. next false if evo_species != new_species || $bag.quantity(parameter) < 999
  194. $bag.remove(parameter, 999)
  195. next true
  196. }
  197. })
  198.  
  199. GameData::Evolution.register({
  200. :id => :LevelWithPartner,
  201. :parameter => Integer,
  202. :level_up_proc => proc { |pkmn, parameter|
  203. next pkmn.level >= parameter && $PokemonGlobal.partner
  204. }
  205. })
  206.  
  207. GameData::Evolution.register({
  208. :id => :LevelUseMoveCount,
  209. :parameter => :Move,
  210. :any_level_up => true, # Needs any level up
  211. :level_up_proc => proc { |pkmn, parameter|
  212. next pkmn.evo_move_count(parameter) >= 20
  213. },
  214. :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
  215. next false if evo_species != new_species || pkmn.evo_move_count(parameter) < 20
  216. pkmn.set_evo_move_count(parameter, 0)
  217. next true
  218. }
  219. })
  220.  
  221. GameData::Evolution.register({
  222. :id => :LevelDefeatItsKindWithItem,
  223. :parameter => :Item,
  224. :any_level_up => true, # Needs any level up
  225. :level_up_proc => proc { |pkmn, parameter|
  226. next pkmn.evo_crest_count(parameter) >= 3
  227. },
  228. :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
  229. next false if evo_species != new_species || pkmn.evo_crest_count(parameter) < 3
  230. pkmn.set_evo_crest_count(parameter,0)
  231. next true
  232. }
  233. })
  234.  
  235. GameData::Evolution.register({
  236. :id => :LevelRecoilDamage,
  237. :parameter => Integer,
  238. :any_level_up => true, # Needs any level up
  239. :level_up_proc => proc { |pkmn, parameter|
  240. next pkmn.evo_recoil_count >= parameter
  241. },
  242. :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
  243. next false if evo_species != new_species || pkmn.evo_recoil_count < parameter
  244. pkmn.evo_recoil_count = 0
  245. next true
  246. }
  247. })
  248.  
  249. GameData::Evolution.register({
  250. :id => :LevelWalk,
  251. :parameter => Integer,
  252. :any_level_up => true, # Needs any level up
  253. :level_up_proc => proc { |pkmn, parameter|
  254. next pkmn.evo_step_count >= parameter
  255. },
  256. :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
  257. next false if evo_species != new_species || pkmn.evo_step_count < parameter
  258. pkmn.evo_step_count = 0
  259. next true
  260. }
  261. })
  262.  
  263.  
  264. ################################################################################
  265. #
  266. # Step-based event handlers.
  267. #
  268. ################################################################################
  269.  
  270.  
  271. #-------------------------------------------------------------------------------
  272. # Tracks steps taken to trigger walking evolutions for the lead Pokemon.
  273. #-------------------------------------------------------------------------------
  274. EventHandlers.add(:on_player_step_taken, :evolution_steps, proc {
  275. $player.first_able_pokemon.walking_evolution if $player.party.length > 0 && $player.first_able_pokemon
  276. })
  277.  
  278. #-------------------------------------------------------------------------------
  279. # Initializes Mirror Herb step counter.
  280. #-------------------------------------------------------------------------------
  281. class PokemonGlobalMetadata
  282. attr_accessor :mirrorherb_steps
  283. alias paldea_initialize initialize
  284. def initialize
  285. @mirrorherb_steps = 0
  286. paldea_initialize
  287. end
  288. end
  289.  
  290. #-------------------------------------------------------------------------------
  291. # Tracks steps taken while Pokemon in the party are holding a Mirror Herb.
  292. # Every 256 steps, inherits Egg moves from other party members if possible.
  293. #-------------------------------------------------------------------------------
  294. EventHandlers.add(:on_player_step_taken, :mirrorherb_step, proc {
  295. if $player.able_party.any? { |p| p&.hasItem?(:MIRRORHERB) }
  296. $PokemonGlobal.mirrorherb_steps = 0 if !$PokemonGlobal.mirrorherb_steps
  297. $PokemonGlobal.mirrorherb_steps += 1
  298. if $PokemonGlobal.mirrorherb_steps > 255
  299. found_eggMove = false
  300. $player.able_party.each_with_index do |pkmn, i|
  301. next if pkmn.item != :MIRRORHERB
  302. next if pkmn.numMoves == Pokemon::MAX_MOVES
  303. baby_species = pkmn.species_data.get_baby_species
  304. eggmoves = GameData::Species.get(baby_species).egg_moves.clone
  305. eggmoves.shuffle.each do |move|
  306. next if pkmn.hasMove?(move)
  307. next if !$player.get_pokemon_with_move(move)
  308. pkmn.learn_move(move)
  309. found_eggMove = true
  310. break
  311. end
  312. break if found_eggMove
  313. end
  314. $PokemonGlobal.mirrorherb_steps = 0
  315. end
  316. else
  317. $PokemonGlobal.mirrorherb_steps = 0
  318. end
  319. })
  320.  
  321. ################################################################################
  322. #
  323. # Edits to Egg generation for Tauros regional form inheritence.
  324. #
  325. ################################################################################
  326.  
  327. class DayCare
  328. module EggGenerator
  329. module_function
  330.  
  331. def generate(mother, father)
  332. if mother.male? || father.female? || mother.genderless?
  333. mother, father = father, mother
  334. end
  335. mother_data = [mother, mother.species_data.egg_groups.include?(:Ditto)]
  336. father_data = [father, father.species_data.egg_groups.include?(:Ditto)]
  337. species_parent = (mother_data[1]) ? father : mother
  338. baby_species = determine_egg_species(species_parent.species, mother, father)
  339. mother_data.push(mother.species_data.breeding_can_produce?(baby_species))
  340. father_data.push(father.species_data.breeding_can_produce?(baby_species))
  341. egg = generate_basic_egg(baby_species, species_parent)
  342. inherit_form(egg, species_parent, mother_data, father_data)
  343. inherit_nature(egg, mother, father)
  344. inherit_ability(egg, mother_data, father_data)
  345. inherit_moves(egg, mother_data, father_data)
  346. inherit_IVs(egg, mother, father)
  347. inherit_poke_ball(egg, mother_data, father_data)
  348. set_shininess(egg, mother, father)
  349. set_pokerus(egg)
  350. egg.calc_stats
  351. return egg
  352. end
  353.  
  354. def generate_basic_egg(species, species_parent)
  355. egg = Pokemon.new(species, Settings::EGG_LEVEL)
  356. egg.name = _INTL("Egg")
  357. egg.steps_to_hatch = egg.species_data.hatch_steps
  358. egg.obtain_text = _INTL("Day-Care Couple")
  359. egg.happiness = 120
  360. egg.form = 0 if species == :SINISTEA
  361. new_form = MultipleForms.call("getFormOnEggCreation", egg, species_parent)
  362. egg.form = new_form if new_form
  363. return egg
  364. end
  365. end
  366. end
  367.  
  368. ################################################################################
  369. #
  370. # Form handlers.
  371. #
  372. ################################################################################
  373.  
  374.  
  375. #-------------------------------------------------------------------------------
  376. # Regional forms upon creating an egg.
  377. #-------------------------------------------------------------------------------
  378. MultipleForms.register(:RATTATA, {
  379. "getFormOnEggCreation" => proc { |pkmn, parent|
  380. if $game_map
  381. map_pos = $game_map.metadata&.town_map_position
  382. if map_pos
  383. form = 0
  384. case map_pos[0]
  385. #-----------------------------------------------------------------------
  386. when 1 # Alola region
  387. case pkmn.species
  388. when :RATTATA, :SANDSHREW, :VULPIX, :DIGLETT, :MEOWTH, :GEODUDE, :GRIMER
  389. form = 1
  390. end
  391. #-----------------------------------------------------------------------
  392. when 2 # Galar region
  393. case pkmn.species
  394. when :PONYTA, :SLOWPOKE, :FARFETCHD, :ARTICUNO, :ZAPDOS, :MOLTRES, :CORSOLA, :ZIGZAGOON, :YAMASK, :STUNFISK
  395. form = 1
  396. when :MEOWTH, :DARUMAKA
  397. form = 2
  398. end
  399. #-----------------------------------------------------------------------
  400. when 3 # Hisui region
  401. case pkmn.species
  402. when :GROWLITHE, :VOLTORB, :QWILFISH, :SNEASEL, :ZORUA
  403. form = 1
  404. end
  405. #-----------------------------------------------------------------------
  406. when 4 # Paldea region
  407. case pkmn.species
  408. when :WOOPER
  409. form = 1
  410. when :TAUROS
  411. form = (parent.form == 0) ? 1 : parent.form
  412. end
  413. end
  414. next form if form > 0 && GameData::Species.get_species_form(pkmn.species, form).form == form
  415. end
  416. end
  417. next 0
  418. }
  419. })
  420.  
  421. MultipleForms.copy(:RATTATA, :SANDSHREW, :VULPIX, :DIGLETT, :MEOWTH, :GEODUDE, :GRIMER, # Alolan
  422. :PONYTA, :FARFETCHD, :CORSOLA, :ZIGZAGOON, :YAMASK, :STUNFISK, # Galarian
  423. :SLOWPOKE, :ARTICUNO, :ZAPDOS, :MOLTRES, # Galarian (DLC)
  424. :GROWLITHE, :VOLTORB, :QWILFISH, :SNEASEL, :ZORUA, # Hisuian
  425. :TAUROS, :WOOPER # Paldean
  426. )
  427.  
  428. #-------------------------------------------------------------------------------
  429. # Species with regional evolutions (Hisuian forms).
  430. #-------------------------------------------------------------------------------
  431. MultipleForms.register(:QUILAVA, {
  432. "getForm" => proc { |pkmn|
  433. next if pkmn.form_simple >= 2
  434. if $game_map
  435. map_pos = $game_map.metadata&.town_map_position
  436. next 1 if map_pos && map_pos[0] == 3 # Hisui region
  437. end
  438. next 0
  439. }
  440. })
  441.  
  442. MultipleForms.copy(:QUILAVA, :DEWOTT, :DARTRIX, :PETILIL, :RUFFLET, :GOOMY, :BERGMITE)
  443.  
  444. #-------------------------------------------------------------------------------
  445. # Dundunsparce - Segment sizes.
  446. #-------------------------------------------------------------------------------
  447. MultipleForms.register(:DUNSPARCE, {
  448. "getFormOnCreation" => proc { |pkmn|
  449. next (pkmn.personalID % 100 == 0) ? 1 : 0
  450. }
  451. })
  452.  
  453. MultipleForms.copy(:DUNSPARCE, :DUDUNSPARCE)
  454.  
  455. #-------------------------------------------------------------------------------
  456. # Dialga - Origin Forme.
  457. #-------------------------------------------------------------------------------
  458. MultipleForms.register(:DIALGA, {
  459. "getForm" => proc { |pkmn|
  460. next 1 if pkmn.hasItem?(:ADAMANTCRYSTAL)
  461. next 0
  462. }
  463. })
  464.  
  465. #-------------------------------------------------------------------------------
  466. # Palkia - Origin Forme.
  467. #-------------------------------------------------------------------------------
  468. MultipleForms.register(:PALKIA, {
  469. "getForm" => proc { |pkmn|
  470. next 1 if pkmn.hasItem?(:LUSTROUSGLOBE)
  471. next 0
  472. }
  473. })
  474.  
  475. #-------------------------------------------------------------------------------
  476. # Giratina - Origin Forme.
  477. #-------------------------------------------------------------------------------
  478. MultipleForms.register(:GIRATINA, {
  479. "getForm" => proc { |pkmn|
  480. next 1 if pkmn.hasItem?(:GRISEOUSCORE)
  481. next 1 if Settings::MECHANICS_GENERATION < 9 && pkmn.hasItem?(:GRISEOUSORB)
  482. if $game_map &&
  483. GameData::MapMetadata.try_get($game_map.map_id)&.has_flag?("DistortionWorld")
  484. next 1
  485. end
  486. next 0
  487. }
  488. })
  489.  
  490. #-------------------------------------------------------------------------------
  491. # Shaymin - Sky Forme.
  492. #-------------------------------------------------------------------------------
  493. MultipleForms.register(:SHAYMIN, {
  494. "getForm" => proc { |pkmn|
  495. next 0 if pkmn.fainted? || [:FROZEN, :FROSTBITE].include?(pkmn.status) || PBDayNight.isNight?
  496. }
  497. })
  498.  
  499. #-------------------------------------------------------------------------------
  500. # Hoopa - Unbound form.
  501. #-------------------------------------------------------------------------------
  502. MultipleForms.register(:HOOPA, {
  503. "getForm" => proc { |pkmn|
  504. if Settings::MECHANICS_GENERATION < 9 && (!pkmn.time_form_set ||
  505. pbGetTimeNow.to_i > pkmn.time_form_set.to_i + (60 * 60 * 24 * 3)) # 3 days
  506. next 0
  507. end
  508. },
  509. "onSetForm" => proc { |pkmn, form, oldForm|
  510. pkmn.time_form_set = (form > 0) ? pbGetTimeNow.to_i : nil if Settings::MECHANICS_GENERATION < 9
  511. # Move Change
  512. form_moves = [
  513. :HYPERSPACEHOLE, # Confined form
  514. :HYPERSPACEFURY, # Unbound form
  515. ]
  516. # Find a known move that should be forgotten
  517. old_move_index = -1
  518. pkmn.moves.each_with_index do |move, i|
  519. next if !form_moves.include?(move.id)
  520. old_move_index = i
  521. break
  522. end
  523. # Determine which new move to learn (if any)
  524. new_move_id = form_moves[form]
  525. new_move_id = nil if !GameData::Move.exists?(new_move_id)
  526. new_move_id = nil if pkmn.hasMove?(new_move_id)
  527. # Forget a known move (if relevant) and learn a new move (if relevant)
  528. if old_move_index >= 0
  529. old_move_name = pkmn.moves[old_move_index].name
  530. if new_move_id.nil?
  531. # Just forget the old move
  532. pkmn.forget_move_at_index(old_move_index)
  533. else
  534. # Replace the old move with the new move (keeps the same index)
  535. pkmn.moves[old_move_index].id = new_move_id
  536. new_move_name = pkmn.moves[old_move_index].name
  537. pbMessage("\\se[]" + _INTL("{1} learned {2}!", pkmn.name, new_move_name) + "\\se[Pkmn move learnt]")
  538. end
  539. end
  540. }
  541. })
  542.  
  543. #-------------------------------------------------------------------------------
  544. # Basculin
  545. #-------------------------------------------------------------------------------
  546. MultipleForms.register(:BASCULIN, {
  547. "getForm" => proc { |pkmn|
  548. if pkmn.form_simple >= 2
  549. next (pkmn.female?) ? 3 : 2
  550. end
  551. next pkmn.form_simple
  552. }
  553. })
  554.  
  555. #-------------------------------------------------------------------------------
  556. # Basculegion - Gender forms.
  557. #-------------------------------------------------------------------------------
  558. MultipleForms.register(:BASCULEGION, {
  559. "getForm" => proc { |pkmn|
  560. next (pkmn.female?) ? 3 : 2
  561. },
  562. "getFormOnCreation" => proc { |pkmn|
  563. next (pkmn.female?) ? 3 : 2
  564. }
  565. })
  566.  
  567. #-------------------------------------------------------------------------------
  568. # Oinkologne - Gender forms.
  569. #-------------------------------------------------------------------------------
  570. MultipleForms.register(:LECHONK, {
  571. "getForm" => proc { |pkmn|
  572. next pkmn.gender
  573. },
  574. "getFormOnCreation" => proc { |pkmn|
  575. next pkmn.gender
  576. }
  577. })
  578.  
  579. MultipleForms.copy(:LECHONK, :OINKOLOGNE)
  580.  
  581. #-------------------------------------------------------------------------------
  582. # Maushold - Family sizes.
  583. #-------------------------------------------------------------------------------
  584. MultipleForms.register(:TANDEMAUS, {
  585. "getFormOnCreation" => proc { |pkmn|
  586. next (pkmn.personalID % 100 == 0) ? 1 : 0
  587. }
  588. })
  589.  
  590. MultipleForms.copy(:TANDEMAUS, :MAUSHOLD)
  591.  
  592. #-------------------------------------------------------------------------------
  593. # Squawkabilly - Plumage colors.
  594. #-------------------------------------------------------------------------------
  595. MultipleForms.register(:SQUAWKABILLY, {
  596. "getFormOnCreation" => proc { |pkmn|
  597. next rand(4)
  598. }
  599. })
  600.  
  601. #-------------------------------------------------------------------------------
  602. # Palafin - Zero Form.
  603. #-------------------------------------------------------------------------------
  604. MultipleForms.register(:PALAFIN, {
  605. "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle|
  606. next 0 if endBattle
  607. }
  608. })
  609.  
  610. #-------------------------------------------------------------------------------
  611. # Tatsugiri - Multiple Forms.
  612. #-------------------------------------------------------------------------------
  613. MultipleForms.register(:TATSUGIRI, {
  614. "getFormOnCreation" => proc { |pkmn|
  615. next rand(3)
  616. }
  617. })
  618.  
  619. #-------------------------------------------------------------------------------
  620. # Poltchageist/Sinistcha - Unremarkable/Masterpiece forms.
  621. #-------------------------------------------------------------------------------
  622. MultipleForms.copy(:SINISTEA, :POLTEAGEIST, :POLTCHAGEIST, :SINISTCHA)
  623.  
  624. #-------------------------------------------------------------------------------
  625. # Ogerpon - Masked forms.
  626. #-------------------------------------------------------------------------------
  627. MultipleForms.register(:OGERPON, {
  628. "getForm" => proc { |pkmn|
  629. next 1 if pkmn.hasItem?(:WELLSPRINGMASK)
  630. next 2 if pkmn.hasItem?(:HEARTHFLAMEMASK)
  631. next 3 if pkmn.hasItem?(:CORNERSTONEMASK)
  632. next 0
  633. },
  634. "getFormOnStartingBattle" => proc { |pkmn, wild|
  635. next 5 if pkmn.hasItem?(:WELLSPRINGMASK)
  636. next 6 if pkmn.hasItem?(:HEARTHFLAMEMASK)
  637. next 7 if pkmn.hasItem?(:CORNERSTONEMASK)
  638. next 4
  639. },
  640. "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle|
  641. next pkmn.form - 4 if pkmn.form > 3 && endBattle
  642. },
  643. "getTerastalForm" => proc { |pkmn|
  644. next pkmn.form + 4
  645. },
  646. "getUnTerastalForm" => proc { |pkmn|
  647. next pkmn.form - 4
  648. },
  649. # Compability for Pokedex Data Page plugin
  650. "getDataPageInfo" => proc { |pkmn|
  651. next if pkmn.form < 8
  652. mask = nil
  653. case pkmn.form
  654. when 9 then mask = :WELLSPRINGMASK
  655. when 10 then mask = :HEARTHFLAMEMASK
  656. when 11 then mask = :CORNERSTONEMASK
  657. end
  658. next [pkmn.form, pkmn.form - 4, mask]
  659. }
  660. })
  661.  
  662. #-------------------------------------------------------------------------------
  663. # Terapagos - Terastal and Stellar form.
  664. #-------------------------------------------------------------------------------
  665. MultipleForms.register(:TERAPAGOS, {
  666. "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle|
  667. next 0 if pkmn.form > 0 && endBattle
  668. },
  669. "getTerastalForm" => proc { |pkmn|
  670. next 2
  671. },
  672. "getUnTerastalForm" => proc { |pkmn|
  673. next 1
  674. },
  675. "getDataPageInfo" => proc { |pkmn|
  676. next if pkmn.form < 2
  677. next [pkmn.form, 1]
  678. }
  679. })
  680.  
  681. #-------------------------------------------------------------------------------
  682. # Zygarde - Mega Zygarde form.
  683. #-------------------------------------------------------------------------------
  684. MultipleForms.register(:ZYGARDE, {
  685. "changePokemonOnMegaEvolve" => proc { |battler, battle|
  686. if GameData::Move.exists?(:NIHILLIGHT)
  687. if [4, 5].include?(battler.form)
  688. battler.eachMoveWithIndex do |m, i|
  689. next if m.id != :COREENFORCER
  690. pokemon_move = battler.pokemon.moves[i]
  691. pokemon_move.id = :NIHILLIGHT
  692. battler_move = Battle::Move.from_pokemon_move(battle, pokemon_move)
  693. battler.moves[i] = battler_move
  694. if battle.choices[battler.index][1] == i
  695. battle.choices[battler.index][2] = battler_move
  696. battle.pbDisplay(_INTL("{1}'s {2} transform into {3}!", battler.pbThis,
  697. GameData::Move.get(:COREENFORCER).name,
  698. GameData::Move.get(:NIHILLIGHT).name
  699. ))
  700. break
  701. end
  702. end
  703. end
  704. end
  705. },
  706. "getMegaMoves" => proc { |pkmn|
  707. next { :COREENFORCER => :NIHILLIGHT }
  708. },
  709. "changePokemonOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle|
  710. if GameData::Move.exists?(:COREENFORCER) && endBattle
  711. pkmn.moves.each { |move| move.id = :COREENFORCER if move.id == :NIHILLIGHT }
  712. end
  713. },
  714. "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle|
  715. pkmn.makeUnmega if pkmn.mega? && endBattle
  716. next pkmn.form - 2 if [2, 3].include?(pkmn.form) && (pkmn.fainted? || endBattle)
  717. }
  718. })