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

Pregnancy additions: Job items and machines #865

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__SPLURTCODE/DEFINES/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define COMSIG_ORGAN_REMOVED "organ_removed"
#define COMSIG_MOB_CLIMAX "mob_coomed"
#define COMSIG_OBJ_WRITTEN_ON "written_on"
#define COMSIG_MACHINERY_INCUBATOR_PROCESS "incubator_proc"

#define COMSIG_MOB_GENITAL_TRY_INSERTING "mob_genital_try_inserting" //Handles external restrictions to the inserting

Expand Down
135 changes: 85 additions & 50 deletions modular_splurt/code/datums/components/pregnancy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

var/obj/item/organ/container
var/mob/living/carrier
var/obj/machinery/incubator/incubator_carrier

var/datum/dna/father_dna
var/datum/dna/mother_dna

var/list/mother_features
var/list/father_features
var/datum/dna/egg_dna
var/list/egg_features = list()

var/mother_name

Expand Down Expand Up @@ -56,36 +54,11 @@
if(nads.owner)
carrier = nads.owner

if(iscarbon(_father))
var/mob/living/carbon/cardad = _father
father_dna = new
cardad.dna.copy_dna(father_dna)

if(iscarbon(_mother))
var/mob/living/carbon/carmom = _mother
mother_dna = new
carmom.dna.copy_dna(mother_dna)
determine_egg_dna(_mother, _father)
determine_egg_features(_mother, _father)

mother_name = _mother.real_name

if(ishuman(_father))
var/mob/living/carbon/human/cardad = _father
LAZYINITLIST(father_features)
father_features["skin_tone"] = cardad.skin_tone
father_features["hair_color"] = cardad.hair_color
father_features["facial_hair_color"] = cardad.facial_hair_color
father_features["left_eye_color"] = cardad.left_eye_color
father_features["right_eye_color"] = cardad.right_eye_color

if(ishuman(_mother))
var/mob/living/carbon/human/carmom = _mother
LAZYINITLIST(mother_features)
mother_features["skin_tone"] = carmom.skin_tone
mother_features["hair_color"] = carmom.hair_color
mother_features["facial_hair_color"] = carmom.facial_hair_color
mother_features["left_eye_color"] = carmom.left_eye_color
mother_features["right_eye_color"] = carmom.right_eye_color

pregnancy_inflation = carrier?.client?.prefs?.pregnancy_inflation

pregnancy_breast_growth = carrier?.client?.prefs?.pregnancy_breast_growth
Expand Down Expand Up @@ -120,6 +93,12 @@
if(oviposition)
RegisterSignal(carrier, COMSIG_MOB_CLIMAX, .proc/on_climax)

/datum/component/pregnancy/proc/register_machine()
RegisterSignal(incubator_carrier, COMSIG_MACHINERY_INCUBATOR_PROCESS, .proc/handle_machine_incubator)

/datum/component/pregnancy/proc/unregister_machine()
UnregisterSignal(incubator_carrier, COMSIG_MACHINERY_INCUBATOR_PROCESS, .proc/handle_machine_incubator)

/datum/component/pregnancy/proc/unregister_carrier()
UnregisterSignal(carrier, COMSIG_MOB_DEATH)
UnregisterSignal(carrier, COMSIG_LIVING_BIOLOGICAL_LIFE)
Expand All @@ -132,6 +111,60 @@
generic_pragency_end()
return ..()


/datum/component/pregnancy/proc/determine_egg_dna(mob/living/_mother, mob/living/_father)
var/mob/living/carbon/father = _father
var/mob/living/carbon/mother = _mother
if(iscarbon(father) && iscarbon(_mother))
egg_dna = mother.dna.transfer_identity_random_dna_only(father.dna)
else if(iscarbon(father))
egg_dna = new
egg_dna.initialize_dna()
egg_dna = father.dna.transfer_identity_random_dna_only(egg_dna)
else if(iscarbon(mother))
egg_dna = new
egg_dna.initialize_dna()
egg_dna = mother.dna.transfer_identity_random_dna_only(egg_dna)

/datum/component/pregnancy/proc/determine_egg_features(mob/living/_mother, mob/living/_father)
if(ishuman(_father) && ishuman(_mother))
var/mob/living/carbon/human/cardad = _father
var/mob/living/carbon/human/carmom = _mother
var/list/father_features = list()
var/list/mother_features = list()

father_features["skin_tone"] = cardad.skin_tone
father_features["hair_color"] = cardad.hair_color
father_features["facial_hair_color"] = cardad.facial_hair_color
father_features["left_eye_color"] = cardad.left_eye_color
father_features["right_eye_color"] = cardad.right_eye_color

mother_features["skin_tone"] = carmom.skin_tone
mother_features["hair_color"] = carmom.hair_color
mother_features["facial_hair_color"] = carmom.facial_hair_color
mother_features["left_eye_color"] = carmom.left_eye_color
mother_features["right_eye_color"] = carmom.right_eye_color

transfer_randomized_list(egg_features, mother_features, father_features)

else if(ishuman(_father))
var/mob/living/carbon/human/cardad = _father

egg_features["skin_tone"] = cardad.skin_tone
egg_features["hair_color"] = cardad.hair_color
egg_features["facial_hair_color"] = cardad.facial_hair_color
egg_features["left_eye_color"] = cardad.left_eye_color
egg_features["right_eye_color"] = cardad.right_eye_color

else if(ishuman(_mother))
var/mob/living/carbon/human/carmom = _mother

egg_features["skin_tone"] = carmom.skin_tone
egg_features["hair_color"] = carmom.hair_color
egg_features["facial_hair_color"] = carmom.facial_hair_color
egg_features["left_eye_color"] = carmom.left_eye_color
egg_features["right_eye_color"] = carmom.right_eye_color

/datum/component/pregnancy/proc/name_egg(datum/source, name)
SIGNAL_HANDLER

Expand Down Expand Up @@ -172,11 +205,25 @@
pregnancy_breast_growth = carrier.client?.prefs?.pregnancy_breast_growth
register_carrier()
generic_pragency_start()
else if(istype(destination, /obj/machinery/incubator))
var/obj/machinery/incubator/inc = destination
incubator_carrier = inc
register_machine()
else if(carrier)
generic_pragency_end()
unregister_carrier()
unregister_machine()
carrier = null
container = null
incubator_carrier = null

/datum/component/pregnancy/proc/handle_machine_incubator()
SIGNAL_HANDLER

if(COOLDOWN_FINISHED(src, stage_time))
stage += 1
stage = min(stage, max_stage)
COOLDOWN_START(src, stage_time, PREGNANCY_STAGE_DURATION)

/datum/component/pregnancy/proc/handle_life(seconds)
SIGNAL_HANDLER
Expand Down Expand Up @@ -346,29 +393,17 @@

//not how genetics work but okay
/datum/component/pregnancy/proc/determine_baby_dna(mob/living/carbon/human/babby)
if(mother_dna && father_dna)
mother_dna.transfer_identity_random(father_dna, babby)
else if(mother_dna && !father_dna)
mother_dna.transfer_identity_random(babby.dna, babby)
else if(!mother_dna && father_dna)
father_dna.transfer_identity_random(babby.dna, babby)
egg_dna.transfer_identity(babby)

/datum/component/pregnancy/proc/determine_baby_features(mob/living/carbon/human/babby)

var/list/final_features = list()

transfer_randomized_list(final_features, mother_features, father_features)

if(final_features["skin_tone"])
babby.skin_tone = final_features["skin_tone"]
if(final_features["hair_color"])
babby.hair_color = final_features["hair_color"]
if(final_features["facial_hair_color"])
babby.facial_hair_color = final_features["facial_hair_color"]
if(final_features["left_eye_color"])
babby.left_eye_color = final_features["left_eye_color"]
if(final_features["right_eye_color"])
babby.right_eye_color = final_features["right_eye_color"]
babby.skin_tone = egg_features["skin_tone"]
babby.hair_color = egg_features["hair_color"]
babby.facial_hair_color = egg_features["facial_hair_color"]
babby.left_eye_color = egg_features["left_eye_color"]
babby.right_eye_color = egg_features["right_eye_color"]

babby.hair_style = pick("Bedhead", "Bedhead 2", "Bedhead 3")
babby.facial_hair_style = "Shaved"
Expand Down
24 changes: 24 additions & 0 deletions modular_splurt/code/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@

if(prob(50))
destination.set_species(species.type, FALSE)
destination.dna.species = new species.type
destination.dna.species.say_mod = species.say_mod
destination.dna.custom_species = custom_species
else
destination.set_species(second_set.species.type, FALSE)
destination.dna.species = new second_set.species.type
destination.dna.species.say_mod = second_set.species.say_mod
destination.dna.custom_species = second_set.custom_species

Expand All @@ -113,4 +115,26 @@

destination.updateappearance(icon_update=TRUE, mutcolor_update=TRUE, mutations_overlay_update=TRUE)

/datum/dna/proc/transfer_identity_random_dna_only(datum/dna/second_set)
var/datum/dna/destination= new

TRANSFER_RANDOMIZED(destination.blood_type, blood_type, second_set.blood_type)
TRANSFER_RANDOMIZED(destination.skin_tone_override, skin_tone_override, second_set.skin_tone_override)
transfer_randomized_list(destination.features, features, second_set.features)
transfer_randomized_list(destination.temporary_mutations, temporary_mutations, second_set.temporary_mutations)

if(prob(50))
destination.species = new species.type
destination.species.say_mod = species.say_mod
destination.custom_species = custom_species
else
destination.species = new second_set.species.type
destination.species.say_mod = second_set.species.say_mod
destination.custom_species = second_set.custom_species

destination.update_dna_identity()
destination.generate_dna_blocks()

return destination

#undef TRANSFER_RANDOMIZED
101 changes: 101 additions & 0 deletions modular_splurt/code/game/machinery/embryonator.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#define DUMMY_HUMAN_SLOT_DAYCARE "dummy_daycare"
/obj/machinery/embryonator
name = "Honeystone's Genetic Daycare"
desc = "A machine used to modify an egg's genetics. It has a nursery theme to it"
density = TRUE
layer = BELOW_OBJ_LAYER
icon = 'modular_splurt/icons/obj/machinery/honeystones_genetic_daycare.dmi'
icon_state = "empty"
use_power = ACTIVE_POWER_USE
active_power_usage = 150
resistance_flags = FIRE_PROOF | ACID_PROOF
circuit = /obj/item/circuitboard/machine/embryonator
var/icon/child_image
var/obj/item/embryo_egg


/obj/machinery/embryonator/update_icon_state()
if((!is_operational()) || (!is_on))
if (panel_open)
icon_state = "panel_open"
else
icon_state = "empty"
else
if(embryo_egg)
icon_state = "inserted"
else
icon_state = "empty"

/obj/machinery/embryonator/attackby(obj/item/I, mob/user, params)
if(default_deconstruction_screwdriver(user, "panel-open", "empty", I))
return

else if(default_deconstruction_crowbar(I))
return

if(default_unfasten_wrench(user, I))
return

if(embryo_egg)
to_chat(user, span_warning("You can't insert [I] into [src], there is already an egg inside the machine"))
return ..()

if(!I.GetComponent(/datum/component/pregnancy))
to_chat(user, span_warning("You can't insert [I] into [src], the machine only accepts viable eggs"))
return ..()

. = TRUE // no afterattack
if(panel_open)
to_chat(user, "<span class='warning'>You can't use the [src.name] while its panel is opened!</span>")
return
if(!user.transferItemToLoc(I, src))
return
to_chat(user, "<span class='notice'>You add [I] to [src].</span>")
update_icon()

embryo_egg = I
var/datum/component/pregnancy/preggo = I.GetComponent(/datum/component/pregnancy)
var/mob/living/carbon/human/dummy/mannequin = generate_or_wait_for_human_dummy(DUMMY_HUMAN_SLOT_HALLUCINATION)
mannequin.setDir(NORTH)
preggo.determine_baby_features(mannequin)
preggo.determine_baby_dna(mannequin)
mannequin.update_appearance()
child_image = getFlatIcon(mannequin)
unset_busy_human_dummy(DUMMY_HUMAN_SLOT_DAYCARE)

/obj/machinery/embryonator/Destroy()
embryo_egg = null
for(var/obj/item/viable_egg in contents)
viable_egg.forceMove(get_turf(src))
. = ..()

/obj/machinery/embryonator/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Daycare")
ui.open()
ui.set_autoupdate(FALSE)

/obj/machinery/embryonator/ui_static_data(mob/user)
. = ..()

/obj/machinery/embryonator/ui_data(mob/user)
. = ..()
if(!embryo_egg)
child_image = null
return
.["image"] = icon2base64(child_image)
.["egg"] = REF(embryo_egg)

.["features"] = list()
for(var/thing in embryo_egg.features)
var/list/data = list(
name = embryo_egg.features[thing],
setting = thing
)
.["features"] += list(data)



/obj/machinery/embryonator/ui_act(action, params)
. = ..()
Loading
Loading