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
57 changes: 57 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,60 @@
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/mob/living/carbon/xenomorph/carrier/owner = null
Birdtalon marked this conversation as resolved.
Show resolved Hide resolved
var/last_refreshed = null
var/life_timer = null
Copy link
Contributor

Choose a reason for hiding this comment

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

code doc these


/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(start_unstoppable_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

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
RegisterSignal(owner, COMSIG_PARENT_QDELETING, PROC_REF(cleanup_owner))
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to do this, you can just do the destroy bit i mentioned above


///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()
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)
deltimer(life_timer)

/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()
Copy link
Contributor

Choose a reason for hiding this comment

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

code doc

SIGNAL_HANDLER
owner = null

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,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"
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
Expand All @@ -15,6 +17,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 +43,44 @@
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 = EGGSAC_OFF_WEED_EGGCAP
var/sustain_distance = 14
Copy link
Contributor

Choose a reason for hiding this comment

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

code doc


/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]
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
if(get_dist(bound_xeno, my_egg) <= sustain_distance)
my_egg.last_refreshed = world.time
else
my_egg.check_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/handle_death(mob/M)
for(var/obj/effect/alien/egg/carrier_egg/my_egg as anything in eggs_sustained)
remove_egg_owner(my_egg)
my_egg.start_unstoppable_decay()

/datum/action/xeno_action/active_toggle/generate_egg
name = "Generate Eggs (50)"
action_icon_state = "lay_egg"
Expand Down Expand Up @@ -77,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