Merge pull request #11043 from VOREStation/Arokha/uavview

Make UAVs not work at impossible distances
This commit is contained in:
Aronai Sieyes
2021-07-12 19:45:34 -04:00
committed by Chompstation Bot
parent 796c58e062
commit 85b0fbdd30
4 changed files with 37 additions and 11 deletions

View File

@@ -13,11 +13,11 @@
if(current_uav)
if(QDELETED(current_uav))
set_current(null)
clear_current()
else if(signal_test_counter-- <= 0)
signal_strength = get_signal_to(current_uav)
if(!signal_strength)
set_current(null)
clear_current()
else // Don't reset counter until we find a UAV that's actually in range we can stay connected to
signal_test_counter = 20
@@ -95,16 +95,33 @@
signal_strength = 0
current_uav = U
RegisterSignal(U, COMSIG_MOVABLE_Z_CHANGED, .proc/current_uav_changed_z)
if(LAZYLEN(viewers))
for(var/weakref/W in viewers)
var/M = W.resolve()
if(M)
if(current_uav)
to_chat(M, "<span class='warning'>You're disconnected from the UAV's camera!</span>")
unlook(M)
else
look(M)
look(M)
/datum/tgui_module/uav/proc/clear_current()
if(!current_uav)
return
UnregisterSignal(current_uav, COMSIG_MOVABLE_Z_CHANGED)
signal_strength = 0
current_uav = null
if(LAZYLEN(viewers))
for(var/weakref/W in viewers)
var/M = W.resolve()
if(M)
to_chat(M, "<span class='warning'>You're disconnected from the UAV's camera!</span>")
unlook(M)
/datum/tgui_module/uav/proc/current_uav_changed_z(old_z, new_z)
signal_strength = get_signal_to(current_uav)
if(!signal_strength)
clear_current()
////
//// Finding signal strength between us and the UAV
@@ -130,6 +147,7 @@
var/list/zlevels_in_range = using_map.get_map_levels(their_z, FALSE)
var/list/zlevels_in_long_range = using_map.get_map_levels(their_z, TRUE, om_range = DEFAULT_OVERMAP_RANGE) - zlevels_in_range
var/their_signal = 0
// Measure z-distance between the AM passed in and the nearest relay
for(var/relay in ntnet_global.relays)
var/obj/machinery/ntnet_relay/R = relay
if(!R.operable())
@@ -144,7 +162,8 @@
their_signal = 1
break
if(!their_signal) //They have no NTnet at all
// AM passed in has no NTnet at all
if(!their_signal)
if(get_z(host) == their_z && (get_dist(host, AM) < adhoc_range))
return 1 //We can connect (with weak signal) in same z without ntnet, within 30 turfs
else