From 543dd8e58d0b8e69ed9d8cb645a03cdaba6ac3f8 Mon Sep 17 00:00:00 2001 From: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Date: Sun, 8 Sep 2024 04:50:00 +0300 Subject: [PATCH] fixes can_see not working (#86517) ## About The Pull Request can_see wasnt working after the new inbuilt byond procs were introduced to it. ## Why It's Good For The Game closes #86515 ## Changelog :cl: fix: basic mobs will now act hostile again /:cl: --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/__HELPERS/atoms.dm | 4 ++-- code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/can_see.dm | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 code/modules/unit_tests/can_see.dm diff --git a/code/__HELPERS/atoms.dm b/code/__HELPERS/atoms.dm index 22f082a5eb3..646410026a0 100644 --- a/code/__HELPERS/atoms.dm +++ b/code/__HELPERS/atoms.dm @@ -63,9 +63,9 @@ var/turf/target_turf = get_turf(target) if(get_dist(source, target) > length) return FALSE - if(current == target_turf)//they are on the same turf, source can see the target + if(current == target_turf || source.CanReach(target))//they are on the same turf or in reach, source can see the target return TRUE - var/list/steps = get_steps_to(current, target_turf) + var/list/steps = get_steps_to(source, target) if(isnull(steps) || length(steps) > length) return FALSE for(var/direction in steps) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index f56eab7af5f..95b7f4a4634 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -107,6 +107,7 @@ #include "breath.dm" #include "burning.dm" #include "cable_powernets.dm" +#include "can_see.dm" #include "card_mismatch.dm" #include "cardboard_cutouts.dm" #include "cargo_dep_order_locations.dm" diff --git a/code/modules/unit_tests/can_see.dm b/code/modules/unit_tests/can_see.dm new file mode 100644 index 00000000000..cb7f7bef047 --- /dev/null +++ b/code/modules/unit_tests/can_see.dm @@ -0,0 +1,7 @@ +/// Unit test to make sure can_see is working properly +/datum/unit_test/can_see_test + +/datum/unit_test/can_see_test/Run() + var/mob/living/carbon/human/observer = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) //make sure they're both apart + var/mob/living/carbon/human/to_be_seen = allocate(/mob/living/carbon/human/consistent, run_loc_floor_top_right) + TEST_ASSERT(can_see(observer, to_be_seen, get_dist(observer, to_be_seen)), "can_see returned false despite dummies being able to see one another!")