Galv’s Vehicle Riders V.1.1

No demo yet – will add one later.

#------------------------------------------------------------------------------#
#  Galv's Vehicle Riders
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.1
#------------------------------------------------------------------------------#
#  2013-02-08 - Version 1.1 - fixed bug with single character filesheets
#  2013-02-07 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  Allows you to make the player mount certain vehicles.
#
#  Instructions:
#  Place under Materials and above Main
#------------------------------------------------------------------------------#

($imported ||= {})["Galv_Riders"] = true
module Galv_Riders

#------------------------------------------------------------------------------#  
#  SETUP OPTIONS
#------------------------------------------------------------------------------#

  MOUNTS = [:boat,:ship]  # Which vehicles you want to be mountable only these
                          # vehicles will use mounts, others will not
  
#------------------------------------------------------------------------------#
  POS = {} # Don't touch this
#------------------------------------------------------------------------------#

  # Below is to specify positioning of the rider graphic for each vehicle and
  # to specify if it uses a different charactersheet or not. These options are:
  # [x offset, y offset, charactersheet extension, horse]

  POS[:boat] = [6,-12,"", true]
  POS[:ship] = [0,-9,"_ship", false]
  POS[:airship] = [0,0,"",false]

#------------------------------------------------------------------------------#
#  EXPLANATION
#------------------------------------------------------------------------------#

  # x offset - will offset the rider horizontally that many pixels
  # y offset - will offset the rider vertically that many pixels
  # charactersheet extension - To use a different charactersheet for the rider.
  #       If this is set to "_rider" and the group leader uses "Actor4" charset
  #       then it will look for "Actor4_rider" charset to use when mounted on
  #       that vehicle. Leave this option as "" to use the actor's charset.
  # horse - when facing down, the actor's graphic will appear under the vehicle
  #         this was made with the horse from the "animal" charset in mind.

#------------------------------------------------------------------------------#  
#  END SETUP OPTIONS
#------------------------------------------------------------------------------#
end



class Game_Vehicle < Game_Character
  attr_reader :type
end # Game_Vehicle < Game_Character

class Spriteset_Map
  alias galv_riders_sm_create_characters create_characters
  def create_characters
    galv_riders_sm_create_characters
    @riders_sprites = []
    $game_map.vehicles.each do |v|
      if Galv_Riders::MOUNTS.include?(v.type)
        @riders_sprites.push(Sprite_riders.new(@viewport1, v))
      end
    end
  end
  
  alias galv_riders_sm_update update
  def update
    galv_riders_sm_update
    @riders_sprites.each {|s| s.update}
  end

  alias galv_riders_sm_dispose_characters dispose_characters
  def dispose_characters
    galv_riders_sm_dispose_characters
    @riders_sprites.each {|s| s.dispose}
  end
end # Spriteset_Map


class Sprite_riders < Sprite_Character
  def initialize(viewport, character = nil)
    super(viewport, character)
    @character = character
    update
  end

  def update
    update_bitmap
    update_src_rect
    update_position
    update_other
  end
  
  def set_character_bitmap
    self.bitmap = Cache.character($game_party.leader.character_name + 
    Galv_Riders::POS[@character.type][2]) rescue Cache.character($game_party.leader.character_name)
    sign = $game_party.leader.character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch
  end

  def update_src_rect
    if @tile_id == 0
      index = $game_party.leader.character_index
      pattern = @character.pattern < 3 ? @character.pattern : 1
      sx = (index % 4 * 3 + pattern) * @cw
      sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
  end
  
  def update_position
    self.x = @character.screen_x
    self.y = @character.screen_y + Galv_Riders::POS[@character.type][1]
    self.z = 150
    case $game_player.direction
    when 2; self.z = 100 if Galv_Riders::POS[@character.type][3]
    when 4; self.x += Galv_Riders::POS[@character.type][0]
    when 6; self.x -= Galv_Riders::POS[@character.type][0]
    end
  end
  
  def update_other
    @character.driving ? self.opacity = 255 : self.opacity = 0
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    self.visible = !@character.transparent
  end
  
end # Sprite_riders < Sprite_Character
Advertisements

3 thoughts on “Galv’s Vehicle Riders V.1.1

  1. Megablackdragon says:

    Sorry to bother yourself Galv,it is posible to dissable the actor walking? The poor chocobo/dragon are suffering because three is a moron waliking in their backs. :P Excuse me for my bad english and thanks you very much for this great script.
    PD: i understand you are busy,you dont have to fullfill my request if you dont want to.

    • Galv says:

      Unfortunately I am busy – if there’s no setting for it then someone would have to add it via script

    • jimmy says:

      You can probably just create a switch that would control if the character animation is on/off while he rides. You have to create a way for your player to get on/off anyways.

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