pigu_6

seitensei| Vehicle additions

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