Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up code relating to pathogen clouds / infections #2784

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
#define FIRE_PRIORITY_AMBIENCE 10
#define FIRE_PRIORITY_GARBAGE 15
#define FIRE_PRIORITY_DATABASE 16
#define FIRE_PRIORITY_PATHOGEN 18
#define FIRE_PRIORITY_WET_FLOORS 20
#define FIRE_PRIORITY_FLUIDS 20
#define FIRE_PRIORITY_AIR 20
Expand All @@ -220,7 +221,6 @@
#define FIRE_PRIORITY_REAGENTS 26
#define FIRE_PRIORITY_SPACEDRIFT 30
#define FIRE_PRIORITY_HOTSPOT 30
#define FIRE_PRIORITY_PATHOGEN 31
#define FIRE_PRIORITY_SMOOTHING 35
#define FIRE_PRIORITY_OBJ 40
#define FIRE_PRIORITY_ACID 40
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ GLOBAL_LIST_INIT(virusDB, list())
return

if(mob.immune_system)
if(prob(10 - (robustness * 0.01))) //100 robustness don't auto cure
if(SPT_PROB(10 - (robustness * 0.01), seconds_per_tick)) //100 robustness don't auto cure
mob.immune_system.NaturalImmune()

if(!mob.immune_system.CanInfect(src))
Expand All @@ -176,11 +176,11 @@ GLOBAL_LIST_INIT(virusDB, list())
ticks += 10
else
logged_virusfood=0
if(prob(strength * 0.1))
if(SPT_PROB(strength * 0.1, seconds_per_tick))
incubate(mob, 1)

//Moving to the next stage
if(ticks > stage*100 && prob(stageprob))
if(ticks > (stage * 100) && SPT_PROB(stageprob, seconds_per_tick))
incubate(mob, 1)
if(stage < max_stages)
log += "<br />[ROUND_TIME()] NEXT STAGE ([stage])"
Expand Down Expand Up @@ -222,7 +222,7 @@ GLOBAL_LIST_INIT(virusDB, list())
if (MOB_SIZE_HUGE)
mob.bodytemperature += fever*2

if (fever > 0 && prob(3))
if (fever > 0 && SPT_PROB(3, seconds_per_tick))
switch (fever_warning)
if (0)
to_chat(mob, span_warning("You feel a fever coming on, your body warms up and your head hurts a bit."))
Expand Down
30 changes: 18 additions & 12 deletions monkestation/code/modules/virology/effects/cleanables.dm
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
GLOBAL_LIST_INIT(infected_cleanables, list())
GLOBAL_LIST_EMPTY_TYPED(infected_cleanables, /obj/effect/decal/cleanable)

/obj/effect/decal/cleanable/Initialize(mapload, list/datum/disease/diseases)
..()
return INITIALIZE_HINT_LATELOAD

/obj/effect/decal/cleanable/LateInitialize()
. = ..()
spawn(1)//cleanables can get infected in many different ways when they spawn so it's much easier to handle the pathogen overlay here after a delay
if (src.diseases && length(src.diseases))
GLOB.infected_cleanables += src
if (!pathogen)
pathogen = image('monkestation/code/modules/virology/icons/effects.dmi',src,"pathogen_blood")
pathogen.plane = HUD_PLANE
pathogen.appearance_flags = RESET_COLOR|RESET_ALPHA
for (var/mob/L in GLOB.science_goggles_wearers)
if (L.client)
L.client.images |= pathogen
addtimer(CALLBACK(src, PROC_REF(handle_pathogen_images)), 0.1 SECONDS, TIMER_DELETE_ME)

/obj/effect/decal/cleanable/proc/handle_pathogen_images()
if(!length(diseases))
return
GLOB.infected_cleanables += src
if(!pathogen)
pathogen = image('monkestation/code/modules/virology/icons/effects.dmi', src, "pathogen_blood")
pathogen.plane = HUD_PLANE
pathogen.appearance_flags = RESET_COLOR|RESET_ALPHA
for (var/mob/wearer in GLOB.science_goggles_wearers)
wearer.client?.images |= pathogen

