Guest User

Untitled

a guest
Jul 3rd, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 113.19 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Dynamax/Gigantamax Script - By #Not Important
  4. #
  5. #===============================================================================
  6. # ~Installation~
  7. #===============================================================================
  8. # 1) To install, insert a new section below any other battle edits, and paste
  9. # this script there.
  10. #
  11. # 2) Next, you must add the following to your items PBS file:
  12. =begin
  13. XXX,DBAND,Dynamax Band,,1,99999,"A band that allows the holder/'s pokémon to use dynamax",0,0,15,
  14.  
  15. These to moves.txt:
  16. 712,MAXFLARE,Max Flare,POL,110,FIRE,Physical,100,10,0,00,0,,"This is a Fire-type attack Dynamax Pokémon use. The user intensifies the sun for five turns."
  17. 713,MAXFLUTTERBY,Max Flutterby,LOP,110,BUG,Physical,100,10,0,00,0,,"This is a Bug-type attack Dynamax Pokémon use. This lowers the target's Sp. Atk stat."
  18. 714,MAXLIGHTNING,Max Lightning,OOO,110,ELECTRIC,Physical,100,10,0,00,0,,"This is an Electric-type attack Dynamax Pokémon use. The user turns the ground into Electric Terrain for five turns."
  19. 715,MAXSTRIKE,Max Strike,PPP,110,NORMAL,Physical,100,10,0,00,0,,"This is a Normal-type attack Dynamax Pokémon use. This lowers the target's Speed stat."
  20. 716,MAXKNUCKLE,Max Knuckle,WWW,110,FIGHTING,Physical,100,10,0,00,0,,"This is a Fighting-type attack Dynamax Pokémon use. This raises ally Pokémon's Attack stats."
  21. 717,MAXPHANTASM,Max Phantasm,RRR,110,GHOST,Physical,100,10,0,00,0,,"This is a Ghost-type attack Dynamax Pokémon use. This lowers the target's Defense stat."
  22. 718,MAXHAILSTORM,Max Hailstorm,SSS,110,ICE,Physical,100,10,0,00,0,,"This is an Ice-type attack Dynamax Pokémon use. The user summons a hailstorm lasting five turns."
  23. 719,MAXOOZE,Max Ooze,EEE,110,POISON,Physical,100,10,0,00,0,,"This is a Poison-type attack Dynamax Pokémon use. This raises ally Pokémon's Sp. Atk stats."
  24. 720,MAXGEYSER,Max Geyser,GGG,110,WATER,Physical,100,10,0,00,0,,"This is a Water-type attack Dynamax Pokémon use. The user summons a heavy rain that falls for five turns."
  25. 721,MAXAIRSTREAM,Max Airstream,UUU,110,FLYING,Physical,100,10,0,00,0,,"This is a Flying-type attack Dynamax Pokémon use. This raises ally Pokémon's Speed stats."
  26. 722,MAXSTARFALL,Max Starfall,ÑÑÑ,110,FAIRY,Physical,100,10,0,00,0,,"This is a Fairy-type attack Dynamax Pokémon use. The user turns the ground into Misty Terrain for five turns."
  27. 723,MAXWYRMWIND,Max Wyrmwind,999,110,DRAGON,Physical,100,10,0,00,0,,"This is a Dragon-type attack Dynamax Pokémon use. This lowers the target's Attack stat."
  28. 724,MAXMINDSTORM,Max Mindstorm,MMM,110,PSYCHIC,Physical,100,10,0,00,0,,"This is a Psychic-type attack Dynamax Pokémon use. The user turns the ground into Psychic Terrain for five turns."
  29. 725,MAXROCKFALL,Max Rockfall,XXX,110,ROCK,Physical,100,10,0,00,0,,"This is a Rock-type attack Dynamax Pokémon use. The user summons a sandstorm lasting five turns."
  30. 726,MAXQUAKE,Max Quake,ZZZ,110,GROUND,Physical,100,10,0,00,0,,"This is a Ground-type attack Dynamax Pokémon use. This raises ally Pokémon's Sp. Def stats."
  31. 727,MAXDARKNESS,Max Darkness,YYY,110,DARK,Physical,100,10,0,00,0,,"This is a Dark-type attack Dynamax Pokémon use. This lowers the target's Sp. Def stat."
  32. 728,MAXOVERGROWTH,Max Overgrowth,JJJ,110,GRASS,Physical,100,10,0,00,0,,"This is a Grass-type attack Dynamax Pokémon use. The user turns the ground into Grassy Terrain for five turns."
  33. 729,MAXSTEELSPIKE,Max Steelspike,LLL,110,STEEL,Physical,100,10,0,00,0,,"This is a Steel-type attack Dynamax Pokémon use. This raises ally Pokémon's Defense stats."
  34. 730,MAXGUARD,Max Guard,BBB,0,NORMAL,Status,100,10,0,00,0,,"This is a Status category attack Dynamax Pokémon use. Protect against all move, include other Dynamax moves."
  35.  
  36. IF YOU WANT GMAXING:
  37.  
  38. <add here>
  39. =end
  40. #
  41. # ^MAKE SURE TO ADJUST THE ITEM NUMBER TO MATCH YOUR GAME
  42. #
  43. # Everything below is written for Pokémon Essentials v.17.2
  44. #===============================================================================
  45. # V SETTINGS V
  46. ZPOWER=true #Compatiability for Ludicrous89's Zodiac powers script
  47. ZMOVES=false #Compatiability for the Z-move addon
  48. SPOWER=true #Compatiability for my spirit powers script
  49. DYNAMAXBANDS=[:DBAND] #The items that the player can have to trigger the
  50. #dynamax
  51. GMAX=true #Allow gigantamaxing
  52. NO_DYNAMAX=808 #The Switch for no dynamaxing
  53. MAPS=false #If you want certain maps to have dynamax and gmax only
  54. maps=[] #Add the map numbers that you want to have dynamax and gmax on
  55. #Use only if MAPS is set to true
  56. #------------------------#
  57. # #
  58. # Behold the script #
  59. # </> #
  60. #------------------------#
  61. #===============================================================================
  62. # Defines when a Pokemon has access to dynamax in battle.
  63. #===============================================================================
  64. module PBEffects
  65. Dynamax = 201
  66. end
  67.  
  68. def hasMax?
  69. return canMax?
  70. end
  71.  
  72.  
  73. class PokeBattle_Battle
  74. attr_accessor(:dynamax)
  75.  
  76. def canMax?
  77. for i in DYNAMAXBANDS
  78. next if !hasConst?(PBItems,i)
  79. return true if $PokemonBag.pbHasItem?(i)
  80. end
  81. end
  82. end
  83.  
  84.  
  85. class PokeBattle_Pokemon
  86.  
  87.  
  88. def canGmax?
  89. return false if @effects[PBEffects::Transform]
  90. if @pokemon && @pokemon.dynamaxlevel==10
  91. if isConst?(species,PBSpecies,:CHARIZARD) ||
  92. isConst?(species,PBSpecies,:BUTTERFREE) ||
  93. isConst?(species,PBSpecies,:PIKACHU) ||
  94. isConst?(species,PBSpecies,:MEOWTH) ||
  95. isConst?(species,PBSpecies,:MACHAMP) ||
  96. isConst?(species,PBSpecies,:GENGAR) ||
  97. isConst?(species,PBSpecies,:KINGLER) ||
  98. isConst?(species,PBSpecies,:LAPRAS) ||
  99. isConst?(species,PBSpecies,:EEVEE) ||
  100. isConst?(species,PBSpecies,:SNORLAX) ||
  101. isConst?(species,PBSpecies,:GARBODOR) ||
  102. isConst?(species,PBSpecies,:MELMETAL) ||
  103. isConst?(species,PBSpecies,:CORVIKNIGHT) ||
  104. isConst?(species,PBSpecies,:ORBEETLE) ||
  105. isConst?(species,PBSpecies,:DREDNAW) ||
  106. isConst?(species,PBSpecies,:COALOSSAL) ||
  107. isConst?(species,PBSpecies,:APPLETUN) ||
  108. isConst?(species,PBSpecies,:FLAPPLE) ||
  109. isConst?(species,PBSpecies,:SANDACONDA) ||
  110. isConst?(species,PBSpecies,:TOXTRICITY) ||
  111. isConst?(species,PBSpecies,:CENTISKORCH) ||
  112. isConst?(species,PBSpecies,:HATTERENE) ||
  113. isConst?(species,PBSpecies,:GRIMMSNARL) ||
  114. isConst?(species,PBSpecies,:ALCREMIE) ||
  115. isConst?(species,PBSpecies,:COPPERAJAH) ||
  116. isConst?(species,PBSpecies,:DURALUDON) ||
  117. isConst?(species,PBSpecies,:ETERNATUS) ||
  118. isConst?(species,PBSpecies,:CINDERACE) ||
  119. isConst?(species,PBSpecies,:RILLABOOM) ||
  120. isConst?(species,PBSpecies,:INTELEON)
  121. return true
  122. end
  123. end
  124. return false
  125. end
  126.  
  127. def canGmaxNewPokemon?
  128. return false if @effects[PBEffects::Transform]
  129. if @pokemon
  130. if isConst?(species,PBSpecies,:CHARIZARD) ||
  131. isConst?(species,PBSpecies,:BUTTERFREE) ||
  132. isConst?(species,PBSpecies,:PIKACHU) ||
  133. isConst?(species,PBSpecies,:MEOWTH) ||
  134. isConst?(species,PBSpecies,:MACHAMP) ||
  135. isConst?(species,PBSpecies,:GENGAR) ||
  136. isConst?(species,PBSpecies,:KINGLER) ||
  137. isConst?(species,PBSpecies,:LAPRAS) ||
  138. isConst?(species,PBSpecies,:EEVEE) ||
  139. isConst?(species,PBSpecies,:SNORLAX) ||
  140. isConst?(species,PBSpecies,:GARBODOR) ||
  141. isConst?(species,PBSpecies,:MELMETAL) ||
  142. isConst?(species,PBSpecies,:CORVIKNIGHT) ||
  143. isConst?(species,PBSpecies,:ORBEETLE) ||
  144. isConst?(species,PBSpecies,:DREDNAW) ||
  145. isConst?(species,PBSpecies,:COALOSSAL) ||
  146. isConst?(species,PBSpecies,:APPLETUN) ||
  147. isConst?(species,PBSpecies,:FLAPPLE) ||
  148. isConst?(species,PBSpecies,:SANDACONDA) ||
  149. isConst?(species,PBSpecies,:TOXTRICITY) ||
  150. isConst?(species,PBSpecies,:CENTISKORCH) ||
  151. isConst?(species,PBSpecies,:HATTERENE) ||
  152. isConst?(species,PBSpecies,:GRIMMSNARL) ||
  153. isConst?(species,PBSpecies,:ALCREMIE) ||
  154. isConst?(species,PBSpecies,:COPPERAJAH) ||
  155. isConst?(species,PBSpecies,:DURALUDON) ||
  156. isConst?(species,PBSpecies,:ETERNATUS) ||
  157. isConst?(species,PBSpecies,:CINDERACE) ||
  158. isConst?(species,PBSpecies,:RILLABOOM) ||
  159. isConst?(species,PBSpecies,:INTELEON)
  160. return true
  161. end
  162. end
  163. return false
  164. end
  165.  
  166. def pbGetGmaxForm
  167. if @pokemon
  168. if isConst?(species,PBSpecies,:CHARIZARD)
  169. return 3 #Mega Y, Mega X, Gmax
  170. elsif isConst?(species,PBSpecies,:BUTTERFREE)
  171. return 1 #Gmax
  172. elsif isConst?(species,PBSpecies,:PIKACHU)
  173. return 1 #Gmax
  174. elsif isConst?(species,PBSpecies,:EEVEE)
  175. return 1 #Gmax
  176. elsif isConst?(species,PBSpecies,:MEOWTH)
  177. return 3 #Alolan, Galarian, Gmax
  178. elsif isConst?(species,PBSpecies,:MACHAMP)
  179. return 2 #Mega, Gmax
  180. elsif isConst?(species,PBSpecies,:GENGAR)
  181. return 2 #Mega, Gmax
  182. elsif isConst?(species,PBSpecies,:KINGLER)
  183. return 1 #Gmax
  184. elsif isConst?(species,PBSpecies,:LAPRAS)
  185. return 1 #Gmax
  186. elsif isConst?(species,PBSpecies,:SNORLAX)
  187. return 1 #Gmax
  188. elsif isConst?(species,PBSpecies,:GARBODOR)
  189. return 1 #Gmax
  190. elsif isConst?(species,PBSpecies,:MELMETAL)
  191. return 1 #Gmax
  192. elsif isConst?(species,PBSpecies,:CORVIKNIGHT)
  193. return 1 #Gmax
  194. elsif isConst?(species,PBSpecies,:ORBEETLE)
  195. return 1 #Gmax
  196. elsif isConst?(species,PBSpecies,:DREADNAW)
  197. return 1 #Gmax
  198. elsif isConst?(species,PBSpecies,:COALOSSAL)
  199. return 1 #Gmax
  200. elsif isConst?(species,PBSpecies,:APPLETUN)
  201. return 1 #Gmax
  202. elsif isConst?(species,PBSpecies,:FLAPPLE)
  203. return 1 #Gmax
  204. elsif isConst?(species,PBSpecies,:SANDACONDA)
  205. return 1 #Gmax
  206. elsif isConst?(species,PBSpecies,:TOXTRICITY)
  207. return 2 #Amped (0), Low-key (1), Gmax (2)
  208. elsif isConst?(species,PBSpecies,:CENTISCORCH)
  209. return 1 #Gmax
  210. elsif isConst?(species,PBSpecies,:HATTERENE) # I DIDN'T EVEN KNOW THIS HAD A GMAX FORM
  211. return 1 #Gmax
  212. elsif isConst?(species,PBSpecies,:GRIMMSNARL)
  213. return 1 #Gmax
  214. elsif isConst?(species,PBSpecies,:ALCREMIE)
  215. return 63 #ALL THE OTHER FORMS THAT NO-ONE BOTHERS WITH, Gmax
  216. elsif isConst?(species,PBSpecies,:COPPERAJAH)
  217. return 1 #Gmax
  218. elsif isConst?(species,PBSpecies,:DURALDON)
  219. return 1 #Gmax
  220. elsif isConst?(species,PBSpecies,:ETERNATUS)
  221. return 1 #Eternamax
  222. elsif isConst?(species,PBSpecies,:CINDERACE) ||
  223. isConst?(species,PBSpecies,:RILLABOOM) ||
  224. isConst?(species,PBSpecies,:INTELEON)
  225. return 1 #Gmax
  226. end
  227. end
  228. end
  229.  
  230.  
  231. def pbGetMaxMoves(user)
  232. imposter=user.isConst?(species,PBSpecies,:DITTO) && user.isConst?(ability,PBAbilities,:LIMBER)
  233. for i in 0...4
  234. next if user.moves[i].id==0 && imposter
  235. #################
  236. #Stores the moves
  237. user.oldmoves[i] = user.moves[i]
  238. ##################
  239. move = user.moves[i]
  240. if move.pbIsStatus?
  241. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXGUARD)))
  242. elsif move.type == PBTypes::NORMAL
  243. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXSTRIKE)))
  244. elsif move.type == PBTypes::FIGHTING
  245. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXKNUCKLE)))
  246. elsif move.type == PBTypes::FLYING
  247. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXAIRSTREAM)))
  248. elsif move.type == PBTypes::POISON
  249. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXOOZE)))
  250. elsif move.type == PBTypes::GROUND
  251. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXQUAKE)))
  252. elsif move.type == PBTypes::ROCK
  253. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXROCKFALL)))
  254. elsif move.type == PBTypes::BUG
  255. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXFLUTTERBY)))
  256. elsif move.type == PBTypes::GHOST
  257. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXPHANTASM)))
  258. elsif move.type == PBTypes::STEEL
  259. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXSTEELSPIKE)))
  260. elsif move.type == PBTypes::FIRE
  261. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXFLARE)))
  262. elsif move.type == PBTypes::WATER
  263. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXGEYSER)))
  264. elsif move.type == PBTypes::Grass
  265. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXOVERGROWTH)))
  266. elsif move.type == PBTypes::ELECTRIC
  267. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXLIGHTNING)))
  268. elsif move.type == PBTypes::PSYCHIC
  269. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXMINDSTORM)))
  270. elsif move.type == PBTypes::ICE
  271. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXHAILSTORM)))
  272. elsif move.type == PBTypes::DRAGON
  273. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXWYRMWIND)))
  274. elsif move.type == PBTypes::DARK
  275. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXDARKNESS)))
  276. elsif move.type == PBTypes::FAIRY
  277. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXSTARFALL)))
  278. end
  279. if user.canGmax?
  280. if (user.isConst?(species,PBSpecies,:CHARIZARD)) && (move.type == PBTypes::FIRE)
  281. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXWILDFIRE)))
  282. end
  283. if (user.isConst?(species,PBSpecies,:BUTTERFREE)) && (move.type == PBTypes::BUG)
  284. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXBEFUDDLE)))
  285. end
  286. if (user.isConst?(species,PBSpecies,:PIKACHU)) && (move.type == PBTypes::ELECTRIC)
  287. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXVOLTCRASH)))
  288. end
  289. if (user.isConst?(species,PBSpecies,:MEOWTH)) && (move.type == PBTypes::NORMAL)
  290. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXGOLDRUSH)))
  291. end
  292. if (user.isConst?(species,PBSpecies,:MACHAMP)) && (move.type == PBTypes::FIGHTING)
  293. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXCHISTRIKE)))
  294. end
  295. if (user.isConst?(species,PBSpecies,:GENGAR)) && (move.type == PBTypes::GHOST)
  296. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXTERROR)))
  297. end
  298. if (user.isConst?(species,PBSpecies,:KINGLER)) && (move.type == PBTypes::WATER)
  299. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXFOAMBURST)))
  300. end
  301. if (user.isConst?(species,PBSpecies,:LAPRAS)) && (move.type == PBTypes::ICE)
  302. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXRESONANCE)))
  303. end
  304. if (user.isConst?(species,PBSpecies,:EEVEE)) && (move.type == PBTypes::NORMAL)
  305. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXCUDDLE)))
  306. end
  307. if (user.isConst?(species,PBSpecies,:SNORLAX)) && (move.type == PBTypes::NORMAL)
  308. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXREPLENISH)))
  309. end
  310. if (user.isConst?(species,PBSpecies,:GARBODOR)) && (move.type == PBTypes::POISON)
  311. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXMALODOR)))
  312. end
  313. if (user.isConst?(species,PBSpecies,:MELMETAL)) && (move.type == PBTypes::STEEL)
  314. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXMELMETAL)))
  315. end
  316. if (user.isConst?(species,PBSpecies,:CINDERACE)) && (move.type == PBTypes::FIRE)
  317. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXFIREBALL)))
  318. end
  319. if (user.isConst?(species,PBSpecies,:RILLABOOM)) && (move.type == PBTypes::GRASS)
  320. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXDRUMSOLO)))
  321. end
  322. if (user.isConst?(species,PBSpecies,:INTELEON)) && (move.type == PBTypes::WATER)
  323. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXHYDROSNIPE)))
  324. end
  325. if (user.isConst?(species,PBSpecies,:CORVINIGHT)) && (move.type == PBTypes::FLYING)
  326. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXWINDRAGE)))
  327. end
  328. if (user.isConst?(species,PBSpecies,:ORBEETLE)) && (move.type == PBTypes::PSYCHIC)
  329. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXCHISTRIKE)))
  330. end
  331. if (user.isConst?(species,PBSpecies,:DREADNAW)) && (move.type == PBTypes::WATER)
  332. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXSTONESURGE)))
  333. end
  334. if (user.isConst?(species,PBSpecies,:COALOSSAL)) && (move.type == PBTypes::ROCK)
  335. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXVOLCALITH)))
  336. end
  337. if (user.isConst?(species,PBSpecies,:FLAPPLE)) && (move.type == PBTypes::GRASS)
  338. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXTARTNESS)))
  339. end
  340. if (user.isConst?(species,PBSpecies,:APPLETUN)) && (move.type == PBTypes::GRASS)
  341. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXSWEETNESS)))
  342. end
  343. if (user.isConst?(species,PBSpecies,:SANDACONDA)) && (move.type == PBTypes::GROUND)
  344. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXSANDBLAST)))
  345. end
  346. if (user.isConst?(species,PBSpecies,:TOXTRICITY)) && (move.type == PBTypes::ELECTRIC)
  347. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXSTUNSHOCK)))
  348. end
  349. if (user.isConst?(species,PBSpecies,:CENTISCORCH)) && (move.type == PBTypes::FIRE)
  350. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXCENTIFERNO)))
  351. end
  352. if (user.isConst?(species,PBSpecies,:HATTERENE)) && (move.type == PBTypes::FAIRY)
  353. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXSMITE)))
  354. end
  355. if (user.isConst?(species,PBSpecies,:GRIMMSNARL)) && (move.type == PBTypes::DARK)
  356. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXSNOOZE)))
  357. end
  358. if (user.isConst?(species,PBSpecies,:ALCREMIE)) && (move.type == PBTypes::FAIRY)
  359. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXFINALE)))
  360. end
  361. if (user.isConst?(species,PBSpecies,:COPPERAJAH)) && (move.type == PBTypes::STEEL)
  362. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXSTEELSURGE)))
  363. end
  364. if (user.isConst?(species,PBSpecies,:DURALUDON)) && (move.type == PBTypes::DRAGON)
  365. move=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:GMAXDEPLETION)))
  366. end
  367. end
  368. end
  369. end
  370.  
  371. def pbRestoreMoves(user)
  372. for i in 0...4
  373. user.moves[i] = user.oldmoves1 if i==1 && user.oldmoves1
  374. user.moves[i] = user.oldmoves2 if i==2 && user.oldmoves2
  375. user.moves[i] = user.oldmoves3 if i==3 && user.oldmoves3
  376. user.moves[i] = user.oldmoves4 if i==4 && user.oldmoves4
  377. end
  378. end
  379.  
  380. def pbUnMaxMoves
  381. for i in 0...4
  382. if @pokemon
  383. @moves[i] = @oldmoves[i]
  384. end
  385. end
  386. end
  387.  
  388. end
  389.  
  390. class PokeBattle_Battle
  391. def hasMax?
  392. if MAPS
  393. if @pokemon && ($game_map && maps.include?($game_map.map_id)) &&
  394. !(self.isConst?(species,PBSpecies,:ZACIAN) ||
  395. self.isConst?(species,PBSpecies,:ZAMAZENTA) ||
  396. self.isConst?(species,PBSpecies,:ETERNATUS))
  397. return (canMax? rescue false)
  398. end
  399. else
  400. if @pokemon &&
  401. !(self.isConst?(species,PBSpecies,:ZACIAN) ||
  402. self.isConst?(species,PBSpecies,:ZAMAZENTA) ||
  403. self.isConst?(species,PBSpecies,:ETERNATUS))
  404. return (canMax? rescue false)
  405. end
  406. end
  407. end
  408. end
  409.  
  410. class PokeBattle_Pokemon
  411. attr_accessor(:dynamaxlevel)
  412. attr_accessor(:oldmoves1)
  413. attr_accessor(:oldmoves2)
  414. attr_accessor(:oldmoves3)
  415. attr_accessor(:oldmoves4)
  416. end
  417.  
  418. class PokeBattle_Battler
  419. attr_accessor(:dynamaxlevel)
  420. attr_accessor(:oldmoves1)
  421. attr_accessor(:oldmoves2)
  422. attr_accessor(:oldmoves3)
  423. attr_accessor(:oldmoves4)
  424.  
  425. def pbRestoreMoves(user)
  426. for i in 0...4
  427. user.moves[i] = user.oldmoves1 if i==1 && user.oldmoves1
  428. user.moves[i] = user.oldmoves2 if i==2 && user.oldmoves2
  429. user.moves[i] = user.oldmoves3 if i==3 && user.oldmoves3
  430. user.moves[i] = user.oldmoves4 if i==4 && user.oldmoves4
  431. end
  432. end
  433.  
  434. def canGmax?
  435. return false if @effects[PBEffects::Transform]
  436. if @pokemon && @pokemon.dynamaxlevel==10
  437. if isConst?(species,PBSpecies,:CHARIZARD) ||
  438. isConst?(species,PBSpecies,:BUTTERFREE) ||
  439. isConst?(species,PBSpecies,:PIKACHU) ||
  440. isConst?(species,PBSpecies,:MEOWTH) ||
  441. isConst?(species,PBSpecies,:MACHAMP) ||
  442. isConst?(species,PBSpecies,:GENGAR) ||
  443. isConst?(species,PBSpecies,:KINGLER) ||
  444. isConst?(species,PBSpecies,:LAPRAS) ||
  445. isConst?(species,PBSpecies,:EEVEE) ||
  446. isConst?(species,PBSpecies,:SNORLAX) ||
  447. isConst?(species,PBSpecies,:GARBODOR) ||
  448. isConst?(species,PBSpecies,:MELMETAL) ||
  449. isConst?(species,PBSpecies,:CORVIKNIGHT) ||
  450. isConst?(species,PBSpecies,:ORBEETLE) ||
  451. isConst?(species,PBSpecies,:DREDNAW) ||
  452. isConst?(species,PBSpecies,:COALOSSAL) ||
  453. isConst?(species,PBSpecies,:APPLETUN) ||
  454. isConst?(species,PBSpecies,:FLAPPLE) ||
  455. isConst?(species,PBSpecies,:SANDACONDA) ||
  456. isConst?(species,PBSpecies,:TOXTRICITY) ||
  457. isConst?(species,PBSpecies,:CENTISKORCH) ||
  458. isConst?(species,PBSpecies,:HATTERENE) ||
  459. isConst?(species,PBSpecies,:GRIMMSNARL) ||
  460. isConst?(species,PBSpecies,:ALCREMIE) ||
  461. isConst?(species,PBSpecies,:COPPERAJAH) ||
  462. isConst?(species,PBSpecies,:DURALUDON) ||
  463. isConst?(species,PBSpecies,:ETERNATUS) ||
  464. isConst?(species,PBSpecies,:CINDERACE) ||
  465. isConst?(species,PBSpecies,:RILLABOOM) ||
  466. isConst?(species,PBSpecies,:INTELEON)
  467. return true
  468. end
  469. end
  470. return false
  471. end
  472.  
  473. def canGmaxNewPokemon?
  474. return false if @effects[PBEffects::Transform]
  475. if @pokemon
  476. if isConst?(species,PBSpecies,:CHARIZARD) ||
  477. isConst?(species,PBSpecies,:BUTTERFREE) ||
  478. isConst?(species,PBSpecies,:PIKACHU) ||
  479. isConst?(species,PBSpecies,:MEOWTH) ||
  480. isConst?(species,PBSpecies,:MACHAMP) ||
  481. isConst?(species,PBSpecies,:GENGAR) ||
  482. isConst?(species,PBSpecies,:KINGLER) ||
  483. isConst?(species,PBSpecies,:LAPRAS) ||
  484. isConst?(species,PBSpecies,:EEVEE) ||
  485. isConst?(species,PBSpecies,:SNORLAX) ||
  486. isConst?(species,PBSpecies,:GARBODOR) ||
  487. isConst?(species,PBSpecies,:MELMETAL) ||
  488. isConst?(species,PBSpecies,:CORVIKNIGHT) ||
  489. isConst?(species,PBSpecies,:ORBEETLE) ||
  490. isConst?(species,PBSpecies,:DREDNAW) ||
  491. isConst?(species,PBSpecies,:COALOSSAL) ||
  492. isConst?(species,PBSpecies,:APPLETUN) ||
  493. isConst?(species,PBSpecies,:FLAPPLE) ||
  494. isConst?(species,PBSpecies,:SANDACONDA) ||
  495. isConst?(species,PBSpecies,:TOXTRICITY) ||
  496. isConst?(species,PBSpecies,:CENTISKORCH) ||
  497. isConst?(species,PBSpecies,:HATTERENE) ||
  498. isConst?(species,PBSpecies,:GRIMMSNARL) ||
  499. isConst?(species,PBSpecies,:ALCREMIE) ||
  500. isConst?(species,PBSpecies,:COPPERAJAH) ||
  501. isConst?(species,PBSpecies,:DURALUDON) ||
  502. isConst?(species,PBSpecies,:ETERNATUS) ||
  503. isConst?(species,PBSpecies,:CINDERACE) ||
  504. isConst?(species,PBSpecies,:RILLABOOM) ||
  505. isConst?(species,PBSpecies,:INTELEON)
  506. return true
  507. end
  508. end
  509. return false
  510. end
  511.  
  512. def pbGetGmaxForm
  513. if @pokemon
  514. if isConst?(species,PBSpecies,:CHARIZARD)
  515. return 3 #Mega Y, Mega X, Gmax
  516. elsif isConst?(species,PBSpecies,:BUTTERFREE)
  517. return 1 #Gmax
  518. elsif isConst?(species,PBSpecies,:PIKACHU)
  519. return 1 #Gmax
  520. elsif isConst?(species,PBSpecies,:EEVEE)
  521. return 1 #Gmax
  522. elsif isConst?(species,PBSpecies,:MEOWTH)
  523. return 3 #Alolan, Galarian, Gmax
  524. elsif isConst?(species,PBSpecies,:MACHAMP)
  525. return 2 #Mega, Gmax
  526. elsif isConst?(species,PBSpecies,:GENGAR)
  527. return 2 #Mega, Gmax
  528. elsif isConst?(species,PBSpecies,:KINGLER)
  529. return 1 #Gmax
  530. elsif isConst?(species,PBSpecies,:LAPRAS)
  531. return 1 #Gmax
  532. elsif isConst?(species,PBSpecies,:SNORLAX)
  533. return 1 #Gmax
  534. elsif isConst?(species,PBSpecies,:GARBODOR)
  535. return 1 #Gmax
  536. elsif isConst?(species,PBSpecies,:MELMETAL)
  537. return 1 #Gmax
  538. elsif isConst?(species,PBSpecies,:CORVIKNIGHT)
  539. return 1 #Gmax
  540. elsif isConst?(species,PBSpecies,:ORBEETLE)
  541. return 1 #Gmax
  542. elsif isConst?(species,PBSpecies,:DREADNAW)
  543. return 1 #Gmax
  544. elsif isConst?(species,PBSpecies,:COALOSSAL)
  545. return 1 #Gmax
  546. elsif isConst?(species,PBSpecies,:APPLETUN)
  547. return 1 #Gmax
  548. elsif isConst?(species,PBSpecies,:FLAPPLE)
  549. return 1 #Gmax
  550. elsif isConst?(species,PBSpecies,:SANDACONDA)
  551. return 1 #Gmax
  552. elsif isConst?(species,PBSpecies,:TOXTRICITY)
  553. return 2 #Amped (0), Low-key (1), Gmax (2)
  554. elsif isConst?(species,PBSpecies,:CENTISCORCH)
  555. return 1 #Gmax
  556. elsif isConst?(species,PBSpecies,:HATTERENE) # I DIDN'T EVEN KNOW THIS HAD A GMAX FORM
  557. return 1 #Gmax
  558. elsif isConst?(species,PBSpecies,:GRIMMSNARL)
  559. return 1 #Gmax
  560. elsif isConst?(species,PBSpecies,:ALCREMIE)
  561. return 63 #ALL THE OTHER FORMS THAT NO-ONE BOTHERS WITH, Gmax
  562. elsif isConst?(species,PBSpecies,:COPPERAJAH)
  563. return 1 #Gmax
  564. elsif isConst?(species,PBSpecies,:DURALDON)
  565. return 1 #Gmax
  566. elsif isConst?(species,PBSpecies,:ETERNATUS)
  567. return 1 #Eternamax
  568. elsif isConst?(species,PBSpecies,:CINDERACE) ||
  569. isConst?(species,PBSpecies,:RILLABOOM) ||
  570. isConst?(species,PBSpecies,:INTELEON)
  571. return 1 #Gmax
  572. end
  573. end
  574. end
  575. end
  576.  
  577. class PokeBattle_BattleEffects
  578. def pbFlinch(attacker=nil)
  579. return false if @effects[PBEffects::Dynamax]>0
  580. return false if (!attacker || !attacker.hasMoldBreaker) && hasWorkingAbility(:INNERFOCUS)
  581. @effects[PBEffects::Flinch]=true
  582. return true
  583. end
  584. end
  585.  
  586.  
  587. #===============================================================================
  588. # Rewrites the PokeBattle_Battle script.
  589. #===============================================================================
  590. class PokeBattle_Battle
  591. attr_reader(:player) # Player trainer
  592. attr_reader(:opponent) # Opponent trainer
  593. attr_accessor(:dynamaxButton) # Dmax Button
  594.  
  595. def initialize(scene,p1,p2,player,opponent)
  596. if p1.length==0
  597. raise ArgumentError.new(_INTL("Party 1 has no Pokémon."))
  598. return
  599. end
  600. if p2.length==0
  601. raise ArgumentError.new(_INTL("Party 2 has no Pokémon."))
  602. return
  603. end
  604. if p2.length>2 && !opponent
  605. raise ArgumentError.new(_INTL("Wild battles with more than two Pokémon are not allowed."))
  606. return
  607. end
  608. @scene = scene
  609. @decision = 0
  610. @internalbattle = true
  611. @doublebattle = false
  612. @cantescape = false
  613. @shiftStyle = true
  614. @battlescene = true
  615. @debug = false
  616. @debugupdate = 0
  617. if opponent && player.is_a?(Array) && player.length==0
  618. player = player[0]
  619. end
  620. if opponent && opponent.is_a?(Array) && opponent.length==0
  621. opponent = opponent[0]
  622. end
  623. @player = player # PokeBattle_Trainer object
  624. @opponent = opponent # PokeBattle_Trainer object
  625. @party1 = p1
  626. @party2 = p2
  627. @party1order = []
  628. for i in 0...12; @party1order.push(i); end
  629. @party2order = []
  630. for i in 0...12; @party2order.push(i); end
  631. @fullparty1 = false
  632. @fullparty2 = false
  633. @battlers = []
  634. @items = nil
  635. @sides = [PokeBattle_ActiveSide.new, # Player's side
  636. PokeBattle_ActiveSide.new] # Foe's side
  637. @field = PokeBattle_ActiveField.new # Whole field (gravity/rooms)
  638. @environment = PBEnvironment::None # e.g. Tall grass, cave, still water
  639. @weather = 0
  640. @weatherduration = 0
  641. @switching = false
  642. @futuresight = false
  643. @choices = [ [0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1] ]
  644. @successStates = []
  645. for i in 0...4
  646. @successStates.push(PokeBattle_SuccessState.new)
  647. end
  648. @lastMoveUsed = -1
  649. @lastMoveUser = -1
  650. @nextPickupUse = 0
  651. @megaEvolution = []
  652. if @player.is_a?(Array)
  653. @megaEvolution[0]=[-1]*@player.length
  654. else
  655. @megaEvolution[0]=[-1]
  656. end
  657. if @opponent.is_a?(Array)
  658. @megaEvolution[1]=[-1]*@opponent.length
  659. else
  660. @megaEvolution[1]=[-1]
  661. end
  662. #===========================================================================
  663. # Zodiac Powers
  664. if ZPOWER
  665. @zodiacPower = []
  666. if @player.is_a?(Array)
  667. @zodiacPower[0]=[-1]*@player.length
  668. else
  669. @zodiacPower[0]=[-1]
  670. end
  671. if @opponent.is_a?(Array)
  672. @zodiacPower[1]=[-1]*@opponent.length
  673. else
  674. @zodiacPower[1]=[-1]
  675. end
  676. end
  677. #===========================================================================
  678. # Z-Moves
  679. if ZMOVES
  680. @zMove = []
  681. if @player.is_a?(Array)
  682. @zMove[0]=[-1]*@player.length
  683. else
  684. @zMove[0]=[-1]
  685. end
  686. if @opponent.is_a?(Array)
  687. @zMove[1]=[-1]*@opponent.length
  688. else
  689. @zMove[1]=[-1]
  690. end
  691. end
  692. #===========================================================================
  693. # Spirit Power
  694. if SPOWER
  695. @spiritPower = []
  696. if @player.is_a?(Array)
  697. @spiritPower[0]=[-1]*@player.length
  698. else
  699. @spiritPower[0]=[-1]
  700. end
  701. if @opponent.is_a?(Array)
  702. @spiritPower[1]=[-1]*@opponent.length
  703. else
  704. @spiritPower[1]=[-1]
  705. end
  706. end
  707. #===========================================================================
  708. @dynamax = []
  709. if @player.is_a?(Array)
  710. @dynamax[0]=[-1]*@player.length
  711. else
  712. @dynamax[0]=[-1]
  713. end
  714. if @opponent.is_a?(Array)
  715. @dynamax[1]=[-1]*@opponent.length
  716. else
  717. @dynamax[1]=[-1]
  718. end
  719. @amuletcoin = false
  720. @extramoney = 0
  721. @doublemoney = false
  722. @endspeech = ""
  723. @endspeech2 = ""
  724. @endspeechwin = ""
  725. @endspeechwin2 = ""
  726. @rules = {}
  727. @turncount = 0
  728. @peer = PokeBattle_BattlePeer.create()
  729. @priority = []
  730. @usepriority = false
  731. @snaggedpokemon = []
  732. @runCommand = 0
  733. if hasConst?(PBMoves,:STRUGGLE)
  734. @struggle = PokeBattle_Move.pbFromPBMove(self,PBMove.new(getConst(PBMoves,:STRUGGLE)))
  735. else
  736. @struggle = PokeBattle_Struggle.new(self,nil)
  737. end
  738. @struggle.pp = -1
  739. for i in 0...4
  740. battlers[i] = PokeBattle_Battler.new(self,i)
  741. end
  742. for i in @party1
  743. next if !i
  744. i.itemRecycle = 0
  745. i.itemInitial = i.item
  746. i.belch = false
  747. end
  748. for i in @party2
  749. next if !i
  750. i.itemRecycle = 0
  751. i.itemInitial = i.item
  752. i.belch = false
  753. end
  754. end
  755.  
  756. #===============================================================================
  757. # Dynamax/Gmax a battler
  758. #===============================================================================
  759.  
  760. def pbDynamax(index)
  761. user=@battlers[index]
  762. level = user.dynamaxlevel
  763. user.totalhp = (user.totalhp*2) # HP boost
  764. user.hp = (user.hp*2) # HP boost
  765. pbGetMaxMoves(user)
  766. user.effects[PBEffects::Dynamax]=3
  767. if user.canGmax? && GMAX
  768. user.form = user.pbGetGmaxForm
  769. end
  770. end
  771.  
  772. def pbUndynamax(index)
  773. user=@battlers[index]
  774. user.hp = (user.hp)/2
  775. user.totalhp = (user.totalhp)/2
  776. user.pbUnMaxMoves
  777. if user.canGmax?
  778. user.form = 0
  779. end
  780. end
  781.  
  782. def pbUndynamaxForFaint
  783. @hp = (@hp)/2
  784. @totalhp = (@totalhp)/2
  785. pbUnMaxMoves
  786. if canGmax? && GMAX
  787. @form = 0
  788. end
  789. end
  790.  
  791. def isMaxed?
  792. if @pokemon
  793. return true if @pokemon.effects[PBEffects::Dynamax]>0
  794. return false
  795. end
  796. end
  797.  
  798. def pbFaint(showMessage=true)
  799. unless fainted?
  800. PBDebug.log("!!!***Can't faint with HP greater than 0")
  801. return true
  802. end
  803. if @fainted
  804. PBDebug.log("!!!***Can't faint if already fainted")
  805. return true
  806. end
  807. @battle.scene.pbFainted(self)
  808. pbInitEffects(false)
  809. # Reset status
  810. self.status=0
  811. self.statusCount=0
  812. if @pokemon && @battle.internalbattle
  813. @pokemon.changeHappiness("faint")
  814. end
  815. @pokemon.makeUnmega if self.isMega?
  816. @pokemon.makeUnprimal if self.isPrimal?
  817. @pokemon.pbUndynamaxForFaint if self.isMaxed?
  818. @fainted=true
  819. # reset choice
  820. @battle.choices[@index]=[0,0,nil,-1]
  821. pbOwnSide.effects[PBEffects::LastRoundFainted]=@battle.turncount
  822. @battle.pbDisplayPaused(_INTL("{1} fainted!",pbThis)) if showMessage
  823. PBDebug.log("[Pokémon fainted] #{pbThis}")
  824. return true
  825. end
  826.  
  827. #===============================================================================
  828. # More rewrites of PokeBattle_Battle.
  829. #===============================================================================
  830. def pbRegisterSwitch(idxPokemon,idxOther)
  831. return false if !pbCanSwitch?(idxPokemon,idxOther,false)
  832. @choices[idxPokemon][0]=2 # "Switch Pokémon"
  833. @choices[idxPokemon][1]=idxOther # Index of other Pokémon to switch with
  834. @choices[idxPokemon][2]=nil
  835. side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
  836. owner=pbGetOwnerIndex(idxPokemon)
  837. if @megaEvolution[side][owner]==idxPokemon
  838. @megaEvolution[side][owner]=-1
  839. end
  840. #==============================================
  841. # Zodiac Powers
  842. if ZPOWER
  843. if @zodiacPower[side][owner]==idxPokemon
  844. @zodiacPower[side][owner]=-1
  845. end
  846. end
  847. #==============================================
  848. # Z-Moves
  849. if ZMOVES
  850. if @zMove[side][owner]==idxPokemon
  851. @zMove[side][owner]=-1
  852. end
  853. end
  854. #==============================================
  855. if SPOWER
  856. if @spiritPower[side][owner]==idxPokemon
  857. @spiritPower[side][owner]=-1
  858. end
  859. end
  860. #==============================================
  861. if @dynamax[side][owner]==idxPokemon
  862. @dynamax[side][owner]=-1
  863. end
  864. return true
  865. end
  866.  
  867. def pbRegisterItem(idxPokemon,idxItem,idxTarget=nil)
  868. if idxTarget!=nil && idxTarget>=0
  869. for i in 0...4
  870. if !@battlers[i].pbIsOpposing?(idxPokemon) &&
  871. @battlers[i].pokemonIndex==idxTarget &&
  872. @battlers[i].effects[PBEffects::Embargo]>0
  873. pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",@battlers[i].pbThis(true)))
  874. if pbBelongsToPlayer?(@battlers[i].index)
  875. if $PokemonBag.pbCanStore?(idxItem)
  876. $PokemonBag.pbStoreItem(idxItem)
  877. else
  878. raise _INTL("Couldn't return unused item to Bag somehow.")
  879. end
  880. end
  881. return false
  882. end
  883. end
  884. end
  885. if ItemHandlers.hasUseInBattle(idxItem)
  886. if idxPokemon==0 # Player's first Pokémon
  887. if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
  888. # Using Poké Balls or Poké Doll only
  889. ItemHandlers.triggerUseInBattle(idxItem,@battlers[idxPokemon],self)
  890. if @doublebattle
  891. @battlers[idxPokemon].pbPartner.effects[PBEffects::SkipTurn]=true
  892. end
  893. else
  894. if $PokemonBag.pbCanStore?(idxItem)
  895. $PokemonBag.pbStoreItem(idxItem)
  896. else
  897. raise _INTL("Couldn't return unusable item to Bag somehow.")
  898. end
  899. return false
  900. end
  901. else
  902. if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
  903. pbDisplay(_INTL("It's impossible to aim without being focused!"))
  904. end
  905. return false
  906. end
  907. end
  908. @choices[idxPokemon][0]=3 # "Use an item"
  909. @choices[idxPokemon][1]=idxItem # ID of item to be used
  910. @choices[idxPokemon][2]=idxTarget # Index of Pokémon to use item on
  911. side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
  912. owner=pbGetOwnerIndex(idxPokemon)
  913. if @megaEvolution[side][owner]==idxPokemon
  914. @megaEvolution[side][owner]=-1
  915. end
  916. #==============================================
  917. # Zodiac Powers
  918. if ZPOWER
  919. if @zodiacPower[side][owner]==idxPokemon
  920. @zodiacPower[side][owner]=-1
  921. end
  922. end
  923. #==============================================
  924. # Z-Moves
  925. if ZMOVES
  926. if @zMove[side][owner]==idxPokemon
  927. @zMove[side][owner]=-1
  928. end
  929. end
  930. #==============================================
  931. if SPOWER
  932. if @spiritPower[side][owner]==idxPokemon
  933. @spiritPower[side][owner]=-1
  934. end
  935. end
  936. #==============================================
  937. if @dynamax[side][owner]==idxPokemon
  938. @dynamax[side][owner]=-1
  939. end
  940. return true
  941. end
  942.  
  943. #===============================================================================
  944. # Using Dynamax in battle.
  945. #===============================================================================
  946.  
  947. def pbCanUseDynamax?(index)
  948. return false if pbIsOpposing?(index) && !@opponent
  949. return true if $DEBUG && Input.press?(Input::CTRL)
  950. return false if !canMax?
  951. side=(pbIsOpposing?(index)) ? 1 : 0
  952. owner=pbGetOwnerIndex(index)
  953. return false if @dynamax[side][owner]!=-1
  954. return false if @battlers[index].effects[PBEffects::SkyDrop]
  955. return false if @battlers[index].effects[PBEffects::Transform]
  956. return true if canMax?
  957. return true
  958. end
  959.  
  960. def pbRegisterDynamax(index)
  961. side=(pbIsOpposing?(index)) ? 1 : 0
  962. owner=pbGetOwnerIndex(index)
  963. @dynamax[side][owner]=index
  964. end
  965.  
  966. def pbUseDynamax(index)
  967. return if !@battlers[index] || !@battlers[index].pokemon
  968. return if !(@battlers[index].canMax? rescue false)
  969. pbDynamax(index)
  970. side=(pbIsOpposing?(index)) ? 1 : 0
  971. owner=pbGetOwnerIndex(index)
  972. @dynamax[side][owner]=-2
  973. end
  974.  
  975. #===============================================================================
  976. # Rewrites to PokeBattle_AI
  977. # Allows opposing Pokemon to use Zodiac Powers & Spirit powers
  978. #===============================================================================
  979.  
  980. def pbEnemyShouldDynamax?(index)
  981. return pbCanUseDynamax?(index)
  982. end
  983.  
  984. def pbDefaultChooseEnemyCommand(index)
  985. if !pbCanShowFightMenu?(index)
  986. return if pbEnemyShouldUseItem?(index)
  987. return if pbEnemyShouldWithdraw?(index)
  988. pbAutoChooseMove(index)
  989. return
  990. else
  991. return if pbEnemyShouldUseItem?(index)
  992. return if pbEnemyShouldWithdraw?(index)
  993. return if pbAutoFightMenu(index)
  994. pbRegisterMegaEvolution(index) if pbEnemyShouldMegaEvolve?(index)
  995. #=========================================================================
  996. # Zodiac Powers
  997. if ZPOWER
  998. pbRegisterZodiacPower(index) if pbEnemyShouldUseZodiac?(index)
  999. end
  1000. #=========================================================================
  1001. # Z-Moves
  1002. if ZMOVES
  1003. if pbEnemyShouldZMove?(index)
  1004. return pbChooseEnemyZMove(index)
  1005. end
  1006. end
  1007. #=========================================================================
  1008. if SPOWER
  1009. pbRegisterSpiritPower(index) if pbEnemyShouldUsePower?(index)
  1010. end
  1011. #=========================================================================
  1012. pbRegisterDynamax(index) if pbEnemyShouldDynamax?(index)
  1013. pbChooseMoves(index)
  1014. end
  1015. end
  1016. end
  1017. #===============================================================================
  1018. # More rewrites to PokeBattle_Battle.
  1019. #===============================================================================
  1020. class PokeBattle_Battle
  1021. def pbCommandPhase
  1022. @scene.pbBeginCommandPhase
  1023. # @scene.pbResetCommandIndices
  1024. for i in 0...4 # Reset choices if commands can be shown
  1025. @battlers[i].effects[PBEffects::SkipTurn]=false
  1026. if pbCanShowCommands?(i) || @battlers[i].fainted?
  1027. @choices[i][0]=0
  1028. @choices[i][1]=0
  1029. @choices[i][2]=nil
  1030. @choices[i][3]=-1
  1031. else
  1032. unless !@doublebattle && pbIsDoubleBattler?(i)
  1033. PBDebug.log("[Reusing commands] #{@battlers[i].pbThis(true)}")
  1034. end
  1035. end
  1036. end
  1037. # Reset choices to perform Mega Evolution if it wasn't done somehow
  1038. for i in 0...2
  1039. for j in 0...@megaEvolution[i].length
  1040. @megaEvolution[i][j]=-1 if @megaEvolution[i][j]>=0
  1041. end
  1042. end
  1043. #=======================================================
  1044. # Zodiac Powers
  1045. if ZPOWER
  1046. for i in 0...2
  1047. for j in 0...@zodiacPower[i].length
  1048. @zodiacPower[i][j]=-1 if @zodiacPower[i][j]>=0
  1049. end
  1050. end
  1051. end
  1052. #=======================================================
  1053. # Z-Moves
  1054. if ZMOVES
  1055. for i in 0...@zMove[0].length
  1056. @zMove[0][i]=-1 if @zMove[0][i]>=0
  1057. end
  1058. for i in 0...@zMove[1].length
  1059. @zMove[1][i]=-1 if @zMove[1][i]>=0
  1060. end
  1061. end
  1062. #=======================================================
  1063. if SPOWER
  1064. for i in 0...2
  1065. for j in 0...@spiritPower[i].length
  1066. @spiritPower[i][j]=-1 if @spiritPower[i][j]>=0
  1067. end
  1068. end
  1069. end
  1070. #=======================================================
  1071. for i in 0...2
  1072. for j in 0...@dynamax[i].length
  1073. @dynamax[i][j]=-1 if @dynamax[i][j]>=0
  1074. end
  1075. end
  1076. for i in 0...4
  1077. break if @decision!=0
  1078. next if @choices[i][0]!=0
  1079. if !pbOwnedByPlayer?(i) || @controlPlayer
  1080. if !@battlers[i].fainted? && pbCanShowCommands?(i)
  1081. @scene.pbChooseEnemyCommand(i)
  1082. end
  1083. else
  1084. commandDone=false
  1085. commandEnd=false
  1086. if pbCanShowCommands?(i)
  1087. loop do
  1088. cmd=pbCommandMenu(i)
  1089. if cmd==0 # Fight
  1090. if pbCanShowFightMenu?(i)
  1091. commandDone=true if pbAutoFightMenu(i)
  1092. until commandDone
  1093. index=@scene.pbFightMenu(i)
  1094. if index<0
  1095. side=(pbIsOpposing?(i)) ? 1 : 0
  1096. owner=pbGetOwnerIndex(i)
  1097. if @megaEvolution[side][owner]==i
  1098. @megaEvolution[side][owner]=-1
  1099. end
  1100. #===================================
  1101. # Zodiac Powers
  1102. if ZPOWER
  1103. if @zodiacPower[side][owner]==i
  1104. @zodiacPower[side][owner]=-1
  1105. end
  1106. end
  1107. #===================================
  1108. # Z-Moves
  1109. if ZMOVES
  1110. if @zMove[side][owner]==i
  1111. @zMove[side][owner]=-1
  1112. end
  1113. end
  1114. #===================================
  1115. if SPOWER
  1116. if @spiritPower[side][owner]==i
  1117. @spiritPower[side][owner]=-1
  1118. end
  1119. end
  1120. if @dynamax[side][owner]==i
  1121. @dynamax[side][owner]=-1
  1122. end
  1123. break
  1124. end
  1125. next if !pbRegisterMove(i,index)
  1126. if @doublebattle
  1127. thismove=@battlers[i].moves[index]
  1128. target=@battlers[i].pbTarget(thismove)
  1129. if target==PBTargets::SingleNonUser # single non-user
  1130. target=@scene.pbChooseTarget(i,target)
  1131. next if target<0
  1132. pbRegisterTarget(i,target)
  1133. elsif target==PBTargets::UserOrPartner # Acupressure
  1134. target=@scene.pbChooseTarget(i,target)
  1135. next if target<0 || (target&1)==1
  1136. pbRegisterTarget(i,target)
  1137. end
  1138. end
  1139. commandDone=true
  1140. end
  1141. else
  1142. pbAutoChooseMove(i)
  1143. commandDone=true
  1144. end
  1145. elsif cmd!=0 && @battlers[i].effects[PBEffects::SkyDrop]
  1146. pbDisplay(_INTL("Sky Drop won't let {1} go!",@battlers[i].pbThis(true)))
  1147. elsif cmd==1 # Bag
  1148. if !@internalbattle
  1149. if pbOwnedByPlayer?(i)
  1150. pbDisplay(_INTL("Items can't be used here."))
  1151. end
  1152. else
  1153. item=pbItemMenu(i)
  1154. if item[0]>0
  1155. if pbRegisterItem(i,item[0],item[1])
  1156. commandDone=true
  1157. end
  1158. end
  1159. end
  1160. elsif cmd==2 # Pokémon
  1161. pkmn=pbSwitchPlayer(i,false,true)
  1162. if pkmn>=0
  1163. commandDone=true if pbRegisterSwitch(i,pkmn)
  1164. end
  1165. elsif cmd==3 # Run
  1166. run=pbRun(i)
  1167. if run>0
  1168. commandDone=true
  1169. return
  1170. elsif run<0
  1171. commandDone=true
  1172. side=(pbIsOpposing?(i)) ? 1 : 0
  1173. owner=pbGetOwnerIndex(i)
  1174. if @megaEvolution[side][owner]==i
  1175. @megaEvolution[side][owner]=-1
  1176. end
  1177. #===================================
  1178. # Zodiac Powers
  1179. if ZPOWER
  1180. if @zodiacPower[side][owner]==i
  1181. @zodiacPower[side][owner]=-1
  1182. end
  1183. end
  1184. #===================================
  1185. # Z-Moves
  1186. if ZMOVES
  1187. if @zMove[side][owner]==i
  1188. @zMove[side][owner]=-1
  1189. end
  1190. end
  1191. #===================================
  1192. if SPOWER
  1193. if @spiritPower[side][owner]==i
  1194. @spiritPower[side][owner]=-1
  1195. end
  1196. end
  1197. if @dynamax[side][owner]==i
  1198. @dynamax[side][owner]=-1
  1199. end
  1200. end
  1201. elsif cmd==4 # Call
  1202. thispkmn=@battlers[i]
  1203. @choices[i][0]=4 # "Call Pokémon"
  1204. @choices[i][1]=0
  1205. @choices[i][2]=nil
  1206. side=(pbIsOpposing?(i)) ? 1 : 0
  1207. owner=pbGetOwnerIndex(i)
  1208. if @megaEvolution[side][owner]==i
  1209. @megaEvolution[side][owner]=-1
  1210. end
  1211. #===================================
  1212. # Zodiac Powers
  1213. if INCLUDE_ZPOWER
  1214. if @zodiacPower[side][owner]==i
  1215. @zodiacPower[side][owner]=-1
  1216. end
  1217. end
  1218. #===================================
  1219. # Z-Moves
  1220. if INCLUDE_ZMOVES
  1221. if @zMove[side][owner]==i
  1222. @zMove[side][owner]=-1
  1223. end
  1224. end
  1225. #===================================
  1226. if SPOWER
  1227. if @spiritPower[side][owner]==i
  1228. @spiritPower[side][owner]=-1
  1229. end
  1230. end
  1231. if @dynamax[side][owner]==i
  1232. @dynamax[side][owner]=-1
  1233. end
  1234. commandDone=true
  1235. elsif cmd==-1 # Go back to first battler's choice
  1236. @megaEvolution[0][0]=-1 if @megaEvolution[0][0]>=0
  1237. @megaEvolution[1][0]=-1 if @megaEvolution[1][0]>=0
  1238. #======================================================
  1239. # Zodiac Powers
  1240. if ZPOWER
  1241. @zodiacPower[0][0]=-1 if @zodiacPower[0][0]>=0
  1242. @zodiacPower[1][0]=-1 if @zodiacPower[1][0]>=0
  1243. end
  1244. #======================================================
  1245. # Z-Moves
  1246. if ZMOVES
  1247. @zMove[0][0]=-1 if @zMove[0][0]>=0
  1248. @zMove[1][0]=-1 if @zMove[1][0]>=0
  1249. end
  1250. #======================================================
  1251. if SPOWER
  1252. @spiritPower[0][0]=-1 if @spiritPower[0][0]>=0
  1253. @spiritPower[1][0]=-1 if @spiritPower[1][0]>=0
  1254. end
  1255. @dynamax[0][0]=-1 if @dynamax[0][0]>=0
  1256. @dynamax[1][0]=-1 if @dynamax[1][0]>=0
  1257. # Restore the item the player's first Pokémon was due to use
  1258. if @choices[0][0]==3 && $PokemonBag && $PokemonBag.pbCanStore?(@choices[0][1])
  1259. $PokemonBag.pbStoreItem(@choices[0][1])
  1260. end
  1261. pbCommandPhase
  1262. return
  1263. end
  1264. break if commandDone
  1265. end
  1266. end
  1267. end
  1268. end
  1269. end
  1270.  
  1271. def pbAttackPhase
  1272. @scene.pbBeginAttackPhase
  1273. for i in 0...4
  1274. @successStates[i].clear
  1275. if @choices[i][0]!=1 && @choices[i][0]!=2
  1276. @battlers[i].effects[PBEffects::DestinyBond]=false
  1277. @battlers[i].effects[PBEffects::Grudge]=false
  1278. end
  1279. @battlers[i].turncount+=1 if !@battlers[i].fainted?
  1280. @battlers[i].effects[PBEffects::Rage]=false if !pbChoseMove?(i,:RAGE)
  1281. end
  1282. #===================================
  1283. # Calculate priority at this time
  1284. @usepriority=false
  1285. priority=pbPriority(false,true)
  1286. # Mega Evolution
  1287. megaevolved=[]
  1288. for i in priority
  1289. if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
  1290. side=(pbIsOpposing?(i.index)) ? 1 : 0
  1291. owner=pbGetOwnerIndex(i.index)
  1292. if @megaEvolution[side][owner]==i.index
  1293. pbMegaEvolve(i.index)
  1294. megaevolved.push(i.index)
  1295. end
  1296. end
  1297. end
  1298. if megaevolved.length>0
  1299. for i in priority
  1300. i.pbAbilitiesOnSwitchIn(true) if megaevolved.include?(i.index)
  1301. end
  1302. end
  1303. #===========================================================================
  1304. # Zodiac Powers
  1305. if ZPOWER
  1306. zodiacUsed=[]
  1307. for i in priority
  1308. if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
  1309. side=(pbIsOpposing?(i.index)) ? 1 : 0
  1310. owner=pbGetOwnerIndex(i.index)
  1311. if @zodiacPower[side][owner]==i.index
  1312. pbUseZodiacPower(i.index)
  1313. zodiacUsed.push(i.index)
  1314. end
  1315. end
  1316. end
  1317. end
  1318. #===========================================================================
  1319. # Spirit powers [8901]
  1320. if SPOWER
  1321. spiritUsed=[]
  1322. for i in priority
  1323. if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
  1324. side=(pbIsOpposing?(i.index)) ? 1 : 0
  1325. owner=pbGetOwnerIndex(i.index)
  1326. if @spiritPower[side][owner]==i.index
  1327. pbUseSpiritPower(i.index)
  1328. spiritUsed.push(i.index)
  1329. end
  1330. end
  1331. end
  1332. end
  1333. #===========================================================================
  1334. # Dynamaxing
  1335. dynamaxed = []
  1336. for i in priority
  1337. if @choices[i.index][0]== 1 && !i.effects[PBEffects::SkipTurn]
  1338. side = (pbIsOpposing?(i.index)) ? 1 : 0
  1339. owner = pbGetOwnerIndex (i.index)
  1340. if @dynamax[side][owner]==i.index
  1341. pbDynamax(i.index)
  1342. dynamaxed.push(i.index)
  1343. end
  1344. end
  1345. end
  1346. # Call at Pokémon
  1347. for i in priority
  1348. if @choices[i.index][0]==4 && !i.effects[PBEffects::SkipTurn]
  1349. pbCall(i.index)
  1350. end
  1351. end
  1352. # Switch out Pokémon
  1353. @switching=true
  1354. switched=[]
  1355. for i in priority
  1356. if @choices[i.index][0]==2 && !i.effects[PBEffects::SkipTurn]
  1357. index=@choices[i.index][1] # party position of Pokémon to switch to
  1358. newpokename=index
  1359. if isConst?(pbParty(i.index)[index].ability,PBAbilities,:ILLUSION)
  1360. newpokename=pbGetLastPokeInTeam(i.index)
  1361. end
  1362. self.lastMoveUser=i.index
  1363. if !pbOwnedByPlayer?(i.index)
  1364. owner=pbGetOwner(i.index)
  1365. pbDisplayBrief(_INTL("{1} withdrew {2}!",owner.fullname,i.name))
  1366. PBDebug.log("[Withdrew Pokémon] Opponent withdrew #{i.pbThis(true)}")
  1367. else
  1368. pbDisplayBrief(_INTL("{1}, that's enough!\r\nCome back!",i.name))
  1369. PBDebug.log("[Withdrew Pokémon] Player withdrew #{i.pbThis(true)}")
  1370. end
  1371. for j in priority
  1372. #=====================================================================
  1373. side=(pbIsOpposing?(j.index)) ? 1 : 0
  1374. owner=pbGetOwnerIndex(j.index)
  1375. #=====================================================================
  1376. next if !i.pbIsOpposing?(j.index)
  1377. # if Pursuit and this target ("i") was chosen
  1378. if (pbChoseMoveFunctionCode?(j.index,0x88) && # Pursuit
  1379. !j.hasMovedThisRound?) ||
  1380. #==================================================================
  1381. # Adds the Pursuit effect to 'The Hunter' zodiac power.
  1382. #==================================================================
  1383. if ZPOWER
  1384. (@zodiacPower[side][owner]==j.index && j.ZodiacPursuit?)
  1385. end
  1386. #==================================================================
  1387. if j.status!=PBStatuses::SLEEP && j.status!=PBStatuses::FROZEN &&
  1388. !j.effects[PBEffects::SkyDrop] &&
  1389. (!j.hasWorkingAbility(:TRUANT) || !j.effects[PBEffects::Truant])
  1390. @choices[j.index][3]=i.index # Make sure to target the switching Pokémon
  1391. j.pbUseMove(@choices[j.index]) # This calls pbGainEXP as appropriate
  1392. j.effects[PBEffects::Pursuit]=true
  1393. @switching=false
  1394. return if @decision>0
  1395. end
  1396. end
  1397. break if i.fainted?
  1398. end
  1399. if !pbRecallAndReplace(i.index,index,newpokename)
  1400. # If a forced switch somehow occurs here in single battles
  1401. # the attack phase now ends
  1402. if !@doublebattle
  1403. @switching=false
  1404. return
  1405. end
  1406. else
  1407. switched.push(i.index)
  1408. end
  1409. end
  1410. end
  1411. if switched.length>0
  1412. for i in priority
  1413. i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
  1414. end
  1415. end
  1416. @switching=false
  1417. # Use items
  1418. for i in priority
  1419. if @choices[i.index][0]==3 && !i.effects[PBEffects::SkipTurn]
  1420. if pbIsOpposing?(i.index)
  1421. # Opponent use item
  1422. pbEnemyUseItem(@choices[i.index][1],i)
  1423. else
  1424. # Player use item
  1425. item=@choices[i.index][1]
  1426. if item>0
  1427. usetype=$ItemData[item][ITEMBATTLEUSE]
  1428. if usetype==1 || usetype==3
  1429. if @choices[i.index][2]>=0
  1430. pbUseItemOnPokemon(item,@choices[i.index][2],i,@scene)
  1431. end
  1432. elsif usetype==2 || usetype==4
  1433. if !ItemHandlers.hasUseInBattle(item) # Poké Ball/Poké Doll used already
  1434. pbUseItemOnBattler(item,@choices[i.index][2],i,@scene)
  1435. end
  1436. end
  1437. end
  1438. end
  1439. end
  1440. end
  1441. # Use attacks
  1442. for i in priority
  1443. next if i.effects[PBEffects::SkipTurn]
  1444. if pbChoseMoveFunctionCode?(i.index,0x115) # Focus Punch
  1445. pbCommonAnimation("FocusPunch",i,nil)
  1446. pbDisplay(_INTL("{1} is tightening its focus!",i.pbThis))
  1447. end
  1448. end
  1449. 10.times do
  1450. # Forced to go next
  1451. advance=false
  1452. for i in priority
  1453. next if !i.effects[PBEffects::MoveNext]
  1454. next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  1455. advance=i.pbProcessTurn(@choices[i.index])
  1456. break if advance
  1457. end
  1458. return if @decision>0
  1459. next if advance
  1460. # Regular priority order
  1461. for i in priority
  1462. next if i.effects[PBEffects::Quash]
  1463. #=======================================================================
  1464. # Switches out after attacking if Fugitive Zodiac Power is used.
  1465. #=======================================================================
  1466. if ZPOWER
  1467. side=(pbIsOpposing?(i.index)) ? 1 : 0
  1468. owner=pbGetOwnerIndex(i.index)
  1469. if @zodiacPower[side][owner]==i.index
  1470. pbUseSelfSwitchOut(i.index)
  1471. end
  1472. end
  1473. #=======================================================================
  1474. next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  1475. advance=i.pbProcessTurn(@choices[i.index])
  1476. #=======================================================================
  1477. # Switches out opponent after attacking if Voyager Zodiac Power is used.
  1478. #=======================================================================
  1479. if ZPOWER
  1480. side=(pbIsOpposing?(i.index)) ? 1 : 0
  1481. owner=pbGetOwnerIndex(i.index)
  1482. if @zodiacPower[side][owner]==i.index
  1483. pbUseOppSwitchOut(i.index)
  1484. end
  1485. end
  1486. #=======================================================================
  1487. break if advance
  1488. end
  1489. return if @decision>0
  1490. next if advance
  1491. # Quashed
  1492. for i in priority
  1493. next if !i.effects[PBEffects::Quash]
  1494. next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  1495. advance=i.pbProcessTurn(@choices[i.index])
  1496. break if advance
  1497. end
  1498. return if @decision>0
  1499. next if advance
  1500. # Check for all done
  1501. for i in priority
  1502. advance=true if @choices[i.index][0]==1 && !i.hasMovedThisRound? &&
  1503. !i.effects[PBEffects::SkipTurn]
  1504. break if advance
  1505. end
  1506. next if advance
  1507. break
  1508. end
  1509. 10.times do
  1510. @scene.pbGraphicsUpdate
  1511. @scene.pbInputUpdate
  1512. @scene.pbFrameUpdate
  1513. end
  1514. end
  1515. end
  1516.  
  1517. #===============================================================================
  1518. # Menu Graphic for toggling Zodiac Power.
  1519. #===============================================================================
  1520. class FightMenuDisplay
  1521. attr_reader :battler
  1522. attr_reader :index
  1523. attr_accessor :megaButton
  1524. attr_accessor :zodiacButton
  1525. attr_accessor :zButton
  1526. attr_accessor :spiritButton
  1527. attr_accessor :dynamaxButton
  1528.  
  1529. def initialize(battler,viewport=nil)
  1530. @display=nil
  1531. if PokeBattle_SceneConstants::USEFIGHTBOX
  1532. @display=IconSprite.new(0,Graphics.height-96,viewport)
  1533. @display.setBitmap("Graphics/Pictures/Battle/overlay_fight")
  1534. end
  1535. @window=Window_CommandPokemon.newWithSize([],0,Graphics.height-96,320,96,viewport)
  1536. @window.columns=2
  1537. @window.columnSpacing=4
  1538. @window.ignore_input=true
  1539. pbSetNarrowFont(@window.contents)
  1540. @info=Window_AdvancedTextPokemon.newWithSize(
  1541. "",320,Graphics.height-96,Graphics.width-320,96,viewport)
  1542. pbSetNarrowFont(@info.contents)
  1543. @ctag=shadowctag(PokeBattle_SceneConstants::MENUBASECOLOR,
  1544. PokeBattle_SceneConstants::MENUSHADOWCOLOR)
  1545. @buttons=nil
  1546. @battler=battler
  1547. @index=0
  1548. @megaButton=0 # 0=don't show, 1=show, 2=pressed
  1549. #====================================================
  1550. # Zodiac Powers
  1551. @zodiacButton=0 # 0=don't show, 1=show, 2=pressed
  1552. #====================================================
  1553. # Z-Moves
  1554. @zButton=0 # 0=don't show, 1=show, 2=pressed
  1555. #====================================================
  1556. @spiritButton=0 # 0=don't show, 1=show, 2=pressed
  1557. #====================================================
  1558. @dynamaxButton=0 # 0=don't show, 1=show, 2=pressed
  1559. if PokeBattle_SceneConstants::USEFIGHTBOX
  1560. @window.opacity=0
  1561. @window.x=Graphics.width
  1562. @info.opacity=0
  1563. @info.x=Graphics.width+Graphics.width-96
  1564. @buttons=FightMenuButtons.new(self.index,nil,viewport)
  1565. end
  1566. refresh
  1567. end
  1568.  
  1569. def refresh
  1570. return if !@battler
  1571. commands=[]
  1572. for i in 0...4
  1573. break if @battler.moves[i].id==0
  1574. commands.push(@battler.moves[i].name)
  1575. end
  1576. @window.commands=commands
  1577. selmove=@battler.moves[@index]
  1578. movetype=PBTypes.getName(selmove.type)
  1579. if selmove.totalpp==0
  1580. @info.text=_INTL("{1}PP: ---<br>TYPE/{2}",@ctag,movetype)
  1581. else
  1582. @info.text=_ISPRINTF("{1:s}PP: {2: 2d}/{3: 2d}<br>TYPE/{4:s}",
  1583. @ctag,selmove.pp,selmove.totalpp,movetype)
  1584. end
  1585. #===========================================================================
  1586. @buttons.refresh(self.index,@battler ? @battler.moves : nil,@megaButton,@zodiacButton,@zButton,@spiritButton,@dynamaxButton) if @buttons
  1587. #===========================================================================
  1588. end
  1589.  
  1590. def update
  1591. @info.update
  1592. @window.update
  1593. @display.update if @display
  1594. if @buttons
  1595. moves=@battler ? @battler.moves : nil
  1596. #=========================================================================
  1597. @buttons.update(self.index,moves,@megaButton,@zodiacButton,@zButton,@spiritButton,@dynamaxButton)
  1598. #=========================================================================
  1599. end
  1600. end
  1601. end
  1602.  
  1603. class FightMenuButtons < BitmapSprite
  1604. UPPERGAP=46
  1605.  
  1606. def initialize(index=0,moves=nil,viewport=nil)
  1607. super(Graphics.width,96+UPPERGAP,viewport)
  1608. self.x=0
  1609. self.y=Graphics.height-96-UPPERGAP
  1610. pbSetNarrowFont(self.bitmap)
  1611. @buttonbitmap=AnimatedBitmap.new("Graphics/Pictures/Battle/cursor_fight")
  1612. @typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
  1613. @megaevobitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_mega"))
  1614. #===========================================================================
  1615. @zodiacbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Birthsigns/Other/battlezodiac"))
  1616. #===========================================================================
  1617. @zmovebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/ZMove"))
  1618. #===========================================================================
  1619. @spiritbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/Spirit_Power_Button"))
  1620. #===========================================================================
  1621. @maxbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_dynamax"))
  1622. refresh(index,moves,0,0,0,0,0)
  1623. end
  1624.  
  1625. def dispose
  1626. @buttonbitmap.dispose
  1627. @typebitmap.dispose
  1628. @megaevobitmap.dispose
  1629. #======================
  1630. @zodiacbitmap.dispose
  1631. #======================
  1632. @zmovebitmap.dispose
  1633. #======================
  1634. @spiritbitmap.dispose
  1635. #======================
  1636. @maxbitmap.dispose
  1637. super
  1638. end
  1639.  
  1640. def update(index=0,moves=nil,megaButton=0,zodiacButton=0,zButton=0,spiritButton=0,dynamaxButton=0)
  1641. refresh(index,moves,megaButton,zodiacButton,zButton,spiritButton,dynamaxButton)
  1642. end
  1643.  
  1644. def refresh(index,moves,megaButton,zodiacButton,zButton,spiritButton,dynamaxButton)
  1645. return if !moves
  1646. self.bitmap.clear
  1647. textpos=[]
  1648. for i in 0...4
  1649. next if i==index
  1650. next if moves[i].id==0
  1651. x=((i%2)==0) ? 4 : 192
  1652. y=((i/2)==0) ? 6 : 48
  1653. y+=UPPERGAP
  1654. self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(0,moves[i].type*46,192,46))
  1655. textpos.push([moves[i].name,x+96,y+8,2,
  1656. PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
  1657. end
  1658. ppcolors=[
  1659. PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
  1660. PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
  1661. PokeBattle_SceneConstants::PPTEXTBASECOLORYELLOW,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORYELLOW,
  1662. PokeBattle_SceneConstants::PPTEXTBASECOLORORANGE,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORORANGE,
  1663. PokeBattle_SceneConstants::PPTEXTBASECOLORRED,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORRED
  1664. ]
  1665. for i in 0...4
  1666. next if i!=index
  1667. next if moves[i].id==0
  1668. x=((i%2)==0) ? 4 : 192
  1669. y=((i/2)==0) ? 6 : 48
  1670. y+=UPPERGAP
  1671. self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(192,moves[i].type*46,192,46))
  1672. self.bitmap.blt(416,20+UPPERGAP,@typebitmap.bitmap,Rect.new(0,moves[i].type*28,64,28))
  1673. textpos.push([moves[i].name,x+96,y+8,2,
  1674. PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
  1675. if moves[i].totalpp>0
  1676. ppfraction=(4.0*moves[i].pp/moves[i].totalpp).ceil
  1677. textpos.push([_INTL("PP: {1}/{2}",moves[i].pp,moves[i].totalpp),
  1678. 448,50+UPPERGAP,2,ppcolors[(4-ppfraction)*2],ppcolors[(4-ppfraction)*2+1]])
  1679. end
  1680. end
  1681. pbDrawTextPositions(self.bitmap,textpos)
  1682. if megaButton>0
  1683. self.bitmap.blt(146,0,@megaevobitmap.bitmap,Rect.new(0,(megaButton-1)*46,96,46))
  1684. end
  1685. #===========================================================================
  1686. # Zodiac Powers
  1687. if zodiacButton>0
  1688. self.bitmap.blt(146,0,@zodiacbitmap.bitmap,Rect.new(0,(zodiacButton-1)*46,96,46))
  1689. end
  1690. #===========================================================================
  1691. # Z-Moves
  1692. if zButton>0
  1693. self.bitmap.blt(146,0,@zmovebitmap.bitmap,Rect.new(0,(zButton-1)*46,96,46))
  1694. end
  1695. #===========================================================================
  1696. # Spirit Powers
  1697. if spiritButton>0
  1698. self.bitmap.blt(146,0,@spiritbitmap.bitmap,Rect.new(0,(spiritButton-1)*46,96,46))
  1699. end
  1700. #===========================================================================
  1701. if dynamaxButton>0
  1702. self.bitmap.blt(146,0,@maxbitmap.bitmap,Rect.new(0,(dynamaxButton-1)*46,96,46))
  1703. end
  1704. end
  1705. end
  1706.  
  1707. class PokeBattle_Scene
  1708. def pbFightMenu(index)
  1709. pbShowWindow(FIGHTBOX)
  1710. cw = @sprites["fightwindow"]
  1711. battler=@battle.battlers[index]
  1712. cw.battler=battler
  1713. lastIndex=@lastmove[index]
  1714. if battler.moves[lastIndex].id!=0
  1715. cw.setIndex(lastIndex)
  1716. else
  1717. cw.setIndex(0)
  1718. end
  1719. cw.megaButton=0
  1720. cw.megaButton=1 if @battle.pbCanMegaEvolve?(index)
  1721. #=====================================================
  1722. cw.zodiacButton=0
  1723. if ZPOWER
  1724. cw.zodiacButton=1 if @battle.pbCanUseZodiacPower?(index)
  1725. end
  1726. #=====================================================
  1727. cw.zButton=0
  1728. if ZMOVES
  1729. cw.zButton=1 if @battle.pbCanZMove?(index)
  1730. end
  1731. #=====================================================
  1732. cw.spiritButton=0
  1733. if SPOWER
  1734. cw.spiritButton=1 if @battle.pbCanUseSpiritPower?(index)
  1735. end
  1736. #=====================================================
  1737. cw.dynamaxButton=0
  1738. cw.dynamaxButton=1 if @battle.pbCanUseDynamax?(index)
  1739. pbSelectBattler(index)
  1740. pbRefresh
  1741. loop do
  1742. pbGraphicsUpdate
  1743. pbInputUpdate
  1744. pbFrameUpdate(cw)
  1745. # Update selected command
  1746. if Input.trigger?(Input::LEFT) && (cw.index&1)==1
  1747. pbPlayCursorSE if cw.setIndex(cw.index-1)
  1748. elsif Input.trigger?(Input::RIGHT) && (cw.index&1)==0
  1749. pbPlayCursorSE if cw.setIndex(cw.index+1)
  1750. elsif Input.trigger?(Input::UP) && (cw.index&2)==2
  1751. pbPlayCursorSE if cw.setIndex(cw.index-2)
  1752. elsif Input.trigger?(Input::DOWN) && (cw.index&2)==0
  1753. pbPlayCursorSE if cw.setIndex(cw.index+2)
  1754. end
  1755. #================I just think this is better than this --> ###############
  1756. if Input.trigger?(Input::C) # Confirm choice
  1757. ret=cw.index
  1758. if cw.zButton==2
  1759. if battler.pbCompatibleZMoveFromIndex?(ret)
  1760. pbPlayDecisionSE()
  1761. @lastmove[index]=ret
  1762. return ret
  1763. else
  1764. @battle.pbDisplay(_INTL("{1} is not compatible with {2}!",PBMoves.getName(battler.moves[ret]),PBItems.getName(battler.item)))
  1765. @lastmove[index]=cw.index
  1766. return -1
  1767. end
  1768. else
  1769. pbPlayDecisionSE
  1770. @lastmove[index]=ret
  1771. return ret
  1772. end
  1773. elsif Input.trigger?(Input::A) # Use Mega Evolution
  1774. if @battle.pbCanMegaEvolve?(index)
  1775. @battle.pbRegisterMegaEvolution(index)
  1776. cw.megaButton=2
  1777. pbPlayDecisionSE
  1778. end
  1779. #=======================================================================
  1780. if ZPOWER
  1781. if @battle.pbCanUseZodiacPower?(index) # Use Zodiac Power
  1782. @battle.pbRegisterZodiacPower(index)
  1783. cw.zodiacButton=2
  1784. pbPlayDecisionSE
  1785. end
  1786. end
  1787. #=======================================================================
  1788. if ZMOVES
  1789. if @battle.pbCanZMove?(index) # Use Z Move
  1790. @battle.pbRegisterZMove(index)
  1791. cw.zButton=2
  1792. pbPlayDecisionSE
  1793. end
  1794. end
  1795. #=======================================================================
  1796. if SPOWER
  1797. if @battle.pbCanUseSpiritPower?(index)
  1798. @battle.pbRegisterSpiritPower(index)
  1799. cw.spiritButton=2
  1800. pbPlayDecisionSE
  1801. end
  1802. end
  1803. #=======================================================================
  1804. if @battle.pbCanUseDynamax?(index)
  1805. @battle.pbRegisterDynamax(index)
  1806. cw.dynamaxButton=2
  1807. pbPlayDecisionSE
  1808. end
  1809. elsif Input.trigger?(Input::B) # Cancel fight menu
  1810. @lastmove[index]=cw.index
  1811. pbPlayCancelSE
  1812. return -1
  1813. end
  1814. end
  1815. end
  1816. end
  1817.  
  1818. class PokeBattle_Battler
  1819.  
  1820. def pbUndynamaxForFaint
  1821. @hp=(@hp)/2
  1822. @totalhp=(@totalhp)/2
  1823. pbRestoreMoves(@pokemon)
  1824. if canGmax?
  1825. @form=0
  1826. end
  1827. end
  1828.  
  1829. end
  1830.  
  1831. class PokeBattle_Battle
  1832.  
  1833. def pbEndOfRoundPhase
  1834. PBDebug.log("[End of round]")
  1835. for i in 0...4
  1836. @battlers[i].effects[PBEffects::Electrify]=false
  1837. @battlers[i].effects[PBEffects::Endure]=false
  1838. @battlers[i].effects[PBEffects::FirstPledge]=0
  1839. @battlers[i].effects[PBEffects::HyperBeam]-=1 if @battlers[i].effects[PBEffects::HyperBeam]>0
  1840. @battlers[i].effects[PBEffects::KingsShield]=false
  1841. @battlers[i].effects[PBEffects::LifeOrb]=false
  1842. @battlers[i].effects[PBEffects::MoveNext]=false
  1843. @battlers[i].effects[PBEffects::Powder]=false
  1844. @battlers[i].effects[PBEffects::Protect]=false
  1845. @battlers[i].effects[PBEffects::ProtectNegation]=false
  1846. @battlers[i].effects[PBEffects::Quash]=false
  1847. @battlers[i].effects[PBEffects::Roost]=false
  1848. @battlers[i].effects[PBEffects::SpikyShield]=false
  1849. end
  1850. @usepriority=false # recalculate priority
  1851. priority=pbPriority(true) # Ignoring Quick Claw here
  1852. # Weather
  1853. case @weather
  1854. when PBWeather::SUNNYDAY
  1855. @weatherduration=@weatherduration-1 if @weatherduration>0
  1856. if @weatherduration==0
  1857. pbDisplay(_INTL("The sunlight faded."))
  1858. @weather=0
  1859. PBDebug.log("[End of effect] Sunlight weather ended")
  1860. else
  1861. pbCommonAnimation("Sunny",nil,nil)
  1862. # pbDisplay(_INTL("The sunlight is strong."))
  1863. if pbWeather==PBWeather::SUNNYDAY
  1864. for i in priority
  1865. if i.hasWorkingAbility(:SOLARPOWER)
  1866. PBDebug.log("[Ability triggered] #{i.pbThis}'s Solar Power")
  1867. @scene.pbDamageAnimation(i,0)
  1868. i.pbReduceHP((i.totalhp/8).floor)
  1869. pbDisplay(_INTL("{1} was hurt by the sunlight!",i.pbThis))
  1870. if i.fainted?
  1871. return if !i.pbFaint
  1872. end
  1873. end
  1874. end
  1875. end
  1876. end
  1877. when PBWeather::RAINDANCE
  1878. @weatherduration=@weatherduration-1 if @weatherduration>0
  1879. if @weatherduration==0
  1880. pbDisplay(_INTL("The rain stopped."))
  1881. @weather=0
  1882. PBDebug.log("[End of effect] Rain weather ended")
  1883. else
  1884. pbCommonAnimation("Rain",nil,nil)
  1885. # pbDisplay(_INTL("Rain continues to fall."))
  1886. end
  1887. when PBWeather::SANDSTORM
  1888. @weatherduration=@weatherduration-1 if @weatherduration>0
  1889. if @weatherduration==0
  1890. pbDisplay(_INTL("The sandstorm subsided."))
  1891. @weather=0
  1892. PBDebug.log("[End of effect] Sandstorm weather ended")
  1893. else
  1894. pbCommonAnimation("Sandstorm",nil,nil)
  1895. # pbDisplay(_INTL("The sandstorm rages."))
  1896. if pbWeather==PBWeather::SANDSTORM
  1897. PBDebug.log("[Lingering effect triggered] Sandstorm weather damage")
  1898. for i in priority
  1899. next if i.fainted?
  1900. if !i.pbHasType?(:GROUND) && !i.pbHasType?(:ROCK) && !i.pbHasType?(:STEEL) &&
  1901. !i.hasWorkingAbility(:SANDVEIL) &&
  1902. !i.hasWorkingAbility(:SANDRUSH) &&
  1903. !i.hasWorkingAbility(:SANDFORCE) &&
  1904. !i.hasWorkingAbility(:MAGICGUARD) &&
  1905. !i.hasWorkingAbility(:OVERCOAT) &&
  1906. !i.hasWorkingItem(:SAFETYGOGGLES) &&
  1907. ![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
  1908. @scene.pbDamageAnimation(i,0)
  1909. i.pbReduceHP((i.totalhp/16).floor)
  1910. pbDisplay(_INTL("{1} is buffeted by the sandstorm!",i.pbThis))
  1911. if i.fainted?
  1912. return if !i.pbFaint
  1913. end
  1914. end
  1915. end
  1916. end
  1917. end
  1918. when PBWeather::HAIL
  1919. @weatherduration=@weatherduration-1 if @weatherduration>0
  1920. if @weatherduration==0
  1921. pbDisplay(_INTL("The hail stopped."))
  1922. @weather=0
  1923. PBDebug.log("[End of effect] Hail weather ended")
  1924. else
  1925. pbCommonAnimation("Hail",nil,nil)
  1926. # pbDisplay(_INTL("Hail continues to fall."))
  1927. if pbWeather==PBWeather::HAIL
  1928. PBDebug.log("[Lingering effect triggered] Hail weather damage")
  1929. for i in priority
  1930. next if i.fainted?
  1931. if !i.pbHasType?(:ICE) &&
  1932. !i.hasWorkingAbility(:ICEBODY) &&
  1933. !i.hasWorkingAbility(:SNOWCLOAK) &&
  1934. !i.hasWorkingAbility(:MAGICGUARD) &&
  1935. !i.hasWorkingAbility(:OVERCOAT) &&
  1936. !i.hasWorkingItem(:SAFETYGOGGLES) &&
  1937. ![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
  1938. @scene.pbDamageAnimation(i,0)
  1939. i.pbReduceHP((i.totalhp/16).floor)
  1940. pbDisplay(_INTL("{1} is buffeted by the hail!",i.pbThis))
  1941. if i.fainted?
  1942. return if !i.pbFaint
  1943. end
  1944. end
  1945. end
  1946. end
  1947. end
  1948. when PBWeather::HEAVYRAIN
  1949. hasabil=false
  1950. for i in 0...4
  1951. if isConst?(@battlers[i].ability,PBAbilities,:PRIMORDIALSEA) && !@battlers[i].fainted?
  1952. hasabil=true; break
  1953. end
  1954. end
  1955. @weatherduration=0 if !hasabil
  1956. if @weatherduration==0
  1957. pbDisplay(_INTL("The heavy rain stopped."))
  1958. @weather=0
  1959. PBDebug.log("[End of effect] Primordial Sea's rain weather ended")
  1960. else
  1961. pbCommonAnimation("HeavyRain",nil,nil)
  1962. # pbDisplay(_INTL("It is raining heavily."))
  1963. end
  1964. when PBWeather::HARSHSUN
  1965. hasabil=false
  1966. for i in 0...4
  1967. if isConst?(@battlers[i].ability,PBAbilities,:DESOLATELAND) && !@battlers[i].fainted?
  1968. hasabil=true; break
  1969. end
  1970. end
  1971. @weatherduration=0 if !hasabil
  1972. if @weatherduration==0
  1973. pbDisplay(_INTL("The harsh sunlight faded."))
  1974. @weather=0
  1975. PBDebug.log("[End of effect] Desolate Land's sunlight weather ended")
  1976. else
  1977. pbCommonAnimation("HarshSun",nil,nil)
  1978. # pbDisplay(_INTL("The sunlight is extremely harsh."))
  1979. if pbWeather==PBWeather::HARSHSUN
  1980. for i in priority
  1981. if i.hasWorkingAbility(:SOLARPOWER)
  1982. PBDebug.log("[Ability triggered] #{i.pbThis}'s Solar Power")
  1983. @scene.pbDamageAnimation(i,0)
  1984. i.pbReduceHP((i.totalhp/8).floor)
  1985. pbDisplay(_INTL("{1} was hurt by the sunlight!",i.pbThis))
  1986. if i.fainted?
  1987. return if !i.pbFaint
  1988. end
  1989. end
  1990. end
  1991. end
  1992. end
  1993. when PBWeather::STRONGWINDS
  1994. hasabil=false
  1995. for i in 0...4
  1996. if isConst?(@battlers[i].ability,PBAbilities,:DELTASTREAM) && !@battlers[i].fainted?
  1997. hasabil=true; break
  1998. end
  1999. end
  2000. @weatherduration=0 if !hasabil
  2001. if @weatherduration==0
  2002. pbDisplay(_INTL("The air current subsided."))
  2003. @weather=0
  2004. PBDebug.log("[End of effect] Delta Stream's wind weather ended")
  2005. else
  2006. pbCommonAnimation("StrongWinds",nil,nil)
  2007. # pbDisplay(_INTL("The wind is strong."))
  2008. end
  2009. end
  2010. # Shadow Sky weather
  2011. if isConst?(@weather,PBWeather,:SHADOWSKY)
  2012. @weatherduration=@weatherduration-1 if @weatherduration>0
  2013. if @weatherduration==0
  2014. pbDisplay(_INTL("The shadow sky faded."))
  2015. @weather=0
  2016. PBDebug.log("[End of effect] Shadow Sky weather ended")
  2017. else
  2018. pbCommonAnimation("ShadowSky",nil,nil)
  2019. # pbDisplay(_INTL("The shadow sky continues."));
  2020. if isConst?(pbWeather,PBWeather,:SHADOWSKY)
  2021. PBDebug.log("[Lingering effect triggered] Shadow Sky weather damage")
  2022. for i in priority
  2023. next if i.fainted?
  2024. if !i.isShadow?
  2025. @scene.pbDamageAnimation(i,0)
  2026. i.pbReduceHP((i.totalhp/16).floor)
  2027. pbDisplay(_INTL("{1} was hurt by the shadow sky!",i.pbThis))
  2028. if i.fainted?
  2029. return if !i.pbFaint
  2030. end
  2031. end
  2032. end
  2033. end
  2034. end
  2035. end
  2036. # Future Sight/Doom Desire
  2037. for i in battlers # not priority
  2038. next if i.fainted?
  2039. if i.effects[PBEffects::FutureSight]>0
  2040. i.effects[PBEffects::FutureSight]-=1
  2041. if i.effects[PBEffects::FutureSight]==0
  2042. move=i.effects[PBEffects::FutureSightMove]
  2043. PBDebug.log("[Lingering effect triggered] #{PBMoves.getName(move)} struck #{i.pbThis(true)}")
  2044. pbDisplay(_INTL("{1} took the {2} attack!",i.pbThis,PBMoves.getName(move)))
  2045. moveuser=nil
  2046. for j in battlers
  2047. next if j.pbIsOpposing?(i.effects[PBEffects::FutureSightUserPos])
  2048. if j.pokemonIndex==i.effects[PBEffects::FutureSightUser] && !j.fainted?
  2049. moveuser=j; break
  2050. end
  2051. end
  2052. if !moveuser
  2053. party=pbParty(i.effects[PBEffects::FutureSightUserPos])
  2054. if party[i.effects[PBEffects::FutureSightUser]].hp>0
  2055. moveuser=PokeBattle_Battler.new(self,i.effects[PBEffects::FutureSightUserPos])
  2056. moveuser.pbInitDummyPokemon(party[i.effects[PBEffects::FutureSightUser]],
  2057. i.effects[PBEffects::FutureSightUser])
  2058. end
  2059. end
  2060. if !moveuser
  2061. pbDisplay(_INTL("But it failed!"))
  2062. else
  2063. @futuresight=true
  2064. moveuser.pbUseMoveSimple(move,-1,i.index)
  2065. @futuresight=false
  2066. end
  2067. i.effects[PBEffects::FutureSight]=0
  2068. i.effects[PBEffects::FutureSightMove]=0
  2069. i.effects[PBEffects::FutureSightUser]=-1
  2070. i.effects[PBEffects::FutureSightUserPos]=-1
  2071. if i.fainted?
  2072. return if !i.pbFaint
  2073. next
  2074. end
  2075. end
  2076. end
  2077. end
  2078. for i in priority
  2079. next if i.fainted?
  2080. # Rain Dish
  2081. if i.hasWorkingAbility(:RAINDISH) && i.effects[PBEffects::HealBlock]==0 &&
  2082. (pbWeather==PBWeather::RAINDANCE ||
  2083. pbWeather==PBWeather::HEAVYRAIN)
  2084. PBDebug.log("[Ability triggered] #{i.pbThis}'s Rain Dish")
  2085. hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
  2086. pbDisplay(_INTL("{1}'s {2} restored its HP a little!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
  2087. end
  2088. # Dry Skin
  2089. if i.hasWorkingAbility(:DRYSKIN)
  2090. if (pbWeather==PBWeather::RAINDANCE || pbWeather==PBWeather::HEAVYRAIN) &&
  2091. i.effects[PBEffects::HealBlock]==0
  2092. PBDebug.log("[Ability triggered] #{i.pbThis}'s Dry Skin (in rain)")
  2093. hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
  2094. pbDisplay(_INTL("{1}'s {2} was healed by the rain!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
  2095. elsif pbWeather==PBWeather::SUNNYDAY ||
  2096. pbWeather==PBWeather::HARSHSUN
  2097. PBDebug.log("[Ability triggered] #{i.pbThis}'s Dry Skin (in sun)")
  2098. @scene.pbDamageAnimation(i,0)
  2099. hploss=i.pbReduceHP((i.totalhp/8).floor)
  2100. pbDisplay(_INTL("{1}'s {2} was hurt by the sunlight!",i.pbThis,PBAbilities.getName(i.ability))) if hploss>0
  2101. end
  2102. end
  2103. # Ice Body
  2104. if i.hasWorkingAbility(:ICEBODY) && pbWeather==PBWeather::HAIL &&
  2105. i.effects[PBEffects::HealBlock]==0
  2106. PBDebug.log("[Ability triggered] #{i.pbThis}'s Ice Body")
  2107. hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
  2108. pbDisplay(_INTL("{1}'s {2} restored its HP a little!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
  2109. end
  2110. if i.fainted?
  2111. return if !i.pbFaint
  2112. end
  2113. end
  2114. # Wish
  2115. for i in priority
  2116. next if i.fainted?
  2117. if i.effects[PBEffects::Wish]>0
  2118. i.effects[PBEffects::Wish]-=1
  2119. if i.effects[PBEffects::Wish]==0
  2120. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Wish")
  2121. hpgain=i.pbRecoverHP(i.effects[PBEffects::WishAmount],true)
  2122. if hpgain>0
  2123. wishmaker=pbThisEx(i.index,i.effects[PBEffects::WishMaker])
  2124. pbDisplay(_INTL("{1}'s wish came true!",wishmaker))
  2125. end
  2126. end
  2127. end
  2128. end
  2129. # Fire Pledge + Grass Pledge combination damage
  2130. for i in 0...2
  2131. if sides[i].effects[PBEffects::SeaOfFire]>0 &&
  2132. pbWeather!=PBWeather::RAINDANCE &&
  2133. pbWeather!=PBWeather::HEAVYRAIN
  2134. @battle.pbCommonAnimation("SeaOfFire",nil,nil) if i==0
  2135. @battle.pbCommonAnimation("SeaOfFireOpp",nil,nil) if i==1
  2136. for j in priority
  2137. next if (j.index&1)!=i
  2138. next if j.pbHasType?(:FIRE) || j.hasWorkingAbility(:MAGICGUARD)
  2139. @scene.pbDamageAnimation(j,0)
  2140. hploss=j.pbReduceHP((j.totalhp/8).floor)
  2141. pbDisplay(_INTL("{1} is hurt by the sea of fire!",j.pbThis)) if hploss>0
  2142. if j.fainted?
  2143. return if !j.pbFaint
  2144. end
  2145. end
  2146. end
  2147. end
  2148. for i in priority
  2149. next if i.fainted?
  2150. # Shed Skin, Hydration
  2151. if (i.hasWorkingAbility(:SHEDSKIN) && pbRandom(10)<3) ||
  2152. (i.hasWorkingAbility(:HYDRATION) && (pbWeather==PBWeather::RAINDANCE ||
  2153. pbWeather==PBWeather::HEAVYRAIN))
  2154. if i.status>0
  2155. PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
  2156. s=i.status
  2157. i.pbCureStatus(false)
  2158. case s
  2159. when PBStatuses::SLEEP
  2160. pbDisplay(_INTL("{1}'s {2} cured its sleep problem!",i.pbThis,PBAbilities.getName(i.ability)))
  2161. when PBStatuses::POISON
  2162. pbDisplay(_INTL("{1}'s {2} cured its poison problem!",i.pbThis,PBAbilities.getName(i.ability)))
  2163. when PBStatuses::BURN
  2164. pbDisplay(_INTL("{1}'s {2} healed its burn!",i.pbThis,PBAbilities.getName(i.ability)))
  2165. when PBStatuses::PARALYSIS
  2166. pbDisplay(_INTL("{1}'s {2} cured its paralysis!",i.pbThis,PBAbilities.getName(i.ability)))
  2167. when PBStatuses::FROZEN
  2168. pbDisplay(_INTL("{1}'s {2} thawed it out!",i.pbThis,PBAbilities.getName(i.ability)))
  2169. end
  2170. end
  2171. end
  2172. # Healer
  2173. if i.hasWorkingAbility(:HEALER) && pbRandom(10)<3
  2174. partner=i.pbPartner
  2175. if partner && partner.status>0
  2176. PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
  2177. s=partner.status
  2178. partner.pbCureStatus(false)
  2179. case s
  2180. when PBStatuses::SLEEP
  2181. pbDisplay(_INTL("{1}'s {2} cured its partner's sleep problem!",i.pbThis,PBAbilities.getName(i.ability)))
  2182. when PBStatuses::POISON
  2183. pbDisplay(_INTL("{1}'s {2} cured its partner's poison problem!",i.pbThis,PBAbilities.getName(i.ability)))
  2184. when PBStatuses::BURN
  2185. pbDisplay(_INTL("{1}'s {2} healed its partner's burn!",i.pbThis,PBAbilities.getName(i.ability)))
  2186. when PBStatuses::PARALYSIS
  2187. pbDisplay(_INTL("{1}'s {2} cured its partner's paralysis!",i.pbThis,PBAbilities.getName(i.ability)))
  2188. when PBStatuses::FROZEN
  2189. pbDisplay(_INTL("{1}'s {2} thawed its partner out!",i.pbThis,PBAbilities.getName(i.ability)))
  2190. end
  2191. end
  2192. end
  2193. end
  2194. for i in priority
  2195. next if i.fainted?
  2196. # Grassy Terrain (healing)
  2197. if @field.effects[PBEffects::GrassyTerrain]>0 && !i.isAirborne?
  2198. if i.effects[PBEffects::HealBlock]==0
  2199. hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
  2200. pbDisplay(_INTL("{1}'s HP was restored.",i.pbThis)) if hpgain>0
  2201. end
  2202. end
  2203. # Held berries/Leftovers/Black Sludge
  2204. i.pbBerryCureCheck(true)
  2205. if i.fainted?
  2206. return if !i.pbFaint
  2207. end
  2208. end
  2209. # Aqua Ring
  2210. for i in priority
  2211. next if i.fainted?
  2212. if i.effects[PBEffects::AquaRing]
  2213. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Aqua Ring")
  2214. hpgain=(i.totalhp/16).floor
  2215. hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT)
  2216. hpgain=i.pbRecoverHP(hpgain,true)
  2217. pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",i.pbThis)) if hpgain>0
  2218. end
  2219. end
  2220. # Ingrain
  2221. for i in priority
  2222. next if i.fainted?
  2223. if i.effects[PBEffects::Ingrain]
  2224. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Ingrain")
  2225. hpgain=(i.totalhp/16).floor
  2226. hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT)
  2227. hpgain=i.pbRecoverHP(hpgain,true)
  2228. pbDisplay(_INTL("{1} absorbed nutrients with its roots!",i.pbThis)) if hpgain>0
  2229. end
  2230. end
  2231. # Leech Seed
  2232. for i in priority
  2233. next if i.fainted?
  2234. if i.effects[PBEffects::LeechSeed]>=0 && !i.hasWorkingAbility(:MAGICGUARD)
  2235. recipient=@battlers[i.effects[PBEffects::LeechSeed]]
  2236. if recipient && !recipient.fainted?
  2237. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Leech Seed")
  2238. pbCommonAnimation("LeechSeed",recipient,i)
  2239. hploss=i.pbReduceHP((i.totalhp/8).floor,true)
  2240. if i.hasWorkingAbility(:LIQUIDOOZE)
  2241. recipient.pbReduceHP(hploss,true)
  2242. pbDisplay(_INTL("{1} sucked up the liquid ooze!",recipient.pbThis))
  2243. else
  2244. if recipient.effects[PBEffects::HealBlock]==0
  2245. hploss=(hploss*1.3).floor if recipient.hasWorkingItem(:BIGROOT)
  2246. recipient.pbRecoverHP(hploss,true)
  2247. end
  2248. pbDisplay(_INTL("{1}'s health was sapped by Leech Seed!",i.pbThis))
  2249. end
  2250. if i.fainted?
  2251. return if !i.pbFaint
  2252. end
  2253. if recipient.fainted?
  2254. return if !recipient.pbFaint
  2255. end
  2256. end
  2257. end
  2258. end
  2259. for i in priority
  2260. next if i.fainted?
  2261. # Poison/Bad poison
  2262. if i.status==PBStatuses::POISON
  2263. if i.statusCount>0
  2264. i.effects[PBEffects::Toxic]+=1
  2265. i.effects[PBEffects::Toxic]=[15,i.effects[PBEffects::Toxic]].min
  2266. end
  2267. if i.hasWorkingAbility(:POISONHEAL)
  2268. pbCommonAnimation("Poison",i,nil)
  2269. if i.effects[PBEffects::HealBlock]==0 && i.hp<i.totalhp
  2270. PBDebug.log("[Ability triggered] #{i.pbThis}'s Poison Heal")
  2271. i.pbRecoverHP((i.totalhp/8).floor,true)
  2272. pbDisplay(_INTL("{1} is healed by poison!",i.pbThis))
  2273. end
  2274. else
  2275. if !i.hasWorkingAbility(:MAGICGUARD)
  2276. PBDebug.log("[Status damage] #{i.pbThis} took damage from poison/toxic")
  2277. if i.statusCount==0
  2278. i.pbReduceHP((i.totalhp/8).floor)
  2279. else
  2280. i.pbReduceHP(((i.totalhp*i.effects[PBEffects::Toxic])/16).floor)
  2281. end
  2282. i.pbContinueStatus
  2283. end
  2284. end
  2285. end
  2286. # Burn
  2287. if i.status==PBStatuses::BURN
  2288. if !i.hasWorkingAbility(:MAGICGUARD)
  2289. PBDebug.log("[Status damage] #{i.pbThis} took damage from burn")
  2290. if i.hasWorkingAbility(:HEATPROOF)
  2291. PBDebug.log("[Ability triggered] #{i.pbThis}'s Heatproof")
  2292. i.pbReduceHP((i.totalhp/16).floor)
  2293. else
  2294. i.pbReduceHP((i.totalhp/8).floor)
  2295. end
  2296. end
  2297. i.pbContinueStatus
  2298. end
  2299. # Nightmare
  2300. if i.effects[PBEffects::Nightmare]
  2301. if i.status==PBStatuses::SLEEP
  2302. if !i.hasWorkingAbility(:MAGICGUARD)
  2303. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s nightmare")
  2304. i.pbReduceHP((i.totalhp/4).floor,true)
  2305. pbDisplay(_INTL("{1} is locked in a nightmare!",i.pbThis))
  2306. end
  2307. else
  2308. i.effects[PBEffects::Nightmare]=false
  2309. end
  2310. end
  2311. if i.fainted?
  2312. return if !i.pbFaint
  2313. next
  2314. end
  2315. end
  2316. # Curse
  2317. for i in priority
  2318. next if i.fainted?
  2319. if i.effects[PBEffects::Curse] && !i.hasWorkingAbility(:MAGICGUARD)
  2320. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s curse")
  2321. i.pbReduceHP((i.totalhp/4).floor,true)
  2322. pbDisplay(_INTL("{1} is afflicted by the curse!",i.pbThis))
  2323. end
  2324. if i.fainted?
  2325. return if !i.pbFaint
  2326. next
  2327. end
  2328. end
  2329. # Multi-turn attacks (Bind/Clamp/Fire Spin/Magma Storm/Sand Tomb/Whirlpool/Wrap)
  2330. for i in priority
  2331. next if i.fainted?
  2332. if i.effects[PBEffects::MultiTurn]>0
  2333. i.effects[PBEffects::MultiTurn]-=1
  2334. movename=PBMoves.getName(i.effects[PBEffects::MultiTurnAttack])
  2335. if i.effects[PBEffects::MultiTurn]==0
  2336. PBDebug.log("[End of effect] Trapping move #{movename} affecting #{i.pbThis} ended")
  2337. pbDisplay(_INTL("{1} was freed from {2}!",i.pbThis,movename))
  2338. else
  2339. if isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:BIND)
  2340. pbCommonAnimation("Bind",i,nil)
  2341. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:CLAMP)
  2342. pbCommonAnimation("Clamp",i,nil)
  2343. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:FIRESPIN)
  2344. pbCommonAnimation("FireSpin",i,nil)
  2345. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:MAGMASTORM)
  2346. pbCommonAnimation("MagmaStorm",i,nil)
  2347. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:SANDTOMB)
  2348. pbCommonAnimation("SandTomb",i,nil)
  2349. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:WRAP)
  2350. pbCommonAnimation("Wrap",i,nil)
  2351. elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:INFESTATION)
  2352. pbCommonAnimation("Infestation",i,nil)
  2353. else
  2354. pbCommonAnimation("Wrap",i,nil)
  2355. end
  2356. if !i.hasWorkingAbility(:MAGICGUARD)
  2357. PBDebug.log("[Lingering effect triggered] #{i.pbThis} took damage from trapping move #{movename}")
  2358. @scene.pbDamageAnimation(i,0)
  2359. amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/8).floor : (i.totalhp/16).floor
  2360. if @battlers[i.effects[PBEffects::MultiTurnUser]].hasWorkingItem(:BINDINGBAND)
  2361. amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/6).floor : (i.totalhp/8).floor
  2362. end
  2363. i.pbReduceHP(amt)
  2364. pbDisplay(_INTL("{1} is hurt by {2}!",i.pbThis,movename))
  2365. end
  2366. end
  2367. end
  2368. if i.fainted?
  2369. return if !i.pbFaint
  2370. end
  2371. end
  2372. # Taunt
  2373. for i in priority
  2374. next if i.fainted?
  2375. if i.effects[PBEffects::Taunt]>0
  2376. i.effects[PBEffects::Taunt]-=1
  2377. if i.effects[PBEffects::Taunt]==0
  2378. pbDisplay(_INTL("{1}'s taunt wore off!",i.pbThis))
  2379. PBDebug.log("[End of effect] #{i.pbThis} is no longer taunted")
  2380. end
  2381. end
  2382. end
  2383. # Encore
  2384. for i in priority
  2385. next if i.fainted?
  2386. if i.effects[PBEffects::Encore]>0
  2387. if i.moves[i.effects[PBEffects::EncoreIndex]].id!=i.effects[PBEffects::EncoreMove]
  2388. i.effects[PBEffects::Encore]=0
  2389. i.effects[PBEffects::EncoreIndex]=0
  2390. i.effects[PBEffects::EncoreMove]=0
  2391. PBDebug.log("[End of effect] #{i.pbThis} is no longer encored (encored move was lost)")
  2392. else
  2393. i.effects[PBEffects::Encore]-=1
  2394. if i.effects[PBEffects::Encore]==0 || i.moves[i.effects[PBEffects::EncoreIndex]].pp==0
  2395. i.effects[PBEffects::Encore]=0
  2396. pbDisplay(_INTL("{1}'s encore ended!",i.pbThis))
  2397. PBDebug.log("[End of effect] #{i.pbThis} is no longer encored")
  2398. end
  2399. end
  2400. end
  2401. end
  2402. # Disable/Cursed Body
  2403. for i in priority
  2404. next if i.fainted?
  2405. if i.effects[PBEffects::Disable]>0
  2406. i.effects[PBEffects::Disable]-=1
  2407. if i.effects[PBEffects::Disable]==0
  2408. i.effects[PBEffects::DisableMove]=0
  2409. pbDisplay(_INTL("{1} is no longer disabled!",i.pbThis))
  2410. PBDebug.log("[End of effect] #{i.pbThis} is no longer disabled")
  2411. end
  2412. end
  2413. end
  2414. # Magnet Rise
  2415. for i in priority
  2416. next if i.fainted?
  2417. if i.effects[PBEffects::MagnetRise]>0
  2418. i.effects[PBEffects::MagnetRise]-=1
  2419. if i.effects[PBEffects::MagnetRise]==0
  2420. pbDisplay(_INTL("{1} stopped levitating.",i.pbThis))
  2421. PBDebug.log("[End of effect] #{i.pbThis} is no longer levitating by Magnet Rise")
  2422. end
  2423. end
  2424. end
  2425. # Telekinesis
  2426. for i in priority
  2427. next if i.fainted?
  2428. if i.effects[PBEffects::Telekinesis]>0
  2429. i.effects[PBEffects::Telekinesis]-=1
  2430. if i.effects[PBEffects::Telekinesis]==0
  2431. pbDisplay(_INTL("{1} stopped levitating.",i.pbThis))
  2432. PBDebug.log("[End of effect] #{i.pbThis} is no longer levitating by Telekinesis")
  2433. end
  2434. end
  2435. end
  2436. # Heal Block
  2437. for i in priority
  2438. next if i.fainted?
  2439. if i.effects[PBEffects::HealBlock]>0
  2440. i.effects[PBEffects::HealBlock]-=1
  2441. if i.effects[PBEffects::HealBlock]==0
  2442. pbDisplay(_INTL("{1}'s Heal Block wore off!",i.pbThis))
  2443. PBDebug.log("[End of effect] #{i.pbThis} is no longer Heal Blocked")
  2444. end
  2445. end
  2446. end
  2447. # Embargo
  2448. for i in priority
  2449. next if i.fainted?
  2450. if i.effects[PBEffects::Embargo]>0
  2451. i.effects[PBEffects::Embargo]-=1
  2452. if i.effects[PBEffects::Embargo]==0
  2453. pbDisplay(_INTL("{1} can use items again!",i.pbThis(true)))
  2454. PBDebug.log("[End of effect] #{i.pbThis} is no longer affected by an embargo")
  2455. end
  2456. end
  2457. end
  2458. # Yawn
  2459. for i in priority
  2460. next if i.fainted?
  2461. if i.effects[PBEffects::Yawn]>0
  2462. i.effects[PBEffects::Yawn]-=1
  2463. if i.effects[PBEffects::Yawn]==0 && i.pbCanSleepYawn?
  2464. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Yawn")
  2465. i.pbSleep
  2466. i.pbBerryCureCheck
  2467. end
  2468. end
  2469. end
  2470. # Perish Song
  2471. perishSongUsers=[]
  2472. for i in priority
  2473. next if i.fainted?
  2474. if i.effects[PBEffects::PerishSong]>0
  2475. i.effects[PBEffects::PerishSong]-=1
  2476. pbDisplay(_INTL("{1}'s perish count fell to {2}!",i.pbThis,i.effects[PBEffects::PerishSong]))
  2477. PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Perish Song count dropped to #{i.effects[PBEffects::PerishSong]}")
  2478. if i.effects[PBEffects::PerishSong]==0
  2479. perishSongUsers.push(i.effects[PBEffects::PerishSongUser])
  2480. i.pbReduceHP(i.hp,true)
  2481. end
  2482. end
  2483. if i.fainted?
  2484. return if !i.pbFaint
  2485. end
  2486. end
  2487. if perishSongUsers.length>0
  2488. # If all remaining Pokemon fainted by a Perish Song triggered by a single side
  2489. if (perishSongUsers.find_all{|item| pbIsOpposing?(item) }.length==perishSongUsers.length) ||
  2490. (perishSongUsers.find_all{|item| !pbIsOpposing?(item) }.length==perishSongUsers.length)
  2491. pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
  2492. end
  2493. end
  2494. if @decision>0
  2495. pbGainEXP
  2496. return
  2497. end
  2498. # Reflect
  2499. for i in 0...2
  2500. if sides[i].effects[PBEffects::Reflect]>0
  2501. sides[i].effects[PBEffects::Reflect]-=1
  2502. if sides[i].effects[PBEffects::Reflect]==0
  2503. pbDisplay(_INTL("Your team's Reflect faded!")) if i==0
  2504. pbDisplay(_INTL("The opposing team's Reflect faded!")) if i==1
  2505. PBDebug.log("[End of effect] Reflect ended on the player's side") if i==0
  2506. PBDebug.log("[End of effect] Reflect ended on the opponent's side") if i==1
  2507. end
  2508. end
  2509. end
  2510. # Light Screen
  2511. for i in 0...2
  2512. if sides[i].effects[PBEffects::LightScreen]>0
  2513. sides[i].effects[PBEffects::LightScreen]-=1
  2514. if sides[i].effects[PBEffects::LightScreen]==0
  2515. pbDisplay(_INTL("Your team's Light Screen faded!")) if i==0
  2516. pbDisplay(_INTL("The opposing team's Light Screen faded!")) if i==1
  2517. PBDebug.log("[End of effect] Light Screen ended on the player's side") if i==0
  2518. PBDebug.log("[End of effect] Light Screen ended on the opponent's side") if i==1
  2519. end
  2520. end
  2521. end
  2522. # Safeguard
  2523. for i in 0...2
  2524. if sides[i].effects[PBEffects::Safeguard]>0
  2525. sides[i].effects[PBEffects::Safeguard]-=1
  2526. if sides[i].effects[PBEffects::Safeguard]==0
  2527. pbDisplay(_INTL("Your team is no longer protected by Safeguard!")) if i==0
  2528. pbDisplay(_INTL("The opposing team is no longer protected by Safeguard!")) if i==1
  2529. PBDebug.log("[End of effect] Safeguard ended on the player's side") if i==0
  2530. PBDebug.log("[End of effect] Safeguard ended on the opponent's side") if i==1
  2531. end
  2532. end
  2533. end
  2534. # Mist
  2535. for i in 0...2
  2536. if sides[i].effects[PBEffects::Mist]>0
  2537. sides[i].effects[PBEffects::Mist]-=1
  2538. if sides[i].effects[PBEffects::Mist]==0
  2539. pbDisplay(_INTL("Your team's Mist faded!")) if i==0
  2540. pbDisplay(_INTL("The opposing team's Mist faded!")) if i==1
  2541. PBDebug.log("[End of effect] Mist ended on the player's side") if i==0
  2542. PBDebug.log("[End of effect] Mist ended on the opponent's side") if i==1
  2543. end
  2544. end
  2545. end
  2546. # Tailwind
  2547. for i in 0...2
  2548. if sides[i].effects[PBEffects::Tailwind]>0
  2549. sides[i].effects[PBEffects::Tailwind]-=1
  2550. if sides[i].effects[PBEffects::Tailwind]==0
  2551. pbDisplay(_INTL("Your team's Tailwind petered out!")) if i==0
  2552. pbDisplay(_INTL("The opposing team's Tailwind petered out!")) if i==1
  2553. PBDebug.log("[End of effect] Tailwind ended on the player's side") if i==0
  2554. PBDebug.log("[End of effect] Tailwind ended on the opponent's side") if i==1
  2555. end
  2556. end
  2557. end
  2558. # Lucky Chant
  2559. for i in 0...2
  2560. if sides[i].effects[PBEffects::LuckyChant]>0
  2561. sides[i].effects[PBEffects::LuckyChant]-=1
  2562. if sides[i].effects[PBEffects::LuckyChant]==0
  2563. pbDisplay(_INTL("Your team's Lucky Chant faded!")) if i==0
  2564. pbDisplay(_INTL("The opposing team's Lucky Chant faded!")) if i==1
  2565. PBDebug.log("[End of effect] Lucky Chant ended on the player's side") if i==0
  2566. PBDebug.log("[End of effect] Lucky Chant ended on the opponent's side") if i==1
  2567. end
  2568. end
  2569. end
  2570. # End of Pledge move combinations
  2571. for i in 0...2
  2572. if sides[i].effects[PBEffects::Swamp]>0
  2573. sides[i].effects[PBEffects::Swamp]-=1
  2574. if sides[i].effects[PBEffects::Swamp]==0
  2575. pbDisplay(_INTL("The swamp around your team disappeared!")) if i==0
  2576. pbDisplay(_INTL("The swamp around the opposing team disappeared!")) if i==1
  2577. PBDebug.log("[End of effect] Grass Pledge's swamp ended on the player's side") if i==0
  2578. PBDebug.log("[End of effect] Grass Pledge's swamp ended on the opponent's side") if i==1
  2579. end
  2580. end
  2581. if sides[i].effects[PBEffects::SeaOfFire]>0
  2582. sides[i].effects[PBEffects::SeaOfFire]-=1
  2583. if sides[i].effects[PBEffects::SeaOfFire]==0
  2584. pbDisplay(_INTL("The sea of fire around your team disappeared!")) if i==0
  2585. pbDisplay(_INTL("The sea of fire around the opposing team disappeared!")) if i==1
  2586. PBDebug.log("[End of effect] Fire Pledge's sea of fire ended on the player's side") if i==0
  2587. PBDebug.log("[End of effect] Fire Pledge's sea of fire ended on the opponent's side") if i==1
  2588. end
  2589. end
  2590. if sides[i].effects[PBEffects::Rainbow]>0
  2591. sides[i].effects[PBEffects::Rainbow]-=1
  2592. if sides[i].effects[PBEffects::Rainbow]==0
  2593. pbDisplay(_INTL("The rainbow around your team disappeared!")) if i==0
  2594. pbDisplay(_INTL("The rainbow around the opposing team disappeared!")) if i==1
  2595. PBDebug.log("[End of effect] Water Pledge's rainbow ended on the player's side") if i==0
  2596. PBDebug.log("[End of effect] Water Pledge's rainbow ended on the opponent's side") if i==1
  2597. end
  2598. end
  2599. end
  2600. # Gravity
  2601. if @field.effects[PBEffects::Gravity]>0
  2602. @field.effects[PBEffects::Gravity]-=1
  2603. if @field.effects[PBEffects::Gravity]==0
  2604. pbDisplay(_INTL("Gravity returned to normal."))
  2605. PBDebug.log("[End of effect] Strong gravity ended")
  2606. end
  2607. end
  2608. # Trick Room
  2609. if @field.effects[PBEffects::TrickRoom]>0
  2610. @field.effects[PBEffects::TrickRoom]-=1
  2611. if @field.effects[PBEffects::TrickRoom]==0
  2612. pbDisplay(_INTL("The twisted dimensions returned to normal."))
  2613. PBDebug.log("[End of effect] Trick Room ended")
  2614. end
  2615. end
  2616. # Wonder Room
  2617. if @field.effects[PBEffects::WonderRoom]>0
  2618. @field.effects[PBEffects::WonderRoom]-=1
  2619. if @field.effects[PBEffects::WonderRoom]==0
  2620. pbDisplay(_INTL("Wonder Room wore off, and the Defense and Sp. Def stats returned to normal!"))
  2621. PBDebug.log("[End of effect] Wonder Room ended")
  2622. end
  2623. end
  2624. # Magic Room
  2625. if @field.effects[PBEffects::MagicRoom]>0
  2626. @field.effects[PBEffects::MagicRoom]-=1
  2627. if @field.effects[PBEffects::MagicRoom]==0
  2628. pbDisplay(_INTL("The area returned to normal."))
  2629. PBDebug.log("[End of effect] Magic Room ended")
  2630. end
  2631. end
  2632. # Mud Sport
  2633. if @field.effects[PBEffects::MudSportField]>0
  2634. @field.effects[PBEffects::MudSportField]-=1
  2635. if @field.effects[PBEffects::MudSportField]==0
  2636. pbDisplay(_INTL("The effects of Mud Sport have faded."))
  2637. PBDebug.log("[End of effect] Mud Sport ended")
  2638. end
  2639. end
  2640. # Water Sport
  2641. if @field.effects[PBEffects::WaterSportField]>0
  2642. @field.effects[PBEffects::WaterSportField]-=1
  2643. if @field.effects[PBEffects::WaterSportField]==0
  2644. pbDisplay(_INTL("The effects of Water Sport have faded."))
  2645. PBDebug.log("[End of effect] Water Sport ended")
  2646. end
  2647. end
  2648. # Electric Terrain
  2649. if @field.effects[PBEffects::ElectricTerrain]>0
  2650. @field.effects[PBEffects::ElectricTerrain]-=1
  2651. if @field.effects[PBEffects::ElectricTerrain]==0
  2652. pbDisplay(_INTL("The electric current disappeared from the battlefield."))
  2653. PBDebug.log("[End of effect] Electric Terrain ended")
  2654. end
  2655. end
  2656. # Grassy Terrain (counting down)
  2657. if @field.effects[PBEffects::GrassyTerrain]>0
  2658. @field.effects[PBEffects::GrassyTerrain]-=1
  2659. if @field.effects[PBEffects::GrassyTerrain]==0
  2660. pbDisplay(_INTL("The grass disappeared from the battlefield."))
  2661. PBDebug.log("[End of effect] Grassy Terrain ended")
  2662. end
  2663. end
  2664. # Misty Terrain
  2665. if @field.effects[PBEffects::MistyTerrain]>0
  2666. @field.effects[PBEffects::MistyTerrain]-=1
  2667. if @field.effects[PBEffects::MistyTerrain]==0
  2668. pbDisplay(_INTL("The mist disappeared from the battlefield."))
  2669. PBDebug.log("[End of effect] Misty Terrain ended")
  2670. end
  2671. end
  2672. # Uproar
  2673. for i in priority
  2674. next if i.fainted?
  2675. if i.effects[PBEffects::Uproar]>0
  2676. for j in priority
  2677. if !j.fainted? && j.status==PBStatuses::SLEEP && !j.hasWorkingAbility(:SOUNDPROOF)
  2678. PBDebug.log("[Lingering effect triggered] Uproar woke up #{j.pbThis(true)}")
  2679. j.pbCureStatus(false)
  2680. pbDisplay(_INTL("{1} woke up in the uproar!",j.pbThis))
  2681. end
  2682. end
  2683. i.effects[PBEffects::Uproar]-=1
  2684. if i.effects[PBEffects::Uproar]==0
  2685. pbDisplay(_INTL("{1} calmed down.",i.pbThis))
  2686. PBDebug.log("[End of effect] #{i.pbThis} is no longer uproaring")
  2687. else
  2688. pbDisplay(_INTL("{1} is making an uproar!",i.pbThis))
  2689. end
  2690. end
  2691. end
  2692. for i in priority
  2693. next if i.fainted?
  2694. # Speed Boost
  2695. # A Pokémon's turncount is 0 if it became active after the beginning of a round
  2696. if i.turncount>0 && i.hasWorkingAbility(:SPEEDBOOST)
  2697. if i.pbIncreaseStatWithCause(PBStats::SPEED,1,i,PBAbilities.getName(i.ability))
  2698. PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
  2699. end
  2700. end
  2701. # Bad Dreams
  2702. if i.status==PBStatuses::SLEEP && !i.hasWorkingAbility(:MAGICGUARD)
  2703. if i.pbOpposing1.hasWorkingAbility(:BADDREAMS) ||
  2704. i.pbOpposing2.hasWorkingAbility(:BADDREAMS)
  2705. PBDebug.log("[Ability triggered] #{i.pbThis}'s opponent's Bad Dreams")
  2706. hploss=i.pbReduceHP((i.totalhp/8).floor,true)
  2707. pbDisplay(_INTL("{1} is having a bad dream!",i.pbThis)) if hploss>0
  2708. end
  2709. end
  2710. if i.fainted?
  2711. return if !i.pbFaint
  2712. next
  2713. end
  2714. # Pickup
  2715. if i.hasWorkingAbility(:PICKUP) && i.item<=0
  2716. item=0; index=-1; use=0
  2717. for j in 0...4
  2718. next if j==i.index
  2719. if @battlers[j].effects[PBEffects::PickupUse]>use
  2720. item=@battlers[j].effects[PBEffects::PickupItem]
  2721. index=j
  2722. use=@battlers[j].effects[PBEffects::PickupUse]
  2723. end
  2724. end
  2725. if item>0
  2726. i.item=item
  2727. @battlers[index].effects[PBEffects::PickupItem]=0
  2728. @battlers[index].effects[PBEffects::PickupUse]=0
  2729. @battlers[index].pokemon.itemRecycle=0 if @battlers[index].pokemon.itemRecycle==item
  2730. if !@opponent && # In a wild battle
  2731. i.pokemon.itemInitial==0 &&
  2732. @battlers[index].pokemon.itemInitial==item
  2733. i.pokemon.itemInitial=item
  2734. @battlers[index].pokemon.itemInitial=0
  2735. end
  2736. pbDisplay(_INTL("{1} found one {2}!",i.pbThis,PBItems.getName(item)))
  2737. i.pbBerryCureCheck(true)
  2738. end
  2739. end
  2740. # Harvest
  2741. if i.hasWorkingAbility(:HARVEST) && i.item<=0 && i.pokemon.itemRecycle>0
  2742. if pbIsBerry?(i.pokemon.itemRecycle) &&
  2743. (pbWeather==PBWeather::SUNNYDAY ||
  2744. pbWeather==PBWeather::HARSHSUN || pbRandom(10)<5)
  2745. i.item=i.pokemon.itemRecycle
  2746. i.pokemon.itemRecycle=0
  2747. i.pokemon.itemInitial=i.item if i.pokemon.itemInitial==0
  2748. pbDisplay(_INTL("{1} harvested one {2}!",i.pbThis,PBItems.getName(i.item)))
  2749. i.pbBerryCureCheck(true)
  2750. end
  2751. end
  2752. # Moody
  2753. if i.hasWorkingAbility(:MOODY)
  2754. randomup=[]; randomdown=[]
  2755. for j in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,PBStats::SPATK,
  2756. PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
  2757. randomup.push(j) if i.pbCanIncreaseStatStage?(j,i)
  2758. randomdown.push(j) if i.pbCanReduceStatStage?(j,i)
  2759. end
  2760. if randomup.length>0
  2761. PBDebug.log("[Ability triggered] #{i.pbThis}'s Moody (raise stat)")
  2762. r=pbRandom(randomup.length)
  2763. i.pbIncreaseStatWithCause(randomup[r],2,i,PBAbilities.getName(i.ability))
  2764. for j in 0...randomdown.length
  2765. if randomdown[j]==randomup[r]
  2766. randomdown[j]=nil; randomdown.compact!
  2767. break
  2768. end
  2769. end
  2770. end
  2771. if randomdown.length>0
  2772. PBDebug.log("[Ability triggered] #{i.pbThis}'s Moody (lower stat)")
  2773. r=pbRandom(randomdown.length)
  2774. i.pbReduceStatWithCause(randomdown[r],1,i,PBAbilities.getName(i.ability))
  2775. end
  2776. end
  2777. end
  2778. for i in priority
  2779. next if i.fainted?
  2780. # Toxic Orb
  2781. if i.hasWorkingItem(:TOXICORB) && i.status==0 && i.pbCanPoison?(nil,false)
  2782. PBDebug.log("[Item triggered] #{i.pbThis}'s Toxic Orb")
  2783. i.pbPoison(nil,_INTL("{1} was badly poisoned by its {2}!",i.pbThis,
  2784. PBItems.getName(i.item)),true)
  2785. end
  2786. # Flame Orb
  2787. if i.hasWorkingItem(:FLAMEORB) && i.status==0 && i.pbCanBurn?(nil,false)
  2788. PBDebug.log("[Item triggered] #{i.pbThis}'s Flame Orb")
  2789. i.pbBurn(nil,_INTL("{1} was burned by its {2}!",i.pbThis,PBItems.getName(i.item)))
  2790. end
  2791. # Sticky Barb
  2792. if i.hasWorkingItem(:STICKYBARB) && !i.hasWorkingAbility(:MAGICGUARD)
  2793. PBDebug.log("[Item triggered] #{i.pbThis}'s Sticky Barb")
  2794. @scene.pbDamageAnimation(i,0)
  2795. i.pbReduceHP((i.totalhp/8).floor)
  2796. pbDisplay(_INTL("{1} is hurt by its {2}!",i.pbThis,PBItems.getName(i.item)))
  2797. end
  2798. if i.fainted?
  2799. return if !i.pbFaint
  2800. end
  2801. end
  2802. # Slow Start's end message
  2803. if i.hasWorkingAbility(:SLOWSTART) && i.turncount==6
  2804. pbDisplay(_INTL("{1} finally got its act together!",i.pbThis))
  2805. end
  2806. # Form checks
  2807. for i in 0...4
  2808. next if @battlers[i].fainted?
  2809. @battlers[i].pbCheckForm
  2810. end
  2811. pbGainEXP
  2812. pbSwitch
  2813. return if @decision>0
  2814. for i in priority
  2815. next if i.fainted?
  2816. i.pbAbilitiesOnSwitchIn(false)
  2817. end
  2818. # Healing Wish/Lunar Dance - should go here
  2819. # Spikes/Toxic Spikes/Stealth Rock - should go here (in order of their 1st use)
  2820. for i in 0...4
  2821. if @battlers[i].turncount>0 && @battlers[i].hasWorkingAbility(:TRUANT)
  2822. @battlers[i].effects[PBEffects::Truant]=!@battlers[i].effects[PBEffects::Truant]
  2823. end
  2824. if @battlers[i].effects[PBEffects::LockOn]>0 # Also Mind Reader
  2825. @battlers[i].effects[PBEffects::LockOn]-=1
  2826. @battlers[i].effects[PBEffects::LockOnPos]=-1 if @battlers[i].effects[PBEffects::LockOn]==0
  2827. end
  2828. @battlers[i].effects[PBEffects::Flinch]=false
  2829. @battlers[i].effects[PBEffects::FollowMe]=0
  2830. @battlers[i].effects[PBEffects::HelpingHand]=false
  2831. @battlers[i].effects[PBEffects::MagicCoat]=false
  2832. @battlers[i].effects[PBEffects::Snatch]=false
  2833. @battlers[i].effects[PBEffects::Charge]-=1 if @battlers[i].effects[PBEffects::Charge]>0
  2834. @battlers[i].lastHPLost=0
  2835. @battlers[i].tookDamage=false
  2836. @battlers[i].lastAttacker.clear
  2837. @battlers[i].effects[PBEffects::Counter]=-1
  2838. @battlers[i].effects[PBEffects::CounterTarget]=-1
  2839. @battlers[i].effects[PBEffects::MirrorCoat]=-1
  2840. @battlers[i].effects[PBEffects::MirrorCoatTarget]=-1
  2841. if SPOWER
  2842. if @battlers[i].effects[PBEffects::Distort] != 0
  2843. @battlers[i].type1=PBTypes::PSYCHIC
  2844. else
  2845. @battlers[i].effects[PBEffects::Distort] -= 1
  2846. end
  2847. end
  2848. if @battlers[i].effects[PBEffects::Dynamax] != 0
  2849. @battlers[i].pbUndynamaxForFaint
  2850. else
  2851. @battlers[i].effects[PBEffects::Dynamax] -= 1
  2852. end
  2853. end
  2854. for i in 0...2
  2855. if !@sides[i].effects[PBEffects::EchoedVoiceUsed]
  2856. @sides[i].effects[PBEffects::EchoedVoiceCounter]=0
  2857. end
  2858. @sides[i].effects[PBEffects::EchoedVoiceUsed]=false
  2859. @sides[i].effects[PBEffects::MatBlock]= false
  2860. @sides[i].effects[PBEffects::QuickGuard]=false
  2861. @sides[i].effects[PBEffects::WideGuard]=false
  2862. @sides[i].effects[PBEffects::CraftyShield]=false
  2863. @sides[i].effects[PBEffects::Round]=0
  2864. end
  2865. @field.effects[PBEffects::FusionBolt]=false
  2866. @field.effects[PBEffects::FusionFlare]=false
  2867. @field.effects[PBEffects::IonDeluge]=false
  2868. @field.effects[PBEffects::FairyLock]-=1 if @field.effects[PBEffects::FairyLock]>0
  2869. # invalidate stored priority
  2870. @usepriority=false
  2871. end
  2872. end
Add Comment
Please, Sign In to add comment