From 0c6ed3d5fd0bbbbff944c5e3dfa7602b8b8f929f Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Wed, 18 Oct 2023 19:45:08 +0100 Subject: [PATCH 1/9] implements new egg type and egg handling for eggsac carrier --- code/modules/cm_aliens/structures/egg.dm | 43 +++++++++++++++++++ .../mob/living/carbon/xenomorph/egg_item.dm | 13 ++++-- .../mutators/strains/carrier/eggsac.dm | 35 ++++++++++++++- 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index c23f4f3e2b20..0d81fae1f83f 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -296,3 +296,46 @@ linked_egg.HasProximity(C) if(linked_eggmorph) linked_eggmorph.HasProximity(C) + +/* +SPECIAL EGG USED BY EGG CARRIER +*/ + +#define CARRIER_EGG_UNSUSTAINED_LIFE 1 MINUTES +#define CARRIER_EGG_MAXIMUM_LIFE 5 MINUTES + +/obj/effect/alien/egg/carrier_egg + name = "fragile egg" + desc = "It looks like a weird, fragile egg." + var/owner = null + var/last_refreshed = null + var/life_timer + +/obj/effect/alien/egg/carrier_egg/Initialize(mapload, hivenumber, planter = null) + . = ..() + last_refreshed = world.time + if(!planter) + //If we have no owner when created... this really shouldn't happen but start decaying the egg immediately. + start_unstoppable_decay() + else + //Die after maximum lifetime + life_timer = addtimer(CALLBACK(src, PROC_REF(remove_owner_and_decay)), CARRIER_EGG_MAXIMUM_LIFE, TIMER_STOPPABLE) + +/obj/effect/alien/egg/carrier_egg/proc/remove_owner_and_decay() + if(owner) + var/mob/living/carbon/xenomorph/carrier/my_owner = owner + var/datum/behavior_delegate/carrier_eggsac/my_delegate = my_owner.behavior_delegate + my_delegate.eggs_sustained += src + start_unstoppable_decay() + +/obj/effect/alien/egg/carrier_egg/proc/check_decay() + //Check the last refreshed time and burst the egg if we're over the lifetime of the egg + if(last_refreshed + CARRIER_EGG_UNSUSTAINED_LIFE < world.time) + start_unstoppable_decay() + +/obj/effect/alien/egg/carrier_egg/proc/start_unstoppable_decay() + addtimer(CALLBACK(src, PROC_REF(Burst), TRUE), 10 SECONDS) + deltimer(life_timer) + +#undef CARRIER_EGG_UNSUSTAINED_LIFE +#undef CARRIER_EGG_MAXIMUM_LIFE diff --git a/code/modules/mob/living/carbon/xenomorph/egg_item.dm b/code/modules/mob/living/carbon/xenomorph/egg_item.dm index 77c5548d9f9f..05d456d0025d 100644 --- a/code/modules/mob/living/carbon/xenomorph/egg_item.dm +++ b/code/modules/mob/living/carbon/xenomorph/egg_item.dm @@ -98,7 +98,7 @@ to_chat(user, SPAN_XENOWARNING("[src] must be planted on [lowertext(hive.prefix)]weeds.")) return - if(!hive_weeds) + if(!hive_weeds && user.mutation_type != CARRIER_EGGSAC) to_chat(user, SPAN_XENOWARNING("[src] can only be planted on [lowertext(hive.prefix)]hive weeds.")) return @@ -117,9 +117,16 @@ return for(var/obj/effect/alien/weeds/weed in T) - if(weed.weed_strength >= WEED_LEVEL_HIVE) + if(weed.weed_strength >= WEED_LEVEL_HIVE || user.mutation_type == CARRIER_EGGSAC) user.use_plasma(30) - var/obj/effect/alien/egg/newegg = new /obj/effect/alien/egg(T, hivenumber) + var/obj/effect/alien/egg/newegg + if(weed.weed_strength >= WEED_LEVEL_HIVE) + newegg = new /obj/effect/alien/egg(T, hivenumber) + else if(weed.weed_strength == WEED_LEVEL_STANDARD) + newegg = new /obj/effect/alien/egg/carrier_egg(T,hivenumber, user) + else + to_chat(user, SPAN_XENOWARNING("[src] can't be planted on these weeds.")) + return newegg.flags_embryo = flags_embryo diff --git a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm index 18d28675557e..b010435509a1 100644 --- a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm +++ b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm @@ -1,6 +1,6 @@ /datum/xeno_mutator/eggsac name = "STRAIN: Carrier - Eggsac" - description = "In exchange for your ability to store huggers and place traps, you gain larger plasma stores, strong pheromones, and the ability to lay eggs by using your plasma stores. In addition, you can now carry twelve eggs at once and can place eggs one pace further than normal" + description = "In exchange for your ability to store huggers and place traps, you gain larger plasma stores, strong pheromones, and the ability to lay eggs by using your plasma stores. In addition, you can now carry twelve eggs at once and can place eggs one pace further than normal. You can also place a limited number of eggs on normal weeds." flavor_description = "An egg is always an adventure; the next one may be different." cost = MUTATOR_COST_EXPENSIVE individual_only = TRUE @@ -15,6 +15,7 @@ /datum/action/xeno_action/active_toggle/generate_egg, /datum/action/xeno_action/activable/retrieve_egg, // readding it so it gets at the end of the ability list ) + behavior_delegate_type = /datum/behavior_delegate/carrier_eggsac keystone = TRUE /datum/xeno_mutator/eggsac/apply_mutator(datum/mutator_set/individual_mutators/mutator_set) @@ -40,8 +41,40 @@ carrier.update_eggsac_overlays() carrier.eggs_max = 12 carrier.egg_planting_range = 2 + apply_behavior_holder(carrier) return TRUE +/datum/behavior_delegate/carrier_eggsac + name = "Eggsac Carrier Behavior Delegate" + var/list/eggs_sustained = list() + var/egg_sustain_cap = 4 + var/sustain_distance = 14 + +/datum/behavior_delegate/carrier_eggsac/append_to_stat() + . = "Eggs sustained: [length(eggs_sustained)] / [egg_sustain_cap]" + +/datum/behavior_delegate/carrier_eggsac/on_life() + if(length(eggs_sustained) > egg_sustain_cap) + var/obj/effect/alien/egg/carrier_egg/my_egg = eggs_sustained[1] + my_egg.remove_owner_and_decay() + to_chat(bound_xeno, SPAN_XENOWARNING("You can only sustain [egg_sustain_cap] eggs off hive weeds! Your last placed egg is decaying rapidly.")) + + for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) + //Get the distance from us to our sustained egg + if(get_dist(bound_xeno, my_egg) <= sustain_distance) + my_egg.last_refreshed = world.time + else + my_egg.check_decay() + +/datum/behavior_delegate/carrier_eggsac/handle_death(mob/M) + for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) + my_egg.remove_owner_and_decay() + +/datum/behavior_delegate/carrier_eggsac/Destroy(force, ...) + for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) + my_egg.remove_owner_and_decay() + return ..() + /datum/action/xeno_action/active_toggle/generate_egg name = "Generate Eggs (50)" action_icon_state = "lay_egg" From ed5bda19ca2d54e7121d514cd68da7f8f45d39b8 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Wed, 18 Oct 2023 21:09:20 +0100 Subject: [PATCH 2/9] make add timer null --- code/modules/cm_aliens/structures/egg.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index 0d81fae1f83f..9abd248acd1f 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -309,7 +309,7 @@ SPECIAL EGG USED BY EGG CARRIER desc = "It looks like a weird, fragile egg." var/owner = null var/last_refreshed = null - var/life_timer + var/life_timer = null /obj/effect/alien/egg/carrier_egg/Initialize(mapload, hivenumber, planter = null) . = ..() From 3fa2ce2ab5c8459709ca1b6bc76881c360b24273 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Tue, 31 Oct 2023 19:44:23 +0000 Subject: [PATCH 3/9] adds further egg handling to bursting + fixes planting eggs --- code/modules/cm_aliens/structures/egg.dm | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index 9abd248acd1f..ebbe8c9cd89f 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -320,12 +320,28 @@ SPECIAL EGG USED BY EGG CARRIER else //Die after maximum lifetime life_timer = addtimer(CALLBACK(src, PROC_REF(remove_owner_and_decay)), CARRIER_EGG_MAXIMUM_LIFE, TIMER_STOPPABLE) + set_owner(planter) -/obj/effect/alien/egg/carrier_egg/proc/remove_owner_and_decay() +/obj/effect/alien/egg/carrier_egg/Destroy() + . = ..() + remove_owner() + if(life_timer) + deltimer(life_timer) + +/obj/effect/alien/egg/carrier_egg/proc/set_owner(mob/living/carbon/xenomorph/carrier/planter) + var/datum/behavior_delegate/carrier_eggsac/my_delegate = planter.behavior_delegate + my_delegate.eggs_sustained += src + owner = planter + +/obj/effect/alien/egg/carrier_egg/proc/remove_owner() if(owner) var/mob/living/carbon/xenomorph/carrier/my_owner = owner var/datum/behavior_delegate/carrier_eggsac/my_delegate = my_owner.behavior_delegate - my_delegate.eggs_sustained += src + my_delegate.eggs_sustained -= src + owner = null + +/obj/effect/alien/egg/carrier_egg/proc/remove_owner_and_decay() + remove_owner() start_unstoppable_decay() /obj/effect/alien/egg/carrier_egg/proc/check_decay() @@ -335,7 +351,13 @@ SPECIAL EGG USED BY EGG CARRIER /obj/effect/alien/egg/carrier_egg/proc/start_unstoppable_decay() addtimer(CALLBACK(src, PROC_REF(Burst), TRUE), 10 SECONDS) - deltimer(life_timer) + if(life_timer) + deltimer(life_timer) + +/obj/effect/alien/egg/carrier_egg/Burst(kill, instant_trigger, mob/living/carbon/xenomorph/X, is_hugger_player_controlled) + . = ..() + remove_owner() + #undef CARRIER_EGG_UNSUSTAINED_LIFE #undef CARRIER_EGG_MAXIMUM_LIFE From 9ea31d9be581870dadd4ce3df82a7d0867a7c62c Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Thu, 9 Nov 2023 18:36:04 +0000 Subject: [PATCH 4/9] added description documentation, moved remove owner to behaviour delegate and owner cleanup on qdel --- code/modules/cm_aliens/structures/egg.dm | 27 ++++++------------ .../mutators/strains/carrier/eggsac.dm | 28 ++++++++++++------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index ebbe8c9cd89f..23be30eaef2a 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -307,7 +307,7 @@ SPECIAL EGG USED BY EGG CARRIER /obj/effect/alien/egg/carrier_egg name = "fragile egg" desc = "It looks like a weird, fragile egg." - var/owner = null + var/mob/living/carbon/xenomorph/carrier/owner = null var/last_refreshed = null var/life_timer = null @@ -319,12 +319,11 @@ SPECIAL EGG USED BY EGG CARRIER start_unstoppable_decay() else //Die after maximum lifetime - life_timer = addtimer(CALLBACK(src, PROC_REF(remove_owner_and_decay)), CARRIER_EGG_MAXIMUM_LIFE, TIMER_STOPPABLE) + life_timer = addtimer(CALLBACK(src, PROC_REF(start_unstoppable_decay)), CARRIER_EGG_MAXIMUM_LIFE, TIMER_STOPPABLE) set_owner(planter) /obj/effect/alien/egg/carrier_egg/Destroy() . = ..() - remove_owner() if(life_timer) deltimer(life_timer) @@ -332,20 +331,10 @@ SPECIAL EGG USED BY EGG CARRIER var/datum/behavior_delegate/carrier_eggsac/my_delegate = planter.behavior_delegate my_delegate.eggs_sustained += src owner = planter + RegisterSignal(owner, COMSIG_PARENT_QDELETING, PROC_REF(cleanup_owner)) -/obj/effect/alien/egg/carrier_egg/proc/remove_owner() - if(owner) - var/mob/living/carbon/xenomorph/carrier/my_owner = owner - var/datum/behavior_delegate/carrier_eggsac/my_delegate = my_owner.behavior_delegate - my_delegate.eggs_sustained -= src - owner = null - -/obj/effect/alien/egg/carrier_egg/proc/remove_owner_and_decay() - remove_owner() - start_unstoppable_decay() - +///Check the last refreshed time and burst the egg if we're over the lifetime of the egg /obj/effect/alien/egg/carrier_egg/proc/check_decay() - //Check the last refreshed time and burst the egg if we're over the lifetime of the egg if(last_refreshed + CARRIER_EGG_UNSUSTAINED_LIFE < world.time) start_unstoppable_decay() @@ -356,8 +345,10 @@ SPECIAL EGG USED BY EGG CARRIER /obj/effect/alien/egg/carrier_egg/Burst(kill, instant_trigger, mob/living/carbon/xenomorph/X, is_hugger_player_controlled) . = ..() - remove_owner() + owner = null + +/obj/effect/alien/egg/carrier_egg/proc/cleanup_owner() + SIGNAL_HANDLER + owner = null -#undef CARRIER_EGG_UNSUSTAINED_LIFE -#undef CARRIER_EGG_MAXIMUM_LIFE diff --git a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm index b010435509a1..f6441214fab7 100644 --- a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm +++ b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm @@ -1,6 +1,8 @@ +#define EGGSAC_OFF_WEED_EGGCAP 4 + /datum/xeno_mutator/eggsac name = "STRAIN: Carrier - Eggsac" - description = "In exchange for your ability to store huggers and place traps, you gain larger plasma stores, strong pheromones, and the ability to lay eggs by using your plasma stores. In addition, you can now carry twelve eggs at once and can place eggs one pace further than normal. You can also place a limited number of eggs on normal weeds." + description = "In exchange for your ability to store huggers and place traps, you gain larger plasma stores, strong pheromones, and the ability to lay eggs by using your plasma stores. In addition, you can now carry twelve eggs at once and can place eggs one pace further than normal. \n\nYou can also place a small number of fragile eggs on normal weeds. These eggs have a lifetime of five minutes while you remain within 14 tiles. Or one minute if you leave this range." flavor_description = "An egg is always an adventure; the next one may be different." cost = MUTATOR_COST_EXPENSIVE individual_only = TRUE @@ -47,7 +49,7 @@ /datum/behavior_delegate/carrier_eggsac name = "Eggsac Carrier Behavior Delegate" var/list/eggs_sustained = list() - var/egg_sustain_cap = 4 + var/egg_sustain_cap = EGGSAC_OFF_WEED_EGGCAP var/sustain_distance = 14 /datum/behavior_delegate/carrier_eggsac/append_to_stat() @@ -56,8 +58,9 @@ /datum/behavior_delegate/carrier_eggsac/on_life() if(length(eggs_sustained) > egg_sustain_cap) var/obj/effect/alien/egg/carrier_egg/my_egg = eggs_sustained[1] - my_egg.remove_owner_and_decay() - to_chat(bound_xeno, SPAN_XENOWARNING("You can only sustain [egg_sustain_cap] eggs off hive weeds! Your last placed egg is decaying rapidly.")) + remove_egg_owner(my_egg) + my_egg.start_unstoppable_decay() + to_chat(bound_xeno, SPAN_XENOWARNING("You can only sustain [egg_sustain_cap] eggs off hive weeds! Your oldest placed egg is decaying rapidly.")) for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) //Get the distance from us to our sustained egg @@ -66,14 +69,17 @@ else my_egg.check_decay() -/datum/behavior_delegate/carrier_eggsac/handle_death(mob/M) - for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) - my_egg.remove_owner_and_decay() +///Remove owner of egg +/datum/behavior_delegate/carrier_eggsac/proc/remove_egg_owner(obj/effect/alien/egg/carrier_egg/egg) + if(!egg.owner || egg.owner != bound_xeno) + return + eggs_sustained -= egg + egg.owner = null -/datum/behavior_delegate/carrier_eggsac/Destroy(force, ...) +/datum/behavior_delegate/carrier_eggsac/handle_death(mob/M) for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) - my_egg.remove_owner_and_decay() - return ..() + remove_egg_owner(my_egg) + my_egg.start_unstoppable_decay() /datum/action/xeno_action/active_toggle/generate_egg name = "Generate Eggs (50)" @@ -110,3 +116,5 @@ xeno.eggs_cur++ to_chat(xeno, SPAN_XENONOTICE("You generate a egg. Now sheltering: [xeno.eggs_cur] / [xeno.eggs_max].")) xeno.update_icons() + +#undef EGGSAC_OFF_WEED_EGGCAP From c7e8ff476a2fbae3654794173d38f941a2fcc775 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Thu, 9 Nov 2023 18:39:02 +0000 Subject: [PATCH 5/9] unregisters the signal if we burst and already set owner to null --- code/modules/cm_aliens/structures/egg.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index 23be30eaef2a..73a2788d9a32 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -338,6 +338,7 @@ SPECIAL EGG USED BY EGG CARRIER if(last_refreshed + CARRIER_EGG_UNSUSTAINED_LIFE < world.time) start_unstoppable_decay() +///Burst the egg without hugger release after a 10 second timer & remove the life timer. /obj/effect/alien/egg/carrier_egg/proc/start_unstoppable_decay() addtimer(CALLBACK(src, PROC_REF(Burst), TRUE), 10 SECONDS) if(life_timer) @@ -345,9 +346,9 @@ SPECIAL EGG USED BY EGG CARRIER /obj/effect/alien/egg/carrier_egg/Burst(kill, instant_trigger, mob/living/carbon/xenomorph/X, is_hugger_player_controlled) . = ..() + UnregisterSignal(owner, COMSIG_PARENT_QDELETING) owner = null - /obj/effect/alien/egg/carrier_egg/proc/cleanup_owner() SIGNAL_HANDLER owner = null From 140fadbbf961eac9bfb3185cd71558a2e79eaff6 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Sat, 11 Nov 2023 00:26:09 +0000 Subject: [PATCH 6/9] additional doc, nulls the owner on destroy instead of signal, improvements to append_to_stat() --- code/modules/cm_aliens/structures/egg.dm | 11 +++-------- .../xenomorph/mutators/strains/carrier/eggsac.dm | 3 ++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index 73a2788d9a32..a2d7b9d54f68 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -323,15 +323,16 @@ SPECIAL EGG USED BY EGG CARRIER set_owner(planter) /obj/effect/alien/egg/carrier_egg/Destroy() - . = ..() if(life_timer) deltimer(life_timer) + owner = null + . = ..() +/// Set the owner of the egg to the planter. /obj/effect/alien/egg/carrier_egg/proc/set_owner(mob/living/carbon/xenomorph/carrier/planter) var/datum/behavior_delegate/carrier_eggsac/my_delegate = planter.behavior_delegate my_delegate.eggs_sustained += src owner = planter - RegisterSignal(owner, COMSIG_PARENT_QDELETING, PROC_REF(cleanup_owner)) ///Check the last refreshed time and burst the egg if we're over the lifetime of the egg /obj/effect/alien/egg/carrier_egg/proc/check_decay() @@ -346,10 +347,4 @@ SPECIAL EGG USED BY EGG CARRIER /obj/effect/alien/egg/carrier_egg/Burst(kill, instant_trigger, mob/living/carbon/xenomorph/X, is_hugger_player_controlled) . = ..() - UnregisterSignal(owner, COMSIG_PARENT_QDELETING) owner = null - -/obj/effect/alien/egg/carrier_egg/proc/cleanup_owner() - SIGNAL_HANDLER - owner = null - diff --git a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm index f6441214fab7..af006604f14e 100644 --- a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm +++ b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm @@ -53,7 +53,8 @@ var/sustain_distance = 14 /datum/behavior_delegate/carrier_eggsac/append_to_stat() - . = "Eggs sustained: [length(eggs_sustained)] / [egg_sustain_cap]" + . = list() + . += "Eggs sustained: [length(eggs_sustained)] / [egg_sustain_cap]" /datum/behavior_delegate/carrier_eggsac/on_life() if(length(eggs_sustained) > egg_sustain_cap) From 928154bf45ada30899a4f4295d4d580e8121582f Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Sun, 12 Nov 2023 20:15:15 +0000 Subject: [PATCH 7/9] addressed further review --- code/modules/cm_aliens/structures/egg.dm | 5 ++++- .../xenomorph/mutators/strains/carrier/eggsac.dm | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index a2d7b9d54f68..860fe0d0f2ff 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -307,8 +307,11 @@ SPECIAL EGG USED BY EGG CARRIER /obj/effect/alien/egg/carrier_egg name = "fragile egg" desc = "It looks like a weird, fragile egg." + ///Owner of the fragile egg, must be a mob/living/carbon/xenomorph/carrier var/mob/living/carbon/xenomorph/carrier/owner = null + ///Time that the carrier was last within refresh range of the egg (14 tiles) var/last_refreshed = null + /// Timer holder for the maximum lifetime of the egg as defined CARRIER_EGG_MAXIMUM_LIFE var/life_timer = null /obj/effect/alien/egg/carrier_egg/Initialize(mapload, hivenumber, planter = null) @@ -326,7 +329,7 @@ SPECIAL EGG USED BY EGG CARRIER if(life_timer) deltimer(life_timer) owner = null - . = ..() + return ..() /// Set the owner of the egg to the planter. /obj/effect/alien/egg/carrier_egg/proc/set_owner(mob/living/carbon/xenomorph/carrier/planter) diff --git a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm index af006604f14e..afbc7b968474 100644 --- a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm +++ b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm @@ -1,5 +1,3 @@ -#define EGGSAC_OFF_WEED_EGGCAP 4 - /datum/xeno_mutator/eggsac name = "STRAIN: Carrier - Eggsac" description = "In exchange for your ability to store huggers and place traps, you gain larger plasma stores, strong pheromones, and the ability to lay eggs by using your plasma stores. In addition, you can now carry twelve eggs at once and can place eggs one pace further than normal. \n\nYou can also place a small number of fragile eggs on normal weeds. These eggs have a lifetime of five minutes while you remain within 14 tiles. Or one minute if you leave this range." @@ -46,11 +44,17 @@ apply_behavior_holder(carrier) return TRUE +#define EGGSAC_OFF_WEED_EGGCAP 4 +#define EGGSAC_EGG_SUSTAIN_DISTANCE 14 + /datum/behavior_delegate/carrier_eggsac name = "Eggsac Carrier Behavior Delegate" + ///List of /obj/effect/alien/egg/carrier_egg sustained by the carrier on normal weeds var/list/eggs_sustained = list() + ///Total number of eggs which can be sustained defined as EGGSAC_OFF_WEED_EGGCAP var/egg_sustain_cap = EGGSAC_OFF_WEED_EGGCAP - var/sustain_distance = 14 + ///Distance from the egg that the carrier can go before it stops sustaining it + var/sustain_distance = EGGSAC_EGG_SUSTAIN_DISTANCE /datum/behavior_delegate/carrier_eggsac/append_to_stat() . = list() @@ -119,3 +123,4 @@ xeno.update_icons() #undef EGGSAC_OFF_WEED_EGGCAP +#undef EGGSAC_EGG_SUSTAIN_DISTANCE From c2e15cd0e2f3d4dc2238ccd76b92195b8e2a89f8 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Thu, 16 Nov 2023 23:35:10 +0000 Subject: [PATCH 8/9] adds some Destroy() stuff I thought was needed --- code/modules/cm_aliens/structures/egg.dm | 7 ++++++- .../carbon/xenomorph/mutators/strains/carrier/eggsac.dm | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/code/modules/cm_aliens/structures/egg.dm b/code/modules/cm_aliens/structures/egg.dm index 860fe0d0f2ff..ce0be7c0c8a1 100644 --- a/code/modules/cm_aliens/structures/egg.dm +++ b/code/modules/cm_aliens/structures/egg.dm @@ -328,7 +328,12 @@ SPECIAL EGG USED BY EGG CARRIER /obj/effect/alien/egg/carrier_egg/Destroy() if(life_timer) deltimer(life_timer) - owner = null + //Remove reference to src in owner's behavior_delegate and set owner to null + if(owner) + var/mob/living/carbon/xenomorph/carrier/my_owner = owner + var/datum/behavior_delegate/carrier_eggsac/behavior = my_owner.behavior_delegate + behavior.eggs_sustained -= src + my_owner = null return ..() /// Set the owner of the egg to the planter. diff --git a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm index afbc7b968474..9959a4bc952f 100644 --- a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm +++ b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm @@ -86,6 +86,11 @@ remove_egg_owner(my_egg) my_egg.start_unstoppable_decay() +///Remove all references to src in eggs_sustained +/datum/behavior_delegate/carrier_eggsac/Destroy() + for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) + my_egg.owner = null + /datum/action/xeno_action/active_toggle/generate_egg name = "Generate Eggs (50)" action_icon_state = "lay_egg" From 32deb028f3f25f61c76a747dd2f7dcdc6bb2276f Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Sat, 25 Nov 2023 21:38:37 +0000 Subject: [PATCH 9/9] destroy parent --- .../living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm index 9959a4bc952f..f7b353cd0173 100644 --- a/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm +++ b/code/modules/mob/living/carbon/xenomorph/mutators/strains/carrier/eggsac.dm @@ -90,6 +90,7 @@ /datum/behavior_delegate/carrier_eggsac/Destroy() for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained) my_egg.owner = null + return ..() /datum/action/xeno_action/active_toggle/generate_egg name = "Generate Eggs (50)"