Advertisement
Vendily

Dynamic Surf

May 9th, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.60 KB | None | 0 0
  1. #PField_Field
  2. # This method causes a lot of lag when the game is encrypted
  3. def pbGetPlayerCharset(meta,charset,trainer=nil)
  4.   trainer=$Trainer if !trainer
  5.   outfit=trainer ? trainer.outfit : 0
  6.   ret=meta[charset]
  7.   ret=meta[1] if !ret || ret==""
  8. #  if FileTest.image_exist?("Graphics/Characters/"+ret+"_"+outfit.to_s)
  9.   if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s)
  10.     ret=ret+"_"+outfit.to_s
  11.   end
  12.   if (charset == 3) || (charset == 5)# || (charset == 7)
  13.     CreateOverlayBitmap(ret)
  14.   end
  15.   return ret
  16. end
  17.  
  18. def CreateOverlayBitmap(fileString)
  19.   if $Trainer.ridepoke
  20.     filepath = pbPokemonOverworldFiles($Trainer.ridepoke)
  21.     # Safety Copy
  22.     if !File.exists?("Graphics/Characters/"+fileString+"_safetyCopy"+".png")
  23.       safetyCopy=Bitmap.new("Graphics/Characters/"+fileString)
  24.       safetyCopy.saveToPng("Graphics/Characters/"+fileString+"_safetyCopy"+".png")
  25.     end
  26.     trainerlay = Bitmap.new("Graphics/Characters/"+fileString+"_safetyCopy"+".png")
  27.     pokelay = Bitmap.new(filepath)
  28.     pokelay.blt(0,0,trainerlay,Rect.new(0,0,Graphics.width,Graphics.height))
  29.     #pokelay.blt(0,pokelay.height/4,Bitmap.new(filepath),Rect.new(0,pokelay.height/4,pokelay.width,pokelay.height/2)) if trainer.ridepoke.rideOverlay[1]
  30.     for i in 0..$Trainer.ridepoke.rideOverlay.length
  31.       case $Trainer.ridepoke.rideOverlay[i]
  32.       when 1
  33.         pokelay.blt(0,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(0,i*pokelay.height/4,pokelay.width,pokelay.height/8))
  34.       when 2
  35.         pokelay.blt(i*pokelay.height/4,pokelay.height/8,Bitmap.new(filepath),Rect.new(i*pokelay.height/4,pokelay.height/8,pokelay.width,pokelay.height/8))
  36.       when 3
  37.         pokelay.blt(0,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(0,i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  38.         pokelay.blt(pokelay.width/4,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(pokelay.width/4,i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  39.         pokelay.blt(2*pokelay.width/4,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(2*pokelay.width/4,i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  40.         pokelay.blt(3*pokelay.width/4,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(3*pokelay.width/4,i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  41.       when 4
  42.         pokelay.blt(pokelay.width/8,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(pokelay.width/16,i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  43.         pokelay.blt(pokelay.width/8+pokelay.width/4,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(pokelay.width/16+pokelay.width/4,i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  44.         pokelay.blt(pokelay.width/8+(2*pokelay.width/4),i*pokelay.height/4,Bitmap.new(filepath),Rect.new(pokelay.width/16+(2*pokelay.width/4),i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  45.         pokelay.blt(pokelay.width/8+(3*pokelay.width/4),i*pokelay.height/4,Bitmap.new(filepath),Rect.new(pokelay.width/16+(3*pokelay.width/4),i*pokelay.height/4,pokelay.width/8+pokelay.width/16,pokelay.height/4))
  46.       when 5
  47.         pokelay.blt(0,i*pokelay.height/4,Bitmap.new(filepath),Rect.new(0,i*pokelay.height/4,pokelay.width,pokelay.height/4))
  48.       end
  49.     end
  50.     pokelay.saveToPng("Graphics/Characters/"+fileString+".png")
  51.   end
  52. end
  53.  
  54. #PokeBattle_Pokemon
  55. # None = 0, Top = 1, Bottom = 2, Left = 3, Right = 4, All = 5
  56. OVERLAY_INDEX = {
  57.   78=>[5,2,2,2],
  58.   130=>[3,3,4,3],
  59.   131=>[5,3,0,0],
  60.   567=>[5,5,5,0],
  61.   581=>[5,5,5,0]
  62. }  
  63.  
  64.   def rideOverlay
  65.     ret=OVERLAY_INDEX[@species]
  66.     ret2= !ret ? [0,0,0,0] : ret
  67.     return ret2
  68.   end
  69.  
  70. #PField_HiddenMoves
  71. def pbStartSurfing(movefinder=nil)
  72.   if movefinder != nil
  73.     $Trainer.ridepoke = movefinder
  74.   end
  75.   Kernel.pbCancelVehicles
  76.   $PokemonEncounters.clearStepCount
  77.   $PokemonGlobal.surfing=true
  78.   Kernel.pbUpdateVehicle
  79.   Kernel.pbJumpToward
  80.   Kernel.pbUpdateVehicle
  81.   $game_player.check_event_trigger_here([1,2])
  82. end
  83.  
  84. def pbEndSurf(xOffset,yOffset)
  85.   return false if !$PokemonGlobal.surfing
  86.   $Trainer.ridepoke=nil
  87.   x=$game_player.x
  88.   y=$game_player.y
  89.   currentTag=$game_map.terrain_tag(x,y)
  90.   facingTag=Kernel.pbFacingTerrainTag
  91.   if pbIsSurfableTag?(currentTag) && !pbIsSurfableTag?(facingTag)
  92.     if Kernel.pbJumpToward(1,false,true)
  93. #      Kernel.pbCancelVehicles
  94.       $game_map.autoplayAsCue
  95.       $game_player.increase_steps
  96.       result=$game_player.check_event_trigger_here([1,2])
  97.       Kernel.pbOnStepTaken(result)
  98.     end
  99.     return true
  100.   end
  101.   return false
  102. end
  103.  
  104. #Following pokemon
  105. def Kernel.pbSurf
  106.   if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  107.     return false
  108.   end
  109.   if $DEBUG ||
  110.     (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
  111.     movefinder=Kernel.pbCheckMove(:SURF)
  112.     if movefinder || $DEBUG
  113.       if Kernel.pbConfirmMessage(_INTL("The water is dyed a deep blue...  Would you like to surf?"))
  114.         speciesname=!movefinder ? $Trainer.name : movefinder.name
  115.         Kernel.pbMessage(_INTL("{1} used Surf!",speciesname))
  116.         pbHiddenMoveAnimation(movefinder)
  117.         surfbgm=pbGetMetadata(0,MetadataSurfBGM)
  118.         $PokemonTemp.dependentEvents.check_surf(true)
  119.         if surfbgm
  120.           pbCueBGM(surfbgm,0.5)
  121.         end
  122.         pbStartSurfing(movefinder) #edit!!!
  123.         return true
  124.       end
  125.     end
  126.   end
  127.   return false
  128. end
  129.  
  130. alias follow_pbStartSurfing pbStartSurfing
  131. def pbStartSurfing(movefinder=nil)#edit
  132.   follow_pbStartSurfing(movefinder)#edit
  133.   $PokemonGlobal.surfing=true
  134. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement