Advertisement
M3rein

Pokéride_Main

Oct 18th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.12 KB | None | 0 0
  1. #==============================================================================#
  2. #                    Pokéride for Pokémon Essentials v17.X                     #
  3. #                                    v1.0                                      #
  4. #                                                                              #
  5. #                                  by Marin                                    #
  6. #==============================================================================#
  7. #                                    Note                                      #
  8. # This script is merely for functionality. It does not provide a whole system, #
  9. #    and things such as availability of certain Pokérides is not included.     #
  10. #==============================================================================#
  11. #                                    Usage                                     #
  12. #  To mount a Pokéride, use "pbMount(name)". "name" is the name of the module, #
  13. #                  which can be found in "Pokéride_Rides".                     #
  14. #==============================================================================#
  15.  
  16.  
  17. # Example:
  18. # pbMount(Tauros)
  19. # but these are also possible:
  20. # pbMount(:Tauros)
  21. # pbMount("Tauros")
  22. def pbMount(_module)
  23.   _module = eval(_module.to_s) if _module.is_a?(String) || _module.is_a?(Symbol)
  24.   sheet = _module::MoveSheet[$Trainer.gender]
  25.   $game_player.setDefaultCharName(sheet,$game_player.fullPattern)
  26.   _module.mount if _module.respond_to?("mount")
  27.   $PokemonGlobal.surfing = true if defined?(_module::CanSurf) && _module::CanSurf
  28.   $PokemonGlobal.mount = _module
  29. end
  30.  
  31. def pbDismount
  32.   $PokemonGlobal.mount.dismount if $PokemonGlobal.mount &&
  33.                                    $PokemonGlobal.mount.respond_to?("dismount")
  34.   $PokemonGlobal.surfing = false if defined?(_module::CanSurf) && _module::CanSurf
  35.   $PokemonGlobal.mount = nil
  36.   $game_player.setDefaultCharName(nil,$game_player.fullPattern)
  37. end
  38.  
  39. # $Trainer.can_rock_climb has to be true if you want to be able to use Rock Climb.
  40. class PokeBattle_Trainer
  41.   attr_accessor :can_rock_climb
  42.  
  43.   alias pokeride_init initialize
  44.   def initialize(name, trainertype)
  45.     pokeride_init(name, trainertype)
  46.     @can_rock_climb = false
  47.   end
  48. end
  49.  
  50. unless defined?(pbList)
  51.   # If you call this on an event, it'll be no longer listed in the Itemfinder
  52.   # (if it even had ".hidden" in the name)
  53.   def pbUnlist(event_id)
  54.     $game_map.events[event_id].listed = false if $game_map.events[event_id]
  55.   end
  56.  
  57.   # The Itemfinder will show this event (but still only if it has .hidden in name)
  58.   def pbList(event_id)
  59.     $game_map.events[event_id].listed = true if $game_map.events[event_id]
  60.   end
  61. end
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. # Crap you won't need to mess with starts here.
  69. class PokemonGlobalMetadata
  70.   attr_accessor :mount
  71.   attr_accessor :mount_action
  72. end
  73.  
  74. unless defined?(Game_Event.listed)
  75.   class Game_Event
  76.     attr_accessor :listed
  77.    
  78.     alias pokeride_init initialize
  79.     def initialize(map_id, event, map = nil)
  80.       pokeride_init(map_id, event, map)
  81.       @listed = true # Set to true, but whether it's actually listed or not
  82.                      # depends on the name.
  83.     end
  84.   end
  85. end
  86.  
  87. def pbHiddenItemNearby?
  88.   x = $game_player.x
  89.   y = $game_player.y
  90.   for event in $game_map.events
  91.     event = event[1]
  92.     if event.name.include?(".hidden") && event.listed
  93.       if event.x - x >= -4 && event.x - x <= 4
  94.         if event.y - y >= -4 && event.y - y <= 4
  95.           return true
  96.         end
  97.       end
  98.     end
  99.   end
  100.   return false
  101. end
  102.  
  103. class Game_Player
  104.   alias pokeride_update update
  105.   def update
  106.     pokeride_update
  107.     if $PokemonGlobal.mount
  108.       if Input.press?(Input::A)
  109.         @move_speed = $PokemonGlobal.mount::ActionSpeed
  110.         sheet = $PokemonGlobal.mount::ActionSheet[$Trainer.gender]
  111.         $game_player.setDefaultCharName(sheet,$game_player.fullPattern)
  112.         $PokemonGlobal.mount_action = true
  113.         if defined?($PokemonGlobal.mount::ShowHidden) && $PokemonGlobal.mount::ShowHidden
  114.           if pbHiddenItemNearby?
  115.             sheet = $PokemonGlobal.mount::HiddenNearbySheet[$Trainer.gender]
  116.             $game_player.setDefaultCharName(sheet,$game_player.fullPattern)
  117.             @move_speed = $PokemonGlobal.mount::HiddenNearbySpeed
  118.           end
  119.         end
  120.       else
  121.         @move_speed = $PokemonGlobal.mount::MoveSpeed
  122.         sheet = $PokemonGlobal.mount::MoveSheet[$Trainer.gender]
  123.         $game_player.setDefaultCharName(sheet,$game_player.fullPattern)
  124.         $PokemonGlobal.mount_action = false
  125.       end
  126.     end
  127.   end
  128.  
  129.   alias pokeride_trigger check_event_trigger_there
  130.   def check_event_trigger_there(triggers)
  131.     result = pokeride_trigger(triggers)
  132.     return result if ROCK_CLIMB_MOUNT.nil?
  133.     new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  134.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  135.     if result == false
  136.       for i in [2,1,0]
  137.         if $game_map.terrain_tags[$game_map.map.data[new_x, new_y, i]] == PBTerrain::RockClimb
  138.           activemount = $PokemonGlobal.mount && defined?($PokemonGlobal.mount::RockClimb) &&
  139.                         $PokemonGlobal.mount::RockClimb
  140.           if activemount || $Trainer.can_rock_climb && Kernel.pbConfirmMessage(_INTL("Do you want to rock climb here?"))
  141.             unless activemount
  142.               Kernel.pbCancelVehicles
  143.               pbMount(eval(ROCK_CLIMB_MOUNT))
  144.               pbWait(10)
  145.             end
  146.             climb = true
  147.             up = false
  148.             for j in [2,1,0]
  149.               if $game_map.terrain_tags[$game_map.map.data[@x+2,@y-1,j]] == PBTerrain::RockClimb ||
  150.                  $game_map.terrain_tags[$game_map.map.data[@x-2,@y-1,j]] == PBTerrain::RockClimb
  151.                 up = true
  152.                 break
  153.               end
  154.             end
  155.             unless @direction == 2 || direction == 8
  156.               @x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  157.             end
  158.             pbWait(4)
  159.             while climb
  160.               _x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  161.               _y = @y
  162.               if @direction == 2 || @direction == 8
  163.                 _y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  164.               elsif up
  165.                 _y -= 1
  166.               else
  167.                 _y += 1
  168.               end
  169.               pbWait(4)
  170.               climb = false
  171.               @x = _x
  172.               for j in [2,1,0]
  173.                 if $game_map.terrain_tags[$game_map.map.data[_x, _y, j]] == PBTerrain::RockClimb
  174.                   climb = true
  175.                   break
  176.                 end
  177.               end
  178.               @y = _y if climb || @direction == 2 || @direction == 8
  179.             end
  180.           end
  181.           pbWait(20)
  182.           pbDismount if !activemount
  183.           return true
  184.         end
  185.       end
  186.     end
  187.     return result
  188.   end
  189. end
  190.  
  191. class Sprite_SurfBase
  192.   alias pokeride_init initialize
  193.   def initialize(sprite, event, viewport = nil)
  194.     return if $PokemonGlobal.mount
  195.     pokeride_init(sprite, event, viewport)
  196.   end
  197.  
  198.   alias pokeride_update update
  199.   def update
  200.     return if $PokemonGlobal.mount
  201.     pokeride_update
  202.   end
  203.  
  204.   def dispose
  205.     if !@disposed
  206.       @sprite.dispose if @sprite
  207.       @sprite   = nil
  208.       @surfbitmap.dispose if @surfbitmap
  209.       @surfbitmap = nil
  210.       @disposed = true
  211.     end
  212.   end
  213. end
  214.  
  215. module Kernel
  216.   class << Kernel
  217.     alias pokeride_cancel_vehicles pbCancelVehicles
  218.     alias pokeride_surf pbSurf
  219.   end
  220.  
  221.   def self.pbCancelVehicles(destination = nil)
  222.     pbDismount
  223.     pokeride_cancel_vehicles(destination)
  224.   end
  225.  
  226.   def self.pbSurf
  227.     unless SURF_MOUNT.nil?
  228.       Kernel.pbCancelVehicles
  229.       $PokemonEncounters.clearStepCount
  230.       $PokemonGlobal.surfing = true
  231.       $PokemonTemp.surfJump = $MapFactory.getFacingCoords($game_player.x,$game_player.y,$game_player.direction)
  232.       $PokemonGlobal.mount = eval(SURF_MOUNT)
  233.       Kernel.pbJumpToward
  234.       $PokemonTemp.surfJump = nil
  235.       Kernel.pbUpdateVehicle
  236.       $game_player.check_event_trigger_here([1,2])
  237.     else
  238.       pokeride_surf
  239.     end
  240.   end
  241. end
  242.  
  243. class Game_Character
  244.   alias pokeride_passableex passableEx?
  245.   def passableEx?(x, y, d, strict = false)
  246.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  247.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  248.     return false unless self.map.valid?(new_x, new_y)
  249.     return true if @through
  250.     # Pokéride Rock Smash
  251.     if $PokemonGlobal.mount && $PokemonGlobal.mount_action &&
  252.        defined?($PokemonGlobal.mount::RockSmash) &&
  253.        $PokemonGlobal.mount::RockSmash
  254.       for event in self.map.events
  255.         if event[1].name == "Rock" && event[1].x == new_x && event[1].y == new_y
  256.           facingEvent = $game_player.pbFacingEvent
  257.           if facingEvent
  258.             pbSmashEvent(facingEvent)
  259.             return true
  260.           end
  261.         end
  262.       end
  263.     end
  264.     return pokeride_passableex(x, y, d, strict)
  265.   end
  266. end
  267.  
  268. class Spriteset_Map
  269.   alias pokeride_update update
  270.   def update
  271.     pokeride_update
  272.     if $PokemonGlobal.mount && defined?($PokemonGlobal.mount::Strength) &&
  273.        $PokemonGlobal.mount::Strength
  274.       $PokemonMap.strengthUsed = $PokemonGlobal.mount_action
  275.     end
  276.   end
  277. end
  278.  
  279. module PBTerrain
  280.   Mudsdale = 17 # Only passable if on a Mudsdale
  281.   RockClimb = 18 # Can only be traversed on a Pokéride with RockClimb capabilities
  282. end
  283.  
  284. class Game_Map
  285.   attr_reader :map
  286.  
  287.   alias pokeride_playerpassable playerPassable?
  288.   def playerPassable?(x, y, d, self_event = nil)
  289.     for i in [2, 1, 0]
  290.       if @terrain_tags[data[x, y, i]] == PBTerrain::Mudsdale
  291.         return $PokemonGlobal.mount && defined?($PokemonGlobal.mount::WalkOnMudsdale) &&
  292.                $PokemonGlobal.mount::WalkOnMudsdale
  293.       end
  294.     end
  295.     pokeride_playerpassable(x, y, d, self_event)
  296.   end
  297. end
  298.  
  299. def pbStartSurfing
  300.   Kernel.pbCancelVehicles
  301.   $PokemonEncounters.clearStepCount
  302.   $PokemonGlobal.surfing = true
  303.   $PokemonTemp.surfJump = $MapFactory.getFacingCoords($game_player.x,$game_player.y,$game_player.direction)
  304.   Kernel.pbUpdateVehicle
  305.   Kernel.pbJumpToward
  306.   $PokemonTemp.surfJump = nil
  307.   Kernel.pbUpdateVehicle
  308. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement