From 03314d16c452a7c4fcd1c3c2127c50d952df8018 Mon Sep 17 00:00:00 2001 From: Seth Scherer Date: Mon, 2 May 2022 00:11:26 -0400 Subject: [PATCH] Fixes being able to ride dead space carp (#66530) Removes the ridable element on death, and unbuckles all the mobs --- code/datums/elements/ridable.dm | 9 ++++++++- .../mob/living/simple_animal/hostile/carp.dm | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/code/datums/elements/ridable.dm b/code/datums/elements/ridable.dm index 6b12870474d..daf2c88c9db 100644 --- a/code/datums/elements/ridable.dm +++ b/code/datums/elements/ridable.dm @@ -30,9 +30,11 @@ RegisterSignal(target, COMSIG_MOVABLE_PREBUCKLE, .proc/check_mounting) if(isvehicle(target)) RegisterSignal(target, COMSIG_SPEED_POTION_APPLIED, .proc/check_potion) + if(ismob(target)) + RegisterSignal(target, COMSIG_LIVING_DEATH, .proc/handle_removal) /datum/element/ridable/Detach(datum/target) - UnregisterSignal(target, list(COMSIG_MOVABLE_PREBUCKLE, COMSIG_SPEED_POTION_APPLIED)) + UnregisterSignal(target, list(COMSIG_MOVABLE_PREBUCKLE, COMSIG_SPEED_POTION_APPLIED, COMSIG_LIVING_DEATH)) return ..() /// Someone is buckling to this movable, which is literally the only thing we care about (other than speed potions) @@ -143,8 +145,13 @@ qdel(O) return TRUE +/datum/element/ridable/proc/handle_removal(datum/source) + SIGNAL_HANDLER + var/atom/movable/ridden = source + ridden.unbuckle_all_mobs() + Detach(source) /obj/item/riding_offhand name = "offhand" diff --git a/code/modules/mob/living/simple_animal/hostile/carp.dm b/code/modules/mob/living/simple_animal/hostile/carp.dm index 839af83ffea..c41b19b3711 100644 --- a/code/modules/mob/living/simple_animal/hostile/carp.dm +++ b/code/modules/mob/living/simple_animal/hostile/carp.dm @@ -66,6 +66,8 @@ var/static/list/carp_colors_rare = list( "silver" = "#fdfbf3" ) + /// Is the carp tamed? + var/tamed = FALSE /mob/living/simple_animal/hostile/carp/Initialize(mapload, mob/tamer) AddElement(/datum/element/simple_flying) @@ -83,10 +85,24 @@ else make_tameable() +/mob/living/simple_animal/hostile/carp/revive(full_heal, admin_revive) + if (tamed) + var/datum/weakref/friendref = ai_controller.blackboard[BB_HOSTILE_FRIEND] + var/mob/living/friend = friendref?.resolve() + if(friend) + tamed(friend) + return ..() + +/mob/living/simple_animal/hostile/carp/death(gibbed) + if (tamed) + can_buckle = FALSE + return ..() + /mob/living/simple_animal/hostile/carp/proc/make_tameable() AddComponent(/datum/component/tameable, food_types = list(/obj/item/food/meat), tame_chance = 10, bonus_tame_chance = 5, after_tame = CALLBACK(src, .proc/tamed)) /mob/living/simple_animal/hostile/carp/proc/tamed(mob/living/tamer) + tamed = TRUE can_buckle = TRUE buckle_lying = 0 AddElement(/datum/element/ridable, /datum/component/riding/creature/carp)