mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-26 22:42:26 +01:00
Fix mapped-in objects being deaf, destroy virtual mobs (#15343)
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
anchored = 1 // don't get pushed around
|
||||
simulated = FALSE
|
||||
virtual_mob = null // Hear no evil, speak no evil
|
||||
|
||||
var/last_ready_name // This has to be saved because the client is nulled prior to Logout()
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
var/global/const/VIRTUAL_ABILITY_NONE = 0
|
||||
var/global/const/VIRTUAL_ABILITY_HEAR = 1
|
||||
var/global/const/VIRTUAL_ABILITY_SEE = 2
|
||||
var/global/const/VIRTUAL_ABILITY_ALL = (~VIRTUAL_ABILITY_NONE)
|
||||
@@ -1,71 +0,0 @@
|
||||
//
|
||||
// Virtual Mob
|
||||
//
|
||||
|
||||
var/global/list/all_virtual_listeners = list()
|
||||
|
||||
/mob/abstract/observer/virtual
|
||||
icon = 'icons/mob/abstract/virtual.dmi'
|
||||
invisibility = INVISIBILITY_SYSTEM
|
||||
see_in_dark = SEE_IN_DARK_DEFAULT
|
||||
see_invisible = SEE_INVISIBLE_LIVING
|
||||
sight = SEE_SELF
|
||||
|
||||
virtual_mob = null
|
||||
no_z_overlay = TRUE
|
||||
|
||||
should_add_to_mob_list = FALSE
|
||||
|
||||
var/atom/movable/host
|
||||
var/host_type = /atom/movable
|
||||
var/abilities = VIRTUAL_ABILITY_HEAR|VIRTUAL_ABILITY_SEE
|
||||
var/list/broadcast_methods
|
||||
|
||||
var/static/list/overlay_icons
|
||||
|
||||
/mob/abstract/observer/virtual/New(var/location, var/atom/movable/host)
|
||||
..()
|
||||
if(!istype(host, host_type))
|
||||
CRASH("Received an unexpected host type. Expected [host_type], was [log_info_line(host)].")
|
||||
src.host = host
|
||||
moved_event.register(host, src, /atom/movable/proc/move_to_turf_or_null)
|
||||
|
||||
all_virtual_listeners += src
|
||||
|
||||
update_icon()
|
||||
|
||||
/mob/abstract/observer/virtual/Initialize()
|
||||
. = ..()
|
||||
STOP_PROCESSING(SSmob, src)
|
||||
|
||||
/mob/abstract/observer/virtual/Destroy()
|
||||
moved_event.unregister(host, src, /atom/movable/proc/move_to_turf_or_null)
|
||||
all_virtual_listeners -= src
|
||||
host = null
|
||||
return ..()
|
||||
|
||||
/mob/abstract/observer/virtual/update_icon()
|
||||
if(!overlay_icons)
|
||||
overlay_icons = list()
|
||||
for(var/i_state in icon_states(icon))
|
||||
overlay_icons[i_state] = image(icon = icon, icon_state = i_state)
|
||||
overlays.Cut()
|
||||
|
||||
if(abilities & VIRTUAL_ABILITY_HEAR)
|
||||
overlays += overlay_icons["hear"]
|
||||
if(abilities & VIRTUAL_ABILITY_SEE)
|
||||
overlays += overlay_icons["see"]
|
||||
|
||||
//
|
||||
// Virtual Mob Creation
|
||||
//
|
||||
/atom/movable
|
||||
var/mob/abstract/observer/virtual/virtual_mob
|
||||
|
||||
/atom/movable/Initialize()
|
||||
. = ..()
|
||||
if(shall_have_virtual_mob())
|
||||
virtual_mob = new virtual_mob(get_turf(src), src)
|
||||
|
||||
/atom/movable/proc/shall_have_virtual_mob()
|
||||
return ispath(initial(virtual_mob))
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* These calls could easily be setup to be a bunch of call()() with relevant procs and predicates but performance is a concern.
|
||||
* BYOND is also a bit inflexible, as some predicates are of the sort /proc/name(host), others host.proc_name(), and some even do host.proc_name(parameter).
|
||||
* Nothing that cannot be worked around, but it'd be a little messy. I miss C# lambdas...
|
||||
*/
|
||||
|
||||
// Procs are arranged by "in range/hearers/viewers()" usage, as opposed to virtual mob hear/see abilities.
|
||||
// Most of these procs can technically take any movable atom but unless they have a virtual mob the returned objects may not be the expected ones
|
||||
|
||||
#define ACQUIRE_VIRTUAL_OR_TURF(A) A = (isvirtualmob(A) ? A : (((istype(A) && A.virtual_mob) ? A.virtual_mob : get_turf(A)))) ; if(!A) return
|
||||
#define ACQUIRE_VIRTUAL_OR_RETURN(A) A = (isvirtualmob(A) ? A : (((istype(A) && A.virtual_mob) ? A.virtual_mob : null))) ; if(!A) return
|
||||
|
||||
/****************
|
||||
* Range Helpers *
|
||||
****************/
|
||||
/proc/clients_in_range(var/atom/movable/center_vmob)
|
||||
. = list()
|
||||
|
||||
ACQUIRE_VIRTUAL_OR_TURF(center_vmob)
|
||||
for(var/mob/abstract/observer/virtual/v_mob in range(world.view, center_vmob))
|
||||
var/client/C = v_mob.get_client()
|
||||
if(C)
|
||||
. |= C
|
||||
|
||||
/proc/hearers_in_range(var/atom/movable/center_vmob, var/hearing_range = world.view)
|
||||
. = list()
|
||||
|
||||
ACQUIRE_VIRTUAL_OR_TURF(center_vmob)
|
||||
for(var/mob/abstract/observer/virtual/v_mob in range(hearing_range, center_vmob))
|
||||
if(v_mob.abilities & VIRTUAL_ABILITY_HEAR)
|
||||
. |= v_mob.host
|
||||
|
||||
/proc/viewers_in_range(var/atom/movable/center_vmob)
|
||||
. = list()
|
||||
|
||||
ACQUIRE_VIRTUAL_OR_TURF(center_vmob)
|
||||
for(var/mob/abstract/observer/virtual/v_mob in range(world.view, center_vmob))
|
||||
if(v_mob.abilities & VIRTUAL_ABILITY_SEE)
|
||||
. |= v_mob.host
|
||||
|
||||
/***************
|
||||
* Hear Helpers *
|
||||
***************/
|
||||
// A mob hears another mob if they have direct line of sight, ignoring turf luminosity.
|
||||
// If there is an opaque object beteween the mobs then they cannot hear each other, even if their respective turfs can be seen.
|
||||
// Thus, unlike viewing hearing is communicative. I.e. if Mob A can hear Mob B then Mob B can also hear Mob A.
|
||||
|
||||
// Gets the hosts of all the virtual mobs that can hear the given movable atom (or rather, it's virtual mob or turf in that existence order)
|
||||
/proc/all_hearers(var/atom/movable/heard_vmob, var/range = world.view)
|
||||
. = list()
|
||||
|
||||
ACQUIRE_VIRTUAL_OR_TURF(heard_vmob)
|
||||
for(var/mob/abstract/observer/virtual/v_mob in hearers(range, heard_vmob))
|
||||
if(v_mob.abilities & VIRTUAL_ABILITY_HEAR)
|
||||
. |= v_mob.host
|
||||
|
||||
/***************
|
||||
* View Helpers *
|
||||
***************/
|
||||
// A mob can see another mob if:
|
||||
// * Within visual range, with the following differences for (N)PCs.
|
||||
// * PCs: Target is within client.view range, with center originating from either the mob or client.eye depending on client.eye_perspective.
|
||||
// * NPCs: Target is within world.view range, with center always originating from the mob.
|
||||
// * Either of the following is true:
|
||||
// * The target mob is in direct line of sight and not standing on a turf with luminosity = 0 unless the viewing mob is close enough for see_in_dark to also be in range
|
||||
// * The viewing mob has the SEE_MOBS sight flag.
|
||||
|
||||
// Gets the hosts of all virtual mobs that can see the given atom movable as well as its turf
|
||||
/proc/all_viewers(var/mob/abstract/observer/virtual/viewed_atom)
|
||||
. = list()
|
||||
|
||||
viewed_atom = istype(viewed_atom) ? viewed_atom.host : viewed_atom
|
||||
var/turf/T = get_turf(viewed_atom)
|
||||
if(!T)
|
||||
return
|
||||
|
||||
for(var/mob/abstract/observer/virtual/seeing_v_mob in viewers(world.view, viewed_atom))
|
||||
if(!(seeing_v_mob.abilities & VIRTUAL_ABILITY_SEE))
|
||||
continue
|
||||
var/atom/movable/host = seeing_v_mob.host
|
||||
if(host.virtual_can_see_turf(T))
|
||||
. |= host
|
||||
|
||||
// This proc returns all hosts of virtual mobs in the given atom's view range (using its turf), ignoring invisibility, VIRUAL_ABILITY_SEE, and most other restrictions.
|
||||
// In most cases you actually want the all_* procs above. This helper was designed with LOOC in mind.
|
||||
/proc/hosts_in_view_range(var/atom/movable/viewing_atom, var/range = world.view)
|
||||
. = list()
|
||||
|
||||
ACQUIRE_VIRTUAL_OR_TURF(viewing_atom)
|
||||
// As per http://www.byond.com/docs/ref/info.html#/proc/view by using a non-mob/client this automatically skips the vast majority of sight checks
|
||||
for(var/mob/abstract/observer/virtual/v_mob in viewers(range, get_turf(viewing_atom.loc)))
|
||||
. |= v_mob.host
|
||||
|
||||
/*
|
||||
Misc. helper
|
||||
*/
|
||||
|
||||
// Eye mobs technically see everything always, the owner just has an overlay applied, thus this helper
|
||||
/atom/movable/proc/virtual_can_see_turf(var/turf/T)
|
||||
return TRUE // We assume objects have already been filtered using viewers() or similar proc
|
||||
|
||||
#undef ACQUIRE_VIRTUAL_OR_TURF
|
||||
#undef ACQUIRE_VIRTUAL_OR_RETURN
|
||||
@@ -1,22 +0,0 @@
|
||||
/mob/abstract/observer/virtual/mob
|
||||
host_type = /mob
|
||||
|
||||
/mob/abstract/observer/virtual/mob/New(var/location, var/mob/host)
|
||||
..()
|
||||
|
||||
sight_set_event.register(host, src, /mob/abstract/observer/virtual/mob/proc/sync_sight)
|
||||
see_invisible_set_event.register(host, src, /mob/abstract/observer/virtual/mob/proc/sync_sight)
|
||||
see_in_dark_set_event.register(host, src, /mob/abstract/observer/virtual/mob/proc/sync_sight)
|
||||
|
||||
sync_sight(host)
|
||||
|
||||
/mob/abstract/observer/virtual/mob/Destroy()
|
||||
sight_set_event.unregister(host, src, /mob/abstract/observer/virtual/mob/proc/sync_sight)
|
||||
see_invisible_set_event.unregister(host, src, /mob/abstract/observer/virtual/mob/proc/sync_sight)
|
||||
see_in_dark_set_event.unregister(host, src, /mob/abstract/observer/virtual/mob/proc/sync_sight)
|
||||
. = ..()
|
||||
|
||||
/mob/abstract/observer/virtual/mob/proc/sync_sight(var/mob/mob_host)
|
||||
sight = mob_host.sight
|
||||
see_invisible = mob_host.see_invisible
|
||||
see_in_dark = mob_host.see_in_dark
|
||||
@@ -165,7 +165,7 @@
|
||||
else
|
||||
speaker_name = "Unknown"
|
||||
|
||||
if(ishuman(speaker) && speaker.GetVoice() != real_name)
|
||||
if(ishuman(speaker))
|
||||
speaker_name = speaker.GetVoice()
|
||||
|
||||
if(hard_to_hear)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/mob/living/carbon/human/dummy
|
||||
real_name = "Test Dummy"
|
||||
status_flags = GODMODE|CANPUSH
|
||||
virtual_mob = null
|
||||
|
||||
/mob/living/carbon/human/dummy/mannequin
|
||||
mob_thinks = FALSE
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
animate_movement = 2
|
||||
flags = PROXMOVE
|
||||
sight = DEFAULT_SIGHT
|
||||
virtual_mob = /mob/abstract/observer/virtual/mob
|
||||
var/datum/mind/mind
|
||||
|
||||
var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak
|
||||
|
||||
@@ -1292,6 +1292,3 @@ proc/is_blind(A)
|
||||
|
||||
/mob/get_client()
|
||||
return client
|
||||
|
||||
/mob/abstract/observer/virtual/get_client()
|
||||
return host.get_client()
|
||||
|
||||
Reference in New Issue
Block a user