Cleanups and tweaks observer code (#30250)

* observer cleanup

* this

* bit more

* Update tgui.bundle.js
This commit is contained in:
kyunkyunkyun
2025-09-05 05:54:22 +00:00
committed by GitHub
parent 8f98876b47
commit 10f2e67e65
66 changed files with 362 additions and 447 deletions
+213 -297
View File
@@ -1,119 +1,90 @@
#define GHOST_CAN_REENTER 1
#define GHOST_IS_OBSERVER 2
GLOBAL_LIST_EMPTY(ghost_images)
GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
GLOBAL_DATUM_INIT(ghost_crew_monitor, /datum/ui_module/crew_monitor/ghost, new)
/mob/dead/observer
name = "ghost"
desc = "It's a g-g-g-g-ghooooost!" //jinkies!
desc = "It's a g-g-g-g-ghooooost!" // jinkies!
icon = 'icons/mob/mob.dmi'
icon_state = "ghost"
layer = GHOST_LAYER
stat = DEAD
density = FALSE
alpha = 127
invisibility = INVISIBILITY_OBSERVER
see_in_dark = 100
sight = SEE_TURFS | SEE_MOBS | SEE_OBJS | SEE_SELF
blocks_emissive = FALSE // Ghosts are transparent, duh
hud_type = /datum/hud/ghost
speaks_ooc = TRUE
var/can_reenter_corpse
var/bootime = FALSE
var/started_as_observer //This variable is set to 1 when you enter the game as an observer.
//If you died in the game and are a ghsot - this will remain as null.
//Note that this is not a reliable way to determine if admins started as observers, since they change mobs a lot.
universal_speak = TRUE
var/image/ghostimage = null //this mobs ghost image, for deleting and stuff
var/ghostvision = TRUE //is the ghost able to see things humans can't?
var/seedarkness = TRUE
var/seerads = FALSE // can the ghost see radiation?
/// Defines from __DEFINES/hud.dm go here based on which huds the ghost has activated.
var/list/data_hud_seen = list()
/// Shape we orbit in. Other values are unused currently..
var/ghost_orbit = GHOST_ORBIT_CIRCLE
var/health_scan = FALSE //does the ghost have health scanner mode on? by default it should be off
///toggle for ghost gas analyzer
var/gas_scan = FALSE
///toggle for ghost plant analyzer
var/plant_analyzer = FALSE
/// The "color" their runechat would have had
var/alive_runechat_color = "#FFFFFF"
/// UID of the mob which we are currently observing
var/mob_observed
/// Ghost flags. Being set on Initialize
var/ghost_flags
/mob/dead/observer/New(mob/body=null, flags=1)
/mob/dead/observer/Initialize(mapload, flags = GHOST_FLAGS_DEFAULT)
set_stat(DEAD)
set_invisibility(GLOB.observer_default_invisibility)
sight |= SEE_TURFS | SEE_MOBS | SEE_OBJS | SEE_SELF
see_invisible = SEE_INVISIBLE_OBSERVER_AI_EYE
see_in_dark = 100
add_verb(src, list(
/mob/dead/observer/proc/dead_tele,
/mob/dead/observer/proc/jump_to_ruin,
/mob/dead/observer/proc/open_spawners_menu))
/mob/dead/observer/proc/open_spawners_menu,
))
// Our new boo spell.
AddSpell(new /datum/spell/boo(null))
can_reenter_corpse = flags & GHOST_CAN_REENTER
started_as_observer = flags & GHOST_IS_OBSERVER
set_stat(DEAD)
var/turf/T
if(ismob(body))
T = get_turf(body) //Where is the body located?
attack_log_old = body.attack_log_old //preserve our attack logs by copying them to our ghost
var/turf/location
var/mob/body = loc
if(istype(body))
location = get_turf(body) // Where is the body located?
attack_log_old = body.attack_log_old // preserve our attack logs by copying them to our ghost
mind = body.mind // we don't transfer the mind but we keep a reference to it.
alive_runechat_color = body.get_runechat_color()
toggle_all_huds_on(body)
var/mutable_appearance/MA = copy_appearance(body)
if(body.mind && body.mind.name)
MA.name = body.mind.name
var/mutable_appearance/new_appearance = copy_appearance(body)
if(mind?.name)
new_appearance.name = mind.name
else if(body.real_name)
MA.name = body.real_name
new_appearance.name = body.real_name
else
if(gender == MALE)
MA.name = capitalize(pick(GLOB.first_names_male)) + " " + capitalize(pick(GLOB.last_names))
new_appearance.name = capitalize(pick(GLOB.first_names_male)) + " " + capitalize(pick(GLOB.last_names))
else
MA.name = capitalize(pick(GLOB.first_names_female)) + " " + capitalize(pick(GLOB.last_names))
new_appearance.name = capitalize(pick(GLOB.first_names_female)) + " " + capitalize(pick(GLOB.last_names))
mind = body.mind //we don't transfer the mind but we keep a reference to it.
appearance = MA
appearance = new_appearance
ghostimage = image(icon = icon, loc = src, icon_state = icon_state)
ghostimage.overlays = overlays
ghostimage.dir = dir
ghostimage.appearance_flags |= KEEP_TOGETHER
ghostimage.alpha = alpha
appearance_flags |= KEEP_TOGETHER
GLOB.ghost_images |= ghostimage
updateallghostimages()
if(!T)
T = pick(GLOB.latejoin) //Safety in case we cannot find the body's position
forceMove(T)
if(!location)
location = pick(GLOB.latejoin) // Safety in case we cannot find the body's position
abstract_move(location)
if(!name) //To prevent nameless ghosts
RegisterSignal(src, COMSIG_MOB_HUD_CREATED, PROC_REF(set_ghost_darkness_level)) // something something don't call this until we have a HUD
. = ..()
if(!name) // To prevent nameless ghosts
name = capitalize(pick(GLOB.first_names_male)) + " " + capitalize(pick(GLOB.last_names))
real_name = name
//starts ghosts off with all HUDs.
toggle_all_huds_on(body)
RegisterSignal(src, COMSIG_MOB_HUD_CREATED, PROC_REF(set_ghost_darkness_level)) //something something don't call this until we have a HUD
..()
plane = GAME_PLANE
add_observer_verbs()
ADD_TRAIT(src, TRAIT_RESPAWNABLE, GHOSTED)
ghost_flags = flags
if(ghost_flags & GHOST_RESPAWNABLE)
ADD_TRAIT(src, TRAIT_RESPAWNABLE, GHOSTED)
else
GLOB.non_respawnable_keys[ckey] = TRUE
// Our new boo spell.
AddSpell(new /datum/spell/boo)
/mob/dead/observer/Destroy()
toggle_all_huds_off()
UnregisterSignal(src, COMSIG_MOB_HUD_CREATED)
if(ghostimage)
GLOB.ghost_images -= ghostimage
QDEL_NULL(ghostimage)
updateallghostimages()
if(seerads)
if(ghost_flags & GHOST_SEE_RADS)
STOP_PROCESSING(SSobj, src)
remove_observer_verbs()
if(mob_observed)
@@ -126,8 +97,7 @@ GLOBAL_DATUM_INIT(ghost_crew_monitor, /datum/ui_module/crew_monitor/ghost, new)
. += "It seems extremely obvious."
/mob/dead/observer/process()
if(seerads)
show_rads(5)
show_rads(5)
/mob/dead/observer/proc/set_ghost_darkness_level()
if(!client)
@@ -140,78 +110,61 @@ GLOBAL_DATUM_INIT(ghost_crew_monitor, /datum/ui_module/crew_monitor/ghost, new)
// Copying an appearance directly from a mob includes it's verb list, it's invisibility, it's alpha, and it's density
// You might recognize these things as "fucking ridiculous to put in an appearance"
// You'd be right, but that's fucking BYOND for you.
/mob/dead/observer/proc/copy_appearance(mutable_appearance/COPY)
var/mutable_appearance/MA = new(src)
/mob/dead/observer/proc/copy_appearance(mutable_appearance/copy_from)
var/mutable_appearance/appearance = new(src)
MA.appearance_flags = COPY.appearance_flags
MA.blend_mode = COPY.blend_mode
MA.color = COPY.color
MA.dir = COPY.dir
MA.icon = COPY.icon
MA.icon_state = COPY.icon_state
MA.layer = COPY.layer
MA.maptext = COPY.maptext
MA.maptext_width = COPY.maptext_width
MA.maptext_height = COPY.maptext_height
MA.maptext_x = COPY.maptext_x
MA.maptext_y = COPY.maptext_y
MA.mouse_opacity = COPY.mouse_opacity
MA.overlays = COPY.overlays
if(!isicon(MA.icon) && !LAZYLEN(MA.overlays)) // Gibbing/dusting/melting removes the icon before ghostize()ing the mob, so we need to account for that
MA.icon = initial(icon)
MA.icon_state = initial(icon_state)
MA.underlays = COPY.underlays
MA.layer = GHOST_LAYER
MA.plane = GAME_PLANE
. = MA
appearance.appearance_flags = copy_from.appearance_flags
appearance.blend_mode = copy_from.blend_mode
appearance.color = copy_from.color
appearance.dir = copy_from.dir
appearance.icon = copy_from.icon
appearance.icon_state = copy_from.icon_state
appearance.overlays = copy_from.overlays
if(!isicon(appearance.icon) && !LAZYLEN(appearance.overlays)) // Gibbing/dusting/melting removes the icon before ghostize()ing the mob, so we need to account for that
appearance.icon = initial(icon)
appearance.icon_state = initial(icon_state)
appearance.maptext = copy_from.maptext
appearance.maptext_width = copy_from.maptext_width
appearance.maptext_height = copy_from.maptext_height
appearance.maptext_x = copy_from.maptext_x
appearance.maptext_y = copy_from.maptext_y
appearance.mouse_opacity = copy_from.mouse_opacity
appearance.underlays = copy_from.underlays
appearance.layer = GHOST_LAYER
appearance.plane = GAME_PLANE
return appearance
/mob/dead/CanPass(atom/movable/mover, border_dir)
return 1
return TRUE
/*
Transfer_mind is there to check if mob is being deleted/not going to have a body.
Works together with spawning an observer, noted above.
*/
/mob/dead/proc/assess_targets(list/target_list, mob/dead/observer/U)
var/client/C = U.client
for(var/mob/living/carbon/human/target in target_list)
C.images += target.hud_list[SPECIALROLE_HUD]
for(var/mob/living/silicon/target in target_list)
C.images += target.hud_list[SPECIALROLE_HUD]
return 1
/mob/proc/ghostize(flags = GHOST_CAN_REENTER, user_color, ghost_name)
/mob/proc/ghostize(flags = GHOST_FLAGS_DEFAULT, ghost_name, ghost_color)
if(!key)
return
if(player_logged) // if they have disconnected we want to remove their SSD overlay
overlays -= image('icons/effects/effects.dmi', icon_state = "zzz_glow")
if(GLOB.non_respawnable_keys[ckey])
flags &= ~GHOST_CAN_REENTER
var/mob/dead/observer/ghost = new(src, flags) // Transfer safety to observer spawning proc.
ghost.timeofdeath = src.timeofdeath // BS12 EDIT
if(ghost.can_reenter_corpse)
ADD_TRAIT(ghost, TRAIT_RESPAWNABLE, GHOSTED)
else
GLOB.non_respawnable_keys[ckey] = 1
// mods, mentors, and the like will have admin observe anyway, so this is moot
if(((key in GLOB.antag_hud_users) || (key in GLOB.roundstart_observer_keys)) && !check_rights(R_MOD | R_ADMIN | R_MENTOR, FALSE, src))
ghost.verbs |= /mob/dead/observer/proc/do_observe
ghost.verbs |= /mob/dead/observer/proc/observe
if(user_color)
add_atom_colour(user_color, ADMIN_COLOUR_PRIORITY)
ghost.color = user_color
if(ghost_color)
add_atom_colour(ghost_color, ADMIN_COLOUR_PRIORITY)
ghost.color = ghost_color
if(ghost_name)
ghost.name = ghost_name
ghost.key = key
ghost.timeofdeath = src.timeofdeath
ghost.key = key
ghost.client?.init_verbs()
for(var/mob/dead/observer/obs in observers)
for(var/mob/dead/observer/obs as anything in observers)
obs.cleanup_observe()
return ghost
/*
@@ -233,17 +186,16 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(HAS_TRAIT(M, TRAIT_RESPAWNABLE))
if(isdrone(M))//We do not punish maint drones for leaving early, *but* we don't want them ghosting, finding damage, respawning / rentering over and over.
var/mob/dead/observer/ghost = ghostize(TRUE) // Keep them respawnable
ghost.can_reenter_corpse = FALSE // but keep them out of their old body
var/mob/dead/observer/ghost = ghostize(GHOST_FLAGS_NO_REENTER)
ghost.timeofdeath = world.time // Because the living mob won't have a time of death and we want the respawn timer to work properly.
return
ghostize(TRUE)
ghostize()
return
if(isbrain(M))
// let a brain ghost out if they want to, but also let them freely re-enter their brain.
var/response = tgui_alert(src, "Ghosting from this brain means you'll be respawnable but will be kicked out of your brain, which someone else could take over. Is this what you want?", "Ghost", list("Stay in Brain", "Ghost"))
if(response == "Ghost")
ghostize(TRUE)
ghostize()
log_admin("[key_name(M)] has ghosted as a brain-mob, but is keeping respawnability.")
return
if(P)
@@ -273,11 +225,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(warningmsg)
// Not respawnable
var/mob/dead/observer/ghost = ghostize(FALSE) // FALSE parameter stops them re-entering their body
var/mob/dead/observer/ghost = ghostize(GHOST_FLAGS_OBSERVE_ONLY)
ghost.timeofdeath = world.time // Because the living mob won't have a time of death and we want the respawn timer to work properly.
else
// Respawnable
ghostize(TRUE)
ghostize()
// If mob in cryopod, despawn mob
if(P)
@@ -289,27 +241,39 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
// Ghosts have no momentum, being massless ectoplasm
/mob/dead/observer/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
return 1
return TRUE
/mob/dead/observer/Move(NewLoc, direct)
update_parallax_contents()
/mob/dead/observer/Move(atom/newloc, direct = 0, glide_size_override = 0, update_dir = TRUE, momentum_change = TRUE)
setDir(direct)
ghostimage.dir = dir
if(NewLoc)
forceMove(NewLoc, direct)
if(glide_size_override)
set_glide_size(glide_size_override)
if(newloc)
abstract_move(newloc)
else
forceMove(get_turf(src), direct) //Get out of closets and such as a ghost
if((direct & NORTH) && y < world.maxy)
y++
else if((direct & SOUTH) && y > 1)
y--
if((direct & EAST) && x < world.maxx)
x++
else if((direct & WEST) && x > 1)
x--
var/turf/destination = get_turf(src)
/mob/dead/observer/can_use_hands() return 0
if((direct & NORTH) && y < world.maxy)
destination = get_step(destination, NORTH)
else if((direct & SOUTH) && y > 1)
destination = get_step(destination, SOUTH)
if((direct & EAST) && x < world.maxx)
destination = get_step(destination, EAST)
else if((direct & WEST) && x > 1)
destination = get_step(destination, WEST)
abstract_move(destination) // Get out of closets and such as a ghost
/mob/dead/observer/forceMove(atom/destination)
abstract_move(destination) // move like the wind
return TRUE
/mob/dead/observer/can_use_hands()
return FALSE
/mob/dead/observer/get_status_tab_items()
var/list/status_tab_data = ..()
@@ -319,15 +283,16 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/verb/reenter_corpse()
set category = "Ghost"
set name = "Re-enter Corpse"
if(!client)
return
if(!mind || QDELETED(mind.current))
to_chat(src, "<span class='warning'>You have no body.</span>")
return
if(!can_reenter_corpse)
if(!(ghost_flags & GHOST_CAN_REENTER))
to_chat(src, "<span class='warning'>You cannot re-enter your body.</span>")
return
if(mind.current.key && copytext(mind.current.key,1,2)!="@") //makes sure we don't accidentally kick any clients
if(mind.current.key && copytext(mind.current.key, 1, 2) != "@") // makes sure we don't accidentally kick any clients
to_chat(usr, "<span class='warning'>Another consciousness is in your body...It is resisting you.</span>")
return
@@ -335,14 +300,13 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
SEND_SIGNAL(mind.current, COMSIG_LIVING_REENTERED_BODY)
return 1
return TRUE
/mob/dead/observer/proc/notify_cloning(message, sound, atom/source)
if(message)
to_chat(src, "<span class='ghostalert'>[message]</span>")
if(source)
var/atom/movable/screen/alert/A = throw_alert("\ref[source]_notify_cloning", /atom/movable/screen/alert/notify_cloning)
var/atom/movable/screen/alert/A = throw_alert("[source.UID()]_notify_cloning", /atom/movable/screen/alert/notify_cloning)
if(A)
if(client && client.prefs && client.prefs.UI_style)
A.icon = ui_style2icon(client.prefs.UI_style)
@@ -351,7 +315,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
var/old_plane = source.plane
source.layer = FLOAT_LAYER
source.plane = FLOAT_PLANE
A.overlays += source
A.add_overlay(source)
source.layer = old_layer
source.plane = old_plane
to_chat(src, "<span class='ghostalert'><a href=byond://?src=[UID()];reenter=1>(Click to re-enter)</a></span>")
@@ -363,7 +327,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
H.add_hud_to(src)
data_hud_seen |= hud_index
/mob/dead/observer/proc/remove_the_hud(hud_index) //remove old huds
// remove old huds
/mob/dead/observer/proc/remove_the_hud(hud_index)
var/datum/atom_hud/H = GLOB.huds[hud_index]
H.remove_hud_from(src)
data_hud_seen -= hud_index
@@ -371,8 +336,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/verb/open_hud_panel()
set category = "Ghost"
set name = "Ghost HUD Panel"
if(!client)
return
GLOB.ghost_hud_panel.ui_interact(src)
/**
@@ -390,10 +357,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
show_me_the_hud(DATA_HUD_MALF_AI)
if(!check_rights((R_ADMIN | R_MOD), FALSE, user))
return
antagHUD = TRUE
GLOB.antag_hud_users |= user.ckey
for(var/datum/atom_hud/antag/H in GLOB.huds)
H.add_hud_to(src)
for(var/datum/atom_hud/antag/hud in GLOB.huds)
hud.add_hud_to(src)
/**
* Toggles off all HUDs for the ghost player.
@@ -407,12 +375,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
for(var/datum/atom_hud/antag/H in GLOB.huds)
H.remove_hud_from(src)
/mob/dead/observer/proc/set_radiation_view(enabled)
if(enabled)
seerads = TRUE
/mob/dead/observer/proc/toggle_rad_view()
ghost_flags ^= GHOST_SEE_RADS
if(ghost_flags & GHOST_SEE_RADS)
START_PROCESSING(SSobj, src)
else
seerads = FALSE
STOP_PROCESSING(SSobj, src)
/mob/dead/observer/verb/set_dnr()
@@ -422,7 +389,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(!isobserver(src)) // Somehow
return
if(!can_reenter_corpse)
if(!(ghost_flags & GHOST_CAN_REENTER))
to_chat(src, "<span class='warning'>You are already set to DNR!</span>")
return
if(!mind || QDELETED(mind.current))
@@ -432,11 +399,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
to_chat(src, "<span class='warning'>Your body is still alive!</span>")
return
var/choice = tgui_alert(src, "If you enable this, your body will be unrevivable for the remainder of the round.", "Do Not Revive!", list("Yes", "No"))
if(choice == "Yes")
if(tgui_alert(src, "If you enable this, your body will be unrevivable for the remainder of the round.", "Do Not Revive!", list("Yes", "No")) == "Yes")
to_chat(src, "<span class='boldnotice'>Do Not Revive state enabled.</span>")
create_log(MISC_LOG, "DNR Enabled")
can_reenter_corpse = FALSE
ghost_flags &= ~GHOST_CAN_REENTER
if(!QDELETED(mind.current)) // Could change while they're choosing
mind.current.remove_status_effect(STATUS_EFFECT_REVIVABLE)
SEND_SIGNAL(mind.current, COMSIG_LIVING_SET_DNR)
@@ -446,10 +412,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set name = "Teleport"
set desc= "Teleport to a location"
if(!isobserver(usr))
to_chat(usr, "Not when you're not dead!")
if(!isobserver(src))
to_chat(src, "Not when you're not dead!")
return
var/target = tgui_input_list(usr, "Area to teleport to", "Teleport to a location", SSmapping.ghostteleportlocs)
var/target = tgui_input_list(src, "Area to teleport to", "Teleport to a location", SSmapping.ghostteleportlocs)
teleport(SSmapping.ghostteleportlocs[target])
/mob/dead/observer/proc/jump_to_ruin()
@@ -481,7 +448,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
var/obj/effect/landmark/ruin/landmark = names[ruinname]
if(istype(landmark))
forceMove(get_turf(landmark))
abstract_move(get_turf(landmark))
update_parallax_contents()
var/list/messages = list(
@@ -501,7 +468,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(!length(turfs))
to_chat(src, "<span class='warning'>Nowhere to jump to!</span>")
return
forceMove(pick(turfs))
abstract_move(pick(turfs))
update_parallax_contents()
/mob/dead/observer/verb/follow()
@@ -520,20 +487,20 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/proc/add_observer_verbs()
verbs.Add(
/mob/dead/observer/proc/ManualFollow,
/mob/dead/observer/proc/manual_follow,
)
/mob/dead/observer/proc/remove_observer_verbs()
verbs.Remove(
/mob/dead/observer/proc/ManualFollow,
/mob/dead/observer/proc/manual_follow,
// these might not necessarily be here, but we want to make sure they're gonezo anyway
/mob/dead/observer/proc/observe,
/mob/dead/observer/proc/do_observe
)
// This is the ghost's follow verb with an argument.
// We need to do the usr check on this verb itself, but the logic follows.
/mob/dead/observer/proc/ManualFollow(atom/movable/target)
// We need to do the src check on this verb itself, but the logic follows.
/mob/dead/observer/proc/manual_follow(atom/movable/target)
set name = "\[Observer\] Orbit"
set desc = "Orbits the specified movable atom."
set category = null
@@ -555,14 +522,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(src in target.get_orbiters())
return
var/icon/I = icon(target.icon, target.icon_state, target.dir)
var/orbitsize = (I.Width() + I.Height())*0.5
var/list/icon_dimensions = get_icon_dimensions(target.icon)
var/orbitsize = (icon_dimensions["width"] + icon_dimensions["height"]) * 0.5
if(orbitsize == 0)
orbitsize = 40
orbitsize -= (orbitsize/world.icon_size)*(world.icon_size*0.25)
orbitsize -= (orbitsize / world.icon_size) * (world.icon_size * 0.25)
var/rot_seg
@@ -579,30 +543,18 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
rot_seg = 36 // 360/10 bby, smooth enough aproximation of a circle
to_chat(src, "<span class='notice'>Now following [target].</span>")
orbit(target, orbitsize, FALSE, 20, rot_seg)
orbit(A = target, radius = orbitsize, rotation_segments = rot_seg)
/mob/dead/observer/orbit(atom/A, radius = 10, clockwise = FALSE, rotation_speed = 20, rotation_segments = 36, pre_rotation = TRUE, lock_in_orbit = FALSE, force_move = FALSE, orbit_layer = GHOST_LAYER)
setDir(2)//reset dir so the right directional sprites show up
setDir(SOUTH) // reset dir so the right directional sprites show up
return ..()
/mob/dead/observer/proc/jump_to_mob(mob/M)
if(!M || !isobserver(usr))
return
var/mob/A = src //Source mob
var/turf/T = get_turf(M) //Turf of the destination mob
if(T && isturf(T)) //Make sure the turf exists, then move the source to that destination.
A.forceMove(T)
M.update_parallax_contents()
return
to_chat(A, "This mob is not located in the game world.")
/mob/dead/observer/memory()
set hidden = 1
set hidden = TRUE
to_chat(src, "<span class='warning'>You are dead! You have no mind to store memory!</span>")
/mob/dead/observer/add_memory()
set hidden = 1
set hidden = TRUE
to_chat(src, "<span class='warning'>You are dead! You have no mind to store memory!</span>")
/mob/dead/observer/verb/toggle_health_scan()
@@ -610,44 +562,35 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set desc = "Toggles whether you health-scan living beings on click"
set category = "Ghost"
if(health_scan) //remove old huds
to_chat(src, "<span class='notice'>Health scan disabled.</span>")
health_scan = FALSE
else
to_chat(src, "<span class='notice'>Health scan enabled.</span>")
health_scan = TRUE
ghost_flags ^= GHOST_GAS_SCAN
to_chat(src, "<span class='notice'>Gas scan [ghost_flags & GHOST_GAS_SCAN ? "en" : "dis"]abled.</span>")
/mob/dead/observer/verb/toggle_gas_scan()
set name = "Toggle Gas Scan"
set desc = "Toggles whether you analyze gas contents on click"
set category = "Ghost"
gas_scan = !gas_scan
if(gas_scan)
to_chat(src, "<span class='notice'>Gas scan enabled.</span>")
else
to_chat(src, "<span class='notice'>Gas scan disabled.</span>")
ghost_flags ^= GHOST_GAS_SCAN
to_chat(src, "<span class='notice'>Gas scan [ghost_flags & GHOST_GAS_SCAN ? "en" : "dis"]abled.</span>")
/mob/dead/observer/verb/toggle_plant_anaylzer()
set name = "Toggle Plant Analyzer"
set desc = "Toggles wether you can anaylze plants and seeds on click"
set category = "Ghost"
if(plant_analyzer)
to_chat(src, "<span class='notice'>Plant Analyzer disabled.</span>")
plant_analyzer = FALSE
else
to_chat(src, "<span class='notice'>Plant Analyzer enabled. Click on a plant or seed to analyze.</span>")
plant_analyzer = TRUE
ghost_flags ^= GHOST_PLANT_ANALYZER
to_chat(src, "<span class='notice'>Plant Analyzer [ghost_flags & GHOST_PLANT_ANALYZER ? "en" : "dis"]abled.</span>")
/mob/dead/observer/verb/view_manifest()
set name = "View Crew Manifest"
set category = "Ghost"
GLOB.generic_crew_manifest.ui_interact(usr)
//this is called when a ghost is drag clicked to something.
// this is called when a ghost is drag clicked to something.
/mob/dead/observer/MouseDrop(atom/over)
if(!usr || !over) return
if(!usr || !over)
return
if(isobserver(usr) && usr.client && usr.client.holder)
if(usr.client.holder.cmd_ghost_drag(src,over))
return
@@ -655,7 +598,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return ..()
/proc/ghost_follow_link(atom/target, atom/ghost)
if((!target) || (!ghost)) return
if(!istype(target) || !istype(ghost))
return
if(is_ai(target)) // AI core/eye follow links
var/mob/living/silicon/ai/A = target
. = "<a href='byond://?src=[ghost.UID()];follow=[A.UID()]'>core</a>"
@@ -671,117 +615,95 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
else
return "<a href='byond://?src=[ghost.UID()];follow=[target.UID()]'>follow</a>"
//BEGIN TELEPORT HREF CODE
/mob/dead/observer/Topic(href, href_list)
if(usr != src)
return
if(href_list["track"])
var/atom/target = locate(href_list["track"])
if(target)
ManualFollow(target)
manual_follow(target)
if(href_list["follow"])
var/atom/target = locate(href_list["follow"])
if(target)
ManualFollow(target)
manual_follow(target)
if(href_list["jump"])
var/mob/target = locate(href_list["jump"])
var/mob/A = usr
to_chat(A, "Teleporting to [target]...")
//var/mob/living/silicon/ai/A = locate(href_list["track2"]) in GLOB.mob_list
if(target && target != usr)
spawn(0)
var/turf/pos = get_turf(A)
var/turf/T=get_turf(target)
if(T != pos)
if(!T)
return
if(!client)
return
forceMove(T)
to_chat(src, "Teleporting to [target]...")
if(target != usr)
var/turf/source_turf = get_turf(src)
var/turf/target_turf = get_turf(target)
if(source_turf != target_turf)
if(!target_turf)
return
if(!client)
return
abstract_move(target_turf)
if(href_list["reenter"])
reenter_corpse()
..()
//END TELEPORT HREF CODE
return ..()
/mob/dead/observer/verb/toggle_ghostsee()
set name = "Toggle Ghost Vision"
set desc = "Toggles your ability to see things only ghosts can see, like other ghosts"
set category = "Ghost"
ghostvision = !(ghostvision)
update_sight()
to_chat(usr, "You [(ghostvision?"now":"no longer")] have ghost vision.")
/mob/dead/observer/verb/pick_darkness(desired_dark as num)
ghost_flags ^= GHOST_VISION
update_sight()
to_chat(src, "<span class='notice'>Ghost vision [ghost_flags & GHOST_VISION ? "en" : "dis"]abled.</span>")
/mob/dead/observer/verb/pick_darkness()
set name = "Pick Darkness"
set desc = "Choose how much darkness you want to see, (0 - 255). Higher numbers being darker."
set category = "Ghost"
if(isnull(desired_dark))
return
if(!client)
return
client.prefs.ghost_darkness_level = clamp(desired_dark, 0, 255)
var/darkness_level = tgui_input_list(src, "Choose your darkness", "Pick Darkness", list("Darkness", "Twilight", "Brightness", "Custom"))
if(!darkness_level)
return
var/new_darkness
switch(darkness_level)
if("Darkness")
new_darkness = LIGHTING_PLANE_ALPHA_VISIBLE
if("Twilight")
new_darkness = 210
if("Brightness")
new_darkness = LIGHTING_PLANE_ALPHA_INVISIBLE
if("Custom")
new_darkness = tgui_input_number(src, "Choose how much darkness you want to see (0 - 255). Higher numbers being darker", "Pick Darkness", lighting_alpha, LIGHTING_PLANE_ALPHA_VISIBLE, LIGHTING_PLANE_ALPHA_INVISIBLE)
if(isnull(new_darkness))
return
client.prefs.ghost_darkness_level = new_darkness
client.prefs.save_preferences(src)
lighting_alpha = client.prefs.ghost_darkness_level
update_sight()
/mob/dead/observer/update_sight()
if(!ghostvision)
see_invisible = SEE_INVISIBLE_LIVING
else
see_invisible = SEE_INVISIBLE_OBSERVER
see_invisible = ghost_flags & GHOST_VISION ? SEE_INVISIBLE_OBSERVER : SEE_INVISIBLE_OBSERVER_NO_OBSERVERS
return ..()
updateghostimages()
. = ..()
/mob/dead/observer/proc/updateghostsight()
if(!seedarkness)
see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING
else
see_invisible = SEE_INVISIBLE_OBSERVER
if(!ghostvision)
see_invisible = SEE_INVISIBLE_LIVING
updateghostimages()
/mob/dead/observer/advanced_reagent_vision() // Ghosts can see all the reagents inside things.
// Ghosts can see all the reagents inside things.
/mob/dead/observer/advanced_reagent_vision()
return TRUE
/proc/updateallghostimages()
for(var/mob/dead/observer/O in GLOB.player_list)
O.updateghostimages()
/mob/dead/observer/proc/updateghostimages()
if(!client)
return
if(seedarkness || !ghostvision)
client.images -= GLOB.ghost_images
else
//add images for the 60inv things ghosts can normally see when darkness is enabled so they can see them now
client.images |= GLOB.ghost_images
if(ghostimage)
client.images -= ghostimage //remove ourself
/mob/proc/can_admin_interact()
return FALSE
/mob/dead/observer/can_admin_interact()
return check_rights(R_ADMIN, FALSE, src)
/mob/proc/can_advanced_admin_interact()
return FALSE
/mob/dead/observer/can_admin_interact()
return check_rights(R_ADMIN, 0, src)
/mob/dead/observer/can_advanced_admin_interact()
if(!can_admin_interact())
return FALSE
if(client && client.advanced_admin_interaction)
return TRUE
return FALSE
return client?.advanced_admin_interaction && can_admin_interact()
/mob/dead/observer/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE)
return TRUE
@@ -789,13 +711,13 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
//this is a mob verb instead of atom for performance reasons
//see /mob/verb/examinate() in mob.dm for more info
//overriden here and in /mob/living for different point span classes and sanity checks
/mob/dead/observer/run_pointed(atom/A as mob|obj|turf in view())
/mob/dead/observer/run_pointed(atom/A)
if(!..())
return FALSE
for(var/mob/M in range(7, src))
if(M.see_invisible < invisibility)
continue //can't view the invisible
continue // can't view the invisible
var/follow_link
if(invisibility) // Only show the button if the ghost is not visible to the living
follow_link = " ([ghost_follow_link(A, M)])" // Ghost needs to be link clicker, otherwise it breaks
@@ -803,7 +725,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return TRUE
/mob/dead/observer/proc/incarnate_ghost(datum/mind/from_mind = null)
/mob/dead/observer/proc/incarnate_ghost(datum/mind/from_mind)
if(!client)
return
@@ -834,11 +756,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(var_name == "invisibility")
set_invisibility(invisibility) // updates light
/proc/set_observer_default_invisibility(amount, message=null)
for(var/mob/dead/observer/G in GLOB.player_list)
G.set_invisibility(amount)
/proc/set_observer_default_invisibility(amount, message)
for(var/mob/dead/observer/ghost in GLOB.dead_mob_list)
ghost.set_invisibility(amount)
if(message)
to_chat(G, message)
to_chat(ghost, message)
GLOB.observer_default_invisibility = amount
/mob/dead/observer/proc/open_spawners_menu()
@@ -846,8 +768,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set desc = "See all currently available ghost spawners"
set category = "Ghost"
var/datum/spawners_menu/menu = new /datum/spawners_menu(src)
menu.ui_interact(src)
GLOB.ghost_spawners_menu.ui_interact(src)
/**
* Check if a player has antag-hudded, and if so, if they can rejoin.
@@ -865,7 +786,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return allow_roundstart_observers
return FALSE
/mob/dead/observer/get_runechat_color()
return alive_runechat_color
@@ -929,7 +849,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
mob_eye.hud_used?.show_hud(mob_eye.hud_used.hud_version, src)
mob_observed = mob_eye.UID()
// mentor observing grants you this trait, and provides its own signal handler for this
if(!HAS_MIND_TRAIT(src, TRAIT_MENTOR_OBSERVING))
RegisterSignal(src, COMSIG_ATOM_ORBITER_STOP, PROC_REF(on_observer_orbit_end), override = TRUE)
@@ -964,6 +883,3 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(HAS_MIND_TRAIT(src, TRAIT_MENTOR_OBSERVING))
log_debug("[key_name(src)] ended up in regular cleanup_observe rather than the mentor cleanup observe despite having TRAIT_MENTOR_OBSERVING. This is likely a bug and may result in them being stuck outside of their bodies.")
cleanup_observe()
#undef GHOST_CAN_REENTER
#undef GHOST_IS_OBSERVER
@@ -1,13 +1,10 @@
/mob/dead/observer/Login()
..()
if(ghostimage)
ghostimage.icon_state = src.icon_state
updateghostimages()
. = ..()
if(isliving(mind?.current))
mind.current.med_hud_set_status()
if(GLOB.non_respawnable_keys[ckey])
can_reenter_corpse = 0
ghost_flags &= ~GHOST_RESPAWNABLE
REMOVE_TRAIT(src, TRAIT_RESPAWNABLE, GHOSTED)
update_admin_actions()
@@ -1,6 +1,4 @@
/mob/dead/observer/Logout()
if(client)
client.images -= GLOB.ghost_images
if(mob_observed && ismob(locateUID(mob_observed)))
cleanup_observe()
+1 -1
View File
@@ -30,7 +30,7 @@ GLOBAL_DATUM_INIT(orbit_menu, /datum/orbit_menu, new)
. = TRUE
return
var/mob/dead/observer/ghost = ui.user
ghost.ManualFollow(poi)
ghost.manual_follow(poi)
. = TRUE
if("refresh")
update_static_data(ui.user, ui)