Galv’s Superman Ability V.1.5

NOTE: This script is NOT designed for use with followers. For one that is, look here.

Demo – Version 1.5 >

#------------------------------------------------------------------------------#
#  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 = :X                # 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 = true     # 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
Advertisements

20 thoughts on “Galv’s Superman Ability V.1.5

  1. harry mckay says:

    how can i use a different button for it

    • Galv says:

      In the settings where it says:
      BUTTON = :X

      :X is the “a” key. Start a test play of your project and press F1 to see the controls and which controller button corresponds with which key.

  2. BillyD says:

    hey really nice mod I coppied the script to materials in my own game I play tested it when I press “a” nothing happens there’s no flying animation and in my computer/user/documents/rpgvxace/project6/graphics/characters i copied my character ‘s folder(a character that I created) i renamed it and put _fly at the end and still nothing happens please help me (sorry for my bad english:/)

  3. BillyD says:

    How do i turn it on? I checked the script and it was ENABLE_SWITCH = 1 but i still couldn’t fly

  4. Dream says:

    Thank you for this awesome script. Is it possible to use a sound effect or BGM before initiating flight?. Thanks!

    • Galv says:

      That would require a small change in the script – I am currently really busy I recommend asking in forums for someone to change for you :)

  5. everybear says:

    Can the height that the sprite floats above the ground be adjusted? Im using this with a Mode 7 script and the actor is clipping through events on the ground rather than floating above them.

  6. Mordrid says:

    Thanks for the awesome script! But there’s a rather troublesome typo in the script’s instructions–it says to use the notetag “fly”, when it needs to be “flight”. It’s easy enough to figure out if ya download and poke at the demo, but thought you might want to know. |Da

  7. Kyle says:

    Hey so does the very first switch have to be called EVENT_SWITCH in order to use the flight ability? Also is there a way to set up for only one character to be able to fly?

    • Galv says:

      In the settings, where it says:
      ENABLE_SWITCH = 1

      That refers to switch number 1 in game. You can change this number to any switch you want to use. What you call the switch in the editor doesn’t matter as long as it’s the same number.

      For only one character to be able to fly, put the notetag (in the notes section of the actor):

  8. Kyle says:

    Actually never mind. I think I just have to make graphics of the character flying.

  9. Drbigt says:

    Is there a way to have a switch or something to check that they can’t fly? Like, inside a house or something could say something like “The roof is too low, I can’t fly here!” ?

    • Galv says:

      In the settings there is a switch to enable flying:
      ENABLE_SWITCH = 1 # Can only fly when this switch is ON

      Unfortunately I dont have time to add anything custom to the script if this doesn’t do what you are after

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s