More revamping and rearranging

This commit is contained in:
Maruno17
2021-01-23 20:44:07 +00:00
parent 8a89ef1220
commit 7de034957b
38 changed files with 674 additions and 661 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -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

View File

@@ -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