From dfb5d07b88a093e794898ba4b7a90099eeb7859a Mon Sep 17 00:00:00 2001
From: Ghom <42542238+Ghommie@users.noreply.github.com>
Date: Sat, 9 Nov 2024 04:07:55 +0100
Subject: [PATCH] Fixed fishing rod duping with poly belts and shapeshift
spells. (#87706)
## About The Pull Request
It turns out the "shapeshifted from spell" status ejects everything
inside the shapeshifted mob when removed. That's been causing a little
issue with the fishing rod from the profound_fisher component, which a
few mobs have. This PR fixes just that.
## Why It's Good For The Game


## Changelog
:cl:
fix: Fixed fishing rod duping with poly belts and shapeshift spells.
spellcheck: Fixed a small typo when examining fishing rods.
/:cl:
---
code/datums/components/profound_fisher.dm | 29 ++++++++++++++-----
code/modules/fishing/fishing_rod.dm | 2 +-
code/modules/mod/modules/modules_general.dm | 2 +-
.../spell_types/shapeshift/_shape_status.dm | 2 +-
4 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/code/datums/components/profound_fisher.dm b/code/datums/components/profound_fisher.dm
index 9638af4a8f2..cc7e87aeb40 100644
--- a/code/datums/components/profound_fisher.dm
+++ b/code/datums/components/profound_fisher.dm
@@ -2,15 +2,18 @@
/datum/component/profound_fisher
///the fishing rod this mob will use
var/obj/item/fishing_rod/mob_fisher/our_rod
+ ///Wether we should delete the fishing rod along with the component or replace it if it's somehow removed from the parent
+ var/delete_rod_when_deleted = TRUE
-/datum/component/profound_fisher/Initialize(our_rod)
+/datum/component/profound_fisher/Initialize(our_rod, delete_rod_when_deleted = TRUE)
var/isgloves = istype(parent, /obj/item/clothing/gloves)
if(!isliving(parent) && !isgloves)
return COMPONENT_INCOMPATIBLE
src.our_rod = our_rod || new(parent)
src.our_rod.internal = TRUE
+ src.delete_rod_when_deleted = delete_rod_when_deleted
ADD_TRAIT(src.our_rod, TRAIT_NOT_BARFABLE, REF(src))
- RegisterSignal(src.our_rod, COMSIG_QDELETING, PROC_REF(on_rod_qdel))
+ RegisterSignal(src.our_rod, COMSIG_MOVABLE_MOVED, PROC_REF(on_rod_moved))
if(!isgloves)
RegisterSignal(parent, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack))
@@ -37,14 +40,26 @@
examine_list += span_info("When [EXAMINE_HINT("held")] or [EXAMINE_HINT("equipped")], [EXAMINE_HINT("right-click")] with a empty hand to open the integrated fishing rod interface.")
examine_list += span_tinynoticeital("To fish, you need to turn combat mode off.")
-/datum/component/profound_fisher/proc/on_rod_qdel(datum/source)
+///Handles replacing the fishing rod if somehow removed from the parent movable if delete_rod_when_deleted is TRUE, otherwise delete the component.
+/datum/component/profound_fisher/proc/on_rod_moved(datum/source)
SIGNAL_HANDLER
- qdel(src)
+ if(QDELETED(src) || our_rod.loc == parent)
+ return
+ if(delete_rod_when_deleted)
+ UnregisterSignal(our_rod, COMSIG_MOVABLE_MOVED)
+ if(!QDELETED(our_rod))
+ qdel(our_rod)
+ our_rod = new our_rod.type(parent)
+ else
+ qdel(src)
/datum/component/profound_fisher/Destroy()
- our_rod.internal = FALSE
- UnregisterSignal(our_rod, COMSIG_QDELETING)
- REMOVE_TRAIT(our_rod, TRAIT_NOT_BARFABLE, REF(src))
+ UnregisterSignal(our_rod, COMSIG_MOVABLE_MOVED)
+ if(!delete_rod_when_deleted)
+ our_rod.internal = FALSE
+ REMOVE_TRAIT(our_rod, TRAIT_NOT_BARFABLE, REF(src))
+ else if(!QDELETED(our_rod))
+ QDEL_NULL(our_rod)
our_rod = null
return ..()
diff --git a/code/modules/fishing/fishing_rod.dm b/code/modules/fishing/fishing_rod.dm
index 8b24e34b9e5..4bd045616b3 100644
--- a/code/modules/fishing/fishing_rod.dm
+++ b/code/modules/fishing/fishing_rod.dm
@@ -122,7 +122,7 @@
if(hook)
equipped_stuff += "[icon2html(hook, user)] [hook.name]"
if(bait)
- equipped_stuff += "[icon2html(bait, user)] [bait] as bait."
+ equipped_stuff += "[icon2html(bait, user)] [bait]"
if(length(equipped_stuff))
. += span_notice("It has \a [english_list(equipped_stuff)] equipped.")
if(!bait)
diff --git a/code/modules/mod/modules/modules_general.dm b/code/modules/mod/modules/modules_general.dm
index 14fc328aed7..42e4c56f55e 100644
--- a/code/modules/mod/modules/modules_general.dm
+++ b/code/modules/mod/modules/modules_general.dm
@@ -985,7 +985,7 @@
return
gloves.AddComponent(/datum/component/adjust_fishing_difficulty, 5)
if(equipped)
- gloves.AddComponent(/datum/component/profound_fisher, equipped)
+ gloves.AddComponent(/datum/component/profound_fisher, equipped, delete_rod_when_deleted = FALSE)
/obj/item/mod/module/fishing_glove/on_part_deactivation(deleting = FALSE)
var/obj/item/gloves = mod.get_part_from_slot(ITEM_SLOT_GLOVES)
diff --git a/code/modules/spells/spell_types/shapeshift/_shape_status.dm b/code/modules/spells/spell_types/shapeshift/_shape_status.dm
index 2f8d53eeac2..f8f44817a59 100644
--- a/code/modules/spells/spell_types/shapeshift/_shape_status.dm
+++ b/code/modules/spells/spell_types/shapeshift/_shape_status.dm
@@ -194,7 +194,7 @@
if(owner?.contents)
// Prevent round removal and consuming stuff when losing shapeshift
for(var/atom/movable/thing as anything in owner.contents)
- if(thing == caster_mob)
+ if(thing == caster_mob || HAS_TRAIT(thing, TRAIT_NOT_BARFABLE))
continue
thing.forceMove(get_turf(owner))