Files
CHOMPStation2/code/modules/virus2/helpers.dm
Chinsky 5703b8089d -Forgot to commit one file for previous iteration.
-Fixed derp with analyser.

Refactoring virus2, Part II - Viruses.
-Removed obsolete curing/resistance methods.
-Split base.dm into disease2.dm, effect.dm, helpers.dm.
2013-06-08 18:44:57 +04:00

84 lines
2.4 KiB
Plaintext

//Returns 1 if mob can be infected, 0 otherwise. Checks his clothing.
proc/get_infection_chance(var/mob/living/carbon/M)
var/score = 0
if (!istype(M))
return 0
if(istype(M, /mob/living/carbon/human))
if(M:gloves)
score += 5
if(istype(M:wear_suit, /obj/item/clothing/suit/space)) score += 10
if(istype(M:wear_suit, /obj/item/clothing/suit/bio_suit)) score += 10
if(istype(M:head, /obj/item/clothing/head/helmet/space)) score += 5
if(istype(M:head, /obj/item/clothing/head/bio_hood)) score += 5
if(M.wear_mask)
score += 5
if(istype(M:wear_mask, /obj/item/clothing/mask/surgical) && !M.internal)
score += 10
if(M.internal)
score += 10
if(score >= 30)
return 0
else if(score == 25 && prob(99))
return 0
else if(score == 20 && prob(95))
return 0
else if(score == 15 && prob(75))
return 0
else if(score == 10 && prob(55))
return 0
else if(score == 5 && prob(35))
return 0
return 1
//Checks if table-passing table can reach target (5 tile radius)
proc/airborne_can_reach(turf/source, turf/target)
var/obj/dummy = new(source)
dummy.flags = FPRINT | TABLEPASS
dummy.pass_flags = PASSTABLE
for(var/i=0, i<5, i++) if(!step_towards(dummy, target)) break
var/rval = (dummy.loc in range(1,target))
del dummy
return rval
//Attemptes to infect mob M with virus. Set forced to 1 to ignore protective clothnig
/proc/infect_virus2(var/mob/living/carbon/M,var/datum/disease2/disease/disease,var/forced = 0)
if(M.virus2)
return
if(!disease)
return
// if one of the antibodies in the mob's body matches one of the disease's antigens, don't infect
if(M.antibodies & disease.antigen != 0) return
if(prob(disease.infectionchance) || forced)
if(M.virus2)
return
else
// certain clothes can prevent an infection
if(!forced && !M.get_infection_chance())
return
M.virus2 = disease.getcopy()
M.virus2.minormutate()
//Infects mob M with random lesser disease, if he doesn't have one
/proc/infect_mob_random_lesser(var/mob/living/carbon/M)
if(!M.virus2)
M.virus2 = new /datum/disease2/disease
M.virus2.makerandom()
M.virus2.infectionchance = 1
//Infects mob M with random greated disease, if he doesn't have one
/proc/infect_mob_random_greater(var/mob/living/carbon/M)
if(!M.virus2)
M.virus2 = new /datum/disease2/disease
M.virus2.makerandom(1)
//Fancy prob() function.
/proc/dprob(var/p)
return(prob(sqrt(p)) && prob(sqrt(p)))