Advertisement
roninator2

Tenseiten Vehicle Interiors mod

Dec 4th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.95 KB | None | 0 0
  1. #===============================================================================
  2. # * Vehicle Additions
  3. #   Version 0.41b
  4. #-------------------------------------------------------------------------------
  5. # * Authored by: tenseiten/seitensei
  6. # * With help from: shaz
  7. # * Updated by Roninator2
  8. #===============================================================================
  9.  
  10. #===============================================================================
  11. # * Change log
  12. #-------------------------------------------------------------------------------
  13. =begin
  14.  
  15. 0.41b - 2020-12-10 18:05 CST
  16.   - added switches to turn feature on or off
  17.  
  18. 0.4b - 2020-12-10 18:00 CST
  19.   - Added support for ship interior
  20.  
  21. 0.35b - 2011-12-27 1:19 JST
  22.   - Replaced cloned methods with alias to fix possible compatibility issues.
  23.     This script should be placed below any other that modified the default
  24.     vehicle behavior.
  25.  
  26. 0.35a - 2011-12-22, 19:16 JST
  27.   - Fixed Boat and Ship not being passed through
  28.  
  29. 0.30a - 2011-12-21, 19:20 JST
  30.   - First Public Release
  31.   - Fixed Teleport on Unlandable Spaces
  32.  
  33. 0.20a - Internal Version
  34.  
  35. 0.10a - Internal Version
  36.  
  37. 0.00a - Internal Version
  38.  
  39. =end
  40. #===============================================================================
  41.  
  42. #===============================================================================
  43. =begin
  44.  
  45. .:Introduction:.
  46. This Vehicle Additions script adds the ability to access an additional map as
  47. the interior of the vehicle. So far, only the airship has been implemented. This
  48. script overwrites the get_on_vehicle and the get_off_vehicle methods, so it is
  49. not compatible with anything that edits those. However, since it uses a the
  50. default code when the system is not enabled for a vehicle, created a patch to
  51. solve incompatibilities is not within the real of impossibility.
  52.  
  53. .:Instruction:.
  54. Set the map ID and X/Y coordinates of for the map that will serve as the
  55. interior of the vehicle. Create an event that brings the player back to the
  56. overmap and forces them to pilot the vehicle by by creating and event that
  57. calls the following code:
  58.  
  59. $game_player.pilot_vehicle
  60.  
  61. To exit the vehicle's interior, and return to the overmap (on foot), call
  62. the following:
  63.  
  64. $game_player.exit_vehicle
  65.  
  66. =end
  67. #===============================================================================
  68.  
  69. #-------------------------------------------------------------------------------
  70. # * Config Section
  71. #-------------------------------------------------------------------------------
  72. module Tenseiten
  73.   module Vehicle
  74.     AIRSHIP_ENABLED = 2 # switch # Whether or not we want to invoke additions
  75.     AIRSHIP_MAP = 3 # interior map id
  76.     AIRSHIP_MAP_X = 10 # interior x
  77.     AIRSHIP_MAP_Y = 10 # interior y
  78.    
  79.     SHIP_ENABLED = 3 # switch # Whether or not we want to invoke additions
  80.     SHIP_MAP = 4 # interior map id
  81.     SHIP_MAP_X = 10 # interior x
  82.     SHIP_MAP_Y = 10 # interior y
  83.   end
  84. end
  85. #-------------------------------------------------------------------------------
  86. # * Config End
  87. #-------------------------------------------------------------------------------
  88. class Game_Player < Game_Character
  89.   #--------------------------------------------------------------------------
  90.   # * Get on Vehicle (From Overmap)
  91.   #   Intercept the player, and send them inside.
  92.   #--------------------------------------------------------------------------
  93.   alias control_vehicle get_on_vehicle
  94.   def get_on_vehicle
  95.     front_x = $game_map.round_x_with_direction(@x, @direction)
  96.     front_y = $game_map.round_y_with_direction(@y, @direction)
  97.     # check if player is allowed to get onto the airship
  98.     if $game_map.airship.pos?(@x, @y)
  99.       if $game_switches[Tenseiten::Vehicle::AIRSHIP_ENABLED] == true
  100.         #Save world map information
  101.         @player_w_map = $game_map.map_id
  102.         @player_w_x = @x
  103.         @player_w_y = @y
  104.         @used_vehicle = :airship
  105.         #Now Teleport to the map set in config
  106.         reserve_transfer(Tenseiten::Vehicle::AIRSHIP_MAP, Tenseiten::Vehicle::AIRSHIP_MAP_X, Tenseiten::Vehicle::AIRSHIP_MAP_Y, @direction) # transfer to new map
  107.       else
  108.         #Continue to normal function when not enabled
  109.         @vehicle_type = :airship
  110.         control_vehicle
  111.       end
  112.     end
  113.     if $game_map.boat.pos?(front_x, front_y)
  114.       @vehicle_type = :boat
  115.       control_vehicle
  116.     end
  117.     if $game_map.ship.pos?(front_x, front_y)
  118.       if $game_switches[Tenseiten::Vehicle::SHIP_ENABLED] == true
  119.         #Save world map information
  120.         @player_w_map = $game_map.map_id
  121.         @player_w_x = @x
  122.         @player_w_y = @y
  123.         @player_w_d = @direction
  124.         @used_vehicle = :ship
  125.         #Now Teleport to the map set in config
  126.         reserve_transfer(Tenseiten::Vehicle::SHIP_MAP, Tenseiten::Vehicle::SHIP_MAP_X, Tenseiten::Vehicle::SHIP_MAP_Y, @direction) # transfer to new map
  127.       else
  128.         #Continue to normal function when not enabled
  129.         @vehicle_type = :ship
  130.         control_vehicle
  131.       end
  132.     end
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Pilot Vehicle (From Interior)
  136.   #   Brings player back to the overmap to control the ship
  137.   #--------------------------------------------------------------------------
  138.   def pilot_vehicle
  139.     # Save Interior Map Location
  140.     @player_int_map = $game_map.map_id
  141.     @player_int_x = @x
  142.     @player_int_y = @y
  143.     # Transfer to World Map
  144.     if @used_vehicle == :ship
  145.       @direction = @player_w_d
  146.       if @player_w_d == 2
  147.         @player_w_y += 1
  148.       elsif @player_w_d == 4
  149.         @player_w_x -= 1
  150.       elsif @player_w_d == 6
  151.         @player_w_x += 1
  152.       elsif @player_w_d == 8
  153.         @player_w_y -= 1
  154.       end
  155.     end
  156.     reserve_transfer(@player_w_map, @player_w_x, @player_w_y, @direction)
  157.     @vehicle_type = @used_vehicle
  158.     control_vehicle
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * Leave Vehicle (From Overmap)
  162.   #   Intercept the player, and end them inside
  163.   #--------------------------------------------------------------------------
  164.   alias abandon_vehicle get_off_vehicle
  165.   def get_off_vehicle
  166.     if @vehicle_type == :airship
  167.       if $game_switches[Tenseiten::Vehicle::AIRSHIP_ENABLED] == true
  168.         if vehicle.land_ok?(@x, @y, @direction)
  169.         set_direction(1) if in_airship?
  170.         @followers.synchronize(@x, @y, @direction)
  171.         vehicle.get_off
  172.         unless in_airship?
  173.           force_move_forward
  174.           @transparent = false
  175.         end
  176.         @vehicle_getting_off = true
  177.         @move_speed = 4
  178.         @through = false
  179.         make_encounter_count
  180.         @followers.gather
  181.         end
  182.         @vehicle_getting_off
  183.       if vehicle.land_ok?(@x, @y, @direction)
  184.         @player_w_map = $game_map.map_id
  185.         @player_w_x = @x
  186.         @player_w_y = @y
  187.         reserve_transfer(@player_int_map, @player_int_x, @player_int_y, @direction) # transfer to new map
  188.       end
  189.       else
  190.           abandon_vehicle
  191.       end
  192.     elsif @vehicle_type == :ship
  193.       if $game_switches[Tenseiten::Vehicle::SHIP_ENABLED] == true
  194.         vehicle.get_off
  195.         force_move_forward
  196.         @transparent = false
  197.         @vehicle_getting_off = true
  198.         @move_speed = 4
  199.         @through = false
  200.         make_encounter_count
  201.         @followers.gather
  202.         @vehicle_getting_off
  203.         @player_w_map = $game_map.map_id
  204.         @player_w_x = @x
  205.         @player_w_y = @y
  206.         reserve_transfer(@player_int_map, @player_int_x, @player_int_y, @direction) # transfer to new map
  207.       else
  208.           abandon_vehicle
  209.       end
  210.     else
  211.       abandon_vehicle
  212.     end
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # * Exit Vehicle (From Interior)
  216.   #   Returns the party to the overmap
  217.   #--------------------------------------------------------------------------
  218.   def exit_vehicle
  219.     reserve_transfer(@player_w_map, @player_w_x, @player_w_y, @direction)
  220.   end
  221. end
  222.  
  223.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement