Hopefully fixes spectral blade letting ghosts stay visible (#17602)

This commit is contained in:
Luc
2022-04-12 15:53:37 +01:00
committed by GitHub
parent 43754c445b
commit 1b3b040ce5
2 changed files with 28 additions and 14 deletions
+9 -3
View File
@@ -78,6 +78,7 @@
orbit_data += new_comp.orbit_data
new_comp.orbiter_list = list()
new_comp.orbit_data = list()
QDEL_NULL(new_comp)
/datum/component/orbiter/PostTransfer()
if(!isatom(parent) || isarea(parent) || !get_turf(parent))
@@ -448,8 +449,9 @@
/**
* Check every object in the hierarchy above ourselves for orbiters, and return the full list of them.
* If an object is being held in a backpack, returns orbiters of the backpack, the person
* If recursive == TRUE, this will also check recursively through any ghosts seen to make sure we find *everything* upstream
*/
/atom/proc/get_orbiters_up_hierarchy(list/processed, source = TRUE)
/atom/proc/get_orbiters_up_hierarchy(list/processed, source = TRUE, recursive = FALSE)
var/list/output = list()
if(!processed)
processed = list()
@@ -459,10 +461,14 @@
processed += src
for(var/atom/movable/atom_orbiter in get_orbiters())
if(isobserver(atom_orbiter))
if(recursive)
output += atom_orbiter.get_orbiters_recursive()
output += atom_orbiter
if(atom_orbiter.loc != null)
output += atom_orbiter.loc.get_orbiters_up_hierarchy(processed, source = FALSE)
if(loc)
output += loc.get_orbiters_up_hierarchy(processed, source = FALSE)
return output
#undef ORBIT_LOCK_IN
#undef ORBIT_FORCE_MOVE
@@ -58,7 +58,7 @@
/obj/item/melee/ghost_sword/examine()
. = ..()
if(spirits)
if(length(spirits))
. += "It appears to pulse with the power of [length(spirits)] vengeful spirits!"
else
. += "It glows weakly."
@@ -81,23 +81,28 @@
/obj/item/melee/ghost_sword/proc/add_ghost(atom/movable/orbited, atom/orbiter)
SIGNAL_HANDLER // COMSIG_ATOM_ORBIT_BEGIN
if(!isobserver(orbiter))
var/mob/dead/observer/ghost = orbiter
if(!istype(ghost) || !isobserver(orbiter) || (ghost in spirits))
return
var/mob/dead/observer/ghost = orbiter
if(!ismob(loc))
// Don't count any new ghosts while the sword isn't being held in hand
// they'll get added to spirits (and turned visible) when the sword enters a mob's hand then
return
register_signals(ghost) // Sure, just in case someone's orbiting an orbiting ghost
register_signals(ghost) // Pull in any ghosts that may be orbiting other ghosts TODO THIS MIGHT BE THE FUCKIN PROBLEM
spirits |= ghost
ghost.invisibility = 0
/obj/item/melee/ghost_sword/proc/remove_ghost(atom/movable/orbited, atom/orbiter)
SIGNAL_HANDLER // COMSIG_ATOM_ORBIT_STOP
if(!isobserver(orbiter))
return
var/mob/dead/observer/ghost = orbiter
if(!istype(ghost) || !isobserver(ghost) || !(ghost in spirits))
return
remove_signals(ghost)
spirits -= ghost
@@ -115,16 +120,19 @@
* When moving into something's contents
*/
/obj/item/melee/ghost_sword/proc/on_move(atom/movable/this, atom/old_loc, direction)
SIGNAL_HANDLER // on move
SIGNAL_HANDLER // COMSIG_MOVABLE_MOVED
// We should only really care about the wielder of the sword and the sword itself when checking ghosts
if(ismob(old_loc))
remove_signals(old_loc)
for(var/mob/dead/observer/orbiter in old_loc.get_orbiters())
remove_ghost(orbiter)
for(var/mob/dead/observer/orbiter in spirits)
remove_ghost(src, orbiter)
if(ismob(loc))
register_signals(loc)
for(var/mob/dead/observer/orbiter in loc.get_orbiters())
add_ghost(orbiter)
// Add ghosts directly orbiting
for(var/mob/dead/observer/orbiter in get_orbiters_up_hierarchy(recursive = TRUE))
add_ghost(src, orbiter)
/obj/item/melee/ghost_sword/attack(mob/living/target, mob/living/carbon/human/user)
force = 0