Defined map boundaries (splitting up a big map, for camera)

noctiluca

Veteran
Veteran
Joined
Jan 9, 2015
Messages
187
Reaction score
167
First Language
English
Primarily Uses
I've been looking for ways to split up large maps into segments (like the common technique of having multiple interiors for a town combined on one larger map) and while you technically don't need any script or plugin to do that, it can make the camera movement very clumsy-looking (lots of empty blank space, in order to prevent the player from seeing the other segments of the map). And you have to waste almost a screen's worth of tiles to keep everything well-hidden, too.





^ how segmented maps have to look in the editor by default (so much wasted space)


It causes even more obvious problems when having the blank space would be very ugly/conspicuous, like on outdoor maps (ie. imagine a puzzle where you have events moving "across maps"-- instead of having to use a combination of global switches and variables, you can just teleport the event to another segment of the map to give the illusion that you are moving it to another map. This works for towns as well to help make simulated NPC schedules!! :D ).





^ what the game camera does by default, and how it would ideally look ('locking' to the boundaries)


I've tried to work with a few camera control scripts, but it's difficult to use them because they are geared toward cutscene direction, not purposes like this.


I think the solution lies in having the Game_Map.scrollUp/Left/Down/Right functions to be based on the user-set boundaries and not the actual map width/height, but I don't have the know-how to take it a step further and actually get it to work, and I think this script would help a lot more people than just myself. The intended effect is having what would look exactly like several separate maps in-game (camera stopping at the edge of the boundary), but it's all actually in one map in the editor. The plugin detects what segment the player is active in using their x/y coords, and behaves accordingly.


I was thinking it would be best if these boundaries were defined in the map's notetags like


<boundaries>


1: x,y,width,height (example 0,0,24,17)


2: x,y,width,height (example 25,0,17,13)


</boundaries>


...because it would also be a way to identify if the map is supposed to be segmented, or just a regular scrolling map. Using regions might also be possible, but since regions are used for so many other purposes I feel like it would conflict with too many other systems... there are 256 of them though, and I doubt anyone really uses all of them in a single map so it may be a way to go about it too.


Other really useful snippets that could go along with this would be functions that check which map segment the player or an event is currently positioned in. Events could have different pages activated based on the segment they are in (again, super useful for livelier NPCs)


as far as preventing the player from walking across the "edge" of a map by leaving a segment, I figured that would have to be done manually by the developer either by setting up impassible tiles or transfer events on the edges. There are possible advantages to allowing events, for example, to move between segments on their own. Events could also be recycled, like if you had some decorative events that are used over and over (birds, butterflies, lights...), you could teleport them along with the player during the transfer event to where they need to be. That way, you can greatly reduce the number of total events you have on the map.
 

noctiluca

Veteran
Veteran
Joined
Jan 9, 2015
Messages
187
Reaction score
167
First Language
English
Primarily Uses
Bump.


I was able to get the camera to stop where it needs to stop moving by changing this section of code:


Game_Map.prototype.scrollDown = function(distance) {
if (this.isLoopVertical()) {
this._displayY += distance;
this._displayY %= $dataMap.height;
if (this._parallaxLoopY) {
this._parallaxY += distance;
}
} else if (this.height() >= this.screenTileY()) {
var lastY = this._displayY;
this._displayY = Math.min(this._displayY + distance,
this.height() - this.screenTileY());
this._parallaxY += this._displayY - lastY;
}
};


changing this.height() in the this._displayY = Math.min(.....) part to the number of tiles I want the segment to be resulted in the desired visual effect. So changing it to 20 made the map stop scrolling when the tiles with a Y of 20 were visible on screen.


Obviously, editing the base code isn't what I want to do and for a map that has many different segments, it needs to know the origin tile x & y and the width and height in tiles of the segment through some kind of variable. And there's also ScrollLeft,ScrollRight,ScrollUp functions. There should be some way, like adding another "if" clause like the isLoopVertical() (like isMapSegmented) to tell the game that it needs to be segmented and to use the appropriate variables.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I'd look at using regions for this - allocate one region id that will be used for this purpose on ALL maps, change the functions above to not scroll anymore if the edge tile contains the specified region, and that way you don't have to use a fixed/uniform size.
 

noctiluca

Veteran
Veteran
Joined
Jan 9, 2015
Messages
187
Reaction score
167
First Language
English
Primarily Uses
Thanks for the response!


I get the idea behind using a region border, but don't really know how to implement it. The only way i know how to find the region of a tile is $gameMap.regionId(x,y) and you need a specific X and Y value to get a result. I have no idea how to search a map for all the X and Y values of tiles marked with region N without doing a loop that checks every single tile on the map, and even then I wouldn't know how to use the data retrieved by that loop :/ Sorry if this is asking a really stupid/obvious question, I am hopeless with geometry.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
Shaz what is the command to disable mapscroll? in ace that doesnt exist. did they implemented thatone in mv? not sure how regions could help in this case.


Edit:


You just need the Region on which the Player stands, because thatone is important.


The others doesnt matter.


$gameMap.regionId($game_player.x,$game_player.y)  (Not sure if this is written correct)


But i dont see how regions would help you solve your camera problem.
 
Last edited by a moderator:

noctiluca

Veteran
Veteran
Joined
Jan 9, 2015
Messages
187
Reaction score
167
First Language
English
Primarily Uses
The problem with using the region that the player is standing on is that by the time the player is standing on the border region, the camera will have already scrolled too far spilling the camera into the other maps.





(I know this is not a very logical example because the maps are so different from each other, but let's say the boundaries are the tiles in pink)


The camera has to stop in that direction as soon as a boundary region comes into view, and then ease up/allow free movement in that direction once the region boundary is out of sight again. If there's a visible region boundary on the left, then the camera cannot scroll left any further. If it's visible on the left and right side, then the camera can only scroll up/down. And so on...


This is where the problem comes in, because I don't know how to check for this, because the region boundary tiles could be anywhere. I think screenTileX/Y (which are the default window size in tiles) might be helpful in calculating, but I really don't know. It probably needs a lot of extra functions to search the borders of the screen.
 
Last edited by a moderator:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
If you just have rectangle maps it would be easier to automate than L shaped maps.


For example if you are right of the Tent and you go up 1Tile the whole map will start Scrolling up to 8Tiles to the right.


Is that behavior in  L Maps ok for you?


Else, this is a nice Mechanic Idea of yours. Thumps Up.
 

noctiluca

Veteran
Veteran
Joined
Jan 9, 2015
Messages
187
Reaction score
167
First Language
English
Primarily Uses
Actually in the L-shaped map, the scroll-right behavior would remain locked until the player moved up enough tiles for that pink border along the dead trees to be out of view of the camera, way past the tent. It isn't exactly elegant, but if the script just looks for what is on the edge of the screen it should behave that way. Simple rectangles are easier to visualize though... and oddly shaped maps are somewhat rare, I'd imagine. Just having a feature for rectangular maps would be a huge leap forward.


Anyway, the most obvious use for this system is having sim features, like NPCs with AI that wander from place to place on a schedule or through behavior trees, without having to make many clones of that character for each map (and then deal with the headache of switches and variables management + calculating exactly where that NPC is supposed to be on their route at any given time). The other solution to that is somehow making a whole new class of events that exist and operate independently from a map, and I think that would be way harder to integrate because the game only ever loads one map at a time. A character can't run around a map that isn't even loaded, and having many maps loaded in the background would prolly cause even worse memory problems than having one larger map.
 

Ricksoaz

Villager
Member
Joined
Aug 6, 2016
Messages
11
Reaction score
0
Primarily Uses
Not sure if noctiluca still wants it, but I was able to find a "workaround" for this. It is simply binding the camera to an invisible, wall-phasing and over-character event that follows the player around. I used Galv's Cam Control to bind the camera to my "camera man" and simply set the boundaries to its movement based on the "fake" map size that I asign each time I enter the area. It replicates the default camera almost perfectly, you just have to fiddle a bit with the event/camera speed like this:


if ($gamePlayer.isDashing()){this._moveSpeed = 5;} else {this._moveSpeed = 4;}




Mine is assuming the area is a rectangle ofc. My javascript skills suck too much to try the methods mentioned above haha. I hope this helps someone. 
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,546
Members
137,835
Latest member
yetisteven
Top