Skip to content

Commit

Permalink
Fertile refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben10083 committed Sep 15, 2024
1 parent 9bc0bc5 commit 2671f9a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
5 changes: 4 additions & 1 deletion code/modules/mob/living/simple_animal/friendly/adhomai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
if(!stat && prob(3) && eggsleft > 0 && (gender = FEMALE))
visible_message("[src] lays an egg.")
eggsleft--
new /obj/item/reagent_containers/food/snacks/egg/ice_tunnelers(get_turf(src))
var/obj/item/reagent_containers/food/snacks/egg/ice_tunnelers/egg = new /obj/item/reagent_containers/food/snacks/egg/ice_tunnelers(get_turf(src))
egg.fertilize()
egg.pixel_x = rand(-6,6)
egg.pixel_y = rand(-6,6)

/mob/living/simple_animal/ice_tunneler/male
icon_state = "tunneler_m"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@
if(!stat && prob(3) && eggsleft > 0 && chicken_count < MAX_CHICKENS)
visible_message("[src] [pick("lays an egg.","squats down and croons.","begins making a huge racket.","begins clucking raucously.")]")
eggsleft--
var/obj/item/reagent_containers/food/snacks/egg/E = new(get_turf(src), TRUE)
var/obj/item/reagent_containers/food/snacks/egg/E = new(get_turf(src))
E.fertilize()
E.pixel_x = rand(-6,6)
E.pixel_y = rand(-6,6)

Expand Down
5 changes: 4 additions & 1 deletion code/modules/mob/living/simple_animal/friendly/schlorrgo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@
return
visible_message("[src] lays an egg.")
eggs_left--
new /obj/item/reagent_containers/food/snacks/egg/schlorrgo(get_turf(src), TRUE)
var/obj/item/reagent_containers/food/snacks/egg/schlorrgo/egg = new /obj/item/reagent_containers/food/snacks/egg/schlorrgo(get_turf(src))
egg.fertilize()
egg.pixel_x = rand(-6,6)
egg.pixel_y = rand(-6,6)

/mob/living/simple_animal/schlorrgo/unarmed_harm_attack(mob/living/carbon/human/user)
var/obj/item/organ/external/left_leg = user.get_organ(BP_L_LEG)
Expand Down
16 changes: 9 additions & 7 deletions code/modules/reagents/reagent_containers/food/snacks/eggs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
filling_color = "#FDFFD1"
volume = 10
reagents_to_add = list(/singleton/reagent/nutriment/protein/egg = 3)
/// What can be hatched from this egg
var/hatchling = /mob/living/simple_animal/chick
/// If set to TRUE, egg is currently growing and will eventually spawn a hatchling if left alone on a turf.
/// Set to TRUE for eggs mapped in, but meant to be able to hatch.
var/fertile = FALSE

/obj/item/reagent_containers/food/snacks/egg/Initialize(mapload, fertile = FALSE)
/obj/item/reagent_containers/food/snacks/egg/Initialize(mapload)
. = ..()
if(fertile) // If fertile, start processing so it can grow
START_PROCESSING(SSprocessing, src)
if(fertile)
egg.fertilize()

/obj/item/reagent_containers/food/snacks/egg/afterattack(obj/O as obj, mob/user as mob, proximity)
if(!(proximity && O.is_open_container()))
Expand Down Expand Up @@ -49,8 +53,9 @@
var/amount_grown = 0

/// Call this proc to have the given egg start growing. Should only be called if hatching is set
/obj/item/reagent_containers/food/snacks/egg/proc/start_growing()
/obj/item/reagent_containers/food/snacks/egg/proc/fertilize()
if(hatchling)
fertile = TRUE
START_PROCESSING(SSprocessing,src)

/// Handles hatching. Eggs only grow when on a turf.
Expand Down Expand Up @@ -104,9 +109,6 @@
reagents_to_add = list(/singleton/reagent/nutriment/protein/egg = 6) // Big egg
hatchling = /mob/living/simple_animal/schlorrgo/baby

/obj/item/reagent_containers/food/snacks/egg/schlorrgo/fertile/Initialize(mapload, fertile) // Snowflake subtype due to cargo code unable to insert values into an Initialize
return ..(mapload, TRUE)

/obj/item/reagent_containers/food/snacks/egg/ice_tunnelers
name = "ice tunneler egg"
desc = "An egg laid by an Adhomian animal."
Expand Down
16 changes: 12 additions & 4 deletions maps/random_ruins/exoplanets/adhomai/adhomai_schlorrgo_cage.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@
dir = 8
},
/obj/structure/closet/crate/freezer,
/obj/item/reagent_containers/food/snacks/egg/schlorrgo,
/obj/item/reagent_containers/food/snacks/egg/schlorrgo,
/obj/item/reagent_containers/food/snacks/egg/schlorrgo,
/obj/item/reagent_containers/food/snacks/egg/schlorrgo,
/obj/item/reagent_containers/food/snacks/egg/schlorrgo{
fertile = 1
},
/obj/item/reagent_containers/food/snacks/egg/schlorrgo{
fertile = 1
},
/obj/item/reagent_containers/food/snacks/egg/schlorrgo{
fertile = 1
},
/obj/item/reagent_containers/food/snacks/egg/schlorrgo{
fertile = 1
},
/turf/simulated/floor/concrete/square,
/area/adhomai_schlorrgo_cage)
"f" = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
var/mob/living/carbon/human/H = user
var/obj/item/reagent_containers/food/snacks/egg/ice_tunnelers/E = new/obj/item/reagent_containers/food/snacks/egg/ice_tunnelers (get_turf(src), TRUE)
H.put_in_hands(E)
E.fertilize()
eggs--
update_icon()

0 comments on commit 2671f9a

Please sign in to comment.