I am using a map script that will allow me to use a picture for the world map, this is what it is....:
[spoiler]#==============================================================================
# World Map Script
# by arevulopapo (rmxp.pl)
# Jul 13th 2007
#
# Updates:
# - Music volumes for map and airship added Jul 17th 2007
#
#
#
# Overview:
# This script lets you create a world map with pictures. It has built in boat
# and airship vehicles. It also allows to set different encouters (troops and
# battlebacks) for any region of the map. Also, you're able to create waypoints
# with different names displayed in a window, and, if you desire, with graphics
# (also animated). Waypoints are what transfers the player to game maps.
#
# Installation:
# Paste this section (Instructions/Settings) over the "Main", and the "World Map"
# section right under this one.
#
# General information:
# The picture of a map should be named "map.jpg" and located in the "Pictures"
# folder. Passability map (white - passable land, blue - water, black - unpassable)
# should be named "map_pass.png". Encounter map should be named "map_enc.png".
# Colors on the encounter map, and troops/backdrops assigned to them are defined
# below.
# To enter a world map from a game map call a script as follows:
# $game_system.map_coords = [x, y]
# $scene = scene_World_Map.new
# The x, y are coordinates at which the player will appear on the world map.
#
# Waypoint settings:
WAYPOINTS = [] # This is an array for waypoints. Don't touch it!
# You add new waypoints by pasting a line of code like this:
# WAYPOINTS << [x, y, enterable, data, "name", "picture", frames, speed]
# The parameters are as follows:
# x, y - Coordinates of the waypoint on the map.
# enterable - Set to true if a waypoint leads to some location, or false if it doesn't.
# data - This is an array of game map ID, and position of a player on that map,
# these are used when a waypoint is enterable, and has been entered from
# the world map. The structure is like this: [map_id, map_x, map_y].
# "name" - This is the name that will be displayed in the window if a player is
# close to the waypoint. If the name is "" - the window won't open.
# "picture" - Filename of the picture for the waypoint. If "" no graphic will be displayed.
# frames - If the waypoint is animated insert the frames number of the graphic.
# The frames should be in one row (see exaples in the "Pictures" folder).
# speed - Speed od animation between multiple frames.
#
# Exaple waypoints present on map:
WAYPOINTS << [690, 470, true, [1,9,13], "Mountain Path", "", 1, 10]
WAYPOINTS << [979, 640, false, [], "Obelisk", "obelisk.png", 1, 10]
WAYPOINTS << [800, 800, false, [], "", "flowers.png", 4, 10]
#
# Encounter settings:
ENCOUNTER_TERRAINS = [] # This is an array for encounters. Don't touch it!
# Add new terrains by pasting the following code:
# ENCOUNTER_TERRAINS << [color, troops, "back"]
# The parameters are as follows:
# color - A color on the "map_enc.png", defined as Color.new(red,green,blue).
# troops - Array of troops possible to encounter. Examples: [1], [2,5,30], etc.
# "back" - Filename of the battle backgroun from the "Battlebacks" folder.
# Example encouter terrains present in this demo:
ENCOUNTER_TERRAINS << [Color.new(0,128,0), [1,2,3], "002-Woods01"]
ENCOUNTER_TERRAINS << [Color.new(0,255,0), [10,12,31], "001-Grassland01"]
ENCOUNTER_TERRAINS << [Color.new(0,255,255), [11,22,32], "006-Desert01"]
ENCOUNTER_TERRAINS << [Color.new(255,0,255), [25,26,28], "041-EvilCastle01"]
#
# Other settings:
# The rest is set up in the Game_System class, located below. Each parameter
# to set up is commented.
#==============================================================================
# ** Edit to Game_System class. Setup here.
#==============================================================================
class Game_System
attr_accessor :on_map
attr_accessor :map_coords
attr_accessor :airship_coords
attr_accessor :airship_switch
attr_accessor :boat_coords
attr_accessor :boat_switch
attr_accessor :map_sprite_scale
attr_accessor :map_bgm
attr_accessor :map_airship_bgm
attr_accessor :battle_interval
attr_accessor :battle_steps
attr_accessor :map_fog
attr_accessor :map_speeds
attr_accessor :fog_scale
attr_accessor :map_volume
attr_accessor :airship_volume
attr_accessor :birds_graphic
attr_accessor :birds_switch
#--------------------------------------------------------------------------
alias game_sys_initialize initialize
#--------------------------------------------------------------------------
def initialize
@on_map = false
@map_coords = [1024, 512] # Position on the map. Usually it's changed each time when entering a world map.
@airship_switch = false
@airship_coords = [1741,285] # Position of the airship on the map.
@boat_switch = false
@boat_coords = [316,1639] # Position of the boat on the map.
@map_sprite_scale = 0.5 # Scale of the player's sprite
@map_bgm = "ff6 terra" # Map BGM located in the "Audio/BGM" folder.
@map_volume = 100 # Change the volume of map's BGM
@map_airship_bgm = "046-Positive04" # Airship BGM located in the "Audio/BGM" folder.
@airship_volume = 100 # Change the volume ofairship's BGM
@battle_interval = 100 # Steps between battles. Are randomized to a degree.
@battle_steps = 0
@map_fog = "002-Clouds01" # Filename of the fog for the map ("Fogs" folder).
@map_speeds = [2, 10, 4] # Speeds of [player, airship, boat] on the map.
@fog_scale = 5 # Scale of the fog (NOTE).
@birds_graphic = "birds" # Graphic for the birds, "Pictures" folder.
@birds_switch = true # Turn this ON if you want the birds on a map, OFF if you don't.
game_sys_initialize
#--------------------------------------------------------------------------
# NOTE:
# The fog picture should have dimensions, that multiplied by the fog_scale
# would equal the size of the map. Otherwise some errors may occur, when
# traveling "around the world".
#--------------------------------------------------------------------------
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
def draw_dot(x, y, color=Color.new(255,255,255))
self.set_pixel(x, y, color)
self.set_pixel(x + 1, y, color)
self.set_pixel(x - 1, y, color)
self.set_pixel(x, y + 1, color)
self.set_pixel(x, y - 1, color)
end
#--------------------------------------------------------------------------
def draw_gradient_fog(color=Color.new(200,220,250))
for i in 0..192
self.fill_rect(0, i, 640, 1, Color.new(color.red, color.green, color.blue, 192-i))#255 - i*(255.00/192.00)))
end
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Window_Waypoint_Name < Window_Base
#--------------------------------------------------------------------------
def initialize
super(320, 0, 256, 52)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------
def refresh(text = "")
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 224, 20, text.to_s, 1)
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Waypoint < Sprite
#--------------------------------------------------------------------------
attr_reader :name
attr_reader :enterable
attr_reader :data
#--------------------------------------------------------------------------
def initialize(viewport, x=0, y=0, enterable=false, data=[1,1,1], name="Town", sprite="", frames=1, speed=1)
@viewport = viewport
@enterable = enterable
@data = data
@name = name
@frames = frames
@speed = speed
@pattern = 0
super(@viewport)
self.bitmap = RPG::Cache.picture(sprite)
self.x = x
self.y = y
self.ox = self.bitmap.width / frames / 2
self.oy = self.bitmap.height
self.opacity = 2 * self.y
sx = @pattern * self.bitmap.width / @frames
self.src_rect.set(sx, 0, self.bitmap.width / @frames, self.bitmap.height)
end
#--------------------------------------------------------------------------
def update
self.z = 100 + self.y
#return if @frames == 1
self.opacity = 2 * self.y
@pattern = (@pattern + 1) % @frames if Graphics.frame_count % @speed == 0
sx = @pattern * self.bitmap.width / @frames
self.src_rect.set(sx, 0, self.bitmap.width / @frames, self.bitmap.height)
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Player_Object < Sprite
#--------------------------------------------------------------------------
def initialize(viewport, directions = 4, frames = 4)
@viewport = viewport
@directions = directions
@frames = frames
@pattern = 0
super(@viewport)
self.bitmap = RPG::Cache.character($game_party.actors[0].character_name, $game_party.actors[0].character_hue)
self.zoom_x = $game_system.map_sprite_scale
self.zoom_y = $game_system.map_sprite_scale
self.ox = self.bitmap.width / @frames / 2
self.oy = self.bitmap.height / @directions
sx = @pattern * self.bitmap.width / @frames
sy = (Input.dir8 == 2 ? 0 : Input.dir8 == 8 ? 3 : Input.dir8 == 4 ? 1 : Input.dir8 == 6 ? 2 : 0)
@temp_sy = sy
sy *= self.bitmap.height / @directions
self.src_rect.set(sx, sy, self.bitmap.width / @frames, self.bitmap.height / @directions)
end
#--------------------------------------------------------------------------
def update
self.z = 100 + self.y
#return if @frames == 1
@pattern = (@pattern + 1) % @frames if (Graphics.frame_count % 5 == 0 and Input.dir8 != 0)
@pattern = 0 if Input.dir8 == 0
sx = @pattern * self.bitmap.width / @frames
sy = (Input.dir8 == 2 ? 0 : Input.dir8 == 8 ? 3 : Input.dir8 == 4 ? 1 : Input.dir8 == 6 ? 2 : @temp_sy)
@temp_sy = sy
sy *= self.bitmap.height / @directions
self.src_rect.set(sx, sy, self.bitmap.width / @frames, self.bitmap.height / @directions)
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Vehicle_Object < Sprite
#--------------------------------------------------------------------------
def initialize(viewport, bitmap="", directions = 4, frames = 4, shift=0)
@viewport = viewport
@directions = directions
@frames = frames
@shift = shift
@pattern = 0
super(@viewport)
self.bitmap = RPG::Cache.character(bitmap, 0)
self.ox = self.bitmap.width / @frames / 2
self.oy = self.bitmap.height / @directions - @shift
@sx = @pattern * self.bitmap.width / @frames
@sy = 0
@temp_sy = @sy
@sy *= self.bitmap.height / @directions
self.src_rect.set(0, 0, self.bitmap.width / @frames, self.bitmap.height / @directions)
end
#--------------------------------------------------------------------------
def update
self.z = 100 + self.y
@pattern = (@pattern + 1) % @frames if (Graphics.frame_count % 10 == 0)
@sx = @pattern * self.bitmap.width / @frames
self.src_rect.set(@sx, @sy * self.bitmap.height / @directions, self.bitmap.width / @frames, self.bitmap.height / @directions)
end
#--------------------------------------------------------------------------
def direction_update
@sy = (Input.dir8 == 2 ? 0 : Input.dir8 == 8 ? 3 : Input.dir8 == 4 ? 1 : Input.dir8 == 6 ? 2 : @temp_sy)
@temp_sy = @sy
end
#--------------------------------------------------------------------------
def direction
case @sy
when 0
return 2
when 3
return 8
when 1
return 4
when 2
return 6
end
end
end
#==============================================================================
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
alias menu_update_comm update_command
#--------------------------------------------------------------------------
def update_command
menu_update_comm
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
if $game_system.on_map == true
$scene = Scene_World_Map.new
return
else
$scene = Scene_Map.new
return
end
end
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
def battle_end(result)
$game_temp.in_battle = false
$game_party.clear_actions
for actor in $game_party.actors
actor.remove_states_battle
end
$game_troop.enemies.clear
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
if $game_system.on_map == true
$scene = Scene_World_Map.new
else
$scene = Scene_Map.new
end
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
alias load_on_dec on_decision
#--------------------------------------------------------------------------
def on_decision(filename)
load_on_dec(filename)
if $game_system.on_map == true
$scene = Scene_World_Map.new
else
$scene = Scene_Map.new
end
end
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Scene_World_Map
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def main
$game_system.on_map = true
#$game_system.battle_steps = 0
@battle_interval = $game_system.battle_interval * (50 + rand(100)) / 100
@viewport = Viewport.new(0,0,640,480)
if $game_system.airship_switch
@map_speed = $game_system.map_speeds[1]
elsif $game_system.boat_switch
@map_speed = $game_system.map_speeds[2]
else
@map_speed = $game_system.map_speeds[0]
end
@delay = 0
@last_press = 2
@map_pass = Plane.new(@viewport)
@map_pass.bitmap = RPG::Cache.picture("map_pass.png")
@map_enc = Plane.new(@viewport)
@map_enc.bitmap = RPG::Cache.picture("map_enc.png")
@map = Plane.new(@viewport)
@map.bitmap = RPG::Cache.picture("map.jpg")
if $game_system.airship_switch
Audio.bgm_play("Audio/BGM/" + $game_system.map_airship_bgm, $game_system.airship_volume, 100)
else
Audio.bgm_play("Audio/BGM/" + $game_system.map_bgm, $game_system.map_volume, 100)
end
#--------------------------------------------------------------------------
# Create an array for towns, villages, etc.
#--------------------------------------------------------------------------
@waypoints = []
for i in 0..WAYPOINTS.size - 1
w = WAYPOINTS[i]
@waypoints << Waypoint.new(@viewport, w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7])
end
@popup = Window_Waypoint_Name.new
@popup.width = 0
@popup.z = 2000
@player = Player_Object.new(@viewport)
@player.x = $game_system.map_coords[0]
@player.y = $game_system.map_coords[1]
@airship = Vehicle_Object.new(@viewport, "Airship")
@airship.x = $game_system.airship_coords[0]
@airship.y = $game_system.airship_coords[1]
@boat = Vehicle_Object.new(@viewport, "boat", 4, 4, 24)
@boat.x = $game_system.boat_coords[0]
@boat.y = $game_system.boat_coords[1]
@viewport.ox = @player.x - 320
@viewport.oy = @player.y - 200
@fog = Sprite.new
@fog.z = 1000
@fog.bitmap = Bitmap.new(640,480)
@fog.bitmap.draw_gradient_fog(Color.new(128,200,255))
@clouds = Plane.new(@viewport)
@clouds.bitmap = RPG::Cache.fog($game_system.map_fog, 0)
@clouds.zoom_x = $game_system.fog_scale
@clouds.zoom_y = $game_system.fog_scale
@clouds.blend_type = 2
@clouds.opacity = 64
@clouds.z = 9999
Graphics.transition(20, "Graphics/Transitions/020-Flat01")
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@popup.dispose
@map.bitmap.dispose
@map.dispose
@map_pass.bitmap.dispose
@map_pass.dispose
@map_enc.bitmap.dispose
@map_enc.dispose
dispose_waypoints
@fog.bitmap.dispose
@fog.dispose
@player.dispose
@airship.dispose
@boat.dispose
end
#--------------------------------------------------------------------------
# ** Update shit :>
#--------------------------------------------------------------------------
def update
@player.update
@airship.direction_update if $game_system.airship_switch
@airship.update
@boat.direction_update if $game_system.boat_switch
@boat.update
@delay -= 1 unless @delay == 0
@clouds.ox += 2
@clouds.oy += 1 #if Graphics.frame_count % 2 == 0
if $game_system.airship_switch or $game_system.boat_switch
@player.opacity = 0
else
@player.opacity = 255
end
update_waypoints
update_vehicles
if $game_system.battle_steps >= @battle_interval and not $game_system.airship_switch
check_for_battle
end
if Input.trigger?(Input::B)
call_menu
end
#--------------------------------------------------------------------------
# Exit airship.
#--------------------------------------------------------------------------
if Input.trigger?(Input::C) and $game_system.airship_switch and @delay == 0
if @map_pass.bitmap.get_pixel(@player.x, @player.y) == Color.new(255,255,255)
@delay = 5
$game_system.airship_switch = false
@map_speed = $game_system.map_speeds[0]
Audio.bgm_play("Audio/BGM/"+$game_system.map_bgm, 100, 100)
end
end
#--------------------------------------------------------------------------
# Exit boat.
#--------------------------------------------------------------------------
if Input.trigger?(Input::C) and $game_system.boat_switch and @delay == 0
if passable?(@boat.direction, true)
@delay = 5
$game_system.boat_switch = false
x_mod = (@boat.direction == 2 ? 0 : @boat.direction == 8 ? 0 : @boat.direction == 4 ? -1 : @boat.direction == 6 ? 1 : 0)
y_mod = (@boat.direction == 2 ? 1 : @boat.direction == 8 ? -1 : @boat.direction == 4 ? 0 : @boat.direction == 6 ? 0 : 0)
@player.x = @boat.x + x_mod * 8 * @map_speed
@player.y = @boat.y + y_mod * 8 * @map_speed
@map_speed = $game_system.map_speeds[0]
end
end
if Input.dir8
x_mod = (Input.dir8 == 2 ? 0 : Input.dir8 == 8 ? 0 : Input.dir8 == 1 ? -1 : Input.dir8 == 4 ? -1 : Input.dir8 == 7 ? -1 : Input.dir8 == 3 ? 1 : Input.dir8 == 6 ? 1 : Input.dir8 == 9 ? 1 : 0)
y_mod = (Input.dir8 == 2 ? 1 : Input.dir8 == 8 ? -1 : Input.dir8 == 1 ? 1 : Input.dir8 == 4 ? 0 : Input.dir8 == 7 ? -1 : Input.dir8 == 3 ? 1 : Input.dir8 == 6 ? 0 : Input.dir8 == 9 ? -1 : 0)
if passable?(Input.dir8) or ($DEBUG and Input.press?(Input::CTRL))
$game_system.battle_steps += 1 if x_mod != 0 or x_mod != 0 and not $game_system.airship_switch
@player.x += x_mod * @map_speed
@player.y += y_mod * @map_speed
@player.x %= @map.bitmap.width
@player.y %= @map.bitmap.height
if $game_system.airship_switch
@airship.x += x_mod * @map_speed
@airship.y += y_mod * @map_speed
@airship.x %= @map.bitmap.width
@airship.y %= @map.bitmap.height
end
if $game_system.boat_switch
@boat.x += x_mod * @map_speed
@boat.y += y_mod * @map_speed
@boat.x %= @map.bitmap.width
@boat.y %= @map.bitmap.height
end
end
end
@viewport.ox = @player.x - 320
@viewport.oy = @player.y - 200
end
#--------------------------------------------------------------------------
# ** Call menu.
#--------------------------------------------------------------------------
def call_menu
$game_system.se_play($data_system.cancel_se)
$game_system.map_coords = [@player.x, @player.y]
$game_system.airship_coords = [@airship.x, @airship.y]
$game_system.boat_coords = [@boat.x, @boat.y]
$scene = Scene_Menu.new
end
#--------------------------------------------------------------------------
# ** Check if player is close to a waypoint.
#--------------------------------------------------------------------------
def update_waypoints
@waypoints.each_with_index{|w,i|
w.update
if Math.sqrt((w.x - @player.x)**2 + (w.y - @player.y)**2) <= 32
if Input.trigger?(Input::C) and w.enterable and not $game_system.airship_switch
$game_system.on_map = false
$game_map.setup(w.data[0])
$game_player.moveto(w.data[1], w.data[2])
$game_player.refresh
$game_map.autoplay
$game_map.update
$game_system.airship_coords = [@airship.x, @airship.y]
$game_system.boat_coords = [@boat.x, @boat.y]
$scene = Scene_Map.new
end
if w.name != ""
(@popup.width += 16 and @popup.x -= 8) unless @popup.width == 256
@popup.refresh(w.name)
@popup.opacity = 160
end
else
end
}
in_range = []
@waypoints.each{|w|
if Math.sqrt((w.x - @player.x)**2 + (w.y - @player.y)**2) <= 32
in_range << w
end
}
if in_range.size == 0
(@popup.width -= 32 and @popup.x += 16) unless @popup.width == 0
end
end
#--------------------------------------------------------------------------
# ** Check if player is close to a vehicle.
#--------------------------------------------------------------------------
def update_vehicles
if Math.sqrt((@player.x - @airship.x)**2 + (@player.y - @airship.y)**2) <= 32
if Input.trigger?(Input::C) and not $game_system.airship_switch and @delay == 0
@delay = 5
@player.x = @airship.x
@player.y = @airship.y
$game_system.airship_switch = true
Audio.bgm_play("Audio/BGM/"+$game_system.map_airship_bgm, 100, 100) if $game_system.map_airship_bgm != ""
@map_speed = $game_system.map_speeds[1]
end
elsif Math.sqrt((@player.x - @boat.x)**2 + (@player.y - @boat.y)**2) <= 32
if Input.trigger?(Input::C) and not $game_system.boat_switch and @delay == 0
@delay = 5
@player.x = @boat.x
@player.y = @boat.y
$game_system.boat_switch = true
@map_speed = $game_system.map_speeds[2]
end
end
end
#--------------------------------------------------------------------------
# ** Dispose waypoints.
#--------------------------------------------------------------------------
def dispose_waypoints
@waypoints.delete_if{ |m|
m.dispose
true
}
end
#--------------------------------------------------------------------------
# ** Determine if the terrain one step in front of the player is passable.
#--------------------------------------------------------------------------
def passable?(direction=0, boat_override=false)
passable_color = Color.new(255,255,255)
speed = @map_speed
if $game_system.boat_switch
passable_color = Color.new(0,0,255)
speed = 8*$game_system.map_speeds[2]
end
if $game_system.airship_switch
return true
end
if boat_override == true
passable_color = Color.new(255,255,255)
end
case direction
when 0
return true if @map_pass.bitmap.get_pixel((@player.x) % @map_pass.bitmap.width, (@player.y) % @map_pass.bitmap.height) == passable_color
when 1
return true if @map_pass.bitmap.get_pixel((@player.x - @map_speed) % @map_pass.bitmap.width, (@player.y + speed) % @map_pass.bitmap.height) == passable_color
when 2
return true if @map_pass.bitmap.get_pixel((@player.x) % @map_pass.bitmap.width, (@player.y + speed) % @map_pass.bitmap.height) == passable_color
when 3
return true if @map_pass.bitmap.get_pixel((@player.x + speed) % @map_pass.bitmap.width, (@player.y + speed) % @map_pass.bitmap.height) == passable_color
when 4
return true if @map_pass.bitmap.get_pixel((@player.x - speed) % @map_pass.bitmap.width, (@player.y) % @map_pass.bitmap.height) == passable_color
when 6
return true if @map_pass.bitmap.get_pixel((@player.x + speed) % @map_pass.bitmap.width, (@player.y) % @map_pass.bitmap.height) == passable_color
when 7
return true if @map_pass.bitmap.get_pixel((@player.x - speed) % @map_pass.bitmap.width, (@player.y - speed) % @map_pass.bitmap.height) == passable_color
when 8
return true if @map_pass.bitmap.get_pixel((@player.x) % @map_pass.bitmap.width, (@player.y - speed) % @map_pass.bitmap.height) == passable_color
when 9
return true if @map_pass.bitmap.get_pixel((@player.x + speed) % @map_pass.bitmap.width, (@player.y - speed) % @map_pass.bitmap.height) == passable_color
end
end
#--------------------------------------------------------------------------
# ** When battle steps reached, call for battle if possible.
#--------------------------------------------------------------------------
def check_for_battle
ENCOUNTER_TERRAINS.each{|e|
if @map_enc.bitmap.get_pixel(@player.x, @player.y) == e[0]
troop = e[1][rand(e[1].size)]
backdrop = e[2]
call_battle(troop, backdrop) if troop != 0
@battle_interval = $game_system.battle_interval * (50 + rand(100)) / 100
end
}
end
#--------------------------------------------------------------------------
# ** Setup battle.
#--------------------------------------------------------------------------
def call_battle(troop = 1, backdrop = "")
$game_system.battle_steps = 0
$game_temp.battle_calling = false
$game_temp.menu_calling = false
$game_temp.menu_beep = false
$game_player.make_encounter_count
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
$game_system.se_play($data_system.battle_start_se)
$game_system.bgm_play($game_system.battle_bgm)
$game_temp.battle_troop_id = troop
$game_map.battleback_name = backdrop
$game_system.map_coords = [@player.x, @player.y]
$game_system.airship_coords = [@airship.x, @airship.y]
$game_system.boat_coords = [@boat.x, @boat.y]
$scene = Scene_Battle.new
end
#--------------------------------------------------------------------------
end
[/spoiler]
I also have an 8-directional movement script :
[spoiler][code] #==============================================================================
# ** Eight Directional / Multiple Frame Movement Script v2 (10-05-2006)
# by DerVVulfman
#------------------------------------------------------------------------------
#
# This system allows the user to have either 4 OR 8 directional movement by
# the events and player sprites he uses. It also allows the user to set up
# the number of animation frames and whether a generic idle pose is used.
#
#==============================================================================
# * Configuration Section *
DIR_8_CHAR = false # This enables/disables 8 directional charsets
DIR_8_CONTROL = true # This enables/disables 8 directional movement
DIR_8_POSES = false # This enables/disables 8 directional facing
DIR_8_FRAMES = 4 # This holds the number of motion frames when walking
DIR_8_STAND = false # This determines if separate frame used for standing
$dir_8_fram = {1 => 8, 2 => 4}
=begin
FULL DEFINITIONS ON EDITABLES ABOVE:
DIR_8_CHAR: This value (true/false) determines whether the sprite's charset
uses 4 directional movement (up,down,left,right), or whether it
uses 8 directional movement (the diagonals too). Turning it on
allows you to use sprites that have 8 directional movement.
--If you turn this to 'true' when using a 4 directional sprite,
you will have an on-screen image of a sprite cut in half. Or,
if you set this to 'false' when using an 8 directional sprite
in your system, then your sprite will show two images on top
of each other.--
Ex: [1] Down [1] Down/left
[2] Right [2] Down
[3] Left [3] Down/Right
[4] Up [4] Right
[5] Up/Left
[6] Left
[7] Up/Right
[8] Up
DIR_8_CONTROL: This value (true/false) determines whether the player-control-
led character can be moved diagonally, regardless of character
pose. It won't affect [event] movement controls.
--If you turn this to 'true' when using a 4 directional char-
racter sprite, you will still only have them facing 4 ways
(up, down, left, right), even if your character is moving in
diagonal directions. Likewise, if you have this value set to
'false', even 8 directional player-controlled will be forced
to move in just the 4 prime directions... even if events can
move in all 8.
DIR_8_POSES: This value (true/false) determines whether the event or sprite
(if using an 8-directional charset) uses all 8 poses available
or whether just the prime 4 poses are used. It's pretty much
a given that IF you turn DIR_8_CHAR to true, you'll turn this
value to true as well.
DIR_8_FRAMES: This value (numeric) sets how many frames of animation is per-
formed by the sprite or event in motion. By default, the RTP
sprite uses a basic 4 frames (the default). Please note that
this only determines how many frames are in the animation of
the sprite and has nothing to do with the IDLE pose.
DIR_8_STAND: This value (true/false) determines whether an additional frame
is in the charset. This frame is of the character in an IDLE
pose... standing. The idle pose is always the first frame per
direction.
--This in no way is an animated idle pose (feet tapping on the
ground as the game waits for the player to make an action).
It only shows a single frame. The inclusion of a 'dash/idle'
script that replaces the charset with an applicable charset
would do the trick. But the charset would still have to be
goverened by the same layout as all the other charactersets.
Implementing the other person's idle/dash script will be up
to you, including timing mechanics such as how long to wait
before the on-screen character begins to perform their ani-
mated idle pose.
NOTE: If you have a sprite with 6 frames of animation and an idle pose (for a
total of 7 frames per direction) you would label them as:
DIR_8_FRAMES = 6
DIR_8_STAND = true
________ ________ ________ ________ ________ ________ ________
EX: | | | | | | | |
| Idle | Move 1 | Move 2 | Move 3 | Move 4 | Move 5 | Move 6 |
| Pose | Frame | Frame | Frame | Frame | Frame | Frame |
|________|________|________|________|________|________|________|
FINAL NOTES FOR EVENTS:
1) This script affects ALL charactersets used in your game. You cannot have
8 directional and/or 8 framed characters running around the screen and not
use similarly designed charactersets in your events. Using RTP graphics
with more advanced character graphics will give you... weirdly clipped re-
sults. You've been warned! Mwuahahahahahaha..... *cough*
2) To allow [event] sprites to remain in place while triggering the the "Turn
to Player" command in the event editor (to simulate sentries), you will
want to toggle the event's 'Move Animation' checkbox OFF (So uncheck it!).
For charsets that contain an 'IDLE' pose,this'll prevent these event-drawn
characters from using the first frame of the movement animation from being
shown... a little fix I picked up on. :)
=end
#==============================================================================
# ** Game_Character (Modification)
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :step_anime # Holds a sprite's step flag
attr_reader :walk_anime # Holds an event's movement flag
attr_reader :stop_count # The number of steps left to count
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Branch with jumping, moving, and stopping
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
# If animation count exceeds maximum value
# * Maximum value is move speed * 1 taken from basic value 18
if @anime_count > 18 - @move_speed * 2
# If stop animation is OFF when stopping
if not @step_anime and @stop_count > 0
# Return to original pattern
@pattern = @original_pattern
# If stop animation is ON when moving
else
# Update pattern
@pattern = ((@pattern + 1 ) % DIR_8_FRAMES)
end
# Clear animation count
@anime_count = 0
end
# If waiting
if @wait_count > 0
# Reduce wait count
@wait_count -= 1
return
end
# If move route is forced
if @move_route_forcing
# Custom move
move_type_custom
return
end
# When waiting for event execution or locked
if @starting or lock?
# Not moving by self
return
end
# If stop count exceeds a certain value (computed from move frequency)
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
# Branch by move type
case @move_type
when 1 # Random
move_type_random
when 2 # Approach
move_type_toward_player
when 3 # Custom
move_type_custom
end
end
end
#--------------------------------------------------------------------------
# * Move Lower Left (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_lower_left
unless @direction_fix
if DIR_8_POSES
# Face down-left
@direction = 1
else
# Face down is facing right or up
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
end
# When a down to left or a left to down course is passable
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
if DIR_8_POSES
turn_downleft
end
@x -= 1
@y += 1
increase_steps
end
end
#--------------------------------------------------------------------------
# * Move Lower Right (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_lower_right
unless @direction_fix
if DIR_8_POSES
@direction = 3
else
# Face right if facing left, and face down if facing up
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
end
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
if DIR_8_POSES
turn_downright
end
@x += 1
@y += 1
increase_steps
end
end
#--------------------------------------------------------------------------
# * Move Upper Left (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_upper_left
unless @direction_fix
if DIR_8_POSES
@direction = 7
else
# Face left if facing right, and face up if facing down
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
end
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
if DIR_8_POSES
turn_upleft
end
@x -= 1
@y -= 1
increase_steps
end
end
#--------------------------------------------------------------------------
# * Move Upper Left (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_upper_right
unless @direction_fix
if DIR_8_POSES
@direction = 9
else
# Face right if facing left, and face up if facing down
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
end
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
if DIR_8_POSES
turn_upright
end
@x += 1
@y -= 1
increase_steps
end
end
#--------------------------------------------------------------------------
# * Move at Random (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_random
# Determine random value's max based on the number of poses used
if DIR_8_POSES
# Random value maxed out at 8 directions
caserand=8
else
# Random value maxed out at 4 directions
caserand=4
end
# Branch according to random value
case rand(caserand)
when 0 # Move down
move_down(false)
when 1 # Move left
move_left(false)
when 2 # Move right
move_right(false)
when 3 # Move up
move_up(false)
when 4 # Move Upper Left
move_lower_left
when 5 # Move Upper Right
move_lower_right
when 6 # Move Lower Left
move_upper_left
when 7 # Move Lower Right
move_upper_right
end
end
#--------------------------------------------------------------------------
# * Move toward Player (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_toward_player
# Get difference in player coordinates
sx = @x - $game_player.x
sy = @y - $game_player.y
# If coordinates are equal
if sx == 0 and sy == 0
return
end
# Get absolute value of difference
abs_sx = sx.abs
abs_sy = sy.abs
if DIR_8_POSES
# Move towards player, prioritizes diagonal before straight
if sx > 0
if sy > 0
move_upper_left
elsif sy <0
move_lower_left
else
move_left
end
elsif sx <0
if sy > 0
move_upper_right
elsif sy <0
move_lower_right
else
move_right
end
else
if sy > 0
move_up
elsif sy <0
move_down
else
# nada (Completely Equal)
end
end
else
# If horizontal and vertical distances are equal
if abs_sx == abs_sy
# Increase one of them randomly by 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# If horizontal distance is longer
if abs_sx > abs_sy
# Move towards player, prioritize left and right directions
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
# If vertical distance is longer
else
# Move towards player, prioritize up and down directions
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
end
#--------------------------------------------------------------------------
# * Move away from Player (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_away_from_player
# Get difference in player coordinates
sx = @x - $game_player.x
sy = @y - $game_player.y
# If coordinates are equal
if sx == 0 and sy == 0
return
end
# Get absolute value of difference
abs_sx = sx.abs
abs_sy = sy.abs
if DIR_8_POSES
# Move away from player, prioritizes diagonal before straight
if sx > 0
if sy > 0
move_lower_right
elsif sy <0
move_upper_right
else
move_right
end
elsif sx <0
if sy > 0
move_lower_left
elsif sy <0
move_upper_left
else
move_left
end
else
if sy > 0
move_down
elsif sy <0
move_up
else
# nada (Completely Equal)
end
end
else
# If horizontal and vertical distances are equal
if abs_sx == abs_sy
# Increase one of them randomly by 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# If horizontal distance is longer
if abs_sx > abs_sy
# Move away from player, prioritize left and right directions
sx > 0 ? move_right : move_left
if not moving? and sy != 0
sy > 0 ? move_down : move_up
end
# If vertical distance is longer
else
# Move away from player, prioritize up and down directions
sy > 0 ? move_down : move_up
if not moving? and sx != 0
sx > 0 ? move_right : move_left
end
end
end
end
#--------------------------------------------------------------------------
# * 1 Step Forward (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_forward
if DIR_8_POSES
case @direction
when 2
move_down(false)
when 4
move_left(false)
when 6
move_right(false)
when 8
move_up(false)
end
else
case @direction
when 1
move_lower_left
when 2
move_down(false)
when 3
move_lower_right
when 4
move_left(false)
when 6
move_right(false)
when 7
move_upper_left
when 8
move_up(false)
when 9
move_upper_right
end
end
end
#--------------------------------------------------------------------------
# * 1 Step Backward (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def move_backward
# Remember direction fix situation
last_direction_fix = @direction_fix
# Force directino fix
@direction_fix = true
if DIR_8_POSES
# Branch by direction
case @direction
when 1
move_upper_right
when 2
move_up(false)
when 3
move_upper_left
when 4
move_right(false)
when 6
move_left(false)
when 7
move_lower_right
when 8
move_down(false)
when 9
move_lower_left
end
else
case @direction
when 2 # Down
move_up(false)
when 4 # Left
move_right(false)
when 6 # Right
move_left(false)
when 8 # Up
move_down(false)
end
end
# Return direction fix situation back to normal
@direction_fix = last_direction_fix
end
#--------------------------------------------------------------------------
# * Jump (Rewritten for diagonal animation)
# x_plus : x-coordinate plus value
# y_plus : y-coordinate plus value
#--------------------------------------------------------------------------
def jump(x_plus, y_plus)
if DIR_8_POSES
# Turns player, prioritizes diagonal before straight
if x_plus > 0
if y_plus > 0
turn_downright
elsif y_plus <0
turn_upright
else
turn_right
end
elsif x_plus <0
if y_plus > 0
turn_downleft
elsif y_plus <0
turn_upleft
else
turn_left
end
else
if y_plus > 0
turn_down
elsif y_plus <0
turn_up
else
# nada (Completely Equal)
end
end
else
# If plus value is not (0,0)
if x_plus != 0 or y_plus != 0
# If horizontal distnace is longer
if x_plus.abs > y_plus.abs
# Change direction to left or right
x_plus < 0 ? turn_left : turn_right
# If vertical distance is longer, or equal
else
# Change direction to up or down
y_plus < 0 ? turn_up : turn_down
end
end
end
# Calculate new coordinates
new_x = @x + x_plus
new_y = @y + y_plus
# If plus value is (0,0) or jump destination is passable
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
# Straighten position
straighten
# Update coordinates
@x = new_x
@y = new_y
# Calculate distance
distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
# Set jump count
@jump_peak = 10 + distance - @move_speed
@jump_count = @jump_peak * 2
# Clear stop count
@stop_count = 0
end
end
#--------------------------------------------------------------------------
# * Turn Up Left (Added for diagonal animation)
#--------------------------------------------------------------------------
def turn_upleft
unless @direction_fix
@direction = 7
@stop_count = 0
end
end
#--------------------------------------------------------------------------
# * Turn Up Right (Added for diagonal animation)
#--------------------------------------------------------------------------
def turn_upright
unless @direction_fix
@direction = 9
@stop_count = 0
end
end
#--------------------------------------------------------------------------
# * Turn Down Left (Added for diagonal animation)
#--------------------------------------------------------------------------
def turn_downleft
unless @direction_fix
@direction = 1
@stop_count = 0
end
end
#--------------------------------------------------------------------------
# * Turn Down Right (Added for diagonal animation)
#--------------------------------------------------------------------------
def turn_downright
unless @direction_fix
@direction = 3
@stop_count = 0
end
end
#--------------------------------------------------------------------------
# * Turn 90° Right (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def turn_right_90
case @direction
when 1
turn_downright
when 2
turn_left
when 3
turn_upright
when 4
turn_up
when 6
turn_down
when 7
turn_downleft
when 8
turn_right
when 9
turn_upleft
end
end
#--------------------------------------------------------------------------
# * Turn 90° Left (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def turn_left_90
case @direction
when 1
turn_upleft
when 2
turn_right
when 3
turn_downleft
when 4
turn_down
when 6
turn_up
when 7
turn_upright
when 8
turn_left
when 9
turn_downright
end
end
#--------------------------------------------------------------------------
# * Turn 180° (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def turn_180
case @direction
when 1
turn_upright
when 2
turn_up
when 3
turn_upleft
when 4
turn_right
when 6
turn_left
when 7
turn_downright
when 8
turn_down
when 9
turn_downleft
end
end
#--------------------------------------------------------------------------
# * Turn at Random (Rewritten for diagonal animation)
#--------------------------------------------------------------------------
def turn_random
if DIR_8_POSES
caserand = 8
else
caserand = 4
end
case rand(caserand)
when 0 # Move down
turn_down
when 1 # Move left
turn_left
when 2 # Move right
turn_right
when 3 # Move up
turn_up
when 4 # Move Upper Left
turn_downleft
when 5 # Move Upper Right
turn_downright
when 6 # Move Lower Left
turn_upleft
when 7 # Move Lower Right
turn_upright
end
end
#--------------------------------------------------------------------------
# * Turn Towards Player
#--------------------------------------------------------------------------
def turn_toward_player
# Get difference in player coordinates
sx = @x - $game_player.x
sy = @y - $game_player.y
if DIR_8_POSES
# turn towards player, prioritizes diagonal before straight
if sx > 0
if sy > 0
turn_upleft
elsif sy <0
turn_downleft
else
turn_left
end
elsif sx <0
if sy > 0
turn_upright
elsif sy <0
turn_downright
else
turn_right
end
else
if sy > 0
turn_up
elsif sy <0
turn_down
else
# nada (Completely Equal)
end
end
else
# If coordinates are equal
if sx == 0 and sy == 0
return
end
# If horizontal distance is longer
if sx.abs > sy.abs
# Turn to
I'll look into it. I'll see if I can find what's wrong. What version and type of RMXP are you using? Type would be legal or PK.
Okies. I tried using PK's and legal's RGSS dlls to see if it was a version issue but I couldn't get it to hang in the demo regardless of what I did. I'll need to look at your project to figure this out. Upload it somewhere and post the link so I can check it out to bust this error.
A bit off topic but I still gotta say this. You found a wicked awesome script.
Quote from: Shinami on November 11, 2007, 07:03:19 PM
A bit off topic but I still gotta say this. You found a wicked awesome script.
Blizzards Blizz-ABS does the 8 way movement too. ._.
I was refering to the world map script.
Yeah, and it might be a bit much to get an ABS script just for the 8-way movement.
Quote from: Shinami on November 11, 2007, 07:03:19 PM
Okies. I tried using PK's and legal's RGSS dlls to see if it was a version issue but I couldn't get it to hang in the demo regardless of what I did. I'll need to look at your project to figure this out. Upload it somewhere and post the link so I can check it out to bust this error.
A bit off topic but I still gotta say this. You found a wicked awesome script.
hehe, yes it is an awesome script, and I'm starting to figure it out, but I still don't see anything that would be keeping me from using it... *Sighs* I'll try and find a place to upload my project.... any ideason where?
On RMRK if it is small enough
Go to Additional Options and attach it as a zip. Otherwise sendspace is a good host.
:'( I still don't know what the problem really is, but, I tried using my map pics in the demo (importing them instead of the ones she/he used) but... alas, it does it there too, so I have to assume it is my pictures that are the problem.... I don't understand why, only that they are a problem... I'll try again, maybe its just still too big *shrugs*
EDIT: Nope, it can't be too big now.... the map images in the demo are like.... 10 bigger than what I was trying to use... I don't get it.... if I posted the pictures here, would someone be able to test them, or at least help me remake them so they work?
Considering that the script uses colors on the maps to determine monster zones, passability, and the like...are you sure that you aren't using conflicting colors or using a color not registered in the script?
that is a possibility, for the passability, I'm pretty sure I'm using the right colors, (white, black, and blue) but, maybe the blue is a little off? I dunno, and the encounter map, I would acctually prefer not to use it at all, so I made one that doesn't have any encounter areas... maybe thats it, I was afraid to mess around with the script before I got it working, in case it was something I did that made it not work. Also, I was wondering if it had something to do with the pixel size. I don't see anywhere in the script where they acctualy put down the size of the picture, and the instructions didn't mention haveing to change anything... but *shrugs* I'm not sure....
This is the image I'm using for my encounter
[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fus.share.geocities.com%2Ffruitbodywash%2Fmap_enc.png&hash=ea9eb6b743763fe43edd5b760a63ff915392dc1d)[/spoiler]
and I'm using the same one for my passability, I did this because I don't want any encounters, so I didn't make any encounter areas. In the demo, the encounter map looks just like the passability map, except it has the encounter areas as well.
I couldn't get the map itself to upload, its just a little tooo big. *sigh* but, as you can see, the colors are straightforward... so, I dunno
Could you upload the rest of your map pictures? Just having one doesn't do me any good.
EDIT:I also need your "Settings" script so I can look at the way you setup the waypoints and the like.
The settings are all the same, except I took out hte "default" waypoints and encounters... I'm just trying to get out to the map as of now.
I'm going to try and upload the map.jpg somewhere else, I'll post it as soon as I can.
EDIT: Here are the map files I use...
Thanks. Now I can look into what's wrong.
Okies. I had to step away from the comp for awhile but I've finished looking into things. It's really strange. I import map.jpg and it hangs. I import map_enc.png or map_pass.png on their own, it's fine. I import them together and it hangs. The maps you're using are too much for RGSS to process. I resized them to 20% of the original size and tried again. It didn't hang OR lag when switching to the world map picture.
:o :D :-* :lol: yey! alright, I'll give that a try, i wasn't sure if it was the map.jpg or not, but, if it is, and i can fix it... thanks! hehe... I really wanted to be able to use this script, it just looks so great, ya know?
Thanks again! (heres where someone would normally say +rep and I'm going to try it, but... I don't know if thats right, or exactly how to do it) Thanks again! (+rep is a good thing right?)
Always a pleasure, never a chore. Now if I can just find out why sites like Yahoo! refuse to load while RMRK loads just fine I'll feel even better!