From 67b8b58e918a83b4e6bdd17f267788d5914ea187 Mon Sep 17 00:00:00 2001 From: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:38:42 +0200 Subject: [PATCH] Fixed harvesters vision not making them shoot at opaque turfs on non-vertical alignments (#20104) Fixed harvesters vision not making them shoot at opaque turfs on non-vertical alignments. Some code QoL changes. Fixes #19684 --- .../hostile/hivebots/hivebot_beacon.dm | 2 +- .../hostile/hivebots/hivebot_harvester.dm | 6 +- .../living/simple_animal/hostile/hostile.dm | 28 ++++++--- .../fluffyghost-fixharvestersvision.yml | 59 +++++++++++++++++++ 4 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 html/changelogs/fluffyghost-fixharvestersvision.yml diff --git a/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_beacon.dm b/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_beacon.dm index a691f9dc5b9..c2ed4bb2087 100644 --- a/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_beacon.dm +++ b/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_beacon.dm @@ -185,7 +185,7 @@ stop_automated_movement = 1 if(QDELETED(target_mob) || SA_attackable(target_mob)) LoseTarget() - if(!see_target()) + if(!see_target(target_mob)) LoseTarget() if(target_mob in targets) if(get_dist(src, target_mob) <= 6) diff --git a/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_harvester.dm b/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_harvester.dm index 202b3d1302b..8dff584dbae 100644 --- a/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_harvester.dm +++ b/code/modules/mob/living/simple_animal/hostile/hivebots/hivebot_harvester.dm @@ -253,9 +253,8 @@ return if(istype(T, /turf/simulated/wall)) - var/turf/simulated/wall/W = T rapid = 1 - OpenFire(W) + OpenFire(T, ignore_visibility = TRUE) rapid = 0 return @@ -337,7 +336,6 @@ /mob/living/simple_animal/hostile/retaliate/hivebotharvester/shoot_wrapper(target, location, user) target_mob = target - if(see_target()) - Shoot(target, location, user) + Shoot(target, location, user) target_mob = null return diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 5a4cee9e213..594eef8931b 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -156,14 +156,20 @@ ABSTRACT_TYPE(/mob/living/simple_animal/hostile) /mob/living/simple_animal/hostile/proc/FoundTarget() return -/mob/living/simple_animal/hostile/proc/see_target() - return is_in_sight(src, target_mob) +/mob/living/simple_animal/hostile/proc/see_target(atom/target) + SHOULD_NOT_SLEEP(TRUE) + + if(!target) + stack_trace("see_target() called with null target!") + return FALSE + + return is_in_sight(src, target) /mob/living/simple_animal/hostile/proc/MoveToTarget() stop_automated_movement = 1 if(QDELETED(target_mob) || SA_attackable(target_mob)) LoseTarget() - if(!see_target()) + if(!see_target(target_mob)) LoseTarget() if(target_mob in targets) if(ranged) @@ -188,7 +194,7 @@ ABSTRACT_TYPE(/mob/living/simple_animal/hostile) if(!(target_mob in targets)) LoseTarget() return 0 - if(!see_target()) + if(!see_target(target_mob)) LoseTarget() if(ON_ATTACK_COOLDOWN(src)) return @@ -210,7 +216,7 @@ ABSTRACT_TYPE(/mob/living/simple_animal/hostile) return if(!canmove) return - if(!see_target()) + if(!see_target(target_mob)) LoseTarget() for(var/grab in grabbed_by) var/obj/item/grab/G = grab @@ -323,11 +329,19 @@ ABSTRACT_TYPE(/mob/living/simple_animal/hostile) return TRUE -/mob/living/simple_animal/hostile/proc/OpenFire(target_mob) +/** + * Handles the logic of firing at a target for the hostile mob + * + * * target_mob - The mob to fire at + * * ignore_visibility - Whether or not to ignore the visibility check + */ +/mob/living/simple_animal/hostile/proc/OpenFire(target_mob, ignore_visibility = FALSE) set waitfor = FALSE - if(!see_target()) + if(!ignore_visibility && !see_target(target_mob)) LoseTarget() + return + var/target = target_mob // This code checks if we are not going to hit our target if(smart_ranged && !check_fire(target_mob)) diff --git a/html/changelogs/fluffyghost-fixharvestersvision.yml b/html/changelogs/fluffyghost-fixharvestersvision.yml new file mode 100644 index 00000000000..5aef44ab38a --- /dev/null +++ b/html/changelogs/fluffyghost-fixharvestersvision.yml @@ -0,0 +1,59 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# - (fixes bugs) +# wip +# - (work in progress) +# qol +# - (quality of life) +# soundadd +# - (adds a sound) +# sounddel +# - (removes a sound) +# rscadd +# - (adds a feature) +# rscdel +# - (removes a feature) +# imageadd +# - (adds an image or sprite) +# imagedel +# - (removes an image or sprite) +# spellcheck +# - (fixes spelling or grammar) +# experiment +# - (experimental change) +# balance +# - (balance changes) +# code_imp +# - (misc internal code change) +# refactor +# - (refactors code) +# config +# - (makes a change to the config files) +# admin +# - (makes changes to administrator tools) +# server +# - (miscellaneous changes to server) +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit. +# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Fixed harvesters vision not making them shoot at opaque turfs on non-vertical alignments." + - code_imp: "Some code QoL changes."