[XP] Atlas Script

Started by Aqua, July 29, 2009, 04:29:40 pm

Previous topic - Next topic

Aqua

July 29, 2009, 04:29:40 pm Last Edit: July 29, 2009, 04:53:44 pm by Aqua
Atlas of the World
Authors: Aqua
Version: 1.00
Type: Atlas Display System
Key Term: Environment Add-on



Introduction

This script creates an atlas that displays your repetoire of available maps.
It also displays the player's location and the map name.


Features


  • Display an atlas of maps
  • Very customizable
  • Able to display where on map the player is
  • Able to display map name



Screenshots

Spoiler: ShowHide



Demo

[link]


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=#
# Atlas Script by TerreAqua
# Version: 1.00
# Type: Fullscreen Map System
# Key Term: Environment Add-on
# Date: 7/29/09
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=#

#===============================================================================
# Information
#-------------------------------------------------------------------------------
#
#   This script creates an atlas that displays your repetoire of available maps.
#   It also displays the player's location and the map name.
#
#   If you need to contact me about this script, please go to:
#   http://forum.chaos-project.com
#
#   You should have only gotten this script from http://chaos-project.com
#   Please let me know if you have found it somewhere else.
#===============================================================================
module AquaAtlas
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~::~:~:~: Instructions :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#===============================================================================
# All maps to be shown in the atlas should be in Pictures/Atlas.
# They should all be the same size (in dimensions) and be named according to
# what map id it belongs to (with 3 digits).
# For example, map id 1 should have a picture file that is named 001
#
# Use $scene = Scene_Atlas.new to call up the Atlas.
# Use $game_system.atlas_unlocked.push(MAP_ID) to flag MAP_ID as viewable.
# Use $game_system.atlas_player_icon = 'FILE' to change player's icon.
# Use $game_system.atlas_bg = 'FILE' to change background of atlas.
# Use $game_system.atlas_display_current = true/false to change display mode.
# Use $game_system.atlas_default_map = ID to change default map in atlas.
#
# Complete the below fields.
#===============================================================================

# File in Pictures folder to use as Player Icon
# Leave as '' to have no icon displayed
PLAYERICON = 'Atlas/PlayerIcon'

# File in Pictures folder to use as a background for the Atlas
# Leave as '' to have the map as back
ATLASBG = ''

# The area of the Atlas that is actual terrain
MAP_AREA_X = 480
MAP_AREA_Y = 360

# Where to position the Atlas on the screen
MAP_POS_X = 80
MAP_POS_Y = 60

# This changes the positioning of the Player Icon in case it is off a little
# Can be calculated by taking the top left coordinates of the actual start of
# the map on the map image, then adding MAP_POS_X and MAP_POS_Y respectively
MAP_0X = 80
MAP_0Y = 60

# Where to display the name of the map
NAME_X = 10
NAME_Y = 450

# Which maps to have in the Atlas by default
ENABLED_MAPS = [1, 2, 4, 5, 6]

# Always display current map first?
DISPLAYCURRENT = true

# Default Map - Always shows this first if DISPLAYCURRENT is false
DEFAULT_MAP = 1

# Overrides default setup on certain maps
def self.override(id)
 case id
# when MAP_ID then return ['PICTURE', MAP_0X, MAP_0Y, MAP_AREA_X, MAP_AREA_Y]
 when 4 then return ['004', 217, 60, 206, 360]
 when 5 then return ['Mountainside', 80, 60, 192, 144]
 when 6 then return ['Mountainside', 273, 60, 288, 144]
 
#===============================================================================  
# Don't edit anything below this line unless you know what you're doing
#===============================================================================
 end
 return [id, MAP_0X, MAP_0Y, MAP_AREA_X, MAP_AREA_Y]
end

end

#===============================================================================
# Credits:
# Aqua (aka TerreAqua) for making this script.
# Evander for requesting it.
# LegacyBlade for finding a potential bug.
# Starrodkirby86 for being you. :D
#===============================================================================

#===============================================================================
#  This work is protected by the following license:
# #-----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #-----------------------------------------------------------------------------
#===============================================================================

