Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minimap
#1
MiniMapScript V1.7
# Translation by: Mr. DJ/ Derk Jan
# Request by: KHORN
# Made by: markusmks

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given.


Code:
#==============================================================================
# â–�  MiniMapScript
#------------------------------------------------------------------------------
# Translation by: Mr. DJ
# Request by: KHORN
# Made by: markusmks
#==============================================================================

class MiniMapScript < Window_Base
attr_accessor :modus
#--------------------------------------------------------------------------
# â—? Initialize
#--------------------------------------------------------------------------
def initialize(mapname=nil)
   super(0, 0, 200, 67)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.color = normal_color
   self.contents.font.name = "Arial"
   self.contents.font.size = 20
   self.windowskin = nil
   # ---------------------------OPTIONEN-------------------------
   # Modus 1 = Name of the map as: "mapname.png"
   # Vb: "Dungeon.png"
   # Modus 2 = Id as the name as "mapID.png"
   # Vb: "1.png"
   # Modus 3 = $name_minim[MapID] = "Screen" / screenone ".png"
   # in Modus 3 you save all the images in /pictures/MiniMaps and asign them to the map with call script
   #============================================================
   @modus = 3
   # ------------------------------------------------------------
   @mapname = mapname
   if @modus == 1
     real_map = $game_map.name
   elsif @modus == 2
     real_map = $game_map.map_id.to_s
   elsif @modus == 3
     real_map = $name_minim[$game_map.map_id]
   end
   @real_map = real_map
   if FileTest.exist?("Graphics/Pictures/MiniMaps/"+real_map+".png")
     @mapname = real_map
   end
   if @mapname != nil
     #--<Colors>-- Will be the colors of the player and NPC, but do not change these! see below
     player_color = Color.new(0,0,0)
     npc_color = Color.new(255,0,0)
     #----MAP------------------------#
     @player_color=player_color
     @npc_color=npc_color
     @gra_dir = "Graphics/Pictures/MiniMaps/"
     @mmap = @gra_dir+@mapname+".png"
     map = Bitmap.new(@mmap)
     @map_sprite = Sprite.new
     @map_sprite.bitmap = map
     @map_sprite.x = 0
     @map_sprite.y = 0
     @map_sprite.opacity = 180
     @map_sprite.zoom_x = 0.98
     @map_sprite.zoom_y = 0.98
     #------PLAYER------------#
     @player_sprite = Sprite.new
     @player_sprite.bitmap = Bitmap.new(3,3)
     @player_sprite.bitmap.fill_rect(0,0,3,3,@player_color) #you can change these
     @event_sprite = []
     for i in $game_map.events.keys.sort
       if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
         @event_sprite[i] = Sprite.new  
         @event_sprite[i].bitmap = Bitmap.new(3,3)
         if $game_map.events[i].list[1].parameters[0] != nil
           colors = $game_map.events[i].list[1].parameters[0].split
           red = colors[0].to_i
           green = colors[1].to_i
           blue = colors[2].to_i
           @npc_color = Color.new(red,green,blue)
         else
           @npc_color = Color.new(255,0,0)
         end
         @event_sprite[i].bitmap.fill_rect(0,0,3,3,@npc_color)
       end
     end
     refresh
   end
end
#--------------------------------------------------------------------------
# â—? Refresh
#--------------------------------------------------------------------------
def refresh
   self.contents.clear
   if @event_sprite == []
     renew
   end
   if FileTest.exist?("Graphics/Pictures/MiniMaps/"+@real_map+".png")
     @mapname = @real_map
   else
     @mapname = nil
   end
   if @mapname != nil
     for i in $game_map.events.keys.sort
       if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
         if @event_sprite == []
           renew
           return
         end
         @event_sprite[i].x = $game_map.events[i].real_x/16
         @event_sprite[i].y = $game_map.events[i].real_y/16
         @event_sprite[i].opacity = 255
         @event_sprite[i].zoom_x = 1
         @event_sprite[i].zoom_y = 1
       end
       i += 1
     end
     #----PLAYER MOVE---------#
     @player_sprite.x = $game_player.real_x/16
     @player_sprite.y = $game_player.real_y/16
     @player_sprite.opacity = 255
     @player_sprite.zoom_x = 1
     @player_sprite.zoom_y = 1  
     #----------------------------#
   end
