Modding Help Making microdungeons overlappable?

Discussion in 'Starbound Modding' started by Cgeta, Dec 29, 2016.

  1. Cgeta

    Cgeta Pangalactic Porcupine

    Hai, I've had the spontaneous idea to make a new planet type that contains tall trees made up of tiles.
    They are generated as microdungeons that consist of multiple parts, just like regular dungeons, but way more common.

    The issue I'm having is that they tend to cut each other off when they generate too close to each other.

    So I was wondering if it is possible to have microdungeons be able to generate on top of each other, and if not, if it's possible to create a distribution for the biome file in order to keep them away from each other at a set minimum distance? The problem with a random distribution is that even when they are very rare, they still have a chance to pop up right next to each other.

    Another issue I sometimes notice is that they cut off even without anything else being present. I wonder what could be causing this. This strangely seems to happen more likely the rarer I make them spawn.

    Before I forget, the log doesn't say anything. No errors or warnings. Might be since they're technically still microdungeons.
  2. lazarus78

    lazarus78 The Waste of Time

    Not much you can do there. When a part is spawned in, it will overwrite everything in its area. The game manages this by having the parts exactly the size they want, or having buffer space around them so they won't overlap because of the issue you are seeing.
  3. Cgeta

    Cgeta Pangalactic Porcupine

    I was able to alleviate most of the issues caused by them generating too close to each other.
    Now my main issue is that in certain areas it appears that chunks of the trees are missing for no reason. This is especially the case near the spawn point on the planet. Sometimes it happens to almost every tree, other times is happens almost not at all.
    I really wonder what's causing this as I have no idea.

    It seems to be independant of the size of the trees, and their distance from each other. To some it happens, to some it doesn't.
    And the cut off is not based on the individual parts of the trees. It goes straight through the whole thing
    Last edited: Dec 31, 2016
  4. lazarus78

    lazarus78 The Waste of Time

    What do the sections look like? Sections will be missing if you have bad placed link points.
  5. Cgeta

    Cgeta Pangalactic Porcupine

    The missing parts are independend from the sections of the dungeon. It is not failing to place them, rather, areas across multiple sections are missing. As if the full thing just gets parts cut out of. And it is not that entire sections that are missing either. Just parts of them
  6. Inf_Wolf14

    Inf_Wolf14 Parsec Taste Tester

    I'm just trying to get a grasp before I offer any advice...

    Are your trees, which are generated dungeon pieces, still cutting into each other?
    Or are they just generating with gaps that are independent of neighboring trees?

    (Also, for the sake of clarification later, your using Tiled to design the trees, yes?)
  7. bk3k

    bk3k Oxygen Tank

    Perhaps make them objects instead. Overlapping objects is easy by way of defining "spaces" instead of the spacescan method. And while I haven't played with tiled, you can probably just have those objects placed via microdungeon.

    There are multiple ways to do place the blocks as part of the objects. One way(what doors do) is object.setMaterialSpaces() where you feed it a table of relative positions and materials that if stored in your object might look like this.
      "wallMaterialSpaces" : [
        [ [0, 2], "metamaterial:objectsolid" ],
        [ [1, 2], "metamaterial:objectsolid" ],
        [ [2, 2], "metamaterial:objectsolid" ],
        [ [3, 2], "metamaterial:objectsolid" ],
        [ [4, 2], "metamaterial:objectsolid" ],
        [ [5, 2], "metamaterial:objectsolid" ],
        [ [5, 1], "metamaterial:objectsolid" ],
        [ [5, 0], "metamaterial:objectsolid" ],
        [ [14, 0], "metamaterial:objectsolid" ],
        [ [14, 1], "metamaterial:objectsolid" ],
        [ [14, 2], "metamaterial:objectsolid" ],
        [ [15, 2], "metamaterial:objectsolid" ],
        [ [16, 2], "metamaterial:objectsolid" ],
        [ [17, 2], "metamaterial:objectsolid" ],
        [ [18, 2], "metamaterial:objectsolid" ],
        [ [19, 2], "metamaterial:objectsolid" ],
        [ [0, 11], "metamaterial:objectsolid" ],
        [ [1, 11], "metamaterial:objectsolid" ],
        [ [2, 11], "metamaterial:objectsolid" ],
        [ [3, 11], "metamaterial:objectsolid" ],
        [ [4, 11], "metamaterial:objectsolid" ],
        [ [5, 11], "metamaterial:objectsolid" ],
        [ [5, 12], "metamaterial:objectsolid" ],
        [ [5, 13], "metamaterial:objectsolid" ],
        [ [14, 13], "metamaterial:objectsolid" ],
        [ [14, 12], "metamaterial:objectsolid" ],
        [ [14, 11], "metamaterial:objectsolid" ],
        [ [15, 11], "metamaterial:objectsolid" ],
        [ [16, 11], "metamaterial:objectsolid" ],
        [ [17, 11], "metamaterial:objectsolid" ],
        [ [18, 11], "metamaterial:objectsolid" ],
        [ [19, 11], "metamaterial:objectsolid" ]
    Where as you replace the metamaterial there with actual tiles. You could keep that particular metamaterial if you wanted to draw the tree instead

    But you could also use world.placeMaterial() to do the same. That requires actual positions(object position + relative position). The advantages of using world.placeMaterial are that
    1. The placed tiles won't be considered part of the object. Therefore you can cut away some to build your tree house.
    2. You could have trees grow into each other without cutting off as your pictures show. If tile placement fails, it simply returns false.
    3. You can have a certain randomness to branch growth if your tree spaces are determined by functions instead of predefined. Likewise their growth could be adjusted based upon conditions.
    4. You can control the hue of the blocks.
    5. object.setMaterialSpaces doesn't place a background but with world.placeMaterial you can have branches/leaves in the background where there is no foreground tile
    6. The branches could expand every so often(provided no obstacles present. You just add another tile.
  8. Cgeta

    Cgeta Pangalactic Porcupine

    I'm using the old image file type of thing. As far as I remember reading is that Tiled doesn't work with custom tiles? Not sure.
    This way seems much easier
    treebase1.png treemiddle1.png treetop1.png treetopright2.png treetopleft2.png

    And yeah, initially the main problem was that they would generate too close to each other.
    I mostly found my way around this.

    Now there are trees that still have parts missing, even if nothing else is in the area. Most commonly they tend to cut off on the top, creating something like a flat plateau.

    Oyeah, I remember making objects before. Not sure if I want the whole tree to act like one single object though.
    Also I've never fidgeted much in lua before. I'm not really sure if I want to go that far to make it work.
    Last edited: Jan 1, 2017
  9. Inf_Wolf14

    Inf_Wolf14 Parsec Taste Tester

    Well, Tiled does support custom tiles and objects... But making your own tilesets isn't something I'd recommend to someone not very experienced with the program either... :/
    How tall would you say your trees generate as?
    Because I can only think that something is interfering and overwriting them at the top, cutting it off... Unless it's an issue with dungeon size, but I think that's very unlikely.

    Have you checked your log when finding a tree like that? (Just wanna check if it may be some unknown generation error you're getting.)
  10. bk3k

    bk3k Oxygen Tank

    As for the lua to make it work, it wouldn't take much... if you decided to go that path. If you chose to go that path and need help coding, I'd be glad to. Nothing I'm describing would be difficult for me.

    As for it considering the whole thing as one object, that would be true via the first method I mention, and not true for the second.
    world.placeMaterial() will place blocks that are not considered as part of any object... they're just blocks.

    The "object" might be nothing more than a 1x1 tile worth of roots etc. In fact your object could itself be invisible, with you only seeing the blocks placed by it. And the object doesn't necessarily need to have a drop. It can be permanently destroyed by harvest attempts if you want. That might be worth doing if you only ever wanted the object to be a "builder" of your trees.

    For that matter, your object could self destruct after having built the tree.

    Another thing that could be cool to do, is such an object could decide to occasionally generate a house built into the tree, or birds nests, etc. It could be a bit dynamic.

    I have an idea... not that I'm terribly experienced with dungeons. But here's what I'm guessing is going wrong.

    "small" : {
          "size" : [3000, 2000],
          "gravityRange" : [80, 80],
          "layerDefaults" : {
            "secondaryRegionCount" : [1, 1],
            "dungeonCountRange" : [1, 1]
          "layers" : {
            "space" : {
              "baseHeight" : 1850,
              "layerLevel" : 1700
            "atmosphere" : {
              "baseHeight" : 1400,
              "layerLevel" : 1100
            "surface" : {
              "baseHeight" : 675,
              "layerLevel" : 600
            "subsurface" : {
              "baseHeight" : 550,
              "layerLevel" : 500
            "underground1" : {
              "baseHeight" : 450,
              "layerLevel" : 400
            "underground2" : {
              "baseHeight" : 350,
              "layerLevel" : 300
            "underground3" : {
              "baseHeight" : 250,
              "layerLevel" : 200
            "core" : {
              "baseHeight" : 50,
              "layerLevel" : 0

    I'm guessing the level at which it cuts off varies by planet size? Once you hit [x, 1400] on a small planet, you're in a different layer. Your dungeon is set to spawn on the surface. So the portion of your dungeon that would be above the surface level won't generate. If I'm correct and you're determined to use dungeons anyhow, perhaps a second dungeon that starts in "atmosphere" that is specifically rooted to your other dungeon? Or rooted to the wood itself.

    That might involve different dungeon versions for different planet sizes? Or not. But the "tree builder" solution wouldn't have that sort of problem.

    On the other hand, one "atmosphere" dungeon rooted to another could have other really cool possibilities. Imagine an NPC village(dungeon) in the sky using massive trees as a base. Platforms connecting it all.

    And that reminds me... we don't have any objects akin to a rope bridge, do we? Sometimes attempting to help leads to some brainstorming. Rope bridges, but also a more technological solution too. I might have to make some objects like that.
    Inf_Wolf14 likes this.
  11. Cgeta

    Cgeta Pangalactic Porcupine

    Reminds me that one idea I had was about the atmosphere layer having a biome that is made of leaves, and the surface layer below would be the tree trunks.

    Also I am not sure if the trees entering the atmosphere is the reason they cut off, as they cut off at different heights.
    I can have one tree cut off, and the one next to it easily reaches much higher into the atmosphere

    Also no errors in the log
  12. bk3k

    bk3k Oxygen Tank

    Hmm does your zoom level affect it? How tall they get I mean.
  13. Cgeta

    Cgeta Pangalactic Porcupine

    I set the biome height to be 2500 and it didn't have any influence on that problem. The zoom level didn't affect anything either as far as I know

    Also having an object place tiles via lua sounds rather interesting. But I think for now I'll try to solve it with microdungeons. It always feels like I'm so close to a solution, just one little thing.
    But if I never figure out anything else, maybe I'll try the obejct method.

    Also I added some wip background scren.png
    bk3k likes this.
  14. Inf_Wolf14

    Inf_Wolf14 Parsec Taste Tester

    I'm gonna try my hand at a mock-up of this and see if I can recreate the issue using Tiled.
    Your trees are well into the sky outside the surface layers, yes?

    I'll get back to you if I can find some insight into the problem. (Or if I have any success.)
  15. Cgeta

    Cgeta Pangalactic Porcupine

    Some are, but most stay below

    Edit: the ones near the spawn seems to be broken the most. But they have to be generated in the world. Trees placed with placedungeon never had any issues at all
    Last edited: Jan 3, 2017
    Inf_Wolf14 likes this.

Share This Page