Page 1 of 1

TMI - tgstation mapping initative

Posted: Tue Oct 25, 2016 10:08 pm
by Atlanta-Ned
Thanks to XDTM and some surprisingly painful logic, we have an interactive map of Box. This is still in the proof of concept phase. Please for the love of my server, do not distribute this outside tg.

Check it

Click it.

What I need to do:
• Fix the grid overlay so that it corresponds to in-game coordinates
• Figure out a way to link to specific coordinates
• Add other maps and engineering overlays
• Make it so that it's not expecting maps that are 255x255

What I need:
• Map images, made from in-game screenshots, of the ENTIRE z-level, stitched together.
• A better way to get map images that doesn't involve zooming around the entire map as a ghost
• Someone to take a look at the above map/code and see if there's a better way to handle coordinates because I can't brain on that anymore
• Access to STATS (MSO is apparently going to get me something on this
• A better place to host said map, since my server is weak and innocent

Re: TMI - tgstation mapping initative

Posted: Tue Oct 25, 2016 10:12 pm
by oranges
I can provide a server with hosting capability on linode to support this if it can run on linux, along with a domain if required.

Re: TMI - tgstation mapping initative

Posted: Wed Oct 26, 2016 4:53 am
by oranges
also how to get to the code?

Re: TMI - tgstation mapping initative

Posted: Wed Oct 26, 2016 5:10 am
by iamgoofball
is this a telesci cheatsheet

it feels like a telesci cheat sheet

good shit tho

Re: TMI - tgstation mapping initative

Posted: Wed Oct 26, 2016 3:01 pm
by Atlanta-Ned
oranges wrote:I can provide a server with hosting capability on linode to support this if it can run on linux, along with a domain if required.
I'll take you up on this. What do you need from me?
oranges wrote:also how to get to the code?
I'm gonna highjack this to explain all the components at play here:

1. The map image itself
Generated by hand at the moment. I've got map renderer from byondtools "working", but they look like garbage and that code is in need of some serious TLC.

The big, whole z-level image is split up using the imagemagick command line tools. This needs to be split into a standalone script because right now it is a pain in the butt.

2. The javascript/HTML used to power the map
The code for which is here.
Note the external dependencies:
• Line 11: the leaflet library's stylesheet, used to give us the google maps -like interface
• Line 12: the tachyons css framework, used to style the page
• Line 33: leaflet's JS library

I'm loading these in from a public CDN just for the sake of simplicity.

Lines 34-36 are plugins that I'll have to modify in order to make them work with byond's weird coordinate system
The Graticule generates the white grid overlay you see, and is plainly incorrect
The hash plugin will allow us to share links to specific coordinates, but it too needs to be adapted

Which brings us to lines 38 and 39...

3. The map .dmm file rendered into json
The PHP code for which is here.

The DMM file is has two main parts:
Tile definitions
and
where they are on the map.

I split this into two parts and bashed together a tool to turn the defines into an array. We then use the map part, also converted into an array, to look up the definition of a tile at a given set of coordinates.

This feature of the map is superfluous and was mostly done as an exercise to make sure my coordinate math was correct.
iamgoofball wrote:is this a telesci cheatsheet
it feels like a telesci cheat sheet
Could totally make a visual one. But that's a lot of power for one person.

Re: TMI - tgstation mapping initative

Posted: Wed Oct 26, 2016 6:12 pm
by XDTM
It already works as telescience cheatsheet due to the coordinates at the bottom. Also it's probably better to give everyone the ability to look up coords rather than only let those who save coordinates locally raid the armory (...which is how i had those coordinate reference points when we tested the map).
There's got to be a way to automate taking map pictures in byond though, stitching a whole map while staying zoomed in enough to keep details seems like a pain.

Re: TMI - tgstation mapping initative

Posted: Wed Oct 26, 2016 8:49 pm
by Atlanta-Ned
XDTM wrote: There's got to be a way to automate taking map pictures in byond though, stitching a whole map while staying zoomed in enough to keep details seems like a pain.
I found Crispy Mapper, but I don't know if that'll solve anything.

Re: TMI - tgstation mapping initative

Posted: Wed Oct 26, 2016 10:37 pm
by XDTM
Doesn't seem to be copypastable into an image file sadly

Re: TMI - tgstation mapping initative

Posted: Wed Oct 26, 2016 10:55 pm
by Atlanta-Ned
XDTM wrote:Doesn't seem to be copypastable into an image file sadly
Surely we can grab it from the cache at least? I'd fiddle with it on my end but I don't know the first thing about byond >.>

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 3:07 am
by pubby
I whipped up a bash script to automate the imaging process. It takes screenshots of DreamMaker at different positions and stitches them together.

Example result: http://s21.postimg.org/m0h14bm2t/stitched.png

Code: Select all

#!/bin/bash

# Original size of the map.
# You must resize the map to 400x400 before running this script.
MAP_W=256
MAP_H=256

# Upper-left pixel of tile graphics window.
TILES_X=228
TILES_Y=77

# Upper-left pixel of minimap.
MINIMAP_X=20
MINIMAP_Y=64

# Pixels to move on the minimap each step.
# This is half the number of tiles visible on the screen.
STEP_X=12
STEP_Y=10

STEPS_X=$(expr $MAP_W / 2 / $STEP_X)
STEPS_Y=$(expr $MAP_W / 2 / $STEP_Y)

CROP_W=$(expr $STEP_X \* 64)
CROP_H=$(expr $STEP_Y \* 64)

IMGDIR=tmp_screenshots

OLD_HASH=""

screencap()
{
    import -display $DISPLAY -window root $IMG
    convert $IMG -crop $(printf "%ix%i+%i+%i" $CROP_W $CROP_H $TILES_X $TILES_Y) $IMG
    HASH=$(md5sum $IMG | awk '{print $1}')
}

mkdir $IMGDIR
rm -r $IMGDIR/*.bmp
xdotool search --sync --name "Dream Maker" windowraise
xdotool mousemove $MINIMAP_X $MINIMAP_Y
xdotool mousedown 1
for y in $(seq $STEPS_Y); do
    for x in $(seq $STEPS_X); do
        CLICK_X=$(expr $x \* $STEP_X + $MINIMAP_X - $STEP_X / 2)
        CLICK_Y=$(expr $y \* $STEP_Y + $MINIMAP_Y + 200 - $MAP_H / 2 - $STEP_Y / 2)
        IMG=$(printf "$IMGDIR/%03i_%03i.bmp" $y $x)
        echo $IMG
        xdotool mousemove $CLICK_X $CLICK_Y
        sleep 0.2
        screencap
        if [ "$HASH" == "$OLD_HASH" ]; then
            sleep 0.1
            screencap
        fi
        OLD_HASH=$(echo $HASH)
    done
done
xdotool mouseup 1
montage $(ls $IMGDIR/*.bmp | sort) -tile $(printf "%ix%i" $STEPS_X $STEPS_Y) -geometry +0+0 stitched.png
And here's a version that uses the game itself for screenshots rather than DreamMaker. It takes longer though.

http://s10.postimg.org/rr2udk03b/stitched.png

Code: Select all

#!/bin/bash

MAP_W=256
MAP_H=256

# Upper-left pixel of the tile graphics window.
TILES_X=56
TILES_Y=134

# Tiles to move each step.
STEP_X=15
STEP_Y=15

STEPS_X=$(expr $MAP_W / $STEP_X)
STEPS_Y=$(expr $MAP_W / $STEP_Y)

CROP_W=$(expr $STEP_X \* 32)
CROP_H=$(expr $STEP_Y \* 32)

IMGDIR=tmp_screenshots

mkdir $IMGDIR
rm -r $IMGDIR/*.bmp
sleep 3 # While sleeping you have to manually switch focus to the game window!
for y in $(seq $STEPS_Y); do
    for x in $(seq $STEPS_X); do
        JUMP_X=$(expr $x \* $STEP_X - $STEP_X / 2)
        JUMP_Y=$(echo "$MAP_H - ($y * $STEP_Y - $STEP_Y / 2)" | bc)
        IMG=$(printf "$IMGDIR/%03i_%03i.bmp" $y $x)
        xdotool type "Jump-to-Coord $JUMP_X $JUMP_Y 1"
        xdotool key Return
        sleep 1
        import -display $DISPLAY -window root $IMG
        convert $IMG -crop $(printf "%ix%i+%i+%i" $CROP_W $CROP_H $TILES_X $TILES_Y) $IMG
    done
done
montage $(ls $IMGDIR/*.bmp | sort) -tile $(printf "%ix%i" $STEPS_X $STEPS_Y) -geometry +0+0 stitched.png

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 3:09 am
by pubby
Also, I dunno if you're doing this or not, but you should run your images through an aggressive pngquant (or similar tool) before uploading. That will cut down on filesize.

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 4:17 am
by kevinz000
as for telescience there's maps with coords of every single tile on the map available :3

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 6:15 am
by XDTM
They're outdated, kevinz000.

Pubby, the script is giving me errors about xdotool and i don't know how to install it or if it's possible to install it on windows. It seems really handy, though.

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 7:28 am
by oranges
that script is pretty much linux only

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 5:49 pm
by pubby
The windows equivalent would be autohotkey or autoit I guess.

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 6:14 pm
by iamgoofball
oranges wrote:that script is pretty much linux only
You might be able to do the Ubuntu on Windows thing with it

Re: TMI - tgstation mapping initative

Posted: Thu Oct 27, 2016 9:05 pm
by oranges
I should really take a look at the byond tools code

Re: TMI - tgstation mapping initative

Posted: Fri Oct 28, 2016 6:07 pm
by Atlanta-Ned

Re: TMI - tgstation mapping initative

Posted: Fri Oct 28, 2016 6:13 pm
by Okand37
Atlanta-Ned wrote:TMI splash page teaser
I d-don't see room for delta!

Re: TMI - tgstation mapping initative

Posted: Fri Oct 28, 2016 6:19 pm
by XDTM
I understand not acknowledging birdboat, but we get it it rotation whether we like it or not

Re: TMI - tgstation mapping initative

Posted: Fri Oct 28, 2016 6:58 pm
by Atlanta-Ned
Yeah I'm not clear on what maps are currently in rotation, so ¯\_(ツ)_/¯

Re: TMI - tgstation mapping initative

Posted: Fri Oct 28, 2016 10:54 pm
by Atlanta-Ned
Aaaaand the fruits of our combined labors
Still loads more work to do though! ^_^

Re: TMI - tgstation mapping initative

Posted: Sat Oct 29, 2016 8:33 am
by XDTM
If the box map is ready for use you might want to remove the debug stuff and the "click on a tile to show information" bar since it no longer works.
I'll try to to make pubby's script work on Windows somehow, so we can finally get the other maps :reallyhappy:

Re: TMI - tgstation mapping initative

Posted: Mon Oct 31, 2016 4:07 pm
by Atlanta-Ned
I posted an update: http://tgmap.space/status.html
The map renderer has been brought up to a baseline "it works" state. Work will now commence on adding support for optionally rendering underfloor items (pipes, wires, etc), as well as attempting to bring the renderer closer to what a player would see in-game

Re: TMI - tgstation mapping initative

Posted: Mon Oct 31, 2016 7:00 pm
by Atlanta-Ned
I need help:

How would I go about hiding objects that would normally be hidden under a floor tile, ie: wires and pipes?
The issue, as far as I can tell, is that those objects are moved under the flooring at some point as part of the game's startup process. The tricky bit with the renderer is that it's going SOLEY by how objects are defined in the code.

Re: TMI - tgstation mapping initative

Posted: Mon Oct 31, 2016 11:29 pm
by XDTM
Items have a layer var which defines what's drawn over what, maybe you could use it to determine what to hide?

Re: TMI - tgstation mapping initative

Posted: Tue Nov 01, 2016 3:55 pm
by Atlanta-Ned
Here's where I am right now.

On lines 823-828, I was able to pull out the obj's layer property and attach it to the atom itself, manipulating it based on what I know from the code's layers define file.

On line 888, I need to sort the array(?) of atoms by the layer property I specified above, but it apparently doesn't exist. I don't know enough about Python to tell what's going on either :(

Re: TMI - tgstation mapping initative

Posted: Tue Nov 01, 2016 5:04 pm
by NikNakFlak
The boxes on your website are too big so when you hover them, it "breaks" the page and causes a horizontal scroll bar. (ICK)

Re: TMI - tgstation mapping initative

Posted: Tue Nov 01, 2016 7:57 pm
by oranges
Atoms for the second render function are pulled out here.

https://gist.github.com/anonymous/1f7e5 ... er-py-L876

So you need to call as far as I can tell UpdateAtom on https://gist.github.com/anonymous/1f7e5 ... er-py-L828 where you have the layers set.

That loop that you're setting the layer in just builds a list of positions to instanceid mappings and then discards the atoms list with your changes.

Re: TMI - tgstation mapping initative

Posted: Wed Nov 02, 2016 3:33 am
by factoryman942
XDTM wrote: There's got to be a way to automate taking map pictures in byond though, stitching a whole map while staying zoomed in enough to keep details seems like a pain.
Manual is easy enough
Download code, host server, connect, then
Delay-round-start - quite sure it stops meteors and shit, as well as the bots roaming about
Then observe
Toggle-ghost-hud
Stealth-mode
Toggle-darkness
Change-view-rangeto 128
Should have you completely invisible, viewing a large portion of the station
Then you can just use the double-click ghost thing to teleport about, and F2 for screenshots

Then you can just smash them together in paint.net or whatever

For space background, just take a few screenshots of spehss and clone stamp it on another layer
If you know how large z level is(?), and how many pixels per tile there are(16x16?), you could find out how many pixels the whole thing is, make the camvas size that large, then copypasta space background on that

If I wasn't a) kinda busy and b) lazy as fuck, i probably would've done all the maps a million years ago
But no, i've only done that box thing
Although i have meta on my hard drive, with and without pipes, just not whole z level

Re: TMI - tgstation mapping initative

Posted: Wed Nov 02, 2016 7:37 am
by XDTM
So using 128 view range does not reduce the resolution? Man, if i'd known i'd have done this sooner

Re: TMI - tgstation mapping initative

Posted: Wed Nov 02, 2016 9:48 pm
by MrStonedOne
if you take a screenshot using byond's screen shot function, it will always be 1:1 pixel arrangement

Re: TMI - tgstation mapping initative

Posted: Wed Nov 02, 2016 10:37 pm
by factoryman942
so uhh
did some messing about
seems 128 view range
doesn't set your view range to 128
http://www.byond.com/forum/?post=1516982
apparently it's capped at 40 or smth
so now i really want to if there's a way to remove that limit
so we could set view range to like 9999
then all we'd need is a supercomputer
and there
maps 100% sorted
:honkman:

Re: TMI - tgstation mapping initative

Posted: Wed Nov 02, 2016 10:56 pm
by Jordie0608
Said limit is built into byond; We can't easily get around it.

Re: TMI - tgstation mapping initative

Posted: Thu Nov 03, 2016 12:14 am
by factoryman942
Can't easily...
so it's possible
maybe?

Re: TMI - tgstation mapping initative

Posted: Thu Nov 03, 2016 7:05 pm
by MrStonedOne
the limit has more to do with directx, so it won't be bypassable. lummox really should expand it to be closer to the limit thou.

Re: TMI - tgstation mapping initative

Posted: Fri Nov 04, 2016 8:35 am
by Mervill
I can help with with this! My progress: http://i.imgur.com/9HVd7kG.png (zoom in)

details to come (it's very late here). I will open source the code!

Re: TMI - tgstation mapping initative

Posted: Fri Nov 04, 2016 2:10 pm
by Atlanta-Ned
Ooh exciting! :D

Re: TMI - tgstation mapping initative

Posted: Wed Nov 16, 2016 6:24 pm
by Atlanta-Ned
vgstation has a map rendering tool. Is it something we can use/port?

Re: TMI - tgstation mapping initative

Posted: Wed Nov 16, 2016 9:52 pm
by Atlanta-Ned
An update:

The render "pipeline" to locate and prepare the maps is working. Hooray! Part of that includes creating a status page/dashboard that will show the status of the various map renders. Neat stuff!

Unfortunately, the ByondTools map rendering script we've been using doesn't work on the tgmap.space server. This is a very resource-intensive process that doesn't handle a low-memory environment very well. So we'll have to figure out an alternative. But progress! :D

Re: TMI - tgstation mapping initative

Posted: Fri Jan 06, 2017 4:48 pm
by Atlanta-Ned
Frankly, I'm offended that no one's mentioned the minimaps used by crew monitors and the fact that they're posted publicly. ಠ_ಠ

Anyway, this might be something we can use, but, again, I don't know the first thing about BYOND and I'd love some help.

Re: TMI - tgstation mapping initative

Posted: Fri Jan 06, 2017 11:00 pm
by XDTM
A shame that they seem to be low-resolution, but someone's gotta have taken them at full-res before making them minimaps. Maybe there's a tool hidden somewhere to do this already?

Re: TMI - tgstation mapping initative

Posted: Sat Jan 07, 2017 4:08 pm
by MrStonedOne
Those are generated by byond code, so they are taken at the low res.

They also crash the server when generated sometimes, so right now they aren't updated.

Also, they only show certain things, wouldn't work for this.

That being said, I could host part(s) of this on our server, or even look at giving you some shell space.