mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-23 04:51:32 +01:00
Sensor Tweaks (#16434)
* Sensor Tweaks * anotha one * sound tweaks * removed debug code
This commit is contained in:
@@ -39,7 +39,9 @@
|
||||
|
||||
/obj/machinery/computer/ship/sensors/process()
|
||||
..()
|
||||
|
||||
update_sound()
|
||||
|
||||
if(!linked)
|
||||
return
|
||||
|
||||
@@ -51,12 +53,13 @@
|
||||
sensor_range = round(sensors.range,1)
|
||||
var/datum/overmap_contact/self_record = contact_datums[linked]
|
||||
self_record.update_marker_icon()
|
||||
self_record.ping_radar(sensor_range)
|
||||
self_record.show()
|
||||
|
||||
// Update our 'sensor range' (ie. overmap lighting)
|
||||
if(!sensors || !sensors.use_power || (stat & (NOPOWER|BROKEN)))
|
||||
datalink_remove_all_ships_datalink()
|
||||
if(length(datalink_contacts))
|
||||
var/remove_link = !sensors || HAS_FLAG(stat, BROKEN)
|
||||
datalink_remove_all_ships_datalink(remove_link)
|
||||
for(var/key in contact_datums)
|
||||
var/datum/overmap_contact/record = contact_datums[key]
|
||||
if(record.effect == linked)
|
||||
@@ -64,40 +67,27 @@
|
||||
qdel(record) // Immediately cut records if power is lost.
|
||||
|
||||
objects_in_view.Cut()
|
||||
return
|
||||
else
|
||||
self_record.ping_radar(sensor_range)
|
||||
|
||||
// What can we see?
|
||||
var/list/objects_in_current_view = list()
|
||||
// What can we see?
|
||||
var/list/objects_in_current_view = list()
|
||||
|
||||
// Find all sectors with a tracker on their z-level. Only works on ships when they are in space.
|
||||
for(var/obj/item/ship_tracker/tracker in trackers)
|
||||
if(tracker.enabled)
|
||||
var/obj/effect/overmap/visitable/tracked_effect = overmap_sectors["[GET_Z(tracker)]"]
|
||||
if(tracked_effect && istype(tracked_effect) && tracked_effect != linked && tracked_effect.requires_contact)
|
||||
objects_in_current_view[tracked_effect] = TRUE
|
||||
objects_in_view[tracked_effect] = 100
|
||||
// Find all sectors with a tracker on their z-level. Only works on ships when they are in space.
|
||||
for(var/obj/item/ship_tracker/tracker in trackers)
|
||||
if(tracker.enabled)
|
||||
var/obj/effect/overmap/visitable/tracked_effect = overmap_sectors["[GET_Z(tracker)]"]
|
||||
if(tracked_effect && istype(tracked_effect) && tracked_effect != linked && tracked_effect.requires_contact)
|
||||
objects_in_current_view[tracked_effect] = TRUE
|
||||
objects_in_view[tracked_effect] = 100
|
||||
|
||||
|
||||
// Handle datalinked view
|
||||
datalink_process()
|
||||
// Handle datalinked view
|
||||
datalink_process()
|
||||
|
||||
for(var/obj/effect/overmap/contact in view(sensor_range, linked))
|
||||
if(contact == linked)
|
||||
continue
|
||||
if(!contact.requires_contact) // Only some effects require contact for visibility.
|
||||
continue
|
||||
var/turf/overmap_grid_turf = get_turf(linked)
|
||||
|
||||
objects_in_current_view[contact] = TRUE
|
||||
|
||||
if(contact.instant_contact) // Instantly identify the object in range.
|
||||
objects_in_view[contact] = 100
|
||||
else if(!(contact in objects_in_view))
|
||||
objects_in_view[contact] = 0
|
||||
|
||||
if(sensors.deep_scan_toggled)
|
||||
for(var/obj/effect/overmap/contact in range(sensors.deep_scan_range, linked))
|
||||
if(!contact.sensor_range_override)
|
||||
continue
|
||||
for(var/obj/effect/overmap/contact in view(sensor_range, overmap_grid_turf))
|
||||
if(contact == linked)
|
||||
continue
|
||||
if(!contact.requires_contact) // Only some effects require contact for visibility.
|
||||
@@ -110,58 +100,74 @@
|
||||
else if(!(contact in objects_in_view))
|
||||
objects_in_view[contact] = 0
|
||||
|
||||
for(var/obj/effect/overmap/contact in objects_in_view) //Update everything.
|
||||
if(sensors.deep_scan_toggled)
|
||||
for(var/obj/effect/overmap/contact in range(sensors.deep_scan_range, overmap_grid_turf))
|
||||
if(!contact.sensor_range_override)
|
||||
continue
|
||||
if(contact == linked)
|
||||
continue
|
||||
if(!contact.requires_contact) // Only some effects require contact for visibility.
|
||||
continue
|
||||
|
||||
// Are we already aware of this object?
|
||||
var/datum/overmap_contact/record = contact_datums[contact]
|
||||
objects_in_current_view[contact] = TRUE
|
||||
|
||||
// Fade out and remove anything that is out of range.
|
||||
if(QDELETED(contact) || !objects_in_current_view[contact]) // Object has exited sensor range.
|
||||
if(record)
|
||||
animate(record.marker, alpha=0, 2 SECOND, 1, LINEAR_EASING)
|
||||
QDEL_IN(record, 2 SECOND) // Need to restart the search if you've lost contact with the object.
|
||||
if(contact.scannable) // Scannable objects are the only ones that give off notifications to prevent spam
|
||||
visible_message(SPAN_NOTICE("\The [src] states, \"Contact lost with [record.name].\""))
|
||||
playsound(loc, "sound/machines/sensors/contact_lost.ogg", 30, 1)
|
||||
objects_in_view -= contact
|
||||
continue
|
||||
if(contact.instant_contact) // Instantly identify the object in range.
|
||||
objects_in_view[contact] = 100
|
||||
else if(!(contact in objects_in_view))
|
||||
objects_in_view[contact] = 0
|
||||
|
||||
// Generate contact information for this overmap object.
|
||||
var/bearing = round(90 - Atan2(contact.x - linked.x, contact.y - linked.y),5)
|
||||
if(bearing < 0)
|
||||
bearing += 360
|
||||
if(!record) // Begin attempting to identify ship.
|
||||
// The chance of detection decreases with distance to the target ship.
|
||||
if(contact.scannable && prob((SENSORS_DISTANCE_COEFFICIENT * contact.sensor_visibility)/max(get_dist(linked, contact), 0.5)))
|
||||
var/bearing_variability = round(30/sensors.sensor_strength, 5)
|
||||
var/bearing_estimate = round(rand(bearing-bearing_variability, bearing+bearing_variability), 5)
|
||||
if(bearing_estimate < 0)
|
||||
bearing_estimate += 360
|
||||
// Give the player an idea of where the ship is in relation to the ship.
|
||||
if(objects_in_view[contact] <= 0)
|
||||
if(!muted)
|
||||
visible_message(SPAN_NOTICE("<b>\The [src]</b> states, \"Unknown contact designation '[contact.unknown_id]' detected nearby, bearing [bearing_estimate], error +/- [bearing_variability]. Beginning trace.\""))
|
||||
objects_in_view[contact] = round(sensors.sensor_strength**2)
|
||||
else
|
||||
objects_in_view[contact] += round(sensors.sensor_strength**2)
|
||||
if(!muted)
|
||||
visible_message(SPAN_NOTICE("<b>\The [src]</b> states, \"Contact '[contact.unknown_id]' tracing [objects_in_view[contact]]% complete, bearing [bearing_estimate], error +/- [bearing_variability].\""))
|
||||
playsound(loc, "sound/machines/sensors/contactgeneric.ogg", 10, 1) //Let players know there's something nearby.
|
||||
if(objects_in_view[contact] >= 100) // Identification complete.
|
||||
record = new /datum/overmap_contact(src, contact)
|
||||
contact_datums[contact] = record
|
||||
if(contact.scannable)
|
||||
playsound(loc, "sound/machines/sensors/newcontact.ogg", 30, 1)
|
||||
visible_message(SPAN_NOTICE("<b>\The [src]</b> states, \"New contact identified, designation [record.name], bearing [bearing].\""))
|
||||
record.show()
|
||||
animate(record.marker, alpha=255, 2 SECOND, 1, LINEAR_EASING)
|
||||
continue
|
||||
// Update identification information for this record.
|
||||
record.update_marker_icon()
|
||||
for(var/obj/effect/overmap/contact in objects_in_view) //Update everything.
|
||||
|
||||
var/time_delay = max((SENSOR_TIME_DELAY * get_dist(linked, contact)),1)
|
||||
if(!record.pinged)
|
||||
addtimer(CALLBACK(record, PROC_REF(ping)), time_delay)
|
||||
// Are we already aware of this object?
|
||||
var/datum/overmap_contact/record = contact_datums[contact]
|
||||
|
||||
// Fade out and remove anything that is out of range.
|
||||
if(QDELETED(contact) || !objects_in_current_view[contact]) // Object has exited sensor range.
|
||||
if(record)
|
||||
animate(record.marker, alpha=0, 2 SECOND, 1, LINEAR_EASING)
|
||||
QDEL_IN(record, 2 SECOND) // Need to restart the search if you've lost contact with the object.
|
||||
if(contact.scannable) // Scannable objects are the only ones that give off notifications to prevent spam
|
||||
visible_message(SPAN_NOTICE("\The [src] states, \"Contact lost with [record.name].\""))
|
||||
playsound(loc, "sound/machines/sensors/contact_lost.ogg", 30, 1)
|
||||
objects_in_view -= contact
|
||||
continue
|
||||
|
||||
// Generate contact information for this overmap object.
|
||||
var/bearing = round(90 - Atan2(contact.x - linked.x, contact.y - linked.y),5)
|
||||
if(bearing < 0)
|
||||
bearing += 360
|
||||
if(!record) // Begin attempting to identify ship.
|
||||
// The chance of detection decreases with distance to the target ship.
|
||||
if(contact.scannable && prob((SENSORS_DISTANCE_COEFFICIENT * contact.sensor_visibility)/max(get_dist(linked, contact), 0.5)))
|
||||
var/bearing_variability = round(30/sensors.sensor_strength, 5)
|
||||
var/bearing_estimate = round(rand(bearing-bearing_variability, bearing+bearing_variability), 5)
|
||||
if(bearing_estimate < 0)
|
||||
bearing_estimate += 360
|
||||
// Give the player an idea of where the ship is in relation to the ship.
|
||||
if(objects_in_view[contact] <= 0)
|
||||
if(!muted)
|
||||
visible_message(SPAN_NOTICE("<b>\The [src]</b> states, \"Unknown contact designation '[contact.unknown_id]' detected nearby, bearing [bearing_estimate], error +/- [bearing_variability]. Beginning trace.\""))
|
||||
objects_in_view[contact] = round(sensors.sensor_strength**2)
|
||||
else
|
||||
objects_in_view[contact] += round(sensors.sensor_strength**2)
|
||||
if(!muted)
|
||||
visible_message(SPAN_NOTICE("<b>\The [src]</b> states, \"Contact '[contact.unknown_id]' tracing [objects_in_view[contact]]% complete, bearing [bearing_estimate], error +/- [bearing_variability].\""))
|
||||
playsound(loc, "sound/machines/sensors/contactgeneric.ogg", 10, 1) //Let players know there's something nearby.
|
||||
if(objects_in_view[contact] >= 100) // Identification complete.
|
||||
record = new /datum/overmap_contact(src, contact)
|
||||
contact_datums[contact] = record
|
||||
if(contact.scannable)
|
||||
playsound(loc, "sound/machines/sensors/newcontact.ogg", 30, 1)
|
||||
visible_message(SPAN_NOTICE("<b>\The [src]</b> states, \"New contact identified, designation [record.name], bearing [bearing].\""))
|
||||
record.show()
|
||||
animate(record.marker, alpha=255, 2 SECOND, 1, LINEAR_EASING)
|
||||
continue
|
||||
// Update identification information for this record.
|
||||
record.update_marker_icon()
|
||||
|
||||
var/time_delay = max((SENSOR_TIME_DELAY * get_dist(linked, contact)),1)
|
||||
if(!record.pinged)
|
||||
addtimer(CALLBACK(record, PROC_REF(ping)), time_delay)
|
||||
|
||||
/obj/machinery/computer/ship/sensors/attackby(var/obj/item/I, var/mob/user)
|
||||
. = ..()
|
||||
@@ -271,12 +277,13 @@
|
||||
datalink_ship.datalinked |= src.connected
|
||||
src.connected.datalinked |= datalink_ship
|
||||
|
||||
/obj/machinery/computer/ship/sensors/proc/datalink_remove_ship_datalink(var/obj/effect/overmap/visitable/datalink_ship)
|
||||
/obj/machinery/computer/ship/sensors/proc/datalink_remove_ship_datalink(var/obj/effect/overmap/visitable/datalink_ship, var/remove_link)
|
||||
if(datalink_contacts[datalink_ship])
|
||||
for(var/obj/machinery/computer/ship/sensors/sensor_console in datalink_ship.consoles)
|
||||
// Remove the two ships from each other's datalinked list
|
||||
src.connected.datalinked -= datalink_ship
|
||||
datalink_ship.datalinked -= src.connected
|
||||
if(remove_link)
|
||||
src.connected.datalinked -= datalink_ship
|
||||
datalink_ship.datalinked -= src.connected
|
||||
|
||||
// Removes the ship contact itself from the contacts
|
||||
|
||||
@@ -294,14 +301,14 @@
|
||||
datalink_contacts.Remove(datalink_ship)
|
||||
|
||||
// Recurse the function on the other ship's instance
|
||||
sensor_console.datalink_remove_ship_datalink(src.connected)
|
||||
sensor_console.datalink_remove_ship_datalink(src.connected, remove_link)
|
||||
visible_message(SPAN_NOTICE("<b>\The [src]</b> states, \"A datalink contact was severed! Recalibrating...\""))
|
||||
|
||||
|
||||
/obj/machinery/computer/ship/sensors/proc/datalink_remove_all_ships_datalink()
|
||||
/obj/machinery/computer/ship/sensors/proc/datalink_remove_all_ships_datalink(var/remove_link)
|
||||
for(var/obj/effect/overmap/visitable/datalink_ship in linked.datalinked)
|
||||
for(var/obj/machinery/computer/ship/sensors/sensor_console in datalink_ship.consoles)
|
||||
sensor_console.datalink_remove_ship_datalink(linked)
|
||||
sensor_console.datalink_remove_ship_datalink(linked, remove_link)
|
||||
break
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
var/contact_details = null
|
||||
var/contact_name = null
|
||||
|
||||
var/working_sound = 'sound/machines/sensors/dradis.ogg'
|
||||
var/working_sound = 'sound/machines/sensors/ping.ogg'
|
||||
var/datum/sound_token/sound_token
|
||||
var/sound_id
|
||||
|
||||
@@ -61,9 +61,9 @@
|
||||
|
||||
var/obj/machinery/shipsensors/sensors = get_sensors()
|
||||
if(linked && sensors?.use_power && !(sensors.stat & NOPOWER))
|
||||
var/volume = 10
|
||||
var/volume = 15
|
||||
if(!sound_token)
|
||||
sound_token = sound_player.PlayLoopingSound(src, sound_id, working_sound, volume = volume, range = 10)
|
||||
sound_token = sound_player.PlayLoopingSound(src, sound_id, working_sound, volume = volume, range = 10, sound_type = ASFX_CONSOLE_AMBIENCE)
|
||||
sound_token.SetVolume(volume)
|
||||
else if(sound_token)
|
||||
QDEL_NULL(sound_token)
|
||||
@@ -134,7 +134,7 @@
|
||||
var/bearing = round(90 - Atan2(O.x - linked.x, O.y - linked.y),5)
|
||||
if(bearing < 0)
|
||||
bearing += 360
|
||||
contacts.Add(list(list("name"=O.name, "ref"="\ref[O]", "bearing"=bearing)))
|
||||
contacts.Add(list(list("name"=O.name, "ref"="\ref[O]", "bearing"=bearing, "can_datalink"=(!(O in connected.datalinked)))))
|
||||
if(length(contacts))
|
||||
data["contacts"] = contacts
|
||||
|
||||
@@ -304,7 +304,7 @@
|
||||
if (href_list["remove_datalink"])
|
||||
var/obj/effect/overmap/visitable/O = locate(href_list["remove_datalink"])
|
||||
for(var/obj/machinery/computer/ship/sensors/rescinder_sensor_console in src.connected.consoles) // Get sensor console from the rescinder
|
||||
rescinder_sensor_console.datalink_remove_ship_datalink(O)
|
||||
rescinder_sensor_console.datalink_remove_ship_datalink(O, TRUE)
|
||||
return TOPIC_HANDLED
|
||||
|
||||
if (href_list["play_message"])
|
||||
|
||||
@@ -110,7 +110,7 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov
|
||||
if (use_check_and_message(user, flags) || user.blinded || inoperable() || !linked)
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
return SEE_THRU
|
||||
|
||||
/obj/machinery/computer/ship/Destroy()
|
||||
if(linked)
|
||||
|
||||
@@ -66,6 +66,12 @@
|
||||
shuttle_moved_event.register(shuttle_datum, src, PROC_REF(on_shuttle_jump))
|
||||
on_landing(landmark, shuttle_datum.current_location) // We "land" at round start to properly place ourselves on the overmap.
|
||||
|
||||
var/obj/effect/overmap/visitable/mothership = map_sectors["[shuttle_datum.current_location.z]"]
|
||||
if(mothership)
|
||||
for(var/obj/machinery/computer/ship/sensors/sensor_console in consoles)
|
||||
sensor_console.datalink_add_ship_datalink(mothership)
|
||||
break
|
||||
|
||||
/obj/effect/shuttle_landmark/ship
|
||||
name = "Open Space"
|
||||
landmark_tag = "ship"
|
||||
|
||||
Reference in New Issue
Block a user