Charlie's Passability Mini-Map, Version 0.4 - Charlie Fleed - 02-22-2009
Passability Mini-Map by Charlie Fleed Version 0.4.4 (21-1-2011)
Introduction
This script draws a mini-map indicating the passability of each tile and the position of the player and some other map objects.
The map takes into account directional passability, and - for the moment - does not consider blocking events except those using graphics from the tileset. In that case the through check-box is also considered.
A zoom option allows to define how much of the map is displayed.
It includes some code required to save png images in your project folder, which I dind't write, I simply found it on the Internet but I lost track of the author. If anyone recognizes the author I will be happy to credit him/her.
Instructions
The script will create a folder named "pass_maps" inside your project's Pictures folder.
The first time you enter a map, the image is computed and saved, the following times the saved image will be loaded instead. Deleting the image, which will have the map id in its name, forces the image to be recomputed. Do it when you change your maps and you want to update the passability maps.
You can also use a Call Script command "redraw_passmap", in game, for the same purpose.
Use the Call Script commands "show_passmap" and "hide_passmap" in order to... well, I'll let you guess what they do...
Put a comment "Enemy" in some page of enemy-events that you want to be displayed in the mini-map, and a comment "Teleport" in some page of teleport-events. If you want a teleport or an enemy event to be not displayed in the mini-map when a specific page is active, put a comment "No Map" in that page.
The script can use custom images to display the hero, allies and enemies.
You can set the position, size, opacity and background image for the mini-map.
Screenshots
When I say you can set the mini-map size... I mean it ;)
Script
Version 0.4.4
Code:
#==============================================================================
# ** Passability Mini-map by Charlie Fleed
#
# Version: 0.4.4
# Author: Charlie Fleed
#==============================================================================
#
# Instructions: use the commands show_passmap and hide_passmap to make the
# minimap appear and disappear, the last setting will be saved in your savefile.
#
#==============================================================================
PASSABILITY_MAP_H=48*2
PASSABILITY_MAP_W=64*2
PASSABILITY_MAP_X=16 #640-PASSABILITY_MAP_W-16
PASSABILITY_MAP_Y=480-PASSABILITY_MAP_H-16 #480-PASSABILITY_MAP_H-32-16
PASSABILITY_MAP_OPACITY=150
MAP_ZOOM=1
PASSMAP_BACKGROUND_IMAGE="passmap bg" # Put "" if not used
PASSMAP_BACKGROUND_OPACITY=255
PASSMAP_PLAYER_IMAGE=""
PASSMAP_ALLY_IMAGE=""
PASSMAP_ENEMY_IMAGE=""
PASSMAP_BG_COLOR=Color.new(102,90,66,255)
PASSMAP_FG_COLOR=Color.new(179,158,116,255)
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def redraw_passmap
$game_temp.redraw_passmap=true
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def hide_passmap
$game_system.minimap_visible=false
return
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def show_passmap
$game_system.minimap_visible=true
return
end
end
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Game_System
attr_accessor :minimap_visible
attr_accessor :minimap_opacity
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
alias minimap_initialize initialize
def initialize
minimap_initialize
@minimap_visible=true
@minimap_opacity=PASSABILITY_MAP_OPACITY
end
end
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Passability_Map < Sprite
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
@objects=Map_Objects.new(viewport)
self.opacity=$game_system.minimap_opacity
self.visible = ($game_system.minimap_visible and
((not HIDE_WHEN_SHOWING_MESSAGES) or (not $game_temp.message_window_showing)) and
((not HIDE_WHEN_SWITCH_ON) or (not $game_switches[HIDE_SWITCH_NUMBER])))
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def renew
@map=Bitmap.new(4*$game_map.width,4*$game_map.height)
for x in 0...$game_map.width
Graphics.update
for y in 0...$game_map.height
temp=0
@map.fill_rect(x*4,y*4,4,4,PASSMAP_FG_COLOR)
if !$game_map.passable?(x,y,2) # DOWN
@map.fill_rect(x*4,y*4+3,4,1,PASSMAP_BG_COLOR)
temp+=1
end
if !$game_map.passable?(x,y,4) # LEFT
@map.fill_rect(x*4,y*4,1,4,PASSMAP_BG_COLOR)
temp+=1
end
if !$game_map.passable?(x,y,6) # RIGHT
@map.fill_rect(x*4+3,y*4,1,4,PASSMAP_BG_COLOR)
temp+=1
end
if !$game_map.passable?(x,y,8) # UP
@map.fill_rect(x*4,y*4,4,1,PASSMAP_BG_COLOR)
temp+=1
end
if temp==4
@map.fill_rect(x*4+1,y*4+1,2,2,PASSMAP_BG_COLOR)
end
end
end
@map.make_png(@name_map)
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def redraw
self.visible=false
renew
self.bitmap=Bitmap.new(@map.width/MAP_ZOOM,@map.height/MAP_ZOOM)
self.bitmap.stretch_blt(self.bitmap.rect,@map,@map.rect,255)
self.visible=($game_system.minimap_visible and
((not HIDE_WHEN_SHOWING_MESSAGES) or (not $game_temp.message_window_showing)) and
((not HIDE_WHEN_SWITCH_ON) or (not $game_switches[HIDE_SWITCH_NUMBER])))
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def refresh
begin
Dir.mkdir 'Graphics/Pictures/pass_maps'
rescue
begin
Dir.mkdir 'Graphics/Pictures'
Dir.mkdir 'Graphics/Pictures/pass_maps'
rescue
begin
Dir.mkdir 'Graphics'
Dir.mkdir 'Graphics/Pictures'
Dir.mkdir 'Graphics/Pictures/pass_maps'
rescue
end
end
end
@name_map="Graphics/Pictures/pass_maps/pass_map_"+$game_map.map_id.to_s
begin
@map=Bitmap.new(@name_map)
rescue
renew
end
self.bitmap=Bitmap.new(@map.width/MAP_ZOOM,@map.height/MAP_ZOOM)
self.bitmap.stretch_blt(self.bitmap.rect,@map,@map.rect)
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def update
return unless @map!=nil
self.visible = ($game_system.minimap_visible and
((not HIDE_WHEN_SHOWING_MESSAGES) or (not $game_temp.message_window_showing)) and
((not HIDE_WHEN_SWITCH_ON) or (not $game_switches[HIDE_SWITCH_NUMBER])))
@objects.visible=self.visible
return if not self.visible
player_x=(4*$game_player.real_x/128.0)/MAP_ZOOM
player_y=(4*$game_player.real_y/128.0)/MAP_ZOOM
tilesize=4/MAP_ZOOM
self.ox=[[0, player_x - self.viewport.rect.width/2 + tilesize/2].max,
@map.width/MAP_ZOOM-self.viewport.rect.width].min
self.oy=[[0, player_y - self.viewport.rect.height/2+ tilesize/2].max,
@map.height/MAP_ZOOM-self.viewport.rect.height].min
@objects.update
self.opacity=$game_system.minimap_opacity
@objects.opacity=self.opacity
# $scene.debug_window.draw_text(0,0,460,30,"map_w="+(@map.width/MAP_ZOOM).to_s+" h="+(@map.height/MAP_ZOOM).to_s+" viewport_w"+(self.viewport.rect.width).to_s+" viewport_h"+(self.viewport.rect.height).to_s,true)
# $scene.debug_window.draw_text(0,30,460,30,"ox="+self.ox.to_s+"\toy="+self.oy.to_s)
# $scene.debug_window.draw_text(0,60,460,30,"player_x="+player_x.to_s+"\tplayer_y="+player_y.to_s)
# $scene.debug_window.draw_text(0,90,460,30,(self.viewport.rect.height/2).to_s)
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def height
return [@map.height/MAP_ZOOM,self.viewport.rect.height].min
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def width
return [@map.width/MAP_ZOOM,self.viewport.rect.width].min
end
end
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Map_Objects < Sprite
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def update
if self.bitmap!=nil
self.bitmap.dispose
end
self.bitmap=Bitmap.new(4*$game_map.width/MAP_ZOOM,4*$game_map.height/MAP_ZOOM)
player_x=(4*$game_player.real_x/128.0)/MAP_ZOOM
player_y=(4*$game_player.real_y/128.0)/MAP_ZOOM
tilesize=4/MAP_ZOOM
self.ox=[[0, player_x - self.viewport.rect.width/2 + tilesize/2].max,
4*$game_map.width/MAP_ZOOM-self.viewport.rect.width].min
self.oy=[[0, player_y - self.viewport.rect.height/2+ tilesize/2].max,
4*$game_map.height/MAP_ZOOM-self.viewport.rect.height].min
# ENEMIES
for object in $game_map.events.values
if object.is_enemy?
object_x=(4*object.real_x/128.0)/MAP_ZOOM
object_y=(4*object.real_y/128.0)/MAP_ZOOM
if PASSMAP_ENEMY_IMAGE != ""
enemy_bitmap=RPG::Cache.picture(PASSMAP_ENEMY_IMAGE)
self.bitmap.blt([0,object_x-0.5*enemy_bitmap.width].max,
[0,object_y-0.5*enemy_bitmap.height].max,
enemy_bitmap,enemy_bitmap.rect,128)
else
self.bitmap.fill_rect(object_x+tilesize/4,object_y+tilesize/4,2/MAP_ZOOM,2/MAP_ZOOM,Color.new(255,0,0))
end
end
if object.is_teleport?
object_x=(4*object.real_x/128.0)/MAP_ZOOM
object_y=(4*object.real_y/128.0)/MAP_ZOOM
self.bitmap.fill_rect(object_x,object_y,4/MAP_ZOOM,4/MAP_ZOOM,Color.new(255,0,255,200))
end
end
# EVENTS
for object in $game_map.events.values
if KEYWORDS[object.event.name]
object_x=(4*object.real_x/128.0)/MAP_ZOOM
object_y=(4*object.real_y/128.0)/MAP_ZOOM
self.bitmap.fill_rect(object_x+tilesize/4,object_y+tilesize/4,2/MAP_ZOOM,
2/MAP_ZOOM,KEYWORDS[object.event.name]) unless object.no_map?
end
end
# ALLIES
unless $game_allies==nil
for ally in $game_allies.values
ally_x=(4*ally.real_x/128.0)/MAP_ZOOM
ally_y=(4*ally.real_y/128.0)/MAP_ZOOM
if PASSMAP_ALLY_IMAGE != ""
ally_bitmap=RPG::Cache.picture(PASSMAP_ALLY_IMAGE)
self.bitmap.blt([0,ally_x-0.5*ally_bitmap.width].max,
[0,ally_y-0.5*ally_bitmap.height].max,
ally_bitmap,ally_bitmap.rect,128)
else
self.bitmap.fill_rect(ally_x+tilesize/4,ally_y+tilesize/4,2/MAP_ZOOM,2/MAP_ZOOM,Color.new(150,150,0))
end
end
end
# HERO
if PASSMAP_PLAYER_IMAGE != ""
player_bitmap=RPG::Cache.picture(PASSMAP_PLAYER_IMAGE)
self.bitmap.blt([0,player_x-0.5*player_bitmap.width].max,
[0,player_y-0.5*player_bitmap.height].max,
player_bitmap,player_bitmap.rect,128)
else
self.bitmap.fill_rect(player_x+tilesize/4, player_y+tilesize/4,2/MAP_ZOOM,2/MAP_ZOOM,Color.new(0,0,255))
end
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def height
return [4*$game_map.height/MAP_ZOOM,self.viewport.rect.height].min
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def width
return [4*$game_map.width/MAP_ZOOM,self.viewport.rect.width].min
end
end
#class Window_Debug < Window_Base
# def draw_text(a,b,c,d,e,clean=false)
# if clean
# self.contents=Bitmap.new(width-32,height-32)
# end
# self.contents.draw_text(a,b,c,d,e)
# end
#end
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Scene_Map
attr_accessor :map
# attr_accessor :debug_window
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
alias passmap_main main
def main
@map_viewport=Viewport.new(PASSABILITY_MAP_X,PASSABILITY_MAP_Y,
PASSABILITY_MAP_W,PASSABILITY_MAP_H)
@map_viewport.z=9999
@map_viewport.visible=true
@map=Passability_Map.new(@map_viewport)
@map.refresh
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg_viewport=Viewport.new(PASSABILITY_MAP_X+PASSABILITY_MAP_W-@map.width-8,
PASSABILITY_MAP_Y+PASSABILITY_MAP_H-@map.height-8,
@map.width+16,@map.height+16)
# p "width: %d, height: %d",@map.width,@map.height
@map_bg_viewport.z=9998
@map_bg_viewport.visible=($game_system.minimap_visible and
((not HIDE_WHEN_SHOWING_MESSAGES) or (not $game_temp.message_window_showing)) and
((not HIDE_WHEN_SWITCH_ON) or (not $game_switches[HIDE_SWITCH_NUMBER])))
@map_bg=Sprite.new(@map_bg_viewport)
@map_bg.bitmap=RPG::Cache.picture(PASSMAP_BACKGROUND_IMAGE)
@map_bg.opacity=PASSMAP_BACKGROUND_OPACITY
@map_bg.zoom_x = 1.0*(@map_bg_viewport.rect.width)/@map_bg.bitmap.width
@map_bg.zoom_y = 1.0*(@map_bg_viewport.rect.height)/@map_bg.bitmap.height
end
# @debug_window=Window_Debug.new(0,0,640,180)
passmap_main
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg.dispose
@map_bg_viewport.dispose
end
@map.dispose
@map_viewport.dispose
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
alias passmap_update update
def update
passmap_update
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg_viewport.visible=($game_system.minimap_visible and
((not HIDE_WHEN_SHOWING_MESSAGES) or (not $game_temp.message_window_showing)) and
((not HIDE_WHEN_SWITCH_ON) or (not $game_switches[HIDE_SWITCH_NUMBER])))
end
if $game_temp.redraw_passmap
@map.redraw
$game_temp.redraw_passmap=false
end
if $game_temp.refresh_passmap
@map.refresh
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg_viewport.rect.width=@map.width+16
@map_bg_viewport.rect.height=@map.height+16
@map_bg_viewport.rect.x=PASSABILITY_MAP_X+PASSABILITY_MAP_W-@map.width-8
@map_bg_viewport.rect.y=PASSABILITY_MAP_Y+PASSABILITY_MAP_H-@map.height-8
@map_bg.zoom_x = 1.0*(@map_bg_viewport.rect.width)/@map_bg.bitmap.width
@map_bg.zoom_y = 1.0*(@map_bg_viewport.rect.height)/@map_bg.bitmap.height
end
$game_temp.refresh_passmap=false
end
@map.update
end
end
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
alias passmap_setup setup
def setup(id)
passmap_setup(id)
$game_temp.refresh_passmap=true
end
end
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Game_Temp
attr_accessor :redraw_passmap
attr_accessor :refresh_passmap
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
alias passmap_initialize initialize
def initialize
passmap_initialize
@redraw_passmap=false
@refresh_passmap=false
end
end
def make_idat
header = "\x49\x44\x41\x54"
data = make_bitmap_data
data = Zlib::Deflate.deflate(data, 8)
crc = [Zlib.crc32(header + data)].pack("N")
size = [data.length].pack("N")
return size + header + data + crc
end
def make_bitmap_data
gz = Zlib::GzipWriter.open('hoge.gz')
t_Fx = 0
w = @bitmap_Fx.width
h = @bitmap_Fx.height
data = []
for y in 0...h
data.push(0)
for x in 0...w
t_Fx += 1
if t_Fx % 10000 == 0
Graphics.update
end
if t_Fx % 100000 == 0
s = data.pack("C*")
gz.write(s)
data.clear
end
color = @bitmap_Fx.get_pixel(x, y)
red = color.red
green = color.green
blue = color.blue
alpha = color.alpha
data.push(red)
data.push(green)
data.push(blue)
data.push(alpha)
end
end
s = data.pack("C*")
gz.write(s)
gz.close
data.clear
gz = Zlib::GzipReader.open('hoge.gz')
data = gz.read
gz.close
File.delete('hoge.gz')
return data
end
def make_iend
ie_size = [0].pack("N")
ie_sign = "IEND"
ie_crc = [Zlib.crc32(ie_sign)].pack("N")
return ie_size + ie_sign + ie_crc
end
end
end
class Bitmap
def make_png(name="Gui_Img_Save", path="",mode=0)
make_dir(path) if path != ""
Zlib::Png_File.open("temp.gz") {|gz|
gz.make_png(self)
}
Zlib::GzipReader.open("temp.gz") {|gz|
$read = gz.read
}
f = File.open(path + name + ".png","wb")
f.write($read)
f.close
File.delete('temp.gz')
end
def make_dir(path)
dir = path.split("/")
for i in 0...dir.size
unless dir == "."
add_dir = dir[0..i].join("/")
begin
Dir.mkdir(add_dir)
rescue
end
end
end
end
end
#==============================================================================
# **
#------------------------------------------------------------------------------
#
#==============================================================================
class Game_Event < Game_Character
attr_reader :event
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def is_enemy?
if no_map?
return false
end
for p in @event.pages
for command in p.list
if command.code == 108
if command.parameters[0]=="Enemy"
return true
end
end
end
end
return false
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def is_teleport?
if no_map?
return false
end
for p in @event.pages
for command in p.list
if command.code == 108
if command.parameters[0]=="Teleport"
return true
end
end
end
end
return false
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def no_map?
if @page==nil
return true
end
for command in @page.list
if command.code == 108
if command.parameters[0]=="No Map"
return true
end
end
end
return false
end
end
Version 0.4
Code:
#==============================================================================
# ** Passability Mini-map by Charlie Fleed
#
# Version: 0.4
# Author: Charlie Fleed
#==============================================================================
#
# Instructions: use the commands show_passmap and hide_passmap to make the
# minimap appear and disappear, the last setting will be saved in your savefile.
#
#==============================================================================
class Interpreter
def redraw_passmap
$game_temp.redraw_passmap=true
end
def hide_passmap
$game_system.minimap_visible=false
return
end
def show_passmap
$game_system.minimap_visible=true
return
end
end
class Game_System
attr_accessor :minimap_visible
alias minimap_initialize initialize
def initialize
minimap_initialize
@minimap_visible=true
end
end
class Passability_Map < Sprite
def initialize(viewport)
super(viewport)
@objects=Map_Objects.new(viewport)
end
def renew
@map=Bitmap.new(4*$game_map.width,4*$game_map.height)
for x in 0...$game_map.width
Graphics.update
for y in 0...$game_map.height
temp=0
@map.fill_rect(x*4,y*4,4,4,Color.new(190,190,190))
if !$game_map.passable?(x,y,2) # DOWN
@map.fill_rect(x*4,y*4+3,4,1,Color.new(90,90,90))
temp+=1
end
if !$game_map.passable?(x,y,4) # LEFT
@map.fill_rect(x*4,y*4,1,4,Color.new(90,90,90))
temp+=1
end
if !$game_map.passable?(x,y,6) # RIGHT
@map.fill_rect(x*4+3,y*4,1,4,Color.new(90,90,90))
temp+=1
end
if !$game_map.passable?(x,y,8) # UP
@map.fill_rect(x*4,y*4,4,1,Color.new(90,90,90))
temp+=1
end
if temp==4
@map.fill_rect(x*4+1,y*4+1,2,2,Color.new(90,90,90))
end
end
end
@map.make_png(@name_map)
end
def redraw
self.visible=false
renew
self.bitmap=Bitmap.new(@map.width/MAP_ZOOM,@map.height/MAP_ZOOM)
self.bitmap.stretch_blt(self.bitmap.rect,@map,@map.rect,PASSABILITY_MAP_OPACITY)
self.visible=$game_system.minimap_visible
end
def refresh
begin
Dir.mkdir 'Graphics/Pictures/pass_maps'
rescue
end
@name_map="Graphics/Pictures/pass_maps/pass_map_"+$game_map.map_id.to_s
begin
@map=Bitmap.new(@name_map)
rescue
renew
end
self.bitmap=Bitmap.new(@map.width/MAP_ZOOM,@map.height/MAP_ZOOM)
self.bitmap.stretch_blt(self.bitmap.rect,@map,@map.rect,PASSABILITY_MAP_OPACITY)
end
def height
return [@map.height/MAP_ZOOM,self.viewport.rect.height].min
end
def width
return [@map.width/MAP_ZOOM,self.viewport.rect.width].min
end
end
class Map_Objects < Sprite
def update
if self.bitmap!=nil
self.bitmap.dispose
end
self.bitmap=Bitmap.new(4*$game_map.width/MAP_ZOOM,4*$game_map.height/MAP_ZOOM)
player_x=(4*$game_player.real_x/128.0)/MAP_ZOOM
player_y=(4*$game_player.real_y/128.0)/MAP_ZOOM
tilesize=4/MAP_ZOOM
self.ox=[[0, player_x - self.viewport.rect.width/2 + tilesize/2].max,
4*$game_map.width/MAP_ZOOM-self.viewport.rect.width].min
self.oy=[[0, player_y - self.viewport.rect.height/2+ tilesize/2].max,
4*$game_map.height/MAP_ZOOM-self.viewport.rect.height].min
# ENEMIES
for object in $game_map.events.values
if object.is_enemy?
object_x=(4*object.real_x/128.0)/MAP_ZOOM
object_y=(4*object.real_y/128.0)/MAP_ZOOM
if PASSMAP_ENEMY_IMAGE != ""
enemy_bitmap=RPG::Cache.picture(PASSMAP_ENEMY_IMAGE)
self.bitmap.blt([0,object_x-0.5*enemy_bitmap.width].max,
[0,object_y-0.5*enemy_bitmap.height].max,
enemy_bitmap,enemy_bitmap.rect,128)
else
self.bitmap.fill_rect(object_x+tilesize/4,object_y+tilesize/4,2/MAP_ZOOM,2/MAP_ZOOM,Color.new(255,0,0))
end
end
if object.is_teleport?
object_x=(4*object.real_x/128.0)/MAP_ZOOM
object_y=(4*object.real_y/128.0)/MAP_ZOOM
self.bitmap.fill_rect(object_x,object_y,4/MAP_ZOOM,4/MAP_ZOOM,Color.new(0,255,0,128))
end
end
# ALLIES
unless $game_allies==nil
for ally in $game_allies.values
ally_x=(4*ally.real_x/128.0)/MAP_ZOOM
ally_y=(4*ally.real_y/128.0)/MAP_ZOOM
if PASSMAP_ALLY_IMAGE != ""
ally_bitmap=RPG::Cache.picture(PASSMAP_ALLY_IMAGE)
self.bitmap.blt([0,ally_x-0.5*ally_bitmap.width].max,
[0,ally_y-0.5*ally_bitmap.height].max,
ally_bitmap,ally_bitmap.rect,128)
else
self.bitmap.fill_rect(ally_x+tilesize/4,ally_y+tilesize/4,2/MAP_ZOOM,2/MAP_ZOOM,Color.new(250,5,0))
end
end
end
# HERO
if PASSMAP_PLAYER_IMAGE != ""
player_bitmap=RPG::Cache.picture(PASSMAP_PLAYER_IMAGE)
self.bitmap.blt([0,player_x-0.5*player_bitmap.width].max,
[0,player_y-0.5*player_bitmap.height].max,
player_bitmap,player_bitmap.rect,128)
else
self.bitmap.fill_rect(player_x+tilesize/4, player_y+tilesize/4,2/MAP_ZOOM,2/MAP_ZOOM,Color.new(0,0,255))
end
end
end
#class Window_Debug < Window_Base
# def draw_text(a,b,c,d,e,clean=false)
# if clean
# self.contents=Bitmap.new(width-32,height-32)
# end
# self.contents.draw_text(a,b,c,d,e)
# end
#end
class Scene_Map
attr_accessor :map
# attr_accessor :debug_window
alias passmap_main main
def main
@map_viewport=Viewport.new(PASSABILITY_MAP_X,PASSABILITY_MAP_Y,
PASSABILITY_MAP_W,PASSABILITY_MAP_H)
@map_viewport.z=9999
@map_viewport.visible=true
@map=Passability_Map.new(@map_viewport)
@map.refresh
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg_viewport=Viewport.new(PASSABILITY_MAP_X+PASSABILITY_MAP_W-@map.width-8,
PASSABILITY_MAP_Y+PASSABILITY_MAP_H-@map.height-8,
@map.width+16,@map.height+16)
# p "width: %d, height: %d",@map.width,@map.height
@map_bg_viewport.z=9998
@map_bg=Sprite.new(@map_bg_viewport)
@map_bg.bitmap=RPG::Cache.picture(PASSMAP_BACKGROUND_IMAGE)
@map_bg.zoom_x = 1.0*(@map_bg_viewport.rect.width)/@map_bg.bitmap.width
@map_bg.zoom_y = 1.0*(@map_bg_viewport.rect.height)/@map_bg.bitmap.height
end
# @debug_window=Window_Debug.new(0,0,640,180)
passmap_main
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg.dispose
@map_bg_viewport.dispose
end
@map.dispose
@map_viewport.dispose
end
alias passmap_update update
def update
passmap_update
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg_viewport.visible=$game_system.minimap_visible
end
if $game_temp.redraw_passmap
@map.redraw
$game_temp.redraw_passmap=false
end
if $game_temp.refresh_passmap
@map.refresh
if PASSMAP_BACKGROUND_IMAGE != ""
@map_bg_viewport.rect.width=@map.width+16
@map_bg_viewport.rect.height=@map.height+16
@map_bg_viewport.rect.x=PASSABILITY_MAP_X+PASSABILITY_MAP_W-@map.width-8
@map_bg_viewport.rect.y=PASSABILITY_MAP_Y+PASSABILITY_MAP_H-@map.height-8
@map_bg.zoom_x = 1.0*(@map_bg_viewport.rect.width)/@map_bg.bitmap.width
@map_bg.zoom_y = 1.0*(@map_bg_viewport.rect.height)/@map_bg.bitmap.height
end
$game_temp.refresh_passmap=false
end
@map.update
end
end
class Game_Map
alias passmap_setup setup
def setup(id)
passmap_setup(id)
$game_temp.refresh_passmap=true
end
end
class Game_Temp
attr_accessor :redraw_passmap
attr_accessor :refresh_passmap
alias passmap_initialize initialize
def initialize
passmap_initialize
@redraw_passmap=false
@refresh_passmap=false
end
end
def make_idat
header = "\x49\x44\x41\x54"
data = make_bitmap_data
data = Zlib::Deflate.deflate(data, 8)
crc = [Zlib.crc32(header + data)].pack("N")
size = [data.length].pack("N")
return size + header + data + crc
end
def make_bitmap_data
gz = Zlib::GzipWriter.open('hoge.gz')
t_Fx = 0
w = @bitmap_Fx.width
h = @bitmap_Fx.height
data = []
for y in 0...h
data.push(0)
for x in 0...w
t_Fx += 1
if t_Fx % 300 == 0
Graphics.update
end
if t_Fx % 3000 == 0
s = data.pack("C*")
gz.write(s)
data.clear
end
color = @bitmap_Fx.get_pixel(x, y)
red = color.red
green = color.green
blue = color.blue
alpha = color.alpha
data.push(red)
data.push(green)
data.push(blue)
data.push(alpha)
end
end
s = data.pack("C*")
gz.write(s)
gz.close
data.clear
gz = Zlib::GzipReader.open('hoge.gz')
data = gz.read
gz.close
File.delete('hoge.gz')
return data
end
def make_iend
ie_size = [0].pack("N")
ie_sign = "IEND"
ie_crc = [Zlib.crc32(ie_sign)].pack("N")
return ie_size + ie_sign + ie_crc
end
end
end
class Bitmap
def make_png(name="Gui_Img_Save", path="",mode=0)
make_dir(path) if path != ""
Zlib::Png_File.open("temp.gz") {|gz|
gz.make_png(self)
}
Zlib::GzipReader.open("temp.gz") {|gz|
$read = gz.read
}
f = File.open(path + name + ".png","wb")
f.write($read)
f.close
File.delete('temp.gz')
end
def make_dir(path)
dir = path.split("/")
for i in 0...dir.size
unless dir == "."
add_dir = dir[0..i].join("/")
begin
Dir.mkdir(add_dir)
rescue
end
end
end
end
end
class Game_Event < Game_Character
def is_enemy?
if @page==nil
return false
end
for command in @page.list
if command.code == 108
if command.parameters[0]=="No Map"
return false
end
end
end
for p in @event.pages
for command in p.list
if command.code == 108
if command.parameters[0]=="Enemy"
return true
end
end
end
end
return false
end
def is_teleport?
if @page==nil
return false
end
for command in @page.list
if command.code == 108
if command.parameters[0]=="No Map"
return false
end
end
end
for p in @event.pages
for command in p.list
if command.code == 108
if command.parameters[0]=="Teleport"
return true
end
end
end
end
return false
end
end
Charlie's Passability Mini-Map - Charlie Fleed - 03-25-2009
Update. This version (0.3) should be lighter.
Now you can also see transfer points on the mini map (using a "Teleport" comment inside them).
Charlie's Passability Mini-Map - Charlie Fleed - 06-28-2009
A little bug has been fixed, the code looked for "allies" to be drawn on the minimap and caused an error when the user does not have a caterpillar-like script in use.
Charlie's Passability Mini-Map - Lt. Fox - 06-29-2009
Very basic, yet very nice! Good work Charlie! I'll use this with full credit toward you! :p
Charlie's Passability Mini-Map - Charlie Fleed - 07-19-2009
Preview of version 0.4, with background and custom sprites for the hero, allies and enemies.
Charlie Fleed Wrote:You can use a background image.
PASSMAP_BACKGROUND_IMAGE="your picture name".
When you say add color, do you mean changing the light and dark grey?
yea so it shows were the water is and land and objects and trees but if anything just land and water
Charlie's Passability Mini-Map - Charlie Fleed - 12-12-2009
explocion200 Wrote:
Charlie Fleed Wrote:You can use a background image.
PASSMAP_BACKGROUND_IMAGE="your picture name".
When you say add color, do you mean changing the light and dark grey?
yea so it shows were the water is and land and objects and trees but if anything just land and water
I will post a version where you can decide the colors of passable and non-passable tiles. However, even in this version, you cannot differentiate water, which usually is non-passable, from other non-passable tiles and draw them in the map with different colors.
Charlie Fleed Wrote:You can use a background image.
PASSMAP_BACKGROUND_IMAGE="your picture name".
When you say add color, do you mean changing the light and dark grey?
yea so it shows were the water is and land and objects and trees but if anything just land and water
I will post a version where you can decide the colors of passable and non-passable tiles. However, even in this version, you cannot differentiate water, which usually is non-passable, from other non-passable tiles and draw them in the map with different colors.