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