class Game_System
 
 attr_accessor :atlas_unlocked
 attr_accessor :atlas_default_map
 attr_accessor :atlas_bg
 attr_accessor :atlas_display_current
 attr_accessor :atlas_player_icon
 
 alias init_atlas_later initialize
 def initialize
   init_atlas_later
   @atlas_unlocked = AquaAtlas::ENABLED_MAPS
   @atlas_default_map = AquaAtlas::DEFAULT_MAP
   @atlas_bg = AquaAtlas::ATLASBG
   @atlas_display_current = AquaAtlas::DISPLAYCURRENT
   @atlas_player_icon = AquaAtlas::PLAYERICON
 end
 
 
end

class Draw_Map < Sprite
 
 def initialize(viewport = nil)
   super
   self.x, self.y, self.z, self.opacity = 0, 0, 10, 255
   self.bitmap = Bitmap.new(640, 480)
   
   if $game_system.atlas_display_current == true &&
         $game_system.atlas_unlocked.include?($game_map.map_id)
     maptoshow = $game_map.map_id
   else
     maptoshow = $game_system.atlas_default_map
   end
   
   if $atlason != true
     $displayedmap = $game_system.atlas_unlocked.index(maptoshow)
     $atlason = true
   end

   $displayedmap = 0 if $displayedmap == nil
   
   # Cleans up array of atlas_unlocked
   $game_system.atlas_unlocked.sort!
   $game_system.atlas_unlocked = $game_system.atlas_unlocked | $game_system.atlas_unlocked
   
   @mapid = $game_system.atlas_unlocked[$displayedmap]
   $map_names = load_data('Data/MapInfos.rxdata')
   $map_names.each_key {|key| $map_names[key] = $map_names[key].name}
 
   refresh
   
 end
 
 # Draws Atlas
 def refresh
   self.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 0))
   @currentmap = sprintf("%03d", @mapid)
   
   if $game_system.atlas_unlocked.include?(@mapid)
     if @mapid == AquaAtlas.override(@mapid)[0]
       map = RPG::Cache.picture("Atlas/#{@currentmap}")
     else
       map = RPG::Cache.picture("Atlas/#{AquaAtlas.override(@mapid)[0]}")
     end
     self.bitmap.blt(AquaAtlas::MAP_POS_X, AquaAtlas::MAP_POS_Y, map, Rect.new(0, 0, map.width, map.height))
     @mapshown = @mapid
     draw_player_location if @mapid == $game_map.map_id
     self.bitmap.draw_text(AquaAtlas::NAME_X, AquaAtlas::NAME_Y, 300, 28, $map_names[@mapshown], 0)
   end
   
   @displayedmap = $displayedmap
   
 end
 
 # Draws player's location if on displayed map
 def draw_player_location
   px, py = $game_player.x, $game_player.y
   map = load_data(sprintf("Data/Map%03d.rxdata", @mapid))
   map_width, map_height = map.width, map.height
   xratio = AquaAtlas.override(@mapid)[3] / map_width.to_f
   yratio = AquaAtlas.override(@mapid)[4] / map_height.to_f
   player = RPG::Cache.picture($game_system.atlas_player_icon)
   ox = player.width / 2 - 16 / xratio
   oy = player.height / 2 - 16 / yratio
   dx = px * xratio + AquaAtlas.override(@mapid)[1]
   dy = py * yratio + AquaAtlas.override(@mapid)[2]
   self.bitmap.blt(dx - ox, dy - oy, player, Rect.new(0, 0, player.width, player.height), 200)
 end
 
 # Checks if map needs to be updated
 def update
   refresh if @mapid != @mapshown
   refresh if @displayedmap != $displayedmap
 end
 
end

class Scene_Atlas
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Make Atlas Sprite
   @atlas_sprite = Draw_Map.new
   # Make Map Back
   @back = Spriteset_Map.new
   bg = $game_system.atlas_bg
   if bg != ''
     @bg = Sprite.new
     @bg.bitmap = RPG::Cache.picture(bg)
   end
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @atlas_sprite.dispose
   @back.dispose if @back != nil
   @bg.dispose if @bg != nil
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Reset Map
     $displayedmap = 0
     $atlason = false
     # Switch to menu screen
     $scene = Scene_Menu.new(0)
     return
   end
   # If R button was pressed
   if Input.trigger?(Input::RIGHT)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     # To next map
     $displayedmap += 1
     $displayedmap %= $game_system.atlas_unlocked.size
     # Switch to different status screen
     $scene = Scene_Atlas.new
     return
   end
   # If L button was pressed
   if Input.trigger?(Input::LEFT)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     # To previous map
     $displayedmap += $game_system.atlas_unlocked.size - 1
     $displayedmap %= $game_system.atlas_unlocked.size
     # Switch to different status screen
     $scene = Scene_Atlas.new
     return
   end
 end
end


Place in new slot below RTPs, above Main.


Instructions

Look inside script for full instructions


Compatibility

No known compatibility issues


Credits and Thanks


  • Aqua (aka TerreAqua)
  • Evander for requesting it.
  • LegacyBlade for finding a potential bug.
  • Starrodkirby86 for being you. :D



Author's Notes

I hope my instructions are clear enough... XD

acebelowzero

Um its good but i would expect better from u.. But good job
Whats up!
Vist www.dexia.tk and we will host your very own created games!
Thanks.

Aqua

Expect better? O.o
What do you mean?

acebelowzero

Forget it im sorry im just so tired good job and i like your other script " :) Weapon Specific Skills"
Whats up!
Vist www.dexia.tk and we will host your very own created games!
Thanks.

Megamanx4884

I think it's great o_o Bravo, Aqua.  :up:

Look forward to seeing more great scripts. XP
DO NOT CLICK!

Why don't you people listen? D:

vacancydenied

That's a really good script. I think I might use it =). You should make more scripts Aqua
Nothing goes as planned but I keep going forward.

Calintz

So basically, if the player cannot see all of the map, this will reveal it??

Magus

the screenies makes it look like the atlas is taking up the majority of the screen. D:

This is good though

I still prefer Blizzard's mini map for opinionated reasons.
LEVEL ME DOWN. THE ANTI-BLIZZ GROUP IS AMONG YOU... Do it for the chick below...She watches..<br />

Calintz

Nah, I think I prefer this one here ...
If this thing does what I think it does, then it would definitely suit my needs better.

Aqua

It's like a world map (atlas) script...
Except instead of having only 1 world atlas, it can also display the current map that you're on.

So if you're a huuuuge map, using this can at least give you a sense of where to go XD
And you can make the atlas look however you want, say, a real old-fashion cartographer style.

Calintz

Very cool!!
Does it have a scroll feature, or is the atlas guaranteed to display the entire map your on all at once??

Taiine

This is something I've been looking for for a long time, specially if it can accurately pinpoint the players location.

However can it be edited to do something?

My game has a lot of dungeons that you can either buy a map to, or find it somewhere inside the dungeons themselves. I'd like it if you pick up different map items it will only show the map to that one area you use the item for and show your whereabouts on the map, and not scroll though other maps.

Like if your in dungeon 5, you come across a chest that has the map, you can now bring up a map for just that dungeon and see your location on the map. Later you go to a shop, buy a map for a mini dungeon, and now that item allow you to see that map.

That along with conditional branch events inside those dungeon that if item x in invatory and button  blarg is pressed show this map.

Thats just what I'd like, and not scrolling though all the maps or being able to see them all on the get go.

Think theres away for that? Or another script that allows it?

Aqua

I'm too lazy/don't have enough time to do that...

But basically, you'd need to have the option of showing the default map to true.
Then you'd need to change the default map every time you enter/leave a dungeon.

Thirdly, you need to get rid of the scrolling of maps which is in the scene... Around lines 287...
    # If R button was pressed
    if Input.trigger?(Input::RIGHT)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next map
      $displayedmap += 1
      $displayedmap %= $game_system.atlas_unlocked.size
      # Switch to different status screen
      $scene = Scene_Atlas.new
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::LEFT)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous map
      $displayedmap += $game_system.atlas_unlocked.size - 1
      $displayedmap %= $game_system.atlas_unlocked.size
      # Switch to different status screen
      $scene = Scene_Atlas.new
      return
    end

Just delete those XD

Zare

yeah perfect :D great work, lvld you up  :-*
Now I have to find a solution how to make a screen of my 320*220 Worldmap  :wacko:

Aqua

You mean map tiles? XD

Just make a lot of screenshots of the editor and paste them together.
That's what I did for the pictures in the demo (:

Zare

the problem is, that I have many white squares in my worldmap (had terrainproblems to solve xD), which you can't see ingame. I thought I saw a script long time ago where you could save maps as pictures, but maybe this was when I was using RMVX (about 3 years ago xD)

Aqua

You can always just shop those squares out? lolz

Zare

yay but they're about 400 xD but I think I will do it like that, so thank you :3

XxxZEROxxX

i dont like it cuz it dosent work and right i think people would think better from you  :^_^': :uhm:no fense

legacyblade

It works pretty well. You just have to configure it correctly.