Skip to content

Commit

Permalink
tweak: Virology patch (#3925)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidPotroh authored Nov 28, 2023
1 parent df5d234 commit 4aecde5
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 181 deletions.
1 change: 1 addition & 0 deletions code/datums/diseases/vampire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
cure_prob = 8
severity = DANGEROUS
can_immunity = FALSE
visibility_flags = HIDDEN_PANDEMIC

/datum/disease/vampire/stage_act()
if(!..())
Expand Down
3 changes: 3 additions & 0 deletions code/datums/diseases/viruses/_virus.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
while(TRUE)
if(V == T)
var/a_type = (spread_range == 1) ? CONTACT : CONTACT|AIRBORNE
//if we wear bio suit, for example, we won't be able to contract anyone
if(affected_mob.CheckVirusProtection(src, a_type))
return
Contract(C, act_type = a_type, need_protection_check = TRUE)
break
var/turf/Temp = get_step_towards(V, T)
Expand Down
14 changes: 10 additions & 4 deletions code/datums/diseases/viruses/advance/advance.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ GLOBAL_LIST_EMPTY(archive_diseases)
/datum/disease/virus/advance/cure(id, need_immunity)
..(GetDiseaseID(), need_immunity)

/datum/disease/virus/advance/Contract(mob/living/M, act_type, is_carrier = FALSE, need_protection_check = FALSE, zone)
var/datum/disease/virus/advance/A = ..()
if(!istype(A))
return FALSE
A.Refresh(update_properties = FALSE)

// Returns the advance disease with a different reference memory.
/datum/disease/virus/advance/Copy()
var/datum/disease/virus/advance/copy = new
Expand Down Expand Up @@ -335,12 +341,12 @@ GLOBAL_LIST_EMPTY(archive_diseases)
/proc/SetViruses(datum/reagent/R, list/data)
if(data)
var/list/preserve = list()
if(istype(data) && data["viruses"])
for(var/datum/disease/virus/A in data["viruses"])
preserve += A.Copy()
if(istype(data) && data["diseases"])
for(var/datum/disease/D in data["diseases"])
preserve += D.Copy()
R.data = data.Copy()
if(preserve.len)
R.data["viruses"] = preserve
R.data["diseases"] = preserve

/proc/AdminCreateVirus(client/user)

Expand Down
17 changes: 8 additions & 9 deletions code/modules/reagents/chemistry/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
var/datum/chemical_reaction/C = reaction
var/total_required_reagents = length(C.required_reagents)
var/total_matching_reagents = 0
var/total_required_catalysts = length(C.required_catalysts)
var/total_required_catalysts = C.count_of_catalysts == -1 ? length(C.required_catalysts) : C.count_of_catalysts
var/total_matching_catalysts = 0
var/matching_container = FALSE
var/matching_other = FALSE
Expand All @@ -414,9 +414,8 @@
total_matching_reagents++
multipliers += round(get_reagent_amount(B) / C.required_reagents[B])
for(var/B in C.required_catalysts)
if(!has_reagent(B, C.required_catalysts[B]))
break
total_matching_catalysts++
if(has_reagent(B, C.required_catalysts[B]))
total_matching_catalysts++

if(!C.required_container)
matching_container = TRUE
Expand All @@ -437,7 +436,7 @@
if(min_temp == 0)
min_temp = chem_temp

if(total_matching_reagents == total_required_reagents && total_matching_catalysts == total_required_catalysts && matching_container && matching_other && chem_temp <= max_temp && chem_temp >= min_temp)
if(total_matching_reagents == total_required_reagents && total_matching_catalysts >= total_required_catalysts && matching_container && matching_other && chem_temp <= max_temp && chem_temp >= min_temp)
var/multiplier = min(multipliers)
var/preserved_data = null
for(var/B in C.required_reagents)
Expand Down Expand Up @@ -807,11 +806,11 @@
// Technically we should probably copy all data lists, but
// that could possibly eat up a lot of memory needlessly
// if most data lists are read-only.
if(trans_data["viruses"])
if(trans_data["diseases"])
var/list/temp = list()
for(var/datum/disease/v in trans_data["viruses"])
temp.Add(v.Copy())
trans_data["viruses"] = temp
for(var/datum/disease/D in trans_data["diseases"])
temp += D.Copy()
trans_data["diseases"] = temp
return trans_data

/datum/reagents/proc/generate_taste_message(minimum_percent = TASTE_SENSITIVITY_NORMAL)
Expand Down
143 changes: 70 additions & 73 deletions code/modules/reagents/chemistry/machinery/pandemic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,22 @@
overlays.Cut()
stat |= BROKEN

/obj/machinery/computer/pandemic/proc/GetVirusByIndex(index)
if(beaker && beaker.reagents)
if(beaker.reagents.reagent_list.len)
var/datum/reagent/blood/BL = locate() in beaker.reagents.reagent_list
if(BL)
if(BL.data && BL.data["viruses"])
var/list/viruses = BL.data["viruses"]
return viruses[index]
/obj/machinery/computer/pandemic/proc/GetDiseaseByIndex(index)
if(beaker?.reagents?.reagent_list.len)
for(var/datum/reagent/BL in beaker.reagents.reagent_list)
if(BL?.data && BL.data["diseases"])
var/list/diseases = BL.data["diseases"]
return diseases[index]

/obj/machinery/computer/pandemic/proc/GetResistancesByIndex(index)
if(beaker && beaker.reagents)
if(beaker.reagents.reagent_list.len)
var/datum/reagent/blood/BL = locate() in beaker.reagents.reagent_list
if(BL)
if(BL.data && BL.data["resistances"])
var/list/resistances = BL.data["resistances"]
return resistances[index]

/obj/machinery/computer/pandemic/proc/GetVirusTypeByIndex(index)
var/datum/disease/D = GetVirusByIndex(index)
if(beaker?.reagents?.reagent_list.len)
for(var/datum/reagent/BL in beaker.reagents.reagent_list)
if(BL?.data && BL.data["resistances"])
var/list/resistances = BL.data["resistances"]
return resistances[index]

/obj/machinery/computer/pandemic/proc/GetDiseaseTypeByIndex(index)
var/datum/disease/D = GetDiseaseByIndex(index)
if(D)
return D.GetDiseaseID()

Expand Down Expand Up @@ -103,10 +99,10 @@
temp_html = "The replicator is not ready yet."
updateUsrDialog()
return
else if(href_list["create_virus_culture"])
else if(href_list["create_disease_culture"])
if(!wait)
var/datum/disease/D = GetVirusByIndex(text2num(href_list["create_virus_culture"]))
var/datum/disease/copy = null
var/datum/disease/D = GetDiseaseByIndex(text2num(href_list["create_disease_culture"]))
var/datum/disease/copy
if(istype(D, /datum/disease/virus/advance))
var/datum/disease/virus/advance/A = GLOB.archive_diseases[D.GetDiseaseID()]
if(A)
Expand All @@ -118,12 +114,12 @@
var/name = stripped_input(usr,"Name:","Name the culture",copy.name,MAX_NAME_LEN)
if(name == null || wait)
return
var/obj/item/reagent_containers/glass/bottle/B = new/obj/item/reagent_containers/glass/bottle(loc)
var/obj/item/reagent_containers/glass/bottle/B = new(loc)
B.icon_state = "round_bottle"
B.pixel_x = rand(-3, 3)
B.pixel_y = rand(-3, 3)
replicator_cooldown(50)
var/list/data = list("viruses"=list(copy))
var/list/data = list("diseases"=list(copy))
B.name = "[name] culture bottle"
B.desc = "A small bottle. Contains [copy.agent] culture in synthblood medium."
B.reagents.add_reagent("blood",20,data)
Expand Down Expand Up @@ -151,15 +147,15 @@
return
if(..())
return
var/id = GetVirusTypeByIndex(text2num(href_list["name_disease"]))
var/id = GetDiseaseTypeByIndex(text2num(href_list["name_disease"]))
if(GLOB.archive_diseases[id])
var/datum/disease/virus/advance/A = GLOB.archive_diseases[id]
A.AssignName(new_name)
for(var/datum/disease/virus/advance/AD in GLOB.active_diseases)
AD.Refresh()
AD.Refresh(update_properties = FALSE)
updateUsrDialog()
else if(href_list["print_form"])
var/datum/disease/D = GetVirusByIndex(text2num(href_list["print_form"]))
var/datum/disease/D = GetDiseaseByIndex(text2num(href_list["print_form"]))
D = GLOB.archive_diseases[D.GetDiseaseID()]//We know it's advanced no need to check
print_form(D, usr)

Expand Down Expand Up @@ -229,10 +225,13 @@
dat += "<A href='?src=[user.UID()];mach_close=pandemic'>Закрыть</A>"
else
var/datum/reagents/R = beaker.reagents
var/datum/reagent/blood/Blood = null
for(var/datum/reagent/blood/B in R.reagent_list)
if(B)
var/datum/reagent/Blood = null

for(var/datum/reagent/B in R.reagent_list)
if(B.id in GLOB.diseases_carrier_reagents)
Blood = B
if(!Blood.data)
continue
break
if(!R.total_volume||!R.reagent_list.len)
dat += "Мензурка пуста<BR>"
Expand All @@ -246,54 +245,52 @@
dat += "<b>Тип крови:</b> [(Blood.data["blood_type"]||"нет")]<BR>"
dat += "<b>Тип расовой крови:</b> [(Blood.data["blood_species"]||"нет")]<BR>"


if(Blood.data["viruses"])
var/list/vir = Blood.data["viruses"]
if(vir.len)
var/i = 0
for(var/thing in Blood.data["viruses"])
var/datum/disease/D = thing
i++
if(!(D.visibility_flags & HIDDEN_PANDEMIC))

if(istype(D, /datum/disease/virus/advance))

var/datum/disease/virus/advance/A = D
D = GLOB.archive_diseases[A.GetDiseaseID()]
if(D)
if(D.name == "Unknown")
dat += "<b><a href='?src=[UID()];name_disease=[i]'>Назвать вирус</a></b><BR>"
else
dat += "<b><a href='?src=[UID()];print_form=[i]'>Напечатать форму выпуска</a></b><BR>"

if(!D)
CRASH("We weren't able to get the advance disease from the archive.")

dat += "<b>Болезнетворный агент:</b> [D?"[D.agent] — <A href='?src=[UID()];create_virus_culture=[i]'>Создать бутылёк с вирусной культурой</A>":"нет"]<BR>"
dat += "<b>Общепринятое название:</b> [(D.name||"нет")]<BR>"
dat += "<b>Описание: </b> [(D.desc||"нет")]<BR>"
dat += "<b>Путь передачи:</b> [(D.additional_info||"нет")]<BR>"
dat += "<b>Возможное лекарство:</b> [(D.cure_text||"нет")]<BR><BR>"
dat += "<b>Возможность выработки антител:</b> [(D.can_immunity ? "Присутствует" : "Отсутствует")]<BR><BR>"

if(istype(D, /datum/disease/virus/advance))
var/datum/disease/virus/advance/A = D
dat += "<b>Симптомы:</b> "
var/english_symptoms = list()
for(var/datum/symptom/S in A.symptoms)
english_symptoms += S.name
dat += english_list(english_symptoms)

dat += "<h3>Данные о заболеваниях:</h3>"
if(Blood.data["diseases"])
var/i = 0
for(var/datum/disease/D in Blood.data["diseases"])
i++
if(!(D.visibility_flags & HIDDEN_PANDEMIC))

dat += "<b>Общепринятое название: </b>"

if(istype(D, /datum/disease/virus/advance))
var/datum/disease/virus/advance/A = D
D = GLOB.archive_diseases[A.GetDiseaseID()]
if(D)
if(D.name == "Unknown")
dat += "<b><a href='?src=[UID()];name_disease=[i]'>Назвать вирус</a></b><BR>"
else
dat += "[D.name] <b><a href='?src=[UID()];print_form=[i]'>Напечатать форму выпуска</a></b><BR>"
else
dat += "В образце не обнаружен вирус."
dat += "[D.name]<BR>"

if(!D)
CRASH("We weren't able to get the advance disease from the archive.")

dat += "<b>Болезнетворный агент:</b> [D?"[D.agent] — <A href='?src=[UID()];create_disease_culture=[i]'>Создать образец</A>":"нет"]<BR>"
dat += "<b>Описание: </b> [(D.desc||"нет")]<BR>"
dat += "<b>Путь передачи:</b> [(D.additional_info||"нет")]<BR>"
dat += "<b>Возможное лекарство:</b> [(D.cure_text||"нет")]<BR>"
dat += "<b>Возможность выработки антител:</b> [(D.can_immunity ? "Присутствует" : "Отсутствует")]<BR>"

if(istype(D, /datum/disease/virus/advance))
var/datum/disease/virus/advance/A = D
dat += "<BR><b>Симптомы:</b> "
var/english_symptoms = list()
for(var/datum/symptom/S in A.symptoms)
english_symptoms += S.name
dat += english_list(english_symptoms)
dat += "<BR>"
if(i == 0)
dat += "В образце не обнаружен вирус."
else
dat += "В образце не обнаружен вирус."

dat += "<BR><b>Содержит антитела к:</b> "
if(Blood.data["resistances"])
var/list/res = Blood.data["resistances"]
if(res.len)
dat += "<ul>"
dat += "<BR><b>Содержит антитела к:</b><ul>"
var/i = 0
for(var/type in Blood.data["resistances"])
i++
Expand All @@ -310,13 +307,13 @@
dat += "<li>[disease_name] - <A href='?src=[UID()];create_vaccine=[i]'>Создать бутылёк с вакциной</A></li>"
dat += "</ul><BR>"
else
dat += "ничему<BR>"
dat += "<BR><b>Не содержит антител</b><BR>"
else
dat += "nothing<BR>"
dat += "<BR><b>Не содержит антител</b><BR>"
dat += "<BR><A href='?src=[UID()];eject=1'>Извлечь мензурку</A>[((R.total_volume&&R.reagent_list.len) ? "-- <A href='?src=[UID()];empty_beaker=1'>Очистить и извлечь мензурку</A>":"")]<BR>"
dat += "<A href='?src=[user.UID()];mach_close=pandemic'>Закрыть</A>"

var/datum/browser/popup = new(user, "pandemic", name, 575, 400)
var/datum/browser/popup = new(user, "pandemic", name, 575, 480)
popup.set_content(dat)
popup.open(0)
onclose(user, "pandemic")
Expand Down
31 changes: 31 additions & 0 deletions code/modules/reagents/chemistry/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,37 @@
/datum/reagent/proc/on_merge(data)
return

// Called in on_merge() proc if reagent can carry diseases
/datum/reagent/proc/merge_diseases_data(list/mix_data)
if(!(id in GLOB.diseases_carrier_reagents))
return

if(data && mix_data)
if(data["diseases"] || mix_data["diseases"])

var/list/mix1 = data["diseases"]
var/list/mix2 = mix_data["diseases"]

var/list/to_mix = list()

for(var/datum/disease/virus/advance/AD in mix1)
to_mix += AD
for(var/datum/disease/virus/advance/AD in mix2)
to_mix += AD

var/datum/disease/virus/advance/AD = Advance_Mix(to_mix)
var/list/preserve = list()

if(istype(AD))
preserve += AD

for(var/datum/disease/D in data["diseases"] + mix_data["diseases"])
if(!istype(D, /datum/disease/virus/advance))
preserve += D.Copy()
data["diseases"] = preserve

return

/datum/reagent/proc/on_update(atom/A)
return

Expand Down
4 changes: 4 additions & 0 deletions code/modules/reagents/chemistry/reagents/medicine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
Org.rejuvenate()

/datum/reagent/medicine/cryoxadone
data = list("diseases" = null)
name = "Cryoxadone"
id = "cryoxadone"
description = "A plasma mixture with almost magical healing powers. Its main limitation is that the targets body temperature must be under 265K for it to metabolise correctly."
Expand All @@ -141,6 +142,9 @@
head.disfigured = FALSE
return ..() | update_flags

/datum/reagent/medicine/cryoxadone/on_merge(list/mix_data)
merge_diseases_data(mix_data)

/datum/reagent/medicine/rezadone
name = "Rezadone"
id = "rezadone"
Expand Down
7 changes: 4 additions & 3 deletions code/modules/reagents/chemistry/reagents/toxins.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
return ..()

/datum/reagent/slimejelly
data = list("diseases" = null)
name = "Slime Jelly"
id = "slimejelly"
description = "A gooey semi-liquid produced from one of the deadliest lifeforms in existence. SO REAL."
Expand All @@ -112,9 +113,9 @@
return ..() | update_flags

/datum/reagent/slimejelly/on_merge(list/mix_data)
if(data && mix_data)
if(mix_data["colour"])
color = mix_data["colour"]
merge_diseases_data(mix_data)
if(data && mix_data && mix_data["colour"])
color = mix_data["colour"]

/datum/reagent/slimejelly/reaction_turf(turf/T, volume, color)
if(volume >= 3 && !isspaceturf(T) && !locate(/obj/effect/decal/cleanable/blood/slime) in T)
Expand Down
Loading

0 comments on commit 4aecde5

Please sign in to comment.