Antag datum clean up/refactor (#15084)

This commit is contained in:
SteelSlayer
2021-11-25 01:29:46 -06:00
committed by GitHub
parent 57dcffa33e
commit 93908eefc8
13 changed files with 633 additions and 592 deletions
+42 -49
View File
@@ -159,15 +159,9 @@
/datum/mind/proc/gen_objective_text(admin = FALSE)
. = ""
var/obj_count = 1
var/list/all_objectives = list()
for(var/datum/antagonist/A in antag_datums)
all_objectives |= A.objectives
if(LAZYLEN(all_objectives))
for(var/datum/objective/objective in all_objectives)
. += "<br><B>Objective #[obj_count++]</B>: [objective.explanation_text]"
for(var/datum/objective/objective in objectives)
// If they don't have any objectives, "" will be returned.
for(var/datum/objective/objective in get_all_objectives())
. += "<b>Objective #[obj_count++]</b>: [objective.explanation_text]"
if(admin)
. += " <a href='?src=[UID()];obj_edit=\ref[objective]'>Edit</a> " // Edit
@@ -178,6 +172,22 @@
. += "</a>"
. += "<br>"
/**
* Gets every objective this mind owns, including all of those from any antag datums they have, and returns them as a list.
*/
/datum/mind/proc/get_all_objectives()
var/list/all_objectives = list()
for(var/antag in antag_datums)
var/datum/antagonist/A = antag
all_objectives += A.objectives // Add all antag datum objectives.
for(var/objective in objectives)
var/datum/objective/O = objective
all_objectives += O // Add all mind objectives.
return all_objectives
/datum/mind/proc/_memory_edit_header(gamemode, list/alt)
. = gamemode
if(SSticker.mode.config_tag == gamemode || (LAZYLEN(alt) && (SSticker.mode.config_tag in alt)))
@@ -325,7 +335,8 @@
. = _memory_edit_header("traitor", list("traitorchan", "traitorvamp"))
if(has_antag_datum(/datum/antagonist/traitor))
. += "<b><font color='red'>TRAITOR</font></b>|<a href='?src=[UID()];traitor=clear'>no</a>"
if(objectives.len==0)
var/datum/antagonist/traitor/T = has_antag_datum(/datum/antagonist/traitor)
if(!length(T.objectives))
. += "<br>Objectives are empty! <a href='?src=[UID()];traitor=autoobjectives'>Randomize!</a>"
else
. += "<a href='?src=[UID()];traitor=traitor'>traitor</a>|<b>NO</b>"
@@ -489,7 +500,7 @@
out += memory
out += "<br><a href='?src=[UID()];memory_edit=1'>Edit memory</a><br>"
out += "Objectives:<br>"
if(objectives.len == 0)
if(!length(get_all_objectives()))
out += "EMPTY<br>"
else
out += gen_objective_text(admin = TRUE)
@@ -701,6 +712,13 @@
var/datum/objective/objective = locate(href_list["obj_delete"])
if(!istype(objective))
return
for(var/antag in antag_datums)
var/datum/antagonist/A = antag
A.objectives -= objective
A.assigned_targets -= "[objective.target]"
if(istype(objective, /datum/objective/steal))
var/datum/objective/steal/S = objective
A.assigned_targets -= "[S.steal_target]"
objectives -= objective
log_admin("[key_name(usr)] has removed one of [key_name(current)]'s objectives: [objective]")
@@ -839,8 +857,6 @@
qdel(flash)
take_uplink()
var/fail = 0
var/datum/antagonist/traitor/T = has_antag_datum(/datum/antagonist/traitor)
fail |= !T.equip_traitor(src)
fail |= !SSticker.mode.equip_revolutionary(current)
if(fail)
to_chat(usr, "<span class='warning'>Reequipping revolutionary goes wrong!</span>")
@@ -1091,7 +1107,6 @@
if(has_antag_datum(/datum/antagonist/traitor))
to_chat(current, "<span class='warning'><FONT size = 3><B>You have been brainwashed! You are no longer a traitor!</B></FONT></span>")
remove_antag_datum(/datum/antagonist/traitor)
current.client.chatOutput?.clear_syndicate_codes()
log_admin("[key_name(usr)] has de-traitored [key_name(current)]")
message_admins("[key_name_admin(usr)] has de-traitored [key_name_admin(current)]")
@@ -1099,14 +1114,14 @@
if(!(has_antag_datum(/datum/antagonist/traitor)))
var/datum/antagonist/traitor/T = new()
T.give_objectives = FALSE
T.should_equip = FALSE
T.give_uplink = FALSE
add_antag_datum(T)
log_admin("[key_name(usr)] has traitored [key_name(current)]")
message_admins("[key_name_admin(usr)] has traitored [key_name_admin(current)]")
if("autoobjectives")
var/datum/antagonist/traitor/T = has_antag_datum(/datum/antagonist/traitor)
T.forge_traitor_objectives(src)
T.give_objectives()
to_chat(usr, "<span class='notice'>The objectives for traitor [key] have been generated. You can edit them and announce manually.</span>")
log_admin("[key_name(usr)] has automatically forged objectives for [key_name(current)]")
message_admins("[key_name_admin(usr)] has automatically forged objectives for [key_name_admin(current)]")
@@ -1424,8 +1439,7 @@
if("uplink")
if(has_antag_datum(/datum/antagonist/traitor))
var/datum/antagonist/traitor/T = has_antag_datum(/datum/antagonist/traitor)
T.give_codewords()
if(!T.equip_traitor(src))
if(!T.give_uplink())
to_chat(usr, "<span class='warning'>Equipping a syndicate failed!</span>")
return
log_admin("[key_name(usr)] has given [key_name(current)] an uplink")
@@ -1465,6 +1479,7 @@
var/datum/team/antag_team = A.get_team()
if(antag_team)
antag_team.add_member(src)
ASSERT(A.owner && A.owner.current)
A.on_gain()
return A
@@ -1473,6 +1488,8 @@
return
var/datum/antagonist/A = has_antag_datum(datum_type)
if(A)
if(!A.owner?.current)
CRASH("attempted to remove an antag datum ([A.type]) that didn't have an owner or owner.current")
A.on_removal()
return TRUE
@@ -1480,6 +1497,9 @@
/datum/mind/proc/remove_all_antag_datums() //For the Lazy amongst us.
for(var/a in antag_datums)
var/datum/antagonist/A = a
if(!A.owner?.current)
stack_trace("attempted to remove an antag datum ([A.type]) that didn't have an owner or owner.current")
continue
A.on_removal()
/datum/mind/proc/has_antag_datum(datum_type, check_subtypes = TRUE)
@@ -1614,7 +1634,6 @@
qdel(flash)
take_uplink()
var/fail = 0
// fail |= !ticker.mode.equip_traitor(current, 1)
fail |= !SSticker.mode.equip_revolutionary(current)
/datum/mind/proc/make_Abductor()
@@ -1704,38 +1723,12 @@
G.reenter_corpse()
/datum/mind/proc/make_zealot(mob/living/carbon/human/missionary, convert_duration = 6000, team_color = "red")
/datum/mind/proc/make_zealot(mob/living/carbon/human/missionary, convert_duration = 10 MINUTES, team_color = "red")
zealot_master = missionary
var/list/implanters
if(!(missionary.mind in SSticker.mode.implanter))
SSticker.mode.implanter[missionary.mind] = list()
implanters = SSticker.mode.implanter[missionary.mind]
implanters.Add(src)
SSticker.mode.implanted.Add(src)
SSticker.mode.implanted[src] = missionary.mind
SSticker.mode.implanter[missionary.mind] = implanters
SSticker.mode.traitors += src
var/datum/objective/protect/zealot_objective = new
zealot_objective.target = missionary.mind
zealot_objective.owner = src
zealot_objective.explanation_text = "Obey every order from and protect [missionary.real_name], the [missionary.mind.assigned_role == missionary.mind.special_role ? (missionary.mind.special_role) : (missionary.mind.assigned_role)]."
objectives += zealot_objective
add_antag_datum(/datum/antagonist/mindslave)
var/datum/antagonist/traitor/T = missionary.mind.has_antag_datum(/datum/antagonist)
T.update_traitor_icons_added(missionary.mind)
to_chat(current, "<span class='warning'><B>You're now a loyal zealot of [missionary.name]!</B> You now must lay down your life to protect [missionary.p_them()] and assist in [missionary.p_their()] goals at any cost.</span>")
var/datum/mindslaves/slaved = missionary.mind.som
som = slaved
slaved.serv += current
slaved.add_serv_hud(missionary.mind, "master") //handles master servent icons
slaved.add_serv_hud(src, "mindslave")
// Give the new zealot their mindslave datum with a custom greeting.
var/greeting = "You're now a loyal zealot of [missionary.name]!</B> You now must lay down your life to protect [missionary.p_them()] and assist in [missionary.p_their()] goals at any cost."
add_antag_datum(new /datum/antagonist/mindslave(missionary.mind, greeting))
var/obj/item/clothing/under/jumpsuit = null
if(ishuman(current)) //only bother with the jumpsuit stuff if we are a human type, since we won't have the slot otherwise
@@ -1747,7 +1740,7 @@
add_attack_logs(missionary, current, "Converted to a zealot for [convert_duration/600] minutes")
addtimer(CALLBACK(src, .proc/remove_zealot, jumpsuit), convert_duration) //deconverts after the timer expires
return 1
return TRUE
/datum/mind/proc/remove_zealot(obj/item/clothing/under/jumpsuit = null)
if(!zealot_master) //if they aren't a zealot, we can't remove their zealot status, obviously. don't bother with the rest so we don't confuse them with the messages
+2 -2
View File
@@ -85,7 +85,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
/datum/uplink_item/proc/spawn_item(turf/loc, obj/item/uplink/U)
if(hijack_only && !(usr.mind.special_role == SPECIAL_ROLE_NUKEOPS))//nukies get items that regular traitors only get with hijack. If a hijack-only item is not for nukies, then exclude it via the gamemode list.
if(!(locate(/datum/objective/hijack) in usr.mind.objectives))
if(!(locate(/datum/objective/hijack) in usr.mind.get_all_objectives()))
to_chat(usr, "<span class='warning'>The Syndicate will only issue this extremely dangerous item to agents assigned the Hijack objective.</span>")
return
@@ -1748,7 +1748,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
CU.hub = new(mind, CU)
// Update their mind stuff
LAZYSET(GLOB.contractors, mind, CU.hub)
AT.update_traitor_icons_added(mind)
AT.add_antag_hud(mind.current)
log_game("[key_name(usr)] became a Contractor")
return I