Minimap (work in progress):

- Uses freelook visibility calculations
- all visible turfs represented as a 2x2 square
- - doors, windows, and structural objects that block movement show up in different colours from walls, floors, and space
- - windows and windoors that only block the edge of a tile show as a 1x2 line
- Areas that were visble but now aren't display in red. This will happen during regular activity, as doors open and close, as well as during abnormal circumstances, such as a camera being disabled/destroyed, or additional walls being constructed that block a camera's LOS.
- changes in visibility in an area triggers a map update which takes place two minutes later, reducing amount of processing (since further update triggers are ignored until the pending update has taken place), and give antagonists time after disabling a camera to conduct their business, before the map reveals that anything is out of the ordinary.

Sample screenshot: http://i.imgur.com/PS2vF.png

Todo:
- Remove test verb available to everyone, replace with AI-only (and perhaps avaiable to admins and ghosts?) verb.
- Clicking a tile immediately enters freelook and jumps to that tile
- Perhaps overlay blinking blue for areas with atmosphere alerts, brown for power? Independant of visibility, or centred on APC?
- A verb to force-update the current 3x3 area, while in freelook?
This commit is contained in:
Uristqwerty
2012-05-14 04:04:56 -04:00
parent 2c08c02099
commit bcc3972fbe
3 changed files with 169 additions and 17 deletions
+104 -17
View File
@@ -33,9 +33,79 @@
var/list/turfs = list()
var/list/seenby = list()
var/visible = 0
var/changed = 0
var/changed = 1
var/updating = 0
var/x
var/y
var/z
var/minimap_updating = 0
var/icon/minimap_icon = new('minimap.dmi', "chunk_base")
var/obj/minimap_obj = new()
/mob/verb/minimap_test()
winshow(src, "minimapwindow", 1)
client.screen |= cameranet.minimap
/datum/camerachunk/proc/update_minimap()
if(changed && !updating)
update()
minimap_icon.Blend(rgb(255, 0, 0), ICON_MULTIPLY)
var/list/turfs = visibleTurfs | dimTurfs
for(var/turf/turf in turfs)
var/x = (turf.x & 0xf) * 2
var/y = (turf.y & 0xf) * 2
if(turf.density)
minimap_icon.DrawBox(rgb(100, 100, 100), x + 1, y + 1, x + 2, y + 2)
continue
else if(istype(turf, /turf/space))
minimap_icon.DrawBox(rgb(0, 0, 0), x + 1, y + 1, x + 2, y + 2)
else
minimap_icon.DrawBox(rgb(200, 200, 200), x + 1, y + 1, x + 2, y + 2)
for(var/obj/structure/o in turf)
if(o.density)
if(istype(o, /obj/structure/window) && (o.dir == NORTH || o.dir == SOUTH || o.dir == EAST || o.dir == WEST))
if(o.dir == NORTH)
minimap_icon.DrawBox(rgb(150, 150, 200), x + 1, y + 2, x + 2, y + 2)
else if(o.dir == SOUTH)
minimap_icon.DrawBox(rgb(150, 150, 200), x + 1, y + 1, x + 2, y + 1)
else if(o.dir == EAST)
minimap_icon.DrawBox(rgb(150, 150, 200), x + 3, y + 1, x + 2, y + 2)
else if(o.dir == WEST)
minimap_icon.DrawBox(rgb(150, 150, 200), x + 1, y + 1, x + 1, y + 2)
else
minimap_icon.DrawBox(rgb(150, 150, 150), x + 1, y + 1, x + 2, y + 2)
break
for(var/obj/machinery/door/o in turf)
if(istype(o, /obj/machinery/door/window))
if(o.dir == NORTH)
minimap_icon.DrawBox(rgb(100, 150, 100), x + 1, y + 2, x + 2, y + 2)
else if(o.dir == SOUTH)
minimap_icon.DrawBox(rgb(100, 150, 100), x + 1, y + 1, x + 2, y + 1)
else if(o.dir == EAST)
minimap_icon.DrawBox(rgb(100, 150, 100), x + 2, y + 1, x + 2, y + 2)
else if(o.dir == WEST)
minimap_icon.DrawBox(rgb(100, 150, 100), x + 1, y + 1, x + 1, y + 2)
else
minimap_icon.DrawBox(rgb(100, 150, 100), x + 1, y + 1, x + 2, y + 2)
break
minimap_obj.screen_loc = "minimap:[src.x / 16],[src.y / 16]"
minimap_obj.icon = minimap_icon
/mob/aiEye
var/list/visibleCameraChunks = list()
var/mob/ai = null
@@ -50,6 +120,7 @@
seenby += ai
if(changed && !updating)
update()
changed = 0
/datum/camerachunk/proc/remove(mob/aiEye/ai)
ai.visibleCameraChunks -= src
@@ -76,20 +147,28 @@
else
changed = 1
if(!minimap_updating)
minimap_updating = 1
spawn(1200)
if(changed && !updating)
update()
changed = 0
update_minimap()
minimap_updating = 0
/datum/camerachunk/proc/update()
var/list/newDimTurfs = list()
var/list/newVisibleTurfs = list()
for(var/obj/machinery/camera/c in cameras)
var/lum = c.luminosity
c.luminosity = 7
for(var/turf/t in view(7, c))
if(t in turfs)
newDimTurfs += t
for(var/turf/t in view(6, c))
if(t in turfs)
newVisibleTurfs += t
newDimTurfs |= turfs & view(7, c)
newVisibleTurfs |= turfs & view(6, c)
c.luminosity = lum
@@ -154,29 +233,26 @@
m.ai.client.images += t.obscured
/datum/camerachunk/New(loc, x, y, z)
x &= ~0xf
y &= ~0xf
src.x = x
src.y = y
src.z = z
for(var/obj/machinery/camera/c in range(16, locate(x + 8, y + 8, z)))
if(c.status)
cameras += c
for(var/turf/t in range(10, locate(x + 8, y + 8, z)))
if(t.x >= x && t.y >= y && t.x < x + 16 && t.y < y + 16)
turfs += t
turfs = block(locate(x, y, z), locate(min(world.maxx, x + 15), min(world.maxy, y + 15), z))
for(var/obj/machinery/camera/c in cameras)
var/lum = c.luminosity
c.luminosity = 7
for(var/turf/t in view(7, c))
if(t in turfs)
dimTurfs += t
for(var/turf/t in view(6, c))
if(t in turfs)
visibleTurfs += t
dimTurfs |= turfs & view(7, c)
visibleTurfs |= turfs & view(6, c)
c.luminosity = lum
@@ -197,6 +273,8 @@
dim += t.dim
cameranet.minimap += minimap_obj
var/datum/cameranet/cameranet = new()
/datum/cameranet
@@ -205,9 +283,18 @@ var/datum/cameranet/cameranet = new()
var/network = "net1"
var/ready = 0
var/list/minimap = list()
/datum/cameranet/New()
..()
spawn(200)
for(var/x = 0, x <= world.maxx, x += 16)
for(var/y = 0, y <= world.maxy, y += 16)
sleep(1)
var/datum/camerachunk/c = getCameraChunk(x, y, 1)
c.update_minimap()
/datum/cameranet/proc/chunkGenerated(x, y, z)
var/key = "[x],[y],[z]"
return key in chunks
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

+65
View File
@@ -1207,6 +1207,71 @@ window "mapwindow"
on-show = ".winset\"mainwindow.mainvsplit.left=mapwindow\""
on-hide = ".winset\"mainwindow.mainvsplit.left=\""
window "minimapwindow"
elem "minimapwindow"
type = MAIN
pos = 281,0
size = 640x480
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = false
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "pos;size;is-minimized;is-maximized"
on-size = ""
title = ""
titlebar = true
statusbar = true
can-close = true
can-minimize = true
can-resize = true
is-pane = false
is-minimized = false
is-maximized = false
can-scroll = none
icon = ""
image = ""
image-mode = stretch
keep-aspect = false
transparent-color = none
alpha = 255
macro = ""
menu = ""
on-close = ""
elem "minimap"
type = MAP
pos = 0,0
size = 640x480
anchor1 = 0,0
anchor2 = 100,100
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = true
right-click = false
saved-params = "icon-size"
on-size = ""
icon-size = 32
text-mode = false
on-show = ""
on-hide = ""
window "outputwindow"
elem "outputwindow"
type = MAIN