• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Mach and Acro Bike script

1,748
Posts
14
Years
Well, title says all I. This script allows use of the Mach Bike and Acro Bike

Code:
################################################################################
# Mach & Acro Bike Script
# By Rei
# Credits required
################################################################################
# * Adds the Support for Acro Bikes and Mach Bikes!
#
# * How To Use (Acro Bike):
#    - Insert Script
#    - Edit the AcroBikeFileName Setting to what your Acro Bike Graphics would be
#    - ADD THE GRAPHICS INTO THE CHARACTERS FOLDER
#    - ADD THE ITEM "ACROBIKE" (The internal name must be ACROBIKE at the very
#       least)
#
# * How To Use (Mach Bike):
#   - ADD THE ITEM "MACHBIKE" (The internal name must be MACHBIKE at the very
#       least)
#
# * How to create Acro Bike Rails:
#   - Go into the Tileset Editor (through DEBUG mode or Essentials)
#   - Find your desired Acro Bike Rails and set their Terrain Tag to 16
#   - Go into RMXP's tileset editor and set the passages (4dir) of the rails
#     to what it would normally be to pass (EG: Rails left and right need the
#     left and right passages open but the top and bottom closed)
#
#
# * How to create Acro Bike Stepping Stones:
#   - Go into the Tileset Editor (through DEBUG mode or Essentials)
#   - Find your desired Acro Bike Stepping Stones and set their Terrain Tag to 17
#   - Go into RMXP's tileset editor and set the passages of the stepping stones
#     to impassable (the script will allow you to move on them while hopping)
#
# * How to create Mach Bike Slopes:
#   - Go into the Tileset Editor (through DEBUG mode or Essentials)
#   - Find your desired Mach Bike Slopes and set their Terrain Tag to 18
#   - Go into RMXP's tileset editor and set the passages of the slope to passable
#
#
# * Updates:
#    - Fixed Where you can turn to incorrect directions on rails
#    - Fixed Where you need to do a wheelie on an Acro Bike to access rails
#    - Fixed Where there is a few frame skips between running/biking animations
#    - Fixed When you switch from the Acro Bike to a regular Bike, that the
#       regular bike has the settings of the Acro Bike
#    - Added Rail to Rail Jumping on Acro Bikes
#    - Added Mach Bike Support
#
################################################################################

module Settings
  AcroBikeFileName = [
  "boyAcro", # Player A
  "girlAcro", # Player B
  "", # Player C
  "", # Player D
  "", # Player E
  "", # Player F
  ]
end


class PBTerrain
  ACROBIKE = 16
  ACROBIKEHOP = 17
  MACHBIKE = 18
end


class Game_Map
  attr_accessor :acrobike
  attr_accessor :acrobike_held
  attr_accessor :forceacro
  attr_accessor :machbike_speed
  
  alias initialize_ab initialize
  def initialize
    @acrobike = 0
    @acrobike_held = 0
    @forceacro = 0
    @machbike_speed = 0
    initialize_ab
  end
  
  def passable?(x, y, d, self_event = nil)
    return false if !valid?(x, y)
    bit = (1 << (d / 2 - 1)) & 0x0f
    for event in events.values
      if event.tile_id >= 0 and event != self_event and
         event.x == x and event.y == y and not event.through
        return false if @passages[event.tile_id] & bit != 0
        return false if @passages[event.tile_id] & 0x0f == 0x0f
        return true if @priorities[event.tile_id] == 0
      end
    end
    for i in [2, 1, 0]
      tile_id = data[x, y, i]
      next if tile_id && @terrain_tags[tile_id]==PBTerrain::Bridge &&
              $PokemonMap && $PokemonMap.bridge==0
      if tile_id == nil
        return false
      # Make water tiles passable if player is surfing
      elsif pbIsPassableWaterTag?(@terrain_tags[tile_id]) &&
         $PokemonGlobal.surfing #&& self_event==$game_player
        return true
      elsif @terrain_tags[tile_id]==PBTerrain::TallGrass &&
         $PokemonGlobal.bicycle && self_event==$game_player
        return false
      elsif @terrain_tags[tile_id]==PBTerrain::Bridge && $PokemonMap &&
            $PokemonMap.bridge>0
        if @passages[tile_id] & bit != 0 ||
           @passages[tile_id] & 0x0f == 0x0f
          return false
        else
          return true
        end
      elsif @terrain_tags[tile_id]==PBTerrain::MACHBIKE
        return self_event==$game_player || self_event==nil
      elsif @terrain_tags[tile_id]==PBTerrain::ACROBIKE && self_event==$game_player &&
      $PokemonGlobal.acrobike && (@passages[tile_id] & bit == 0)
        return true
      elsif (@terrain_tags[tile_id]==PBTerrain::ACROBIKEHOP || @terrain_tags[tile_id]==PBTerrain::ACROBIKE) && 
        @acrobike==2 && self_event==$game_player && $PokemonGlobal.acrobike
        return true
      elsif @terrain_tags[tile_id]==PBTerrain::ACROBIKE && !$PokemonGlobal.acrobike
        return false
      elsif @terrain_tags[tile_id]==PBTerrain::ACROBIKEHOP && !$PokemonGlobal.acrobike
        return false
      elsif @passages[tile_id] & bit != 0
        return false
      elsif @passages[tile_id] & 0x0f == 0x0f
        return false
      elsif @priorities[tile_id] == 0
        return true
      end
    end
    return true
  end
  
  alias update_ab update
  def update
    @acrobike_held += 1 if !$game_player.moving?
    @acrobike_held = 0 if !Input.press?(Input::A) || !$PokemonGlobal.acrobike
    @acrobike_held = 1 if Input.press?(Input::A) && $game_player.moving? &&
                          @acrobike < 2 && @acrobike != 0
    tag = pbGetTerrainTag($game_player)
    @forceacro = 0
    @forceacro = 1 if tag == PBTerrain::ACROBIKEHOP
    @acrobike = @forceacro
    @acrobike = 1 if @acrobike_held > 0
    if acrobike_held >= Graphics.frame_rate * 2
      @acrobike = 2
    end
    
    
    if $game_player.passableEx?($game_player.x, $game_player.y,
      $game_player.direction) && $PokemonGlobal.machbike && Input.dir4 != 0
      @machbike_speed += 0.1
      @machbike_speed = 3 if @machbike_speed > 3
    else
      @machbike_speed = 0
    end
    
    ### Graphical things
    graphic = Settings::AcroBikeFileName[$PokemonGlobal.playerID]
    if FileTest.image_exist?("Graphics/Characters/" + graphic) && Input.press?(Input::A) &&
      $PokemonGlobal.acrobike
      $game_player.character_name = graphic
    elsif Input.release?(Input::A)
      Kernel.pbUpdateVehicle
    end
    if @acrobike > 1
      if !$game_player.jumping?
        Kernel.pbJumpToward(0)
        pbSEPlay("jump")
      end
    end
    update_ab
  end
  
end

class Game_Player
  alias update_ab update
  def update
    dir = @direction
    update_ab
    dir2 = @direction
    # Make it so you can't turn incorrectly on rails
    if $PokemonGlobal.acrobike && terrain_tag == PBTerrain::ACROBIKE
      if !passableEx?(x, y, @direction, false)
        @direction=dir
      end
    end

    # Do a jump onto another rail
    if !passableEx?(x, y, dir2, false) && Input.trigger?(Input::A) && $PokemonGlobal.acrobike
      dir = @direction
      if (dir2 == 2) # Down
        tag = $game_map.terrain_tag(x, y + 1, false)
        if tag == PBTerrain::ACROBIKE
          $game_player.jump(0,1)
          pbSEPlay("jump")
        end
      elsif (dir2 == 4) # Left
        tag = $game_map.terrain_tag(x - 1, y, false)
        if tag == PBTerrain::ACROBIKE
          $game_player.jump(-1,0)
          pbSEPlay("jump")
        end
      elsif (dir2 == 6) # Right
        tag = $game_map.terrain_tag(x + 1, y, false)
        if tag == PBTerrain::ACROBIKE
          $game_player.jump(1,0)
          pbSEPlay("jump")
        end
      elsif (dir2 == 8) # Up
        tag = $game_map.terrain_tag(x, y - 1, false)
        if tag == PBTerrain::ACROBIKE
          $game_player.jump(0,-1)
          pbSEPlay("jump")
        end
      end
      @direction = dir
    end
    
    #### Mach Bike
    if $PokemonGlobal.machbike
      @move_speed = 3 + $game_map.machbike_speed.floor
    end
    if $game_map.machbike_speed < 2 && terrain_tag == PBTerrain::MACHBIKE
      move_down(false)
      $game_map.machbike_speed = 0
    end
  end
end

class PokemonGlobalMetadata
  attr_accessor :acrobike
  attr_accessor :machbike
end

ItemHandlers::UseInField.add(:BICYCLE,proc{|item|
    if pbBikeCheck
     $PokemonGlobal.machbike = false
     $PokemonGlobal.acrobike = false
     if $PokemonGlobal.acrobike
       Kernel.pbDismountBike
       $PokemonGlobal.bicycle = false
     else
       Kernel.pbMountBike 
       $PokemonGlobal.bicycle = true
     end
   end
})

# Add Acro Bike Property
ItemHandlers::UseInField.add(:ACROBIKE,proc{|item|
   if pbBikeCheck
     $PokemonGlobal.machbike = false
     if $PokemonGlobal.acrobike
       Kernel.pbDismountBike
       $PokemonGlobal.acrobike = false
     else
       Kernel.pbMountBike 
       $PokemonGlobal.acrobike = true
     end
   end
})

# Add Mach Bike Property
ItemHandlers::UseInField.add(:MACHBIKE,proc{|item|
   if pbBikeCheck
     $PokemonGlobal.acrobike = false
     if $PokemonGlobal.machbike
       Kernel.pbDismountBike
       $PokemonGlobal.machbike = false
     else
       Kernel.pbMountBike 
       $PokemonGlobal.machbike = true
     end
   end
})
 
Last edited:
423
Posts
13
Years
  • Age 37
  • Seen Aug 31, 2023
this sounds similar to rollerskates in gen6 (sorry only played gen 1,5 and 6)
 

PiaCRT

[i]Orange Dev[/i]
934
Posts
13
Years
this sounds similar to rollerskates in gen6 (sorry only played gen 1,5 and 6)

While similar the two area bit different. The rollerskates are like a combination of Mach and Acro Bike since the rails in gen 6 require speed to jump over the breaks. The Acro Bike was known for being slow compared to the mach bike but could be used to ride over rails and jump over breaks to get to areas otherwise inaccessible, whereas the mach bike was used to climb mud slides or ride across cracked floors to reach otherwise inaccessible areas once you had gained enough speed.
 

ShadowFiendZX

Gym Leader
59
Posts
11
Years
This script works quite well.
I made made some tiles from game screenshots, and I'm working on a few more, plus the character sprites.
Although the character sprites need to be reprogrammed if they are to act like they do in emerald.
Also, hopping from rail to rail, or from stone to stone doesn't seem to work.
pokemon-emerald182.png

That screenshot shows the rail setup to hop from rail to rail.
And I'm pretty sure the Mach Bike allowed for changing gears, one for slow, and one for fast. Although it's been a while since I played Emerald, so I could be mistaken.
Other than the hopping bug, this script works well.
Thanks for your hard work and releasing it to the public. :)
 
1,748
Posts
14
Years
This script works quite well.
I made made some tiles from game screenshots, and I'm working on a few more, plus the character sprites.
Although the character sprites need to be reprogrammed if they are to act like they do in emerald.
Also, hopping from rail to rail, or from stone to stone doesn't seem to work.
pokemon-emerald182.png

That screenshot shows the rail setup to hop from rail to rail.
And I'm pretty sure the Mach Bike allowed for changing gears, one for slow, and one for fast. Although it's been a while since I played Emerald, so I could be mistaken.
Other than the hopping bug, this script works well.
Thanks for your hard work and releasing it to the public. :)

I haven't had a problem from jumping from rail to rail, and I think the gear setting on the Mach Bike was introduced in D/P/Pt but I do appreciate the feedback

EDIT: Wait, for the jumping problem, are the rails right next to each other (in terms of map tiles) or are they seperated by at least one block?
 

ShadowFiendZX

Gym Leader
59
Posts
11
Years
In terms of map tiles they are right next to eachother. Also, if there is no rail above or below, while hopping on a rail and pressing towards that direction that has no rail, you jump off even though the passage isn't set for that direction. I'm sure I copied the script properly. And the only think I changed were the terrain tags since I already used 16 & 17

