Advertisement
roninator2

Yanfly Move Restrict Regions - addon - Block Vehicle

Dec 8th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.73 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Yanfly Move Restrict patch   ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║ Stop vehicle landing if not able to ║    14 Apr 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:  None                                      ║
  11. # ║                                                          ║
  12. # ║    The script simple fixes an issue that a player        ║
  13. # ║    can get off a ship or airship onto a region that      ║
  14. # ║    is configured to block the player.                    ║
  15. # ║                                                          ║
  16. # ╚══════════════════════════════════════════════════════════╝
  17. # ╔══════════════════════════════════════════════════════════╗
  18. # ║ Updates:                                                 ║
  19. # ║   2023-May-16 - Initial publish                          ║
  20. # ╚══════════════════════════════════════════════════════════╝
  21. # ╔══════════════════════════════════════════════════════════╗
  22. # ║ Terms of use:                                            ║
  23. # ║ Free for all uses in RPG Maker VX Ace except nudity      ║
  24. # ╚══════════════════════════════════════════════════════════╝
  25.  
  26. #==============================================================================
  27. # ** Game CharacterBase
  28. #==============================================================================
  29. class Game_CharacterBase
  30.   #--------------------------------------------------------------------------
  31.   # new method: vehicle dismount
  32.   #--------------------------------------------------------------------------
  33.   def vehicle_dismount(x, y)
  34.     return false if debug_through?
  35.     region = 0
  36.     region = $game_map.region_id(x, y)
  37.     return true if $game_map.all_restrict_regions.include?(region)
  38.     return true if $game_map.player_restrict_regions.include?(region)
  39.     return true if $game_map.player_block_regions.include?(region)
  40.     return false
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # new method: airship dismount
  44.   #--------------------------------------------------------------------------
  45.   def airship_dismount(x, y)
  46.     return false if debug_through?
  47.     region = 0
  48.     region = $game_map.region_id(x, y)
  49.     return true if $game_map.all_restrict_regions.include?(region) && @in_air
  50.     return true if $game_map.player_restrict_regions.include?(region)
  51.     return true if $game_map.player_block_regions.include?(region)
  52.     return false
  53.   end
  54. end
  55.  
  56. #==============================================================================
  57. # ** Game Vehicle
  58. #==============================================================================
  59. class Game_Vehicle
  60.   def land_ok?(x, y, d)
  61.     if @type == :airship
  62.       return false unless $game_map.airship_land_ok?(x, y)
  63.       return false unless $game_map.events_xy(x, y).empty?
  64.       return false if airship_dismount(x, y)
  65.     else
  66.       x2 = $game_map.round_x_with_direction(x, d)
  67.       y2 = $game_map.round_y_with_direction(y, d)
  68.       return false unless $game_map.valid?(x2, y2)
  69.       return false unless $game_map.passable?(x2, y2, reverse_dir(d))
  70.       return false if vehicle_dismount(x2, y2)
  71.       return false if collide_with_characters?(x2, y2)
  72.     end
  73.     return true
  74.   end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement