Files
Aurora.3/code/datums/disease.dm
Lohikar f6dc33a465 Newmap - SMC, Openturf, Arrivals Controller, and Mine Turf Improvements (#1958)
* Replace SSingulo with SScalamity; processing cleanup
- SScalamity now handles blobs as well as singularity-types.
- Processing subtypes have been simplified to not require a stop_processing definition.

* this is probably important

* Remove cascade disabling SSgarbage

* Fixed a bug where dust() did not qdel the target mob

* Misc fixes

* Fix decals surviving break-to-plating

* Subsystem flag tweaks

* Apparently subsystems are new'd before config is.

* Fix paper icons

* Speculative fix for insane lag

* Better machinery stat

* Make organs not use SSoverlay

* Misc bugfixes & tweaks

* Nightmode fixes

* Changelog for SMC

* Port /tg/'s improved MC crash handling

* Add some more SS Recover() procs

* supply_controller -> SScargo

* More New() -> Initialize()

* pAI and robot construction overlays

* Fix cargo unit tests

* Merge the DMM Suite's atom/New() into atoms_init

* Lighting pre-baking

* Lighting initialization logging

* Fix some bad SS init orders

* Fix SSlighting logging; rename Processes to MC

* Speculative fix for insane GC lag

* Prebaked openturf/icon_smooth & fix lighting prebake

* SS init status; SSatoms LATEQDEL

* Fix bug with MC init stat panel

* Fix parallax

* Misc

* Ignore SS_NO_DISPLAY during init

* apparently this is important

* REEEEEE

* Image GC fixes; broadcaster radio-new sanity

* RCON Cleanup

* Move pAI recruiter into subsystem

* Move global solars list into sun subsystem

* Make chickens not use a global

* Demote SSdisposals to SS_BACKGROUND; garbage-debug cleanup

* Speed up space init a little

* Fix bad timer flags on floor drying

* Subsystem panic-restart verb for mins

* Explosion speedup

* Minor subsystem & MC logging tweaks

* SSopenturf improvements

* Make pipenet actually initialize (whoops)

* Minor tweaks

* Implement lighting rounding

* comments are hard okay

* Minor lattice tweaks

* Fix some timer issues & better closet init

* Timer sanity

* Request console tweaks + Storage init sanity

* Minor SSmachiner RCON improvements

* Further reduce world-start timer count

* Standardize subsystem logging

* Garbage hard delete profiling from /tg/

* Timer hang detection & recovery

* Log machines that sleep in process() and fuck up SSmachinery

* Fix an issue with external airlocks sleeping in process()

* Failsafe logging

* Minor tweaks

* Revert "Request console tweaks + Storage init sanity"

This reverts commit 98d3579e35.

* Re-implement RC changes

* Fix SQL FT saving

* Fix SSmachinery sleep in disposals

* Minor SS tweaks

* Paper fixes

* Blood drying fixes

* Merge gameticker and SSticker

* Minor global list init cleanup

* Lagcheck biogenerator & bags

* Tweak SScargo init order; RIG Initialize()

* Caching tweaks

* Remove rogue comma

* Initialize fixes

* Lighting destroy cleanup

* Fix emagging airlocks

* Initial SSicon implementation

* Tweaks & Fixes

* Fire + Air alarm queued icon updates

* Overlays + Queued icon cleanup

* Runtime & background fixes

* Kill some meaningless set statements

* Kill some image qdels

* Bump up lighting rounding val

* Fix adv. scanner destroy runtimes

* Remove unneeded icon update limiting

* Move icon smoothing into helpers

* Show a warning if DM 510 compiles without memory leak hack enabled

* Re-organize subsystems & MC defines a little

* Airlock SFX

* Log of Changes

* Make SSicon_update disable itself when not doing anything

* Fix respawn verb runtime when used early in server-init

* Add more information to MC's stat_entry()

* Replace direct refernces to gcDestroyed with QDEL* macros

* plant_controller -> SSplants

* More plant tweaks

* Add more humor to changelog

* Move parallax globals into SSparallax

* Lighting responsiveness tweaks

* Fix parallax init order & better MC init panel stat

* Make mobs GC

* More overlays + Remove intercom spawn()

* SSfast_process; make pinpointers not use spawn-recursion to process
Also made the SM Cascade beach process with SSprocessing instead of a spawn loop.

* Update changelog

* Mob GC tweaks

* Del() cleanup

* Fix insomniac ZAS connection edges

* Minor pAI cleanup

* Convert more things to SSoverlay; fix duplicated overlay in field gens

* SM Bluespace turf tweaks

* Update SSgarbage debug globals list

* Human-type qdel tweaks

* Subsystem suspension; stat_entry improvements

* SQL Statistics cleanup

* Fix runtimes with ambrosia

* More disable() -> suspend(); fix nightmode again

* Human qdel fix; minor tweaks

* Update turbolift to work with StonedMC

* Make lifts use timers instead of a subsystem

* Make SSassets start earlier

* Convert the radio controller into a subsystem

* Fix some missing CHECK_TICKs in asteroid generation

* MC stat tweaks; make shouldnt_see a typecache

* Kill some redundant debug-controller entries

* radio_controller -> SSradio

* Better SSgarbage hard-del logging from /tg/ upstream

* Logging tweaks + GELF

* Misc client caching improvements

* Slime SSoverlay

* Oven icon fixes

* Implant fixes
- Death implants will no longer spam Common on death of user.
- Death implants should handle a deleted user better.

* Holder tweaks + Welding tool Initialize()

* Fix some bad subsystem logging

* Fix suit cooling units spawning without cells

* Starlight tweaks

* Gibber infinite gib fix

* More SSoverlay stuff

* Make crates use CUT_OVERLAY_IN

* Make SSarrivals suspend instead of disable

* Make openturf use split/phased tick checks

* Speculative fix for unwet timer runtimes

* Blood overlay tweaks/fixes

* Update crusher to play nice with SMC + SSoverlay

* Openturf improvements and fixes

* Minor turbolift tweaks

* Lighting performance improvements + ChangeTurf tweaks

* this is probably important

* Fix wall weld noises on changeturf

* More ChangeTurf tweaks

* Explosion tweaks

* Pre-game lobby tweaks

* Openturf tweaks

* Prevent admins from starting the game before init finishes

* Fix Travis

* Kill an unused var

* Fix ChangeTurf runtimes on openturfs

* Fixes

* Browser datum fixes, asset caching

* Update changelog

* Changelog

* Lobby tweaks

* Ticker tweaks; kill ticker var

* Further lobby tweaks

* Cascade tweaks

* air_master -> SSair

* Reduce overhead from radio autosay

* alarm_manager -> SSalarm

* bomb_processor -> SSexplosives

* corp_regs -> SSlaw

* ZAS overlay fixes

* Small wall icon optimization

* Fix effects master

* Assembly tweaks

* Megavend fixes

* Shuttle fixes

* Camera alert performance improvements

* Fix some world.log spam from lighting overlays

* Fix some Initialize() procs

* Openspace responsiveness tweaks

* Make HE pipes animate through openturfs

* Kill a spawn
2017-05-02 14:40:40 -04:00

208 lines
7.1 KiB
Plaintext

#define SPECIAL -1
#define NON_CONTAGIOUS 0
#define BLOOD 1
#define CONTACT_FEET 2
#define CONTACT_HANDS 3
#define CONTACT_GENERAL 4
#define AIRBORNE 5
#define SCANNER 1
#define PANDEMIC 2
/*
IMPORTANT NOTE: Please delete the diseases by using cure() proc or qdel() instruction.
Diseases are referenced in a global list, so simply setting mob or obj vars
to null does not delete the object itself. Thank you.
*/
var/list/diseases = typesof(/datum/disease) - /datum/disease
/datum/disease
var/form = "Virus" //During medscans, what the disease is referred to as
var/name = "No disease"
var/stage = 1 //all diseases start at stage 1
var/max_stages = 0.0
var/cure = null
var/cure_id = null// reagent.id or list containing them
var/cure_list = null // allows for multiple possible cure combinations
var/cure_chance = 8//chance for the cure to do its job
var/spread = null //spread type description
var/initial_spread = null
var/spread_type = AIRBORNE
var/contagious_period = 0//the disease stage when it can be spread
var/list/affected_species = list()
var/mob/living/carbon/affected_mob = null //the mob which is affected by disease.
var/holder = null //the atom containing the disease (mob or obj)
var/carrier = 0.0 //there will be a small chance that the person will be a carrier
var/curable = 0 //can this disease be cured? (By itself...)
var/list/strain_data = list() //This is passed on to infectees
var/stage_prob = 4 // probability of advancing to next stage, default 4% per check
var/agent = "some microbes"//name of the disease agent
var/permeability_mod = 1//permeability modifier coefficient.
var/desc = null//description. Leave it null and this disease won't show in med records.
var/severity = null//severity descr
var/longevity = 150//time in "ticks" the virus stays in inanimate object (blood stains, corpses, etc). In syringes, bottles and beakers it stays infinitely.
var/list/hidden = list(0, 0)
var/can_carry = 1 // If the disease allows "carriers".
var/age = 0 // age of the disease in the current mob
var/stage_minimum_age = 0 // how old the disease must be to advance per stage
// if hidden[1] is true, then virus is hidden from medical scanners
// if hidden[2] is true, then virus is hidden from PANDEMIC machine
/datum/disease/proc/stage_act()
// Some species are immune to viruses entirely.
if(affected_mob && istype(affected_mob, /mob/living/carbon/human))
var/mob/living/carbon/human/H = affected_mob
if(H.species.virus_immune)
cure()
return
age++
var/cure_present = has_cure()
spread = (cure_present?"Remissive":initial_spread)
if(stage > max_stages)
stage = max_stages
if(!cure_present && prob(stage_prob) && age > stage_minimum_age) //now the disease shouldn't get back up to stage 4 in no time
stage = min(stage + 1, max_stages)
age = 0
else if(cure_present && prob(cure_chance))
stage = max(stage - 1, 1)
if(stage <= 1 && ((prob(1) && curable) || (cure_present && prob(cure_chance))))
cure()
return
return
/datum/disease/proc/has_cure()//check if affected_mob has required reagents.
if(!cure_id) return 0
var/result = 1
if(cure_list == list(cure_id))
if(istype(cure_id, /list))
for(var/C_id in cure_id)
if(!affected_mob.reagents.has_reagent(C_id))
result = 0
else if(!affected_mob.reagents.has_reagent(cure_id))
result = 0
else
for(var/C_list in cure_list)
if(istype(C_list, /list))
for(var/C_id in cure_id)
if(affected_mob.reagents != null)
result = 0
else if(!affected_mob.reagents.has_reagent(C_id))
result = 0
else if(affected_mob.reagents != null)
if(!affected_mob.reagents.has_reagent(C_list))
result = 0
return result
/datum/disease/proc/spread_by_touch()
switch(spread_type)
if(CONTACT_FEET, CONTACT_HANDS, CONTACT_GENERAL)
return 1
return 0
/datum/disease/proc/spread(var/atom/source=null, var/airborne_range = 2, var/force_spread)
//world << "Disease [src] proc spread was called from holder [source]"
// If we're overriding how we spread, say so here
var/how_spread = spread_type
if(force_spread)
how_spread = force_spread
if(how_spread == SPECIAL || how_spread == NON_CONTAGIOUS || how_spread == BLOOD)//does not spread
return
if(stage < contagious_period) //the disease is not contagious at this stage
return
if(!source)//no holder specified
if(affected_mob)//no mob affected holder
source = affected_mob
else //no source and no mob affected. Rogue disease. Break
return
if(affected_mob.reagents != null)
if(affected_mob)
if(affected_mob.reagents.has_reagent("spaceacillin"))
return // Don't spread if we have spaceacillin in our system.
var/check_range = airborne_range//defaults to airborne - range 2
if(how_spread != AIRBORNE && how_spread != SPECIAL)
check_range = 1 // everything else, like infect-on-contact things, only infect things on top of it
if(isturf(source.loc))
for(var/mob/living/carbon/M in oview(check_range, source))
if(isturf(M.loc))
if(AStar(source.loc, M.loc, /turf/proc/AdjacentTurfs, /turf/proc/Distance, check_range))
M.contract_disease(src, 0, 1, force_spread)
return
/datum/disease/process()
if(!holder)
STOP_PROCESSING(SSdisease, src)
return
if(prob(65))
spread(holder)
if(affected_mob)
for(var/datum/disease/D in affected_mob.viruses)
if(D != src)
if(IsSame(D))
//error("Deleting [D.name] because it's the same as [src.name].")
qdel(D) // if there are somehow two viruses of the same kind in the system, delete the other one
if(holder == affected_mob)
if(affected_mob.stat != DEAD) //he's alive
stage_act()
else //he's dead.
if(spread_type!=SPECIAL)
spread_type = CONTACT_GENERAL
affected_mob = null
if(!affected_mob) //the virus is in inanimate obj
// world << "[src] longevity = [longevity]"
if(prob(70))
if(--longevity<=0)
cure(0)
return
/datum/disease/proc/cure(var/resistance=1)//if resistance = 0, the mob won't develop resistance to disease
if(affected_mob)
if(resistance && !(type in affected_mob.resistances))
var/saved_type = "[type]"
affected_mob.resistances += text2path(saved_type)
/*if(istype(src, /datum/disease/alien_embryo)) //Get rid of the infection flag if it's a xeno embryo.
affected_mob.status_flags &= ~(XENO_HOST)*/
affected_mob.viruses -= src //remove the datum from the list
qdel(src) //delete the datum to stop it processing
return
/datum/disease/New(var/process=1, var/datum/disease/D)//process = 1 - adding the object to global list. List is processed by master controller.
cure_list = list(cure_id) // to add more cures, add more vars to this list in the actual disease's New()
if(process) // Viruses in list are considered active.
START_PROCESSING(SSdisease, src)
initial_spread = spread
/datum/disease/Destroy()
STOP_PROCESSING(SSdisease, src)
return ..()
/datum/disease/proc/IsSame(var/datum/disease/D)
if(istype(src, D.type))
return 1
return 0
/datum/disease/proc/Copy(var/process = 0)
return new type(process, src)