Edit: the tiles I used were the ones included in my previous post on this topic.
 
1,748
Posts
14
Years
In terms of map tiles they are right next to eachother. Also, if there is no rail above or below, while hopping on a rail and pressing towards that direction that has no rail, you jump off even though the passage isn't set for that direction. I'm sure I copied the script properly. And the only think I changed were the terrain tags since I already used 16 & 17

That's strange, did you setup the passages right?

Here's an image for incase: View attachment 70784
 

ShadowFiendZX

Gym Leader
59
Posts
11
Years
I setup the passages only for left/right since that was the only tile I ended up doing.
I set up the rail and stones Right on a flat patch of dirt. So maybe that's why it wouldn't work. I'm not on a computer right now, as it's 10:09 pm so I can't double check.
 
1,748
Posts
14
Years
I setup the passages only for left/right since that was the only tile I ended up doing.
I set up the rail and stones Right on a flat patch of dirt. So maybe that's why it wouldn't work. I'm not on a computer right now, as it's 10:09 pm so I can't double check.

Not sure, here is a video showing that it works fine for me....



EDIT: Did you get the update I posted yesterday or not? if not, that would be the problem
 

ShadowFiendZX

Gym Leader
59
Posts
11
Years
Hm. I think I only tried jumping across while the bike was jumping up and down. Maybe that's it, although that doesn't explain the stone thing. I copied and pasted the code at noon, so I'm sure I got the updated version. I'll repaste it tomorrow and see. I'd leave a comment on your gts script as well, but I know next to nothing about MySQL. I did try it anyway though, from a webhost as my apple time capsule doesn't like port forwarding or allowing outside connections. GTScore.install didn't do anything, ad I gave up in pursuit of fine tuning a script I've been working on. I might try again with the gts tomorrow though, maybe I messed up.
 
1,748
Posts
14
Years
Hm. I think I only tried jumping across while the bike was jumping up and down. Maybe that's it, although that doesn't explain the stone thing. I copied and pasted the code at noon, so I'm sure I got the updated version. I'll repaste it tomorrow and see. I'd leave a comment on your gts script as well, but I know next to nothing about MySQL. I did try it anyway though, from a webhost as my apple time capsule doesn't like port forwarding or allowing outside connections. GTScore.install didn't do anything, ad I gave up in pursuit of fine tuning a script I've been working on. I might try again with the gts tomorrow though, maybe I messed up.

Up and down works for the Acro Bike as well, I didn't really test the stepping stones much, but I'll take a look at that a bit more
 

ShadowFiendZX

Gym Leader
59
Posts
11
Years
Turns out, you have to press the direction then press Z. Here's a video of me testing out the features, and it shows that you can hop on and off rails for some reason.
 
1,748
Posts
14
Years
Turns out, you have to press the direction then press Z. Here's a video of me testing out the features, and it shows that you can hop on and off rails for some reason.

Well, the pressing "Z" thing is actually because I was playing R/S/E the other day to try and get it working exactly like that and I noticed you could only jump from rail to rail by pressing "B" and the direction at the same time.

and the hopping on and off rails was at first a glitch but I decided to leave it because why not be able to jump on rails from anywhere?
 

ShadowFiendZX

Gym Leader
59
Posts
11
Years
Well, the pressing "Z" thing is actually because I was playing R/S/E the other day to try and get it working exactly like that and I noticed you could only jump from rail to rail by pressing "B" and the direction at the same time.

and the hopping on and off rails was at first a glitch but I decided to leave it because why not be able to jump on rails from anywhere?

Ah I see. Makes sense. Do you know of a way to select a single frame of the character sprite for not moving, and the other 3 for moving? That way I can use the sprites I made, or should I just make a separate set of character sprites, one for wheeling but not moving (or while hopping), and one for riding around and wheeling, then program for the like?
 
1,748
Posts
14
Years
Ah I see. Makes sense. Do you know of a way to select a single frame of the character sprite for not moving, and the other 3 for moving? That way I can use the sprites I made, or should I just make a separate set of character sprites, one for wheeling but not moving (or while hopping), and one for riding around and wheeling, then program for the like?

Just use a regular character set, this already does everything you need. All you need is a bicycle set (which is just your normal bicycle) and then a wheelie set for the bicycle... It automatically does everything above if you have those two set.
 
Back
Top