Advertisement
Guest User

Untitled

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