Guest User

elite_battle

a guest
Jul 24th, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.61 KB | None | 0 0
  1. #===============================================================================
  2. # Elite Battle system
  3. # by Luka S.J.
  4. # ----------------
  5. # Battle Script
  6. # ----------------
  7. # system is based off the original Essentials battle system, made by
  8. # Poccil & Maruno
  9. # No additional features added to AI, mechanics
  10. # or functionality of the battle system.
  11. # This update is purely cosmetic, and includes a B/W like dynamic scene with a
  12. # custom interface.
  13. #
  14. # Enjoy the script, and make sure to give credit!
  15. # (DO NOT ALTER THE NAMES OF THE INDIVIDUAL SCRIPT SECTIONS OR YOU WILL BREAK
  16. # YOUR SYSTEM!)
  17. #-------------------------------------------------------------------------------
  18. # BattleCore processing
  19. # aliasing and new def is called to account for several changes done to the
  20. # way Pokemon are initially sent into battle
  21. #===============================================================================
  22. class PokeBattle_Battle
  23. attr_reader :midspeech
  24. attr_reader :cuedbgm
  25. attr_accessor :midspeech_done
  26. attr_accessor :abilityMessage
  27. attr_accessor :abilityChange
  28. attr_accessor :abilityTrick
  29. attr_accessor :abilityIntimidate
  30.  
  31. def endspeech=(msg)
  32. @midspeech=""
  33. @cuedbgm=nil
  34. @midspeech_done=false
  35. if msg.is_a?(Array)
  36. @endspeech=msg[0]
  37. @midspeech=msg[1]
  38. @cuedbgm=msg[2] if msg.length > 2
  39. else
  40. @endspeech=msg
  41. end
  42. end
  43.  
  44. alias pbStartBattleCore_ebs pbStartBattleCore unless self.method_defined?(:pbStartBattleCore_ebs)
  45. def pbStartBattleCore(canlose)
  46. if !@fullparty1 && @party1.length > MAXPARTYSIZE
  47. raise ArgumentError.new(_INTL("Party 1 has more than {1} Pokémon.",MAXPARTYSIZE))
  48. end
  49. if !@fullparty2 && @party2.length > MAXPARTYSIZE
  50. raise ArgumentError.new(_INTL("Party 2 has more than {1} Pokémon.",MAXPARTYSIZE))
  51. end
  52. $smAnim = false if ($smAnim && @doublebattle) || EBUISTYLE!=2
  53. if !@opponent
  54. #========================
  55. # Initialize wild Pokémon
  56. #========================
  57. if @party2.length==1
  58. if @doublebattle
  59. raise _INTL("Only two wild Pokémon are allowed in double battles")
  60. end
  61. wildpoke=@party2[0]
  62. @battlers[1].pbInitialize(wildpoke,0,false)
  63. @peer.pbOnEnteringBattle(self,wildpoke)
  64. pbSetSeen(wildpoke)
  65. @scene.pbStartBattle(self)
  66. @scene.sendingOut=true
  67. pbDisplayPaused(_INTL("Wild {1} appeared!",wildpoke.name))
  68. @scene.ebSpecialSpecies_end if $specialSpecies
  69. elsif @party2.length==2
  70. if !@doublebattle
  71. raise _INTL("Only one wild Pokémon is allowed in single battles")
  72. end
  73. @battlers[1].pbInitialize(@party2[0],0,false)
  74. @battlers[3].pbInitialize(@party2[1],0,false)
  75. @peer.pbOnEnteringBattle(self,@party2[0])
  76. @peer.pbOnEnteringBattle(self,@party2[1])
  77. pbSetSeen(@party2[0])
  78. pbSetSeen(@party2[1])
  79. @scene.pbStartBattle(self)
  80. pbDisplayPaused(_INTL("Wild {1} and\r\n{2} appeared!",
  81. @party2[0].name,@party2[1].name))
  82. else
  83. raise _INTL("Only one or two wild Pokémon are allowed")
  84. end
  85. elsif @doublebattle
  86. #=======================================
  87. # Initialize opponents in double battles
  88. #=======================================
  89. if @opponent.is_a?(Array)
  90. if @opponent.length==1
  91. @opponent=@opponent[0]
  92. elsif @opponent.length!=2
  93. raise _INTL("Opponents with zero or more than two people are not allowed")
  94. end
  95. end
  96. if @player.is_a?(Array)
  97. if @player.length==1
  98. @player=@player[0]
  99. elsif @player.length!=2
  100. raise _INTL("Player trainers with zero or more than two people are not allowed")
  101. end
  102. end
  103. @scene.pbStartBattle(self)
  104. @scene.sendingOut=true
  105. if @opponent.is_a?(Array)
  106. pbDisplayPaused(_INTL("{1} and {2} want to battle!",@opponent[0].fullname,@opponent[1].fullname))
  107. sendout1=pbFindNextUnfainted(@party2,0,pbSecondPartyBegin(1))
  108. raise _INTL("Opponent 1 has no unfainted Pokémon") if sendout1 < 0
  109. sendout2=pbFindNextUnfainted(@party2,pbSecondPartyBegin(1))
  110. raise _INTL("Opponent 2 has no unfainted Pokémon") if sendout2 < 0
  111. @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
  112. @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
  113. pbDisplayBrief(_INTL("{1} sent\r\nout {2}! {3} sent\r\nout {4}!",@opponent[0].fullname,getBattlerPokemon(@battlers[1]).name,@opponent[1].fullname,getBattlerPokemon(@battlers[3]).name))
  114. pbSendOutInitial(@doublebattle,1,@party2[sendout1],3,@party2[sendout2])
  115. else
  116. pbDisplayPaused(_INTL("{1}\r\nwould like to battle!",@opponent.fullname))
  117. sendout1=pbFindNextUnfainted(@party2,0)
  118. sendout2=pbFindNextUnfainted(@party2,sendout1+1)
  119. if sendout1 < 0 || sendout2 < 0
  120. raise _INTL("Opponent doesn't have two unfainted Pokémon")
  121. end
  122. @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
  123. @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
  124.  
  125. pbDisplayBrief(_INTL("{1} sent\r\nout {2} and {3}!",
  126. @opponent.fullname,getBattlerPokemon(@battlers[1]).name,getBattlerPokemon(@battlers[3]).name))
  127. pbSendOutInitial(@doublebattle,1,@party2[sendout1],3,@party2[sendout2])
  128. end
  129. else
  130. #======================================
  131. # Initialize opponent in single battles
  132. #======================================
  133. sendout=pbFindNextUnfainted(@party2,0)
  134. raise _INTL("Trainer has no unfainted Pokémon") if sendout < 0
  135. if @opponent.is_a?(Array)
  136. raise _INTL("Opponent trainer must be only one person in single battles") if @opponent.length!=1
  137. @opponent=@opponent[0]
  138. end
  139. if @player.is_a?(Array)
  140. raise _INTL("Player trainer must be only one person in single battles") if @player.length!=1
  141. @player=@player[0]
  142. end
  143. trainerpoke=@party2[0]
  144. @battlers[1].pbInitialize(trainerpoke,sendout,false)
  145. @scene.pbStartBattle(self)
  146. @scene.sendingOut=true
  147. pbDisplayPaused(_INTL("{1}\r\nwould like to battle!",@opponent.fullname))
  148. @scene.endSMSequence if $smAnim
  149. pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent.fullname,getBattlerPokemon(@battlers[1]).name))
  150. pbSendOutInitial(@doublebattle,1,trainerpoke)
  151. end
  152. #=====================================
  153. # Initialize players in double battles
  154. #=====================================
  155. if @doublebattle
  156. @scene.sendingOut=true
  157. if @player.is_a?(Array)
  158. sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0))
  159. raise _INTL("Player 1 has no unfainted Pokémon") if sendout1 < 0
  160. sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0))
  161. raise _INTL("Player 2 has no unfainted Pokémon") if sendout2 < 0
  162. @battlers[0].pbInitialize(@party1[sendout1],sendout1,false)
  163. @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
  164. pbDisplayBrief(_INTL("{1} sent\r\nout {2}! Go! {3}!",
  165. @player[1].fullname,getBattlerPokemon(@battlers[2]).name,getBattlerPokemon(@battlers[0]).name))
  166. pbSetSeen(@party1[sendout1])
  167. pbSetSeen(@party1[sendout2])
  168. else
  169. sendout1=pbFindNextUnfainted(@party1,0)
  170. sendout2=pbFindNextUnfainted(@party1,sendout1+1)
  171. if sendout1 < 0 || sendout2 < 0
  172. raise _INTL("Player doesn't have two unfainted Pokémon")
  173. end
  174. @battlers[0].pbInitialize(@party1[sendout1],sendout1,false)
  175. @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
  176. pbDisplayBrief(_INTL("Go! {1} and {2}!",getBattlerPokemon(@battlers[0]).name,getBattlerPokemon(@battlers[2]).name))
  177. end
  178. pbSendOutInitial(@doublebattle,0,@party1[sendout1],2,@party1[sendout2])
  179. else
  180. #====================================
  181. # Initialize player in single battles
  182. #====================================
  183. @scene.sendingOut=true
  184. sendout=pbFindNextUnfainted(@party1,0)
  185. if sendout < 0
  186. raise _INTL("Player has no unfainted Pokémon")
  187. end
  188. playerpoke=@party1[sendout]
  189. @battlers[0].pbInitialize(playerpoke,sendout,false)
  190. pbDisplayBrief(_INTL("Go! {1}!",getBattlerPokemon(@battlers[0]).name))
  191. pbSendOutInitial(@doublebattle,0,playerpoke)
  192. end
  193. #==================
  194. # Initialize battle
  195. #==================
  196. if @weather==PBWeather::SUNNYDAY
  197. pbDisplay(_INTL("The sunlight is strong."))
  198. elsif @weather==PBWeather::RAINDANCE
  199. pbDisplay(_INTL("It is raining."))
  200. elsif @weather==PBWeather::SANDSTORM
  201. pbDisplay(_INTL("A sandstorm is raging."))
  202. elsif @weather==PBWeather::HAIL
  203. pbDisplay(_INTL("Hail is falling."))
  204. elsif PBWeather.const_defined?(:HEAVYRAIN) && @weather==PBWeather::HEAVYRAIN
  205. pbDisplay(_INTL("It is raining heavily."))
  206. elsif PBWeather.const_defined?(:HARSHSUN) && @weather==PBWeather::HARSHSUN
  207. pbDisplay(_INTL("The sunlight is extremely harsh."))
  208. elsif PBWeather.const_defined?(:STRONGWINDS) && @weather==PBWeather::STRONGWINDS
  209. pbDisplay(_INTL("The wind is strong."))
  210. end
  211. pbOnActiveAll # Abilities
  212. @turncount=0
  213. loop do # Now begin the battle loop
  214. PBDebug.log("***Round #{@turncount+1}***") if $INTERNAL
  215. if @debug && @turncount >=100
  216. @decision=pbDecisionOnTime()
  217. PBDebug.log("***[Undecided after 100 rounds]")
  218. pbAbort
  219. break
  220. end
  221. PBDebug.logonerr{
  222. pbCommandPhase
  223. }
  224. break if @decision > 0
  225. PBDebug.logonerr{
  226. pbAttackPhase
  227. }
  228. break if @decision > 0
  229. @scene.clearMessageWindow
  230. PBDebug.logonerr{
  231. pbEndOfRoundPhase
  232. }
  233. break if @decision > 0
  234. @turncount+=1
  235. end
  236. return pbEndOfBattle(canlose)
  237. end
  238.  
  239. def pbSendOutInitial(doublebattle,*args)
  240. index = args[0]
  241. pokemon = args[1]
  242. if doublebattle
  243. index2 = args[2]
  244. pokemon2 = args[3]
  245. end
  246. pbSetSeen(pokemon)
  247. pbSetSeen(pokemon2) if doublebattle
  248. @peer.pbOnEnteringBattle(self,pokemon)
  249. @peer.pbOnEnteringBattle(self,pokemon2) if doublebattle
  250. if pbIsOpposing?(index)
  251. @scene.pbTrainerSendOut(nil,nil)
  252. else
  253. @scene.pbSendOut(nil,nil)
  254. end
  255. @scene.pbResetMoveIndex(index)
  256. @scene.pbResetMoveIndex(index2) if doublebattle
  257. return if !self.respond_to?(:pbPrimalReversion)
  258. pbPrimalReversion(index)
  259. pbPrimalReversion(index2) if doublebattle
  260. end
  261.  
  262. alias pbReplace_ebs pbReplace unless self.method_defined?(:pbReplace_ebs)
  263. def pbReplace(index,newpoke,batonpass=false)
  264. @abilityTrick = nil
  265. @scene.databoxVisible(false,true)
  266. if !@replaced
  267. @battlers[index].pbResetForm
  268. if !@battlers[index].isFainted?
  269. @scene.pbRecall(index)
  270. end
  271. end
  272. pbReplace_ebs(index,newpoke,batonpass)
  273. @replaced=false
  274. end
  275.  
  276. alias pbRecallAndReplace_ebs pbRecallAndReplace unless self.method_defined?(:pbRecallAndReplace_ebs)
  277. def pbRecallAndReplace(*args)
  278. @replaced=true
  279. @scene.sendingOut=true if args[0]%2==0
  280. return pbRecallAndReplace_ebs(*args)
  281. end
  282.  
  283. alias pbRun_ebs pbRun unless self.method_defined?(:pbRun_ebs)
  284. def pbRun(idxPokemon,duringBattle=false)
  285. ret=pbRun_ebs(idxPokemon,duringBattle=false)
  286. pbSEPlay("BW_flee",80) if ret==1 && !self.opponent
  287. return ret
  288. end
  289.  
  290. alias pbCommandPhase_ebs pbCommandPhase unless self.method_defined?(:pbCommandPhase_ebs)
  291. def pbCommandPhase
  292. pbCommandPhase_ebs
  293. @scene.idleTimer=-1
  294. end
  295.  
  296. alias pbEndOfRoundPhase_ebs pbEndOfRoundPhase unless self.method_defined?(:pbEndOfRoundPhase_ebs)
  297. def pbEndOfRoundPhase
  298. ret = pbEndOfRoundPhase_ebs
  299. @scene.clearMessageWindow
  300. @scene.pbTrainerBattleSpeech
  301. return ret
  302. end
  303.  
  304. alias pbAttackPhase_ebs pbAttackPhase unless self.method_defined?(:pbAttackPhase_ebs)
  305. def pbAttackPhase
  306. $skipDatWait = true
  307. ret = pbAttackPhase_ebs
  308. @scene.afterAnim = false
  309. 16.times do
  310. @scene.animateBattleSprites
  311. Graphics.update
  312. end
  313. return ret
  314. end
  315.  
  316. alias pbSwitch_ebs pbSwitch unless self.method_defined?(:pbSwitch_ebs)
  317. def pbSwitch(*args)
  318. show = false
  319. for index in 0...4
  320. next if @battlers[index] && !@battlers[index].isFainted?
  321. next if !pbCanChooseNonActive?(index)
  322. if !pbOwnedByPlayer?(index)
  323. if !pbIsOpposing?(index) || (@opponent && pbIsOpposing?(index))
  324. if !@doublebattle && @battlers[0].hp>0 && @shiftStyle && @opponent && @internalbattle && pbCanChooseNonActive?(0) && pbIsOpposing?(index) && @battlers[0].effects[PBEffects::Outrage]==0
  325. show = true
  326. end
  327. end
  328. end
  329. end
  330. if EBUISTYLE == 2 && self.opponent && show
  331. @scene.commandWindow.drawLineup
  332. 10.times do; @scene.commandWindow.showArrows; @scene.wait(1); end
  333. end
  334. ret = pbSwitch_ebs(*args)
  335. return ret
  336. end
  337.  
  338. def pbDisplay(msg)
  339. tricked=false
  340. if !@abilityTrick.nil?
  341. @scene.pbDisplayEffect(@abilityTrick)
  342. tricked=true
  343. end
  344. @scene.databoxVisible(false) if @abilityMessage.nil? || tricked
  345. if !@abilityMessage.nil? && @abilityTrick.nil?
  346. @scene.pbDisplayEffect(@abilityMessage)
  347. else
  348. @scene.pbDisplayMessage(msg)
  349. end
  350. if !@abilityIntimidate.nil?
  351. @scene.pbDisplayEffect(@abilityIntimidate)
  352. @scene.databoxVisible(false)
  353. @scene.pbDisplayMessage(msg)
  354. end
  355. @scene.clearMessageWindow if !@scene.briefmessage
  356. @scene.databoxVisible(!@scene.windowVisible?)
  357. @abilityTrick = nil
  358. @abilityMessage = nil
  359. @abilityIntimidate = nil
  360. end
  361.  
  362. alias pbThrowPokeBall_ebs pbThrowPokeBall unless self.method_defined?(:pbThrowPokeBall_ebs)
  363. def pbThrowPokeBall(*args)
  364. @scene.briefmessage = true
  365. ret = pbThrowPokeBall_ebs(*args)
  366. @scene.briefmessage = false
  367. return ret
  368. end
  369.  
  370. def pbDisplayPaused(msg)
  371. @scene.databoxVisible(false)
  372. @scene.pbDisplayPausedMessage(msg)
  373. @scene.clearMessageWindow if !@scene.briefmessage
  374. @scene.databoxVisible(!@scene.windowVisible?)
  375. end
  376.  
  377. def pbDisplayBrief(msg)
  378. @scene.databoxVisible(false)
  379. @scene.pbDisplayMessage(msg,true)
  380. @scene.clearMessageWindow if !@scene.briefmessage
  381. @scene.databoxVisible(!@scene.windowVisible?)
  382. end
  383.  
  384. def pbDisplayConfirm(msg)
  385. @scene.databoxVisible(false)
  386. ret = @scene.pbDisplayConfirmMessage(msg)
  387. @scene.clearMessageWindow if !@scene.briefmessage
  388. @scene.databoxVisible(!@scene.windowVisible?)
  389. return ret
  390. end
  391.  
  392. def pbShowCommands(msg,commands,cancancel=true)
  393. @scene.databoxVisible(false)
  394. ret = @scene.pbShowCommands(msg,commands,cancancel)
  395. @scene.clearMessageWindow if !@scene.briefmessage
  396. @scene.databoxVisible(!@scene.windowVisible?)
  397. return ret
  398. end
  399. end
  400. # Different methods used to obtain pokemon data from battlers
  401. # Added for Gen 6 Project compatibility
  402. def getBattlerPokemon(battler)
  403. if battler.is_a?(Array)
  404. bat=PokeBattle_Battler.new(self,battler[1])
  405. bat.pbInitialize(battler[0],battler[1],false)
  406. battler=bat
  407. end
  408. if PBEffects.const_defined?(:Illusion) && battler.respond_to?('effects') && !battler.effects[PBEffects::Illusion].nil?
  409. return battler.effects[PBEffects::Illusion]
  410. else
  411. return battler
  412. end
  413. end
  414.  
  415. def getBattlerMetrics(metrics,battler)
  416. pokemon = getBattlerPokemon(battler)
  417. pokemon = pokemon.pokemon if pokemon.respond_to?(:pokemon)
  418. return metrics[2][pokemon.species]
  419. end
  420.  
  421. def playBattlerCry(battler)
  422. species = battler.species
  423. pokemon = getBattlerPokemon(battler)
  424. pokemon = pokemon.pokemon if pokemon.respond_to?(:pokemon)
  425. pbPlayCry(pokemon ? pokemon : species)
  426. end
  427.  
  428. def shinyBattler?(battler)
  429. pokemon = getBattlerPokemon(battler)
  430. pokemon = pokemon.pokemon if pokemon.respond_to?(:pokemon)
  431. return pokemon.isShiny?
  432. end
  433. #===============================================================================
  434. # Used for the Illusion ability
  435. #===============================================================================
  436. class PokeBattle_Battler
  437. attr_accessor :thisMoveHits
  438.  
  439. def name
  440. if PBEffects.const_defined?(:Illusion) && @effects && !@effects[PBEffects::Illusion].nil?
  441. return @effects[PBEffects::Illusion].name
  442. else
  443. return @name
  444. end
  445. end
  446.  
  447. alias pbThis_ebs pbThis unless self.method_defined?(:pbThis_ebs)
  448. def pbThis(lowercase=false)
  449. if @battle.pbIsOpposing?(@index)
  450. if @battle.opponent
  451. return lowercase ? _INTL("the foe {1}",self.name) : _INTL("The foe {1}",self.name)
  452. else
  453. return lowercase ? _INTL("the wild {1}",self.name) : _INTL("The wild {1}",self.name)
  454. end
  455. elsif @battle.pbOwnedByPlayer?(@index)
  456. return _INTL("{1}",self.name)
  457. else
  458. return lowercase ? _INTL("the ally {1}",self.name) : _INTL("The ally {1}",self.name)
  459. end
  460. end
  461.  
  462. alias pbSuccessCheck_ebs pbSuccessCheck unless self.method_defined?(:pbSuccessCheck_ebs)
  463. def pbSuccessCheck(*args)
  464. index = args[1].index
  465. ret = pbSuccessCheck_ebs(*args)
  466. @battle.scene.revertMoveTransformations(index) if ret==false
  467. return ret
  468. end
  469.  
  470. alias pbProcessMoveAgainstTarget_ebs pbProcessMoveAgainstTarget unless self.method_defined?(:pbProcessMoveAgainstTarget_ebs)
  471. def pbProcessMoveAgainstTarget(*args)
  472. @thisMoveHits = args[3]
  473. return pbProcessMoveAgainstTarget_ebs(*args)
  474. end
  475. end
  476. #===============================================================================
  477. # Ability Message handlers
  478. # used to display abilities in the style of Gen >= 5 games
  479. #===============================================================================
  480. if EFFECTMESSAGES
  481.  
  482. class PokeBattle_Battler
  483. alias pbAbilitiesOnSwitchIn_ebs pbAbilitiesOnSwitchIn unless self.method_defined?(:pbAbilitiesOnSwitchIn_ebs)
  484. def pbAbilitiesOnSwitchIn(*args)
  485. if self.checkForAbilities(:FRISK,:FOREWARN,:BADDREAMS,:MOODY,:HARVEST,:TRACE,:INTIMIDATE)
  486. @battle.abilityTrick = self
  487. else
  488. @battle.abilityMessage = self
  489. end
  490. ret = pbAbilitiesOnSwitchIn_ebs(*args)
  491. @battle.abilityTrick = nil
  492. @battle.abilityMessage = nil
  493. return ret
  494. end
  495.  
  496. alias pbUseMove_ebs pbUseMove unless self.method_defined?(:pbUseMove_ebs)
  497. def pbUseMove(*args)
  498. if self.checkForAbilities(:STANCECHANGE)
  499. @battle.abilityChange = self
  500. end
  501. @battle.abilityTrick = nil
  502. @battle.abilityIntimidate = nil
  503. if self.checkForAbilities(:PROTEAN)
  504. @battle.abilityMessage = self
  505. end
  506. ret = pbUseMove_ebs(*args)
  507. @battle.abilityMessage = nil
  508. @battle.abilityChange = nil
  509. return ret
  510. end
  511.  
  512. if self.method_defined?(:pbReduceAttackStatIntimidate)
  513. alias pbReduceAttackStatIntimidate_ebs pbReduceAttackStatIntimidate unless self.method_defined?(:pbReduceAttackStatIntimidate_ebs)
  514. def pbReduceAttackStatIntimidate(*args)
  515. if self.checkForAbilities(:CLEARBODY,:WHITESMOKE,:HYPERCUTTER,:FLOWERVEIL)
  516. @battle.abilityIntimidate = self
  517. @battle.abilityTrick = nil
  518. end
  519. return pbReduceAttackStatIntimidate_ebs(*args)
  520. end
  521. else
  522. alias pbReduceAttackStatStageIntimidate_ebs pbReduceAttackStatStageIntimidate unless self.method_defined?(:pbReduceAttackStatStageIntimidate_ebs)
  523. def pbReduceAttackStatStageIntimidate(*args)
  524. if self.checkForAbilities(:CLEARBODY,:WHITESMOKE,:HYPERCUTTER,:FLOWERVEIL)
  525. @battle.abilityIntimidate = self
  526. @battle.abilityTrick = nil
  527. end
  528. return pbReduceAttackStatStageIntimidate_ebs(*args)
  529. end
  530. end
  531.  
  532. def checkForAbilities(*args)
  533. return false if !PokeBattle_Battler.method_defined?(:hasWorkingAbility)
  534. ret = false
  535. for arg in args
  536. ret = true if self.hasWorkingAbility(arg)
  537. end
  538. return ret
  539. end
  540.  
  541. alias pbAbilityCureCheck_ebs pbAbilityCureCheck unless self.method_defined?(:pbAbilityCureCheck_ebs)
  542. def pbAbilityCureCheck(*args)
  543. @battle.abilityTrick = self
  544. ret = pbAbilityCureCheck_ebs(*args)
  545. @battle.abilityTrick = nil
  546. return ret
  547. end
  548.  
  549. if self.method_defined?(:pbEffectsAfterHit)
  550. alias pbEffectsAfterHit_ebs pbEffectsAfterHit unless self.method_defined?(:pbEffectsAfterHit_ebs)
  551. def pbEffectsAfterHit(*args)
  552. user = args[0]; target = args[1]
  553. @battle.abilityTrick = user if user.checkForAbilities(:MOXIE,:MAGICIAN)
  554. @battle.abilityTrick = target if target.checkForAbilities(:COLORCHANGE,:PICKPOCKET)
  555. ret = pbEffectsAfterHit_ebs(*args)
  556. @battle.abilityTrick = nil
  557. return ret
  558. end
  559. end
  560.  
  561. if self.method_defined?(:pbEffectsOnDealingDamage)
  562. alias pbEffectsOnDealingDamage_ebs pbEffectsOnDealingDamage unless self.method_defined?(:pbEffectsOnDealingDamage_ebs)
  563. def pbEffectsOnDealingDamage(*args)
  564. target = args[2]
  565. @battle.abilityMessage = target if target.checkForAbilities(:AFTERMATH,:CUTECHARM,:EFFECTSPORE,:FLAMEBODY,:MUMMY,:POISONPOINT,:ROUGHSKIN,:IRONBARBS,:STATIC,:GOOEY,:POISONTOUCH,:CURSEDBODY,:JUSTIFIED,:RATTLED,:WEAKARMOR,:ANGERPOINT)
  566. ret = pbEffectsOnDealingDamage_ebs(*args)
  567. @battle.abilityMessage = nil
  568. return ret
  569. end
  570. end
  571.  
  572. end
  573.  
  574. class PokeBattle_Move
  575. if self.method_defined?(:pbTypeImmunityByAbility)
  576. alias pbTypeImmunityByAbility_ebs pbTypeImmunityByAbility unless self.method_defined?(:pbTypeImmunityByAbility_ebs)
  577. def pbTypeImmunityByAbility(*args)
  578. @battle.abilityMessage = args[2]
  579. ret = pbTypeImmunityByAbility_ebs(*args)
  580. @battle.abilityMessage = nil
  581. return ret
  582. end
  583. else
  584. alias pbTypeModMessages_ebs pbTypeModMessages unless self.method_defined?(:pbTypeModMessages_ebs)
  585. def pbTypeModMessages(*args)
  586. @battle.abilityMessage = args[2]
  587. ret = pbTypeModMessages_ebs(*args)
  588. @battle.abilityMessage = nil
  589. return ret
  590. end
  591. end
  592. end
  593.  
  594. end
  595. #-------------------------------------------------------------------------------
  596. # Automatic sprite name indexing for v4.3 and above
  597. #-------------------------------------------------------------------------------
  598. class PokemonLoad
  599.  
  600. alias loadSpriteConversion pbStartLoadScreen if !self.method_defined?(:loadSpriteConversion)
  601. def pbStartLoadScreen(*args)
  602. # skips if not in debug mode
  603. return loadSpriteConversion(*args) if !$memDebug || Input.press?(Input::CTRL)
  604. # generates a list of all .png files
  605. allFiles = readDirectoryFiles("Graphics/Battlers/",["*.png"])
  606. files = []
  607. # pushes the necessary file names into the main processing list
  608. for i in 1..PBSpecies.maxValue
  609. next if !(getConstantName(PBSpecies,i) rescue nil)
  610. species = sprintf("%03d",i)
  611. species_name = getConstantName(PBSpecies,i)
  612. j = 0
  613. (allFiles.length).times do
  614. sprite = allFiles[j]
  615. if sprite.include?(species) || sprite.include?(species_name)
  616. files.push(sprite)
  617. allFiles.delete_at(j)
  618. else
  619. j += 1
  620. end
  621. end
  622. end
  623. # starts automatic renaming
  624. unless files.empty? && !allFiles.include?("egg.png") && !allFiles.include?("eggCracks.png")
  625. Kernel.pbMessage("The game has detected that you're running the Elite Battle System version 4.3 or above, but have sprites in your Graphics/Battlers that do not match the new naming convention. This will break your game!")
  626. if Kernel.pbConfirmMessage("Would you like to automatically resolve this issue?")
  627. dir = "Graphics/Battlers/"
  628. # creates new directories if necessary
  629. for ext in ["Front/","Back/","FrontShiny/","BackShiny/","Eggs/"]
  630. Dir.mkdir(dir+ext) if !FileTest.directory?(dir+ext)
  631. Dir.mkdir(dir+ext+"Female/") if !FileTest.directory?(dir+ext+"Female/") && ext != "Eggs/"
  632. end
  633. for file in files
  634. user = dir+file
  635. dest = dir
  636. # generates target directory and target name
  637. if file.include?("egg") || file.include?("Egg")
  638. dest = dir+"Eggs/"
  639. if file.include?("eggCracks")
  640. new_name = file.gsub(/eggCracks/) {|s| "cracks" }
  641. elsif file.include?("Egg")
  642. new_name = file.gsub(/Egg/) {|s| "" }
  643. else
  644. new_name = file.gsub(/egg/) {|s| "" }
  645. end
  646. elsif file.include?("s")
  647. if file.include?("b")
  648. dest = dir+"BackShiny/"
  649. new_name = file.gsub(/sb/) {|s| "" }
  650. else
  651. dest = dir+"FrontShiny/"
  652. new_name = file.gsub(/s/) {|s| "" }
  653. end
  654. else
  655. if file.include?("b")
  656. dest = dir+"Back/"
  657. new_name = file.gsub(/b/) {|s| "" }
  658. else
  659. dest = dir+"Front/"
  660. new_name = file
  661. end
  662. end
  663. if file.include?("f")
  664. dest += "Female/"
  665. new_name.gsub!(/f/) {|s| "" }
  666. end
  667. target = dest+new_name
  668. # moves the files into their appropriate folders
  669. File.rename(user,target)
  670. end
  671. end
  672. # Egg conversion
  673. allFiles = readDirectoryFiles("Graphics/Battlers/",["*.png"])
  674. for file in allFiles
  675. if file == "egg.png"
  676. File.rename("Graphics/Battlers/egg.png","Graphics/Battlers/Eggs/000.png")
  677. elsif file == "eggCracks.png"
  678. File.rename("Graphics/Battlers/eggCracks.png","Graphics/Battlers/Eggs/000cracks.png")
  679. end
  680. end
  681. Kernel.pbMessage("Conversion complete! Have fun using the new system!")
  682. end
  683. # goes back to the load screen
  684. return loadSpriteConversion(*args)
  685. end
  686.  
  687. end
Add Comment
Please, Sign In to add comment