-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
pathogen.dm
1412 lines (1283 loc) · 52.2 KB
/
pathogen.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define COOLDOWN_MULTIPLIER 1
#define INFECT_NONE 0
#define INFECT_TOUCH 1
#define INFECT_AREA 3
#define INFECT_AREA_LARGE 5
// --SYMPTOM RARITIES--
// All symptom contains a rarity value. Use these constants to describe their rarity.
// For malevolent symptoms:
// RARITY_VERY_COMMON: The symptoms are barely noticable. Should not affect gameplay significantly or infect in a large area.
// RARITY_COMMON: The symptoms are noticeable, and may cause occasional inconveniences. May infect in a large area (instead).
// RARITY_UNCOMMON: The symptoms may do occasional damage or longer stuns.
// RARITY_RARE: The symptoms have a ramp in stages from relatively mundane to rather deadly.
// RARITY_VERY_RARE: You are fucked.
// For benevolent symptoms:
// RARITY_VERY_COMMON: As for malevolents, except in the positive direction obviously.
// RARITY_COMMON: The symptom may heal slightly or give an insignificant boost to any statistic.
// RARITY_UNCOMMON: Commonly symptoms which may give you an upper hand in a fight.
// RARITY_RARE: Power-healing and heavy offense/defense symptoms. May contain downsides.
// RARITY_VERY_RARE: God complex with actual godlike powers, traitor items infused in body. Should contain flipsides.
// And for all:
// RARITY_ABSTRACT: Used strictly for categorization. ABSTRACT symptoms will never appear.
// ie. if lingual is a symptom category with multiple subsymptoms (for easy mutex), it should be abstract.
// --SYMPTOM THREAT--
// All symptoms are catagorized with a threat value to describe the scope of their impact.
// Benign symptoms are negative. Malign symptoms are positive.
// THREAT_BENETYPE2: This symptom provides significant health benefits to infected individuals.
// THREAT_BENETYPE1: This symptom provides marginal benefits to infected individuals.
// THREAT_NEUTRAL: The symptom causes no impactful harm or good to infected individuals.
// THREAT_TYPE1: This symptom causes barely noticable, nonfatal harm to infected individuals. Should not affect gameplay mechanically.
// THREAT_TYPE2: This symptom causes noticable, but nonfatal harm to infected individuals. Should not significantly impede gameplay.
// THREAT_TYPE3: This symptom causes significant, but nonfatal harm to infected individuals. May damage the player or impede mechanical gameplay.
// THREAT_TYPE4: This symptom causes severe and potentially fatal harm to infected individuals. Critting from full should take at least 5 minutes unattended. Short stuns are OK.
// THREAT_TYPE5: This symptom is extremely dangerous and will certainly cause fatal harm to infected individuals. Anything that causes incapacitation goes HERE. Critting should take at least 3 minutes. Instant death and adjacent go here.
#define THREAT_BENETYPE2 = -2
#define THREAT_BENETYPE1 = -1
#define THREAT_NEUTRAL = 0
#define THREAT_TYPE1 = 1
#define THREAT_TYPE2 = 2
#define THREAT_TYPE3 = 3
#define THREAT_TYPE4 = 4
#define THREAT_TYPE5 = 5
#define RARITY_VERY_COMMON 1
#define RARITY_COMMON 2
#define RARITY_UNCOMMON 3
#define RARITY_RARE 4
#define RARITY_VERY_RARE 5
#define RARITY_ABSTRACT 0
datum/pathogen_cdc
var/uid = null
var/patient_zero = null
var/patient_zero_kname = ""
var/creation_time = null
var/microbody_type = null
var/list/infections = list()
var/list/mutations = list()
New(var/pathogen_uid)
..()
creation_time = world.time / 600
src.uid = pathogen_uid
datum/controller/pathogen
var/list/next_mutation = new/list()
var/list/pathogen_trees = new/list()
var/next_uid = 1
var/list/UID_to_symptom
var/list/symptom_to_UID
var/list/UID_to_suppressant
var/list/suppressant_to_UID
var/list/microbody_to_UID
var/list/UID_to_carrier
var/list/carrier_to_UID
var/list/path_to_symptom = list()
var/list/path_to_microbody = list()
var/list/path_to_suppressant = list()
var/list/path_to_mutation = list()
var/list/disabled_mutations = list()
var/list/pathogen_affected_reagents = list("blood", "pathogen", "bloodc")
var/list/microbody_choices = list()
var/choicemax = 0
var/list/l_vc
var/list/l_c
var/list/l_u
var/list/l_r
var/list/l_vr
var/list/lnums = list()
var/list/lalph = list()
var/list/nutrients = list()
var/list/media = list()
var/list/cure_bases = list()
proc/get_microbody(var/strength)
var/datum/microbody/M
var/finished = 0
var/tried = 0
while (!finished)
var/choice = rand(1, choicemax)
for (var/datum/choice/C in microbody_choices)
if (C.min <= choice && choice <= C.max)
M = C.target
if (M.strength <= strength)
finished = 1
else
tried++
if (tried > 10)
return M
return M
proc/mob_infected(var/datum/pathogen/P, var/mob/living/carbon/human/H)
var/datum/pathogen_cdc/CDC = src.pathogen_trees[P.name_base]
if (!CDC)
return
if (!CDC.patient_zero)
CDC.patient_zero = H
CDC.patient_zero_kname = "[H]"
if (!(P.name in CDC.mutations))
CDC.mutations += P.name
var/datum/pathogen/template = new /datum/pathogen
template.setup(0, P, 0)
CDC.mutations[P.name] = template
if (!(H in CDC.infections))
CDC.infections += H
CDC.infections[H] = P.name
proc/mob_cured(var/datum/pathogen/P, var/mob/living/carbon/human/H)
var/datum/pathogen_cdc/CDC = src.pathogen_trees[P.name_base]
if (!CDC)
return
if (H in CDC.infections)
CDC.infections -= H
P.oncured()
proc/patient_zero(var/datum/pathogen_cdc/CDC, var/topic_holder)
if (CDC.patient_zero)
return replacetext(CDC.patient_zero_kname, "%holder%", "\ref[topic_holder]")
Topic(href, href_list)
USR_ADMIN_ONLY
var/key = usr.ckey
var/th = locate(href_list["topic_holder"])
switch(href_list["action"])
if ("setstate")
cdc_state[key] = text2num_safe(href_list["state"])
if ("strain_cure")
var/strain = href_list["strain"]
var/datum/pathogen_cdc/CDC = pathogen_trees[strain]
var/count = 0
for (var/mob/living/carbon/human/H in mobs)
LAGCHECK(LAG_LOW)
if (CDC.uid in H.pathogens)
H.cured(H.pathogens[CDC.uid])
count++
message_admins("[key_name(usr)] cured [count] humans from pathogen strain [strain].")
if ("strain_details")
cdc_state[key] = href_list["strain"]
if ("pathogen_creator")
var/datum/pathogen/P = src.cdc_creator[usr.ckey]
switch (href_list["do"])
if ("reset")
src.gen_empty(usr.ckey)
if ("body_type")
var/list/types = list()
for (var/btpath in src.path_to_microbody)
var/datum/microbody/MB = src.path_to_microbody[btpath]
types += MB.name
types[MB.name] = MB
var/chosen = input("Which microbody?", "Microbody", types[1]) in types
P.body_type = types[chosen]
P.advance_speed = 25
P.suppression_threshold = 25
P.spread = 25
P.symptomatic = 1
P.generation = 1
P.stages = P.body_type.stages
if ("suppressant")
var/list/types = list()
for (var/spath in src.path_to_suppressant)
var/datum/suppressant/S = src.path_to_suppressant[spath]
types += S.name
types[S.name] = S
var/chosen = input("Which suppressant?", "Suppressant", types[1]) in types
P.suppressant = types[chosen]
P.desc = "[P.suppressant.color] dodecahedrical [P.body_type.plural]"
if ("add")
var/list/types = list()
for (var/efpath in src.path_to_symptom)
var/datum/pathogeneffects/EF = src.path_to_symptom[efpath]
types += EF.name
types[EF.name] = EF
var/chosen = input("Which symptom?", "Add new symptom", types[1]) in types
if (!(types[chosen] in P.effects))
P.effects += types[chosen]
var/datum/pathogeneffects/EF = types[chosen]
EF.onadd(P)
if ("remove")
var/datum/pathogeneffects/EF = locate(href_list["which"])
if (EF in P.effects)
P.effects -= EF
if ("advance_speed")
P.advance_speed = text2num_safe(input("New advance speed?", "Advance speed", P.advance_speed) as num) || P.advance_speed
if ("suppression_threshold")
P.suppression_threshold = text2num_safe(input("New suppression threshold?", "Suppression threshold", P.suppression_threshold) as num) || P.suppression_threshold
if ("spread")
P.spread = text2num_safe(input("New spread?", "Spread", P.spread) as num) || P.spread
if ("symptomatic")
P.symptomatic = !P.symptomatic
if ("stages")
var/value = P.stages
var/newval = text2num_safe(input("New stages (3-5)?", "Stages", value) as num) || value
if (newval >= 3 && newval <= 5)
P.stages = newval
if ("create")
P.dnasample = new/datum/pathogendna(P)
P.pathogen_uid = "p[next_uid]"
next_uid++
pathogen_trees += P.name_base
var/datum/pathogen_cdc/CDC = new /datum/pathogen_cdc(P.pathogen_uid)
pathogen_trees[P.name_base] = CDC
next_mutation[P.pathogen_uid] = P.mutation + 1
CDC.microbody_type = "[P.body_type]"
CDC.mutations += P.name
CDC.mutations[P.name] = P
message_admins("[key_name(usr)] created a new pathogen ([P]) via the creator.")
src.gen_empty(usr.ckey)
if ("strain_data")
var/datum/pathogen_cdc/CDC = locate(href_list["which"])
var/name = href_list["name"]
var/datum/pathogen/reference = CDC.mutations[name]
switch (href_list["data"])
if ("advance_speed")
var/value = reference.advance_speed
var/newval = text2num_safe(input("New advance speed?", "Advance speed", value) as num) || value
for (var/mob/living/carbon/human/H in CDC.infections)
if (CDC.uid in H.pathogens)
var/datum/pathogen/target = H.pathogens[CDC.uid]
if (target.name == name)
target.advance_speed = newval
reference.advance_speed = newval
message_admins("[key_name(usr)] set the advance speed on pathogen strain mutation [name] to [newval].")
if ("suppression_threshold")
var/value = reference.suppression_threshold
var/newval = text2num_safe(input("New suppression threshold?", "Suppression threshold", value) as num) || value
for (var/mob/living/carbon/human/H in CDC.infections)
if (CDC.uid in H.pathogens)
var/datum/pathogen/target = H.pathogens[CDC.uid]
if (target.name == name)
target.suppression_threshold = newval
reference.suppression_threshold = newval
message_admins("[key_name(usr)] set the suppression threshold on pathogen strain mutation [name] to [newval].")
if ("spread")
var/value = reference.spread
var/newval = text2num_safe(input("New spread?", "Spread", value) as num) || value
for (var/mob/living/carbon/human/H in CDC.infections)
if (CDC.uid in H.pathogens)
var/datum/pathogen/target = H.pathogens[CDC.uid]
if (target.name == name)
target.spread = newval
reference.spread = newval
message_admins("[key_name(usr)] set the spread on pathogen strain mutation [name] to [newval].")
if ("symptomatic")
var/value = reference.symptomatic
var/newval = !value
for (var/mob/living/carbon/human/H in CDC.infections)
if (CDC.uid in H.pathogens)
var/datum/pathogen/target = H.pathogens[CDC.uid]
if (target.name == name)
target.symptomatic = newval
reference.symptomatic = newval
message_admins("[key_name(usr)] set the symptomaticity for pathogen strain mutation [name] to [newval ? "Yes" : "No"].")
if ("stages")
var/value = reference.stages
var/newval = text2num_safe(input("New stages (3-5)?", "Stages", value) as num) || value
if (newval >= 3 && newval <= 5)
for (var/mob/living/carbon/human/H in CDC.infections)
if (CDC.uid in H.pathogens)
var/datum/pathogen/target = H.pathogens[CDC.uid]
if (target.name == name)
target.stages = newval
reference.stages = newval
message_admins("[key_name(usr)] set the stages on pathogen strain mutation [name] to [newval].")
if ("cure")
var/count = 0
for (var/mob/living/carbon/human/H in mobs)
LAGCHECK(LAG_LOW)
if (CDC.uid in H.pathogens)
var/datum/pathogen/P = H.pathogens[CDC.uid]
if (P.name == name)
H.cured(P)
count++
message_admins("[key_name(usr)] cured [count] humans from pathogen strain mutation [name].")
if ("infect")
var/mob/living/carbon/human/target = input("Who would you like to infect with this mutation?", "Infect") as mob in mobs//world
if (!istype(target))
boutput(usr, "<span class='alert'>Cannot infect that. Must be human.</span>")
else
target.infected(reference)
message_admins("[key_name(usr)] infected [target] with [name].")
if ("spawn")
var/obj/item/reagent_containers/glass/vial/V = new /obj/item/reagent_containers/glass/vial(get_turf(usr))
var/datum/reagent/blood/pathogen/RE = new /datum/reagent/blood/pathogen()
RE.volume = 5
RE.pathogens += reference.pathogen_uid
RE.pathogens[reference.pathogen_uid] = reference
RE.holder = V.reagents
V.reagents.reagent_list += RE.id
V.reagents.reagent_list[RE.id] = RE
V.reagents.update_total()
if ("microbody_data")
var/datum/microbody/MB = locate(href_list["which"])
switch (href_list["data"])
if ("stages")
var/new_stages = text2num_safe(input("Stage cap for [MB] microbodies? (3-5)", "Stage cap", MB.stages) as num) || MB.stages
if (new_stages >= 3 && new_stages <= 5)
MB.stages = new_stages
message_admins("[key_name(usr)] set the initial stage cap for pathogen microbody [MB.plural] to [new_stages].")
if ("vaccinable")
MB.vaccination = !MB.vaccination
message_admins("[key_name(usr)] set the vaccinability for pathogen microbody [MB.plural] to [MB.vaccination ? "On" : "Off"].")
if ("activity")
var/stage = text2num_safe(href_list["stage"])
var/new_act = text2num_safe(input("New activity percentage for stage [stage] of [MB] (0-100)?", "Activity", MB.activity[stage]) as num) || MB.activity[stage]
if (new_act >= 0 && new_act <= 100)
MB.activity[stage] = new_act
message_admins("[key_name(usr)] set the activity for pathogen microbody [MB.plural] on stage [stage] to [new_act].")
if ("symptom_data")
var/datum/pathogeneffects/EF = locate(href_list["which"])
switch (href_list["data"])
if ("info")
alert(usr, EF.desc)
cdc_main(th)
var/list/cdc_creator = list()
var/list/cdc_state = list()
var/static/list/states = list("strains", "symptoms", "microbodies", "suppressants", "mutations", "pathogen creator")
proc/severity_color(var/datum/pathogeneffects/EF)
if (EF.rarity == RARITY_ABSTRACT)
return "[EF]"
var/color_value = round(255 / EF.rarity)
if (istype(EF, /datum/pathogeneffects/malevolent))
return "<span style='color: rgb([color_value], 0, 0)'>[EF]</span>"
else
return "<span style='color: rgb(0, [color_value], 0)'>[EF]</span>"
proc/cdc_main(var/topic_holder)
if (!usr || !usr.client)
return
if (!usr.client.holder)
boutput(usr, "<span class='alert'>Visitors of the CDC are not allowed to interact with the equipment!</span>")
return
if (usr.client.holder.level < LEVEL_SA)
boutput(usr, "<span class='alert'>I'm sorry, you require a security clearance of Primary Researcher to go in there. Protocol and all. You know.</span>")
return
var/state = 1
if (usr.ckey in cdc_state)
state = cdc_state[usr.ckey]
else
cdc_state += usr.ckey
cdc_state[usr.ckey] = 1
var/stylesheet = {"<style>
.pathology-table { width: 100%; text-align: left; border-spacing: 0; border-collapse: collapse; }
.pathology-table thead th { background-color: #000066; color: white; font-weight: bold; border: none; }
.pathology-table td { border: none; border-bottom: 1px solid black; }
.pathology-table .small { font-size: 0.75em; }
.pathology-table .name { font-weight: bold; }
</style>"}
var/output = "<html><title>Center for Disease Control</title><head>[stylesheet]</head><body><h2>Center for Disease Control</h2>"
for (var/i = 1, i <= src.states.len, i++)
if (i != 1)
output += " - "
if (state != i)
output += "<a href='?src=\ref[src];action=setstate;state=[i];topic_holder=\ref[topic_holder]'>[states[i]]</a>"
else
output += "<span style='color:#dd0000; font-weight:bold'>[states[i]]</span>"
output += "<br>"
if (istext(state))
output += "<h3>Details for pathogen strain [state]</h3>"
if (state in pathogen_trees)
var/datum/pathogen_cdc/CDC = pathogen_trees[state]
output += "<table class='pathology-table'><thead><tr><th>Mutation name</th><th>Symptoms</th><th class='small'>Primary attributes</th><th>Symptomatic</th><th>Stages</th><th>Infected</th><th>Actions</th></thead><tbody>"
for (var/name in CDC.mutations)
output += "<tr>"
var/datum/pathogen/P = CDC.mutations[name]
output += "<td>[name]</td>"
var/symptoms = ""
var/first = 1
for (var/datum/pathogeneffects/EF in P.effects)
if (first)
symptoms = severity_color(EF)
first = 0
else
symptoms += "<BR>[severity_color(EF)]"
output += "<td>[symptoms]</td>"
output += "<td>"
output += "Advance speed: <a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=advance_speed;topic_holder=\ref[topic_holder]'>[P.advance_speed]</a><BR>"
output += "Suppression: <a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=suppression_threshold;topic_holder=\ref[topic_holder]'>[P.suppression_threshold]</a><BR>"
output += "Spread: <a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=spread;topic_holder=\ref[topic_holder]'>[P.spread]</a><BR>"
output += "</td>"
output += "<td><a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=symptomatic;topic_holder=\ref[topic_holder]'>[P.symptomatic ? "Yes" : "No"]</a></td>"
output += "<td><a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=stages;topic_holder=\ref[topic_holder]'>[P.stages]</a></td>"
var/infected = 0
for (var/mob/living/carbon/human/H in CDC.infections)
var/pname = CDC.infections[H]
if (pname == P.name)
infected++
output += "<td>[infected]</td>"
output += "<td>"
output += "<a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=spawn;topic_holder=\ref[topic_holder]'>(SPAWN)</a><br>"
output += "<a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=infect;topic_holder=\ref[topic_holder]'>(INFECT)</a><br>"
output += "<a href='?src=\ref[src];action=strain_data;which=\ref[CDC];name=[name];data=cure;topic_holder=\ref[topic_holder]'>(CURE)</a><br>"
output += "<a href='?src=\ref[topic_holder];action=view_logs_pathology_strain;presearch=[P.name]'>(LOGS)</a>"
output += "</td>"
output += "</tr>"
else
output += "<h3>This pathogen no longer exists.</h3>"
else
switch (states[state])
if ("strains")
output += "<table class='pathology-table'><thead><tr><th>Created</th><th>Strain name</th><th>UID</th><th>Patient Zero</th><th>Infected</th><th>Immune</th><th>Microbody</th><th>Cure all</th><th>Details</th><th>Logs</th></thead><tbody>"
for (var/pathogen_name in pathogen_trees)
var/datum/pathogen_cdc/CDC = pathogen_trees[pathogen_name]
output += "<tr>"
output += "<td class='name'>[round(CDC.creation_time)]M</td>"
output += "<td class='name'>[pathogen_name]</td>"
output += "<td>[CDC.uid]</td>"
if (CDC.patient_zero)
output += "<td>[CDC.patient_zero_kname]</td>"
else
output += "<td>No infections yet</td>"
var/infections = 0
var/immunities = 0
for (var/mob/living/carbon/human/M in mobs)
LAGCHECK(LAG_LOW)
if (CDC.uid in M.pathogens)
infections++
else if (CDC.uid in M.immunities)
immunities++
output += "<td>[infections]</td>"
output += "<td>[immunities]</td>"
output += "<td>[CDC.microbody_type]</td>"
output += "<td><a href='?src=\ref[src];action=strain_cure;strain=[pathogen_name];topic_holder=\ref[topic_holder]'>(CURE)</a></td>"
output += "<td><a href='?src=\ref[src];action=strain_details;strain=[pathogen_name];topic_holder=\ref[topic_holder]'>(VIEW)</a></td>"
output += "<td><a href='?src=\ref[topic_holder];action=view_logs_pathology_strain;presearch=[pathogen_name]'>(LOGS)</a></td>"
output += "</tr>"
output += "</tbody></table>"
if ("microbodies")
output += "<h3>Changes to stage cap only affects future pathogens.</h3>"
output += "<table class='pathology-table'><thead><tr><th>Name</th><th>Medium</tħ><th>Nutrition</th><th>Stages</th><th>Vaccinable</th><th>Activity</th></thead><tbody>"
for (var/microbody_path in src.path_to_microbody)
output += "<tr>"
var/datum/microbody/MB = src.path_to_microbody[microbody_path]
output += "<td class='name'>[MB]</td>"
output += "<td class='small'>[MB.growth_medium]</td>"
var/nutrition = ""
var/first = 1
for (var/nutrient in MB.nutrients)
if (first)
first = 0
else
nutrition += "<BR>"
nutrition += "[nutrient]"
output += "<td>[nutrition]</td>"
output += "<td><a href='?src=\ref[src];action=microbody_data;which=\ref[MB];data=stages;topic_holder=\ref[topic_holder]'>[MB.stages]</a></td>"
output += "<td><a href='?src=\ref[src];action=microbody_data;which=\ref[MB];data=vaccinable;topic_holder=\ref[topic_holder]'>[MB.vaccination ? "Yes" : "No"]</a></td>"
output += "<td>"
for (var/stage = 1, stage <= 5, stage++)
if (stage != 1)
output += "<br>"
output += "<a href='?src=\ref[src];action=microbody_data;which=\ref[MB];data=activity;stage=[stage];topic_holder=\ref[topic_holder]'>[MB.activity[stage]]%</a>"
output += "</td>"
output += "</tr>"
output += "</tbody></table>"
if ("symptoms")
output += "<table class='pathology-table'><thead><tr><th>Name</th><th>Info</th><th>Infection range</th><th>Infection coefficient</th><th>Rarity</th><th>DNA</th></thead><tbody>"
for (var/sym_path in src.path_to_symptom)
var/datum/pathogeneffects/EF = src.path_to_symptom[sym_path]
output += "<tr>"
output += "<td>[EF]</td>"
output += "<td><a href='?src=\ref[src];action=symptom_data;which=\ref[EF];data=info;topic_holder=\ref[topic_holder]'>Show information</a></td>"
output += "<td>[EF.infect_type]</td>"
output += "<td>[EF.infection_coefficient]</td>"
switch (EF.rarity)
if (RARITY_ABSTRACT)
output += "<td>Non-existent</td>"
if (RARITY_VERY_COMMON)
output += "<td>Very common</td>"
if (RARITY_COMMON)
output += "<td>Common</td>"
if (RARITY_UNCOMMON)
output += "<td>Uncommon</td>"
if (RARITY_RARE)
output += "<td>Rare</td>"
if (RARITY_VERY_RARE)
output += "<td>Very Rare</td>"
var/DNA = src.symptom_to_UID[EF.type]
output += "<td>[DNA]</td>"
output += "</tr>"
if ("suppressants")
output += "<table class='pathology-table'><thead><tr><th>Name</th><th>Suppression reagents</th></thead><tbody>"
for (var/sup_path in src.path_to_suppressant)
output += "<tr>"
var/datum/suppressant/S = src.path_to_suppressant[sup_path]
output += "<td>[S]</td>"
var/first = 1
var/supp = ""
for (var/reagent in S.cure_synthesis)
if (first)
first = 0
else
supp += "<BR>"
supp += "[reagent]"
output += "<td>[supp]</td>"
output += "</tr>"
if ("pathogen creator")
if (!(usr.ckey in src.cdc_creator))
src.gen_empty(usr.ckey)
var/datum/pathogen/P = src.cdc_creator[usr.ckey]
output += "<h3>Pathogen Creator</h3>"
output += "<b>Strain: </b> [P.name_base]<br>"
output += "<b>Base mutation:</b> [P.mutation]<br>"
output += "<b>Name: </b> [P.name]<br>"
if (P.suppressant)
output += "<b>Description: </b> [P.desc]<br>"
if (!P.body_type)
output += "<a href='?src=\ref[src];action=pathogen_creator;do=body_type;topic_holder=\ref[topic_holder]'>Assign microbody</a><br>"
else
output += "<b>Microbody:</b> [P.body_type]<br>"
output += "<b>Stages:</b> <a href='?src=\ref[src];action=pathogen_creator;do=stages;topic_holder=\ref[topic_holder]'>[P.stages]</a><br>"
output += "<b>Advance speed:</b> <a href='?src=\ref[src];action=pathogen_creator;do=advance_speed;topic_holder=\ref[topic_holder]'>[P.advance_speed]</a><br>"
output += "<b>Symptomatic:</b> <a href='?src=\ref[src];action=pathogen_creator;do=symptomatic;topic_holder=\ref[topic_holder]'>[P.symptomatic ? "Yes" : "No"]</a><br>"
output += "<b>Suppression threshold:</b> <a href='?src=\ref[src];action=pathogen_creator;do=suppression_threshold;topic_holder=\ref[topic_holder]'>[P.suppression_threshold]</a><br>"
output += "<b>Spread:</b> <a href='?src=\ref[src];action=pathogen_creator;do=spread;topic_holder=\ref[topic_holder]'>[P.spread]</a><br>"
if (!P.suppressant)
output += "<a href='?src=\ref[src];action=pathogen_creator;do=suppressant;topic_holder=\ref[topic_holder]'>Assign suppressant</a><br>"
else
output += "<b>Suppressant: </b>[P.suppressant]<br><br>"
output += "<b>Effects: </b><br>"
if (P.effects.len)
for (var/datum/pathogeneffects/EF in P.effects)
output += "- [EF] <a href='?src=\ref[src];action=pathogen_creator;do=remove;which=\ref[EF];topic_holder=\ref[topic_holder]'>(remove)</a><br>"
else
output += " -- None -- <br>"
output += "<a href='?src=\ref[src];action=pathogen_creator;do=add;topic_holder=\ref[topic_holder]'>Add effect</a><br><br>"
output += "<a href='?src=\ref[src];action=pathogen_creator;do=reset;topic_holder=\ref[topic_holder]'>Reset pathogen</a>"
if (P.body_type && P.suppressant && length(P.effects))
output += " -- <a href='?src=\ref[src];action=pathogen_creator;do=create;topic_holder=\ref[topic_holder]'>Create pathogen</a>"
else
output += "<h1>NOTHING TO SEE HERE YET</h1>"
output += "</body></html>"
usr.Browse(output, "window=cdc;size=800x480")
proc/gen_empty(var/key)
if (!(key in src.cdc_creator))
src.cdc_creator += key
var/datum/pathogen/P = new /datum/pathogen
P.mutation = pick(lnums)
do
P.name_base = pick(lalph) + pick(lnums) + pick(lalph)
while (P.name_base in pathogen_trees)
P.name = P.name_base + P.mutation
P.mutation = text2num_safe(P.mutation)
P.base_mutation = 0
src.cdc_creator[key] = P
New()
..()
UID_to_symptom = list()
symptom_to_UID = list()
UID_to_suppressant = list()
suppressant_to_UID = list()
UID_to_carrier = list()
carrier_to_UID = list()
microbody_to_UID = list()
for (var/T in childrentypesof(/datum/microbody))
var/datum/microbody/B = new T()
microbody_to_UID[T] = B.uniqueid
path_to_microbody[T] = B
if (!(B.growth_medium in media))
media += B.growth_medium
if (!(B.cure_base in cure_bases))
cure_bases += B.cure_base
for (var/nutrient in B.nutrients)
if (!(nutrient in nutrients))
nutrients += nutrient
var/datum/choice/C = new
C.target = B
C.min = choicemax + 1
choicemax += B.commonness
C.max = choicemax
microbody_choices += C
var/list/eff = typesof(/datum/pathogeneffects)
l_vc = list()
l_c = list()
l_u = list()
l_r = list()
l_vr = list()
for (var/E in eff)
var/datum/pathogeneffects/inst = new E()
if (inst.rarity == RARITY_ABSTRACT)
continue
path_to_symptom[E] = inst
switch (inst.rarity)
if (RARITY_VERY_COMMON)
l_vc += E
if (RARITY_COMMON)
l_c += E
if (RARITY_UNCOMMON)
l_u += E
if (RARITY_RARE)
l_r += E
if (RARITY_VERY_RARE)
l_vr += E
var/list/used = list()
var/list/vc = list()
var/list/cp = list()
var/list/cu = list()
var/list/up = list()
var/list/uu = list()
var/list/rp = list()
var/list/ru = list()
var/list/vrp = list()
var/list/vru = list()
for (var/T in childrentypesof(/datum/suppressant))
var/r
do
r = num2hex(rand(0, 4095), 3)
while (r in used)
suppressant_to_UID[T] = r
UID_to_suppressant[r] = T
path_to_suppressant[T] = new T()
used += r
/*for (var/T in typesof(/datum/pathogen_carrier))
var/r
do
r = num2hex(rand(0, 4095), 3)
while (r in used)
carrier_to_UID[T] = r
UID_to_carrier[r] = new T()
used += r*/
// Assemble VERY_COMMON
for (var/T in l_vc)
var/r
do
r = num2hex(rand(0, 4095), 3)
while (r in used)
symptom_to_UID[T] = r
UID_to_symptom[r] = T
used += r
vc += r
// Create COMMON possibilities
for (var/p1 in vc)
for (var/p2 in vc)
if (!((p1 + p2) in cp))
cp += p1 + p2
if (!((p2 + p1) in cp))
cp += p2 + p1
// Assemble COMMON
for (var/T in l_c)
var/r
if (cp.len)
r = pick(cp)
else
do
r = pick(vc) + num2hex(rand(0, 4095), 3)
while (r in cu)
cp -= r
symptom_to_UID[T] = r
UID_to_symptom[r] = T
cu += r
// Create UNCOMMON possibilities
for (var/p1 in cu)
for (var/p2 in vc)
if (!((p1 + p2) in cp))
up += p1 + p2
if (!((p2 + p1) in cp))
up += p2 + p1
// Assemble UNCOMMON
for (var/T in l_u)
var/r
if (up.len)
r = pick(up)
else
do
r = pick(cu) + num2hex(rand(0, 4095), 3)
while (r in uu)
up -= r
symptom_to_UID[T] = r
UID_to_symptom[r] = T
uu += r
// Create RARE possibilities
for (var/p1 in uu)
for (var/p2 in vc)
if (!((p1 + p2) in cp))
rp += p1 + p2
if (!((p2 + p1) in cp))
rp += p2 + p1
// Assemble RARE
for (var/T in l_r)
var/r
if (rp.len)
r = pick(rp)
else
do
r = pick(uu) + num2hex(rand(0, 4095), 3)
while (r in ru)
rp -= r
symptom_to_UID[T] = r
UID_to_symptom[r] = T
ru += r
// Create VERY_RARE possibilities
for (var/p1 in ru)
for (var/p2 in vc)
if (!((p1 + p2) in cp))
vrp += p1 + p2
if (!((p2 + p1) in cp))
vrp += p2 + p1
// Assemble VERY_RARE
for (var/T in l_vr)
var/r
if (vrp.len)
r = pick(vrp)
else
do
r = pick(ru) + num2hex(rand(0, 4095), 3)
while (r in vru)
vrp -= r
symptom_to_UID[T] = r
UID_to_symptom[r] = T
vru += r
for (var/i = 1, i <= 99, i++)
lnums += "[i]"
for (var/i = text2ascii("A"), i <= text2ascii("Z"), i++)
lalph += ascii2text(i)
var/global/datum/controller/pathogen/pathogen_controller = new()
// A choice assistant datum
datum/choice
var/target
var/min = 0
var/max = 10
// todo: remove this, port.
// A wrapper record returned by the onshocked event of a pathogen symptom.
datum/shockparam
var/amt
var/wattage
var/skipsupp
// A pathogen. How surprising.
datum/pathogen
var/name // The full 'scientific' name for the pathogen (eg. H5N1)
var/name_base // The 'scientific' name without the mutation part (eg. H5N)
var/pathogen_uid // The unique identifier of the pathogen family. All pathogens with the same UID are cured by the same vaccine.
var/mutation // The mutation identifier of the pathogen (eg. for H5N1: 1). Unique for each mutation. Sequential.
var/desc // What a scientist might see when he looks at this pathogen through a microscope (eg. blue stringy viruses)
var/stages // How far the pathogen may advance? Higher stages allow for more malicious/benevolent effects of symptoms. (3 to 5)
// The amount of stages is determined by the body type. The most potent of all are viruses and parasites.
var/list/carriers = list() // A list of carriers to this pathogen. Currently unused.
var/list/effects = list() // A list of symptoms exhibited by those infected with this pathogen.
var/stage // The current stage of the pathogen.
var/advance_speed // The speed at which this pathogen advances stages. An advance speed of N means a flat N/100% chance to advance each tick.
var/base_mutation // Currently unused.
var/datum/microbody/body_type // The body type of the pathogen, which determines the capacity, maximum stat points, activity, and
var/mob/infected // The mob that is infected with this pathogen.
var/cooldown = 3 // An internal 'cooldown' so that the pathogen doesn't instantly advance to stage 5.
var/suppression_threshold // The pathogen's resistance to suppression. The higher this value, the more extreme conditions are required to suppress the pathogen.
var/spread // This determines how easily the pathogen spreads. How this affects spreading symptoms is up to each symptom to determine.
// For instance, a symptom that makes pathogen smoke might make more smoke
// while a pathogen that infects when hugging might have a higher chance to infect on each hug
var/list/mutex = list() // These symptoms are explicitly disallowed by a mutex.
var/symptomatic = 1 // If 0, the pathogen is mostly dormant on the mob. Symptoms may still decide to ignore this.
var/generation = 1 // Higher generation pathogens may replace lower generation pathogens on mobs.
var/datum/pathogendna/dnasample = null // A reference of what the pathogen's DNA looks like. This reference is passed around
// and copied only when coming into contact with something that directly works with
// the DNA itself.
var/datum/suppressant/suppressant // The method of suppression for the pathogen. This is picked from all children of /datum/suppressant with an equal
// probability. I might try to work out a system for rarities once, but it's very low on the priority list. To add a suppression method,
// just define a child for /datum/suppressant and please make sure it's not an already existing colour.
var/suppressed = 0 // A suppression indicator. After every roll for advancement, suppression is reset to 0 and a cooldown is set. Processes of the pathogen
// and the symptoms both may decide to set this flag during this cooldown. The pathogen immediately fails the advance roll if it is suppressed.
// With this being available, symptoms may define their own resistances and vulnerabilities. Setting this to -1 will make all current symptoms'
// vulnerability checks immediately fail - ie. the symptoms' weaknesses will not suppress the pathogen. On the flipside, setting this to 2 will
// make all current symptoms' resistance check immediately fail, ie. the symptoms' resistances will not prevent suppression. It would be good
// practice to build all symptoms consistently with this concept.
// Each disease has their primary suppression method, which provides their colour. The primary suppression method is relevant only if after
// all the symptoms acting, suppressed does not equal -1. Primary suppression methods may suppress the pathogen further: Even if a symptom
// has a weakness powerful enough to force it back a stage, a primary suppression method is also such a weakness that it may be pushed back
// yet another stage.
// A pathogen that cannot be currently suppressed (ie. is strengthened somehow) may advance regardless of advance speed.
// Be sensible when defining suppressions for symptoms. It shouldn't cure the pathogen, and it seldom should push the pathogen back below stage 3.
// TL;DR
// -1: Cannot be suppressed. May cause a negative advance speed pathogen to advance anyway.
// 0: Will not be suppressed.
// 1: Will be suppressed.
// 2: Will surely be suppressed.
var/in_remission = 0 // Pathogens in remission are being cured by the body. Set by the curing reagent.
var/forced_microbody = null // If not null, this pathogen will be generated with a specific microbody.
var/curable_by_suppression = 10 // If not 0, represents a probability of becoming regressive through suppression. If negative, randomly generated.
var/ticked = 0
var/list/symptom_data = list() // Symptom data container.
disposing()
clear()
..()
proc/clear()
name = ""
name_base = ""
pathogen_uid = null
mutation = null
desc = ""
stages = 1
carriers = list()
effects = list()
stage = 1
generation = 1
symptomatic = 1
advance_speed = 0
spread = 0
base_mutation = null
body_type = null
infected = null
cooldown = 3
suppression_threshold = 0
mutex = list()
dnasample = null
suppressant = null
suppressed = 0
in_remission = 0
ticked = 0
symptom_data = list()
forced_microbody = initial(forced_microbody)
curable_by_suppression = initial(curable_by_suppression)
proc/clone()
var/datum/pathogen/P = new /datum/pathogen
P.setup(0, src, 0)
return P
proc/do_prefab(var/strength = 0)
clear()
var/cdc = generate_name()
generate_components(cdc)
generate_attributes(strength)
New()
..()
setup(0, null, 0)
proc/create_weak()
randomize(0)
if (!dnasample)
dnasample = new/datum/pathogendna(src)
proc/cdc_announce(var/mob/M)
var/datum/pathogen_cdc/CDC = null
if (name_base in pathogen_controller.pathogen_trees)
CDC = pathogen_controller.pathogen_trees[name_base]
else
CDC = new /datum/pathogen_cdc(pathogen_uid)
pathogen_controller.pathogen_trees[name_base] = CDC
pathogen_controller.next_mutation[pathogen_uid] = mutation + 1
CDC.microbody_type = body_type
CDC.mutations += name
CDC.mutations[name] = clone()
return
proc/generate_name()
src.mutation = pick(pathogen_controller.lnums)
do
src.name_base = pick(pathogen_controller.lalph) + pick(pathogen_controller.lnums) + pick(pathogen_controller.lalph)
while (src.name_base in pathogen_controller.pathogen_trees)
src.name = name_base + mutation
src.mutation = text2num_safe(mutation)
src.base_mutation = 0
src.pathogen_uid = "p[pathogen_controller.next_uid]"
pathogen_controller.next_uid++
pathogen_controller.pathogen_trees += src.name_base
var/datum/pathogen_cdc/cdc = new /datum/pathogen_cdc(src.pathogen_uid)
pathogen_controller.pathogen_trees[src.name_base] = cdc
pathogen_controller.next_mutation[src.pathogen_uid] = mutation + 1
// if (ticker)
// if (current_state == GAME_STATE_PLAYING)
// message_admins("Pathogen tree [src.name_base] entering play.")
return cdc
proc/generate_components(var/datum/pathogen_cdc/cdc, var/strength)
var/supp_t = pick(pathogen_controller.path_to_suppressant)
suppressant = pathogen_controller.path_to_suppressant[supp_t]
suppressant.onadd(src)
if (!forced_microbody)
src.body_type = pathogen_controller.get_microbody(strength + 5)
cdc.microbody_type = "[src.body_type]"
else
src.body_type = pathogen_controller.path_to_microbody[forced_microbody]
cdc.microbody_type = "[src.body_type]"
proc/generate_randomized_effects(var/strength)
var/adj_strength = strength - 8
if (strength != -1)
var/effcount = pick(1, prob(50); 2, prob(25); 3, prob(10); 4, prob(10); 5)
for (var/i = 0, i < effcount, i++)
var/val = rand(adj_strength, adj_strength + 8)
if (val < 6)
generate_weak_effect()
else if (val < 14)
generate_effect()
else
generate_strong_effect()
proc/generate_attributes(var/strength)
var/adj_strength = strength - 8
src.suppression_threshold = 25 + rand(adj_strength - 8, adj_strength + 8)
src.advance_speed = 25 + rand(adj_strength - 8, adj_strength + 8)
src.spread = 25 + rand(adj_strength - 8, adj_strength + 8)
if (src.curable_by_suppression < 0 && strength < 10)
src.curable_by_suppression = rand(-10 + strength, 10 - strength)
if (src.curable_by_suppression < 0)
src.curable_by_suppression = 0
else
src.curable_by_suppression = 10
src.stages = src.body_type.stages
var/shape = pick("stringy", "snake", "blob", "spherical", "tetrahedral", "star shaped", "tesselated")
src.desc = "[src.suppressant.color] [shape] [src.body_type.plural]"
src.symptomatic = 1
src.generation = 1
src.stage = 1
proc/randomize(var/strength)
var/datum/pathogen_cdc/cdc = generate_name()
cdc.mutations += src.name
cdc.mutations[src.name] = src
generate_randomized_effects(strength)
generate_components(cdc, strength)
generate_attributes(strength)