Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eggsac carrier revival #4716

Merged
merged 9 commits into from
Nov 27, 2023
65 changes: 65 additions & 0 deletions code/modules/cm_aliens/structures/egg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,68 @@
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
fira marked this conversation as resolved.
Show resolved Hide resolved
var/last_refreshed = null
var/life_timer = null

/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)
set_owner(planter)
fira marked this conversation as resolved.
Show resolved Hide resolved

/obj/effect/alien/egg/carrier_egg/Destroy()
. = ..()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call parent at the end of destroy

remove_owner()
if(life_timer)
deltimer(life_timer)

/obj/effect/alien/egg/carrier_egg/proc/set_owner(mob/living/carbon/xenomorph/carrier/planter)
Birdtalon marked this conversation as resolved.
Show resolved Hide resolved
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
owner = null
fira marked this conversation as resolved.
Show resolved Hide resolved

/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()
//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)
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
13 changes: 10 additions & 3 deletions code/modules/mob/living/carbon/xenomorph/egg_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure it's = instead of +=?

Copy link
Contributor Author

@Birdtalon Birdtalon Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it actually matters in this case. But comparing it to the same functionality on other behavior delegates I should be consistent with them, also returning it as a list.


/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"
Expand Down
Loading