From 93d995eb18b8725c765250c51879bf443b3f7554 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Fri, 6 Mar 2020 10:13:11 -0700 Subject: [PATCH 1/2] k --- code/game/objects/items/melee/misc.dm | 2 +- code/modules/mob/living/living.dm | 2 +- code/modules/mob/living/simple_animal/slime/life.dm | 9 +++++---- code/modules/mob/mob.dm | 3 +++ code/modules/mob/mob_defines.dm | 4 ++-- code/modules/recycling/disposal/bin.dm | 2 +- code/modules/research/xenobiology/xenobio_camera.dm | 4 ++-- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/code/game/objects/items/melee/misc.dm b/code/game/objects/items/melee/misc.dm index 996d206c65..5c388276b6 100644 --- a/code/game/objects/items/melee/misc.dm +++ b/code/game/objects/items/melee/misc.dm @@ -233,7 +233,7 @@ if(!iscarbon(user)) target.LAssailant = null else - target.LAssailant = user + target.LAssailant = WEAKREF(user) last_hit = world.time + cooldown user.adjustStaminaLossBuffered(getweight())//CIT CHANGE - makes swinging batons cost stamina diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index d9a22674ae..65f900f768 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -295,7 +295,7 @@ if(!iscarbon(src)) M.LAssailant = null else - M.LAssailant = usr + M.LAssailant = WEAKREF(src) if(isliving(M)) var/mob/living/L = M //Share diseases that are spread by touch diff --git a/code/modules/mob/living/simple_animal/slime/life.dm b/code/modules/mob/living/simple_animal/slime/life.dm index a923da6ed6..4b89d96e64 100644 --- a/code/modules/mob/living/simple_animal/slime/life.dm +++ b/code/modules/mob/living/simple_animal/slime/life.dm @@ -186,12 +186,13 @@ if(M.stat == DEAD) // our victim died if(!client) if(!rabid && !attacked) - if(M.LAssailant && M.LAssailant != M) + var/mob/living/carbon/their_attacker = M.getLAssailant() + if(their_attacker != M) if(prob(50)) - if(!(M.LAssailant in Friends)) - Friends[M.LAssailant] = 1 + if(!(their_attacker in Friends)) + Friends[their_attacker] = 1 else - ++Friends[M.LAssailant] + ++Friends[their_attacker] else to_chat(src, "This subject does not have a strong enough life energy anymore...") diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index a523c22d53..ded7a5e222 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -952,3 +952,6 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0) /mob/setMovetype(newval) . = ..() update_movespeed(FALSE) + +/mob/proc/getLAssailant() + return LAssailant?.resolve() diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 638a3aa0e2..6725e29610 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -80,8 +80,8 @@ var/list/faction = list("neutral") //A list of factions that this mob is currently in, for hostile mob targetting, amongst other things var/move_on_shuttle = 1 // Can move on the shuttle. -//The last mob/living/carbon to push/drag/grab this mob (mostly used by slimes friend recognition) - var/mob/living/carbon/LAssailant = null + /// The last mob/living/carbon to push/drag/grab this mob (mostly used by slimes friend recognition) + var/datum/weakref/LAssailant var/list/obj/user_movement_hooks //Passes movement in client/Move() to these! diff --git a/code/modules/recycling/disposal/bin.dm b/code/modules/recycling/disposal/bin.dm index 38b62546a8..78e18a01e2 100644 --- a/code/modules/recycling/disposal/bin.dm +++ b/code/modules/recycling/disposal/bin.dm @@ -137,7 +137,7 @@ else target.visible_message("[user] has placed [target] in [src].", "[user] has placed [target] in [src].") log_combat(user, target, "stuffed", addition="into [src]") - target.LAssailant = user + target.LAssailant = WEAKREF(user) update_icon() /obj/machinery/disposal/proc/can_stuff_mob_in(mob/living/target, mob/living/user, pushing = FALSE) diff --git a/code/modules/research/xenobiology/xenobio_camera.dm b/code/modules/research/xenobiology/xenobio_camera.dm index 9682d404ea..5492e9bc38 100644 --- a/code/modules/research/xenobiology/xenobio_camera.dm +++ b/code/modules/research/xenobiology/xenobio_camera.dm @@ -236,7 +236,7 @@ if(X.monkeys >= 1) var/mob/living/carbon/monkey/food = new /mob/living/carbon/monkey(remote_eye.loc, TRUE, owner) if (!QDELETED(food)) - food.LAssailant = C + food.LAssailant = WEAKREF(C) X.monkeys -- to_chat(owner, "[X] now has [X.monkeys] monkey(s) left.") else @@ -474,7 +474,7 @@ if(X.monkeys >= 1) var/mob/living/carbon/monkey/food = new /mob/living/carbon/monkey(T, TRUE, C) if (!QDELETED(food)) - food.LAssailant = C + food.LAssailant = WEAKREF(C) X.monkeys-- X.monkeys = round(X.monkeys, 0.1) //Prevents rounding errors to_chat(C, "[X] now has [X.monkeys] monkey(s) stored.") From 204311abad44d6b23382cb5a1f16dc7d39e8d528 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 7 Mar 2020 01:06:24 -0700 Subject: [PATCH 2/2] Update code/modules/mob/living/living.dm Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/modules/mob/living/living.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 65f900f768..abe1c3ee76 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -295,7 +295,7 @@ if(!iscarbon(src)) M.LAssailant = null else - M.LAssailant = WEAKREF(src) + M.LAssailant = WEAKREF(usr) if(isliving(M)) var/mob/living/L = M //Share diseases that are spread by touch