From baad78e7fe8ed95cd890de290306cd0d8e51d793 Mon Sep 17 00:00:00 2001 From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Fri, 11 Jun 2021 16:08:55 +0100 Subject: [PATCH 1/2] bee --- code/datums/elements/mob_holder.dm | 13 ++++++++++++- .../mob/living/simple_animal/hostile/bees.dm | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/code/datums/elements/mob_holder.dm b/code/datums/elements/mob_holder.dm index f73826d899..962ed3d63f 100644 --- a/code/datums/elements/mob_holder.dm +++ b/code/datums/elements/mob_holder.dm @@ -7,8 +7,9 @@ var/left_hand var/inv_slots var/proctype //if present, will be invoked on headwear generation. + var/escape_on_find = FALSE //if present, will be released upon the item being 'found' (i.e. opening a container or pocket with it present) -/datum/element/mob_holder/Attach(datum/target, worn_state, alt_worn, right_hand, left_hand, inv_slots = NONE, proctype) +/datum/element/mob_holder/Attach(datum/target, worn_state, alt_worn, right_hand, left_hand, inv_slots = NONE, proctype, escape_on_find) . = ..() if(!isliving(target)) @@ -20,6 +21,7 @@ src.left_hand = left_hand src.inv_slots = inv_slots src.proctype = proctype + src.escape_on_find = escape_on_find RegisterSignal(target, COMSIG_CLICK_ALT, .proc/mob_try_pickup) RegisterSignal(target, COMSIG_PARENT_EXAMINE, .proc/on_examine) @@ -55,6 +57,8 @@ to_chat(user, "You pick [source] up.") source.drop_all_held_items() var/obj/item/clothing/head/mob_holder/holder = new(get_turf(source), source, worn_state, alt_worn, right_hand, left_hand, inv_slots) + holder.escape_on_find = escape_on_find + if(proctype) INVOKE_ASYNC(src, proctype, source, holder, user) user.put_in_hands(holder) @@ -78,6 +82,7 @@ w_class = WEIGHT_CLASS_BULKY dynamic_hair_suffix = "" var/mob/living/held_mob + var/escape_on_find /obj/item/clothing/head/mob_holder/Initialize(mapload, mob/living/target, worn_state, alt_worn, right_hand, left_hand, slots = NONE) . = ..() @@ -189,3 +194,9 @@ if(ismob(location)) return location.loc.remove_air(amount) return location.remove_air(amount) + +// escape when found if applicable +/obj/item/clothing/head/mob_holder/on_find(mob/living/finder) + if(escape_on_find) + finder.visible_message("[finder] accidentally releases the [held_mob]!") + release() diff --git a/code/modules/mob/living/simple_animal/hostile/bees.dm b/code/modules/mob/living/simple_animal/hostile/bees.dm index 0a3cde3ef8..399a403ce7 100644 --- a/code/modules/mob/living/simple_animal/hostile/bees.dm +++ b/code/modules/mob/living/simple_animal/hostile/bees.dm @@ -58,12 +58,17 @@ var/icon_base = "bee" var/static/beehometypecache = typecacheof(/obj/structure/beebox) var/static/hydroponicstypecache = typecacheof(/obj/machinery/hydroponics) + var/held_icon = "" // bees are small and have no held icon (aka the coder doesn't know how to sprite it) /mob/living/simple_animal/hostile/poison/bees/Initialize() . = ..() generate_bee_visuals() AddComponent(/datum/component/swarming) +/mob/living/simple_animal/hostile/poison/bees/ComponentInitialize() + . = ..() + AddElement(/datum/element/mob_holder, held_icon, escape_on_find = TRUE) + /mob/living/simple_animal/hostile/poison/bees/Destroy() if(beehome) beehome.bees -= src From e78929cde150e908bf7cdf6ca33758e627f87587 Mon Sep 17 00:00:00 2001 From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Fri, 11 Jun 2021 17:55:38 +0100 Subject: [PATCH 2/2] typo --- code/datums/elements/mob_holder.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/elements/mob_holder.dm b/code/datums/elements/mob_holder.dm index 962ed3d63f..92ee9be7d2 100644 --- a/code/datums/elements/mob_holder.dm +++ b/code/datums/elements/mob_holder.dm @@ -196,7 +196,7 @@ return location.remove_air(amount) // escape when found if applicable -/obj/item/clothing/head/mob_holder/on_find(mob/living/finder) +/obj/item/clothing/head/mob_holder/on_found(mob/living/finder) if(escape_on_find) finder.visible_message("[finder] accidentally releases the [held_mob]!") release()