Procedural Maps Generator

Discussion in 'JS Plugin Releases (RMMV)' started by Lantiz, Aug 27, 2017.

  1. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Biter Maps v1.04
    by Lantiz (Biterkid)

    Hello there!

    Today I bring you guys a small pack of plugins that may be used to procedurally generate maps at run time.
    That means a new map can be created based on random numbers whenever the player enters the map.

    I've been working with these plugins for a long time and decided to share it so the community can work together and improve them. I'm currently using a slightly different version of these because of the way that my game works, but this can be the basis for whatever you may need to generate.

    Currently it's possible to generate the following patterns:
    • Cave;
    • City* (to generate modern pattern cities);
    • Dungeon;
    • Grid** (generate rooms for Zelda-like games);
    • Maze;
    • Side scrolling;
    • Town (small towns, medieval style);
    • World (can also be used for outside maps).
    * May need fixing
    ** May need improvement

    Aside from generating the maps, there's also the option to use fog of war and Zelda-like camera scrolling.


    Important notes
    These plugins are really complex and I don't have enough time to write a full documentation.
    I'm sorry about this, but if you read the help section of each plugin or the code itself, I'm sure you can understand it.
    Of course you can also ask here for help, I'll help whenever I can.

    Also, I'm not perfect.
    As I said before, I started working on these plugins a long time ago and I learned a lot since then.
    What I mean is: the plugins are not perfect, they may have errors and compatibility issues.

    If you think you can help to improve them you can edit any of these, but please, only share it here at this topic so we can keep an updated code that everyone can use


    Limitations
    For correctly saving the game and the map state, I had to change the way that the save system works.
    Currently it's only possible to have one save file for one game, which means: trying to create a save on another slot for an already started game will result in the previous slot being removed.
    This can be changed if we manage to implement better directory copying functions. I tried doing this before but didn't seem to work well.

    Fixed the save problems. Now the saving system should work fine as the default.
    It still saves the map state: layers, events, self switches... all that is inside the $dataMap object.


    Usage
    1. Add the plugins to the project;
    2. Use a $ sign at the start of the map name;
    3. Add the note tags to the map, following the help section of the btr_map_core file and each extension as needed;
    4. Add the tiles on the map following the positions [x,y] of each extension's help section;
    5. Add the desired events (and it's note tags) to the map, see btr_map_core and each extension for the possible note tags;

    I uploaded some sample map files and a mapinfo file to the zip package in case you want to see how to configure it.
    There's also a readme.txt file included.


    Screenshots
    Cave
    cave.png

    City
    city.png

    Dungeon
    dungeon.png

    Grid
    grid.png

    Maze
    maze.png

    Side scrolling
    side.png

    Town
    town.png

    World
    world.png


    Plugin order
    order.png


    Changelog
    • btr_map_grid v1.01 - Fixed "push" error on generation


    Download
    Free to use with proper credits given.

    Click here

    Also, check my game here, tell me what you think about it.
    You can follow me on Twitter too.
     

    Attached Files:

    Last edited: Jun 25, 2018
    #1
    Doktor_Q, Schade, zephar123 and 8 others like this.
  2. Nutty171

    Nutty171 Officially a lurker Veteran

    Messages:
    476
    Likes Received:
    538
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Just curious, is it possible to increase the wall height?
     
    #2
  3. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    It is and needs only to change a single value on the core plugin, but the auto tile fixing functions wont work well on walls, and that's why it's disabled.
    The auto tiling needs improvement :/

    Also this may cause unexpected behavior on some extensions, like the City or Town where it calculates the house entrances on the walls.
     
    Last edited: Aug 27, 2017
    #3
    Nutty171 likes this.
  4. Nutty171

    Nutty171 Officially a lurker Veteran

    Messages:
    476
    Likes Received:
    538
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    ^-^ Okay, I tried it out, and here's some suggestions:

    Parameters:
    -Shadows (true/false) Adds shadows/Doesn't add shadows. This'd be nice when using the overworld tileset and mountains as the walls.
    -Density (integer) Changes how frequent the grass/water/walls/paths are, as the caves especially seem rather empty.
    Other:
    -Decorations. Allows you to add pebbles, tufts of grass, etc. randomly.
    -Some way to save the map or make it generate the same map every time.

    Overall, it's pretty good! ^-^ (As far as procedural map generators go)
     
    #4
    SomebodySomething and Lantiz like this.
  5. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    For shadows theres the note tag <skipshadows> on the world extension, so you can generate over worlds without shadows.

    Changing the density is possible, but only by code for now.
    For instance, at the btr_map_world at the line 172 there's this code:

    Code:
        //cotrol the amount of each tile
        var values = [
            this._values.ground, //index 0 is always fill value
            this._values.grass
        ]; 
    If you increase the amount of the grass value inside of the array, it's going to add more grass, like this:

    Code:
        //cotrol the amount of each tile
        var values = [
            this._values.ground, //index 0 is always fill value
            this._values.grass,
            this._values.grass,
            this._values.grass,
            this._values.grass
        ]; 

    For decorations, it's hard to controll the amount each person wants to use. For instance, you may want to use 5 types of decorations, but I would like 10 types, and so on...
    You can achieve the same effect using events, I tested it with lots of event and got not lag so far.
    Of course it's not something recomended for big maps, but it works.
    I thought of creating a function to call via plugin command, so we can configure an event to draw a tile and delete itself.
    Ideas to overcome this are welcome :b

    The map should be saved as long it does not have the <regenerate> note tag. [:

    Thanks for trying, for testing and all the ideas!
    Sadly I'm out of time to improve it for now, but as I said before, I'm sharing this so somebody else can help to improve it [:
     
    #5
    SomebodySomething and Nutty171 like this.
  6. Nutty171

    Nutty171 Officially a lurker Veteran

    Messages:
    476
    Likes Received:
    538
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Ah, I haven't tested how events work on this, I had intended to... :p (And now I'm not at my computer)
     
    #6
  7. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    No worries [:
     
    #7
  8. fizzly

    fizzly Veteran Veteran

    Messages:
    367
    Likes Received:
    253
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    N/A
    Looks good! Can't wait for next development updates of this!
     
    #8
    Lantiz likes this.
  9. Nutty171

    Nutty171 Officially a lurker Veteran

    Messages:
    476
    Likes Received:
    538
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Okay, did a bit more fooling around. It's not generating any buildings in side...? EDIT: Also no buildings in city. I didn't change any map notetags.
    Oh, I meant a way to have the map be the same every time you play the game, not just every time you enter it. :p Or even it could save the map (I don't know it that's possible though.)

    P.S. that grid camera movement could be nice as an individual plugin. :p And it'd be especially awesome if it could work across maps too. :)
     
    Last edited: Aug 28, 2017
    #9
  10. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Buildings in side? I don't get it, can you post a pic?
    Oh, got that... for Side you need to define the note tags <minHouses:X> and <maxHouses:X>.
    For the City one, try using bigger and even sizes for the map.
    For instance the smaller building square is 13 (<maxLeafSize:13>), so if you make a 13x13 map it's going to generate 1 house.
    I do recomend using the Town plugin instead though, unless you want a modern pattern (square based).

    You can do it, the map data will be created inside the "save/fileN" folder (where "N" is the save id), or "save/filetemp" if the game was not saved, inside the game folder, you can just copy the file and place inside the "Data" folder.
    Not exactly made with that in mind though haha.

    You can use it in any map as long as the size of the map fits the screen size well (as specified in the plugin), you just need to add the note tag <grid> to the maps you want. There's already plugins for that though, I'm sure.
    Now if you are talking about loading another map while scrolling, it would be painfull to do. The new map would not be loaded yet.
     
    Last edited: Sep 13, 2017
    #10
  11. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Update.
    Please check the changelog for versions.

    Fixed the save problems. Now the saving system should work fine as the default.
    It still saves the map state: layers, events, self switches... all that is inside the $dataMap object.
     
    Last edited: Feb 26, 2018
    #11
  12. bhindi1224

    bhindi1224 NOT Indian Okra Veteran

    Messages:
    295
    Likes Received:
    164
    First Language:
    English
    Primarily Uses:
    RMMV
    I feel completely stupid here, but I can't seem to get the plugin to work. I've copied the maps to the data folder and installed the plugins in the order stated. Is there some initial setup I need to do after I've copied everything over from the zip?
     
    #12
  13. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Did you copy the MapInfo file too?

    The maps in the zip pack are only examples, you don't need to use them.
    In this case you need:

    1. add a $ symbol at the start of the map's name.
    2. add the tiles to the map in the correct order ( see each [x,y] coordinate on the plugin help section)
    3. define the map note tags (see the help section of the plugins)
    4. define events note tags (see the help section of the plugins)
     
    #13
  14. bhindi1224

    bhindi1224 NOT Indian Okra Veteran

    Messages:
    295
    Likes Received:
    164
    First Language:
    English
    Primarily Uses:
    RMMV
    I was just wanting to take a cruise around the maps. Do I need to create map notes for every variable? And do I need to create certain events for it to function at all? Such as player entrance/exit?

    I'll look directly at the plugins as well. I was just reading what I saw in the text under the plugins tab in MV.

    Edit: I did copy over the MapInfos.json file

    Edit again:
    PixiJS 4.5.4 - ✰ WebGL ✰ http://www.pixijs.com/ ♥♥♥


    rpg_managers.js:1919 Uncaught Error: ENOENT: no such file or directory, mkdir 'D:\RPG Maker MV Resources\Games\BiterMaps\save\filetemp'
    rpg_managers.js:1920 fs.js 789
    fs.js:789 Uncaught Error: ENOENT: no such file or directory, mkdir 'D:\RPG Maker MV Resources\Games\BiterMaps\save\filetemp'
    rpg_managers.js:1949 TypeError: Cannot read property 'x' of undefined
    at Game_Player.performTransfer (/D:/RPG%20Maker%20MV%20Resources/Games/BiterMaps/js/plugins/btr_map_core.js:1099)
    at Scene_Map.onMapLoaded (rpg_scenes.js:569)
    at Scene_Map.isReady (rpg_scenes.js:561)
    at Scene_Map.isReady (/D:/RPG%20Maker%20MV%20Resources/Games/BiterMaps/js/plugins/btr_map_core.js:1233)
    at Function.SceneManager.updateScene (rpg_managers.js:2018)
    at Function.SceneManager.updateMain (rpg_managers.js:1983)
    at Function.SceneManager.update (rpg_managers.js:1907)
     
    Last edited: Oct 5, 2017
    #14
  15. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    No need.
    Try the following:

    1. Start a new project and close it.
    2. Copy the contents from the "maps" folder (of the download) to the "data" folder of the new project.
    3. Copy the plugins to the plugins folder.
    4. Import the plugins and turn on the plugins on the editor.
    5. Place the player on the desired map.
     
    #15
  16. bhindi1224

    bhindi1224 NOT Indian Okra Veteran

    Messages:
    295
    Likes Received:
    164
    First Language:
    English
    Primarily Uses:
    RMMV
    I made a completely new project. I closed it. I copied over the maps folder (overwriting two files) to the data folder. I copied the plugins. I installed them as shown, and didn't change the player on any map, he starts on the cave map. This was my result:
    [​IMG]
    Edit: I know you're leaving soon and don't wanna bug you, I just wanted to take it for a test drive. Thanks for the help so far, I'll figure out what I'm doing wrong later on.
     
    #16
  17. bhindi1224

    bhindi1224 NOT Indian Okra Veteran

    Messages:
    295
    Likes Received:
    164
    First Language:
    English
    Primarily Uses:
    RMMV
    I figured out why it wasn't working. I had to make a save/filetemp folder, then everything worked fine. Not sure why, but that's what had to happen.
     
    #17
  18. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Was about to say, its probably a permission issue.
    The game is trying to save the generated map files.
    I'm trying to update a small change that may prevent this, but the site is giving me error when trying to edit the topic.

    Anyway, glad you could fix it [:
     
    #18
  19. Lantiz

    Lantiz Biterkid Veteran

    Messages:
    709
    Likes Received:
    1,049
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Finally managed to update the code.
    The permission problem should be fixed (it works on my machine, but I can't test anywhere else).
     
    #19
  20. bhindi1224

    bhindi1224 NOT Indian Okra Veteran

    Messages:
    295
    Likes Received:
    164
    First Language:
    English
    Primarily Uses:
    RMMV
    I freshly downloaded the link and made a new game. Still gives the error unless I manually make a save folder. Not a big deal really.
    [​IMG]
     
    #20
    Lantiz likes this.

Share This Page