/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)) return
usr << "Infection chance: [infectionchance]; Speed: [speed]; Spread type: [spreadtype]"
usr << "Affected species: [english_list(affected_species)]"
usr << "Effects:"
for(var/datum/disease2/effectholder/E in effects)
usr << "[E.stage]: [E.effect.name]; chance=[E.chance]; multiplier=[E.multiplier]"
usr << "Antigens: [antigens2string(antigen)]"
return 1
/datum/disease2/disease/get_view_variables_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/mob/living/carbon/infectee = null
// this holds spawned viruses so that the "Info" links work after the proc exits
var/list/spawned_viruses = list()
proc/select(mob/user, stage)
if(stage < 1 || stage > 4) return
var/list/L = list()
for(var/e in (typesof(/datum/disease2/effect) - /datum/disease2/effect))
var/datum/disease2/effect/f = e
if(initial(f.stage) <= stage)
L[initial(f.name)] = e
var/datum/disease2/effect/Eff = s[stage]
var/C = input("Select effect for stage [stage]:", "Stage [stage]", initial(Eff.name)) as null|anything in L
if(!C) return
return L[C]
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 all_species)
var/datum/species/S = 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]
"}
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")
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("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("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("Input infection chance", "Infection Chance", infectionchance) as null|num
if(!I) return
infectionchance = I
if("stype")
var/S = alert("Which spread type?", "Spread Type", "Cancel", "Contact", "Airborne")
if(!S || S == "Cancel") return
spreadtype = S
if("speed")
var/S = input("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("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) usr << "No possible candidates found!"
var/I = input("Choose initial infectee", "Infectee", infectee) as null|anything in candidates
if(!I || !candidates[I]) return
infectee = candidates[I]
species |= infectee.species.get_bodytype()
if("go")
if(!antigens.len)
var/a = alert("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", "Yes", "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
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)