end
#--------------------------------------------------------------------------
# â—? Renew Graphics
#--------------------------------------------------------------------------
def renew
   dispose
   if @modus == 1
     real_map = $game_map.name
   elsif @modus == 2
     real_map = $game_map.map_id.to_s
   elsif @modus == 3
     real_map = $name_minim[$game_map.map_id]
   end
   @real_map = real_map
   if FileTest.exist?("Graphics/Pictures/MiniMaps/"+@real_map+".png")
     @mapname = real_map
   end
   @gra_dir = "Graphics/Pictures/MiniMaps/"
   @mmap = @gra_dir+@mapname+".png"
   map = Bitmap.new(@mmap)
   @map_sprite = Sprite.new
   @map_sprite.bitmap = map
   @map_sprite.x = 0
   @map_sprite.y = 0
   @map_sprite.opacity = 180
   @map_sprite.zoom_x = 0.98
   @map_sprite.zoom_y = 0.98
   @player_sprite = Sprite.new
   @player_sprite.bitmap = Bitmap.new(3,3) #you can change these
  
   @player_sprite.bitmap.fill_rect(0,0,3,3,@player_color=Color.new(0,0,0)) #you can change these
   @event_sprite = []
   for i in $game_map.events.keys.sort
     if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
       @event_sprite[i] = Sprite.new  
       @event_sprite[i].bitmap = Bitmap.new(3,3)
       if $game_map.events[i].list[1].parameters[0] != nil
         colors = $game_map.events[i].list[1].parameters[0].split
         red = colors[0].to_i
         green = colors[1].to_i
         blue = colors[2].to_i
         @npc_color = Color.new(red,green,blue)
       else
         @npc_color = Color.new(255,0,0)
       end
       @event_sprite[i].bitmap.fill_rect(0,0,3,3,@npc_color) #you can change these
     end
   end
end
#--------------------------------------------------------------------------
# â—? Update
#--------------------------------------------------------------------------
def update
   if @modus == 3 and $name_minim[$game_map.map_id] != ""
     renew
   end
   refresh
end
#--------------------------------------------------------------------------
# â—? Dispose all
#--------------------------------------------------------------------------
def dispose
   if @event_sprite != nil
     for sprite in @event_sprite
       if sprite != nil
         sprite.dispose
       end
     end
   end
   if @player_sprite != nil
     @player_sprite.dispose
   end
   if @map_sprite != nil
     @map_sprite.dispose
   end
end
end

#==============================================================================
# â–�  Game_MiniMap
#------------------------------------------------------------------------------
# © i dont know
#==============================================================================

class Game_MiniMap
#--------------------------------------------------------------------------
# â—? Initialize
#--------------------------------------------------------------------------
def initialize
   @data = []
end
#--------------------------------------------------------------------------
# â—? Map ID
#     variable_id : Map ID
#--------------------------------------------------------------------------
def [](variable_id)
   if variable_id <= 5000 and @data[variable_id] != nil
     return @data[variable_id]
   else
     return ""
   end
end
#--------------------------------------------------------------------------
# â—? MiniMap Screen declared here
#     variable_id : Map ID
#     value       : Screen Name
#--------------------------------------------------------------------------
def []=(variable_id, value)
   if variable_id <= 5000
     @data[variable_id] = value
   end
end
end

# ====================  Read this  =======================================
#
# As i cannot alias, please read this!!
# To make sure the data of the minimaps is saved,
# Copy the text between the edits, to the corresponding place in:
# Scene_Title, Scene_Load, Scene_Save
# After you did that...
# ...Delete all the codes below
# so they wont work here ^^... Mr. DJ
#
# ==================================================================

class Scene_Title
def command_new_game
   $game_system.se_play($data_system.decision_se)
   Audio.bgm_stop
   Graphics.frame_count = 0
   $game_temp          = Game_Temp.new
   $game_system        = Game_System.new
   $game_switches      = Game_Switches.new
   $game_variables     = Game_Variables.new
   $game_self_switches = Game_SelfSwitches.new
   $game_screen        = Game_Screen.new
   $game_actors        = Game_Actors.new
   $game_party         = Game_Party.new
   $game_troop         = Game_Troop.new
   $game_map           = Game_Map.new
   $game_player        = Game_Player.new
   # EDIT -------------------------------
   $name_minim         = Game_MiniMap.new
   # ------------------------------------
   $game_party.setup_starting_members
   $game_map.setup($data_system.start_map_id)
   $game_player.moveto($data_system.start_x, $data_system.start_y)
   $game_player.refresh
   $game_map.autoplay
   $game_map.update
   $scene = Scene_Map.new
