Memorize Location Script - Release 2
#1
Memorize Location Script - Release 2
Dubealex
Nov 10 2004

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Download the playable demo here:


.exe   Memorize_Location_Script.exe (Size: 400.5 KB / Downloads: 3)

NEW RELEASE #2 NOW AVAILABLE !

This is the first script I do alone, it's not an edit, I coded it entirely. So here's what it do:

Basic Features:

- Store the location of the player
- Store the location of any events on the map
- Store as many locations in memory as you want
- Recall an event to a location (new in release 2)
- A warp feature to teleport at specific location with script (new in release 2)

What data does it stores ?

-> Map ID
-> Map Name
-> X and Y coordinates on the map
-> Screen X and Screen Y viewed on screen
-> Facing Direction
-> Terrain ID of the tile where the location is
-> A keyname to name each location and refer to them
-> A full name for use in your story line if you want it (optional).

Extra features in the demo:

- An "Exit Warp" item that allows you to exit from a maze, warping you at the entrance you took to enter the maze.

- An item "Location Warp" used to memorize any location the player wants... It memorize the location where the player is when using the item; and when used again, the player is warped back at that location. (Aka like diablo.)

- A Rock that you can pull, and if you exit the map and come back, it will stays where you left it. (New in release 2)

Be sure to read the instructions on this post entirely.

The scripts you need:

PART 1/2:
Adding the save/load lines in order to save the location you did when saving a game.

Search for this line using the Search tool in the script editor in the class "Scene_Save":

Code:
Marshal.dump($game_system, file)



This is the first line of a group of Marshal.dump lines; those that actually saves data in the save file. Under the last one, paste that new line for my script:

Code:
Marshal.dump($MemLocation, file)



Then, go in the class "Scene_Load" and do the same trick, but search for the line:

Code:
$game_system  = Marshal.load(file)



This is once again the first line of a group of Marshal.load, that load data from the save files. So, once again, right under the last Marshal.load line, paste that one:
Code:
$MemLocation  = Marshal.load(file)



PART 2/2:
Adding the new Memorize Location code in the script editor.

All you need to do is add a new class before main named Memorize_Location. (Use "insert" or right click then "insert" to add a class.) And paste that code in it:
Code:
#===================================================
# ■ Memorize Location Script R2 - created by dubealex
#===================================================
# For more infos and update, visit:
# asylum.dubealex.com
#
# -> Real/Screen coordinates fixed.
# -> Screen X/Y added.
#
# November 26, 2004
#===================================================

#===================================================
# ▼ CLASS Store_Location Begins
#===================================================
class Store_Location
  
   attr_accessor :x
   attr_accessor :y
   attr_accessor :rx
   attr_accessor :ry
   attr_accessor :sx
   attr_accessor :sy
   attr_accessor :facing
   attr_accessor :mapID
   attr_accessor :mapName
   attr_accessor :name
   attr_accessor :keyname
   attr_accessor :terrain
  
   def initialize(x, y, rx, ry, sx, sy, facing, mapID, mapName, name, keyname, terrain)
     @x= x
     @y= y
     @rx= rx
     @ry= ry
     @sx=sx
     @sy=sy
     @facing= facing
     @mapID= mapID
     @mapName= mapName
     @name= name
     @keyname= keyname
     @terrain= terrain
   end
  
end
#===================================================
# ▲ CLASS Store_Location  Ends
#===================================================


#===================================================
# ▼ CLASS MemLocation Begins
#===================================================
class MemLocation
  
   def initialize(keyname, name, event)
     @name= name
     @keyname= keyname
     @event = event
    
     if event <= 0    
       x= $game_player.x
       y= $game_player.y
       rx= $game_player.real_x
       ry= $game_player.real_y
       sx= $game_player.screen_x
       sy=$game_player.screen_y
       facing= $game_player.direction
       mapID= $game_map.map_id
       mapName= $game_map.name
       terrain= $game_map.terrain_tag(x, y)
       $MemLocation[@keyname] = Store_Location.new(x, y, rx, ry,sx,sy, facing, mapID, mapName, name, keyname, terrain)
       self
     elsif event >= 0
       x= $game_map.events[event].x
       y= $game_map.events[event].y
       rx= $game_map.events[event].real_x
       ry= $game_map.events[event].real_y
       sx= $game_map.events[event].screen_x
       sy=$game_map.events[event].screen_y
       facing= $game_map.events[event].direction
       mapID= $game_map.map_id
       mapName= $game_map.name
       terrain= $game_map.terrain_tag(x, y)
       $MemLocation[@keyname] = Store_Location.new(x, y, rx, ry,sx,sy, facing, mapID, mapName, name, keyname, terrain)
       self
      end
  end
  
   def [](name)
       $MemLocation[keyname]
   end

end
#===================================================
# ▲ CLASS  MemLocation Ends
#===================================================

#===================================================
# ▼ CLASS RecallLocation Begins
#===================================================
class RecallLocation
  
   def initialize(keyname, facing)
    
     if $MemLocation.has_key?(keyname)  
      $game_map.setup($MemLocation[keyname].mapID)
      $game_player.moveto($MemLocation[keyname].x, $MemLocation[keyname].y)  
      case facing
      when -1
           case $MemLocation[keyname].facing
           when 2
             $game_player.turn_down
           when 4
             $game_player.turn_left
           when 6
             $game_player.turn_right
           when 8
             $game_player.turn_up
         end
      when 2
       $game_player.turn_down
      when 4
       $game_player.turn_left
      when 6
       $game_player.turn_right
      when 8
       $game_player.turn_up
     end
      Graphics.freeze
      $game_temp.transition_processing = true    
      $game_map.autoplay
      $scene = Scene_Map.new
      $game_temp.transition_processing = false
      Graphics.frame_reset
    else
       print "This location does not exist yet in memory."
       print "Use 'Conditional Branches' in your event to bypass this error."
       print "Read the full instruction manual on RMXP.DUBEALEX.COM"
     end
   end
end
#===================================================
# ▲ CLASS  RecallLocation Ends
#===================================================


#===================================================
# ▼ CLASS Warp Begins
#===================================================
class Warp
  
   def initialize(mapID, x, y, facing)
      $game_map.setup(mapID)
      $game_player.moveto(x, y)  
     case facing
      when 2
       $game_player.turn_down
      when 4
       $game_player.turn_left
      when 6
       $game_player.turn_right
      when 8
       $game_player.turn_up
     end
      Graphics.freeze
      $game_temp.transition_processing = true    
      $game_map.autoplay
      $scene = Scene_Map.new
      $game_temp.transition_processing = false
      Graphics.frame_reset
    end
  end
  
  
#===================================================
# ▲ CLASS  Warp Ends
#===================================================


#===================================================
# ▼ CLASS RecallEvent Begins
#===================================================
class RecallEvent
  
   def initialize(keyname, event)
    
     if $MemLocation.has_key?(keyname)
   $game_map.events[event].moveto($MemLocation[keyname].x, $MemLocation[keyname].y)
    else
       print "This location does not exist yet in memory."
       print "Use 'Conditional Branches' in your event to bypass this error."
       print "Read the full instruction manual on RMXP.DUBEALEX.COM"
     end
   end
end
#===================================================
# ▲ CLASS  RecallEvent Ends
#===================================================

#===================================================
# ▼ CLASS Game_Map Additional Code Begins
#===================================================
class Game_Map
  
#Dubealex Addition (from XRXS) to show Map Name on screen
  def name
    $map_infos[@map_id]
  end
end

#===================================================
# ▲ CLASS Game_Map Additional Code Ends
#===================================================


#===================================================
# ▼ CLASS Scene_Title Additional Code Begins
#===================================================
class Scene_Title

  
                   $MemLocation = Hash.new
#Dubealex Addition (from XRXS) to show Map Name on screen
    $map_infos = load_data("Data/MapInfos.rxdata")
    for key in $map_infos.keys
      $map_infos[key] = $map_infos[key].name
    end
end

#===================================================
# ▲ CLASS Scene_Title Additional Code Ends
#===================================================


Instruction Manual
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Set Event Location Randomly xackery 0 2,608 05-08-2009, 01:00 PM
Last Post: xackery
  New Event Location System Ánemus 0 2,627 08-29-2008, 01:00 PM
Last Post: Ánemus
  Encounter Restrictions Script modern algebra 0 2,458 08-25-2007, 01:00 PM
Last Post: modern algebra
  Credit Script 1.4 REAL Acoole 0 2,407 05-01-2007, 01:00 PM
Last Post: Acoole
  Addon or Update Script System BETA samamanjaro 0 2,488 11-15-2006, 01:00 PM
Last Post: samamanjaro
  Item Count Script KaotiX 0 2,500 09-04-2005, 01:00 PM
Last Post: KaotiX
  Learn Skills from Items Script Khatharr 0 2,384 07-14-2005, 01:00 PM
Last Post: Khatharr
  Script Generator Dubealex 0 2,409 05-30-2005, 01:00 PM
Last Post: Dubealex



Users browsing this thread: 2 Guest(s)