Locations system

Started by gerrtunk, January 24, 2011, 02:56:41 pm

Previous topic - Next topic

gerrtunk

Locations system
Version:2
By: gerkrt/gerrtunk

Introduction
This script adds a entry in the main menu(removing steps window)that shows
your actual place. The interesting thing about it is that it lets configure
about anything with flexibility and new features.

Creating locations:

-Using the map tree system. You only have to write the name of the parent map
and all the others under it take his description

-By map name

-By maps groups that share a description

Sublocations:

-By map name

-By maps groups that share a sublocation description

Sublocations allow you to add a specification of the actual area,
so: location "Aoha forest" sublocation "Old tree", for example.

Also you can combine any of these system or options without a problem.


Screenshots



Script

Get a more updated one here: http://usuarios.multimania.es/kisap/english_list.html

Code: text
 
#==============================================================================
# Locations system
# By gerkrt/gerrtunk
# Version: 2
# License: MIT, credits
# Date: 24/01/2011
# IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
# script check here: http://usuarios.multimania.es/kisap/english_list.html
#==============================================================================

=begin

------INTRODUCTION------

This script adds a entry in the main menu(removing steps window)that shows
your actual place. The interesting thing about it is that it lets configure
about anything with flexibility and new features.

Creating locations:

-Using the map tree system. You only have to write the name of the parent map
and all the others under it take his description

-By map name

-By maps groups that share a description

Sublocations:

-By map name

-By maps groups that share a sublocation description

Sublocations allow you to add a specification of the actual area,
so: location "Aoha forest" sublocation "Old tree", for example.

Also you can combine any of these system or options without a problem.


-------CONFIGURING LOCATIONS---------

Location_type : This variable sets the type of locations:
 Location_type = :map_list           -> use map list
 Location_type = :map_name           -> use map name
 Location_type = :map_tree           -> use map tree
 
-By map name: It will just write the actual map name.  

-By map list: Using this you create a group of maps that share a location
description.
 
 Locations_map_id = [
 
   [[1,2,3], 'Ahoha forest'],    # Maps 1,2,3 share Ahoha forest description
   [[4,5,6], 'Sphynx']
 
 ]
 
 Just add lines like this: [[map_id1, map_id2], 'Description'],
 

-By map tree: With this you only have to define a parent map and write its name in
the descriptions. All the maps will have the description, including the parent map.

The map tree is show under the tileset tool. If you doubleclick to - or + you will
see that the maps are shown in groups that depend in parent maps.

Note: I recomend having the maps having the maps ordered and directly relationed with
its parent map to have optimal performance.

Use example:

Mapamundi - Parent of all
 Forest - Parent of maps 3-7
   Mapa3
   Mapa4
   Mapa5 - Parent of 6,7
     Mapa6
     Mapa7
   
 Pantano del Wep
   Mapa9
   
Configuration it:
 
 Locations_map_tree = {
 
  'Forest' => 'Ahoha forest',
  'Prologue' => 'Sphynx'   # All the maps under the map called Prologue have
  # sphynx description
 
 }
 
 To add new locations add these lines:
 'Basename map name' => 'Description',
 

-------CONFIGURING SUBLOCATIONS---------

Show_sublocations : These configurates sublocations


Show_sublocations = :inactive          ---> makes them inactive
Show_sublocations = :map_name         ---> use map name
Show_sublocations = :codes          ---> makes them use map codes


inactive: if they are inactive you are going to see in the first line the
sublocations word

map name: this wall it will simply write the actual map name as a sublocation
description

codes: this works like the locations map list, but for sublocations:

 Sublocations_codes = [
 
   [[1,2], 'Santuary'],
   [[4,5,6], 'Old tree']
 
 ]
 Just add lines like this: [[map_id1, map_id2], 'Description'],
 

------OTHER THINGS------------

Unknown_location_text: This is for maps that dont have a description.
Sublocations_text : Here you can write a prefix for all sublocations
Locations_text : Here you write the describing word of the locations

=end


module Wep
 Unknown_location_text = '?????'
 # :map_tree :map_list :map name
 Location_type = :map_list
 # NEEDS TWO LINES, removes w steps
 Show_sublocations = :inactive       # :inactive, :map_name, :codes

 Sublocations_text = ''
 Locations_text = 'Location'
   
 Locations_map_id = [
 
   [[1,2,3], 'Ahoha forest'],
   [[4,5,6], 'Sphynx']
 
 ]
   
 Sublocations_codes = [
 
   [[1,2], 'Santuary'],
   [[4,5,6], 'Old tree']
 
 ]
 
 Locations_map_tree = {
 
  'Forest' => 'Ahoha forest',
  'Prologue' => 'Sphynx'
 
 }
 
end


#==============================================================================
# ** Window_Locations
#------------------------------------------------------------------------------
#  Show the places you visit
#==============================================================================

class Window_Locations < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 0, 160, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   
   # Set basic text
   text = Wep::Unknown_location_text

   # If uses the complete hash
   if Wep::Location_type == :map_list
     # Extract text from locations
     for location in Wep::Locations_map_id
       if location[0].include? $game_map.map_id
         text = location[1]
         break
       end
     end
   
   # If uses the map name
   elsif Wep::Location_type == :map_name
     # Load mapinfos for map name
     mapinfos = load_data("Data/MapInfos.rxdata")    
     # Make text
     text = mapinfos[$game_map.map_id].name

   # If it uses the map tree methods
   else
     
     # Iteraves over all base maps searching for tree of the
     # actual map.
     for locname, locdescription in Wep::Locations_map_tree
        # Search for actual map in a defined map tree
        if $game_party.tree_includes_map? (locname)
          text = locdescription
          break
        end
     end
 
   end
   
   # Draw text
   self.contents.clear
 
   # If sub locations use map names, read mapinfos
   if Wep::Show_sublocations == :map_names
       # Load mapinfos for map name
       mapinfos = load_data("Data/MapInfos.rxdata")    
       # Make text
       subtext = Wep::Sublocations_text + mapinfos[$game_map.map_id].name
       # Draw using classic style
       self.contents.font.color = system_color
       self.contents.draw_text(4, -5, 120, 32, text)
       self.contents.font.color = normal_color
       self.contents.draw_text(4, 32, 120, 32, subtext, 2)
       
   # If sub locations use map codes, iterate sublocations
   elsif Wep::Show_sublocations == :codes
     # Extract text from sublocations
     for sublocation in Wep::Sublocations_codes
       if sublocation[0].include? $game_map.map_id
         subtext = Wep::Sublocations_text + sublocation[1]
         break
       end
     end
     # Draw using classic style
     self.contents.font.color = system_color
     self.contents.draw_text(4, -5, 120, 32, text)
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 32, 120, 32, subtext, 2)
     
   # If not, draw using Locations word    
   else
     self.contents.font.color = system_color
     self.contents.draw_text(4, -5, 120, 32, Wep::Locations_text)
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 32, 120, 32, text, 2)
     
   end

 end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# Added method tree includes map
#==============================================================================

class Game_Party
 #--------------------------------------------------------------------------
 # * Tree includes map?
 #  look for the name given in actual map tree
 #--------------------------------------------------------------------------
 def tree_includes_map? (name)
   # Load mapinfos for map name
   mapinfos = load_data("Data/MapInfos.rxdata")    
   # If his name is the name searched
   if mapinfos[$game_map.map_id].name == name
       return true
   end

   map = $game_map.map_id
 
   # Iterate all parents maps
   while mapinfos[map].parent_id != 0
       if mapinfos[mapinfos[map].parent_id].name == name
         return true
       else
         map = mapinfos[map].parent_id
       end
   end
 end


Instructions

Nothing special. Just insert it before main.

Authors notes

All my scripts are in development and im open to suggestions, critics,  bugs, etc.

WhiteRose

Looks nice. :) Be sure to apply the template (http://forum.chaos-project.com/index.php/topic,17.0.html) and then we will be able to move this into the Script Database.