/datum/disease2/disease/Topic(href, href_list)
. = ..()
if(.) return
if(href_list["info"])
// spawn or admin privileges to see info about viruses
if(!check_rights(R_ADMIN|R_SPAWN|R_EVENT)) return
to_chat(usr, "Infection chance: [infectionchance]; Speed: [speed]; Spread type: [spreadtype]")
to_chat(usr, "Affected species: [english_list(affected_species)]")
to_chat(usr, "Effects:")
for(var/datum/disease2/effectholder/E in effects)
to_chat(usr, "[E.stage]: [E.effect.name]; chance=[E.chance]; multiplier=[E.multiplier]")
to_chat(usr, "Antigens: [antigens2string(antigen)]; Resistance: [resistance]")
return 1
/datum/disease2/disease/vv_get_header()
. = list()
for(var/datum/disease2/effectholder/E in effects)
. += "[E.stage]: [E.effect.name]"
return {"
[name()]
[jointext(., " ")]
"}
/datum/disease2/disease/get_view_variables_options()
return ..() + {"
"}
/datum/admins/var/datum/virus2_editor/virus2_editor_datum = new
/client/proc/virus2_editor()
set name = "Virus Editor"
set category = "Admin"
if(!holder || !check_rights(R_SPAWN)) return // spawn privileges to create viruses
holder.virus2_editor_datum.show_ui(src)
/datum/virus2_editor
var/list/s = list(/datum/disease2/effect/invisible,/datum/disease2/effect/invisible,/datum/disease2/effect/invisible,/datum/disease2/effect/invisible)
var/list/s_chance = list(1,1,1,1)
var/list/s_multiplier = list(1,1,1,1)
var/species = list()
var/infectionchance = 70
var/spreadtype = "Contact"
var/list/antigens = list()
var/speed = 1
var/resistance = 10
var/mob/living/carbon/infectee = null
// this holds spawned viruses so that the "Info" links work after the proc exits
var/list/spawned_viruses = list()
/datum/virus2_editor/proc/select(mob/user, stage)
if(stage < 1 || stage > 4) return
var/list/L = list()
for(var/datum/disease2/effect/f as anything in subtypesof(/datum/disease2/effect))
if(initial(f.stage) <= stage)
L[initial(f.name)] = f
var/datum/disease2/effect/Eff = s[stage]
var/C = tgui_input_list(usr, "Select effect for stage [stage]:", "Stage [stage]", L, Eff)
if(!C) return
return L[C]
/datum/virus2_editor/proc/show_ui(mob/user)
var/H = {"
Virus2 Virus Editor
Effects:
"}
for(var/i = 1 to 4)
var/datum/disease2/effect/Eff = s[i]
H += {"
[initial(Eff.name)]
Chance: [s_chance[i]]
Multiplier: [s_multiplier[i]]
"}
H += {"
Infectable Species:
"}
var/f = 1
for(var/k in GLOB.all_species)
var/datum/species/S = GLOB.all_species[k]
if(S.get_virus_immune())
continue
if(!f) H += " | "
else f = 0
H += "[k]"
H += {"
Reset Infection Chance:[infectionchance] Spread Type:[spreadtype] Speed:[speed] Resistance:[resistance]
"}
f = 1
for(var/k in ALL_ANTIGENS)
if(!f) H += " | "
else f = 0
H += "[k]"
H += {"
Reset Initial infectee:[infectee ? infectee : "(choose)"]RELEASE
"}
user << browse(H, "window=virus2edit")
/datum/virus2_editor/Topic(href, href_list)
switch(href_list["what"])
if("effect")
var/stage = text2num(href_list["stage"])
if(href_list["effect"])
var/datum/disease2/effect/E = select(usr,stage)
if(!E) return
s[stage] = E
// set a default chance and multiplier of half the maximum (roughly average)
s_chance[stage] = max(1, round(initial(E.chance_maxm)/2))
s_multiplier[stage] = max(1, round(initial(E.maxm)/2))
else if(href_list["chance"])
var/datum/disease2/effect/Eff = s[stage]
var/I = input(usr, "Chance, per tick, of this effect happening (min 0, max [initial(Eff.chance_maxm)])", "Effect Chance", s_chance[stage]) as null|num
if(I == null || I < 0 || I > initial(Eff.chance_maxm)) return
s_chance[stage] = I
else if(href_list["multiplier"])
var/datum/disease2/effect/Eff = s[stage]
var/I = input(usr, "Multiplier for this effect (min 1, max [initial(Eff.maxm)])", "Effect Multiplier", s_multiplier[stage]) as null|num
if(I == null || I < 1 || I > initial(Eff.maxm)) return
s_multiplier[stage] = I
if("species")
if(href_list["toggle"])
var/T = href_list["toggle"]
if(T in species)
species -= T
else
species |= T
else if(href_list["reset"])
species = list()
if(infectee)
if(!infectee.species || !(infectee.species.get_bodytype() in species))
infectee = null
if("ichance")
var/I = input(usr, "Input infection chance", "Infection Chance", infectionchance) as null|num
if(!I) return
infectionchance = I
if("stype")
var/S = tgui_alert(usr, "Which spread type?", "Spread Type", list("Contact", "Airborne", "Blood"))
if(!S) return
spreadtype = S
if("speed")
var/S = input(usr, "Input speed", "Speed", speed) as null|num
if(!S) return
speed = S
if("antigen")
if(href_list["toggle"])
var/T = href_list["toggle"]
if(length(T) != 1) return
if(T in antigens)
antigens -= T
else
antigens |= T
else if(href_list["reset"])
antigens = list()
if("resistance")
var/S = input(usr, "Input % resistance to antibiotics", "Resistance", resistance) as null|num
if(!S) return
resistance = S
if("infectee")
var/list/candidates = list()
for(var/mob/living/carbon/G in living_mob_list)
if(G.stat != DEAD && G.species)
if(G.species.get_bodytype() in species)
candidates["[G.name][G.client ? "" : " (no client)"]"] = G
else
candidates["[G.name] ([G.species.get_bodytype()])[G.client ? "" : " (no client)"]"] = G
if(!candidates.len)
to_chat(usr, "No possible candidates found!")
var/I = tgui_input_list(usr, "Choose initial infectee", "Infectee", candidates)
if(!I || !candidates[I]) return
infectee = candidates[I]
species |= infectee.species.get_bodytype()
if("go")
if(!antigens.len)
var/a = tgui_alert(usr, "This disease has no antigens; it will be impossible to permanently immunise anyone without them.\
It is strongly recommended to set at least one antigen. Do you want to go back and edit your virus?", "Antigens", list("Yes", "No"))
if(a == "Yes") return
var/datum/disease2/disease/D = new
D.infectionchance = infectionchance
D.spreadtype = spreadtype
D.antigen = antigens
D.affected_species = species
D.speed = speed
D.resistance = resistance
for(var/i in 1 to 4)
var/datum/disease2/effectholder/E = new
var/Etype = s[i]
E.effect = new Etype()
E.effect.generate()
E.chance = s_chance[i]
E.multiplier = s_multiplier[i]
E.stage = i
D.effects += E
spawned_viruses += D
message_admins("[key_name_admin(usr)] infected [key_name_admin(infectee)] with a virus (Info)")
log_admin("[key_name_admin(usr)] infected [key_name_admin(infectee)] with a virus!")
infect_virus2(infectee, D, forced=1)
show_ui(usr)