From 0d907db516a2180268778c7c213c351132348c6c Mon Sep 17 00:00:00 2001 From: Fermi Date: Tue, 14 May 2019 21:20:38 +0100 Subject: [PATCH] Almost done. Just need to update reagent vars. --- code/modules/reagents/chemistry/holder.dm | 12 ++-- code/modules/reagents/chemistry/reagents.dm | 3 +- .../chemistry/reagents/fermi_reagents.dm | 15 ++-- .../reagents/chemistry/recipes/fermi.dm | 7 -- .../objects}/fermiclothes.dm | 0 .../code/modules/reagents/objects/items.dm | 67 ++++++++++++++++++ modular_citadel/icons/obj/FermiChem.dmi | Bin 0 -> 814 bytes tgstation.dme | 3 +- 8 files changed, 86 insertions(+), 21 deletions(-) rename modular_citadel/code/modules/{clothing/fermichemclothe => reagents/objects}/fermiclothes.dm (100%) create mode 100644 modular_citadel/code/modules/reagents/objects/items.dm create mode 100644 modular_citadel/icons/obj/FermiChem.dmi diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 6ef2ade8fe..e58225068c 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -832,10 +832,10 @@ if(cached_reagents[reagent]) //if it's already in us, merge var/datum/reagent/R = cached_reagents[reagent] - WIP_TAG //check my maths for purity calculations + //WIP_TAG //check my maths for purity calculations //Add amount and equalize purity - var/our_pure_moles = R.volume * R.purity - var/their_pure_moles = amount * other_purity + //var/our_pure_moles = R.volume * R.purity + //var/their_pure_moles = amount * other_purity R.volume += amount //R.purity = (our_pure_moles + their_pure_moles) / (R.volume) R.purity = ((R.purity * R.volume) + (other_purity * amount)) /((R.volume + amount)) //This should add the purity to the product @@ -846,7 +846,7 @@ my_atom.on_reagent_change(ADD_REAGENT) R.on_merge(data, amount) if(!no_react) - start_reacting() + handle_reactions() return TRUE else @@ -863,7 +863,7 @@ if(my_atom) my_atom.on_reagent_change(ADD_REAGENT) if(!no_react) - start_reacting() + handle_reactions() if(isliving(my_atom)) R.on_mob_add(my_atom) return TRUE @@ -897,7 +897,7 @@ //clamp the removal amount to be between current reagent amount //and zero, to prevent removing more than the holder has stored amount = CLAMP(amount, 0, R.volume) - pH = ((pH * volume)-(R.pH * amount))/(volume - amount) + pH = ((pH * total_volume)-(R.pH * amount))/(total_volume - amount) R.volume -= amount update_total() if(!safety)//So it does not handle reactions when it need not to diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index 4a3579bf07..d95a18dc3e 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -36,7 +36,8 @@ //Fermichem vars: var/purity = 1 var/impureChem = "toxin" - var/loc = null + //var/loc = null + var/pH /datum/reagent/Destroy() // This should only be called by the holder, so it's already handled clearing its references . = ..() diff --git a/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm b/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm index 8c4f16aa09..43aac65143 100644 --- a/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm +++ b/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm @@ -8,9 +8,12 @@ //Naninte chem /datum/reagent/fermi - name = "Fermi" - id = "fermi" - taste_description = "If affection had a taste, this would be it." + name = "Fermi" //Why did I putthis here? + id = "fermi" //It's meeee + taste_description = "If affection had a taste, this would be it." + var/ImpureChem = "toxin" // What chemical is metabolised with an inpure reaction + var/InverseChemVal = 0 // If the impurity is below 0.5, replace ALL of the chem with InverseChem upon metabolising + var/InverseChem = "Initropidril" // What chem is metabolised when purity is below InverseChemVal ///datum/reagent/fermi/on_mob_life(mob/living/carbon/M) //current_cycle++ @@ -22,15 +25,15 @@ /datum/reagent/fermi/on_mob_add(mob/living/carbon/M) if (src.purity == 1) return - if (CR.InverseChemVal > src.purity) + else if (src.InverseChemVal > src.purity) holder.remove_reagent(src.id, volume, FALSE) - holder.add_reagent(CR.InverseChem) + holder.add_reagent(src.InverseChem) return else var/pureVol = volume * purity var/impureVol = volume * (1 - pureVol) holder.remove_reagent(src.id, (volume*impureVol), FALSE) - holder.add_reagent(CR.ImpureChem, impureVol, FALSE) + holder.add_reagent(src.ImpureChem, impureVol, FALSE) diff --git a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm index 2f890244b7..ff78aea252 100644 --- a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm +++ b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm @@ -21,7 +21,6 @@ RateUpLim = 5 //Optimal/max rate possible if all conditions are perfect FermiChem = TRUE//If the chemical uses the Fermichem reaction mechanics FermiExplode = FALSE //If the chemical explodes in a special way - ImpureChem = "toxin" //What chemical is produced with an inpure reaction /datum/chemical_reaction/eigenstate/on_reaction(datum/reagents/holder) var/location = get_turf(holder.my_atom) @@ -50,9 +49,6 @@ RateUpLim = 5 // Optimal/max rate possible if all conditions are perfect FermiChem = TRUE // If the chemical uses the Fermichem reaction mechanics FermiExplode = FALSE // If the chemical explodes in a special way - ImpureChem = "SDGFTox" // What chemical is metabolised with an inpure reaction - InverseChemVal = 0.5 // If the impurity is below 0.5, replace ALL of the chem with InverseChem upon metabolising - InverseChem = "SDZF" // What chem is metabolised when purity is below InverseChemVal /datum/chemical_reaction/BElarger name = "" @@ -119,9 +115,6 @@ RateUpLim = 5 // Optimal/max rate possible if all conditions are perfect FermiChem = TRUE // If the chemical uses the Fermichem reaction mechanics FermiExplode = FALSE // If the chemical explodes in a special way - //ImpureChem = "SDGFTox" // What chemical is metabolised with an inpure reaction - //InverseChemVal = 0.5 // If the impurity is below 0.5, replace ALL of the chem with InverseChem upon metabolising - //InverseChem = "SDZF" // What chem is metabolised when purity is below InverseChemVal /datum/chemical_reaction/enthral/on_reaction(datum/reagents/holder) diff --git a/modular_citadel/code/modules/clothing/fermichemclothe/fermiclothes.dm b/modular_citadel/code/modules/reagents/objects/fermiclothes.dm similarity index 100% rename from modular_citadel/code/modules/clothing/fermichemclothe/fermiclothes.dm rename to modular_citadel/code/modules/reagents/objects/fermiclothes.dm diff --git a/modular_citadel/code/modules/reagents/objects/items.dm b/modular_citadel/code/modules/reagents/objects/items.dm new file mode 100644 index 0000000000..3dd4c41029 --- /dev/null +++ b/modular_citadel/code/modules/reagents/objects/items.dm @@ -0,0 +1,67 @@ +/obj/item/pHbooklet + name = "pH indicator booklet" + desc = "A piece of paper that will change colour depending on the pH of what it's added to." + icon_state = "pHbooklet" + icon = 'modular_citadel/icons/obj/FermiChem.dmi' + item_flags = NOBLUDGEON + var/numberOfPages = 100 + +/obj/item/pHbooklet/attack_hand(mob/user) + if(numberOfPages >= 1) + var/obj/item/pHpaper/P = new /obj/item/pHpaper + //P.add_fingerprint(user) + P.forceMove(user.loc) + user.put_in_hands(P) + to_chat(user, "You take [P] out of \the [src].") + numberOfPages-- + else + to_chat(user, "[src] is empty!") + add_fingerprint(user) + return ..() + +/obj/item/pHpaper + name = "pH indicator strip" + desc = "A piece of paper that will change colour depending on the pH of a solution." + icon_state = "pHpaper" + icon = 'modular_citadel/icons/obj/FermiChem.dmi' + item_flags = NOBLUDGEON + color = "#f5c352" + var/used = FALSE + +/obj/item/pHpaper/attack_hand(mob/user, obj/I) + if(!I.reagents.pH) + return + if(used == TRUE) + to_chat(user, "[src] has already been used!") + return + switch(I.reagents.pH) + if(14 to INFINITY) + src.color = "#462c83" + if(13 to 14) + src.color = "#63459b" + if(12 to 13) + src.color = "#5a51a2" + if(11 to 12) + src.color = "#3853a4" + if(10 to 11) + src.color = "#3f93cf" + if(9 to 10) + src.color = "#0bb9b7" + if(8 to 9) + src.color = "#23b36e" + if(7 to 8) + src.color = "#3aa651" + if(6 to 7) + src.color = "#4cb849" + if(5 to 6) + src.color = "#b5d335" + if(4 to 5) + src.color = "#b5d333" + if(3 to 4) + src.color = "#f7ec1e" + if(2 to 3) + src.color = "#fbc314" + if(1 to 2) + src.color = "#f26724" + if(0 to 1) + src.color = "#ef1d26" diff --git a/modular_citadel/icons/obj/FermiChem.dmi b/modular_citadel/icons/obj/FermiChem.dmi new file mode 100644 index 0000000000000000000000000000000000000000..ffc50d28992e145f5b59292d302c6a2bddb70331 GIT binary patch literal 814 zcmV+}1JV46P)LoV=-0C=2JR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6# za*U0*I5Sc+(=$pSoZ^zil2jm5$s@qWIW@PSq*95CGbOXA7$|1Q#hF%=n41b=!&Me| zB<1I4=cJYpp|T*cAhigWI%Ne{KNqlL0k*F*70wH!{Qv*~_(?=TR9J=8*Ntw1Fcbyg z0+s@!4u&|Wy#I6V-WEz*paL~!9uqXU^YsU1k&ur|G{y5bv5c?m2jT>?1`r<*&$(cZ z0x&G4i9C3KNk}0saG@-t7n(5|-vzlvTR@sea|0S9R?J)NwJq8k}FR739Yi zo&d6rWAlph8Uaganq~>W$?@$Zk=1E%5Nca!ZtcDN)lo0YdwXjv0IJwr5hP$-MwJ;r z!D!+$EW-u5uInN2G+qS*0KsUE6i&zlpabO&t7;ESKns;2a2tRQ4m@w71&{)W%3MZO z^Ez<=`zqLg6wGD7F)4Ol1ue{zQ2lfUKyY$z9RNO0#zvTZ_#C0&1p79Cf?kH%C!%jw z(+c853borOqRRw4%rHFBEdVtMw+}!sdXY26s0_Tw;Y7azjLXpb?*LQ{PdxxpHyyG8 zFc~j^gnLH7*FcEJBd25X{2`#f0jxx9WN-if#QQ&g9}p-+!w^J3e+VKJfW$du>W{|p zz6qQm>^>521{VEb;NTuaFJD3E76xC$kDGuCynhE?Jb~kV7dY6LKO#aVAcdel5