Adds a new ghost vis blocking area flag (#16696)

* Adds a new ghost vis blocking area flag

* .

* .

* .

* .

* .,

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* some more

* add admin verbs to add and remove areas

* .
This commit is contained in:
Kashargul
2024-12-16 10:02:07 +10:00
committed by GitHub
parent 3343f4e0d0
commit 3083f0b730
35 changed files with 237 additions and 53 deletions
+90
View File
@@ -0,0 +1,90 @@
// GHOST CHUNK
//
// A 16x16 grid of the map with a list of turfs that can be seen, are visible and are dimmed.
// Allows ghosts to see turfs of non AREA_BLOCK_GHOST_SIGHT flagged areas within these chunks.
/datum/chunk/ghost
var/list/hidden_areas = list()
/datum/chunk/ghost/acquireVisibleTurfs(var/list/invisible)
for(var/area/A in hidden_areas)
for(var/turf/T in A.contents)
invisible[T] = T
// Don't call the parernt, we work inverted!
/datum/chunk/ghost/New(loc, x, y, z)
for(var/area/A in range(16, locate(x + 8, y + 8, z)))
if(A.flag_check(AREA_BLOCK_GHOST_SIGHT))
hidden_areas += A
// 0xf = 15
x &= ~0xf
y &= ~0xf
src.x = x
src.y = y
src.z = z
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] = t
acquireVisibleTurfs(obscuredTurfs)
// Removes turf that isn't in turfs.
obscuredTurfs &= turfs
visibleTurfs = turfs - obscuredTurfs
for(var/turf/t as anything in obscuredTurfs)
LAZYINITLIST(t.obfuscations)
if(!t.obfuscations[obfuscation.type])
var/image/ob_image = image(obfuscation.icon, t, obfuscation.icon_state, OBFUSCATION_LAYER)
ob_image.plane = PLANE_FULLSCREEN
t.obfuscations[obfuscation.type] = ob_image
obscured += t.obfuscations[obfuscation.type]
/datum/chunk/ghost/update()
set background = 1
var/list/newInvisibleTurfs = new()
acquireVisibleTurfs(newInvisibleTurfs)
// Removes turf that isn't in turfs.
newInvisibleTurfs &= turfs
var/list/visAdded = obscuredTurfs - newInvisibleTurfs
var/list/visRemoved = newInvisibleTurfs - obscuredTurfs
visibleTurfs = turfs - newInvisibleTurfs
obscuredTurfs = newInvisibleTurfs
for(var/turf/t as anything in visAdded)
if(LAZYLEN(t.obfuscations) && t.obfuscations[obfuscation.type])
obscured -= t.obfuscations[obfuscation.type]
for(var/mob/observer/dead/m as anything in seenby)
if(!m)
continue
var/client/client = m.client
if(client)
client.images -= t.obfuscations[obfuscation.type]
for(var/turf/t as anything in visRemoved)
if(obscuredTurfs[t])
LAZYINITLIST(t.obfuscations)
if(!t.obfuscations[obfuscation.type])
var/image/ob_image = image(obfuscation.icon, t, obfuscation.icon_state, OBFUSCATION_LAYER)
ob_image.plane = PLANE_FULLSCREEN
t.obfuscations[obfuscation.type] = ob_image
obscured += t.obfuscations[obfuscation.type]
for(var/mob/observer/dead/m as anything in seenby)
if(!m)
seenby -= m
continue
var/client/client = m.client
if(client)
client.images += t.obfuscations[obfuscation.type]
@@ -0,0 +1,45 @@
// GHOST NET
//
// The datum containing all the hidden chunks.
/datum/visualnet/ghost
chunk_type = /datum/chunk/ghost
// Removes a area from a chunk.
/datum/visualnet/ghost/proc/removeArea(area/A)
if(!A.flag_check(AREA_BLOCK_GHOST_SIGHT))
majorChunkChange(A, 0)
// Add a area to a chunk.
/datum/visualnet/ghost/proc/addArea(area/A)
if(A.flag_check(AREA_BLOCK_GHOST_SIGHT))
majorChunkChange(A, 1)
// Used for ghost visible areas. Since portable areas can be in ANY chunk.
/datum/visualnet/ghost/proc/updateArea(area/A)
if(A.flag_check(AREA_BLOCK_GHOST_SIGHT))
majorChunkChange(A, 1)
else
majorChunkChange(A, 0)
/datum/visualnet/ghost/majorChunkChange(area/A, var/choice)
for(var/entry in chunks)
var/datum/chunk/ghost/gchunk = chunks[entry]
for(var/turf/T in gchunk.turfs)
if(T.loc == A)
onMajorChunkChange(A, choice, gchunk)
gchunk.hasChanged(TRUE)
break
/datum/visualnet/ghost/onMajorChunkChange(atom/c, var/choice, var/datum/chunk/ghost/chunk)
// Only add actual areas to the list of areas
if(istype(c, /area))
if(choice == 0)
// Remove the area.
chunk.hidden_areas -= c
else if(choice == 1)
// You can't have the same area in the list twice.
chunk.hidden_areas |= c
+12 -1
View File
@@ -13,6 +13,9 @@
canmove = 0
blinded = 0
anchored = TRUE // don't get pushed around
var/list/visibleChunks = list()
var/datum/visualnet/visualnet
var/use_static = TRUE
var/can_reenter_corpse
var/datum/hud/living/carbon/hud = null // hud
@@ -140,6 +143,13 @@
animate(pixel_y = default_pixel_y, time = 10, loop = -1)
observer_mob_list += src
..()
visualnet = ghostnet
/mob/observer/dead/Moved(atom/old_loc, direction, forced)
. = ..()
use_static = !(check_rights(R_ADMIN|R_FUN|R_EVENT|R_SERVER, 0, src) || (client && client.buildmode))
if(visualnet && use_static)
visualnet.visibility(src, client)
/mob/observer/dead/Topic(href, href_list)
if (href_list["track"])
@@ -452,7 +462,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
//RS Port #658 Start
var/area/A = get_area(destination)
if(A.flag_check(AREA_BLOCK_GHOSTS))
if(A?.flag_check(AREA_BLOCK_GHOSTS))
to_chat(src,span_warning("Sorry, that area does not allow ghosts."))
if(following)
stop_following()
@@ -572,6 +582,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return ..()
/mob/observer/dead/Destroy()
visualnet = null
if(ismob(following))
var/mob/M = following
M.following_mobs -= src
+1 -1
View File
@@ -24,7 +24,7 @@
/mob/verb/toggle_stomach_vision()
set name = "Toggle Stomach Sprites"
set category = "Preferences"
set category = "Preferences.Vore"
set desc = "Toggle the ability to see stomachs or not"
var/toggle
+1 -1
View File
@@ -350,9 +350,9 @@
switch(mob.incorporeal_move)
if(1)
var/turf/T = get_step(mob, direct)
var/area/A = T.loc //RS Port #658
if(!T)
return
var/area/A = T.loc //RS Port #658
if(mob.check_holy(T))
to_chat(mob, span_warning("You cannot get past holy grounds while you are in this plane of existence!"))
return