Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A look at botany splicing & more
#7
Alright I did more codedigging and found some relevant bits though there is some strange code doubling going on.
plantpot.dm has a HYPadd_harvest_reagents proc which as the name suggests adds the reagents as the plant is harvested. Basically it determines the amount the individual fruit can hold based on quality/potency/etc. then it makes a list of reagents that go in it and finally it fills it with an equal amount of each reagent. The relevant part here is how it generates the reagent list:
Code:
proc/HYPadd_harvest_reagents(var/obj/item/I,var/datum/plant/growing,var/datum/plantgenes/DNA,var/special_condition = null)

[...]

var/list/putreagents = list()
    putreagents = growing.assoc_reagents
    if (MUT)
        putreagents = putreagents | MUT.assoc_reagents
    // Build the list of all what reagents need to go into the new item.

    if (special_condition == "rotten")
        putreagents += "yuck"

    for (var/datum/plant_gene_strain/reagent_adder/R in DNA.commuts)
        putreagents |= R.reagents_to_add

[...]

So it takes the associated reagents from the plant being harvested, adds all reagents from the plant mutation and then does some other stuff. The part in plantpot.dm I found earlier is what makes it impossible for mutation reagents to carry over a splice.
Code:
[...]

for (var/datum/plantmutation/MUT in dominantspecies.mutations)
                    // Only share the dominant species mutations or else shit might get goofy
                    P.mutations += new MUT.type(P)

                if (dominantDNA.mutation)
                    DNA.mutation = new dominantDNA.mutation.type(DNA)

[...]

Which means the Hybrid Cannabis seed coming out (->cannabis is dominant) can only get cannabis mutations ergo the reagents added above will be from those mutations. Note the plural though, this is a list of possible mutations which in the case of cannabis obviously contains all the cannabis variants. The seed also gets the same mutation that the dominant species already had.
 Finally the hydroponics folder contains the actual plant data of basic plants, gene strains and mutations. The mutations mostly replace certain variables on their base crop e.g.
Code:
/datum/plantmutation/cannabis/rainbow
    name = "Rainbow Weed"
    iconmod = "megaweed"
    crop = /obj/item/plant/herb/cannabis/mega
    assoc_reagents = list("LSD")

replaces the name of the crop, changes the icon of the plant in the pot and changes the item that spawns when harvested. The reagent list however is obviously not handled as a replacement but as seen above works alongside the base plant reagent list. I thought about what would happen if we allow a mutation on a plant it's not made for and while it would work it would certainly get wonky. However if we take a look at more of the splicing code:
Code:
            var/obj/item/seed/seed1 = src.splicing1
            var/obj/item/seed/seed2 = src.splicing2

            // Now work out whether we fail to splice or not based on species compatability
            // And the health of the two seeds you're using
            var/splice_chance = 100
            var/datum/plant/P1 = seed1.planttype
            var/datum/plant/P2 = seed2.planttype

[...splice chance calc...]

            if (prob(splice_chance)) // We're good, so start splicing!
                // Create the new seed
                var/obj/item/seed/S = new /obj/item/seed(src)
                var/datum/plant/P = new /datum/plant(S)
                var/datum/plantgenes/DNA = new /datum/plantgenes(S)
                S.planttype = P
                S.plantgenes = DNA
                P.hybrid = 1

[...dominant species determination...]

                for (var/datum/plantmutation/MUT in dominantspecies.mutations)
                    // Only share the dominant species mutations or else shit might get goofy
                    P.mutations += new MUT.type(P)

                if (dominantDNA.mutation)
                    DNA.mutation = new dominantDNA.mutation.type(DNA)

                P.commuts = P1.commuts | P2.commuts // We merge these and share them
                DNA.commuts = P1DNA.commuts | P2DNA.commuts
                P.assoc_reagents = P1.assoc_reagents | P2.assoc_reagents

[...mixing the other attributes and the rest...]

The trick would be to add another variable recessiveDNA which is filled with the DNA from the side that loses in the domination "battle" I skipped. Then in that last line where the reagent list of the new plant is determined by simply throwing the lists of both spliced plants together we could check if the recessiveDNA is mutated and if so add the reagents from that mutation as well. E.g.
Code:
                P.assoc_reagents = P1.assoc_reagents | P2.assoc_reagents

                if (recessiveDNA.mutation)
                    P.assoc_reagents = P.assoc_reagents | recessiveDNA.mutation.assoc_reagents
No guarantee that this is correct code.
Now the resulting hybrid would have the reagents of both plant species and the existing mutation from the non-dominant species. And it would still have the mutation of the dominant species or it could gain one from that list and add those reagents. AND it could then be further spliced into another plant. 
What I am not sure about is how this splicing system currently stops adding the same reagents over and over if the same seed is spliced again and again. Might be that duplicates are eliminated elsewhere. The other thing I noticed is that we actually have three plants.dm, one in the hydroponics folder, the other two listed by Noah containing data about the resulting crops, sub-items like sliced fruit, brew results and other stuff. Now these latter two sometimes have their own reagent lists for the items and I'm not exactly sure where those are used.
Finally what would that allow? You could easily splice poisons into regular foodstuffs but it's not like eating fruit you find lying around is actually safe as it is.

PS: Is there a way to spoilertag stuff like the codesections btw?
Reply


Messages In This Thread
A look at botany splicing & more - by UmmonTL - 05-06-2016, 07:03 AM
RE: A look at botany splicing & more - by UmmonTL - 05-08-2016, 05:05 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)