Advertisement
TechSkylander1518

Battle Shadows

Apr 21st, 2021
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 22.45 KB | None | 0 0
  1. class Sprite
  2.    
  3.   def skew(angle=90)
  4.     return false if !self.bitmap
  5.     angle=angle*(Math::PI/180)
  6.     bitmap=self.bitmap
  7.     rect=Rect.new(0,0,bitmap.width,bitmap.height)
  8.     width=rect.width+((rect.height-1)/Math.tan(angle))
  9.     self.bitmap=Bitmap.new(width,rect.height)
  10.     for i in 0...rect.height
  11.       y=rect.height-i
  12.       x=i/Math.tan(angle)
  13.       self.bitmap.blt(x+rect.x,y+rect.y,bitmap,Rect.new(0,y,rect.width,1))
  14.     end
  15.   end
  16.  
  17.  
  18. end
  19.  
  20.  
  21.  
  22. class PokemonBattlerSprite
  23.     #techshadow
  24.   attr_accessor :shadow
  25.   attr_accessor :showshadow
  26.  
  27.  
  28.  
  29.   def initialize(viewport,sideSize,index,battleAnimations)
  30.     super(viewport)
  31.     @pkmn             = nil
  32.     @sideSize         = sideSize
  33.     @index            = index
  34.     @battleAnimations = battleAnimations
  35.     # @selected: 0 = not selected, 1 = choosing action bobbing for this Pokémon,
  36.     #            2 = flashing when targeted
  37.     @selected         = 0
  38.     @frame            = 0
  39.     @updating         = false
  40.     @spriteX          = 0   # Actual x coordinate
  41.     @spriteY          = 0   # Actual y coordinate
  42.     @spriteXExtra     = 0   # Offset due to "bobbing" animation
  43.     @spriteYExtra     = 0   # Offset due to "bobbing" animation
  44.     @_iconBitmap      = nil
  45.     self.visible      = false
  46.     #techshadow
  47.     @shadow           = Sprite.new(viewport)
  48.     @showshadow       = true
  49.   end
  50.  
  51.  
  52.  
  53.   def dispose
  54.     @_iconBitmap.dispose if @_iconBitmap
  55.     #techshadow
  56.     @shadow.dispose if @shadow
  57.     @_iconBitmap = nil
  58.     self.bitmap = nil if !self.disposed?
  59.     super
  60.   end
  61.  
  62.   def x=(value)
  63.     @spriteX = value
  64.     #techshadow
  65.     @shadow.x=value
  66.     self.formatShadow
  67.     super(value+@spriteXExtra)
  68.   end
  69.  
  70.   def y=(value)
  71.     @spriteY = value
  72.     #techshadow
  73.     @shadow.y=value
  74.     self.formatShadow
  75.     super(value+@spriteYExtra)
  76.   end
  77.  
  78.  
  79.   def setPokemonBitmap(pkmn,back=false)
  80.     @pkmn = pkmn
  81.     @_iconBitmap.dispose if @_iconBitmap
  82.     @_iconBitmap = pbLoadPokemonBitmap(@pkmn,back)
  83.     #techshadow
  84.     @shadow.bitmap    = @_iconBitmap.bitmap.clone  
  85.     self.formatShadow
  86.     self.bitmap = (@_iconBitmap) ? @_iconBitmap.bitmap : nil
  87.     pbSetPosition
  88.   end
  89.  
  90.  
  91.   def update(frameCounter=0)
  92.     return if !@_iconBitmap
  93.     @updating = true
  94.     # Update bitmap
  95.     @_iconBitmap.update
  96.     @shadow.bitmap    = @_iconBitmap.bitmap.clone  
  97.     @shadow.update
  98.     self.bitmap = @_iconBitmap.bitmap
  99.     # Pokémon sprite bobbing while Pokémon is selected
  100.     @spriteYExtra = 0
  101.     if @selected==1    # When choosing commands for this Pokémon
  102.       case (frameCounter/QUARTER_ANIM_PERIOD).floor
  103.       when 1; @spriteYExtra = 2
  104.       when 3; @spriteYExtra = -2
  105.       end
  106.     end
  107.     self.x       = self.x
  108.     self.y       = self.y
  109.     self.visible = @spriteVisible
  110.     # Pokémon sprite blinking when targeted
  111.     if @selected==2 && @spriteVisible
  112.       case (frameCounter/SIXTH_ANIM_PERIOD).floor
  113.       when 2, 5; self.visible = false
  114.       else;      self.visible = true
  115.       end
  116.     end
  117.     @updating = false
  118.   end
  119.  
  120.  
  121.   def formatShadow
  122.    @shadow.zoom_x =  self.zoom_x*0.90
  123.     @shadow.zoom_y =  self.zoom_y*0.30
  124.     @shadow.z =  self.z-1
  125.     @shadow.ox = self.ox - 6
  126.     @shadow.oy = self.oy #- 20
  127.     @shadow.opacity =  self.opacity*0.3
  128.     @shadow.tone = Tone.new(-255,-255,-255,255)
  129.     @shadow.visible =  self.visible
  130.     @shadow.mirror =  self.mirror
  131.     @shadow.angle =  self.angle
  132.     @shadow.visible = false if !@showshadow
  133.   end
  134.  
  135.  
  136. end
  137.  
  138.  
  139.  
  140. class PokeballPlayerSendOutAnimation < PokeBattle_Animation
  141.   include PokeBattle_BallAnimationMixin
  142.  
  143.   def initialize(sprites,viewport,idxTrainer,battler,startBattle,idxOrder=0)
  144.     @idxTrainer     = idxTrainer
  145.     @battler        = battler
  146.     @showingTrainer = startBattle
  147.     @idxOrder       = idxOrder
  148.     @trainer        = @battler.battle.pbGetOwnerFromBattlerIndex(@battler.index)
  149.     sprites["pokemon_#{battler.index}"].visible = false
  150.     super(sprites,viewport)
  151.   end
  152.  
  153.   def createProcesses
  154.     batSprite = @sprites["pokemon_#{@battler.index}"]
  155.     traSprite = @sprites["player_#{@idxTrainer}"]
  156.     # Calculate the Poké Ball graphic to use
  157.     ballType = 0
  158.     if !batSprite.pkmn.nil?
  159.       ballType = batSprite.pkmn.ballused || 0
  160.     end
  161.     # Calculate the color to turn the battler sprite
  162.     col = getBattlerColorFromBallType(ballType)
  163.     col.alpha = 255
  164.     # Calculate start and end coordinates for battler sprite movement
  165.     ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize)
  166.     battlerStartX = ballPos[0]   # Is also where the Ball needs to end
  167.     battlerStartY = ballPos[1]   # Is also where the Ball needs to end + 18
  168.     battlerEndX = batSprite.x
  169.     battlerEndY = batSprite.y
  170.     # Calculate start and end coordinates for Poké Ball sprite movement
  171.     ballStartX = -6
  172.     ballStartY = 202
  173.     ballMidX = 0   # Unused in trajectory calculation
  174.     ballMidY = battlerStartY-144
  175.     # Set up Poké Ball sprite
  176.     ball = addBallSprite(ballStartX,ballStartY,ballType)
  177.     ball.setZ(0,25)
  178.     ball.setVisible(0,false)
  179.     # Poké Ball tracking the player's hand animation (if trainer is visible)
  180.     if @showingTrainer && traSprite && traSprite.x>0
  181.       ball.setZ(0,traSprite.z-1)
  182.       ballStartX, ballStartY = ballTracksHand(ball,traSprite)
  183.     end
  184.     delay = ball.totalDuration   # 0 or 7
  185.     # Poké Ball trajectory animation
  186.     createBallTrajectory(ball,delay,12,
  187.        ballStartX,ballStartY,ballMidX,ballMidY,battlerStartX,battlerStartY-18)
  188.     ball.setZ(9,batSprite.z-1)
  189.     delay = ball.totalDuration+4
  190.     delay += 10*@idxOrder   # Stagger appearances if multiple Pokémon are sent out at once
  191.     ballOpenUp(ball,delay-2,ballType)
  192.     ballBurst(delay,battlerStartX,battlerStartY-18,ballType)
  193.     ball.moveOpacity(delay+2,2,0)
  194.     # Set up battler sprite
  195.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  196.     battler.setXY(0,battlerStartX,battlerStartY)
  197.     battler.setZoom(0,0)
  198.     battler.setColor(0,col)
  199.     # Battler animation
  200.     battlerAppear(battler,delay,battlerEndX,battlerEndY,batSprite,col)
  201.     #if @shadowVisible
  202.       # Set up shadow sprite
  203.       batSprite.showshadow = true
  204.       batSprite.formatShadow
  205.       #shadow.setOpacity(0,0)
  206.      # Shadow animation
  207.       #shadow.setVisible(delay,@shadowVisible)
  208.       #shadow.moveOpacity(delay+5,10,255)
  209.    # end
  210.   end
  211. end
  212.  
  213.  
  214. class PokeballTrainerSendOutAnimation < PokeBattle_Animation
  215.   include PokeBattle_BallAnimationMixin
  216.  
  217.   def initialize(sprites,viewport,idxTrainer,battler,startBattle,idxOrder)
  218.     @idxTrainer     = idxTrainer
  219.     @battler        = battler
  220.     @showingTrainer = startBattle
  221.     @idxOrder       = idxOrder
  222.     sprites["pokemon_#{battler.index}"].visible = false
  223.     @shadowVisible = sprites["pokemon_#{battler.index}"].showshadow
  224.     sprites["pokemon_#{battler.index}"].showshadow = false
  225.     super(sprites,viewport)
  226.   end
  227.  
  228.   def createProcesses
  229.     batSprite = @sprites["pokemon_#{@battler.index}"]
  230.     shaSprite = @sprites["pokemon_#{@battler.index}"].shadow
  231.     # Calculate the Poké Ball graphic to use
  232.     ballType = 0
  233.     if !batSprite.pkmn.nil?
  234.       ballType = batSprite.pkmn.ballused || 0
  235.     end
  236.     # Calculate the color to turn the battler sprite
  237.     col = getBattlerColorFromBallType(ballType)
  238.     col.alpha = 255
  239.     # Calculate start and end coordinates for battler sprite movement
  240.     ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize)
  241.     battlerStartX = ballPos[0]
  242.     battlerStartY = ballPos[1]
  243.     battlerEndX = batSprite.x
  244.     battlerEndY = batSprite.y
  245.     # Set up Poké Ball sprite
  246.     ball = addBallSprite(0,0,ballType)
  247.     ball.setZ(0,batSprite.z-1)
  248.     # Poké Ball animation
  249.     createBallTrajectory(ball,battlerStartX,battlerStartY)
  250.     delay = ball.totalDuration+6
  251.     delay += 10 if @showingTrainer   # Give time for trainer to slide off screen
  252.     delay += 10*@idxOrder   # Stagger appearances if multiple Pokémon are sent out at once
  253.     ballOpenUp(ball,delay-2,ballType)
  254.     ballBurst(delay,battlerStartX,battlerStartY-18,ballType)
  255.     ball.moveOpacity(delay+2,2,0)
  256.     # Set up battler sprite
  257.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  258.     battler.setXY(0,battlerStartX,battlerStartY)
  259.     battler.setZoom(0,0)
  260.     battler.setColor(0,col)
  261.     # Battler animation
  262.     battlerAppear(battler,delay,battlerEndX,battlerEndY,batSprite,col)
  263.    # if @shadowVisible
  264.       # Set up shadow sprite
  265.       battler.showsprite = true
  266.       battler.formatShadow
  267.      # shadow.setOpacity(0,0)
  268.      # Shadow animation
  269.      # shadow.setVisible(delay,@shadowVisible)
  270.      # shadow.moveOpacity(delay+5,10,255)
  271.   #  end
  272.   end
  273.  
  274.   def createBallTrajectory(ball,destX,destY)
  275.     # NOTE: In HGSS, there isn't a Poké Ball arc under any circumstance (neither
  276.     #       when throwing out the first Pokémon nor when switching/replacing a
  277.     #       fainted Pokémon). This is probably worth changing.
  278.     ball.setXY(0,destX,destY-4)
  279.   end
  280. end
  281.  
  282.  
  283.  
  284. #===============================================================================
  285. # Shows a Pokémon being recalled into its Poké Ball
  286. #===============================================================================
  287. class BattlerRecallAnimation < PokeBattle_Animation
  288.   include PokeBattle_BallAnimationMixin
  289.  
  290.   def initialize(sprites,viewport,idxBattler)
  291.     @idxBattler = idxBattler
  292.     super(sprites,viewport)
  293.   end
  294.  
  295.   def createProcesses
  296.     batSprite = @sprites["pokemon_#{@idxBattler}"]
  297.     shaSprite = @sprites["pokemon_#{@idxBattler}"].shadow
  298.     # Calculate the Poké Ball graphic to use
  299.     ballType = 0
  300.     if !batSprite.pkmn.nil?
  301.       ballType = batSprite.pkmn.ballused || 0
  302.     end
  303.     # Calculate the color to turn the battler sprite
  304.     col = getBattlerColorFromBallType(ballType)
  305.     col.alpha = 0
  306.     # Calculate end coordinates for battler sprite movement
  307.     ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,batSprite.sideSize)
  308.     battlerEndX = ballPos[0]
  309.     battlerEndY = ballPos[1]
  310.     # Set up battler sprite
  311.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  312.     battler.setVisible(0,true)
  313.     battler.setColor(0,col)
  314.     # Set up Poké Ball sprite
  315.     ball = addBallSprite(battlerEndX,battlerEndY,ballType)
  316.     ball.setZ(0,batSprite.z+1)
  317.     # Poké Ball animation
  318.     ballOpenUp(ball,0,ballType)
  319.     delay = ball.totalDuration
  320.     ballBurstRecall(delay,battlerEndX,battlerEndY,ballType)
  321.     ball.moveOpacity(10,2,0)
  322.     # Battler animation
  323.     battlerAbsorb(battler,delay,battlerEndX,battlerEndY,col)
  324.     if batSprite.showshadow
  325.       # Set up shadow sprite
  326.       batSprite.formatShadow
  327.       # Shadow animation
  328.      # shadow.moveOpacity(0,10,0)
  329.     #  shadow.setVisible(delay,false)
  330.    end
  331.   end
  332. end
  333.  
  334.  
  335. #===============================================================================
  336. # Shows a Pokémon flashing after taking damage
  337. #===============================================================================
  338. class BattlerDamageAnimation < PokeBattle_Animation
  339.   def initialize(sprites,viewport,idxBattler,effectiveness)
  340.     @idxBattler    = idxBattler
  341.     @effectiveness = effectiveness
  342.     super(sprites,viewport)
  343.   end
  344.  
  345.   def createProcesses
  346.     batSprite = @sprites["pokemon_#{@idxBattler}"]
  347.     # Set up battler/shadow sprite
  348.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  349.     # Animation
  350.     delay = 0
  351.     case @effectiveness
  352.     when 0; battler.setSE(delay,"Battle damage normal")
  353.     when 1; battler.setSE(delay,"Battle damage weak")
  354.     when 2; battler.setSE(delay,"Battle damage super")
  355.     end
  356.     4.times do   # 4 flashes, each lasting 0.2 (4/20) seconds
  357.       battler.setVisible(delay,false)
  358.       battler.setVisible(delay+2,true) if batSprite.visible
  359.       delay += 4
  360.     end
  361.     # Restore original battler/shadow sprites visibilities
  362.     battler.setVisible(delay,batSprite.visible)
  363.   end
  364. end
  365.  
  366.  
  367.  
  368. #===============================================================================
  369. # Shows a Pokémon fainting
  370. #===============================================================================
  371. class BattlerFaintAnimation < PokeBattle_Animation
  372.   def initialize(sprites,viewport,idxBattler,battle)
  373.     @idxBattler = idxBattler
  374.     @battle     = battle
  375.     super(sprites,viewport)
  376.   end
  377.  
  378.   def createProcesses
  379.     batSprite = @sprites["pokemon_#{@idxBattler}"]
  380.     shaSprite = @sprites["pokemon_#{@idxBattler}"].shadow
  381.     # Set up battler/shadow sprite
  382.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  383.     batSprite.formatShadow
  384.     # Get approx duration depending on sprite's position/size. Min 20 frames.
  385.     battlerTop = batSprite.y-batSprite.height
  386.     cropY = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,
  387.        @battle.pbSideSize(@idxBattler))[1]
  388.     cropY += 8
  389.     duration = (cropY-battlerTop)/8
  390.     duration = 10 if duration<10   # Min 0.5 seconds
  391.     # Animation
  392.     # Play cry
  393.     delay = 10
  394.     cry = pbCryFile(batSprite.pkmn)
  395.     if cry
  396.       battler.setSE(0,pbCryFile(batSprite.pkmn),nil,75)   # 75 is pitch
  397.       delay = pbCryFrameLength(batSprite.pkmn)*20/Graphics.frame_rate
  398.     end
  399.     # Sprite drops down
  400.    # shaSprite.setVisible(delay,false)
  401.     battler.setSE(delay,"Pkmn faint")
  402.     battler.moveOpacity(delay,duration,0)
  403.     battler.moveDelta(delay,duration,0,cropY-battlerTop)
  404.     battler.setCropBottom(delay,cropY)
  405.     battler.setVisible(delay+duration,false)
  406.     battler.setOpacity(delay+duration,255)
  407.   end
  408. end
  409.  
  410.  
  411.  
  412. #===============================================================================
  413. # Shows the player's Poké Ball being thrown to capture a Pokémon
  414. #===============================================================================
  415. class PokeballThrowCaptureAnimation < PokeBattle_Animation
  416.   include PokeBattle_BallAnimationMixin
  417.  
  418.   def initialize(sprites,viewport,
  419.                  ballType,numShakes,critCapture,battler,showingTrainer)
  420.     @ballType       = ballType
  421.     @numShakes      = (critCapture) ? 1 : numShakes
  422.     @critCapture    = critCapture
  423.     @battler        = battler
  424.     @showingTrainer = showingTrainer    # Only true if a Safari Zone battle
  425.     @shadowVisible  = sprites["pokemon_#{battler.index}"].showshadow
  426.     @trainer        = battler.battle.pbPlayer
  427.     super(sprites,viewport)
  428.   end
  429.  
  430.   def createProcesses
  431.     # Calculate start and end coordinates for battler sprite movement
  432.     batSprite = @sprites["pokemon_#{@battler.index}"]
  433.     traSprite = @sprites["player_1"]
  434.     ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize)
  435.     battlerStartX = batSprite.x
  436.     battlerStartY = batSprite.y
  437.     ballStartX = -6
  438.     ballStartY = 246
  439.     ballMidX   = 0   # Unused in arc calculation
  440.     ballMidY   = 78
  441.     ballEndX   = ballPos[0]
  442.     ballEndY   = 112
  443.     ballGroundY = ballPos[1]-4
  444.     # Set up Poké Ball sprite
  445.     ball = addBallSprite(ballStartX,ballStartY,@ballType)
  446.     ball.setZ(0,batSprite.z+1)
  447.     @ballSpriteIndex = (@numShakes>=4 || @critCapture) ? @tempSprites.length-1 : -1
  448.     # Set up trainer sprite (only visible in Safari Zone battles)
  449.     if @showingTrainer && traSprite
  450.       if traSprite.bitmap.width>=traSprite.bitmap.height*2
  451.         trainer = addSprite(traSprite,PictureOrigin::Bottom)
  452.         # Trainer animation
  453.         ballStartX, ballStartY = trainerThrowingFrames(ball,trainer,traSprite)
  454.       end
  455.     end
  456.     delay = ball.totalDuration   # 0 or 7
  457.     # Poké Ball arc animation
  458.     ball.setSE(delay,"Battle throw")
  459.     createBallTrajectory(ball,delay,16,
  460.        ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY)
  461.     ball.setZ(9,batSprite.z+1)
  462.     ball.setSE(delay+16,"Battle ball hit")
  463.     # Poké Ball opens up
  464.     delay = ball.totalDuration+6
  465.     ballOpenUp(ball,delay,@ballType,true,false)
  466.     # Set up battler sprite
  467.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  468.     # Poké Ball absorbs battler
  469.     delay = ball.totalDuration
  470.     ballBurstCapture(delay,ballEndX,ballEndY,@ballType)
  471.     delay = ball.totalDuration+4
  472.     # NOTE: The Pokémon does not change color while being absorbed into a Poké
  473.     #       Ball during a capture attempt. This may be an oversight in HGSS.
  474.     battler.setSE(delay,"Battle jump to ball")
  475.     battler.moveXY(delay,5,ballEndX,ballEndY)
  476.     battler.moveZoom(delay,5,0)
  477.     battler.setVisible(delay+5,false)
  478.    # if @shadowVisible
  479.       # Set up shadow sprite
  480.    #   shadow = addSprite(shaSprite,PictureOrigin::Center)
  481.       # Shadow animation
  482.    #   shadow.moveOpacity(delay,5,0)
  483.    #   shadow.moveZoom(delay,5,0)
  484.    #   shadow.setVisible(delay+5,false)
  485.    # end
  486.     # Poké Ball closes
  487.     delay = battler.totalDuration
  488.     ballSetClosed(ball,delay,@ballType)
  489.     ball.moveTone(delay,3,Tone.new(96,64,-160,160))
  490.     ball.moveTone(delay+5,3,Tone.new(0,0,0,0))
  491.     # Poké Ball critical capture animation
  492.     delay = ball.totalDuration+3
  493.     if @critCapture
  494.       ball.setSE(delay,"Battle ball shake")
  495.       ball.moveXY(delay,1,ballEndX+4,ballEndY)
  496.       ball.moveXY(delay+1,2,ballEndX-4,ballEndY)
  497.       ball.moveXY(delay+3,2,ballEndX+4,ballEndY)
  498.       ball.setSE(delay+4,"Battle ball shake")
  499.       ball.moveXY(delay+5,2,ballEndX-4,ballEndY)
  500.       ball.moveXY(delay+7,1,ballEndX,ballEndY)
  501.       delay = ball.totalDuration+3
  502.     end
  503.     # Poké Ball drops to the ground
  504.     for i in 0...4
  505.       t = [4,4,3,2][i]   # Time taken to rise or fall for each bounce
  506.       d = [1,2,4,8][i]   # Fraction of the starting height each bounce rises to
  507.       delay -= t if i==0
  508.       if i>0
  509.         ball.setZoomXY(delay,100+5*(5-i),100-5*(5-i))   # Squish
  510.         ball.moveZoom(delay,2,100)                      # Unsquish
  511.         ball.moveXY(delay,t,ballEndX,ballGroundY-(ballGroundY-ballEndY)/d)
  512.       end
  513.       ball.moveXY(delay+t,t,ballEndX,ballGroundY)
  514.       ball.setSE(delay+2*t,"Battle ball drop",100-i*7)
  515.       delay = ball.totalDuration
  516.     end
  517.     battler.setXY(ball.totalDuration,ballEndX,ballGroundY)
  518.     # Poké Ball shakes
  519.     delay = ball.totalDuration+12
  520.     for i in 0...[@numShakes,3].min
  521.       ball.setSE(delay,"Battle ball shake")
  522.       ball.moveXY(delay,2,ballEndX-2*(4-i),ballGroundY)
  523.       ball.moveAngle(delay,2,5*(4-i))   # positive means counterclockwise
  524.       ball.moveXY(delay+2,4,ballEndX+2*(4-i),ballGroundY)
  525.       ball.moveAngle(delay+2,4,-5*(4-i))   # negative means clockwise
  526.       ball.moveXY(delay+6,2,ballEndX,ballGroundY)
  527.       ball.moveAngle(delay+6,2,0)
  528.       delay = ball.totalDuration+8
  529.     end
  530.     if @numShakes==0 || (@numShakes<4 && !@critCapture)
  531.       # Poké Ball opens
  532.       ball.setZ(delay,batSprite.z-1)
  533.       ballOpenUp(ball,delay,@ballType,false)
  534.       ballBurst(delay,ballEndX,ballGroundY,@ballType)
  535.       ball.moveOpacity(delay+2,2,0)
  536.       # Battler emerges
  537.       col = getBattlerColorFromBallType(@ballType)
  538.       col.alpha = 255
  539.       battler.setColor(delay,col)
  540.       battlerAppear(battler,delay,battlerStartX,battlerStartY,batSprite,col)
  541.      # if @shadowVisible
  542.     #    shadow.setVisible(delay+5,true)
  543.      #   shadow.setZoom(delay+5,100)
  544.     #    shadow.moveOpacity(delay+5,10,255)
  545.     #  end
  546.     else
  547.       # Pokémon was caught
  548.       ballCaptureSuccess(ball,delay,ballEndX,ballGroundY)
  549.     end
  550.   end
  551.  
  552.   def dispose
  553.     if @ballSpriteIndex>=0
  554.       # Capture was successful, the Poké Ball sprite should stay around after
  555.       # this animation has finished.
  556.       @sprites["captureBall"] = @tempSprites[@ballSpriteIndex]
  557.       @tempSprites[@ballSpriteIndex] = nil
  558.     end
  559.     super
  560.   end
  561. end
  562.  
  563.  
  564.  
  565. class BattleIntroAnimation < PokeBattle_Animation
  566.  
  567.   def createProcesses
  568.     appearTime = 20   # This is in 1/20 seconds
  569.     # Background
  570.     if @sprites["battle_bg2"]
  571.       makeSlideSprite("battle_bg",0.5,appearTime)
  572.       makeSlideSprite("battle_bg2",0.5,appearTime)
  573.     end
  574.     # Bases
  575.     makeSlideSprite("base_0",1,appearTime,PictureOrigin::Bottom)
  576.     makeSlideSprite("base_1",-1,appearTime,PictureOrigin::Center)
  577.     # Player sprite, partner trainer sprite
  578.     @battle.player.each_with_index do |_p,i|
  579.       makeSlideSprite("player_#{i+1}",1,appearTime,PictureOrigin::Bottom)
  580.     end
  581.     # Opposing trainer sprite(s) or wild Pokémon sprite(s)
  582.     if @battle.trainerBattle?
  583.       @battle.opponent.each_with_index do |_p,i|
  584.         makeSlideSprite("trainer_#{i+1}",-1,appearTime,PictureOrigin::Bottom)
  585.       end
  586.     else   # Wild battle
  587.       @battle.pbParty(1).each_with_index do |_pkmn,i|
  588.         idxBattler = 2*i+1
  589.         makeSlideSprite("pokemon_#{idxBattler}",-1,appearTime,PictureOrigin::Bottom)
  590.       end
  591.     end
  592.     # Fading blackness over whole screen
  593.     blackScreen = addNewSprite(0,0,"Graphics/Battle animations/black_screen")
  594.     blackScreen.setZ(0,999)
  595.     blackScreen.moveOpacity(0,8,0)
  596.     # Fading blackness over command bar
  597.     blackBar = addNewSprite(@sprites["cmdBar_bg"].x,@sprites["cmdBar_bg"].y,
  598.        "Graphics/Battle animations/black_bar")
  599.     blackBar.setZ(0,998)
  600.     blackBar.moveOpacity(appearTime*3/4,appearTime/4,0)
  601.   end
  602.  
  603. end
  604.  
  605.  
  606.  
  607.  
  608. class PokeBattle_Scene
  609.   def pbFrameUpdate(cw=nil)
  610.     cw.update if cw
  611.     @battle.battlers.each_with_index do |b,i|
  612.       next if !b
  613.       @sprites["dataBox_#{i}"].update(@frameCounter) if @sprites["dataBox_#{i}"]
  614.       @sprites["pokemon_#{i}"].update(@frameCounter) if @sprites["pokemon_#{i}"]
  615.     end
  616.   end
  617.  
  618.  
  619.   # Used by Ally Switch.
  620.   def pbSwapBattlerSprites(idxA,idxB)
  621.     @sprites["pokemon_#{idxA}"], @sprites["pokemon_#{idxB}"] = @sprites["pokemon_#{idxB}"], @sprites["pokemon_#{idxA}"]
  622.     @lastCmd[idxA], @lastCmd[idxB] = @lastCmd[idxB], @lastCmd[idxA]
  623.     @lastMove[idxA], @lastMove[idxB] = @lastMove[idxB], @lastMove[idxA]
  624.     [idxA,idxB].each do |i|
  625.       @sprites["pokemon_#{i}"].index = i
  626.       @sprites["pokemon_#{i}"].pbSetPosition
  627.       @sprites["shadow_#{i}"].pbSetPosition
  628.       @sprites["dataBox_#{i}"].battler = @battle.battlers[i]
  629.     end
  630.     pbRefresh
  631.   end
  632.  
  633.  
  634.   def pbChangePokemon(idxBattler,pkmn)
  635.     idxBattler = idxBattler.index if idxBattler.respond_to?("index")
  636.     pkmnSprite   = @sprites["pokemon_#{idxBattler}"]
  637.     back = !@battle.opposes?(idxBattler)
  638.     pkmnSprite.setPokemonBitmap(pkmn,back)
  639.     pkmnSprite.formatShadow
  640.     # Set visibility of battler's shadow
  641.     if !back
  642.       pkmnSprite.showshadow = showShadow?(pkmn.fSpecies)
  643.     end
  644.   end
  645.  
  646.  
  647.   def pbCreatePokemonSprite(idxBattler)
  648.     sideSize = @battle.pbSideSize(idxBattler)
  649.     batSprite = PokemonBattlerSprite.new(@viewport,sideSize,idxBattler,@animations)
  650.     batSprite.showshadow = false
  651.     @sprites["pokemon_#{idxBattler}"] = batSprite
  652.   end
  653.  
  654. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement