Files
b7f1ade3da vg virology port part 1 (#5793)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
The first part the process to port /vg/station's virology system. This
pr implements an immunesystem in humans which forms the basis of the new
system. I mostly just want this reviewed because I am still unfamiliar
with dreammaker.
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
Currently, this pr doesn't affect gameplay. In the future, continuing to
add features from /vg/station's virology will lead to further depth in
the virology system, like being able to breed diseases specifically to
combat other diseases, and pathogenic contamination, where diseases can
spread to objects, then spread to players. But those come later.
<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
add: Adds the immunesystem, which contains a list of antigens, and a
bunch of procs for it.
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: Jacob Ramsey <ramseyjacob97@gmail.com>
2023-08-02 11:53:39 -07:00

326 lines
9.5 KiB
Plaintext

/datum/disease2/disease
var/infectionchance = 70
var/speed = 1
var/spreadtype = "Blood" // Can also be "Contact" or "Airborne"
var/stage = 1
var/stageprob = 10
var/dead = 0
var/clicks = 0
var/uniqueID = 0
var/list/datum/disease2/effectholder/effects = list()
var/antigen = list() // 16 bits describing the antigens, when one bit is set, a cure with that bit can dock here
var/max_stage = 4
var/list/affected_species = list(SPECIES_HUMAN,SPECIES_UNATHI,SPECIES_SKRELL,SPECIES_TAJ)
var/resistance = 10 // % chance a disease will resist cure, up to 100
var/strength = 15 // threshold for antibodies to overcome to cure disease
/datum/disease2/disease/New()
uniqueID = rand(0,10000)
..()
/datum/disease2/disease/proc/makerandom(var/severity=1)
var/list/excludetypes = list()
for(var/i=1 ; i <= max_stage ; i++ )
var/datum/disease2/effectholder/holder = new /datum/disease2/effectholder
holder.stage = i
holder.getrandomeffect(severity, excludetypes)
excludetypes += holder.effect.type
effects += holder
uniqueID = rand(0,10000)
switch(severity)
if(1)
infectionchance = 1
if(2)
infectionchance = rand(10,20)
else
infectionchance = rand(60,90)
antigen = list(pick(ALL_ANTIGENS))
antigen |= pick(ALL_ANTIGENS)
spreadtype = prob(70) ? "Airborne" : "Contact"
resistance = rand(15,70)
if(severity >= 2 && prob(33))
resistance += 10
strength += 10
else if(severity >= 3)
strength += 20
affected_species = get_infectable_species()
// todo: this is not great, viruses should check on infect attempt if possible with good performance
/proc/get_infectable_species()
var/list/meat = list()
var/list/res = list()
var/list/species_cache = SScharacters.all_static_species_meta()
for(var/datum/species/S in species_cache)
if(S.get_virus_immune())
continue
meat += S
if(meat.len)
var/num = rand(1,meat.len)
for(var/i=0,i<num,i++)
var/datum/species/picked = pick_n_take(meat)
res |= picked.name
if(picked.greater_form)
res |= picked.greater_form
if(picked.primitive_form)
res |= picked.primitive_form
return res
/datum/disease2/disease/proc/activate(var/mob/living/carbon/mob)
if(dead)
cure(mob)
return
if(mob.stat == DEAD)
return
if(stage <= 1 && clicks == 0) // with a certain chance, the mob may become immune to the disease before it starts properly
if(prob(5))
mob.antibodies |= antigen // 20% immunity is a good chance IMO, because it allows finding an immune person easily
// Some species are flat out immune to organic viruses.
var/mob/living/carbon/human/H = mob
if(istype(H) && H.species.get_virus_immune(H))
cure(mob)
return
if(mob.radiation > RAD_VIRUS_MUTATE)
if(prob(1))
majormutate()
//Space antibiotics have a good chance to stop disease completely
if(mob.chem_effects[CE_ANTIBIOTIC])
if(stage == 1 && prob(70-resistance))
src.cure(mob)
else
resistance += rand(1,9)
// Corophazine can treat higher stages
var/antibiotics = mob.chem_effects[CE_ANTIBIOTIC]
if(antibiotics == ANTIBIO_SUPER)
if(prob(70))
src.cure(mob)
//Resistance is capped at 90 without being manually set to 100
if(resistance > 90 && resistance < 100)
resistance = 90
//Virus food speeds up disease progress
if(mob.reagents.has_reagent("virusfood"))
mob.reagents.remove_reagent("virusfood",0.1)
clicks += 10
if(prob(1) && prob(stage)) // Increasing chance of curing as the virus progresses
src.cure(mob)
mob.antibodies |= src.antigen
//Moving to the next stage
if(clicks > max(stage*100, 200) && prob(10))
if((stage <= max_stage) && prob(5)) // ~20% of viruses will be cured by the end of S4 with this
src.cure(mob)
mob.antibodies |= src.antigen
stage++
clicks = 0
//Do nasty effects
for(var/datum/disease2/effectholder/e in effects)
if(prob(33))
e.runeffect(mob,stage)
//Short airborne spread
if(src.spreadtype == "Airborne")
for(var/mob/living/carbon/M in oview(1,mob))
if(airborne_can_reach(get_turf(mob), get_turf(M)))
infect_virus2(M,src)
//fever
mob.bodytemperature = max(mob.bodytemperature, min(310+5*min(stage,max_stage) ,mob.bodytemperature+5*min(stage,max_stage)))
clicks+=speed
/datum/disease2/disease/proc/cure(var/mob/living/carbon/mob)
for(var/datum/disease2/effectholder/e in effects)
e.effect.deactivate(mob)
mob.virus2.Remove("[uniqueID]")
mob.update_hud_med_status()
/datum/disease2/disease/proc/minormutate()
//uniqueID = rand(0,10000)
var/datum/disease2/effectholder/holder = pick(effects)
holder.minormutate()
//infectionchance = min(50,infectionchance + rand(0,10))
/datum/disease2/disease/proc/majormutate()
uniqueID = rand(0,10000)
var/datum/disease2/effectholder/holder = pick(effects)
var/list/exclude = list()
for(var/datum/disease2/effectholder/D in effects)
if(D != holder)
exclude += D.effect.type
holder.majormutate(exclude)
if (prob(5) && prob(100-resistance)) // The more resistant the disease,the lower the chance of randomly developing the antibodies
antigen = list(pick(ALL_ANTIGENS))
antigen |= pick(ALL_ANTIGENS)
if (prob(5))
affected_species = get_infectable_species()
if (prob(10))
resistance += rand(1,9)
if(resistance > 90 && resistance < 100)
resistance = 90
/datum/disease2/disease/proc/getcopy()
var/datum/disease2/disease/disease = new /datum/disease2/disease
disease.infectionchance = infectionchance
disease.spreadtype = spreadtype
disease.stageprob = stageprob
disease.antigen = antigen
disease.uniqueID = uniqueID
disease.affected_species = affected_species.Copy()
for(var/datum/disease2/effectholder/holder in effects)
var/datum/disease2/effectholder/newholder = new /datum/disease2/effectholder
newholder.effect = new holder.effect.type
newholder.effect.generate(holder.effect.data)
newholder.chance = holder.chance
newholder.cure = holder.cure
newholder.multiplier = holder.multiplier
newholder.happensonce = holder.happensonce
newholder.stage = holder.stage
disease.effects += newholder
return disease
/datum/disease2/disease/proc/issame(var/datum/disease2/disease/disease)
var/list/types = list()
var/list/types2 = list()
for(var/datum/disease2/effectholder/d in effects)
types += d.effect.type
var/equal = 1
for(var/datum/disease2/effectholder/d in disease.effects)
types2 += d.effect.type
for(var/type in types)
if(!(type in types2))
equal = 0
if (antigen != disease.antigen)
equal = 0
return equal
/proc/virus_copylist(var/list/datum/disease2/disease/viruses)
var/list/res = list()
for (var/ID in viruses)
var/datum/disease2/disease/V = viruses[ID]
res["[V.uniqueID]"] = V.getcopy()
return res
var/global/list/virusDB = list()
/datum/disease2/disease/proc/name()
.= "stamm #[add_zero("[uniqueID]", 4)]"
if ("[uniqueID]" in virusDB)
var/datum/data/record/V = virusDB["[uniqueID]"]
.= V.fields["name"]
/datum/disease2/disease/proc/get_basic_info()
var/t = ""
for(var/datum/disease2/effectholder/E in effects)
t += ", [E.effect.name]"
return "[name()] ([copytext(t,3)])"
/datum/disease2/disease/proc/get_info()
var/r = {"
<small>Analysis determined the existence of a GNAv2-based viral lifeform.</small><br>
<u>Designation:</u> [name()]<br>
<u>Antigen:</u> [antigens2string(antigen)]<br>
<u>Transmitted By:</u> [spreadtype]<br>
<u>Rate of Progression:</u> [stageprob * 10]<br>
<u>Antibiotic Resistance</u> [resistance]% <br>
<u>Species Affected:</u> [jointext(affected_species, ", ")]<br>
"}
r += "<u>Symptoms:</u><br>"
for(var/datum/disease2/effectholder/E in effects)
r += "([E.stage]) [E.effect.name] "
r += "<small><u>Strength:</u> [E.multiplier >= 3 ? "Severe" : E.multiplier > 1 ? "Above Average" : "Average"] "
r += "<u>Aggressiveness:</u> [E.chance * 15]</small><br>"
return r
/datum/disease2/disease/proc/get_tgui_info()
. = list(
"name" = name(),
"spreadtype" = spreadtype,
"antigen" = antigens2string(antigen),
"rate" = stageprob * 10,
"resistance" = resistance,
"species" = jointext(affected_species, ", "),
"ref" = "\ref[src]",
)
var/list/symptoms = list()
for(var/datum/disease2/effectholder/E in effects)
symptoms.Add(list(list(
"stage" = E.stage,
"name" = E.effect.name,
"strength" = "[E.multiplier >= 3 ? "Severe" : E.multiplier > 1 ? "Above Average" : "Average"]",
"aggressiveness" = E.chance * 15,
)))
.["symptoms"] = symptoms
/datum/disease2/disease/proc/addToDB()
if ("[uniqueID]" in virusDB)
return 0
var/datum/data/record/v = new()
v.fields["id"] = uniqueID
v.fields["name"] = name()
v.fields["description"] = get_info()
v.fields["tgui_description"] = get_tgui_info()
v.fields["tgui_description"]["record"] = "\ref[v]"
v.fields["antigen"] = antigens2string(antigen)
v.fields["spread type"] = spreadtype
virusDB["[uniqueID]"] = v
return 1
/proc/virus2_lesser_infection()
var/list/candidates = list() //list of candidate keys
for(var/mob/living/carbon/human/G in GLOB.player_list)
if(G.client && G.stat != DEAD)
candidates += G
if(!candidates.len) return
candidates = shuffle(candidates)
infect_mob_random_lesser(candidates[1])
/proc/virus2_greater_infection()
var/list/candidates = list() //list of candidate keys
for(var/mob/living/carbon/human/G in GLOB.player_list)
if(G.client && G.stat != DEAD)
candidates += G
if(!candidates.len) return
candidates = shuffle(candidates)
infect_mob_random_greater(candidates[1])
/proc/virology_letterhead(var/report_name)
return {"
<center><h1><b>[report_name]</b></h1></center>
<center><small><i>[station_name()] Virology Lab</i></small></center>
<hr>
"}
/datum/disease2/disease/proc/can_add_symptom(type)
for(var/datum/disease2/effectholder/H in effects)
if(H.effect.type == type)
return 0
return 1