Event Limit Hit: Merging Maps

I was working to making events to stitch together large sections of world map when I hit the event limit. Imagine large 500x500 sections of ocean (guess it was the central atlantic this time) at the edges you need to get to the next section, but obviously I need about 2000 events (500 on 4 sides) to get this done. I saw a few threads on the subject...and I don't think HIME's map script will work well for me because sometimes you get translated into a smaller map near the poles....there would be black spaces and such.

So how do I get around this problem? Really it's only 4 events spammed on all the borders so the player can move on. Is there some other way to do this? Maybe with defined regions?
Region event maybe?


http://www.himeworks.com/2013/12/region-events/


I imagine it would be a lot easier to manage as well.
You could even do it with just 1 parallel process event. Just check the position of the player, if it's a position within a border, transfer him to the next map. This would be really easy especially if all edges of the map would transfer the player.


Like if the player's X is equal to the right-most X coordinate of the map, move him to the next map that is to the right of the current map. And so on
Yeah - use a script to monitor when the player hits the edge of the map and transfer them to a new one. Hime has linked one, I've also written one.


You could even do it with parallel process events. Just add a Wait 10 Frames in each loop.


That many events will cause your game to lag terribly - have you tried to play it with that many?
Here is a script I use all the time in my games to do exactly that --- I don't like slews of events on the edges of the map either.  It triggers a Common Event when the party touches the edge of the map.  To use it, add a tag in this syntax to the Map:

<edge location="2" />

When the player touches any edge of the map, the script will call the common event listed by COMMON_EVENT_ID in the code.  It will set the variable defined by "LOCATION_ID" to the current location (this allows the same Common Event to transport the player to different locations) and the variable defined by "EDGE_ID" to 1 (top of map), 2 (Bottom of map), 3 (Left of map) or 4 (Right of map) to indicate where the party reached.

It's free for commercial and non-commercial use:

Spoiler
####################################################################
# Module which reads XML formatted note tags and returns them as
# HashMaps
module Tag_reader
    
    ###################################################################
    # Represents a single XML node
    class XML_node
        
        #####################################
        # Constructor
        def initialize(name)
            @name=name
            
            # Set of name=value pairs
            @attributes={}
            
        end
        
        ###################################
        # Adds an attribute
        def add_attribute(name, value)
            @attributes[name]=value
        end
        
        ###################################
        # Returns this as an XML string
        def to_s
            result="<"+@name
            @attributes.each {
                |key, value| result += " "+key+"=\""+value+"\""
            }
            result += " />\n"
            return result
        end
        
        attr_reader 🙂name)
        attr_reader 🙂attributes)
        
    end

    #######################################################
    # Reads a set of XML tags    
    class XML_Reader
        def initialize()
            @nodes=[]
        end
        
        ##########################################################
        # Reads the XML tags in note_string.  Does nothing if the
        # note string is empty or nil.  Returns the set of nodes read
        # from the note_string.  This may be empty
        def read(note_string)
            @nodes.clear
            if (note_string == nil)
                return @nodes
            end
            note_s=note_string.to_s.strip
            # Ignore empty strings
            string_len=note_s.length
            if (string_len == 0)
                return
            end
            index=0
            worker=""
            right_index=0
            node_name=""
            
            # Parse the XML string
            while (index < string_len)
                
                # Search for < mark
                if (note_s[index] != '<')
                    index += 1
                    next
                end
                
                # Find the > mark after the < mark
                right_index=note_s.index("/>",index)
                if (right_index == nil)
                    right_index=note_s.index('>',index)
                    if (right_index == nil)
                        break
                    end
                end
                
                # This is a string from < to >
                worker=note_s.slice(index, right_index-index+1)
                worker=worker.strip
                
                # Find name="value" pairs
                
                # Skip the <name part of the XML
                attr_index=worker.index(' ')
                node_name=worker.slice(1,attr_index).strip
                
                new_node=XML_node.new(node_name)
                while (worker.length > attr_index)
                    if (worker[attr_index] == ' ')
                        attr_index += 1
                        next
                    end
                    value_index=worker.index("=\"", attr_index)
                    if (value_index == nil)
                        break
                    end
                    
                    # Backspace to find the previous space or < mark - start of the
                    # attribute
                    attr_start_index=value_index-1
                    while (worker[attr_start_index] != '<' &&
                        worker[attr_start_index] != ' ')
                        attr_start_index -=1
                    end
                    # Get to the start of the attribute name
                    attr_start_index += 1
                    
                    # Skip the =" marker after attribute name
                    second_quote=worker.index("\"", value_index+3)
                    if (second_quote == nil)
                        break
                    end
                    attr=worker.slice(attr_start_index, value_index-attr_index)
                    value=worker.slice(value_index+2, second_quote-value_index-2)
                    new_node.add_attribute(attr, value)
                    attr_index = second_quote+1
                end
                    @nodes << new_node
                index=right_index+1
            end
            return @nodes
        end
    end
end
 

#================================================
#
#    Script:    EdgeWarp
# by:        whitesphere ([email hidden])
#                ???? ?? 2014
#================================================
=begin
================================================================================

Description: Used to call a Common Event with a desired variable pre-set
    once the map edge is reached

--------------------------------------------------------------------------------
History

v1.0 (2014/??/??)
  Initial release
 
 
--------------------------------------------------------------------------------
Terms of Use

- You are free to use this script for non-commercial projects.
- For commercial projects, at least contact me first.
- This script is provided as-is. Don't expect me to give support.
- Reported bug will be fixed, but no guarantee on requested features.
- No guarantee either for compatibility fixes.
- Give credit to whitesphere (me), and do not delete this header.
--------------------------------------------------------------------------------

QUICK START:
???


--------------------------------------------------------------------------------
To use:  Set COMMON_EVENT_ID to the common event to call when the edge of
a map is reached.  And set LOCATION_ID to the variable which will be set to the location identified in the tag.

To each map which uses this script, add a tag in this syntax:
<edge location="2" />

Here, location is a number defining the map.  When the player touches the edge of the map, this script sets the variable defined by LOCATION_ID to the "location" tag value, then calls the common event defined by COMMON_EVENT_ID.

--------------------------------------------------------------------------------
=end




#
module EdgeWarp
    
    
    ##########################################################################
    # CONSTANTS
    
    # Set to current location from tag
    LOCATION_ID=5
    
    # Transport Event
    COMMON_EVENT_ID=1
    
    # Which edge did the player hit? 1=Top, 2=Bottom, 3=Left, 4=Right
    EDGE_ID=4
    
end


# We will clear the event list whenever we switch maps
class Game_Map
    
    attr_reader 🙂map_id)
    
    # We fetch these from the RPGMap
    def edge_get_location_id
        return @map.edge_get_location_id
    end
    
end



        
class RPG::Map
        
    def read_note_tag_as_nodes
        if (@node_set == nil)
            reader=Tag_reader::XML_Reader.new
            @node_set=reader.read(@note)
        end
        return @node_set
    end
    
    # Looks for keys under the "edge" key
    def get_tag_entry(fetch_key)
        nodes=read_note_tag_as_nodes
        if (nodes == nil)
            return nil
        end
        nodes.each {
            |current|
            if (current.name == "edge")
                current.attributes.each {
                |key, value|
                    if (key == fetch_key)
                        return value
                    end
                }
            end
        }
        return nil
    end
    
    # Returns the current location ID
    # NOTE: Common Event ID and Variable ID are hard-coded
    def edge_get_location_id
        if (@map_edge_id != nil)
            if (@map_edge_id == -1)
                return nil
            end
            return @map_edge_id
        end
        @map_edge_id=-1
        nodes=read_note_tag_as_nodes
        if (nodes == nil)
            return nil
        end
        nodes.each {
            |current|
            if (current.name != "edge")
                next
            end
            id=current.attributes["location"]
            if (id == nil)
                next
            end
            @map_edge_id=id.to_i
        }
        return @map_edge_id
    end
    
end

##################################################
# Detect player-specified movement
class Game_Player < Game_Character
    
    alias EdgeWarp_move_straight move_straight
    
    def move_straight(d, turn_ok = true)
        EdgeWarp_move_straight(d, turn_ok)
        # Check for the edges.  If we hit one, it's time
        # to warp
        if (@real_x == 0 || @real_y == 0 ||
            @real_x == $game_map.width-1 ||
            @real_y == $game_map.height-1)
            id=$game_map.edge_get_location_id
            if (id != nil)
                # Left Edge
                if (@real_x == 0)
                $game_variables[EdgeWarp::EDGE_ID]=3
                end
                
                # Right Edge
                if (@real_x == $game_map.width-1)
                $game_variables[EdgeWarp::EDGE_ID]=4
                end
                
                # Top Edge
                if (@real_y == 0)
                $game_variables[EdgeWarp::EDGE_ID]=1
                end
                
                # Bottom Edge
                if (@real_y == $game_map.height-1)
                $game_variables[EdgeWarp::EDGE_ID]=2
                end
                
                
                $game_variables[EdgeWarp::LOCATION_ID]=id
                $game_temp.reserve_common_event(EdgeWarp::COMMON_EVENT_ID)
            end
        end
    end
end
 
Yeah - use a script to monitor when the player hits the edge of the map and transfer them to a new one. Hime has linked one, I've also written one.

You could even do it with parallel process events. Just add a Wait 10 Frames in each loop.

That many events will cause your game to lag terribly - have you tried to play it with that many?
Nope...most of the area had land that didn't need so many events on the borders. So I've only played it with a couple hundred (seemed ok, but I have a nice PC) I only hit the limit when I moved out to a pure sea square. Thanks for the quick suggestions all...should be able to fix it now.

Original thread: https://forums.rpgmakerweb.com/threads/event-limit-hit-merging-maps.32976/