- Joined
- Aug 28, 2012
- Messages
- 6
- Reaction score
- 1
- First Language
- English
- Primarily Uses
I updated your code for Ace if you don't mind so others can use it. It did make a few changes being a professional programmer. So here you go so you can post the update (please take all the credit given that it is your idea and original work). Good job by the way for VX.
Code:
module CallBoatConfig
# The item that must be in inventory for the boat to be called
ITEM_ID = 147
# If this is set to "true", a map name must include this text:
#
# <boat>
#
# in order for the boat to be called automatically.
USE_BOAT_REQ = true
# If this is set to "true", an animation will play
# when the player gets on or off the boat.
USE_ANIMATION = true
# The animation displayed when the player gets on the
# boat if USE_ANIMATION is set to "true".
ON_ANIMATION_ID = 75
# The animation displayed when the player gets off of the
# boat if USE_ANIMATION is set to "true".
OFF_ANIMATION_ID = 75
# If this is set to "true", the boat will
# disappear when the player gets off of it.
REMOVE_VEHICLE = true
end
class Game_Vehicle
attr_accessor :direction
end
class Game_Map
alias :eds_pre_call_setup :setup
def setup(map_id)
eds_pre_call_setup(map_id)
@info = load_data("Data/MapInfos.rvdata2")
end
def can_use_boat?
return true unless CallBoatConfig::USE_BOAT_REQ
return @info[@map_id].name.downcase.include?("<boat>")
end
end
class Game_Player < Game_Character
include CallBoatConfig
def get_directional_pos(d)
x, y = 0, 0;
case(d)
when 8 #up
y, x = @y - 1, @x;
when 2 #down
y, x = @y + 1, @x;
when 6 #right
x, y = @x + 1, @y;
y = @y
when 4 #left
x, y = @x - 1, @y;
end
return x, y;
end
def should_call_boat?(d)
x, y = get_directional_pos(d);
if ($game_map.can_use_boat? &&
$game_party.items.include?($data_items[ITEM_ID]) &&
$game_map.boat_passable?(x, y) &&
!@vehicle_getting_on &&
!in_boat?)
auto_call_boat(x, y);
return true;
end
return false;
end
def auto_call_boat(x, y)
$game_map.boat.direction = $game_player.direction;
$game_map.boat.set_location($game_map.map_id, x, y);
if(USE_ANIMATION)
$game_map.boat.animation_id = ON_ANIMATION_ID
end
get_on_vehicle
end
#--------------------------------------------------------------------------
# * Move Up
#--------------------------------------------------------------------------
alias _move_straight move_straight
def move_straight(d, turn_ok = true)
_move_straight(d, turn_ok) unless should_call_boat?(d);
end
#--------------------------------------------------------------------------
# * Move Right
#--------------------------------------------------------------------------
alias _move_diagonal move_diagonal
def move_diagonal(d, turn_ok = true)
_move_diagonal(d, turn_ok) unless should_call_boat?(d);
end
#--------------------------------------------------------------------------
# * Get Off Vehicle
#--------------------------------------------------------------------------
alias _get_off_vehicle get_off_vehicle
def get_off_vehicle
in_boat = (@vehicle_type == 0);
_get_off_vehicle();
if REMOVE_VEHICLE
$game_map.boat.set_location(-1, -1, -1)
if USE_ANIMATION
$game_map.boat.animation_id = 75;
end
end
end
end

