Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #------------------------------------------------------------------------------#
- # Galv's Superman Ability
- #------------------------------------------------------------------------------#
- # For: RPGMAKER VX ACE
- # Version 1.5
- #------------------------------------------------------------------------------#
- # 2014-09-24 - Version 1.5 - fixed <fly> typo notetage to <flight>
- # 2012-11-30 - Version 1.5 - can set equip/skill/actor requirements to fly
- # - fixed talking and trying to fly/land bug
- # - added script calls to force takeoff and land
- # 2012-11-14 - Version 1.4 - can no longer land on same-as-player events
- # 2012-11-13 - Version 1.3 - another bug fix, priority wasn't above when fly.
- # 2012-11-13 - Version 1.2 - another bug fix, making vehicle speed change.
- # 2012-11-13 - Version 1.1 - fixed bug where could board vehicles while flying.
- # 2012-11-13 - Version 1.0 - release
- #------------------------------------------------------------------------------#
- # This script allows the player to gain the power of flight and land/takeoff
- # whenever they want to. (Designed for use with NO followers.)
- #------------------------------------------------------------------------------#
- # INSTRUCTIONS:
- # Read the setup options below and set it up as desired.
- #------------------------------------------------------------------------------#
- # SCRIPT CALLS:
- #------------------------------------------------------------------------------#
- #
- # flying? # return true or false. Use in conditional branch if ACTIVATE_EVENTS
- # # is set to true in the settings below
- #
- # $game_player.force_land # script call to force player to land
- # $game_player.force_takeoff # script call to force player to take off
- #
- #------------------------------------------------------------------------------#
- # NOTETAG ACTORS / EQUIPS / SKILLS:
- #------------------------------------------------------------------------------#
- #
- # <flight> # if REQUIREMENTS = true, then the leader requires a notetag on
- # # them, one of their equips or a skill they know.
- #
- #------------------------------------------------------------------------------#
- ($imported ||= {})["Galvs_Superman_Ability"] = true
- module Galv_Superman
- #------------------------------------------------------------------------------#
- # SCRIPT SETUP OPTIONS
- #------------------------------------------------------------------------------#
- ENABLE_SWITCH = 1 # Can only fly when this switch is ON
- REQUIREMENTS = true # Leader requires actor/equip/skill <fly> tag
- # false = dont need to tag anything to fly
- SPEED_BONUS = 1 # Speed increases by this number when flying.
- BUTTON = :R # Button to press to fly and land. :X is "a" key.
- FLY_EXTENSION = "_fly" # Character set for when actor is flying. If your
- # actor uses "Actor1.png" then you must have a file
- # called "Actor1_fly.png" if this extenstion is set
- # to "_fly". The actor must be in the same position
- # in both charsets.
- ACTIVATE_EVENTS = false # If true, can still activate events as normal.
- # If false, will work like airship does, unable to
- # activate events until landed.
- #------------------------------------------------------------------------------#
- # END SCRIPT SETUP OPTIONS
- #------------------------------------------------------------------------------#
- end
- class RPG::BaseItem
- def flight
- if @flight.nil?
- if @note =~ /<flight>/i
- @flight = true
- else
- @flight = false
- end
- end
- @flight
- end
- end # RPG::BaseItem
- class Scene_Map < Scene_Base
- alias galv_superman_map_initialize initialize
- def initialize
- galv_superman_map_initialize
- end
- alias galv_superman_map_update_scene update_scene
- def update_scene
- galv_superman_map_update_scene
- $game_player.take_off if $game_player.taking_off
- $game_player.land if $game_player.landing
- end
- end # Scene_Map < Scene_Base
- class Game_Player < Game_Character
- attr_accessor :through
- attr_accessor :altitude
- attr_accessor :step_anime
- attr_accessor :move_speed
- attr_accessor :priority_type
- attr_accessor :in_air
- attr_accessor :taking_off
- attr_accessor :landing
- alias galv_superman_player_initialize initialize
- def initialize
- galv_superman_player_initialize
- @altitude = 0
- @in_air = false
- end
- alias galv_superman_player_refresh refresh
- def refresh
- # stuff here
- galv_superman_player_refresh
- end
- alias galv_superman_player_move_by_input move_by_input
- def move_by_input
- galv_superman_player_move_by_input
- if Input.trigger?(Galv_Superman::BUTTON) && !@taking_off && !@landing
- return if !$game_switches[Galv_Superman::ENABLE_SWITCH]
- return if !$game_player.can_fly? || !$game_player.normal_walk? || $game_map.interpreter.running?
- if @in_air
- return if !$game_map.airship_land_ok?($game_player.x, $game_player.y) || !blocking_event?
- force_land
- else
- force_takeoff
- end
- end
- end
- def blocking_event?
- $game_map.events_xy($game_player.x, $game_player.y).each do |event|
- return false if event.priority_type == 1
- end
- return true
- end
- def force_land
- $game_player.move_speed -= Galv_Superman::SPEED_BONUS
- @in_air = false
- $game_player.through = false
- @landing = true
- end
- def force_takeoff
- $game_system.menu_disabled = true
- $game_player.step_anime = true
- actor = $game_party.leader
- actor.set_graphic(actor.character_name + Galv_Superman::FLY_EXTENSION, actor.character_index, actor.face_name, actor.face_index)
- @in_air = true
- $game_player.through = true
- $game_player.priority_type = 2
- @taking_off = true
- $game_player.refresh
- end
- def take_off
- $game_player.altitude += 1
- if $game_player.altitude >= 32
- $game_player.altitude = 32
- $game_player.move_speed += Galv_Superman::SPEED_BONUS
- @taking_off = false
- end
- end
- def land
- $game_player.altitude -= 1
- if $game_player.altitude <= 0
- $game_player.altitude = 0
- actor = $game_party.leader
- actor.set_graphic(actor.character_name.chomp(Galv_Superman::FLY_EXTENSION), actor.character_index, actor.face_name, actor.face_index)
- $game_player.refresh
- $game_system.menu_disabled = false
- $game_player.step_anime = false
- $game_player.priority_type = 1
- @landing = false
- end
- end
- def can_fly?
- # Check switch
- return true if !Galv_Superman::REQUIREMENTS
- # Check actor
- return true if $data_actors[$game_party.leader.id].flight
- # Check actor's skills
- $game_party.leader.skills.each do |s|
- return true if s.flight
- end
- # Check equips
- no_equips = $game_party.leader.equips.count
- no_equips.times { |i|
- if $game_party.leader.equips[i] != nil
- return true if $game_party.leader.equips[i].flight
- end
- }
- return false
- end
- def screen_y
- super - @altitude
- end
- alias galv_superman_in_airship? in_airship?
- def in_airship?
- if !Galv_Superman::ACTIVATE_EVENTS
- @vehicle_type == :airship || @altitude > 0
- else
- galv_superman_in_airship?
- end
- end
- alias galv_superman_player_get_on_vehicle get_on_vehicle
- def get_on_vehicle
- return if @altitude > 0
- galv_superman_player_get_on_vehicle
- end
- end # Game_Player < Game_Character
- class Spriteset_Map
- alias galv_superman_update_shadow update_shadow
- def update_shadow
- if $game_player.altitude > 0
- player = $game_player
- @shadow_sprite.x = player.screen_x
- @shadow_sprite.y = player.screen_y + player.altitude
- @shadow_sprite.opacity = player.altitude * 8
- @shadow_sprite.update
- else
- galv_superman_update_shadow
- end
- end
- end # Spriteset_Map
- class Game_Interpreter
- def flying?
- $game_player.altitude > 0
- end
- end # Game_Interpreter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement