TechSkylander1518

Battle Shadows with Following EX

Apr 29th, 2021
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 23.89 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. #-------------------------------------------------------------------------------
  215. # New sendout animation for Followers to slide in when sent out for the 1st time in battle
  216. #-------------------------------------------------------------------------------
  217. class PokeballPlayerSendOutAnimation < PokeBattle_Animation
  218.   include PokeBattle_BallAnimationMixin
  219.  
  220.   def initialize(sprites,viewport,idxTrainer,battler,startBattle,idxOrder=0)
  221.     @idxTrainer     = idxTrainer
  222.     @battler        = battler
  223.     @showingTrainer = startBattle
  224.     @idxOrder       = idxOrder
  225.     @trainer        = @battler.battle.pbGetOwnerFromBattlerIndex(@battler.index)
  226.     @followAnim     = false
  227.     @followAnim     = true if $PokemonTemp.dependentEvents.refresh_sprite(false,true) && battler.index == 0 && startBattle
  228.     sprites["pokemon_#{battler.index}"].visible = false
  229.    # @shadowVisible = sprites["shadow_#{battler.index}"].visible
  230.    # sprites["shadow_#{battler.index}"].visible = false
  231.     super(sprites,viewport)
  232.   end
  233.  
  234.   def createProcesses
  235.     batSprite = @sprites["pokemon_#{@battler.index}"]
  236.    # shaSprite = @sprites["shadow_#{@battler.index}"]
  237.     traSprite = @sprites["player_#{@idxTrainer}"]
  238.     # Calculate the Poké Ball graphic to use
  239.     ballType = 0
  240.     if !batSprite.pkmn.nil?
  241.       ballType = batSprite.pkmn.ballused || 0
  242.     end
  243.     # Calculate the color to turn the battler sprite
  244.     col = getBattlerColorFromBallType(ballType)
  245.     col.alpha = 255
  246.     # Calculate start and end coordinates for battler sprite movement
  247.     ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize)
  248.     battlerStartX = ballPos[0]   # Is also where the Ball needs to end
  249.     battlerStartY = ballPos[1]   # Is also where the Ball needs to end + 18
  250.     battlerEndX = batSprite.x
  251.     battlerEndY = batSprite.y
  252.     # Calculate start and end coordinates for Poké Ball sprite movement
  253.     ballStartX = -6
  254.     ballStartY = 202
  255.     ballMidX = 0   # Unused in trajectory calculation
  256.     ballMidY = battlerStartY-144
  257.     # Set up Poké Ball sprite
  258.     ball = addBallSprite(ballStartX,ballStartY,ballType)
  259.     ball.setZ(0,25)
  260.     ball.setVisible(0,false)
  261.     # Poké Ball tracking the player's hand animation (if trainer is visible)
  262.     if @showingTrainer && !@followAnim && traSprite && traSprite.x>0
  263.       ball.setZ(0,traSprite.z-1)
  264.       ballStartX, ballStartY = ballTracksHand(ball,traSprite)
  265.     end
  266.     delay = ball.totalDuration   # 0 or 7
  267.     # Poké Ball trajectory animation
  268.     createBallTrajectory(ball,delay,12,
  269.        ballStartX,ballStartY,ballMidX,ballMidY,battlerStartX,battlerStartY-18) if !@followAnim
  270.     ball.setZ(9,batSprite.z-1)
  271.     delay = ball.totalDuration+4
  272.     delay += 10*@idxOrder   # Stagger appearances if multiple Pokémon are sent out at once
  273.     if !@followAnim
  274.       ballOpenUp(ball,delay-2,ballType)
  275.       ballBurst(delay,battlerStartX,battlerStartY-18,ballType)
  276.       ball.moveOpacity(delay+2,2,0)
  277.     end
  278.     # Set up battler sprite
  279.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  280.     if !@followAnim
  281.       battler.setXY(0,battlerStartX,battlerStartY)
  282.       battler.setZoom(0,0)
  283.       battler.setColor(0,col)
  284.       # Battler animation
  285.       battlerAppear(battler,delay,battlerEndX,battlerEndY,batSprite,col)
  286.     else
  287.       battler.setVisible(delay-ball.totalDuration,true)
  288.       battler.setOpacity(delay-ball.totalDuration,255)
  289.       battler.setXY(0,-192,battlerEndY)
  290.       battler.moveXY(delay-ball.totalDuration+1,16,battlerStartX,battlerEndY)
  291.       battler.setSE(delay-ball.totalDuration+18,"GUI naming tab swap start",100)
  292.       battler.setCallback(delay-ball.totalDuration+18,[batSprite,:pbPlayIntroAnimation])
  293.     end
  294.    # if @shadowVisible
  295.       # Set up shadow sprite
  296.       battler.showsprite = true
  297.       battler.formatShadow
  298.     #  shadow = addSprite(shaSprite,PictureOrigin::Center)
  299.      # shadow.setOpacity(0,0)
  300.       # Shadow animation
  301.     # shadow.setVisible(delay,@shadowVisible)
  302.      # shadow.moveOpacity(delay+5,10,255)
  303.     end
  304.   end
  305. end
  306.  
  307.  
  308. #===============================================================================
  309. # Shows a Pokémon being recalled into its Poké Ball
  310. #===============================================================================
  311. class BattlerRecallAnimation < PokeBattle_Animation
  312.   include PokeBattle_BallAnimationMixin
  313.  
  314.   def initialize(sprites,viewport,idxBattler)
  315.     @idxBattler = idxBattler
  316.     super(sprites,viewport)
  317.   end
  318.  
  319.   def createProcesses
  320.     batSprite = @sprites["pokemon_#{@idxBattler}"]
  321.     shaSprite = @sprites["pokemon_#{@idxBattler}"].shadow
  322.     # Calculate the Poké Ball graphic to use
  323.     ballType = 0
  324.     if !batSprite.pkmn.nil?
  325.       ballType = batSprite.pkmn.ballused || 0
  326.     end
  327.     # Calculate the color to turn the battler sprite
  328.     col = getBattlerColorFromBallType(ballType)
  329.     col.alpha = 0
  330.     # Calculate end coordinates for battler sprite movement
  331.     ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,batSprite.sideSize)
  332.     battlerEndX = ballPos[0]
  333.     battlerEndY = ballPos[1]
  334.     # Set up battler sprite
  335.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  336.     battler.setVisible(0,true)
  337.     battler.setColor(0,col)
  338.     # Set up Poké Ball sprite
  339.     ball = addBallSprite(battlerEndX,battlerEndY,ballType)
  340.     ball.setZ(0,batSprite.z+1)
  341.     # Poké Ball animation
  342.     ballOpenUp(ball,0,ballType)
  343.     delay = ball.totalDuration
  344.     ballBurstRecall(delay,battlerEndX,battlerEndY,ballType)
  345.     ball.moveOpacity(10,2,0)
  346.     # Battler animation
  347.     battlerAbsorb(battler,delay,battlerEndX,battlerEndY,col)
  348.     if batSprite.showshadow
  349.       # Set up shadow sprite
  350.       batSprite.formatShadow
  351.       # Shadow animation
  352.      # shadow.moveOpacity(0,10,0)
  353.     #  shadow.setVisible(delay,false)
  354.    end
  355.   end
  356. end
  357.  
  358.  
  359. #===============================================================================
  360. # Shows a Pokémon flashing after taking damage
  361. #===============================================================================
  362. class BattlerDamageAnimation < PokeBattle_Animation
  363.   def initialize(sprites,viewport,idxBattler,effectiveness)
  364.     @idxBattler    = idxBattler
  365.     @effectiveness = effectiveness
  366.     super(sprites,viewport)
  367.   end
  368.  
  369.   def createProcesses
  370.     batSprite = @sprites["pokemon_#{@idxBattler}"]
  371.     # Set up battler/shadow sprite
  372.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  373.     # Animation
  374.     delay = 0
  375.     case @effectiveness
  376.     when 0; battler.setSE(delay,"Battle damage normal")
  377.     when 1; battler.setSE(delay,"Battle damage weak")
  378.     when 2; battler.setSE(delay,"Battle damage super")
  379.     end
  380.     4.times do   # 4 flashes, each lasting 0.2 (4/20) seconds
  381.       battler.setVisible(delay,false)
  382.       battler.setVisible(delay+2,true) if batSprite.visible
  383.       delay += 4
  384.     end
  385.     # Restore original battler/shadow sprites visibilities
  386.     battler.setVisible(delay,batSprite.visible)
  387.   end
  388. end
  389.  
  390.  
  391.  
  392. #===============================================================================
  393. # Shows a Pokémon fainting
  394. #===============================================================================
  395. class BattlerFaintAnimation < PokeBattle_Animation
  396.   def initialize(sprites,viewport,idxBattler,battle)
  397.     @idxBattler = idxBattler
  398.     @battle     = battle
  399.     super(sprites,viewport)
  400.   end
  401.  
  402.   def createProcesses
  403.     batSprite = @sprites["pokemon_#{@idxBattler}"]
  404.     shaSprite = @sprites["pokemon_#{@idxBattler}"].shadow
  405.     # Set up battler/shadow sprite
  406.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  407.     batSprite.formatShadow
  408.     # Get approx duration depending on sprite's position/size. Min 20 frames.
  409.     battlerTop = batSprite.y-batSprite.height
  410.     cropY = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,
  411.        @battle.pbSideSize(@idxBattler))[1]
  412.     cropY += 8
  413.     duration = (cropY-battlerTop)/8
  414.     duration = 10 if duration<10   # Min 0.5 seconds
  415.     # Animation
  416.     # Play cry
  417.     delay = 10
  418.     cry = pbCryFile(batSprite.pkmn)
  419.     if cry
  420.       battler.setSE(0,pbCryFile(batSprite.pkmn),nil,75)   # 75 is pitch
  421.       delay = pbCryFrameLength(batSprite.pkmn)*20/Graphics.frame_rate
  422.     end
  423.     # Sprite drops down
  424.    # shaSprite.setVisible(delay,false)
  425.     battler.setSE(delay,"Pkmn faint")
  426.     battler.moveOpacity(delay,duration,0)
  427.     battler.moveDelta(delay,duration,0,cropY-battlerTop)
  428.     battler.setCropBottom(delay,cropY)
  429.     battler.setVisible(delay+duration,false)
  430.     battler.setOpacity(delay+duration,255)
  431.   end
  432. end
  433.  
  434.  
  435.  
  436. #===============================================================================
  437. # Shows the player's Poké Ball being thrown to capture a Pokémon
  438. #===============================================================================
  439. class PokeballThrowCaptureAnimation < PokeBattle_Animation
  440.   include PokeBattle_BallAnimationMixin
  441.  
  442.   def initialize(sprites,viewport,
  443.                  ballType,numShakes,critCapture,battler,showingTrainer)
  444.     @ballType       = ballType
  445.     @numShakes      = (critCapture) ? 1 : numShakes
  446.     @critCapture    = critCapture
  447.     @battler        = battler
  448.     @showingTrainer = showingTrainer    # Only true if a Safari Zone battle
  449.     @shadowVisible  = sprites["pokemon_#{battler.index}"].showshadow
  450.     @trainer        = battler.battle.pbPlayer
  451.     super(sprites,viewport)
  452.   end
  453.  
  454.   def createProcesses
  455.     # Calculate start and end coordinates for battler sprite movement
  456.     batSprite = @sprites["pokemon_#{@battler.index}"]
  457.     traSprite = @sprites["player_1"]
  458.     ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize)
  459.     battlerStartX = batSprite.x
  460.     battlerStartY = batSprite.y
  461.     ballStartX = -6
  462.     ballStartY = 246
  463.     ballMidX   = 0   # Unused in arc calculation
  464.     ballMidY   = 78
  465.     ballEndX   = ballPos[0]
  466.     ballEndY   = 112
  467.     ballGroundY = ballPos[1]-4
  468.     # Set up Poké Ball sprite
  469.     ball = addBallSprite(ballStartX,ballStartY,@ballType)
  470.     ball.setZ(0,batSprite.z+1)
  471.     @ballSpriteIndex = (@numShakes>=4 || @critCapture) ? @tempSprites.length-1 : -1
  472.     # Set up trainer sprite (only visible in Safari Zone battles)
  473.     if @showingTrainer && traSprite
  474.       if traSprite.bitmap.width>=traSprite.bitmap.height*2
  475.         trainer = addSprite(traSprite,PictureOrigin::Bottom)
  476.         # Trainer animation
  477.         ballStartX, ballStartY = trainerThrowingFrames(ball,trainer,traSprite)
  478.       end
  479.     end
  480.     delay = ball.totalDuration   # 0 or 7
  481.     # Poké Ball arc animation
  482.     ball.setSE(delay,"Battle throw")
  483.     createBallTrajectory(ball,delay,16,
  484.        ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY)
  485.     ball.setZ(9,batSprite.z+1)
  486.     ball.setSE(delay+16,"Battle ball hit")
  487.     # Poké Ball opens up
  488.     delay = ball.totalDuration+6
  489.     ballOpenUp(ball,delay,@ballType,true,false)
  490.     # Set up battler sprite
  491.     battler = addSprite(batSprite,PictureOrigin::Bottom)
  492.     # Poké Ball absorbs battler
  493.     delay = ball.totalDuration
  494.     ballBurstCapture(delay,ballEndX,ballEndY,@ballType)
  495.     delay = ball.totalDuration+4
  496.     # NOTE: The Pokémon does not change color while being absorbed into a Poké
  497.     #       Ball during a capture attempt. This may be an oversight in HGSS.
  498.     battler.setSE(delay,"Battle jump to ball")
  499.     battler.moveXY(delay,5,ballEndX,ballEndY)
  500.     battler.moveZoom(delay,5,0)
  501.     battler.setVisible(delay+5,false)
  502.    # if @shadowVisible
  503.       # Set up shadow sprite
  504.    #   shadow = addSprite(shaSprite,PictureOrigin::Center)
  505.       # Shadow animation
  506.    #   shadow.moveOpacity(delay,5,0)
  507.    #   shadow.moveZoom(delay,5,0)
  508.    #   shadow.setVisible(delay+5,false)
  509.    # end
  510.     # Poké Ball closes
  511.     delay = battler.totalDuration
  512.     ballSetClosed(ball,delay,@ballType)
  513.     ball.moveTone(delay,3,Tone.new(96,64,-160,160))
  514.     ball.moveTone(delay+5,3,Tone.new(0,0,0,0))
  515.     # Poké Ball critical capture animation
  516.     delay = ball.totalDuration+3
  517.     if @critCapture
  518.       ball.setSE(delay,"Battle ball shake")
  519.       ball.moveXY(delay,1,ballEndX+4,ballEndY)
  520.       ball.moveXY(delay+1,2,ballEndX-4,ballEndY)
  521.       ball.moveXY(delay+3,2,ballEndX+4,ballEndY)
  522.       ball.setSE(delay+4,"Battle ball shake")
  523.       ball.moveXY(delay+5,2,ballEndX-4,ballEndY)
  524.       ball.moveXY(delay+7,1,ballEndX,ballEndY)
  525.       delay = ball.totalDuration+3
  526.     end
  527.     # Poké Ball drops to the ground
  528.     for i in 0...4
  529.       t = [4,4,3,2][i]   # Time taken to rise or fall for each bounce
  530.       d = [1,2,4,8][i]   # Fraction of the starting height each bounce rises to
  531.       delay -= t if i==0
  532.       if i>0
  533.         ball.setZoomXY(delay,100+5*(5-i),100-5*(5-i))   # Squish
  534.         ball.moveZoom(delay,2,100)                      # Unsquish
  535.         ball.moveXY(delay,t,ballEndX,ballGroundY-(ballGroundY-ballEndY)/d)
  536.       end
  537.       ball.moveXY(delay+t,t,ballEndX,ballGroundY)
  538.       ball.setSE(delay+2*t,"Battle ball drop",100-i*7)
  539.       delay = ball.totalDuration
  540.     end
  541.     battler.setXY(ball.totalDuration,ballEndX,ballGroundY)
  542.     # Poké Ball shakes
  543.     delay = ball.totalDuration+12
  544.     for i in 0...[@numShakes,3].min
  545.       ball.setSE(delay,"Battle ball shake")
  546.       ball.moveXY(delay,2,ballEndX-2*(4-i),ballGroundY)
  547.       ball.moveAngle(delay,2,5*(4-i))   # positive means counterclockwise
  548.       ball.moveXY(delay+2,4,ballEndX+2*(4-i),ballGroundY)
  549.       ball.moveAngle(delay+2,4,-5*(4-i))   # negative means clockwise
  550.       ball.moveXY(delay+6,2,ballEndX,ballGroundY)
  551.       ball.moveAngle(delay+6,2,0)
  552.       delay = ball.totalDuration+8
  553.     end
  554.     if @numShakes==0 || (@numShakes<4 && !@critCapture)
  555.       # Poké Ball opens
  556.       ball.setZ(delay,batSprite.z-1)
  557.       ballOpenUp(ball,delay,@ballType,false)
  558.       ballBurst(delay,ballEndX,ballGroundY,@ballType)
  559.       ball.moveOpacity(delay+2,2,0)
  560.       # Battler emerges
  561.       col = getBattlerColorFromBallType(@ballType)
  562.       col.alpha = 255
  563.       battler.setColor(delay,col)
  564.       battlerAppear(battler,delay,battlerStartX,battlerStartY,batSprite,col)
  565.      # if @shadowVisible
  566.     #    shadow.setVisible(delay+5,true)
  567.      #   shadow.setZoom(delay+5,100)
  568.     #    shadow.moveOpacity(delay+5,10,255)
  569.     #  end
  570.     else
  571.       # Pokémon was caught
  572.       ballCaptureSuccess(ball,delay,ballEndX,ballGroundY)
  573.     end
  574.   end
  575.  
  576.   def dispose
  577.     if @ballSpriteIndex>=0
  578.       # Capture was successful, the Poké Ball sprite should stay around after
  579.       # this animation has finished.
  580.       @sprites["captureBall"] = @tempSprites[@ballSpriteIndex]
  581.       @tempSprites[@ballSpriteIndex] = nil
  582.     end
  583.     super
  584.   end
  585. end
  586.  
  587.  
  588.  
  589. class BattleIntroAnimation < PokeBattle_Animation
  590.  
  591.   def createProcesses
  592.     appearTime = 20   # This is in 1/20 seconds
  593.     # Background
  594.     if @sprites["battle_bg2"]
  595.       makeSlideSprite("battle_bg",0.5,appearTime)
  596.       makeSlideSprite("battle_bg2",0.5,appearTime)
  597.     end
  598.     # Bases
  599.     makeSlideSprite("base_0",1,appearTime,PictureOrigin::Bottom)
  600.     makeSlideSprite("base_1",-1,appearTime,PictureOrigin::Center)
  601.     # Player sprite, partner trainer sprite
  602.     @battle.player.each_with_index do |_p,i|
  603.       makeSlideSprite("player_#{i+1}",1,appearTime,PictureOrigin::Bottom)
  604.     end
  605.     # Opposing trainer sprite(s) or wild Pokémon sprite(s)
  606.     if @battle.trainerBattle?
  607.       @battle.opponent.each_with_index do |_p,i|
  608.         makeSlideSprite("trainer_#{i+1}",-1,appearTime,PictureOrigin::Bottom)
  609.       end
  610.     else   # Wild battle
  611.       @battle.pbParty(1).each_with_index do |_pkmn,i|
  612.         idxBattler = 2*i+1
  613.         makeSlideSprite("pokemon_#{idxBattler}",-1,appearTime,PictureOrigin::Bottom)
  614.       end
  615.     end
  616.     # Fading blackness over whole screen
  617.     blackScreen = addNewSprite(0,0,"Graphics/Battle animations/black_screen")
  618.     blackScreen.setZ(0,999)
  619.     blackScreen.moveOpacity(0,8,0)
  620.     # Fading blackness over command bar
  621.     blackBar = addNewSprite(@sprites["cmdBar_bg"].x,@sprites["cmdBar_bg"].y,
  622.        "Graphics/Battle animations/black_bar")
  623.     blackBar.setZ(0,998)
  624.     blackBar.moveOpacity(appearTime*3/4,appearTime/4,0)
  625.   end
  626.  
  627. end
  628.  
  629.  
  630.  
  631.  
  632. class PokeBattle_Scene
  633.   def pbFrameUpdate(cw=nil)
  634.     cw.update if cw
  635.     @battle.battlers.each_with_index do |b,i|
  636.       next if !b
  637.       @sprites["dataBox_#{i}"].update(@frameCounter) if @sprites["dataBox_#{i}"]
  638.       @sprites["pokemon_#{i}"].update(@frameCounter) if @sprites["pokemon_#{i}"]
  639.     end
  640.   end
  641.  
  642.  
  643.   # Used by Ally Switch.
  644.   def pbSwapBattlerSprites(idxA,idxB)
  645.     @sprites["pokemon_#{idxA}"], @sprites["pokemon_#{idxB}"] = @sprites["pokemon_#{idxB}"], @sprites["pokemon_#{idxA}"]
  646.     @lastCmd[idxA], @lastCmd[idxB] = @lastCmd[idxB], @lastCmd[idxA]
  647.     @lastMove[idxA], @lastMove[idxB] = @lastMove[idxB], @lastMove[idxA]
  648.     [idxA,idxB].each do |i|
  649.       @sprites["pokemon_#{i}"].index = i
  650.       @sprites["pokemon_#{i}"].pbSetPosition
  651.      # @sprites["shadow_#{i}"].pbSetPosition
  652.       @sprites["dataBox_#{i}"].battler = @battle.battlers[i]
  653.     end
  654.     pbRefresh
  655.   end
  656.  
  657.  
  658.   def pbChangePokemon(idxBattler,pkmn)
  659.     idxBattler = idxBattler.index if idxBattler.respond_to?("index")
  660.     pkmnSprite   = @sprites["pokemon_#{idxBattler}"]
  661.     back = !@battle.opposes?(idxBattler)
  662.     pkmnSprite.setPokemonBitmap(pkmn,back)
  663.     pkmnSprite.formatShadow
  664.     # Set visibility of battler's shadow
  665.     if !back
  666.       pkmnSprite.showshadow = showShadow?(pkmn.fSpecies)
  667.     end
  668.   end
  669.  
  670.  
  671.   def pbCreatePokemonSprite(idxBattler)
  672.     sideSize = @battle.pbSideSize(idxBattler)
  673.     batSprite = PokemonBattlerSprite.new(@viewport,sideSize,idxBattler,@animations)
  674.     batSprite.showshadow = false
  675.     @sprites["pokemon_#{idxBattler}"] = batSprite
  676.   end
  677.  
  678. end
Advertisement
Add Comment
Please, Sign In to add comment