From 7de034957bbdde772a4504eadd3c6ce21b6c4587 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 23 Jan 2021 20:44:07 +0000 Subject: [PATCH] More revamping and rearranging --- .../011_Data/001_Game data/012_Trainer.rb | 10 +- .../003_Battle/001_PokeBattle_BattleCommon.rb | 8 +- .../004_Battle_ExpAndMoveLearning.rb | 24 +- .../003_Battle/009_Battle_Action_Other.rb | 2 +- .../003_Battle/012_Battle_Phase_EndOfRound.rb | 2 +- .../001_PokeBattle_Animation.rb | 95 ++--- .../002_PokeBattle_SceneAnimations.rb | 65 ++-- .../004_PokeBattle_SceneElements.rb | 6 +- .../005_Battle scene/009_Scene_Animations.rb | 4 +- .../013_Overworld/013_PField_DayCare.rb | 24 +- Data/Scripts/015_Items/001_PItem_Items.rb | 4 +- .../015_Items/002_PItem_ItemEffects.rb | 26 +- .../015_Items/003_PItem_BattleItemEffects.rb | 26 +- Data/Scripts/015_Items/006_PItem_Mail.rb | 3 + .../002_Pokemon_Forms.rb | 40 +- .../004_Pokemon_ShadowPokemon.rb | 355 +++++------------- .../005_Pokemon_Evolution.rb | 0 .../008_Pokemon_Sprites.rb | 0 .../009_Pokemon_Storage.rb | 12 +- Data/Scripts/016_Pokemon/001_Pokemon.rb | 126 +++---- ...lution.rb => 002_Pokemon_MegaEvolution.rb} | 40 +- .../016_Pokemon/003_Pokemon_ShadowPokemon.rb | 156 ++++++++ ...03_Pokemon_Move.rb => 004_Pokemon_Move.rb} | 0 Data/Scripts/016_Pokemon/006_Pokemon_Owner.rb | 4 +- .../016_Pokemon/010_Pokemon_Deprecated.rb | 52 ++- Data/Scripts/017_UI/005_PScreen_Party.rb | 2 +- Data/Scripts/017_UI/006_PScreen_Summary.rb | 44 +-- .../017_UI/017_PScreen_PokemonStorage.rb | 12 +- .../Scripts/017_UI/020_PScreen_EggHatching.rb | 14 +- Data/Scripts/017_UI/021_PScreen_Evolution.rb | 10 +- Data/Scripts/017_UI/022_PScreen_Trading.rb | 28 +- .../017_UI/023_PScreen_MoveRelearner.rb | 4 +- .../017_UI/024_PScreen_PurifyChamber.rb | 13 +- .../Scripts/017_UI/026_PScreen_MysteryGift.rb | 16 +- .../004_PSystem_PokemonUtilities.rb | 12 +- .../005_PSystem_Utilities.rb | 4 +- .../001_Debug menus/002_Debug_MenuCommands.rb | 30 +- .../004_Debug_PokemonCommands.rb | 62 +-- 38 files changed, 674 insertions(+), 661 deletions(-) rename Data/Scripts/016_Pokemon/{ => 001_Pokemon-related}/002_Pokemon_Forms.rb (93%) rename Data/Scripts/016_Pokemon/{ => 001_Pokemon-related}/004_Pokemon_ShadowPokemon.rb (59%) rename Data/Scripts/016_Pokemon/{ => 001_Pokemon-related}/005_Pokemon_Evolution.rb (100%) rename Data/Scripts/016_Pokemon/{ => 001_Pokemon-related}/008_Pokemon_Sprites.rb (100%) rename Data/Scripts/016_Pokemon/{ => 001_Pokemon-related}/009_Pokemon_Storage.rb (96%) rename Data/Scripts/016_Pokemon/{003_Pokemon_MegaEvolution.rb => 002_Pokemon_MegaEvolution.rb} (67%) create mode 100644 Data/Scripts/016_Pokemon/003_Pokemon_ShadowPokemon.rb rename Data/Scripts/016_Pokemon/{003_Pokemon_Move.rb => 004_Pokemon_Move.rb} (100%) diff --git a/Data/Scripts/011_Data/001_Game data/012_Trainer.rb b/Data/Scripts/011_Data/001_Game data/012_Trainer.rb index 09db47be7..4699dd34c 100644 --- a/Data/Scripts/011_Data/001_Game data/012_Trainer.rb +++ b/Data/Scripts/011_Data/001_Game data/012_Trainer.rb @@ -115,12 +115,12 @@ module GameData party.push(pkmn) # Set Pokémon's properties if defined if pkmn_data[:form] - pkmn.forcedForm = pkmn_data[:form] if MultipleForms.hasFunction?(species, "getForm") - pkmn.formSimple = pkmn_data[:form] + pkmn.forced_form = pkmn_data[:form] if MultipleForms.hasFunction?(species, "getForm") + pkmn.form_simple = pkmn_data[:form] end pkmn.item = pkmn_data[:item] if pkmn_data[:moves] && pkmn_data[:moves].length > 0 - pkmn_data[:moves].each { |move| pkmn.pbLearnMove(move) } + pkmn_data[:moves].each { |move| pkmn.learn_move(move) } else pkmn.resetMoves end @@ -149,10 +149,10 @@ module GameData pkmn.name = pkmn_data[:name] if pkmn_data[:name] && !pkmn_data[:name].empty? if pkmn_data[:shadowness] pkmn.makeShadow - pkmn.pbUpdateShadowMoves(true) + pkmn.update_shadow_moves(true) pkmn.shiny = false end - pkmn.ballused = pkmn_data[:poke_ball] if pkmn_data[:poke_ball] + pkmn.poke_ball = pbBallTypeToItem(pkmn_data[:poke_ball]) if pkmn_data[:poke_ball] pkmn.calcStats end return [trainer, @items.clone, party, self.lose_text] diff --git a/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb b/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb index 57806dba0..dc4ba4204 100644 --- a/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb +++ b/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb @@ -144,13 +144,13 @@ module PokeBattle_BattleCommon pkmn.owner = Pokemon::Owner.new_from_trainer(pbPlayer) end BallHandlers.onCatch(ball,self,pkmn) - pkmn.ballused = pbGetBallType(ball) + pkmn.poke_ball = ball pkmn.makeUnmega if pkmn.mega? pkmn.makeUnprimal - pkmn.pbUpdateShadowMoves if pkmn.shadowPokemon? - pkmn.pbRecordFirstMoves + pkmn.update_shadow_moves if pkmn.shadowPokemon? + pkmn.record_first_moves # Reset form - pkmn.forcedForm = nil if MultipleForms.hasFunction?(pkmn.species,"getForm") + pkmn.forced_form = nil if MultipleForms.hasFunction?(pkmn.species,"getForm") @peer.pbOnLeavingBattle(self,pkmn,true,true) # Make the Poké Ball and data box disappear @scene.pbHideCaptureBall(idxBattler) diff --git a/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb b/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb index d5c6e5287..ddc959b08 100644 --- a/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb +++ b/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb @@ -71,19 +71,21 @@ class PokeBattle_Battle evYield.collect! { |a| a*2 } end # Gain EVs for each stat in turn - PBStats.eachStat do |s| - evGain = evYield[s] - # Can't exceed overall limit - if evTotal+evGain>Pokemon::EV_LIMIT - evGain = Pokemon::EV_LIMIT-evTotal + if pkmn.shadowPokemon? && pkmn.saved_ev + PBStats.eachStat { |s| evTotal += pkmn.saved_ev[s] } + PBStats.eachStat do |s| + evGain = evYield[s].clamp(0, Pokemon::EV_STAT_LIMIT - pkmn.ev[s] - pkmn.saved_ev[s]) + evGain = evGain.clamp(0, Pokemon::EV_LIMIT - evTotal) + pkmn.saved_ev[s] += evGain + evTotal += evGain end - # Can't exceed individual stat limit - if pkmn.ev[s]+evGain>Pokemon::EV_STAT_LIMIT - evGain = Pokemon::EV_STAT_LIMIT-pkmn.ev[s] + else + PBStats.eachStat do |s| + evGain = evYield[s].clamp(0, Pokemon::EV_STAT_LIMIT - pkmn.ev[s]) + evGain = evGain.clamp(0, Pokemon::EV_LIMIT - evTotal) + pkmn.ev[s] += evGain + evTotal += evGain end - # Add EV gain - pkmn.ev[s] += evGain - evTotal += evGain end end diff --git a/Data/Scripts/012_Battle/003_Battle/009_Battle_Action_Other.rb b/Data/Scripts/012_Battle/003_Battle/009_Battle_Action_Other.rb index 26b9f56d7..396a18c2a 100644 --- a/Data/Scripts/012_Battle/003_Battle/009_Battle_Action_Other.rb +++ b/Data/Scripts/012_Battle/003_Battle/009_Battle_Action_Other.rb @@ -42,7 +42,7 @@ class PokeBattle_Battle pbDisplay(_INTL("{1}!",battler.name)) if battler.shadowPokemon? if battler.inHyperMode? - battler.pokemon.hypermode = false + battler.pokemon.hyper_mode = false battler.pokemon.adjustHeart(-300) pbDisplay(_INTL("{1} came to its senses from the Trainer's call!",battler.pbThis)) else diff --git a/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb b/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb index 5d8b65436..ae7e29b4d 100644 --- a/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb +++ b/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb @@ -561,7 +561,7 @@ class PokeBattle_Battle # Hyper Mode (Shadow Pokémon) if b.inHyperMode? if pbRandom(100)<10 - b.pokemon.hypermode = false + b.pokemon.hyper_mode = false b.pokemon.adjustHeart(-50) pbDisplay(_INTL("{1} came to its senses!",b.pbThis)) else diff --git a/Data/Scripts/012_Battle/005_Battle scene/001_PokeBattle_Animation.rb b/Data/Scripts/012_Battle/005_Battle scene/001_PokeBattle_Animation.rb index f494921e9..c86e434df 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/001_PokeBattle_Animation.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/001_PokeBattle_Animation.rb @@ -63,34 +63,37 @@ end module PokeBattle_BallAnimationMixin # Returns the color that the Pokémon turns when it goes into or out of its # Poké Ball. - def getBattlerColorFromBallType(ballType) - case ballType - when 1 then return Color.new(132, 189, 247) # Great Ball - when 2 then return Color.new(189, 247, 165) # Safari Ball - when 3 then return Color.new(255, 255, 123) # Ultra Ball - when 4 then return Color.new(189, 165, 231) # Master Ball - when 5 then return Color.new(173, 255, 206) # Net Ball - when 6 then return Color.new( 99, 206, 247) # Dive Ball - when 7 then return Color.new(247, 222, 82) # Nest Ball - when 8 then return Color.new(255, 198, 132) # Repeat Ball - when 9 then return Color.new(239, 247, 247) # Timer Ball - when 10 then return Color.new(255, 140, 82) # Luxury Ball - when 11 then return Color.new(255, 74, 82) # Premier Ball - when 12 then return Color.new(115, 115, 140) # Dusk Ball - when 13 then return Color.new(255, 198, 231) # Heal Ball - when 14 then return Color.new(140, 214, 255) # Quick Ball - when 15 then return Color.new(247, 66, 41) # Cherish Ball + def getBattlerColorFromPokeBall(poke_ball) + case poke_ball + when :GREATBALL then return Color.new(132, 189, 247) + when :SAFARIBALL then return Color.new(189, 247, 165) + when :ULTRABALL then return Color.new(255, 255, 123) + when :MASTERBALL then return Color.new(189, 165, 231) + when :NETBALL then return Color.new(173, 255, 206) + when :DIVEBALL then return Color.new( 99, 206, 247) + when :NESTBALL then return Color.new(247, 222, 82) + when :REPEATBALL then return Color.new(255, 198, 132) + when :TIMERBALL then return Color.new(239, 247, 247) + when :LUXURYBALL then return Color.new(255, 140, 82) + when :PREMIERBALL then return Color.new(255, 74, 82) + when :DUSKBALL then return Color.new(115, 115, 140) + when :HEALBALL then return Color.new(255, 198, 231) + when :QUICKBALL then return Color.new(140, 214, 255) + when :CHERISHBALL then return Color.new(247, 66, 41) end return Color.new(255, 181, 247) # Poké Ball, Sport Ball, Apricorn Balls, others end - def addBallSprite(ballX,ballY,ballType) - ball = addNewSprite(ballX,ballY, - sprintf("Graphics/Battle animations/ball_%02d",ballType),PictureOrigin::Center) + def addBallSprite(ballX, ballY, poke_ball) + file_path = sprintf("Graphics/Battle animations/ball_%s", poke_ball) + if !pbResolveBitmap(file_path) + file_path = sprintf("Graphics/Battle animations/ball_%02d", pbGetBallType(poke_ball)) + end + ball = addNewSprite(ballX, ballY, file_path, PictureOrigin::Center) @ballSprite = @pictureSprites.last - if @ballSprite.bitmap.width>=@ballSprite.bitmap.height - @ballSprite.src_rect.width = @ballSprite.bitmap.height/2 - ball.setSrcSize(0,@ballSprite.bitmap.height/2,@ballSprite.bitmap.height) + if @ballSprite.bitmap.width >= @ballSprite.bitmap.height + @ballSprite.src_rect.width = @ballSprite.bitmap.height / 2 + ball.setSrcSize(0, @ballSprite.bitmap.height / 2, @ballSprite.bitmap.height) end return ball end @@ -201,28 +204,36 @@ module PokeBattle_BallAnimationMixin ball.setAngle(delay+duration,0) end - def ballSetOpen(ball,delay,ballType) - ball.setName(delay,sprintf("Graphics/Battle animations/ball_%02d_open",ballType)) - if @ballSprite && @ballSprite.bitmap.width>=@ballSprite.bitmap.height - ball.setSrcSize(delay,@ballSprite.bitmap.height/2,@ballSprite.bitmap.height) + def ballSetOpen(ball, delay, poke_ball) + file_path = sprintf("Graphics/Battle animations/ball_%s_open", poke_ball) + if !pbResolveBitmap(file_path) + file_path = sprintf("Graphics/Battle animations/ball_%02d_open", pbGetBallType(poke_ball)) + end + ball.setName(delay, file_path) + if @ballSprite && @ballSprite.bitmap.width >= @ballSprite.bitmap.height + ball.setSrcSize(delay, @ballSprite.bitmap.height / 2, @ballSprite.bitmap.height) end end - def ballSetClosed(ball,delay,ballType) - ball.setName(delay,sprintf("Graphics/Battle animations/ball_%02d",ballType)) - if @ballSprite && @ballSprite.bitmap.width>=@ballSprite.bitmap.height - ball.setSrcSize(delay,@ballSprite.bitmap.height/2,@ballSprite.bitmap.height) + def ballSetClosed(ball, delay, poke_ball) + file_path = sprintf("Graphics/Battle animations/ball_%s", poke_ball) + if !pbResolveBitmap(file_path) + file_path = sprintf("Graphics/Battle animations/ball_%02d", pbGetBallType(poke_ball)) + end + ball.setName(delay, file_path) + if @ballSprite && @ballSprite.bitmap.width >= @ballSprite.bitmap.height + ball.setSrcSize(delay, @ballSprite.bitmap.height / 2, @ballSprite.bitmap.height) end end - def ballOpenUp(ball,delay,ballType,showSquish=true,playSE=true) + def ballOpenUp(ball, delay, poke_ball, showSquish = true, playSE = true) if showSquish - ball.moveZoomXY(delay,1,120,80) # Squish - ball.moveZoom(delay+5,1,100) # Unsquish + ball.moveZoomXY(delay, 1, 120, 80) # Squish + ball.moveZoom(delay + 5, 1, 100) # Unsquish delay += 6 end - ball.setSE(delay,"Battle recall") if playSE - ballSetOpen(ball,delay,ballType) + ball.setSE(delay, "Battle recall") if playSE + ballSetOpen(ball, delay, poke_ball) end def battlerAppear(battler,delay,battlerX,battlerY,batSprite,color) @@ -246,20 +257,20 @@ module PokeBattle_BallAnimationMixin end # The regular Poké Ball burst animation. - def ballBurst(delay,ballX,ballY,ballType) + def ballBurst(delay, ballX, ballY, poke_ball) end # The Poké Ball burst animation used when absorbing a wild Pokémon during a # capture attempt. - def ballBurstCapture(delay,ballX,ballY,ballType) + def ballBurstCapture(delay, ballX, ballY, poke_ball) end - def ballCaptureSuccess(ball,delay,ballX,ballY) - ball.setSE(delay,"Battle catch click") - ball.moveTone(delay,4,Tone.new(-64,-64,-64,128)) + def ballCaptureSuccess(ball, delay, ballX, ballY) + ball.setSE(delay, "Battle catch click") + ball.moveTone(delay, 4, Tone.new(-64, -64, -64, 128)) end # The Poké Ball burst animation used when recalling a Pokémon. - def ballBurstRecall(delay,ballX,ballY,ballType) + def ballBurstRecall(delay, ballX, ballY, poke_ball) end end diff --git a/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb b/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb index 953f3c56c..ca8a6c95d 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb @@ -421,12 +421,9 @@ class PokeballPlayerSendOutAnimation < PokeBattle_Animation shaSprite = @sprites["shadow_#{@battler.index}"] traSprite = @sprites["player_#{@idxTrainer}"] # Calculate the Poké Ball graphic to use - ballType = 0 - if !batSprite.pkmn.nil? - ballType = batSprite.pkmn.ballused || 0 - end + poke_ball = (batSprite.pkmn) ? batSprite.pkmn.poke_ball : nil # Calculate the color to turn the battler sprite - col = getBattlerColorFromBallType(ballType) + col = getBattlerColorFromPokeBall(poke_ball) col.alpha = 255 # Calculate start and end coordinates for battler sprite movement ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize) @@ -440,7 +437,7 @@ class PokeballPlayerSendOutAnimation < PokeBattle_Animation ballMidX = 0 # Unused in trajectory calculation ballMidY = battlerStartY-144 # Set up Poké Ball sprite - ball = addBallSprite(ballStartX,ballStartY,ballType) + ball = addBallSprite(ballStartX,ballStartY,poke_ball) ball.setZ(0,25) ball.setVisible(0,false) # Poké Ball tracking the player's hand animation (if trainer is visible) @@ -455,8 +452,8 @@ class PokeballPlayerSendOutAnimation < PokeBattle_Animation ball.setZ(9,batSprite.z-1) delay = ball.totalDuration+4 delay += 10*@idxOrder # Stagger appearances if multiple Pokémon are sent out at once - ballOpenUp(ball,delay-2,ballType) - ballBurst(delay,battlerStartX,battlerStartY-18,ballType) + ballOpenUp(ball,delay-2,poke_ball) + ballBurst(delay,battlerStartX,battlerStartY-18,poke_ball) ball.moveOpacity(delay+2,2,0) # Set up battler sprite battler = addSprite(batSprite,PictureOrigin::Bottom) @@ -501,12 +498,9 @@ class PokeballTrainerSendOutAnimation < PokeBattle_Animation batSprite = @sprites["pokemon_#{@battler.index}"] shaSprite = @sprites["shadow_#{@battler.index}"] # Calculate the Poké Ball graphic to use - ballType = 0 - if !batSprite.pkmn.nil? - ballType = batSprite.pkmn.ballused || 0 - end + poke_ball = (batSprite.pkmn) ? batSprite.pkmn.poke_ball : nil # Calculate the color to turn the battler sprite - col = getBattlerColorFromBallType(ballType) + col = getBattlerColorFromPokeBall(poke_ball) col.alpha = 255 # Calculate start and end coordinates for battler sprite movement ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize) @@ -515,15 +509,15 @@ class PokeballTrainerSendOutAnimation < PokeBattle_Animation battlerEndX = batSprite.x battlerEndY = batSprite.y # Set up Poké Ball sprite - ball = addBallSprite(0,0,ballType) + ball = addBallSprite(0,0,poke_ball) ball.setZ(0,batSprite.z-1) # Poké Ball animation createBallTrajectory(ball,battlerStartX,battlerStartY) delay = ball.totalDuration+6 delay += 10 if @showingTrainer # Give time for trainer to slide off screen delay += 10*@idxOrder # Stagger appearances if multiple Pokémon are sent out at once - ballOpenUp(ball,delay-2,ballType) - ballBurst(delay,battlerStartX,battlerStartY-18,ballType) + ballOpenUp(ball,delay-2,poke_ball) + ballBurst(delay,battlerStartX,battlerStartY-18,poke_ball) ball.moveOpacity(delay+2,2,0) # Set up battler sprite battler = addSprite(batSprite,PictureOrigin::Bottom) @@ -567,12 +561,9 @@ class BattlerRecallAnimation < PokeBattle_Animation batSprite = @sprites["pokemon_#{@idxBattler}"] shaSprite = @sprites["shadow_#{@idxBattler}"] # Calculate the Poké Ball graphic to use - ballType = 0 - if !batSprite.pkmn.nil? - ballType = batSprite.pkmn.ballused || 0 - end + poke_ball = (batSprite.pkmn) ? batSprite.pkmn.poke_ball : nil # Calculate the color to turn the battler sprite - col = getBattlerColorFromBallType(ballType) + col = getBattlerColorFromPokeBall(poke_ball) col.alpha = 0 # Calculate end coordinates for battler sprite movement ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,batSprite.sideSize) @@ -583,12 +574,12 @@ class BattlerRecallAnimation < PokeBattle_Animation battler.setVisible(0,true) battler.setColor(0,col) # Set up Poké Ball sprite - ball = addBallSprite(battlerEndX,battlerEndY,ballType) + ball = addBallSprite(battlerEndX,battlerEndY,poke_ball) ball.setZ(0,batSprite.z+1) # Poké Ball animation - ballOpenUp(ball,0,ballType) + ballOpenUp(ball,0,poke_ball) delay = ball.totalDuration - ballBurstRecall(delay,battlerEndX,battlerEndY,ballType) + ballBurstRecall(delay,battlerEndX,battlerEndY,poke_ball) ball.moveOpacity(10,2,0) # Battler animation battlerAbsorb(battler,delay,battlerEndX,battlerEndY,col) @@ -693,8 +684,8 @@ class PokeballThrowCaptureAnimation < PokeBattle_Animation include PokeBattle_BallAnimationMixin def initialize(sprites,viewport, - ballType,numShakes,critCapture,battler,showingTrainer) - @ballType = ballType + poke_ball,numShakes,critCapture,battler,showingTrainer) + @poke_ball = poke_ball @numShakes = (critCapture) ? 1 : numShakes @critCapture = critCapture @battler = battler @@ -720,7 +711,7 @@ class PokeballThrowCaptureAnimation < PokeBattle_Animation ballEndY = 112 ballGroundY = ballPos[1]-4 # Set up Poké Ball sprite - ball = addBallSprite(ballStartX,ballStartY,@ballType) + ball = addBallSprite(ballStartX,ballStartY,@poke_ball) ball.setZ(0,batSprite.z+1) @ballSpriteIndex = (@numShakes>=4 || @critCapture) ? @tempSprites.length-1 : -1 # Set up trainer sprite (only visible in Safari Zone battles) @@ -740,12 +731,12 @@ class PokeballThrowCaptureAnimation < PokeBattle_Animation ball.setSE(delay+16,"Battle ball hit") # Poké Ball opens up delay = ball.totalDuration+6 - ballOpenUp(ball,delay,@ballType,true,false) + ballOpenUp(ball,delay,@poke_ball,true,false) # Set up battler sprite battler = addSprite(batSprite,PictureOrigin::Bottom) # Poké Ball absorbs battler delay = ball.totalDuration - ballBurstCapture(delay,ballEndX,ballEndY,@ballType) + ballBurstCapture(delay,ballEndX,ballEndY,@poke_ball) delay = ball.totalDuration+4 # NOTE: The Pokémon does not change color while being absorbed into a Poké # Ball during a capture attempt. This may be an oversight in HGSS. @@ -763,7 +754,7 @@ class PokeballThrowCaptureAnimation < PokeBattle_Animation end # Poké Ball closes delay = battler.totalDuration - ballSetClosed(ball,delay,@ballType) + ballSetClosed(ball,delay,@poke_ball) ball.moveTone(delay,3,Tone.new(96,64,-160,160)) ball.moveTone(delay+5,3,Tone.new(0,0,0,0)) # Poké Ball critical capture animation @@ -808,11 +799,11 @@ class PokeballThrowCaptureAnimation < PokeBattle_Animation if @numShakes==0 || (@numShakes<4 && !@critCapture) # Poké Ball opens ball.setZ(delay,batSprite.z-1) - ballOpenUp(ball,delay,@ballType,false) - ballBurst(delay,ballEndX,ballGroundY,@ballType) + ballOpenUp(ball,delay,@poke_ball,false) + ballBurst(delay,ballEndX,ballGroundY,@poke_ball) ball.moveOpacity(delay+2,2,0) # Battler emerges - col = getBattlerColorFromBallType(@ballType) + col = getBattlerColorFromPokeBall(@poke_ball) col.alpha = 255 battler.setColor(delay,col) battlerAppear(battler,delay,battlerStartX,battlerStartY,batSprite,col) @@ -846,9 +837,9 @@ end class PokeballThrowDeflectAnimation < PokeBattle_Animation include PokeBattle_BallAnimationMixin - def initialize(sprites,viewport,ballType,battler) - @ballType = ballType - @battler = battler + def initialize(sprites,viewport,poke_ball,battler) + @poke_ball = poke_ball + @battler = battler super(sprites,viewport) end @@ -863,7 +854,7 @@ class PokeballThrowDeflectAnimation < PokeBattle_Animation ballEndX = ballPos[0] ballEndY = 112 # Set up Poké Ball sprite - ball = addBallSprite(ballStartX,ballStartY,@ballType) + ball = addBallSprite(ballStartX,ballStartY,@poke_ball) ball.setZ(0,90) # Poké Ball arc animation ball.setSE(0,"Battle throw") diff --git a/Data/Scripts/012_Battle/005_Battle scene/004_PokeBattle_SceneElements.rb b/Data/Scripts/012_Battle/005_Battle scene/004_PokeBattle_SceneElements.rb index da40a5cfa..2482309aa 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/004_PokeBattle_SceneElements.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/004_PokeBattle_SceneElements.rb @@ -161,8 +161,8 @@ class PokemonDataBox < SpriteWrapper return (@animatingHP) ? @currentHP : @battler.hp end - def expFraction - return (@animatingExp) ? @currentExp.to_f/@rangeExp : @battler.pokemon.expFraction + def exp_fraction + return (@animatingExp) ? @currentExp.to_f/@rangeExp : @battler.pokemon.exp_fraction end def animateHP(oldHP,newHP,rangeHP) @@ -283,7 +283,7 @@ class PokemonDataBox < SpriteWrapper def refreshExp return if !@showExp - w = self.expFraction*@expBarBitmap.width + w = exp_fraction * @expBarBitmap.width # NOTE: The line below snaps the bar's width to the nearest 2 pixels, to # fit in with the rest of the graphics which are doubled in size. w = ((w/2).round)*2 diff --git a/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb b/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb index 5449d4945..36343a4ec 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb @@ -306,7 +306,7 @@ class PokeBattle_Scene def pbThrow(ball,shakes,critical,targetBattler,showPlayer=false) @briefMessage = false captureAnim = PokeballThrowCaptureAnimation.new(@sprites,@viewport, - pbGetBallType(ball),shakes,critical,@battle.battlers[targetBattler],showPlayer) + ball,shakes,critical,@battle.battlers[targetBattler],showPlayer) loop do captureAnim.update pbUpdate @@ -347,7 +347,7 @@ class PokeBattle_Scene def pbThrowAndDeflect(ball,idxBattler) @briefMessage = false throwAnim = PokeballThrowDeflectAnimation.new(@sprites,@viewport, - pbGetBallType(ball),@battle.battlers[idxBattler]) + ball,@battle.battlers[idxBattler]) loop do throwAnim.update pbUpdate diff --git a/Data/Scripts/013_Overworld/013_PField_DayCare.rb b/Data/Scripts/013_Overworld/013_PField_DayCare.rb index ed4c3e1c6..c9a6ffdf3 100644 --- a/Data/Scripts/013_Overworld/013_PField_DayCare.rb +++ b/Data/Scripts/013_Overworld/013_PField_DayCare.rb @@ -232,7 +232,7 @@ def pbDayCareGenerateEgg GameData::Item.each do |i| atk = i.move next if !atk - next if !egg.compatibleWithMove?(atk) + next if !egg.compatible_with_move?(atk) next if !movefather.hasMove?(atk) moves.push(atk) end @@ -340,17 +340,17 @@ def pbDayCareGenerateEgg if !ditto0 || !ditto1 possible_balls = [] if mother.species == father.species - possible_balls.push(mother.ballused) - possible_balls.push(father.ballused) + possible_balls.push(mother.poke_ball) + possible_balls.push(father.poke_ball) else - possible_balls.push(pkmn0.ballused) if pkmn0.female? || ditto1 - possible_balls.push(pkmn1.ballused) if pkmn1.female? || ditto0 + possible_balls.push(pkmn0.poke_ball) if pkmn0.female? || ditto1 + possible_balls.push(pkmn1.poke_ball) if pkmn1.female? || ditto0 end - possible_balls.delete(pbGetBallType(:MASTERBALL)) # Can't inherit this Ball - possible_balls.delete(pbGetBallType(:CHERISHBALL)) # Can't inherit this Ball + possible_balls.delete(:MASTERBALL) # Can't inherit this Ball + possible_balls.delete(:CHERISHBALL) # Can't inherit this Ball if possible_balls.length > 0 - egg.ballused = possible_balls[0] - egg.ballused = possible_balls[rand(possible_balls.length)] if possible_balls.length > 1 + egg.poke_ball = possible_balls[0] + egg.poke_ball = possible_balls[rand(possible_balls.length)] if possible_balls.length > 1 end end # Set all stats @@ -358,9 +358,9 @@ def pbDayCareGenerateEgg egg.iv = ivs egg.moves = finalmoves egg.calcStats - egg.obtainText = _INTL("Day-Care Couple") + egg.obtain_text = _INTL("Day-Care Couple") egg.name = _INTL("Egg") - egg.eggsteps = egg.species_data.hatch_steps + egg.steps_to_hatch = egg.species_data.hatch_steps egg.givePokerus if rand(65536)0 scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",pkmn.name,hpgain)) @@ -514,7 +514,7 @@ ItemHandlers::UseOnPokemon.add(:REVIVE,proc { |item,pkmn,scene| end pkmn.hp = (pkmn.totalhp/2).floor pkmn.hp = 1 if pkmn.hp<=0 - pkmn.healStatus + pkmn.heal_status scene.pbRefresh scene.pbDisplay(_INTL("{1}'s HP was restored.",pkmn.name)) next true @@ -525,8 +525,8 @@ ItemHandlers::UseOnPokemon.add(:MAXREVIVE,proc { |item,pkmn,scene| scene.pbDisplay(_INTL("It won't have any effect.")) next false end - pkmn.healHP - pkmn.healStatus + pkmn.heal_HP + pkmn.heal_status scene.pbRefresh scene.pbDisplay(_INTL("{1}'s HP was restored.",pkmn.name)) next true @@ -553,7 +553,7 @@ ItemHandlers::UseOnPokemon.add(:HEALPOWDER,proc { |item,pkmn,scene| scene.pbDisplay(_INTL("It won't have any effect.")) next false end - pkmn.healStatus + pkmn.heal_status pkmn.changeHappiness("powder") scene.pbRefresh scene.pbDisplay(_INTL("{1} became healthy.",pkmn.name)) @@ -565,8 +565,8 @@ ItemHandlers::UseOnPokemon.add(:REVIVALHERB,proc { |item,pkmn,scene| scene.pbDisplay(_INTL("It won't have any effect.")) next false end - pkmn.healHP - pkmn.healStatus + pkmn.heal_HP + pkmn.heal_status pkmn.changeHappiness("revivalherb") scene.pbRefresh scene.pbDisplay(_INTL("{1}'s HP was restored.",pkmn.name)) diff --git a/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb b/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb index 94c1f92e6..c0228448d 100644 --- a/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb +++ b/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb @@ -356,7 +356,7 @@ ItemHandlers::BattleUseOnPokemon.add(:SITRUSBERRY,proc { |item,pokemon,battler,c }) ItemHandlers::BattleUseOnPokemon.add(:AWAKENING,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh @@ -366,7 +366,7 @@ ItemHandlers::BattleUseOnPokemon.add(:AWAKENING,proc { |item,pokemon,battler,cho ItemHandlers::BattleUseOnPokemon.copy(:AWAKENING,:CHESTOBERRY,:BLUEFLUTE) ItemHandlers::BattleUseOnPokemon.add(:ANTIDOTE,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh @@ -376,7 +376,7 @@ ItemHandlers::BattleUseOnPokemon.add(:ANTIDOTE,proc { |item,pokemon,battler,choi ItemHandlers::BattleUseOnPokemon.copy(:ANTIDOTE,:PECHABERRY) ItemHandlers::BattleUseOnPokemon.add(:BURNHEAL,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh @@ -386,7 +386,7 @@ ItemHandlers::BattleUseOnPokemon.add(:BURNHEAL,proc { |item,pokemon,battler,choi ItemHandlers::BattleUseOnPokemon.copy(:BURNHEAL,:RAWSTBERRY) ItemHandlers::BattleUseOnPokemon.add(:PARALYZEHEAL,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh @@ -396,7 +396,7 @@ ItemHandlers::BattleUseOnPokemon.add(:PARALYZEHEAL,proc { |item,pokemon,battler, ItemHandlers::BattleUseOnPokemon.copy(:PARALYZEHEAL,:PARLYZHEAL,:CHERIBERRY) ItemHandlers::BattleUseOnPokemon.add(:ICEHEAL,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh @@ -406,7 +406,7 @@ ItemHandlers::BattleUseOnPokemon.add(:ICEHEAL,proc { |item,pokemon,battler,choic ItemHandlers::BattleUseOnPokemon.copy(:ICEHEAL,:ASPEARBERRY) ItemHandlers::BattleUseOnPokemon.add(:FULLHEAL,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler battler.pbCureConfusion if battler name = (battler) ? battler.pbThis : pokemon.name @@ -420,7 +420,7 @@ ItemHandlers::BattleUseOnPokemon.copy(:FULLHEAL, ItemHandlers::BattleUseOnPokemon.copy(:FULLHEAL,:RAGECANDYBAR) if RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS ItemHandlers::BattleUseOnPokemon.add(:FULLRESTORE,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler battler.pbCureConfusion if battler name = (battler) ? battler.pbThis : pokemon.name @@ -435,14 +435,14 @@ ItemHandlers::BattleUseOnPokemon.add(:FULLRESTORE,proc { |item,pokemon,battler,c ItemHandlers::BattleUseOnPokemon.add(:REVIVE,proc { |item,pokemon,battler,choices,scene| pokemon.hp = pokemon.totalhp/2 pokemon.hp = 1 if pokemon.hp<=0 - pokemon.healStatus + pokemon.heal_status scene.pbRefresh scene.pbDisplay(_INTL("{1} recovered from fainting!",pokemon.name)) }) ItemHandlers::BattleUseOnPokemon.add(:MAXREVIVE,proc { |item,pokemon,battler,choices,scene| - pokemon.healHP - pokemon.healStatus + pokemon.heal_HP + pokemon.heal_status scene.pbRefresh scene.pbDisplay(_INTL("{1} recovered from fainting!",pokemon.name)) }) @@ -460,7 +460,7 @@ ItemHandlers::BattleUseOnPokemon.add(:ENERGYROOT,proc { |item,pokemon,battler,ch }) ItemHandlers::BattleUseOnPokemon.add(:HEALPOWDER,proc { |item,pokemon,battler,choices,scene| - pokemon.healStatus + pokemon.heal_status battler.pbCureStatus(false) if battler battler.pbCureConfusion if battler pokemon.changeHappiness("powder") @@ -470,8 +470,8 @@ ItemHandlers::BattleUseOnPokemon.add(:HEALPOWDER,proc { |item,pokemon,battler,ch }) ItemHandlers::BattleUseOnPokemon.add(:REVIVALHERB,proc { |item,pokemon,battler,choices,scene| - pokemon.healHP - pokemon.healStatus + pokemon.heal_HP + pokemon.heal_status pokemon.changeHappiness("revivalherb") scene.pbRefresh scene.pbDisplay(_INTL("{1} recovered from fainting!",pokemon.name)) diff --git a/Data/Scripts/015_Items/006_PItem_Mail.rb b/Data/Scripts/015_Items/006_PItem_Mail.rb index 6940b4fad..fe3f542e8 100644 --- a/Data/Scripts/015_Items/006_PItem_Mail.rb +++ b/Data/Scripts/015_Items/006_PItem_Mail.rb @@ -19,6 +19,9 @@ class PokemonMail attr_reader :item, :message, :sender, :poke1, :poke2, :poke3 def self.copy(mail) + item.poke1[0] = GameData::Species.get(item.poke1[0]).id if item.poke1 + item.poke2[0] = GameData::Species.get(item.poke2[0]).id if item.poke2 + item.poke3[0] = GameData::Species.get(item.poke3[0]).id if item.poke3 return Mail.new(mail.item, item.message, item.sender, item.poke1, item.poke2, item.poke3) end end diff --git a/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb b/Data/Scripts/016_Pokemon/001_Pokemon-related/002_Pokemon_Forms.rb similarity index 93% rename from Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb rename to Data/Scripts/016_Pokemon/001_Pokemon-related/002_Pokemon_Forms.rb index 18df899a6..2ab1de466 100644 --- a/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon-related/002_Pokemon_Forms.rb @@ -155,6 +155,20 @@ MultipleForms.register(:CASTFORM,{ } }) +MultipleForms.register(:GROUDON,{ + "getPrimalForm" => proc { |pkmn| + next 1 if pkmn.hasItem?(:REDORB) + next + } +}) + +MultipleForms.register(:KYOGRE,{ + "getPrimalForm" => proc { |pkmn| + next 1 if pkmn.hasItem?(:BLUEORB) + next + } +}) + MultipleForms.register(:BURMY,{ "getFormOnCreation" => proc { |pkmn| case pbGetEnvironment @@ -217,9 +231,9 @@ MultipleForms.register(:ROTOM,{ # Turned back into the base form; forget form-specific moves if move_index >= 0 move_name = pkmn.moves[move_index].name - pkmn.pbDeleteMoveAtIndex(move_index) + pkmn.forget_move_at_index(move_index) pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name)) - pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves == 0 + pkmn.learn_move(:THUNDERSHOCK) if pkmn.numMoves == 0 end else # Turned into an alternate form; try learning that form's unique move @@ -234,9 +248,9 @@ MultipleForms.register(:ROTOM,{ pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1", pkmn.name, old_move_name)) pbMessage(_INTL("\\se[]{1} learned {2}!\\se[Pkmn move learnt]", pkmn.name, new_move_name)) else - pkmn.pbDeleteMoveAtIndex(move_index) + pkmn.forget_move_at_index(move_index) pbMessage(_INTL("{1} forgot {2}...", pkmn.name, old_move_name)) - pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves == 0 + pkmn.learn_move(:THUNDERSHOCK) if pkmn.numMoves == 0 end else # Just try to learn this form's unique move @@ -397,12 +411,13 @@ MultipleForms.copy(:FLABEBE,:FLOETTE,:FLORGES) MultipleForms.register(:FURFROU,{ "getForm" => proc { |pkmn| - if !pkmn.formTime || pbGetTimeNow.to_i>pkmn.formTime.to_i+60*60*24*5 # 5 days + if !pkmn.time_form_set || + pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 5 # 5 days next 0 end }, "onSetForm" => proc { |pkmn,form,oldForm| - pkmn.formTime = (form>0) ? pbGetTimeNow.to_i : nil + pkmn.time_form_set = (form > 0) ? pbGetTimeNow.to_i : nil } }) @@ -450,12 +465,13 @@ MultipleForms.register(:ZYGARDE,{ MultipleForms.register(:HOOPA,{ "getForm" => proc { |pkmn| - if !pkmn.formTime || pbGetTimeNow.to_i>pkmn.formTime.to_i+60*60*24*3 # 3 days + if !pkmn.time_form_set || + pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 3 # 3 days next 0 end }, "onSetForm" => proc { |pkmn,form,oldForm| - pkmn.formTime = (form>0) ? pbGetTimeNow.to_i : nil + pkmn.time_form_set = (form>0) ? pbGetTimeNow.to_i : nil } }) @@ -467,7 +483,7 @@ MultipleForms.register(:ORICORIO,{ MultipleForms.register(:ROCKRUFF,{ "getForm" => proc { |pkmn| - next if pkmn.formSimple>=2 # Own Tempo Rockruff cannot become another form + next if pkmn.form_simple >= 2 # Own Tempo Rockruff cannot become another form next 1 if PBDayNight.isNight? next 0 } @@ -561,9 +577,9 @@ MultipleForms.register(:NECROZMA,{ end if move_index >= 0 move_name = pkmn.moves[move_index].name - pkmn.pbDeleteMoveAtIndex(move_index) + pkmn.forget_move_at_index(move_index) pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name)) - pkmn.pbLearnMove(:CONFUSION) if pkmn.numMoves == 0 + pkmn.learn_move(:CONFUSION) if pkmn.numMoves == 0 end else # Turned into an alternate form; try learning that form's unique move @@ -581,7 +597,7 @@ MultipleForms.register(:NECROZMA,{ # evolve into different forms depending on the location where they evolved. MultipleForms.register(:PIKACHU, { "getForm" => proc { |pkmn| - next if pkmn.formSimple >= 2 + next if pkmn.form_simple >= 2 map_metadata = GameData::MapMetadata.try_get($game_map.map_id) next 1 if map_metadata && map_metadata.town_map_position && map_metadata.town_map_position[0] == 1 # Tiall region diff --git a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon-related/004_Pokemon_ShadowPokemon.rb similarity index 59% rename from Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb rename to Data/Scripts/016_Pokemon/001_Pokemon-related/004_Pokemon_ShadowPokemon.rb index cc49de1ec..a696d56ac 100644 --- a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon-related/004_Pokemon_ShadowPokemon.rb @@ -16,80 +16,44 @@ critical hit. #=============================================================================== # Purify a Shadow Pokémon. #=============================================================================== -def pbPurify(pokemon,scene) - return if pokemon.heartgauge!=0 || !pokemon.shadow - return if !pokemon.savedev && !pokemon.savedexp - pokemon.shadow = false - pokemon.giveRibbon(PBRibbons::NATIONAL) - scene.pbDisplay(_INTL("{1} opened the door to its heart!",pokemon.name)) +def pbPurify(pkmn, scene) + return if !pkmn.shadowPokemon? || pkmn.heart_gauge != 0 + pkmn.shadow = false + pkmn.giveRibbon(PBRibbons::NATIONAL) + scene.pbDisplay(_INTL("{1} opened the door to its heart!", pkmn.name)) old_moves = [] - pokemon.moves.each { |m| old_moves.push(m.id) } - pokemon.pbUpdateShadowMoves - pokemon.moves.each_with_index do |m, i| - next if m == old_moves[i] - scene.pbDisplay(_INTL("{1} regained the move {2}!", pokemon.name, m.name)) + pkmn.moves.each { |m| old_moves.push(m.id) } + pkmn.update_shadow_moves + pkmn.moves.each_with_index do |m, i| + next if m.id == old_moves[i] + scene.pbDisplay(_INTL("{1} regained the move {2}!", pkmn.name, m.name)) end - pokemon.pbRecordFirstMoves - if pokemon.savedev - for i in 0...6 - pbApplyEVGain(pokemon,i,pokemon.savedev[i]) + pkmn.record_first_moves + if pkmn.saved_ev + pkmn.add_evs(pkmn.saved_ev) + pkmn.saved_ev = nil + end + if pkmn.saved_exp + newexp = PBExperience.pbAddExperience(pkmn.exp, pkmn.saved_exp || 0, pkmn.growth_rate) + pkmn.saved_exp = nil + newlevel = PBExperience.pbGetLevelFromExperience(newexp, pkmn.growth_rate) + curlevel = pkmn.level + if newexp != pkmn.exp + scene.pbDisplay(_INTL("{1} regained {2} Exp. Points!", pkmn.name, newexp - pkmn.exp)) end - pokemon.savedev = nil - end - newexp = PBExperience.pbAddExperience(pokemon.exp,pokemon.savedexp||0,pokemon.growth_rate) - pokemon.savedexp = nil - newlevel = PBExperience.pbGetLevelFromExperience(newexp,pokemon.growth_rate) - curlevel = pokemon.level - if newexp!=pokemon.exp - scene.pbDisplay(_INTL("{1} regained {2} Exp. Points!",pokemon.name,newexp-pokemon.exp)) - end - if newlevel==curlevel - pokemon.exp = newexp - pokemon.calcStats - else - pbChangeLevel(pokemon,newlevel,scene) # for convenience - pokemon.exp = newexp - end - if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?", pokemon.speciesName)) - newname = pbEnterPokemonName(_INTL("{1}'s nickname?", pokemon.speciesName), - 0, Pokemon::MAX_NAME_SIZE, "", pokemon) - pokemon.name = newname - end -end - -def pbApplyEVGain(pokemon,ev,evgain) - totalev = 0 - for i in 0...6 - totalev += pokemon.ev[i] - end - if totalev+evgain>Pokemon::EV_LIMIT # Can't exceed overall limit - evgain -= totalev+evgain-Pokemon::EV_LIMIT - end - if pokemon.ev[ev]+evgain>Pokemon::EV_STAT_LIMIT - evgain -= totalev+evgain-Pokemon::EV_STAT_LIMIT - end - if evgain>0 - pokemon.ev[ev] += evgain - end -end - -def pbReplaceMoves(pkmn, new_moves) - return if !pkmn - new_moves.each do |move| - next if !move || pkmn.hasMove?(move) - # Find a move slot to put move into - for i in 0...Pokemon::MAX_MOVES - if i >= pkmn.numMoves - # Empty slot; add the new move there - pkmn.pbLearnMove(move) - break - elsif !new_moves.include?(pkmn.moves[i].id) - # Known move that isn't a move to be relearned; replace it - pkmn.moves[i].id = move - break - end + if newlevel == curlevel + pkmn.exp = newexp + pkmn.calcStats + else + pbChangeLevel(pkmn, newlevel, scene) # for convenience + pkmn.exp = newexp end end + if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.speciesName)) + newname = pbEnterPokemonName(_INTL("{1}'s nickname?", pkmn.speciesName), + 0, Pokemon::MAX_NAME_SIZE, "", pkmn) + pkmn.name = newname + end end @@ -182,164 +146,21 @@ end #=============================================================================== # #=============================================================================== -def pbIsPurifiable?(pkmn) - return false if !pkmn - return false if pkmn.isSpecies?(:LUGIA) - return false if !pkmn.shadowPokemon? || pkmn.heartgauge>0 - return true -end - -def pbHasPurifiableInParty? - return $Trainer.party.any? { |pkmn| pbIsPurifiable?(pkmn) } -end - def pbRelicStone - if !pbHasPurifiableInParty? + if !$Trainer.party.any? { |pkmn| pkmn.purifiable? } pbMessage(_INTL("You have no Pokémon that can be purified.")) return end pbMessage(_INTL("There's a Pokémon that may open the door to its heart!")) # Choose a purifiable Pokemon - pbChoosePokemon(1,2,proc { |pkmn| - !pkmn.egg? && pkmn.hp>0 && pkmn.shadowPokemon? && pkmn.heartgauge==0 + pbChoosePokemon(1, 2,proc { |pkmn| + pkmn.able? && pkmn.shadowPokemon? && pkmn.heart_gauge == 0 }) - if $game_variables[1]>=0 + if $game_variables[1] >= 0 pbRelicStoneScreen($Trainer.party[$game_variables[1]]) end end -def pbReadyToPurify(pkmn) - return unless pkmn && pkmn.shadowPokemon? - pkmn.pbUpdateShadowMoves - if pkmn.heartgauge==0 - pbMessage(_INTL("{1} can now be purified!",pkmn.name)) - end -end - - - -#=============================================================================== -# Pokémon class. -#=============================================================================== -class Pokemon - attr_writer :heartgauge - attr_accessor :shadow - attr_writer :hypermode - attr_accessor :savedev - attr_accessor :savedexp - attr_accessor :shadowmoves - attr_accessor :shadowmovenum - HEARTGAUGESIZE = 3840 - - alias :__shadow_expeq :exp= - def exp=(value) - if shadowPokemon? - @savedexp += value-self.exp - else - __shadow_expeq(value) - end - end - - alias :__shadow_hpeq :hp= - def hp=(value) - __shadow_hpeq(value) - @hypermode = false if value<=0 - end - - def hypermode - return (self.heartgauge==0 || self.hp==0) ? false : @hypermode - end - - def heartgauge - return @heartgauge || 0 - end - - def heartStage - return 0 if !@shadow - hg = HEARTGAUGESIZE/5.0 - return ([self.heartgauge,HEARTGAUGESIZE].min/hg).ceil - end - - def adjustHeart(value) - return if !@shadow - @heartgauge = 0 if !@heartgauge - @heartgauge += value - @heartgauge = HEARTGAUGESIZE if @heartgauge>HEARTGAUGESIZE - @heartgauge = 0 if @heartgauge<0 - end - - def shadowPokemon? - return @shadow && @heartgauge && @heartgauge>=0 - end - alias :isShadow? :shadowPokemon? - - def makeShadow - self.shadow = true - self.heartgauge = HEARTGAUGESIZE - self.savedexp = 0 - self.savedev = [0,0,0,0,0,0] - self.shadowmoves = [] - # Retrieve Shadow moveset for this Pokémon - shadow_moveset = pbLoadShadowMovesets[species_data.id] - shadow_moveset = pbLoadShadowMovesets[@species] if !shadow_moveset || shadow_moveset.length == 0 - # Record this Pokémon's Shadow moves - if shadow_moveset && shadow_moveset.length > 0 - for i in 0...[shadow_moveset.length, MAX_MOVES].min - self.shadowmoves[i] = shadow_moveset[i] - end - self.shadowmovenum = shadow_moveset.length - else - # No Shadow moveset defined; just use Shadow Rush - self.shadowmoves[0] = :SHADOWRUSH if GameData::Move.exists?(:SHADOWRUSH) - self.shadowmovenum = 1 - end - # Record this Pokémon's original moves - @moves.each_with_index { |m, i| self.shadowmoves[MAX_MOVES + i] = m.id } - # Update moves - pbUpdateShadowMoves - end - - def pbUpdateShadowMoves(relearn_all_moves = false) - return if !@shadowmoves - # Not a Shadow Pokémon (any more); relearn all its original moves - if !@shadow - if @shadowmoves.length > MAX_MOVES - new_moves = [] - @shadowmoves.each_with_index { |m, i| new_moves.push(m) if m && i >= MAX_MOVES } - pbReplaceMoves(self, new_moves) - end - @shadowmoves = nil - return - end - # Is a Shadow Pokémon; ensure it knows the appropriate moves depending on its heart stage - m = @shadowmoves - # Start with all Shadow moves - new_moves = [] - @shadowmoves.each_with_index { |m, i| new_moves.push(m) if m && i < MAX_MOVES } - # Add some original moves (skipping ones in the same slot as a Shadow Move) - num_original_moves = (relearn_all_moves) ? 3 : [3, 3, 2, 1, 1, 0][self.heartStage] - if num_original_moves > 0 - relearned_count = 0 - @shadowmoves.each_with_index do |m, i| - next if !m || i < MAX_MOVES + @shadowmovenum - new_moves.push(m) - relearned_count += 1 - break if relearned_count >= num_original_moves - end - end - # Relearn Shadow moves plus some original moves (may not change anything) - pbReplaceMoves(self, new_moves) - end - - alias :__shadow_clone :clone - def clone - ret = __shadow_clone - ret.savedev = self.savedev.clone if self.savedev - ret.shadowmoves = self.shadowmoves.clone if self.shadowmoves - return ret - end -end - #=============================================================================== @@ -350,7 +171,7 @@ class PokeBattle_Battle def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages=true) ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages) - if ret && pkmn.hypermode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item) + if ret && pkmn.hyper_mode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item) scene.pbDisplay(_INTL("This item can't be used on that Pokémon.")) return false end @@ -366,7 +187,7 @@ class PokeBattle_Battler def pbInitPokemon(*arg) if self.pokemonIndex>0 && inHyperMode? # Called out of Hyper Mode - self.pokemon.hypermode = false + self.pokemon.hyper_mode = false self.pokemon.adjustHeart(-50) end __shadow__pbInitPokemon(*arg) @@ -382,21 +203,21 @@ class PokeBattle_Battler def shadowPokemon? p = self.pokemon - return p && p.respond_to?("shadowPokemon?") && p.shadowPokemon? + return p && p.shadowPokemon? end alias isShadow? shadowPokemon? def inHyperMode? return false if fainted? p = self.pokemon - return p && p.respond_to?("hypermode") && p.hypermode + return p && p.hyper_mode end def pbHyperMode return if fainted? || !shadowPokemon? || inHyperMode? p = self.pokemon - if @battle.pbRandom(p.heartgauge)<=Pokemon::HEARTGAUGESIZE/4 - p.hypermode = true + if @battle.pbRandom(p.heart_gauge) <= Pokemon::HEART_GAUGE_SIZE / 4 + p.hyper_mode = true @battle.pbDisplay(_INTL("{1}'s emotions rose to a fever pitch!\nIt entered Hyper Mode!",self.pbThis)) end end @@ -413,30 +234,27 @@ end #=============================================================================== # Shadow item effects. #=============================================================================== -def pbRaiseHappinessAndReduceHeart(pokemon,scene,amount) - if !pokemon.shadowPokemon? +def pbRaiseHappinessAndReduceHeart(pkmn, scene, heart_amount) + if !pkmn.shadowPokemon? || (pkmn.happiness == 255 && pkmn.heart_gauge == 0) scene.pbDisplay(_INTL("It won't have any effect.")) return false end - if pokemon.happiness==255 && pokemon.heartgauge==0 - scene.pbDisplay(_INTL("It won't have any effect.")) - return false - elsif pokemon.happiness==255 - pokemon.adjustHeart(-amount) - scene.pbDisplay(_INTL("{1} adores you!\nThe door to its heart opened a little.",pokemon.name)) - pbReadyToPurify(pokemon) - return true - elsif pokemon.heartgauge==0 - pokemon.changeHappiness("vitamin") - scene.pbDisplay(_INTL("{1} turned friendly.",pokemon.name)) - return true + if pkmn.happiness == 255 + stage = pkmn.heart_gauge + pkmn.adjustHeart(-heart_amount) + scene.pbDisplay(_INTL("{1} adores you!\nThe door to its heart opened a little.", pkmn.name)) + pkmn.check_ready_to_purify if pkmn.heart_gauge != stage + elsif pkmn.heart_gauge == 0 + pkmn.changeHappiness("vitamin") + scene.pbDisplay(_INTL("{1} turned friendly.", pkmn.name)) else - pokemon.changeHappiness("vitamin") - pokemon.adjustHeart(-amount) - scene.pbDisplay(_INTL("{1} turned friendly.\nThe door to its heart opened a little.",pokemon.name)) - pbReadyToPurify(pokemon) - return true + stage = pkmn.heart_gauge + pkmn.changeHappiness("vitamin") + pkmn.adjustHeart(-heart_amount) + scene.pbDisplay(_INTL("{1} turned friendly.\nThe door to its heart opened a little.", pkmn.name)) + pkmn.check_ready_to_purify if pkmn.heart_gauge != stage end + return true end ItemHandlers::UseOnPokemon.add(:JOYSCENT,proc { |item,pokemon,scene| @@ -452,12 +270,12 @@ ItemHandlers::UseOnPokemon.add(:VIVIDSCENT,proc { |item,pokemon,scene| }) ItemHandlers::UseOnPokemon.add(:TIMEFLUTE,proc { |item,pokemon,scene| - if !pokemon.shadowPokemon? + if !pokemon.shadowPokemon? || pokemon.heart_gauge == 0 scene.pbDisplay(_INTL("It won't have any effect.")) next false end - pokemon.heartgauge = 0 - pbReadyToPurify(pokemon) + pokemon.heart_gauge = 0 + pokemon.check_ready_to_purify next true }) @@ -472,22 +290,22 @@ ItemHandlers::CanUseInBattle.add(:JOYSCENT,proc { |item,pokemon,battler,move,fir ItemHandlers::CanUseInBattle.copy(:JOYSCENT,:EXCITESCENT,:VIVIDSCENT) ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene| - battler.pokemon.hypermode = false - battler.pokemon.adjustHeart(-500) + battler.pokemon.hyper_mode = false + battler.pokemon.adjustHeart(-100) scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name)) next true }) ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene| - battler.pokemon.hypermode = false - battler.pokemon.adjustHeart(-1000) + battler.pokemon.hyper_mode = false + battler.pokemon.adjustHeart(-200) scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name)) next true }) ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene| - battler.pokemon.hypermode = false - battler.pokemon.adjustHeart(-2000) + battler.pokemon.hyper_mode = false + battler.pokemon.adjustHeart(-300) scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name)) next true }) @@ -660,35 +478,39 @@ end # #=============================================================================== class PokemonTemp - attr_accessor :heartgauges + attr_accessor :heart_gauges end +# Record current heart gauges of Pokémon in party, to see if they drop to zero +# during battle and need to say they're ready to be purified afterwards Events.onStartBattle += proc { |_sender| - # Record current heart gauges of Pokémon in party, to see if they drop to zero - # during battle and need to say they're ready to be purified afterwards - $PokemonTemp.heartgauges = [] - for i in 0...$Trainer.party.length - $PokemonTemp.heartgauges[i] = $Trainer.party[i].heartgauge + $PokemonTemp.heart_gauges = [] + $Trainer.party.each_with_index do |pkmn, i| + $PokemonTemp.heart_gauges[i] = pkmn.heart_gauge end } Events.onEndBattle += proc { |_sender,_e| - for i in 0...$PokemonTemp.heartgauges.length - pokemon = $Trainer.party[i] - if pokemon && $PokemonTemp.heartgauges[i] && - $PokemonTemp.heartgauges[i]!=0 && pokemon.heartgauge==0 - pbReadyToPurify(pokemon) - end + $PokemonTemp.heart_gauges.each_with_index do |value, i| + pkmn = $Trainer.party[i] + next if !pkmn || !value || value == 0 + pkmn.check_ready_to_purify if pkmn.heart_gauge == 0 end } Events.onStepTaken += proc { for pkmn in $Trainer.ablePokemonParty - if pkmn.heartgauge>0 - pkmn.adjustHeart(-1) - pbReadyToPurify(pkmn) if pkmn.heartgauge==0 + next if pkmn.heart_gauge == 0 + stage = pkmn.heartStage + pkmn.adjustHeart(-1) + case pkmn.heartStage + when 0 + pkmn.check_ready_to_purify + when stage + else + pkmn.update_shadow_moves end end if ($PokemonGlobal.purifyChamber rescue nil) @@ -697,7 +519,8 @@ Events.onStepTaken += proc { for i in 0...2 pkmn = $PokemonGlobal.daycare[i][0] next if !pkmn + stage = pkmn.heartStage pkmn.adjustHeart(-1) - pkmn.pbUpdateShadowMoves + pkmn.update_shadow_moves if pkmn.heartStage != stage end } diff --git a/Data/Scripts/016_Pokemon/005_Pokemon_Evolution.rb b/Data/Scripts/016_Pokemon/001_Pokemon-related/005_Pokemon_Evolution.rb similarity index 100% rename from Data/Scripts/016_Pokemon/005_Pokemon_Evolution.rb rename to Data/Scripts/016_Pokemon/001_Pokemon-related/005_Pokemon_Evolution.rb diff --git a/Data/Scripts/016_Pokemon/008_Pokemon_Sprites.rb b/Data/Scripts/016_Pokemon/001_Pokemon-related/008_Pokemon_Sprites.rb similarity index 100% rename from Data/Scripts/016_Pokemon/008_Pokemon_Sprites.rb rename to Data/Scripts/016_Pokemon/001_Pokemon-related/008_Pokemon_Sprites.rb diff --git a/Data/Scripts/016_Pokemon/009_Pokemon_Storage.rb b/Data/Scripts/016_Pokemon/001_Pokemon-related/009_Pokemon_Storage.rb similarity index 96% rename from Data/Scripts/016_Pokemon/009_Pokemon_Storage.rb rename to Data/Scripts/016_Pokemon/001_Pokemon-related/009_Pokemon_Storage.rb index d576469dc..585dd3f93 100644 --- a/Data/Scripts/016_Pokemon/009_Pokemon_Storage.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon-related/009_Pokemon_Storage.rb @@ -189,8 +189,8 @@ class PokemonStorage else # Copying into box pkmn = self[boxSrc,indexSrc] raise "Trying to copy nil to storage" if !pkmn - pkmn.formTime = nil if pkmn.respond_to?("formTime") - pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN) + pkmn.time_form_set = nil + pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN) pkmn.heal self[boxDst,indexDst] = pkmn end @@ -212,8 +212,8 @@ class PokemonStorage for i in 0...maxPokemon(box) if self[box,i]==nil if box>=0 - pkmn.formTime = nil if pkmn.respond_to?("formTime") && pkmn.formTime - pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN) + pkmn.time_form_set = nil if pkmn.time_form_set + pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN) pkmn.heal end self[box,i] = pkmn @@ -225,8 +225,8 @@ class PokemonStorage def pbStoreCaught(pkmn) if @currentBox>=0 - pkmn.formTime = nil if pkmn.respond_to?("formTime") - pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN) + pkmn.time_form_set = nil + pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN) pkmn.heal end for i in 0...maxPokemon(@currentBox) diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 8a0866353..90fc1eadf 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -8,14 +8,14 @@ class Pokemon # If defined, this Pokémon's form will be this value even if a MultipleForms # handler tries to say otherwise. # @return [Integer, nil] this Pokémon's form - attr_accessor :forcedForm + attr_accessor :forced_form # If defined, is the time (in Integer form) when this Pokémon's form was set. # @return [Integer, nil] the time this Pokémon's form was set - attr_accessor :formTime + attr_accessor :time_form_set # @return [Integer] the current experience points attr_reader :exp # @return [Integer] the number of steps until this Pokémon hatches, 0 if this Pokémon is not an egg - attr_accessor :eggsteps + attr_accessor :steps_to_hatch # @return [Integer] the current HP attr_reader :hp # @return [Integer] this Pokémon's current status (from PBStatuses) @@ -37,7 +37,7 @@ class Pokemon # @return [Array] the moves known by this Pokémon attr_accessor :moves # @return [Array] the IDs of moves known by this Pokémon when it was obtained - attr_accessor :firstmoves + attr_accessor :first_moves # @return [Array] an array of ribbons owned by this Pokémon attr_accessor :ribbons # @return [Integer] contest stats @@ -46,8 +46,8 @@ class Pokemon attr_accessor :pokerus # @return [Integer] this Pokémon's current happiness (an integer between 0 and 255) attr_accessor :happiness - # @return [Integer] the type of ball used (refer to {$BallTypes} for valid types) - attr_accessor :ballused + # @return [Symbol] the item ID of the Poké Ball this Pokémon is in + attr_accessor :poke_ball # @return [Integer] this Pokémon's markings, one bit per marking attr_accessor :markings # @return [Array] an array of IV values for HP, Atk, Def, Speed, Sp. Atk and Sp. Def @@ -66,17 +66,17 @@ class Pokemon # 0 (met), 1 (as egg), 2 (traded), 4 (fateful encounter) attr_accessor :obtain_method # @return [Integer] the ID of the map this Pokémon was obtained in - attr_accessor :obtainMap + attr_accessor :obtain_map # Describes the manner this Pokémon was obtained. If left undefined, # the obtain map's name is used. # @return [String] the obtain text - attr_accessor :obtainText + attr_accessor :obtain_text # @return [Integer] the level of this Pokémon when it was obtained - attr_accessor :obtainLevel + attr_accessor :obtain_level # If this Pokémon hatched from an egg, returns the map ID where the hatching happened. # Otherwise returns 0. # @return [Integer] the map ID where egg was hatched (0 by default) - attr_accessor :hatchedMap + attr_accessor :hatched_map # Another Pokémon which has been fused with this Pokémon (or nil if there is none). # Currently only used by Kyurem, to record a fused Reshiram or Zekrom. # @return [Pokemon, nil] the Pokémon fused into this one (nil if there is none) @@ -96,7 +96,7 @@ class Pokemon MAX_MOVES = 4 def species_data - return GameData::Species.get_species_form(@species, formSimple) + return GameData::Species.get_species_form(@species, form_simple) end #============================================================================= @@ -108,11 +108,11 @@ class Pokemon def species=(species_id) new_species_data = GameData::Species.get(species_id) return if @species == new_species_data.species - @species = new_species_data.species - @form = new_species_data.form if new_species_data.form != 0 - @forcedForm = nil - @level = nil # In case growth rate is different for the new species - @ability = nil + @species = new_species_data.species + @form = new_species_data.form if new_species_data.form != 0 + @forced_form = nil + @level = nil # In case growth rate is different for the new species + @ability = nil calcStats end @@ -124,15 +124,15 @@ class Pokemon end def form - return @forcedForm if !@forcedForm.nil? + return @forced_form if !@forced_form.nil? return @form if $game_temp.in_battle calc_form = MultipleForms.call("getForm", self) self.form = calc_form if calc_form != nil && calc_form != @form return @form end - def formSimple - return @forcedForm || @form + def form_simple + return @forced_form || @form end def form=(value) @@ -149,7 +149,7 @@ class Pokemon self.form = value end - def formSimple=(value) + def form_simple=(value) @form = value calcStats end @@ -184,7 +184,7 @@ class Pokemon # @return [Boolean] whether this Pokémon is an egg def egg? - return @eggsteps > 0 + return @steps_to_hatch > 0 end alias isEgg? egg? @@ -200,7 +200,7 @@ class Pokemon # @return [Float] a number between 0 and 1 indicating how much of the current level's # Exp this Pokémon has - def expFraction + def exp_fraction lvl = self.level return 0.0 if lvl >= PBExperience.maxLevel g_rate = growth_rate @@ -217,7 +217,7 @@ class Pokemon # @param value [Integer] new HP value def hp=(value) @hp = value.clamp(0, @totalhp) - healStatus if @hp == 0 + heal_status if @hp == 0 end # Sets this Pokémon's status. See {PBStatuses} for all possible status effects. @@ -243,13 +243,13 @@ class Pokemon alias isFainted? fainted? # Heals all HP of this Pokémon. - def healHP + def heal_HP return if egg? @hp = @totalhp end # Heals the status problem of this Pokémon. - def healStatus + def heal_status return if egg? @status = PBStatuses::NONE @statusCount = 0 @@ -259,7 +259,7 @@ class Pokemon # of the move in that index. # @param move_index [Integer] index of the move to heal (-1 if all moves # should be healed) - def healPP(move_index = -1) + def heal_PP(move_index = -1) return if egg? if move_index >= 0 @moves[move_index].pp = @moves[move_index].total_pp @@ -271,9 +271,9 @@ class Pokemon # Heals all HP, PP, and status problems of this Pokémon. def heal return if egg? - healHP - healStatus - healPP + heal_HP + heal_status + heal_PP end #============================================================================= @@ -572,7 +572,7 @@ class Pokemon # Silently learns the given move. Will erase the first known move if it has to. # @param move_id [Integer, Symbol, String] ID of the move to learn - def pbLearnMove(move_id) + def learn_move(move_id) move_data = GameData::Move.try_get(move_id) return if !move_data # Check if self already knows the move; if so, move it to the end of the array @@ -590,7 +590,7 @@ class Pokemon # Deletes the given move from the Pokémon. # @param move_id [Integer, Symbol, String] ID of the move to delete - def pbDeleteMove(move_id) + def forget_move(move_id) move_data = GameData::Move.try_get(move_id) return if !move_data @moves.delete_if { |m| m.id == move_data.id } @@ -598,43 +598,43 @@ class Pokemon # Deletes the move at the given index from the Pokémon. # @param index [Integer] index of the move to be deleted - def pbDeleteMoveAtIndex(index) + def forget_move_at_index(index) @moves.delete_at(index) end # Deletes all moves from the Pokémon. - def pbDeleteAllMoves + def forget_all_moves @moves.clear end # Copies currently known moves into a separate array, for Move Relearner. - def pbRecordFirstMoves - pbClearFirstMoves - @moves.each { |m| @firstmoves.push(m.id) } + def record_first_moves + clear_first_moves + @moves.each { |m| @first_moves.push(m.id) } end # Adds a move to this Pokémon's first moves. # @param move_id [Integer, Symbol, String] ID of the move to add - def pbAddFirstMove(move_id) + def add_first_move(move_id) move_data = GameData::Move.try_get(move_id) - @firstmoves.push(move_data.id) if move_data && !@firstmoves.include?(move_data.id) + @first_moves.push(move_data.id) if move_data && !@first_moves.include?(move_data.id) end # Removes a move from this Pokémon's first moves. # @param move_id [Integer, Symbol, String] ID of the move to remove - def pbRemoveFirstMove(move_id) + def remove_first_move(move_id) move_data = GameData::Move.try_get(move_id) - @firstmoves.delete(move_data.id) if move_data + @first_moves.delete(move_data.id) if move_data end # Clears this Pokémon's first moves. - def pbClearFirstMoves - @firstmoves.clear + def clear_first_moves + @first_moves.clear end # @param move_id [Integer, Symbol, String] ID of the move to check # @return [Boolean] whether the Pokémon is compatible with the given move - def compatibleWithMove?(move_id) + def compatible_with_move?(move_id) move_data = GameData::Move.try_get(move_id) return move_data && species_data.tutor_moves.include?(move_data.id) end @@ -644,7 +644,7 @@ class Pokemon #============================================================================= # @return [Integer] the number of ribbons this Pokémon has - def ribbonCount + def numRibbons return @ribbons.length end @@ -860,8 +860,8 @@ class Pokemon raise _INTL("Unknown happiness-changing method: {1}", method.to_s) end if gain > 0 - gain += 1 if @obtainMap == $game_map.map_id - gain += 1 if @ballused == pbGetBallType(:LUXURYBALL) + gain += 1 if @obtain_map == $game_map.map_id + gain += 1 if @poke_ball == :LUXURYBALL gain = (gain * 1.5).floor if hasItem?(:SOOTHEBELL) end @happiness = (@happiness + gain).clamp(0, 255) @@ -928,14 +928,14 @@ class Pokemon # @return [Pokemon] a copy of this Pokémon def clone ret = super - ret.iv = @iv.clone - ret.ivMaxed = @ivMaxed.clone - ret.ev = @ev.clone - ret.moves = [] + ret.iv = @iv.clone + ret.ivMaxed = @ivMaxed.clone + ret.ev = @ev.clone + ret.moves = [] @moves.each_with_index { |m, i| ret.moves[i] = m.clone } - ret.firstmoves = @firstmoves.cline - ret.owner = @owner.clone - ret.ribbons = @ribbons.clone + ret.first_moves = @first_moves.clone + ret.owner = @owner.clone + ret.ribbons = @ribbons.clone return ret end @@ -948,11 +948,11 @@ class Pokemon species_data = GameData::Species.get(species) @species = species_data.species @form = species_data.form - @forcedForm = nil - @formTime = nil + @forced_form = nil + @time_form_set = nil self.level = level - @eggsteps = 0 - healStatus + @steps_to_hatch = 0 + heal_status @gender = nil @shiny = nil @ability_index = nil @@ -963,7 +963,7 @@ class Pokemon @mail = nil @moves = [] resetMoves if withMoves - @firstmoves = [] + @first_moves = [] @ribbons = [] @cool = 0 @beauty = 0 @@ -974,7 +974,7 @@ class Pokemon @pokerus = 0 @name = nil @happiness = species_data.happiness - @ballused = 0 + @poke_ball = :POKEBALL @markings = 0 @iv = [] @ivMaxed = [] @@ -992,10 +992,10 @@ class Pokemon end @obtain_method = 0 # Met @obtain_method = 4 if $game_switches && $game_switches[FATEFUL_ENCOUNTER_SWITCH] - @obtainMap = ($game_map) ? $game_map.map_id : 0 - @obtainText = nil - @obtainLevel = level - @hatchedMap = 0 + @obtain_map = ($game_map) ? $game_map.map_id : 0 + @obtain_text = nil + @obtain_level = level + @hatched_map = 0 @timeReceived = pbGetTimeNow.to_i @timeEggHatched = nil @fused = nil diff --git a/Data/Scripts/016_Pokemon/003_Pokemon_MegaEvolution.rb b/Data/Scripts/016_Pokemon/002_Pokemon_MegaEvolution.rb similarity index 67% rename from Data/Scripts/016_Pokemon/003_Pokemon_MegaEvolution.rb rename to Data/Scripts/016_Pokemon/002_Pokemon_MegaEvolution.rb index 9d288c9d7..ee400d45f 100644 --- a/Data/Scripts/016_Pokemon/003_Pokemon_MegaEvolution.rb +++ b/Data/Scripts/016_Pokemon/002_Pokemon_MegaEvolution.rb @@ -1,8 +1,8 @@ -#=============================================================================== -# Mega Evolution -# NOTE: These are treated as form changes in Essentials. -#=============================================================================== class Pokemon + #============================================================================= + # Mega Evolution + # NOTE: These are treated as form changes in Essentials. + #============================================================================= def getMegaForm(checkItemOnly = false) ret = 0 GameData::Species.each do |data| @@ -24,12 +24,12 @@ class Pokemon def hasMegaForm? megaForm = self.getMegaForm - return megaForm > 0 && megaForm != self.formSimple + return megaForm > 0 && megaForm != form_simple end def mega? megaForm = self.getMegaForm - return megaForm > 0 && megaForm == self.formSimple + return megaForm > 0 && megaForm == form_simple end alias isMega? mega? @@ -51,15 +51,11 @@ class Pokemon def megaMessage # 0=default message, 1=Rayquaza message return species_data.mega_message end -end - - -#=============================================================================== -# Primal Reversion -# NOTE: These are treated as form changes in Essentials. -#=============================================================================== -class Pokemon + #============================================================================= + # Primal Reversion + # NOTE: These are treated as form changes in Essentials. + #============================================================================= def hasPrimalForm? v = MultipleForms.call("getPrimalForm",self) return v!=nil @@ -83,19 +79,3 @@ class Pokemon end end end - - - -MultipleForms.register(:GROUDON,{ - "getPrimalForm" => proc { |pkmn| - next 1 if pkmn.hasItem?(:REDORB) - next - } -}) - -MultipleForms.register(:KYOGRE,{ - "getPrimalForm" => proc { |pkmn| - next 1 if pkmn.hasItem?(:BLUEORB) - next - } -}) diff --git a/Data/Scripts/016_Pokemon/003_Pokemon_ShadowPokemon.rb b/Data/Scripts/016_Pokemon/003_Pokemon_ShadowPokemon.rb new file mode 100644 index 000000000..05386bc8c --- /dev/null +++ b/Data/Scripts/016_Pokemon/003_Pokemon_ShadowPokemon.rb @@ -0,0 +1,156 @@ +#=============================================================================== +# Pokémon class. +#=============================================================================== +class Pokemon + attr_accessor :shadow + attr_writer :heart_gauge + attr_writer :hyper_mode + attr_accessor :saved_exp + attr_accessor :saved_ev + attr_accessor :shadow_moves + HEART_GAUGE_SIZE = 3840 + + alias :__shadow_expeq :exp= + def exp=(value) + if shadowPokemon? + @saved_exp += value - @exp + else + __shadow_expeq(value) + end + end + + alias :__shadow_hpeq :hp= + def hp=(value) + __shadow_hpeq(value) + @hyper_mode = false if @hp <= 0 + end + + def heart_gauge + return @heart_gauge || 0 + end + + def adjustHeart(value) + return if !shadowPokemon? + @heart_gauge = (self.heart_gauge + value).clamp(0, HEART_GAUGE_SIZE) + end + + def heartStage + return 0 if !shadowPokemon? + stage_size = HEART_GAUGE_SIZE / 5.0 + return ([self.heart_gauge, HEART_GAUGE_SIZE].min / stage_size).ceil + end + + def shadowPokemon? + return @shadow && @heart_gauge && @heart_gauge >= 0 + end + alias isShadow? shadowPokemon? + + def hyper_mode + return (self.heart_gauge == 0 || @hp == 0) ? false : @hyper_mode + end + + def makeShadow + @shadow = true + @heart_gauge = HEART_GAUGE_SIZE + @hyper_mode = false + @saved_exp = 0 + @saved_ev = [0, 0, 0, 0, 0, 0] + @shadow_moves = [] + # Retrieve Shadow moveset for this Pokémon + shadow_moveset = pbLoadShadowMovesets[species_data.id] + shadow_moveset = pbLoadShadowMovesets[@species] if !shadow_moveset || shadow_moveset.length == 0 + # Record this Pokémon's Shadow moves + if shadow_moveset && shadow_moveset.length > 0 + for i in 0...[shadow_moveset.length, MAX_MOVES].min + @shadow_moves[i] = shadow_moveset[i] + end + elsif GameData::Move.exists?(:SHADOWRUSH) + # No Shadow moveset defined; just use Shadow Rush + @shadow_moves[0] = :SHADOWRUSH + else + raise _INTL("Expected Shadow moves or Shadow Rush to be defined, but they weren't.") + end + # Record this Pokémon's original moves + @moves.each_with_index { |m, i| @shadow_moves[MAX_MOVES + i] = m.id } + # Update moves + update_shadow_moves + end + + def update_shadow_moves(relearn_all_moves = false) + return if !@shadow_moves + # Not a Shadow Pokémon (any more); relearn all its original moves + if !shadowPokemon? + if @shadow_moves.length > MAX_MOVES + new_moves = [] + @shadow_moves.each_with_index { |m, i| new_moves.push(m) if m && i >= MAX_MOVES } + replace_moves(new_moves) + end + @shadow_moves = nil + return + end + # Is a Shadow Pokémon; ensure it knows the appropriate moves depending on its heart stage + # Start with all Shadow moves + new_moves = [] + @shadow_moves.each_with_index { |m, i| new_moves.push(m) if m && i < MAX_MOVES } + num_shadow_moves = new_moves.length + # Add some original moves (skipping ones in the same slot as a Shadow Move) + num_original_moves = (relearn_all_moves) ? 3 : [3, 3, 2, 1, 1, 0][self.heartStage] + if num_original_moves > 0 + relearned_count = 0 + @shadow_moves.each_with_index do |m, i| + next if !m || i < MAX_MOVES + num_shadow_moves + new_moves.push(m) + relearned_count += 1 + break if relearned_count >= num_original_moves + end + end + # Relearn Shadow moves plus some original moves (may not change anything) + replace_moves(new_moves) + end + + def replace_moves(new_moves) + new_moves.each do |move| + next if !move || !GameData::Move.exists?(move) || hasMove?(move) + if numMoves < Pokemon::MAX_MOVES # Has an empty slot; just learn move + learn_move(move) + next + end + @moves.each do |m| + next if new_moves.include?(m.id) + m.id = GameData::Move.get(move).id + end + end + end + + def purifiable? + return false if !shadowPokemon? || self.heart_gauge > 0 + return false if isSpecies?(:LUGIA) + return true + end + + def check_ready_to_purify + return if !shadowPokemon? + update_shadow_moves + pbMessage(_INTL("{1} can now be purified!", self.name)) if self.heart_gauge == 0 + end + + def add_evs(added_evs) + total = 0 + @ev.each { |e| total += e } + PBStats.each do |s| + addition = added_evs[s].clamp(0, Pokemon::EV_STAT_LIMIT - @ev[s]) + addition = addition.clamp(0, Pokemon::EV_LIMIT - total) + next if addition == 0 + @ev[s] += addition + total += addition + end + end + + alias :__shadow_clone :clone + def clone + ret = __shadow_clone + ret.saved_ev = @saved_ev.clone if @saved_ev + ret.shadow_moves = @shadow_moves.clone if @shadow_moves + return ret + end +end diff --git a/Data/Scripts/016_Pokemon/003_Pokemon_Move.rb b/Data/Scripts/016_Pokemon/004_Pokemon_Move.rb similarity index 100% rename from Data/Scripts/016_Pokemon/003_Pokemon_Move.rb rename to Data/Scripts/016_Pokemon/004_Pokemon_Move.rb diff --git a/Data/Scripts/016_Pokemon/006_Pokemon_Owner.rb b/Data/Scripts/016_Pokemon/006_Pokemon_Owner.rb index c326a917f..fff9e73b2 100644 --- a/Data/Scripts/016_Pokemon/006_Pokemon_Owner.rb +++ b/Data/Scripts/016_Pokemon/006_Pokemon_Owner.rb @@ -1,5 +1,7 @@ +#=============================================================================== +# Stores information about a Pokémon's owner. +#=============================================================================== class Pokemon - # Stores information about a Pokémon's owner. class Owner # @return [Integer] the ID of the owner attr_reader :id diff --git a/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb index d1a9249c2..eb28479a0 100644 --- a/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb +++ b/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb @@ -18,8 +18,7 @@ class PokeBattle_Pokemon attr_reader :timeReceived, :timeEggHatched attr_reader :cool, :beauty, :cute, :smart, :tough, :sheen attr_reader :trainerID, :ot, :otgender, :language - attr_reader :shadow, :heartgauge, :savedexp, :savedev, :hypermode - attr_reader :shadowmoves, :shadowmovenum + attr_reader :shadow, :heartgauge, :savedexp, :savedev, :hypermode, :shadowmoves def initialise raise "PokeBattle_Pokemon.new is deprecated. Use Pokemon.new instead." @@ -28,10 +27,10 @@ class PokeBattle_Pokemon def self.copy(pkmn) owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language) ret = Pokemon.new(pkmn.species, pkmn.level, owner, false) - ret.forcedForm = pkmn.forcedForm if pkmn.forcedForm - ret.formTime = pkmn.formTime + ret.forced_form = pkmn.forcedForm if pkmn.forcedForm + ret.time_form_set = pkmn.formTime ret.exp = pkmn.exp - ret.eggsteps = pkmn.eggsteps + ret.steps_to_hatch = pkmn.eggsteps ret.status = pkmn.status ret.statusCount = pkmn.statusCount ret.gender = pkmn.genderflag @@ -42,7 +41,7 @@ class PokeBattle_Pokemon ret.item = pkmn.item ret.mail = PokemonMail.copy(pkmn.mail) if pkmn.mail pkmn.moves.each { |m| ret.moves.push(PBMove.copy(m)) if m && m.id > 0 } - pkmn.firstmoves.each { |m| ret.pbAddFirstMove(m) } + pkmn.firstmoves.each { |m| ret.add_first_move(m) } ret.ribbons = pkmn.ribbons.clone if pkmn.ribbons ret.cool = pkmn.cool if pkmn.cool ret.beauty = pkmn.beauty if pkmn.beauty @@ -53,16 +52,16 @@ class PokeBattle_Pokemon ret.pokerus = pkmn.pokerus if pkmn.pokerus ret.name = pkmn.name ret.happiness = pkmn.happiness - ret.ballused = pkmn.ballused + ret.poke_ball = pbBallTypeToItem(pkmn.ballused) ret.markings = pkmn.markings if pkmn.markings ret.iv = pkmn.iv.clone ret.ivMaxed = pkmn.ivMaxed.clone if pkmn.ivMaxed ret.ev = pkmn.ev.clone ret.obtain_method = pkmn.obtainMode - ret.obtainMap = pkmn.obtainMap - ret.obtainText = pkmn.obtainText - ret.obtainLevel = pkmn.obtainLevel if pkmn.obtainLevel - ret.hatchedMap = pkmn.hatchedMap + ret.obtain_map = pkmn.obtainMap + ret.obtain_text = pkmn.obtainText + ret.obtain_level = pkmn.obtainLevel if pkmn.obtainLevel + ret.hatched_map = pkmn.hatchedMap ret.timeReceived = pkmn.timeReceived ret.timeEggHatched = pkmn.timeEggHatched if pkmn.fused @@ -71,16 +70,19 @@ class PokeBattle_Pokemon end ret.personalID = pkmn.personalID ret.hp = pkmn.hp - - ret.shadow = pkmn.shadow - ret.heartgauge = pkmn.heartgauge - ret.savedexp = pkmn.savedexp - ret.savedev = pkmn.savedev.clone - ret.hypermode = pkmn.hypermode - ret.shadowmoves = pkmn.shadowmoves.clone - ret.shadowmovenum = pkmn.shadowmovenum + if pkmn.shadow + ret.shadow = pkmn.shadow + ret.heart_gauge = pkmn.heartgauge + ret.hyper_mode = pkmn.hypermode + ret.saved_exp = pkmn.savedexp + ret.saved_ev = pkmn.savedev.clone + ret.shadow_moves = [] + pkmn.shadowmoves.each_with_index do |move, i| + ret.shadow_moves[i] = GameData::Move.get(move).id if move + end + end # NOTE: Intentionally set last, as it recalculates stats. - ret.formSimple = pkmn.form || 0 + ret.form_simple = pkmn.form || 0 return ret end end @@ -178,6 +180,16 @@ class Pokemon Deprecation.warn_method('Pokemon#setItem', 'v20', 'Pokemon#item=') self.item = value end + + alias healStatus heal_status + alias pbLearnMove learn_move + alias pbDeleteMove forget_move + alias pbDeleteMoveAtIndex forget_move_at_index + alias pbRecordFirstMoves record_first_moves + alias pbAddFirstMove add_first_move + alias pbRemoveFirstMove remove_first_move + alias pbClearFirstMoves clear_first_moves + alias pbUpdateShadowMoves update_shadow_moves end # (see Pokemon#initialize) diff --git a/Data/Scripts/017_UI/005_PScreen_Party.rb b/Data/Scripts/017_UI/005_PScreen_Party.rb index 88a778b9f..b27f948a8 100644 --- a/Data/Scripts/017_UI/005_PScreen_Party.rb +++ b/Data/Scripts/017_UI/005_PScreen_Party.rb @@ -664,7 +664,7 @@ class PokemonParty_Scene next false if !pbCanUseOnPokemon?(itm) if itm.is_machine? move = itm.move - next false if pokemon.hasMove?(move) || !pokemon.compatibleWithMove?(move) + next false if pokemon.hasMove?(move) || !pokemon.compatible_with_move?(move) end next true }) diff --git a/Data/Scripts/017_UI/006_PScreen_Summary.rb b/Data/Scripts/017_UI/006_PScreen_Summary.rb index f6a007d57..ec63ff917 100644 --- a/Data/Scripts/017_UI/006_PScreen_Summary.rb +++ b/Data/Scripts/017_UI/006_PScreen_Summary.rb @@ -302,7 +302,10 @@ class PokemonSummary_Scene @sprites["background"].setBitmap("Graphics/Pictures/Summary/bg_#{page}") imagepos=[] # Show the Poké Ball containing the Pokémon - ballimage = sprintf("Graphics/Pictures/Summary/icon_ball_%02d",@pokemon.ballused) + ballimage = sprintf("Graphics/Pictures/Summary/icon_ball_%s", @pokemon.poke_ball) + if !pbResolveBitmap(ballimage) + ballimage = sprintf("Graphics/Pictures/Summary/icon_ball_%02d", pbGetBallType(@pokemon.poke_ball)) + end imagepos.push([ballimage,14,60]) # Show status/fainted/Pokérus infected icon status = -1 @@ -368,7 +371,7 @@ class PokemonSummary_Scene dexNumShadow = (@pokemon.shiny?) ? Color.new(224,152,144) : Color.new(176,176,176) # If a Shadow Pokémon, draw the heart gauge area and bar if @pokemon.shadowPokemon? - shadowfract = @pokemon.heartgauge*1.0/Pokemon::HEARTGAUGESIZE + shadowfract = @pokemon.heart_gauge.to_f / Pokemon::HEART_GAUGE_SIZE imagepos = [ ["Graphics/Pictures/Summary/overlay_shadow",224,240], ["Graphics/Pictures/Summary/overlay_shadowbar",242,280,0,0,(shadowfract*248).floor,-1] @@ -457,7 +460,7 @@ class PokemonSummary_Scene end # Draw Exp bar if @pokemon.level{1} {2}, {3}\n",date,month,year) end # Write map name egg was received on - mapname = pbGetMapNameFromId(@pokemon.obtainMap) - if (@pokemon.obtainText rescue false) && @pokemon.obtainText!="" - mapname = @pokemon.obtainText - end - if mapname && mapname!="" + mapname = pbGetMapNameFromId(@pokemon.obtain_map) + mapname = @pokemon.obtain_text if @pokemon.obtain_text && !@pokemon.obtain_text.empty? + if mapname && mapname != "" memo += _INTL("A mysterious Pokémon Egg received from {1}.\n",mapname) else memo += _INTL("A mysterious Pokémon Egg.\n",mapname) @@ -515,9 +519,9 @@ class PokemonSummary_Scene # Write Egg Watch blurb memo += _INTL("\"The Egg Watch\"\n") eggstate = _INTL("It looks like this Egg will take a long time to hatch.") - eggstate = _INTL("What will hatch from this? It doesn't seem close to hatching.") if @pokemon.eggsteps<10200 - eggstate = _INTL("It appears to move occasionally. It may be close to hatching.") if @pokemon.eggsteps<2550 - eggstate = _INTL("Sounds can be heard coming from inside! It will hatch soon!") if @pokemon.eggsteps<1275 + eggstate = _INTL("What will hatch from this? It doesn't seem close to hatching.") if @pokemon.steps_to_hatch < 10200 + eggstate = _INTL("It appears to move occasionally. It may be close to hatching.") if @pokemon.steps_to_hatch < 2550 + eggstate = _INTL("Sounds can be heard coming from inside! It will hatch soon!") if @pokemon.steps_to_hatch < 1275 memo += sprintf("%s\n",eggstate) # Draw all text drawFormattedTextEx(overlay,232,78,268,memo) @@ -542,18 +546,16 @@ class PokemonSummary_Scene memo += _INTL("{1} {2}, {3}\n",date,month,year) end # Write map name Pokémon was received on - mapname = pbGetMapNameFromId(@pokemon.obtainMap) - if (@pokemon.obtainText rescue false) && @pokemon.obtainText!="" - mapname = @pokemon.obtainText - end + mapname = pbGetMapNameFromId(@pokemon.obtain_map) + mapname = @pokemon.obtain_text if @pokemon.obtain_text && !@pokemon.obtain_text.empty? mapname = _INTL("Faraway place") if !mapname || mapname=="" memo += sprintf("%s\n",mapname) # Write how Pokémon was obtained - mettext = [_INTL("Met at Lv. {1}.",@pokemon.obtainLevel), + mettext = [_INTL("Met at Lv. {1}.",@pokemon.obtain_level), _INTL("Egg received."), - _INTL("Traded at Lv. {1}.",@pokemon.obtainLevel), + _INTL("Traded at Lv. {1}.",@pokemon.obtain_level), "", - _INTL("Had a fateful encounter at Lv. {1}.",@pokemon.obtainLevel) + _INTL("Had a fateful encounter at Lv. {1}.",@pokemon.obtain_level) ][@pokemon.obtain_method] memo += sprintf("%s\n",mettext) if mettext && mettext!="" # If Pokémon was hatched, write when and where it hatched @@ -564,7 +566,7 @@ class PokemonSummary_Scene year = @pokemon.timeEggHatched.year memo += _INTL("{1} {2}, {3}\n",date,month,year) end - mapname = pbGetMapNameFromId(@pokemon.hatchedMap) + mapname = pbGetMapNameFromId(@pokemon.hatched_map) mapname = _INTL("Faraway place") if !mapname || mapname=="" memo += sprintf("%s\n",mapname) memo += _INTL("Egg hatched.\n") @@ -829,7 +831,7 @@ class PokemonSummary_Scene # Write various bits of text textpos = [ [_INTL("No. of Ribbons:"),234,332,0,Color.new(64,64,64),Color.new(176,176,176)], - [@pokemon.ribbonCount.to_s,450,332,1,Color.new(64,64,64),Color.new(176,176,176)], + [@pokemon.numRibbons.to_s,450,332,1,Color.new(64,64,64),Color.new(176,176,176)], ] # Draw all text pbDrawTextPositions(overlay,textpos) diff --git a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb index 7cfee61e6..417c18057 100644 --- a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb +++ b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb @@ -1720,8 +1720,8 @@ class PokemonStorageScreen end if heldpoke || selected[0]==-1 p = (heldpoke) ? heldpoke : @storage[-1,index] - p.formTime = nil if p.respond_to?("formTime") - p.form = 0 if p.isSpecies?(:SHAYMIN) + p.time_form_set = nil + p.form = 0 if p.isSpecies?(:SHAYMIN) p.heal end @scene.pbStore(selected,heldpoke,destbox,firstfree) @@ -1767,8 +1767,8 @@ class PokemonStorageScreen return end if box>=0 - @heldpkmn.formTime = nil if @heldpkmn.respond_to?("formTime") - @heldpkmn.form = 0 if @heldpkmn.isSpecies?(:SHAYMIN) + @heldpkmn.time_form_set = nil + @heldpkmn.form = 0 if @heldpkmn.isSpecies?(:SHAYMIN) @heldpkmn.heal end @scene.pbPlace(selected,@heldpkmn) @@ -1796,8 +1796,8 @@ class PokemonStorageScreen return false end if box>=0 - @heldpkmn.formTime = nil if @heldpkmn.respond_to?("formTime") - @heldpkmn.form = 0 if @heldpkmn.isSpecies?(:SHAYMIN) + @heldpkmn.time_form_set = nil + @heldpkmn.form = 0 if @heldpkmn.isSpecies?(:SHAYMIN) @heldpkmn.heal end @scene.pbSwap(selected,@heldpkmn) diff --git a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb index 63fb5a9bd..39246b69a 100644 --- a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb +++ b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb @@ -198,11 +198,11 @@ def pbHatch(pokemon) pokemon.happiness = 120 pokemon.timeEggHatched = pbGetTimeNow pokemon.obtain_method = 1 # hatched from egg - pokemon.hatchedMap = $game_map.map_id + pokemon.hatched_map = $game_map.map_id $Trainer.seen[pokemon.species] = true $Trainer.owned[pokemon.species] = true pbSeenForm(pokemon) - pokemon.pbRecordFirstMoves + pokemon.record_first_moves if !pbHatchAnimation(pokemon) pbMessage(_INTL("Huh?\1")) pbMessage(_INTL("...\1")) @@ -218,15 +218,15 @@ end Events.onStepTaken += proc { |_sender,_e| for egg in $Trainer.party - next if egg.eggsteps<=0 - egg.eggsteps -= 1 + next if egg.steps_to_hatch <= 0 + egg.steps_to_hatch -= 1 for i in $Trainer.pokemonParty next if !i.hasAbility?(:FLAMEBODY) && !i.hasAbility?(:MAGMAARMOR) - egg.eggsteps -= 1 + egg.steps_to_hatch -= 1 break end - if egg.eggsteps<=0 - egg.eggsteps = 0 + if egg.steps_to_hatch <= 0 + egg.steps_to_hatch = 0 pbHatch(egg) end end diff --git a/Data/Scripts/017_UI/021_PScreen_Evolution.rb b/Data/Scripts/017_UI/021_PScreen_Evolution.rb index 8238bc6ea..06d3da956 100644 --- a/Data/Scripts/017_UI/021_PScreen_Evolution.rb +++ b/Data/Scripts/017_UI/021_PScreen_Evolution.rb @@ -608,11 +608,11 @@ class PokemonEvolutionScene def self.pbDuplicatePokemon(pkmn, new_species) new_pkmn = pkmn.clone - new_pkmn.species = new_species - new_pkmn.name = nil - new_pkmn.markings = 0 - new_pkmn.ballused = 0 - new_pkmn.item = nil + new_pkmn.species = new_species + new_pkmn.name = nil + new_pkmn.markings = 0 + new_pkmn.poke_ball = :POKEBALL + new_pkmn.item = nil new_pkmn.clearAllRibbons new_pkmn.calcStats new_pkmn.heal diff --git a/Data/Scripts/017_UI/022_PScreen_Trading.rb b/Data/Scripts/017_UI/022_PScreen_Trading.rb index e7ebda5f7..15a2679f6 100644 --- a/Data/Scripts/017_UI/022_PScreen_Trading.rb +++ b/Data/Scripts/017_UI/022_PScreen_Trading.rb @@ -61,9 +61,17 @@ class PokemonTrade_Scene spriteBall = IconSprite.new(0,0,@viewport) pictureBall = PictureEx.new(0) picturePoke = PictureEx.new(0) + ballimage = sprintf("Graphics/Battle animations/ball_%s", @pokemon.poke_ball) + if !pbResolveBitmap(ballimage) + ballimage = sprintf("Graphics/Battle animations/ball_%02d", pbGetBallType(@pokemon.poke_ball)) + end + ballopenimage = sprintf("Graphics/Battle animations/ball_%s_open", @pokemon.poke_ball) + if !pbResolveBitmap(ballimage) + ballopenimage = sprintf("Graphics/Battle animations/ball_%02d_open", pbGetBallType(@pokemon.poke_ball)) + end # Starting position of ball pictureBall.setXY(0,Graphics.width/2,48) - pictureBall.setName(0,sprintf("Graphics/Battle animations/ball_%02d",@pokemon.ballused)) + pictureBall.setName(0,ballimage) pictureBall.setSrcSize(0,32,64) pictureBall.setOrigin(0,PictureOrigin::Center) pictureBall.setVisible(0,true) @@ -76,7 +84,7 @@ class PokemonTrade_Scene # Recall delay = picturePoke.totalDuration picturePoke.setSE(delay,"Battle recall") - pictureBall.setName(delay,sprintf("Graphics/Battle animations/ball_%02d_open",@pokemon.ballused)) + pictureBall.setName(delay,ballopenimage) pictureBall.setSrcSize(delay,32,64) # Move sprite to ball picturePoke.moveZoom(delay,8,0) @@ -84,7 +92,7 @@ class PokemonTrade_Scene picturePoke.setSE(delay+5,"Battle jump to ball") picturePoke.setVisible(delay+8,false) delay = picturePoke.totalDuration+1 - pictureBall.setName(delay,sprintf("Graphics/Battle animations/ball_%02d",@pokemon.ballused)) + pictureBall.setName(delay,ballimage) pictureBall.setSrcSize(delay,32,64) # Make Poké Ball go off the top of the screen delay = picturePoke.totalDuration+10 @@ -101,9 +109,17 @@ class PokemonTrade_Scene spriteBall = IconSprite.new(0,0,@viewport) pictureBall = PictureEx.new(0) picturePoke = PictureEx.new(0) + ballimage = sprintf("Graphics/Battle animations/ball_%s", @pokemon2.poke_ball) + if !pbResolveBitmap(ballimage) + ballimage = sprintf("Graphics/Battle animations/ball_%02d", pbGetBallType(@pokemon2.poke_ball)) + end + ballopenimage = sprintf("Graphics/Battle animations/ball_%s_open", @pokemon2.poke_ball) + if !pbResolveBitmap(ballimage) + ballopenimage = sprintf("Graphics/Battle animations/ball_%02d_open", pbGetBallType(@pokemon2.poke_ball)) + end # Starting position of ball pictureBall.setXY(0,Graphics.width/2,-32) - pictureBall.setName(0,sprintf("Graphics/Battle animations/ball_%02d",@pokemon2.ballused)) + pictureBall.setName(0,ballimage) pictureBall.setSrcSize(0,32,64) pictureBall.setOrigin(0,PictureOrigin::Center) pictureBall.setVisible(0,true) @@ -132,7 +148,7 @@ class PokemonTrade_Scene # Open Poké Ball delay = pictureBall.totalDuration+15 pictureBall.setSE(delay,"Battle recall") - pictureBall.setName(delay,sprintf("Graphics/Battle animations/ball_%02d_open",@pokemon2.ballused)) + pictureBall.setName(delay,ballopenimage) pictureBall.setSrcSize(delay,32,64) pictureBall.setVisible(delay+5,false) # Pokémon appears and enlarges @@ -211,7 +227,7 @@ def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0) yourPokemon.name = nickname yourPokemon.obtain_method = 2 # traded yourPokemon.resetMoves if resetmoves - yourPokemon.pbRecordFirstMoves + yourPokemon.record_first_moves $Trainer.seen[yourPokemon.species] = true $Trainer.owned[yourPokemon.species] = true pbSeenForm(yourPokemon) diff --git a/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb b/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb index 70d31d1d2..5a8f925c6 100644 --- a/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb +++ b/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb @@ -160,8 +160,8 @@ class MoveRelearnerScreen moves.push(m[1]) if !moves.include?(m[1]) end tmoves = [] - if pkmn.firstmoves - for i in pkmn.firstmoves + if pkmn.first_moves + for i in pkmn.first_moves tmoves.push(i) if !pkmn.hasMove?(i) && !moves.include?(i) end end diff --git a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb index 3f1cc15c2..0cf0068b8 100644 --- a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb +++ b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb @@ -218,7 +218,7 @@ class PurifyChamber def isPurifiableIgnoreRegular?(set) shadow=getShadow(set) return false if !shadow - return false if shadow.heartgauge!=0 + return false if shadow.heart_gauge != 0 # Define an exception for Lugia if shadow.isSpecies?(:LUGIA) maxtempo=PurifyChamber.maximumTempo() @@ -237,7 +237,7 @@ class PurifyChamber for set in 0...NUMSETS # If a shadow Pokemon and a regular Pokemon are on the same set if @sets[set].shadow - if @sets[set].shadow.heartgauge>0 + if @sets[set].shadow.heart_gauge > 0 flow=self.chamberFlow(set) @sets[set].shadow.adjustHeart(-flow) if isPurifiable?(set) @@ -337,7 +337,7 @@ class PurifyChamberScreen @chamber=$PokemonGlobal.purifyChamber # for j in 0...PurifyChamber::NUMSETS # @chamber.debugAddShadow(j,rand(100)+1) -# @chamber[j].shadow.heartgauge=0 +# @chamber[j].shadow.heart_gauge = 0 # for i in 0...PurifyChamber::SETSIZE # @chamber.debugAddNormal(j,rand(100)+1) # end @@ -654,8 +654,8 @@ class Window_PurifyChamberSets < Window_DrawableCommand end if @chamber.getShadow(index) pbDrawGauge(self.contents, Rect.new(rect.x+16,rect.y+18,48,8), - Color.new(192,0,256), @chamber.getShadow(index).heartgauge, - Pokemon::HEARTGAUGESIZE) + Color.new(192,0,256), @chamber.getShadow(index).heart_gauge, + Pokemon::HEART_GAUGE_SIZE) end pbDrawTextPositions(self.contents,textpos) end @@ -945,8 +945,7 @@ class PurifyChamberSetView < SpriteWrapper Color.new(248,248,248),Color.new(128,128,128)]) # draw heart gauge pbDrawGauge(@info.bitmap, Rect.new(@info.bitmap.width*3/4,8,@info.bitmap.width*1/4,8), - Color.new(192,0,256), pkmn.heartgauge, - Pokemon::HEARTGAUGESIZE) + Color.new(192,0,256), pkmn.heart_gauge, Pokemon::HEART_GAUGE_SIZE) # draw flow gauge pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,24+8,@info.bitmap.width*1/4,8), Color.new(0,0,248),@chamber.chamberFlow(@set),6) diff --git a/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb b/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb index ce9d09ed4..07d52209e 100644 --- a/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb +++ b/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb @@ -35,7 +35,7 @@ def pbEditMysteryGift(type,item,id=0,giftname="") if type==0 # Pokémon commands=[_INTL("Mystery Gift"), _INTL("Faraway place")] - commands.push(item.obtainText) if item.obtainText && item.obtainText!="" + commands.push(item.obtain_text) if item.obtain_text && !item.obtain_text.empty? commands.push(_INTL("[Custom]")) loop do command=pbMessage( @@ -43,12 +43,12 @@ def pbEditMysteryGift(type,item,id=0,giftname="") if command<0 return nil if pbConfirmMessage(_INTL("Stop editing this gift?")) elsif command _INTL("Quick Hatch"), "description" => _INTL("Make all eggs in the party require just one more step to hatch."), "effect" => proc { - $Trainer.party.each { |pkmn| pkmn.eggsteps = 1 if pkmn.egg? } + $Trainer.party.each { |pkmn| pkmn.steps_to_hatch = 1 if pkmn.egg? } pbMessage(_INTL("All eggs in your party now require one step to hatch.")) } }) diff --git a/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb b/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb index 66d1dccc6..7182bee2e 100644 --- a/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb +++ b/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb @@ -90,7 +90,7 @@ PokemonDebugMenuCommands.register("setstatus", { break if cmd < 0 case cmd when 0 # Cure - pkmn.healStatus + pkmn.heal_status screen.pbDisplay(_INTL("{1}'s status was cured.", pkmn.name)) screen.pbRefreshSingle(pkmnid) else # Give status problem @@ -510,7 +510,7 @@ PokemonDebugMenuCommands.register("forgetmove", { moveindex = screen.pbChooseMove(pkmn, _INTL("Choose move to forget.")) if moveindex >= 0 movename = pkmn.moves[moveindex].name - pkmn.pbDeleteMoveAtIndex(moveindex) + pkmn.forget_move_at_index(moveindex) screen.pbDisplay(_INTL("{1} forgot {2}.", pkmn.name, movename)) screen.pbRefreshSingle(pkmnid) end @@ -583,7 +583,7 @@ PokemonDebugMenuCommands.register("setmovepp", { end end elsif cmd == commands.length - 1 # Restore all PP - pkmn.healPP + pkmn.heal_PP end end } @@ -594,7 +594,7 @@ PokemonDebugMenuCommands.register("setinitialmoves", { "name" => _INTL("Reset initial moves"), "always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| - pkmn.pbRecordFirstMoves + pkmn.record_first_moves screen.pbDisplay(_INTL("{1}'s moves were set as its first-known moves.", pkmn.name)) screen.pbRefreshSingle(pkmnid) } @@ -710,7 +710,7 @@ PokemonDebugMenuCommands.register("speciesform", { cmd = 0 loop do msg = [_INTL("Species {1}, form {2}.", pkmn.speciesName, pkmn.form), - _INTL("Species {1}, form {2} (forced).", pkmn.speciesName, pkmn.form)][(pkmn.forcedForm != nil) ? 1 : 0] + _INTL("Species {1}, form {2} (forced).", pkmn.speciesName, pkmn.form)][(pkmn.forced_form.nil?) ? 0 : 1] cmd = screen.pbShowCommands(msg, [ _INTL("Set species"), _INTL("Set form"), @@ -746,7 +746,7 @@ PokemonDebugMenuCommands.register("speciesform", { if f != pkmn.form if MultipleForms.hasFunction?(pkmn, "getForm") next if !screen.pbConfirm(_INTL("This species decides its own form. Override?")) - pkmn.forcedForm = f + pkmn.forced_form = f end pkmn.form = f pbSeenForm(pkmn) if !settingUpBattle @@ -754,7 +754,7 @@ PokemonDebugMenuCommands.register("speciesform", { end end when 2 # Remove form override - pkmn.forcedForm = nil + pkmn.forced_form = nil screen.pbRefreshSingle(pkmnid) end end @@ -805,21 +805,21 @@ PokemonDebugMenuCommands.register("setpokeball", { balls = [] for key in $BallTypes.keys item = GameData::Item.try_get($BallTypes[key]) - balls.push([key.to_i, item.name]) if item + balls.push([item.id, item.name]) if item end balls.sort! { |a, b| a[1] <=> b[1] } cmd = 0 for i in 0...balls.length - next if balls[i][0] != pkmn.ballused + next if balls[i][0] != pkmn.poke_ball cmd = i break end balls.each { |ball| commands.push(ball[1]) } loop do - oldball = pbBallTypeToItem(pkmn.ballused).name + oldball = GameData::Item.get(pkmn.poke_ball).name cmd = screen.pbShowCommands(_INTL("{1} used.", oldball), commands, cmd) break if cmd < 0 - pkmn.ballused = balls[cmd][0] + pkmn.poke_ball = balls[cmd][0] end } }) @@ -838,7 +838,7 @@ PokemonDebugMenuCommands.register("setribbons", { end commands.push(_INTL("Give all")) commands.push(_INTL("Clear all")) - cmd = screen.pbShowCommands(_INTL("{1} ribbons.", pkmn.ribbonCount), commands, cmd) + cmd = screen.pbShowCommands(_INTL("{1} ribbons.", pkmn.numRibbons), commands, cmd) break if cmd < 0 if cmd >= 0 && cmd < PBRibbons.maxValue # Toggle ribbon if pkmn.hasRibbon?(cmd + 1) @@ -940,34 +940,34 @@ PokemonDebugMenuCommands.register("setegg", { cmd = 0 loop do msg = [_INTL("Not an egg"), - _INTL("Egg with eggsteps: {1}.", pkmn.eggsteps)][pkmn.egg? ? 1 : 0] + _INTL("Egg (hatches in {1} steps).", pkmn.steps_to_hatch)][pkmn.egg? ? 1 : 0] cmd = screen.pbShowCommands(msg, [ _INTL("Make egg"), _INTL("Make Pokémon"), - _INTL("Set eggsteps to 1")], cmd) + _INTL("Set steps left to 1")], cmd) break if cmd < 0 case cmd when 0 # Make egg if !pkmn.egg? && (pbHasEgg?(pkmn.species) || screen.pbConfirm(_INTL("{1} cannot legally be an egg. Make egg anyway?", pkmn.speciesName))) - pkmn.level = EGG_LEVEL + pkmn.level = EGG_LEVEL pkmn.calcStats - pkmn.name = _INTL("Egg") - pkmn.eggsteps = pkmn.species_data.hatch_steps - pkmn.hatchedMap = 0 - pkmn.obtain_method = 1 + pkmn.name = _INTL("Egg") + pkmn.steps_to_hatch = pkmn.species_data.hatch_steps + pkmn.hatched_map = 0 + pkmn.obtain_method = 1 screen.pbRefreshSingle(pkmnid) end when 1 # Make Pokémon if pkmn.egg? - pkmn.name = nil - pkmn.eggsteps = 0 - pkmn.hatchedMap = 0 - pkmn.obtain_method = 0 + pkmn.name = nil + pkmn.steps_to_hatch = 0 + pkmn.hatched_map = 0 + pkmn.obtain_method = 0 screen.pbRefreshSingle(pkmnid) end - when 2 # Set eggsteps to 1 - pkmn.eggsteps = 1 if pkmn.egg? + when 2 # Set steps left to 1 + pkmn.steps_to_hatch = 1 if pkmn.egg? end end } @@ -981,7 +981,7 @@ PokemonDebugMenuCommands.register("shadowpkmn", { cmd = 0 loop do msg = [_INTL("Not a Shadow Pokémon."), - _INTL("Heart gauge is {1} (stage {2}).", pkmn.heartgauge, pkmn.heartStage) + _INTL("Heart gauge is {1} (stage {2}).", pkmn.heart_gauge, pkmn.heartStage) ][pkmn.shadowPokemon? ? 1 : 0] cmd = screen.pbShowCommands(msg, [ _INTL("Make Shadow"), @@ -997,16 +997,16 @@ PokemonDebugMenuCommands.register("shadowpkmn", { end when 1 # Set heart gauge if pkmn.shadowPokemon? - oldheart = pkmn.heartgauge + oldheart = pkmn.heart_gauge params = ChooseNumberParams.new - params.setRange(0, Pokemon::HEARTGAUGESIZE) - params.setDefaultValue(pkmn.heartgauge) + params.setRange(0, Pokemon::HEART_GAUGE_SIZE) + params.setDefaultValue(pkmn.heart_gauge) val = pbMessageChooseNumber( - _INTL("Set the heart gauge (max. {1}).", Pokemon::HEARTGAUGESIZE), + _INTL("Set the heart gauge (max. {1}).", Pokemon::HEART_GAUGE_SIZE), params) { screen.pbUpdate } if val != oldheart pkmn.adjustHeart(val - oldheart) - pbReadyToPurify(pkmn) + pkmn.check_ready_to_purify end else screen.pbDisplay(_INTL("{1} is not a Shadow Pokémon.", pkmn.name))