2017-01-08 03:46:00

Hi,
Obviously I'm asking this to Aprone, but if anyone else knows the answer I'd appreciate it from you as well. But the reason I ask Aprone in particular, is because at least on multi1 map of swamp, there are well over 100000 individual tiles, however the map loads pretty much instantaneously when it's launched. So what I'm asking is, how do you do that tile system? Are the tiles really just big rectangles that have a start x, end x, start y, and end y? Or do you have it so that every tile (coordinate) on the map is stored? I would have assumed the first, but in using CAE Jone's map editor, I found that it's actually quite possible to set tiles individually, as in you could have  grass in a rectangle all the way from 1 1 to 10 10, and plop a dirt tile at 4, 3 and it would save just fine, leading me to believe that maybe you store the tiles individually.
I looked at the multi1 map file to see if I could get an idea, but it's more something like
grass
grass
*inserts an 8 digit number*
wall
wall.wav
*inserts long number*
I would greatly appreciate your help in this matter, as the games which I am working on do use large scale maps such as this.
Thanks,
Steve.

If you have issues with Scramble, please contact support at the link below. I check here at least once a day, so this is the best avenue for submitting your issues and bug reports.
https://stevend.net/scramble/support

2017-01-08 17:06:06

Severestormsteve, every now and then I'm asked about this, and I'm not sure if you and another guy coordinated this but just before noticing this post I was sent the same question via email.  I'm sure I've typed this out to explain it to a few people over the years, but I cannot seem to find any of the old letters, so here goes as I try to type this all out again without forgetting anything important.  smile

Oh yeah, to save time I'll just point the email guy to here after I've typed it out.  big_smile  Haha!

I'm not sure which order is the easiest way to explain, so to start I'm just going to summarize the layout of a Swamp map file.  There are some loops involved, so hopefully it isn't overly confusing.  After the summary I will try to go into a bit more detail to explain how some of the parts work.

-start of file-
number of tile types
...loop through tile types
tile color (you can probably leave blank or zero because this is only used for me when visually building the map with my map editor)
tile type (1=ground 2=wall 3=topofsomething)
tile description
tile sound
...end of tile types loop
starting player x
starting player y
starting player direction (0-359)
x shift (you can probably leave blank or zero because this is only used for me when visually building the map with my map editor)
y shift (you can probably leave blank or zero because this is only used for me when visually building the map with my map editor)
zoom (you can probably leave blank or zero because this is only used for me when visually building the map with my map editor)
start x (I think this may also be an editor thing, but I'm not 100% positive)
start y (I think this may also be an editor thing, but I'm not 100% positive)
map width
map height
...loop through map width
...nested loop through map height
tile number
tile zone 1
tile zone 2
flood water value (you can probably leave blank or zero.  This is used to help the "building helper" navigate players toward the nearest exit.)
scent trail value (you can probably leave blank or zero.  This doesn't pertain to normal maps so you won't need to worry about it.)
...end of nested map height loop
...end of map width loop
number of zones
...loop through zones
zone name
...end of zone loop
number of map markers
...loop through markers
marker name
marker x
marker y
...end of marker loop
number of map loot (sound ambiences basically)
...loop through your map loots
loot name (name it Amb for anything that will be a sound)
loot x
loot y
loot amount
loot type (1=gear  2=questitem  3=small radius ambient  4=large radius ambient, and 5=random ambient which is quiet and randomly decides when to play.  I think 6 might be a random ambient also, but one that plays less often than number 5.  You can ignore numbers other than these I think.)
loot sound
...end of map loot loop
Title of first safe zone story.
First safe zone story.
Title of second safe zone story.
Second safe zone story.
Title of third safe zone story.
Third safe zone story.
Title of first outpost story.
First outpost story.
Title of Second outpost story.
Second outpost story.
final map width (use same as above or you can pick a smaller area, to restrict the playing size.  you might want to do this if your map will be using map copy to pull map pieces in from outside of the playable portion of the map.)
final map height
line you can leave blank
line you can leave blank
-end of file-


Tile types represent all of the different kinds of tiles like grass, pavement, or tile floor.  Many of those are all technically floor, for example, so the tile type identifies them.  The description is the name which might only be used in the map editor, so you may be able to ignore that.  The sound is the name of the folder, in steps, where the game will pull the foot step sounds from when someone walks on this.  When we aren't talking about floors, the sound is listing a specific file name (not a folder), and that is the sound played when the player runs into this type of tile.  Like bumping into a fence, wall, or crate.

Next are some bits about how the player first spawns on the map.  I should make a quick note that on the server any and all of this map data can be changed as needed, but when playing single player maps (or CMMS) these values are what will be used.  The player direction is zero for east, then I believe it goes clockwise so 90 would be south.

A loop within a loop will take you through all of the tiles on the map.  There are 5 pieces of information about each tile, though you can ignore the last 2.  Tile number is actually the number of the previously mentioned tile type.  If the 3rd tile type was grass, for example, then any tile with the number 3 is grass.  The tile zone 1 and zone 2 values work in the very same way, except we haven't gotten to the part about zones yet.

Now zones.  Zones are just a list of text descriptions that can be used around the map.  When a tile has a number in either it's zone 1 or zone 2 spot, it just looks at this list of zones and uses the text from that position.  So as an example, a tile may have 33 for zone 1 and 56 for zone 2.  When you look at the text in spot 33 and 56 you get "frozen foods aisle", and "Kai mart".  I'm guessing on numbers so 33 and 56 won't actually be those messages, haha.  Zone 1 is always the small-scale description while zone 2 is the larger more zoomed out description.  It makes sense to have all of the Zone 2's of a building or room be the same, and then use a bunch of different zone 1's to decorate the place with shelves, sofas, and other things.

Map markers are the 13 possible locations you can see by pressing grave, the number keys, minus, and plus.  These are the beacons such as the safe zone.  You decide what name the game will call the beacon, then list the X and Y coordinates on the map where it will ping.  The order that you list the markers is the order they will appear in the game.

Next you decorate your map with ambient sounds, and possibly loot of you're making yourself some sort of a campaign.  To be clear from the very start, if you're making a campaign it is a FAR better idea to use the Swamp campaign scripting language (SCS) to add loot to your map.  Using the "gear" and "questitem" features inside of the map file itself is not really how it should be done.  I navigated away from this approach before the SCS support was added, and using these will quite possibly break or crash things in your map due to being so outdated.  To be safe, only decorate your maps with sounds and leave "gear" and "quest items" out of it!

You start by giving your loot a name, which should always be "Amb" (capital A, lowercase m and b) if you're taking my advice of only using sounds.  When you get to the amount, just set it to 1.  That spot was meant for times when you're using actual items instead of sounds.  I believe support for either the small or large radius ambient was removed, so I'm not entirely sure which one you should use.  The good news is that whichever one I removed, I made the number still work and it just uses the other size automatically.  So yeah, I wouldn't waste time setting some sounds to 3 and others to 4, because the game is probably not going to treat them any differently.  The loot sound is the name of the file, in the Ambience folder, that will be played.

Now at the end you get to include some story, if your map happens to have either a safe zone or an outpost.  I really can't remember if safe zones or outposts let you see stories in single player, but for now I'll just assume that they do.  If you've ever been in the safe zone in Swamp then you'll probably remember seeing 3 menu options which are all story when you select them.  The Title line is what will show up in the menu (keep it short for players), and the following line will be what is read when they select it.  The 2 outpost story sections work the same way.

And that's it!  Hopefully this helps you out in some way.  Some times things are coded in a certain way just to make it easier on the developer, but often times I have a useful reason for why I do things the way I do.  If I'm storing my maps extremely differently from how you do, and you can't figure out why, feel free to ask.  My answer may be "I was lazy and just went with such-and-such just to save time", or it might be something that you didn't realize would cut down on memory usage, speed up collision detection, or whatever.  tongue

- Aprone
Please try out my games and programs:
Aprone's software

2017-01-08 19:55:12

Thanks Aprone.
That's actually quite a coincidence; I was not coordinating with anyone else on this question, I was simply looking for a way of storing a large number of tiles plus their information in a file and hoping it wouldn't take a whole bunch of time and memory to load. I appreciate this a lot.

If you have issues with Scramble, please contact support at the link below. I check here at least once a day, so this is the best avenue for submitting your issues and bug reports.
https://stevend.net/scramble/support