/obj/effect/decal/cleanable/Destroy()
. = ..()
GLOB.infected_cleanables -= src
return ..()

/obj/effect/decal/cleanable/Entered(mob/living/perp)
..()
Expand Down
162 changes: 81 additions & 81 deletions monkestation/code/modules/virology/effects/pathogen_cloud.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GLOBAL_LIST_INIT(pathogen_clouds, list())
GLOBAL_LIST_INIT(science_goggles_wearers, list())
GLOBAL_LIST_EMPTY(pathogen_clouds)
GLOBAL_LIST_EMPTY(science_goggles_wearers)

/obj/effect/pathogen_cloud
name = ""
Expand All @@ -13,115 +13,115 @@ GLOBAL_LIST_INIT(science_goggles_wearers, list())
anchored = 0
density = 0
var/mob/source = null
var/sourceIsCarrier = TRUE
var/list/viruses = list()
var/source_is_carrier = TRUE
var/list/viruses
var/lifetime = 10 SECONDS //how long until we naturally disappear, humans breath about every 8 seconds, so it has to survive at least this long to have a chance to infect
var/turf/target = null //when created, we'll slowly move toward this turf
var/core = FALSE
var/modified = FALSE
var/moving = TRUE
var/list/id_list = list()
var/list/id_list
var/death = 0

/obj/effect/pathogen_cloud/New(turf/loc, mob/sourcemob, list/virus, isCarrier = TRUE, isCore = TRUE)
..()
if (!loc || !virus || virus.len <= 0)
qdel(src)
return
core = isCore
sourceIsCarrier = isCarrier
GLOB.pathogen_clouds += src

viruses = virus
/obj/effect/pathogen_cloud/Initialize(mapload, mob/source, list/viruses, is_carrier = TRUE, is_core = TRUE)
. = ..()
if (QDELETED(loc) || !LAZYLEN(viruses))
return INITIALIZE_HINT_QDEL
src.source = source
src.viruses = viruses
src.source_is_carrier = is_carrier
src.core = is_core

for(var/datum/disease/advanced/D as anything in viruses)
id_list += "[D.uniqueID]-[D.subID]"
for(var/datum/disease/advanced/virus as anything in viruses)
LAZYADD(id_list, "[virus.uniqueID]-[virus.subID]")

if(!core)
var/obj/effect/pathogen_cloud/core/core = locate(/obj/effect/pathogen_cloud/core) in src.loc
if(get_turf(core) == get_turf(src))
for(var/datum/disease/advanced/V as anything in viruses)
if("[V.uniqueID]-[V.subID]" in core.id_list)
var/obj/effect/pathogen_cloud/core/existing_core = locate(/obj/effect/pathogen_cloud/core) in src.loc
if(!QDELETED(existing_core))
for(var/datum/disease/advanced/virus as anything in viruses)
if("[virus.uniqueID]-[virus.subID]" in existing_core.id_list)
continue
core.viruses |= V.Copy()
core.modified = TRUE
qdel(src)
LAZYOR(existing_core.viruses, virus.Copy())
existing_core.modified = TRUE
return INITIALIZE_HINT_QDEL

if(istype(src, /obj/effect/pathogen_cloud/core))
SSpathogen_clouds.cores += src
else
SSpathogen_clouds.clouds += src
GLOB.pathogen_clouds += src
register()

pathogen = image('monkestation/code/modules/virology/icons/96x96.dmi',src,"pathogen_airborne")
pathogen = image('monkestation/code/modules/virology/icons/96x96.dmi', src, "pathogen_airborne")
pathogen.plane = HUD_PLANE
pathogen.appearance_flags = RESET_COLOR|RESET_ALPHA
for (var/mob/living/L as anything in GLOB.science_goggles_wearers)
if (L.client)
L.client.images |= pathogen
pathogen.appearance_flags = RESET_COLOR | RESET_ALPHA
for (var/mob/living/wearer in GLOB.science_goggles_wearers)
wearer.client?.images |= pathogen

source = sourcemob
if(lifetime)
QDEL_IN(src, lifetime)

death = world.time + lifetime
/obj/effect/pathogen_cloud/Destroy()
GLOB.pathogen_clouds -= src
unregister()
if(pathogen)
for(var/mob/living/wearer in GLOB.science_goggles_wearers)
wearer.client?.images -= pathogen
pathogen = null
source = null
viruses = null
target = null
return ..()

START_PROCESSING(SSpathogen_processing, src)
/obj/effect/pathogen_cloud/proc/register()
SSpathogen_clouds.clouds += src

/obj/effect/pathogen_cloud/process(seconds_per_tick)
if(death <= world.time)
qdel(src)
return PROCESS_KILL
/obj/effect/pathogen_cloud/proc/unregister()
SSpathogen_clouds.clouds -= src
SSpathogen_clouds.current_run_clouds -= src

/obj/effect/pathogen_cloud/core
core = TRUE

/obj/effect/pathogen_cloud/Destroy()
. = ..()
STOP_PROCESSING(SSpathogen_processing, src)

if(istype(src, /obj/effect/pathogen_cloud/core))
SSpathogen_clouds.cores -= src
SSpathogen_clouds.current_run_cores -= src
else
SSpathogen_clouds.clouds -= src
SSpathogen_clouds.current_run_clouds -= src

if (pathogen)
for (var/mob/living/L in GLOB.science_goggles_wearers)
if (L.client)
L.client.images -= pathogen
pathogen = null
GLOB.pathogen_clouds -= src
source = null
viruses = list()
lifetime = 3
target = null
/obj/effect/pathogen_cloud/core/Initialize(mapload, mob/source, list/viruses, is_carrier = TRUE, is_core = TRUE)
. = ..()

/obj/effect/pathogen_cloud/core/New(turf/loc, mob/sourcemob, list/virus)
..()
if (!loc || !virus || virus.len <= 0)
if(.)
return

var/strength = 0
for (var/datum/disease/advanced/V as anything in viruses)
strength += V.infectionchance
strength = round(strength/viruses.len)
var/list/possible_turfs = list()
for (var/turf/open/T in range(max(0,(strength/20)-1),loc))//stronger viruses can reach turfs further away.
if(isclosedturf(T))
continue
possible_turfs += T
target = pick(possible_turfs)
for (var/datum/disease/advanced/virus as anything in viruses)
strength += virus.infectionchance
strength = round(strength / length(viruses))
var/spread_range = max(0, (strength / 20) - 1)
if(spread_range > 0)
var/list/possible_turfs = list()
for(var/turf/open/turf as anything in view(spread_range, loc)) //stronger viruses can reach turfs further away.
if(!isopenturf(turf) || QDELING(turf))
continue
possible_turfs += turf
if(length(possible_turfs))
target = pick(possible_turfs)
START_PROCESSING(SSpathogen_processing, src)

/obj/effect/pathogen_cloud/core/Destroy()
STOP_PROCESSING(SSpathogen_processing, src)
return ..()

/obj/effect/pathogen_cloud/core/register()
SSpathogen_clouds.cores += src

/obj/effect/pathogen_cloud/core/unregister()
SSpathogen_clouds.cores -= src
SSpathogen_clouds.current_run_cores -= src

/obj/effect/pathogen_cloud/core/process(seconds_per_tick)
. = ..()
if(!moving)
return PROCESS_KILL
var/turf/open/turf = get_turf(src)
if(!istype(turf) || QDELING(turf))
qdel(src)
return PROCESS_KILL
if ((turf != target) && moving)
if (prob(75))
if(!step_towards(src,target)) // we hit a wall and our momentum is shattered
if(!QDELETED(target) && SPT_PROB(75, seconds_per_tick))
if(!step_towards(src, target)) // we hit a wall and our momentum is shattered
moving = FALSE
else
step_rand(src)
var/obj/effect/pathogen_cloud/C = new /obj/effect/pathogen_cloud(turf, source, viruses, sourceIsCarrier, FALSE)
C.modified = modified
C.moving = FALSE
var/obj/effect/pathogen_cloud/new_cloud = new(turf, source, viruses, source_is_carrier, FALSE)
new_cloud.modified = src.modified
new_cloud.moving = FALSE
Loading
Loading