Created
February 10, 2021 23:13
-
-
Save ZeWaka/30dff5acce1ff9d5dec0c3c0ead61eb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/proc/CAGetSolid(var/L, var/currentX, var/currentY, var/generation) | |
var/default = 1 //1 = wall, 0 = empty | |
var/minSolid = 5 //Min amount of solid tiles in a given window to produce another solid tile, less = more dense map | |
var/fillLarge = 0 //If 1, put rocks in the middle of very large open caverns so they don't look so empty. Can create very tight maps. | |
var/endFill = -1 //Reduce minSolid by this much in the last few passes (produces tighter corridors) | |
var/passTwoRange = 2 //Range Threshold for second pass (fill pass, see fillLarge). The higher the number, the larger the cavern needs to be before it is filled in. | |
var/count = 0 | |
for(var/xx=-1, xx<=1, xx++) | |
for(var/yy=-1, yy<=1, yy++) | |
if(currentX+xx <= world.maxx && currentX+xx >= 1 && currentY+yy <= world.maxy && currentY+yy >= 1) | |
count += L[currentX+xx][currentY+yy] | |
else //OOB, count as wall. | |
count += default | |
var/count2 = 0 | |
if(fillLarge) | |
for(var/xx=-passTwoRange, xx<=passTwoRange, xx++) | |
for(var/yy=-passTwoRange, yy<=passTwoRange, yy++) | |
if(abs(xx)==passTwoRange && abs(yy)==passTwoRange) continue //Skip diagonals for this one. Better results | |
if(currentX+xx <= world.maxx && currentX+xx >= 1 && currentY+yy <= world.maxy && currentY+yy >= 1) | |
count2 += L[currentX+xx][currentY+yy] | |
else //OOB, count as wall. | |
count2 += default | |
return (count >= minSolid + ((generation==4||generation==3) ? endFill : 0 ) || (count2<=(generation==4?1:2) && fillLarge && (generation==3 || generation==4)) ) //Remove ((generation==4||generation==3)?-1:0) for larger corridors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment