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

Moves breathing from species to the lung organ #20869

Merged
merged 11 commits into from Oct 21, 2016

Conversation

AKlimentyev
Copy link

🆑
experiment: Breathing has been moved from species to the lung organ
add: Lung transplants are now possible!
/:cl:

@optimumtact optimumtact added the Refactor Makes the code harder to read label Oct 8, 2016
@PKPenguin321
Copy link
Contributor

Slightly related, we really really really need to refactor eye damage/color to be dependent on an eyes organ

@WJohn
Copy link
Contributor

WJohn commented Oct 8, 2016

Does this make it so if you transplant ashwalker lungs into yourself, you'll be able to breathe on lavaland without equipment?

@@ -257,8 +257,10 @@ var/list/non_simple_animals = typecacheof(list(/mob/living/carbon/monkey,/mob/li
switch(upgrade_type)
if(VAULT_TOXIN)
H << "<span class='notice'>You feel resistant to airborne toxins.</span>"
S.tox_breath_dam_min = 0
S.tox_breath_dam_max = 0
if(/obj/item/organ/lungs in H.internal_organs)
Copy link
Contributor

Choose a reason for hiding this comment

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

false.

the H.internal_organs list will never contain the path /obj/item/organ/lungs, or any paths at all for that matter!
It's a lit of objects.

you're probably forgetting a locate() call

Copy link
Author

Choose a reason for hiding this comment

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

Oh. I didn't know that didn't work with objects.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well /obj/item/organ/lungs and an instantiated lung object are completely different.
that lung object's .type variable however is a 100% match for /obj/item/organ/lungs

paths != objects

Copy link
Author

Choose a reason for hiding this comment

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

It would be if(locate(/obj/item/organ/lungs) in H.internal_organs) then, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep yep

Copy link
Author

Choose a reason for hiding this comment

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

@RemieRichards k. I fixed it.

@AKlimentyev
Copy link
Author

@WJohn actually, no.
Ash walkers have NOBREATH, which is still part of the species. I'm not sure if they even have lungs due to that.
I'm planning on adding N2 to the list of breathable gasses and have ashwalkers breath lavaland airmix in a later pr.
That was actually the original purpose of the pr (hence the branch name), but @phil235 asked me to move breathing to lungs, so I did that instead.

@GunHog
Copy link
Contributor

GunHog commented Oct 9, 2016

What lung types are there? Could I give a guy Xeno lungs for breathing plasma and removing the need for oxygen? Cybernetic lungs for immunity to toxic gasses? Plasmaman lungs for FORCING people to breathe plasma?

@AKlimentyev
Copy link
Author

@GunHog
If you made subtypes, yes.
At the moment, the lungs set their vars based off of the species where they originated from.
Also, I don't think xeno lungs work with this system. They have separate breathing code.

@FantasticFwoosh
Copy link
Contributor

If you steal ashwalker/golem lungs, and aug a body, then suppliment a heat gene you are effectively space proof when revived from practically any condition of death with strange reagent.

This is a slightly better alternative to reattaching to a ashwalker torso, and will fuel my surgeon experiments.

@PKPenguin321
Copy link
Contributor

You don't need augs to space proof, cold res handles pressure resistance

@FantasticFwoosh
Copy link
Contributor

Double checked, ashwalkers and NOBREATHE related races have their lungs qdeleted in the code.

So no-breathe transplanted lungs are currently impossible without badminnery to restore said lungs and assign them to the owner.

@coiax
Copy link
Member

coiax commented Oct 10, 2016

I specifically did the NOBREATH species having no lungs, because it made no sense for golems and skeletons to have a set of lungs. If ashwalkers are being switched to a lavaland gas mixture, then they won't be NOBREATH anymore.


return 0
else
if(istype(L,/obj/item/organ/lungs))
Copy link
Contributor

Choose a reason for hiding this comment

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

people can have an organ in the lung slot that isn't /obj/item/organ/lungs ??

Copy link
Author

Choose a reason for hiding this comment

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

Badmins? Idk.
I just like to do an istype before casting stuff, just in case.
Should I remove this check then?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I don't really see what admins could use a non lung organ in the lung slot for. But I guess it prevents potential runtimes, so let's keep it.

@nullbear
Copy link
Contributor

I cant wait for the entire server to die of suffocation within 3 minutes of starting the round if this bugs out.

@AKlimentyev
Copy link
Author

I tested it. it works fine

@PKPenguin321
Copy link
Contributor

famous last words

@Razharas
Copy link
Contributor

First step in porting all the species behaviour to organs

Wonderful

@RemieRichards
Copy link
Contributor

RemieRichards commented Oct 12, 2016

>First Step
>Probably the 3 or 4th time functionality has been moved to an organ

HMMMMMMM.

Copy link
Contributor

@Razharas Razharas left a comment

Choose a reason for hiding this comment

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

Moving stuff from mobs\species to organs is the goal

@Razharas
Copy link
Contributor

Thats the first one i see so its first for me


//-- TRACES --//

if(breath && !(NOBREATH in specflags)) // If there's some other shit in the air lets deal with it here.
Copy link
Member

Choose a reason for hiding this comment

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

there's no point in checking this because NOBREATH species will have no lungs and this line will never be reached if that is the case.

Copy link
Author

Choose a reason for hiding this comment

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

removed

Copy link
Contributor

Choose a reason for hiding this comment

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

what if you insert lungs into a human with NOBREATH?

Copy link
Author

Choose a reason for hiding this comment

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

I dunno. Haven't tested it post check removal yet.
I'd assume either the check in the species would make them still not breath, or they would need to breath.

Copy link
Contributor

Choose a reason for hiding this comment

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

Things with nobreath shouldnt even try to call their lungs procs
Thus inserting lungs into them should be as impactful as inserting a bike horn into their cavity

Copy link
Member

Choose a reason for hiding this comment

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

Well there is what should happen and then what the code actually does, so you would need to check.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, tested it. If the species has nobreath, they basically skip breathe(), and don't call check_breath() which is where the lung code is.
So they don't breathe if you transplant lungs into them.

@Anonmare
Copy link
Contributor

I'm hopeful for this PR

@@ -150,6 +132,9 @@
else if((!(NOBREATH in specflags)) && (!lungs))
lungs = new()
lungs.Insert(C)
if(lungs)
lungs.breathlevels = list("safe_oxygen_min" = safe_oxygen_min,"safe_oxygen_max" = safe_oxygen_max,"safe_co2_min" = safe_co2_min,"safe_co2_max" = safe_co2_max,
"safe_toxins_min" = safe_toxins_min,"safe_toxins_max" = safe_toxins_max,"SA_para_min" = SA_para_min,"SA_sleep_min" = SA_sleep_min,"BZ_trip_balls_min" = BZ_trip_balls_min)
Copy link
Contributor

Choose a reason for hiding this comment

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

in human/New() organs are created after setting up the species, so if we make lizard have special values, their lung won't have those.

@AKlimentyev AKlimentyev changed the title Moves breathing from species to the lung organ [WIP]Moves breathing from species to the lung organ Oct 20, 2016
@AKlimentyev
Copy link
Author

@phil235 I did the change you suggested, but now the lungs aren't spawning in humans.
I cant figure out what I did wrong, ahhhhhhhh!

if(dna.species.mutantlungs)
internal_organs += new dna.species.mutantlungs()
else
internal_organs += new /obj/item/organ/lungs
Copy link
Contributor

Choose a reason for hiding this comment

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

()

throw_alert("not_enough_tox", /obj/screen/alert/not_enough_tox)
else if(S.safe_co2_min)
else if(S.breathid = "co2")
Copy link
Contributor

Choose a reason for hiding this comment

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

throw_alert("oxy", /obj/screen/alert/oxy)
else if(S.safe_toxins_min)
else if(S.breathid = "tox")
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -108,11 +108,11 @@
if(dna && dna.species)
var/datum/species/S = dna.species

if(S.safe_oxygen_min)
if(S.breathid = "o2")
Copy link
Contributor

Choose a reason for hiding this comment

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

throw_alert("oxy", /obj/screen/alert/oxy)
else if(S.breathid = "tox")
throw_alert("not_enough_tox", /obj/screen/alert/not_enough_tox)
else if(S.breathid = "co2")
Copy link
Contributor

@phil235 phil235 Oct 20, 2016

Choose a reason for hiding this comment

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

"=="


if(S.breathid = "o2")
throw_alert("oxy", /obj/screen/alert/oxy)
else if(S.breathid = "tox")
Copy link
Contributor

@phil235 phil235 Oct 20, 2016

Choose a reason for hiding this comment

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

"=="

if(dna && dna.species)
var/datum/species/S = dna.species

if(S.breathid = "o2")
Copy link
Contributor

@phil235 phil235 Oct 20, 2016

Choose a reason for hiding this comment

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

"=="

@AKlimentyev
Copy link
Author

Compiles now. lungs still not spawning ;_;
So confused as to what I'm doing wrong.

@phil235
Copy link
Contributor

phil235 commented Oct 20, 2016

Manually calling create_internal_organs() gives lungs, and adminspawned humans correctly have lungs. So it's only happening when players are first spawned by the game, or when they join the game.

edit: found the issue.

@@ -144,11 +119,14 @@
heart = new()
heart.Insert(C)

if((NOBREATH in specflags) && lungs)
if(lungs)
lungs.Remove(C)
qdel(lungs)
Copy link
Contributor

@phil235 phil235 Oct 20, 2016

Choose a reason for hiding this comment

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

you're not immediately nullifying lungs so the if(!lungs) check below fails.

@AKlimentyev AKlimentyev changed the title [WIP]Moves breathing from species to the lung organ Moves breathing from species to the lung organ Oct 21, 2016
@Cheridan Cheridan merged commit 091e101 into tgstation:master Oct 21, 2016
@AKlimentyev AKlimentyev deleted the gaswalkers branch October 21, 2016 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Makes the code harder to read
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet