From 631e7bee3599b2acf802228b7d1d3e372a7146e5 Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 9 May 2018 19:08:07 -0700 Subject: [PATCH 1/6] DS / prefs fix --- code/__HELPERS/game.dm | 29 +++--- code/modules/admin/verbs/striketeam.dm | 92 ++++++++++--------- .../admin/verbs/striketeam_syndicate.dm | 11 ++- code/modules/client/preference/preferences.dm | 16 ++-- 4 files changed, 80 insertions(+), 68 deletions(-) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index 5c483b310fe..b62f32c2da9 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -490,19 +490,26 @@ proc/pollCandidates(Question, be_special_type, antag_age_check = 0, poll_time = return candidates -/proc/pollCandidatesByKeyWithVeto(adminclient, adminusr, max_slots, Question, be_special_type, antag_age_check = 0, poll_time = 300, ignore_respawnability = 0, min_hours = 0, flashwindow = TRUE, check_antaghud = TRUE) +/proc/pollCandidatesWithVeto(adminclient, adminusr, max_slots, Question, be_special_type, antag_age_check = 0, poll_time = 300, ignore_respawnability = 0, min_hours = 0, flashwindow = TRUE, check_antaghud = TRUE) var/list/willing_ghosts = pollCandidates(Question, be_special_type, antag_age_check, poll_time, ignore_respawnability, min_hours, flashwindow, check_antaghud) - var/list/candidate_ckeys = list() - var/list/selected_ckeys = list() + var/list/selected_ghosts = list() if(!willing_ghosts.len) - return selected_ckeys - for(var/mob/dead/observer/G in willing_ghosts) - candidate_ckeys += G.key - for(var/i = max_slots, (i > 0 && candidate_ckeys.len), i--) - var/this_ckey = input("Pick players. This will go on until there either no more ghosts to pick from or the slots are full.", "Candidates") as null|anything in candidate_ckeys - candidate_ckeys -= this_ckey - selected_ckeys += this_ckey - return selected_ckeys + return selected_ghosts + + var/list/candidate_ghosts = willing_ghosts.Copy() + + to_chat(adminusr, "Candidate Ghosts:"); + for(var/mob/dead/observer/G in candidate_ghosts) + if(G.key && G.client) + to_chat(adminusr, "- [G] ([G.key])"); + else + candidate_ghosts -= G + + for(var/i = max_slots, (i > 0 && candidate_ghosts.len), i--) + var/this_ghost = input("Pick players. This will go on until there either no more ghosts to pick from or the [i] remaining slot(s) are full.", "Candidates") as null|anything in candidate_ghosts + candidate_ghosts -= this_ghost + selected_ghosts += this_ghost + return selected_ghosts /proc/window_flash(client/C) if(ismob(C)) diff --git a/code/modules/admin/verbs/striketeam.dm b/code/modules/admin/verbs/striketeam.dm index d3c9ae98511..2a3de8b40fd 100644 --- a/code/modules/admin/verbs/striketeam.dm +++ b/code/modules/admin/verbs/striketeam.dm @@ -37,8 +37,8 @@ var/global/sent_strike_team = 0 break // Find ghosts willing to be DS - var/list/commando_ckeys = pollCandidatesByKeyWithVeto(src, usr, commandos_possible, "Join the DeathSquad?",, 21, 600, 1, role_playtime_requirements[ROLE_DEATHSQUAD], TRUE, FALSE) - if(!commando_ckeys.len) + var/list/commando_ghosts = pollCandidatesWithVeto(src, usr, commandos_possible, "Join the DeathSquad?",, 21, 200, 1, role_playtime_requirements[ROLE_DEATHSQUAD], TRUE, FALSE) + if(!commando_ghosts.len) to_chat(usr, "Nobody volunteered to join the DeathSquad.") return @@ -51,49 +51,50 @@ var/global/sent_strike_team = 0 if(commando_number<=0) break if(L.name == "Commando") - spawn(0) - var/use_ds_borg = FALSE - var/ghost_key // Ghost ckey that we intend to put into the commando. Can remain undefined if we don't have one. - if(commando_ckeys.len) - ghost_key = pick(commando_ckeys) - commando_ckeys -= ghost_key - if(!is_leader) - var/new_gender = alert(src, "Select Deathsquad Type.", "DS Character Generation", "Organic", "Cyborg") - if(new_gender == "Cyborg") - use_ds_borg = TRUE - - if(use_ds_borg) - var/mob/living/silicon/robot/deathsquad/R = new() - R.forceMove(get_turf(L)) - var/rnum = rand(1,1000) - var/borgname = "Epsilon [rnum]" - R.name = borgname - R.custom_name = borgname - R.real_name = R.name - R.mind = new - R.mind.current = R - R.mind.original = R - R.mind.assigned_role = "MODE" - R.mind.special_role = SPECIAL_ROLE_DEATHSQUAD - if(!(R.mind in ticker.minds)) - ticker.minds += R.mind - ticker.mode.traitors += R.mind - if(ghost_key) - R.key = ghost_key - if(nuke_code) - R.mind.store_memory("Nuke Code: [nuke_code].") - R.mind.store_memory("Mission: [input].") - to_chat(R, "You are a Special Operations cyborg, in the service of Central Command. \nYour current mission is: [input]") - else - var/mob/living/carbon/human/new_commando = create_death_commando(L, is_leader) - if(ghost_key) - new_commando.key = ghost_key - new_commando.internal = new_commando.s_store - new_commando.update_action_buttons_icon() - if(nuke_code) - new_commando.mind.store_memory("Nuke Code: [nuke_code].") - new_commando.mind.store_memory("Mission: [input].") - to_chat(new_commando, "You are a Special Ops [is_leader ? "TEAM LEADER" : "commando"] in the service of Central Command. Check the table ahead for detailed instructions.\nYour current mission is: [input]") + var/use_ds_borg = FALSE + var/mob/ghost_mob + if(commando_ghosts.len) + ghost_mob = pick(commando_ghosts) + commando_ghosts -= ghost_mob + if(!is_leader || TRUE) + var/new_gender = alert(ghost_mob.client, "Select Deathsquad Type.", "DS Character Generation", "Organic", "Cyborg") + if(new_gender == "Cyborg") + use_ds_borg = TRUE + else + continue + if(use_ds_borg) + var/mob/living/silicon/robot/deathsquad/R = new() + R.forceMove(get_turf(L)) + var/rnum = rand(1,1000) + var/borgname = "Epsilon [rnum]" + R.name = borgname + R.custom_name = borgname + R.real_name = R.name + R.mind = new + R.mind.current = R + R.mind.original = R + R.mind.assigned_role = "MODE" + R.mind.special_role = SPECIAL_ROLE_DEATHSQUAD + if(!(R.mind in ticker.minds)) + ticker.minds += R.mind + ticker.mode.traitors += R.mind + if(ghost_mob && ghost_mob.key) + R.key = ghost_mob.key + if(nuke_code) + R.mind.store_memory("Nuke Code: [nuke_code].") + R.mind.store_memory("Mission: [input].") + to_chat(R, "You are a Special Operations cyborg, in the service of Central Command. \nYour current mission is: [input]") + else + var/mob/living/carbon/human/new_commando = create_death_commando(L, is_leader) + if(ghost_mob && ghost_mob.key) + new_commando.mind.key = ghost_mob.key + new_commando.key = ghost_mob.key + new_commando.internal = new_commando.s_store + new_commando.update_action_buttons_icon() + if(nuke_code) + new_commando.mind.store_memory("Nuke Code: [nuke_code].") + new_commando.mind.store_memory("Mission: [input].") + to_chat(new_commando, "You are a Special Ops [is_leader ? "TEAM LEADER" : "commando"] in the service of Central Command. Check the table ahead for detailed instructions.\nYour current mission is: [input]") is_leader = FALSE commando_number-- @@ -133,6 +134,7 @@ var/global/sent_strike_team = 0 A.real_name = "[commando_rank] [commando_name]" A.copy_to(new_commando) + new_commando.dna.ready_dna(new_commando)//Creates DNA. //Creates mind stuff. diff --git a/code/modules/admin/verbs/striketeam_syndicate.dm b/code/modules/admin/verbs/striketeam_syndicate.dm index cc52adf40c6..bb0299c2000 100644 --- a/code/modules/admin/verbs/striketeam_syndicate.dm +++ b/code/modules/admin/verbs/striketeam_syndicate.dm @@ -45,8 +45,8 @@ var/global/sent_syndicate_strike_team = 0 break // Find ghosts willing to be SST - var/list/commando_ckeys = pollCandidatesByKeyWithVeto(src, usr, syndicate_commandos_possible, "Join the Syndicate Strike Team?",, 21, 600, 1, role_playtime_requirements[ROLE_DEATHSQUAD], TRUE, FALSE) - if(!commando_ckeys.len) + var/list/commando_ghosts = pollCandidatesWithVeto(src, usr, syndicate_commandos_possible, "Join the Syndicate Strike Team?",, 21, 600, 1, role_playtime_requirements[ROLE_DEATHSQUAD], TRUE, FALSE) + if(!commando_ghosts.len) to_chat(usr, "Nobody volunteered to join the SST.") return @@ -58,9 +58,10 @@ var/global/sent_syndicate_strike_team = 0 if(L.name == "Syndicate-Commando") var/mob/living/carbon/human/new_syndicate_commando = create_syndicate_death_commando(L, is_leader) - if(commando_ckeys.len) - new_syndicate_commando.key = pick(commando_ckeys) - commando_ckeys -= new_syndicate_commando.key + if(commando_ghosts.len) + var/mob/thisghost = pick(commando_ghosts) + new_syndicate_commando.key = thisghost.key + commando_ghosts -= thisghost new_syndicate_commando.internal = new_syndicate_commando.s_store new_syndicate_commando.update_action_buttons_icon() diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index ad25c8fdeb1..6b130a12b7b 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -209,6 +209,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts b_type = pick(4;"O-", 36;"O+", 3;"A-", 28;"A+", 1;"B-", 20;"B+", 1;"AB-", 5;"AB+") max_gear_slots = config.max_loadout_points + var/loaded_preferences_successfully = FALSE if(istype(C)) if(!IsGuestKey(C.key)) unlock_content = C.IsByondMember() @@ -217,16 +218,17 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(C.donator_level >= DONATOR_LEVEL_ONE) max_gear_slots += 5 - var/loaded_preferences_successfully = load_preferences(C) - if(loaded_preferences_successfully) - if(load_character(C)) - return + loaded_preferences_successfully = load_preferences(C) // Do not call this with no client/C, it generates a runtime / SQL error + if(loaded_preferences_successfully) + if(load_character(C)) + return //we couldn't load character data so just randomize the character appearance + name random_character() //let's create a random character then - rather than a fat, bald and naked man. real_name = random_name(gender) - if(!loaded_preferences_successfully) - save_preferences(C) - save_character(C) //let's save this new random character so it doesn't keep generating new ones. + if(istype(C)) + if(!loaded_preferences_successfully) + save_preferences(C) // Do not call this with no client/C, it generates a runtime / SQL error + save_character(C) // Do not call this with no client/C, it generates a runtime / SQL error /datum/preferences/proc/color_square(colour) return "___" From a44060da136fc71ae69926ee9de6749f1d2fd6f7 Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 9 May 2018 19:13:26 -0700 Subject: [PATCH 2/6] fixup --- code/modules/admin/verbs/striketeam.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/admin/verbs/striketeam.dm b/code/modules/admin/verbs/striketeam.dm index 2a3de8b40fd..0937ffa6169 100644 --- a/code/modules/admin/verbs/striketeam.dm +++ b/code/modules/admin/verbs/striketeam.dm @@ -37,7 +37,7 @@ var/global/sent_strike_team = 0 break // Find ghosts willing to be DS - var/list/commando_ghosts = pollCandidatesWithVeto(src, usr, commandos_possible, "Join the DeathSquad?",, 21, 200, 1, role_playtime_requirements[ROLE_DEATHSQUAD], TRUE, FALSE) + var/list/commando_ghosts = pollCandidatesWithVeto(src, usr, commandos_possible, "Join the DeathSquad?",, 21, 600, 1, role_playtime_requirements[ROLE_DEATHSQUAD], TRUE, FALSE) if(!commando_ghosts.len) to_chat(usr, "Nobody volunteered to join the DeathSquad.") return @@ -56,7 +56,7 @@ var/global/sent_strike_team = 0 if(commando_ghosts.len) ghost_mob = pick(commando_ghosts) commando_ghosts -= ghost_mob - if(!is_leader || TRUE) + if(!is_leader) var/new_gender = alert(ghost_mob.client, "Select Deathsquad Type.", "DS Character Generation", "Organic", "Cyborg") if(new_gender == "Cyborg") use_ds_borg = TRUE From e1cfc14799eca2545ba75db5307f146487801104 Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 9 May 2018 19:39:57 -0700 Subject: [PATCH 3/6] refactor --- code/modules/admin/verbs/striketeam.dm | 42 +++++++++++-------- .../admin/verbs/striketeam_syndicate.dm | 27 ++++++++---- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/code/modules/admin/verbs/striketeam.dm b/code/modules/admin/verbs/striketeam.dm index 0937ffa6169..f3298bb7eb9 100644 --- a/code/modules/admin/verbs/striketeam.dm +++ b/code/modules/admin/verbs/striketeam.dm @@ -47,21 +47,31 @@ var/global/sent_strike_team = 0 // Spawns commandos and equips them. var/commando_number = commandos_possible //for selecting a leader var/is_leader = TRUE // set to FALSE after leader is spawned + for(var/obj/effect/landmark/L in landmarks_list) - if(commando_number<=0) break + + if(commando_number <= 0) + break + if(L.name == "Commando") + if(!commando_ghosts.len) + break + var/use_ds_borg = FALSE - var/mob/ghost_mob - if(commando_ghosts.len) - ghost_mob = pick(commando_ghosts) - commando_ghosts -= ghost_mob - if(!is_leader) - var/new_gender = alert(ghost_mob.client, "Select Deathsquad Type.", "DS Character Generation", "Organic", "Cyborg") - if(new_gender == "Cyborg") - use_ds_borg = TRUE - else + var/mob/ghost_mob = pick(commando_ghosts) + commando_ghosts -= ghost_mob + if(!ghost_mob || !ghost_mob.key || !ghost_mob.client) continue + + if(!is_leader) + var/new_dstype = alert(ghost_mob.client, "Select Deathsquad Type.", "DS Character Generation", "Organic", "Cyborg") + if(new_dstype == "Cyborg") + use_ds_borg = TRUE + + if(!ghost_mob || !ghost_mob.key || !ghost_mob.client) // Have to re-check this due to the above alert() call + continue + if(use_ds_borg) var/mob/living/silicon/robot/deathsquad/R = new() R.forceMove(get_turf(L)) @@ -78,19 +88,17 @@ var/global/sent_strike_team = 0 if(!(R.mind in ticker.minds)) ticker.minds += R.mind ticker.mode.traitors += R.mind - if(ghost_mob && ghost_mob.key) - R.key = ghost_mob.key + R.key = ghost_mob.key if(nuke_code) R.mind.store_memory("Nuke Code: [nuke_code].") R.mind.store_memory("Mission: [input].") to_chat(R, "You are a Special Operations cyborg, in the service of Central Command. \nYour current mission is: [input]") else var/mob/living/carbon/human/new_commando = create_death_commando(L, is_leader) - if(ghost_mob && ghost_mob.key) - new_commando.mind.key = ghost_mob.key - new_commando.key = ghost_mob.key - new_commando.internal = new_commando.s_store - new_commando.update_action_buttons_icon() + new_commando.mind.key = ghost_mob.key + new_commando.key = ghost_mob.key + new_commando.internal = new_commando.s_store + new_commando.update_action_buttons_icon() if(nuke_code) new_commando.mind.store_memory("Nuke Code: [nuke_code].") new_commando.mind.store_memory("Mission: [input].") diff --git a/code/modules/admin/verbs/striketeam_syndicate.dm b/code/modules/admin/verbs/striketeam_syndicate.dm index bb0299c2000..52f50ded86b 100644 --- a/code/modules/admin/verbs/striketeam_syndicate.dm +++ b/code/modules/admin/verbs/striketeam_syndicate.dm @@ -54,16 +54,29 @@ var/global/sent_syndicate_strike_team = 0 //Spawns commandos and equips them. for(var/obj/effect/landmark/L in landmarks_list) - if(syndicate_commando_number<=0) break + + if(syndicate_commando_number <= 0) + break + if(L.name == "Syndicate-Commando") + + if(!commando_ghosts.len) + break + + var/mob/thisghost = pick(commando_ghosts) + commando_ghosts -= thisghost + + if(!thisghost.key || !ghost_mob.client) + continue + var/mob/living/carbon/human/new_syndicate_commando = create_syndicate_death_commando(L, is_leader) - if(commando_ghosts.len) - var/mob/thisghost = pick(commando_ghosts) - new_syndicate_commando.key = thisghost.key - commando_ghosts -= thisghost - new_syndicate_commando.internal = new_syndicate_commando.s_store - new_syndicate_commando.update_action_buttons_icon() + if(!new_syndicate_commando) + continue + + new_syndicate_commando.key = thisghost.key + new_syndicate_commando.internal = new_syndicate_commando.s_store + new_syndicate_commando.update_action_buttons_icon() //So they don't forget their code or mission. if(nuke_code) From 49c830457330198f78a0ec0c5b203e8cbe4bce06 Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 9 May 2018 19:49:18 -0700 Subject: [PATCH 4/6] standardization --- code/modules/admin/verbs/striketeam_syndicate.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/verbs/striketeam_syndicate.dm b/code/modules/admin/verbs/striketeam_syndicate.dm index 52f50ded86b..bf41a122a1d 100644 --- a/code/modules/admin/verbs/striketeam_syndicate.dm +++ b/code/modules/admin/verbs/striketeam_syndicate.dm @@ -63,10 +63,10 @@ var/global/sent_syndicate_strike_team = 0 if(!commando_ghosts.len) break - var/mob/thisghost = pick(commando_ghosts) - commando_ghosts -= thisghost + var/mob/ghost_mob = pick(commando_ghosts) + commando_ghosts -= ghost_mob - if(!thisghost.key || !ghost_mob.client) + if(!ghost_mob.key || !ghost_mob.client) continue var/mob/living/carbon/human/new_syndicate_commando = create_syndicate_death_commando(L, is_leader) From 6438c55ae25a1389562076647682e49166daf529 Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 9 May 2018 19:55:20 -0700 Subject: [PATCH 5/6] fixup --- code/modules/admin/verbs/striketeam_syndicate.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/admin/verbs/striketeam_syndicate.dm b/code/modules/admin/verbs/striketeam_syndicate.dm index bf41a122a1d..ff69d62a8ed 100644 --- a/code/modules/admin/verbs/striketeam_syndicate.dm +++ b/code/modules/admin/verbs/striketeam_syndicate.dm @@ -74,7 +74,7 @@ var/global/sent_syndicate_strike_team = 0 if(!new_syndicate_commando) continue - new_syndicate_commando.key = thisghost.key + new_syndicate_commando.key = ghost_mob.key new_syndicate_commando.internal = new_syndicate_commando.s_store new_syndicate_commando.update_action_buttons_icon() From 213704c3ef2c8f7c2b066fa1855097762b51f28a Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 9 May 2018 20:11:28 -0700 Subject: [PATCH 6/6] more safety --- code/modules/admin/verbs/striketeam_syndicate.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/admin/verbs/striketeam_syndicate.dm b/code/modules/admin/verbs/striketeam_syndicate.dm index ff69d62a8ed..2280beca919 100644 --- a/code/modules/admin/verbs/striketeam_syndicate.dm +++ b/code/modules/admin/verbs/striketeam_syndicate.dm @@ -66,7 +66,7 @@ var/global/sent_syndicate_strike_team = 0 var/mob/ghost_mob = pick(commando_ghosts) commando_ghosts -= ghost_mob - if(!ghost_mob.key || !ghost_mob.client) + if(!ghost_mob || !ghost_mob.key || !ghost_mob.client) continue var/mob/living/carbon/human/new_syndicate_commando = create_syndicate_death_commando(L, is_leader)