- 1,748
- Posts
- 15
- Years
- Age 28
- Nearby my feet.
- Seen Apr 18, 2021
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: