Advertisement
Guest User

Flying Script

a guest
Jun 7th, 2018
1,824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.34 KB | None | 0 0
  1. #------------------------------------------------------------------------------#
  2. # Galv's Superman Ability
  3. #------------------------------------------------------------------------------#
  4. # For: RPGMAKER VX ACE
  5. # Version 1.5
  6. #------------------------------------------------------------------------------#
  7. # 2014-09-24 - Version 1.5 - fixed <fly> typo notetage to <flight>
  8. # 2012-11-30 - Version 1.5 - can set equip/skill/actor requirements to fly
  9. # - fixed talking and trying to fly/land bug
  10. # - added script calls to force takeoff and land
  11. # 2012-11-14 - Version 1.4 - can no longer land on same-as-player events
  12. # 2012-11-13 - Version 1.3 - another bug fix, priority wasn't above when fly.
  13. # 2012-11-13 - Version 1.2 - another bug fix, making vehicle speed change.
  14. # 2012-11-13 - Version 1.1 - fixed bug where could board vehicles while flying.
  15. # 2012-11-13 - Version 1.0 - release
  16. #------------------------------------------------------------------------------#
  17. # This script allows the player to gain the power of flight and land/takeoff
  18. # whenever they want to. (Designed for use with NO followers.)
  19. #------------------------------------------------------------------------------#
  20. # INSTRUCTIONS:
  21. # Read the setup options below and set it up as desired.
  22. #------------------------------------------------------------------------------#
  23. # SCRIPT CALLS:
  24. #------------------------------------------------------------------------------#
  25. #
  26. # flying? # return true or false. Use in conditional branch if ACTIVATE_EVENTS
  27. # # is set to true in the settings below
  28. #
  29. # $game_player.force_land # script call to force player to land
  30. # $game_player.force_takeoff # script call to force player to take off
  31. #
  32. #------------------------------------------------------------------------------#
  33. # NOTETAG ACTORS / EQUIPS / SKILLS:
  34. #------------------------------------------------------------------------------#
  35. #
  36. # <flight> # if REQUIREMENTS = true, then the leader requires a notetag on
  37. # # them, one of their equips or a skill they know.
  38. #
  39. #------------------------------------------------------------------------------#
  40.  
  41. ($imported ||= {})["Galvs_Superman_Ability"] = true
  42.  
  43. module Galv_Superman
  44. #------------------------------------------------------------------------------#
  45. # SCRIPT SETUP OPTIONS
  46. #------------------------------------------------------------------------------#
  47.  
  48.  
  49. ENABLE_SWITCH = 1 # Can only fly when this switch is ON
  50.  
  51. REQUIREMENTS = true # Leader requires actor/equip/skill <fly> tag
  52. # false = dont need to tag anything to fly
  53.  
  54. SPEED_BONUS = 1 # Speed increases by this number when flying.
  55.  
  56. BUTTON = :R # Button to press to fly and land. :X is "a" key.
  57.  
  58. FLY_EXTENSION = "_fly" # Character set for when actor is flying. If your
  59. # actor uses "Actor1.png" then you must have a file
  60. # called "Actor1_fly.png" if this extenstion is set
  61. # to "_fly". The actor must be in the same position
  62. # in both charsets.
  63.  
  64. ACTIVATE_EVENTS = false # If true, can still activate events as normal.
  65. # If false, will work like airship does, unable to
  66. # activate events until landed.
  67.  
  68.  
  69. #------------------------------------------------------------------------------#
  70. # END SCRIPT SETUP OPTIONS
  71. #------------------------------------------------------------------------------#
  72.  
  73. end
  74.  
  75.  
  76. class RPG::BaseItem
  77. def flight
  78. if @flight.nil?
  79. if @note =~ /<flight>/i
  80. @flight = true
  81. else
  82. @flight = false
  83. end
  84. end
  85. @flight
  86. end
  87. end # RPG::BaseItem
  88.  
  89.  
  90. class Scene_Map < Scene_Base
  91.  
  92. alias galv_superman_map_initialize initialize
  93. def initialize
  94. galv_superman_map_initialize
  95. end
  96.  
  97. alias galv_superman_map_update_scene update_scene
  98. def update_scene
  99. galv_superman_map_update_scene
  100. $game_player.take_off if $game_player.taking_off
  101. $game_player.land if $game_player.landing
  102. end
  103.  
  104. end # Scene_Map < Scene_Base
  105.  
  106.  
  107. class Game_Player < Game_Character
  108. attr_accessor :through
  109. attr_accessor :altitude
  110. attr_accessor :step_anime
  111. attr_accessor :move_speed
  112. attr_accessor :priority_type
  113. attr_accessor :in_air
  114. attr_accessor :taking_off
  115. attr_accessor :landing
  116.  
  117. alias galv_superman_player_initialize initialize
  118. def initialize
  119. galv_superman_player_initialize
  120. @altitude = 0
  121. @in_air = false
  122. end
  123.  
  124. alias galv_superman_player_refresh refresh
  125. def refresh
  126. # stuff here
  127. galv_superman_player_refresh
  128. end
  129.  
  130. alias galv_superman_player_move_by_input move_by_input
  131. def move_by_input
  132. galv_superman_player_move_by_input
  133.  
  134. if Input.trigger?(Galv_Superman::BUTTON) && !@taking_off && !@landing
  135.  
  136. return if !$game_switches[Galv_Superman::ENABLE_SWITCH]
  137. return if !$game_player.can_fly? || !$game_player.normal_walk? || $game_map.interpreter.running?
  138.  
  139. if @in_air
  140. return if !$game_map.airship_land_ok?($game_player.x, $game_player.y) || !blocking_event?
  141. force_land
  142. else
  143. force_takeoff
  144. end
  145. end
  146. end
  147.  
  148. def blocking_event?
  149. $game_map.events_xy($game_player.x, $game_player.y).each do |event|
  150. return false if event.priority_type == 1
  151. end
  152. return true
  153. end
  154.  
  155. def force_land
  156. $game_player.move_speed -= Galv_Superman::SPEED_BONUS
  157. @in_air = false
  158. $game_player.through = false
  159. @landing = true
  160. end
  161.  
  162. def force_takeoff
  163. $game_system.menu_disabled = true
  164. $game_player.step_anime = true
  165. actor = $game_party.leader
  166. actor.set_graphic(actor.character_name + Galv_Superman::FLY_EXTENSION, actor.character_index, actor.face_name, actor.face_index)
  167. @in_air = true
  168. $game_player.through = true
  169. $game_player.priority_type = 2
  170. @taking_off = true
  171. $game_player.refresh
  172. end
  173.  
  174. def take_off
  175. $game_player.altitude += 1
  176. if $game_player.altitude >= 32
  177. $game_player.altitude = 32
  178. $game_player.move_speed += Galv_Superman::SPEED_BONUS
  179. @taking_off = false
  180. end
  181. end
  182. def land
  183. $game_player.altitude -= 1
  184. if $game_player.altitude <= 0
  185. $game_player.altitude = 0
  186. actor = $game_party.leader
  187. actor.set_graphic(actor.character_name.chomp(Galv_Superman::FLY_EXTENSION), actor.character_index, actor.face_name, actor.face_index)
  188. $game_player.refresh
  189. $game_system.menu_disabled = false
  190. $game_player.step_anime = false
  191. $game_player.priority_type = 1
  192. @landing = false
  193. end
  194. end
  195.  
  196. def can_fly?
  197. # Check switch
  198. return true if !Galv_Superman::REQUIREMENTS
  199.  
  200. # Check actor
  201. return true if $data_actors[$game_party.leader.id].flight
  202.  
  203. # Check actor's skills
  204. $game_party.leader.skills.each do |s|
  205. return true if s.flight
  206. end
  207.  
  208. # Check equips
  209. no_equips = $game_party.leader.equips.count
  210. no_equips.times { |i|
  211. if $game_party.leader.equips[i] != nil
  212. return true if $game_party.leader.equips[i].flight
  213. end
  214. }
  215. return false
  216. end
  217.  
  218. def screen_y
  219. super - @altitude
  220. end
  221.  
  222. alias galv_superman_in_airship? in_airship?
  223. def in_airship?
  224. if !Galv_Superman::ACTIVATE_EVENTS
  225. @vehicle_type == :airship || @altitude > 0
  226. else
  227. galv_superman_in_airship?
  228. end
  229. end
  230.  
  231. alias galv_superman_player_get_on_vehicle get_on_vehicle
  232. def get_on_vehicle
  233. return if @altitude > 0
  234. galv_superman_player_get_on_vehicle
  235. end
  236. end # Game_Player < Game_Character
  237.  
  238.  
  239. class Spriteset_Map
  240. alias galv_superman_update_shadow update_shadow
  241. def update_shadow
  242. if $game_player.altitude > 0
  243. player = $game_player
  244. @shadow_sprite.x = player.screen_x
  245. @shadow_sprite.y = player.screen_y + player.altitude
  246. @shadow_sprite.opacity = player.altitude * 8
  247. @shadow_sprite.update
  248. else
  249. galv_superman_update_shadow
  250. end
  251. end
  252. end # Spriteset_Map
  253.  
  254.  
  255. class Game_Interpreter
  256. def flying?
  257. $game_player.altitude > 0
  258. end
  259. end # Game_Interpreter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement