From 2fc96f13b416ce22635e334505efae968dad7768 Mon Sep 17 00:00:00 2001 From: skull132 Date: Sun, 2 Oct 2016 23:11:53 +0300 Subject: [PATCH] Antag Contest Update (#1029) Fixes #881 Contest: Fix assigning of self Fix objective hoarding Preferences Helpers So we have an easier way of keeping track who's represented where and how. Add aggressive objectives and remove passive ones. --- code/modules/antag_contest/contest_helpers.dm | 19 ++++++++ .../antag_contest/contest_objective.dm | 12 ++++++ code/modules/antag_contest/contest_verbs.dm | 43 ++++++++++++++++--- code/modules/client/client procs.dm | 1 - code/modules/client/preferences_sql.dm | 2 + html/changelogs/skull132_contest.yml | 7 +++ 6 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 html/changelogs/skull132_contest.yml diff --git a/code/modules/antag_contest/contest_helpers.dm b/code/modules/antag_contest/contest_helpers.dm index 9ca70ce093c..53235d77b50 100644 --- a/code/modules/antag_contest/contest_helpers.dm +++ b/code/modules/antag_contest/contest_helpers.dm @@ -23,3 +23,22 @@ return list(TCD, "Tup Commandos Division") else return list(INDEP, "Independent") + +// Helper vars for the datum class. Not for use outside of this module! +/datum/preferences/var/antag_contest_faction = null +/datum/preferences/var/antag_contest_side = null + +/datum/preferences/proc/load_character_contest(slot) + if (config.antag_contest_enabled && config.sql_enabled && establish_db_connection(dbcon)) + var/DBQuery/query = dbcon.NewQuery("SELECT contest_faction FROM ss13_contest_participants WHERE character_id = :char_id") + query.Execute(list(":char_id" = slot)) + + if (query.NextRow()) + antag_contest_faction = text2num(query.item[1]) + + if (antag_contest_faction in contest_factions_prosynth) + antag_contest_side = PRO_SYNTH + else if (antag_contest_faction in contest_factions_antisynth) + antag_contest_side = ANTI_SYNTH + else + antag_contest_side = 0 diff --git a/code/modules/antag_contest/contest_objective.dm b/code/modules/antag_contest/contest_objective.dm index d3f22aa97ab..2b88ed59b46 100644 --- a/code/modules/antag_contest/contest_objective.dm +++ b/code/modules/antag_contest/contest_objective.dm @@ -69,6 +69,18 @@ if (log_query.ErrorMsg()) log_debug("CONTEST: Error uploading results. Datadump: [list2params(params)]") +/* + * One flippy objective. + */ +/datum/objective/competition/assassinate_supporter/find_target() + var/list/possible_targets = list() + for(var/datum/mind/possible_target in ticker.minds) + if(possible_target != owner && ishuman(possible_target.current) && (possible_target.current.stat != 2)) + if (possible_target.current.client && possible_target.current.client.prefs && possible_target.current.client.prefs.antag_contest_side != side) + possible_targets += possible_target + if(possible_targets.len > 0) + target = pick(possible_targets) + /* * Pro-synth objectives */ diff --git a/code/modules/antag_contest/contest_verbs.dm b/code/modules/antag_contest/contest_verbs.dm index 6c9ab2a037a..b731e85808a 100644 --- a/code/modules/antag_contest/contest_verbs.dm +++ b/code/modules/antag_contest/contest_verbs.dm @@ -88,6 +88,16 @@ src << "You do not have a valid role! You must be a traitor, mercenary, or a raider for these to be usable! Contact an admin if you need assignment." return + if (src.mob.mind.objectives.len >= 3) + var/uncompleted_objectives = 0 + for (var/datum/objective/O in src.mob.mind.objectives) + if (!O.completed) + uncompleted_objectives++ + + if (uncompleted_objectives >= 3) + src << span("warning", "You have [uncompleted_objectives] uncompleted objectives underway right now. Please finish them before requesting new ones.") + return + if (!establish_db_connection(dbcon)) src << "Failed to establish SQL connection! Contact a member of staff!" return @@ -105,15 +115,15 @@ var/list/faction_data = contest_faction_data(part_check.item[1]) if (side == "Pro-synth") - if (faction_data[1] in contest_factions_antisynth && alert("This choice goes against your faction's current allegience.\nDo you wish to continue?", "Yes", "No") == "No") + if (faction_data[1] in contest_factions_antisynth && alert("This choice goes against your faction's current allegience.\nDo you wish to continue?", "Decisions", "Yes", "No") == "No") return - available_objs = list("Promote a Synth", "Protect Robotics", "Borgify", "Protect a Synth", "Unslave Borgs") + available_objs = list("Assassinate Anti-Synth Supporter", "Promote a Synth", "Borgify", "Unslave Borgs") else - if (faction_data[1] in contest_factions_prosynth && alert("This choice goes against your faction's current allegience.\nDo you wish to continue?", "Yes", "No") == "No") + if (faction_data[1] in contest_factions_prosynth && alert("This choice goes against your faction's current allegience.\nDo you wish to continue?", "Decisions", "Yes", "No") == "No") return - available_objs = list("Sabotage Robotics", "Fire a Synth", "Brig a Synth", "Harm a Synth") + available_objs = list("Assassinate Pro-Synth Supporter", "Sabotage Robotics", "Fire a Synth", "Brig a Synth", "Harm a Synth") if (!available_objs) src << "No objectives were found for you! This is odd!" @@ -125,22 +135,39 @@ src << "Cancelled." return - var/datum/objective/new_objective + var/datum/objective/competition/new_objective var/failed_target = 0 switch (choice) + if ("Assassinate Pro-Synth Supporter") + new_objective = new /datum/objective/competition/assassinate_supporter + new_objective.side = ANTI_SYNTH + new_objective.type_name = "anti_synth/assassin" + new_objective.owner = src.mob.mind + if (!new_objective.find_target()) + failed_target = 1 + if ("Assassinate Anti-Synth Supporter") + new_objective = new /datum/objective/competition/assassinate_supporter + new_objective.side = PRO_SYNTH + new_objective.type_name = "pro_synth/assassin" + new_objective.owner = src.mob.mind + if (!new_objective.find_target()) + failed_target = 1 if ("Promote a Synth") new_objective = new /datum/objective/competition/pro_synth/promote + new_objective.owner = src.mob.mind if (!new_objective.find_target()) failed_target = 1 if ("Protect Robotics") new_objective = new /datum/objective/competition/pro_synth/protect_robotics if ("Borgify") new_objective = new /datum/objective/competition/pro_synth/borgify + new_objective.owner = src.mob.mind if (!new_objective.find_target()) failed_target = 1 if ("Protect a Synth") new_objective = new /datum/objective/competition/pro_synth/protect + new_objective.owner = src.mob.mind if (!new_objective.find_target()) failed_target = 1 if ("Unslave Borgs") @@ -161,14 +188,17 @@ new_objective = new /datum/objective/competition/anti_synth/sabotage if ("Fire a Synth") new_objective = new /datum/objective/competition/anti_synth/demote + new_objective.owner = src.mob.mind if (!new_objective.find_target()) failed_target = 1 if ("Brig a Synth") new_objective = new /datum/objective/competition/anti_synth/brig + new_objective.owner = src.mob.mind if (!new_objective.find_target()) failed_target = 1 if ("Harm a Synth") new_objective = new /datum/objective/competition/anti_synth/harm + new_objective.owner = src.mob.mind if (!new_objective.find_target()) failed_target = 1 else @@ -181,7 +211,8 @@ qdel(new_objective) return - new_objective.owner = src.mob.mind + if (!new_objective.owner) + new_objective.owner = src.mob.mind src.mob.mind.objectives += new_objective src << "New objective assigned! Have fun, and roleplay well!" log_admin("CONTEST: [key_name(src)] has assigned themselves an objective: [new_objective.type].") diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index b0e168fac50..2715e4a68c6 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -167,7 +167,6 @@ if ("logie") if (config.sql_stats && href_list["ie_data"]) - testing("Data recovered: [href_list["ie_data"]]") var/list/data = json_decode(href_list["ie_data"]) data["_ckey"] = src.ckey if (data.len != 7) diff --git a/code/modules/client/preferences_sql.dm b/code/modules/client/preferences_sql.dm index 1cbd946b3f1..7662f2f3a96 100644 --- a/code/modules/client/preferences_sql.dm +++ b/code/modules/client/preferences_sql.dm @@ -406,6 +406,8 @@ if (!faction) faction = "None" if (!religion) religion = "None" + load_character_contest(slot) + return 1 /datum/preferences/proc/save_character_sql(var/client/C) diff --git a/html/changelogs/skull132_contest.yml b/html/changelogs/skull132_contest.yml new file mode 100644 index 00000000000..6b6d475437a --- /dev/null +++ b/html/changelogs/skull132_contest.yml @@ -0,0 +1,7 @@ +author: Skull132 + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +changes: + - tweak: "Contest v2.5 is a thing now. Passive pro-synth objectives are gone, all major known exploits are gone, and a more aggressive pro-synth objective has been added."