end
end
class Scene_Save
def write_save_data(file)
   characters = []
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     characters.push([actor.character_name, actor.character_hue])
   end
   Marshal.dump(characters, file)
   Marshal.dump(Graphics.frame_count, file)
   $game_system.save_count += 1
   $game_system.magic_number = $data_system.magic_number
   Marshal.dump($game_system, file)
   Marshal.dump($game_switches, file)
   Marshal.dump($game_variables, file)
   Marshal.dump($game_self_switches, file)
   Marshal.dump($game_screen, file)
   Marshal.dump($game_actors, file)
   Marshal.dump($game_party, file)
   Marshal.dump($game_troop, file)

   Marshal.dump($game_map, file)
   Marshal.dump($game_player, file)
   # EDIT ------------------------
   Marshal.dump($name_minim, file)
   # -----------------------------
end
end
class Scene_Load
def read_save_data(file)
   characters = Marshal.load(file)
   Graphics.frame_count = Marshal.load(file)
   $game_system        = Marshal.load(file)
   $game_switches      = Marshal.load(file)
   $game_variables     = Marshal.load(file)
   $game_self_switches = Marshal.load(file)
   $game_screen        = Marshal.load(file)
   $game_actors        = Marshal.load(file)
   $game_party         = Marshal.load(file)
   $game_troop         = Marshal.load(file)
   $game_map           = Marshal.load(file)
   $game_player        = Marshal.load(file)
   # EDIT ---------------------------------
   $name_minim         = Marshal.load(file)
   # --------------------------------------
   if $game_system.magic_number != $data_system.magic_number
     $game_map.setup($game_map.map_id)
     $game_player.center($game_player.x, $game_player.y)
   end
   $game_party.refresh
end
end

Check the Demo :)
.zip   MiniMapScript_V1.zip (Size: 238.24 KB / Downloads: 2)

Im not gonna put scrennies, beacuse its a small demo
Howeverm nake sure you read the last comments in the script, regarding about, i cannot alias... :P'

Mr. DJ

Code:
# â–� MiniMapScript
#------------------------------------------------------------------------------
# © markusmks
# KHORN
#==============================================================================

class MiniMapScript < Window_Base
attr_accessor :modus
#--------------------------------------------------------------------------
# â—? Initialize
#--------------------------------------------------------------------------
def initialize(mapname=nil)
super(-16, -16, 193, 154)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.color = normal_color
self.contents.font.name = "Arial"
self.contents.font.size = 20
self.windowskin = nil
# OPTIONEN ----------#
# Zeigt schwarze umrandung
@rand = true
# HIER BITTE ANGEBEN,WIE HERO ANGEZEIGT:
# 1 = Normales Kästchen
# 2 = Eigenen Point
# 3 = Meine Version :D > line 247
@hero = 1
# falls 2, dann hier das Bild angeben (in Picture ordner)
@hero_graphic = "sample_point.png"
# -----------------------
@dummy_window = Window_Base.new(-16,-16,195,156)
@dummy_window.contents = Bitmap.new(163,124)
@dummy_window.opacity = 0
@dummy_window.z = 0
# ---------------------------OPTIONEN-------------------------
# Modus 1 = Echter Map name zu "mapname.png" zB: "Dungeon.png"
# Modus 2 = Echte Map ID name zu "mapID.png" zB: "1.png"
# Modus 3 = $name_minim[MapID] = "BILD" / bitte ohne ".png"
# ============================================================
@modus = 3
# ------------------------------------------------------------
@mapname = mapname
if @modus == 1
real_map = $game_map.name
elsif @modus == 2
real_map = $game_map.map_id.to_s
elsif @modus == 3
real_map = $name_minim[$game_map.map_id]
end
@real_map = real_map
if FileTest.exist?("Graphics/Pictures/MiniMaps/"+real_map+".png")
@mapname = real_map
end
if @rand == true
@dummy_window.contents.fill_rect(156,0,2,117,Color.new(0,0,0))
@dummy_window.contents.fill_rect(0,117,157,2,Color.new(0,0,0))
end
if @mapname != nil
#--<Colors>--#
player_color = Color.new(0,0,0)
npc_color = Color.new(255,0,0)
#----MAP-----#
@player_color=player_color
@npc_color=npc_color
@gra_dir = "Graphics/Pictures/MiniMaps/"
@mmap = @gra_dir+@mapname+".png"
map = Bitmap.new(@mmap)
@map_sprite = Sprite.new
@map_sprite.bitmap = map
@map_sprite.src_rect = Rect.new(0,0,161,122)
@map_sprite.x = 0
@map_sprite.y = 0
@map_sprite.opacity = 180
@map_sprite.zoom_x = 0.98
@map_sprite.zoom_y = 0.98
#------PLAYER------------#
@player_sprite = Sprite.new
if @hero == 1
@player_sprite.bitmap = Bitmap.new(3,3)
@player_sprite.bitmap.fill_rect(0,0,3,3,@player_color)
elsif @hero == 2
@player_sprite.bitmap = RPG::Cache.picture(@hero_graphic.to_s)
elsif @hero == 3
@player_sprite.bitmap = fun_hero
end
@event_sprite = []
for i in $game_map.events.keys.sort
if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
@event_sprite[i] = Sprite.new
@event_sprite[i].bitmap = Bitmap.new(3,3)
if $game_map.events[i].list[1].parameters[0] != nil
colors = $game_map.events[i].list[1].parameters[0].split
red = colors[0].to_i
green = colors[1].to_i
blue = colors[2].to_i
@npc_color = Color.new(red,green,blue)
else
@npc_color = Color.new(255,0,0)
end
@event_sprite[i].bitmap.fill_rect(0,0,3,3,@npc_color)
end
end
refresh
end
end
#--------------------------------------------------------------------------
# â—? Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@dummy_window.contents.clear
if @event_sprite == []
renew
end
if @rand == true
@dummy_window.contents.fill_rect(156,0,2,117,Color.new(0,0,0))
@dummy_window.contents.fill_rect(0,117,157,2,Color.new(0,0,0))
end
if FileTest.exist?("Graphics/Pictures/MiniMaps/"+@real_map+".png")
@mapname = @real_map
else
@mapname = nil
end
if @mapname != nil
for i in $game_map.events.keys.sort
if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
if @event_sprite == []
renew
return
end
@event_sprite[i].x = $game_map.events[i].screen_x/4-3
@event_sprite[i].y = $game_map.events[i].screen_y/4-7
if @event_sprite[i].x > 156 or @event_sprite[i].y > 122-8
@event_sprite[i].opacity = 0
else
@event_sprite[i].opacity = 255
end
@event_sprite[i].zoom_x = 1
@event_sprite[i].zoom_y = 1
end
i += 1
end
#----PLAYER MOVE---------#
@player_sprite.x = $game_player.screen_x/4-3
@player_sprite.y = $game_player.screen_y/4-6
@player_sprite.opacity = 255
@player_sprite.zoom_x = 1
@player_sprite.zoom_y = 1
#----MAP MOVE------------#
x = $game_map.display_x/64
y = $game_map.display_y/64
x *= 4
y *= 4
@map_sprite.src_rect = Rect.new(x,y,161,122)
#------------------------#
end
end
#--------------------------------------------------------------------------
# â—? Renew Graphics
#--------------------------------------------------------------------------
def renew
dispose
if @modus == 1
real_map = $game_map.name
elsif @modus == 2
real_map = $game_map.map_id.to_s
elsif @modus == 3
real_map = $name_minim[$game_map.map_id]
end
@real_map = real_map
if FileTest.exist?("Graphics/Pictures/MiniMaps/"+@real_map+".png")
@mapname = real_map
end
@dummy_window = Window_Base.new(-16,-16,195,156)
@dummy_window.contents = Bitmap.new(163,124)
@dummy_window.opacity = 0
@dummy_window.z = 0
@gra_dir = "Graphics/Pictures/MiniMaps/"
@mmap = @gra_dir+@mapname+".png"
map = Bitmap.new(@mmap)
@map_sprite = Sprite.new
@map_sprite.bitmap = map
@map_sprite.src_rect = Rect.new(0,0,161,122)
@map_sprite.x = 0
@map_sprite.y = 0
@map_sprite.opacity = 180
@map_sprite.zoom_x = 0.98
@map_sprite.zoom_y = 0.98
@player_sprite = Sprite.new
if @hero == 1
@player_sprite.bitmap = Bitmap.new(3,3)
@player_sprite.bitmap.fill_rect(0,0,3,3,@player_color=Color.new(0,0,0))
elsif @hero == 2
@player_sprite.bitmap = RPG::Cache.picture(@hero_graphic.to_s)
elsif @hero == 3
@player_sprite.bitmap = fun_hero
end
@event_sprite = []
for i in $game_map.events.keys.sort
if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
@event_sprite[i] = Sprite.new
@event_sprite[i].bitmap = Bitmap.new(3,3)
if $game_map.events[i].list[1].parameters[0] != nil
colors = $game_map.events[i].list[1].parameters[0].split
red = colors[0].to_i
green = colors[1].to_i
blue = colors[2].to_i
@npc_color = Color.new(red,green,blue)
else
@npc_color = Color.new(255,0,0)
end
@event_sprite[i].bitmap.fill_rect(0,0,3,3,@npc_color) #you can change these
end
end
end
#--------------------------------------------------------------------------
# â—? Update
#--------------------------------------------------------------------------
def update
if @modus == 3 and $name_minim[$game_map.map_id] != ""
renew
end
refresh
end
#--------------------------------------------------------------------------
# â—? Dispose all
#--------------------------------------------------------------------------
def dispose
if @event_sprite != nil
for sprite in @event_sprite
if sprite != nil
sprite.dispose
end
end
end
if @player_sprite != nil
@player_sprite.dispose
end
if @map_sprite != nil
@map_sprite.dispose
end
if @dummy_window != nil
@dummy_window.dispose
end
end
#--------------------------------------------------------------------------
# â—? :D
# Draw your own Chara
# (maybe the game lag with this)
#--------------------------------------------------------------------------
def fun_hero
@hero_bitmap = Bitmap.new(4,4)
braun = Color.new(138,67,0)
blau = Color.new(109,189,206)
haut = Color.new(248,169,97)
mund = Color.new(214,109,214)
@hero_bitmap.fill_rect(0,0,3,1,braun)
@hero_bitmap.fill_rect(0,3,3,1,braun)
@hero_bitmap.set_pixel(0,2,braun)
@hero_bitmap.set_pixel(3,2,braun)
@hero_bitmap.set_pixel(0,1,blau)
@hero_bitmap.set_pixel(3,1,blau)
@hero_bitmap.fill_rect(1,1,2,1,braun)
@hero_bitmap.fill_rect(1,2,2,1,mund)
return @hero_bitmap
end
end

#==============================================================================
# â–� Game_MiniMap
#------------------------------------------------------------------------------
# © markusmks
#==============================================================================

class Game_MiniMap
#--------------------------------------------------------------------------
# â—? Initialize
#--------------------------------------------------------------------------
def initialize
@data = []
end
#--------------------------------------------------------------------------
# â—? Map ID
# variable_id : Map ID
#--------------------------------------------------------------------------
def [](variable_id)
if variable_id <= 5000 and @data[variable_id] != nil
return @data[variable_id]
else
return ""
end
end
#--------------------------------------------------------------------------
# â—? MiniMap Screen declared here
# variable_id : Map ID
# value : Screen Name
#--------------------------------------------------------------------------
def []=(variable_id, value)
if variable_id <= 5000
@data[variable_id] = value
end
end
end

class Scene_Title
alias scene_title_command_new_game command_new_game
def command_new_game
$name_minim = Game_MiniMap.new
scene_title_command_new_game
end
end
class Scene_Save
alias save_new_game_here write_save_data
def write_save_data(file)
save_new_game_here(file)
Marshal.dump($name_minim, file)
end
end
class Scene_Load
alias read_saved_one read_save_data
def read_save_data(file)
read_saved_one(file)
$name_minim = Marshal.load(file)
end
end
}




Users browsing this thread: