From 6e45e5620da00baed406fbc3e09b9e4b107c682c Mon Sep 17 00:00:00 2001 From: Matt Atlas Date: Sat, 15 Apr 2023 00:21:36 +0200 Subject: [PATCH] Hostile mobs no longer target logged out players. (#16200) * Hostile mobs no longer target logged out players. * ffs --------- Co-authored-by: Matt Atlas --- .../living/simple_animal/hostile/hostile.dm | 10 ++++- html/changelogs/mattatlas-hivebotdisaster.yml | 41 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 html/changelogs/mattatlas-hivebotdisaster.yml diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 67fa83468f9..8649b4fb4ea 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -70,6 +70,10 @@ for (var/atom/A in targets) if(A == src) continue + if(ismob(A)) //Don't target mobs with keys that have logged out. + var/mob/M = A + if(M.key && !M.client) + continue if(!isturf(A.loc)) A = A.loc var/datum/callback/cb = null @@ -121,7 +125,7 @@ target_mob = user change_stance(HOSTILE_STANCE_ATTACK) -mob/living/simple_animal/hostile/hitby(atom/movable/AM as mob|obj,var/speed = THROWFORCE_SPEED_DIVISOR)//Standardization and logging -Sieve +/mob/living/simple_animal/hostile/hitby(atom/movable/AM as mob|obj,var/speed = THROWFORCE_SPEED_DIVISOR)//Standardization and logging -Sieve ..() if(istype(AM,/obj/)) var/obj/O = AM @@ -170,6 +174,10 @@ mob/living/simple_animal/hostile/hitby(atom/movable/AM as mob|obj,var/speed = TH if(QDELETED(target_mob) || SA_attackable(target_mob)) LoseTarget() return 0 + if(ismob(target_mob)) //target_mob is not in fact always a mob + if(target_mob.key && !target_mob.client) + LoseTarget() + return 0 if(!(target_mob in targets)) LoseTarget() return 0 diff --git a/html/changelogs/mattatlas-hivebotdisaster.yml b/html/changelogs/mattatlas-hivebotdisaster.yml new file mode 100644 index 00000000000..54c1cd0ff1d --- /dev/null +++ b/html/changelogs/mattatlas-hivebotdisaster.yml @@ -0,0 +1,41 @@ +################################ +# 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 +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: MattAtlas + +# 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, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Hostile mobs no longer target players that have logged out."