Merge pull request #9064 from Anasari/MoreClickAntag

One-click antag improvement. Antag-related refactor, memory confirmation & typo fixing
This commit is contained in:
tigercat2000
2018-06-13 18:43:18 -07:00
committed by GitHub
5 changed files with 155 additions and 185 deletions
+8 -8
View File
@@ -39,35 +39,35 @@
switch(href_list["makeAntag"])
if("1")
log_admin("[key_name(usr)] has spawned a traitor.")
if(!src.makeTraitors())
if(!makeTraitors())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("2")
log_admin("[key_name(usr)] has spawned a changeling.")
if(!src.makeChanglings())
if(!makeChangelings())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("3")
log_admin("[key_name(usr)] has spawned revolutionaries.")
if(!src.makeRevs())
if(!makeRevs())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("4")
log_admin("[key_name(usr)] has spawned a cultists.")
if(!src.makeCult())
if(!makeCult())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("5")
log_admin("[key_name(usr)] has spawned a wizard.")
if(!src.makeWizard())
if(!makeWizard())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("6")
log_admin("[key_name(usr)] has spawned vampires.")
if(!src.makeVampires())
if(!makeVampires())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("7")
log_admin("[key_name(usr)] has spawned vox raiders.")
if(!src.makeVoxRaiders())
if(!makeVoxRaiders())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("8")
log_admin("[key_name(usr)] has spawned an abductor team.")
if(!src.makeAbductorTeam())
if(!makeAbductorTeam())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
else if(href_list["dbsearchckey"] || href_list["dbsearchadmin"] || href_list["dbsearchip"] || href_list["dbsearchcid"] || href_list["dbsearchbantype"])
+129 -134
View File
@@ -25,6 +25,22 @@ client/proc/one_click_antag()
usr << browse(dat, "window=oneclickantag;size=400x400")
return
/datum/admins/proc/CandCheck(var/role = null, var/mob/living/carbon/human/M, var/datum/game_mode/temp = null)
// You pass in ROLE define (optional), the applicant, and the gamemode, and it will return true / false depending on whether the applicant qualify for the candidacy in question
if(jobban_isbanned(M, "Syndicate"))
return FALSE
if(M.stat || !M.mind || M.mind.special_role)
return FALSE
if(temp)
if(M.mind.assigned_role in temp.restricted_jobs || M.client.prefs.species in temp.protected_species)
return FALSE
if(role) // Don't even bother evaluating if there's no role
if(player_old_enough_antag(M.client,role) && (role in M.client.prefs.be_special) && (!jobban_isbanned(M, role)))
return TRUE
else
return FALSE
else
return TRUE
/datum/admins/proc/makeTraitors()
var/datum/game_mode/traitor/temp = new
@@ -35,35 +51,29 @@ client/proc/one_click_antag()
var/list/mob/living/carbon/human/candidates = list()
var/mob/living/carbon/human/H = null
log_admin("[key_name(owner)] tried making Traitors with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making Traitors with One-Click-Antag")
var/antnum = input(owner, "How many traitors you want to create? Enter 0 to cancel","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making [antnum] traitors with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making [antnum] traitors with One-Click-Antag")
for(var/mob/living/carbon/human/applicant in player_list)
if(ROLE_TRAITOR in applicant.client.prefs.be_special)
if(player_old_enough_antag(applicant.client,ROLE_TRAITOR))
if(!applicant.stat)
if(applicant.mind)
if(!applicant.mind.special_role)
if(!jobban_isbanned(applicant, "traitor") && !jobban_isbanned(applicant, "Syndicate"))
if(!(applicant.mind.assigned_role in temp.restricted_jobs))
if(!(applicant.client.prefs.species in temp.protected_species))
candidates += applicant
if(CandCheck(ROLE_TRAITOR, applicant, temp))
candidates += applicant
if(candidates.len)
var/numTratiors = min(candidates.len, 3)
var/numTraitors = min(candidates.len, antnum)
for(var/i = 0, i<numTratiors, i++)
for(var/i = 0, i<numTraitors, i++)
H = pick(candidates)
H.mind.make_Tratior()
H.mind.make_Traitor()
candidates.Remove(H)
return 1
return 0
/datum/admins/proc/makeChanglings()
/datum/admins/proc/makeChangelings()
var/datum/game_mode/changeling/temp = new
if(config.protect_roles_from_antagonist)
@@ -72,30 +82,25 @@ client/proc/one_click_antag()
var/list/mob/living/carbon/human/candidates = list()
var/mob/living/carbon/human/H = null
log_admin("[key_name(owner)] tried making Changelings with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making Changelings with One-Click-Antag")
var/antnum = input(owner, "How many changelings you want to create? Enter 0 to cancel.","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making [antnum] changelings with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making [antnum] changelings with One-Click-Antag")
for(var/mob/living/carbon/human/applicant in player_list)
if(ROLE_CHANGELING in applicant.client.prefs.be_special)
if(player_old_enough_antag(applicant.client,ROLE_CHANGELING))
if(!applicant.stat)
if(applicant.mind)
if(!applicant.mind.special_role)
if(!jobban_isbanned(applicant, "changeling") && !jobban_isbanned(applicant, "Syndicate"))
if(!(applicant.mind.assigned_role in temp.restricted_jobs))
if(!(applicant.client.prefs.species in temp.protected_species))
candidates += applicant
if(CandCheck(ROLE_CHANGELING, applicant, temp))
candidates += applicant
if(candidates.len)
var/numChanglings = min(candidates.len, 3)
var/numChangelings = min(candidates.len, antnum)
for(var/i = 0, i<numChanglings, i++)
for(var/i = 0, i<numChangelings, i++)
H = pick(candidates)
H.mind.make_Changling()
H.mind.make_Changeling()
candidates.Remove(H)
return 1
return 0
/datum/admins/proc/makeRevs()
@@ -107,33 +112,31 @@ client/proc/one_click_antag()
var/list/mob/living/carbon/human/candidates = list()
var/mob/living/carbon/human/H = null
log_admin("[key_name(owner)] tried making Revolutionaries with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making Revolutionaries with One-Click-Antag")
var/antnum = input(owner, "How many revolutionaries you want to create? Enter 0 to cancel","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making [antnum] revolutionaries with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making [antnum] revolutionaries with One-Click-Antag")
for(var/mob/living/carbon/human/applicant in player_list)
if(ROLE_REV in applicant.client.prefs.be_special)
if(player_old_enough_antag(applicant.client,ROLE_REV))
if(applicant.stat == CONSCIOUS)
if(applicant.mind)
if(!applicant.mind.special_role)
if(!jobban_isbanned(applicant, "revolutionary") && !jobban_isbanned(applicant, "Syndicate"))
if(!(applicant.mind.assigned_role in temp.restricted_jobs))
if(!(applicant.client.prefs.species in temp.protected_species))
candidates += applicant
if(CandCheck(ROLE_REV, applicant, temp))
candidates += applicant
if(candidates.len)
var/numRevs = min(candidates.len, 3)
var/numRevs = min(candidates.len, antnum)
for(var/i = 0, i<numRevs, i++)
H = pick(candidates)
H.mind.make_Rev()
candidates.Remove(H)
return 1
return 0
/datum/admins/proc/makeWizard()
var/confirm = alert("Are you sure?", "Confirm creation", "Yes", "No")
if(confirm != "Yes")
return 0
var/list/candidates = pollCandidates("Do you wish to be considered for the position of a Wizard Foundation 'diplomat'?", "wizard")
log_admin("[key_name(owner)] tried making a Wizard with One-Click-Antag")
@@ -157,31 +160,25 @@ client/proc/one_click_antag()
var/list/mob/living/carbon/human/candidates = list()
var/mob/living/carbon/human/H = null
var/antnum = input(owner, "How many cultists you want to create? Enter 0 to cancel.","Amount:", 0) as num
if(!antnum || antnum <= 0) // 5 because cultist can really screw balance over if spawned in high amount.
return
log_admin("[key_name(owner)] tried making a Cult with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making a Cult with One-Click-Antag")
for(var/mob/living/carbon/human/applicant in player_list)
if(ROLE_CULTIST in applicant.client.prefs.be_special)
if(player_old_enough_antag(applicant.client,ROLE_CULTIST))
if(applicant.stat == CONSCIOUS)
if(applicant.mind)
if(!applicant.mind.special_role)
if(!jobban_isbanned(applicant, "cultist") && !jobban_isbanned(applicant, "Syndicate"))
if(!(applicant.mind.assigned_role in temp.restricted_jobs))
if(!(applicant.client.prefs.species in temp.protected_species))
candidates += applicant
if(CandCheck(ROLE_CULTIST, applicant, temp))
candidates += applicant
if(candidates.len)
var/numCultists = min(candidates.len, 4)
var/numCultists = min(candidates.len, antnum)
for(var/i = 0, i<numCultists, i++)
H = pick(candidates)
H.mind.make_Cultist()
ticker.mode.add_cultist(H.mind)
candidates.Remove(H)
return 1
return 0
@@ -192,8 +189,11 @@ client/proc/one_click_antag()
var/mob/theghost = null
var/time_passed = world.time
log_admin("[key_name(owner)] tried making a Nuke Op Team with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making a Nuke Op Team with One-Click-Antag")
var/antnum = input(owner, "How many nuclear operative you want to create? Enter 0 to cancel.","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making a [antnum] person Nuke Op Team with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making a [antnum] person Nuke Op Team with One-Click-Antag")
for(var/mob/G in respawnable_list)
if(istype(G) && G.client && (ROLE_OPERATIVE in G.client.prefs.be_special))
@@ -213,10 +213,9 @@ client/proc/one_click_antag()
sleep(300)
if(candidates.len)
var/numagents = 5
var/agentcount = 0
for(var/i = 0, i<numagents,i++)
for(var/i = 0, i<antnum,i++)
shuffle(candidates) //More shuffles means more randoms
for(var/mob/j in candidates)
if(!j || !j.client)
@@ -276,12 +275,14 @@ client/proc/one_click_antag()
for(var/obj/machinery/nuclearbomb/bomb in world)
bomb.r_code = nuke_code // All the nukes are set to this code.
return 1
//Abductors
/datum/admins/proc/makeAbductorTeam()
var/confirm = alert("Are you sure?", "Confirm creation", "Yes", "No")
if(confirm != "Yes")
return 0
new /datum/event/abductor
log_admin("[key_name(owner)] tried making Abductors with One-Click-Antag")
@@ -292,10 +293,13 @@ client/proc/one_click_antag()
/datum/admins/proc/makeAliens()
var/datum/event/alien_infestation/E = new /datum/event/alien_infestation
var/antnum = input(owner, "How many aliens you want to create? Enter 0 to cancel.","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making Aliens with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making Aliens with One-Click-Antag")
E.spawncount = 3
E.spawncount = antnum
// TODO The fact we have to do this rather than just have events start
// when we ask them to, is bad.
E.processing = TRUE
@@ -315,67 +319,65 @@ client/proc/one_click_antag()
if(prob(10))
input = "Save Runtime and any other cute things on the station."
log_admin("[key_name(owner)] tried making a Death Squad with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making a Death Squad with One-Click-Antag")
var/antnum = input(owner, "How many deathsquad members you want to create? Enter 0 to cancel.","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making a [antnum] person Death Squad with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making a [antnum] person Death Squad with One-Click-Antag")
var/syndicate_leader_selected = 0 //when the leader is chosen. The last person spawned.
var/syndicate_leader_selected = 0 //when the leader is chosen. The last person spawned.
//Generates a list of commandos from active ghosts. Then the user picks which characters to respawn as the commandos.
for(var/mob/G in respawnable_list)
if(!jobban_isbanned(G, "Syndicate"))
spawn(0)
switch(alert(G,"Do you wish to be considered for an elite syndicate strike team being sent in?","Please answer in 30 seconds!","Yes","No"))
if("Yes")
if((world.time-time_passed)>300)//If more than 30 game seconds passed.
//Generates a list of commandos from active ghosts. Then the user picks which characters to respawn as the commandos.
for(var/mob/G in respawnable_list)
if(!jobban_isbanned(G, "Syndicate"))
spawn(0)
switch(alert(G,"Do you wish to be considered for an elite syndicate strike team being sent in?","Please answer in 30 seconds!","Yes","No"))
if("Yes")
if((world.time-time_passed)>300)//If more than 30 game seconds passed.
return
candidates += G
if("No")
return
candidates += G
if("No")
return
else
return
sleep(300)
else
return
sleep(300)
for(var/mob/dead/observer/G in candidates)
if(!G.key)
candidates.Remove(G)
for(var/mob/dead/observer/G in candidates)
if(!G.key)
candidates.Remove(G)
if(candidates.len)
var/numagents = 6
//Spawns commandos and equips them.
for(var/obj/effect/landmark/L in /area/syndicate_mothership/elite_squad)
if(numagents<=0)
break
if(L.name == "Syndicate-Commando")
syndicate_leader_selected = numagents == 1?1:0
var/mob/living/carbon/human/new_syndicate_commando = create_syndicate_death_commando(L, syndicate_leader_selected)
while((!theghost || !theghost.client) && candidates.len)
theghost = pick(candidates)
candidates.Remove(theghost)
if(!theghost)
qdel(new_syndicate_commando)
if(candidates.len)
//Spawns commandos and equips them.
for(var/obj/effect/landmark/L in /area/syndicate_mothership/elite_squad)
if(antnum <= 0)
break
if(L.name == "Syndicate-Commando")
syndicate_leader_selected = antnum == 1?1:0
new_syndicate_commando.key = theghost.key
new_syndicate_commando.internal = new_syndicate_commando.s_store
new_syndicate_commando.update_action_buttons_icon()
var/mob/living/carbon/human/new_syndicate_commando = create_syndicate_death_commando(L, syndicate_leader_selected)
//So they don't forget their code or mission.
while((!theghost || !theghost.client) && candidates.len)
theghost = pick(candidates)
candidates.Remove(theghost)
if(!theghost)
qdel(new_syndicate_commando)
break
new_syndicate_commando.key = theghost.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.
to_chat(new_syndicate_commando, "<span class='notice'>You are an Elite Syndicate. [!syndicate_leader_selected ? "commando" : "<B>LEADER</B>"] in the service of the Syndicate. \nYour current mission is: <span class='danger'>[input]</span></span>")
to_chat(new_syndicate_commando, "<span class='notice'>You are an Elite Syndicate. [!syndicate_leader_selected ? "commando" : "<B>LEADER</B>"] in the service of the Syndicate. \nYour current mission is: <span class='danger'>[input]</span></span>")
numagents--
if(numagents >= 6)
return 0
for(var/obj/effect/landmark/L in /area/shuttle/syndicate_elite)
if(L.name == "Syndicate-Commando-Bomb")
new /obj/effect/spawner/newbomb/timer/syndicate(L.loc)
antnum--
for(var/obj/effect/landmark/L in /area/shuttle/syndicate_elite)
if(L.name == "Syndicate-Commando-Bomb")
new /obj/effect/spawner/newbomb/timer/syndicate(L.loc)
return 1
@@ -429,10 +431,12 @@ client/proc/one_click_antag()
var/leader_chosen = 0 //when the leader is chosen. The last person spawned.
var/antnum = input(owner, "How many raiders you want to create? Enter 0 to cancel.","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making Vox Raiders with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making Vox Raiders with One-Click-Antag")
//Generates a list of candidates from active ghosts.
//Generates a list of candidates from active ghosts.
for(var/mob/G in respawnable_list)
if(istype(G) && G.client && (ROLE_RAIDER in G.client.prefs.be_special))
if(player_old_enough_antag(G.client,ROLE_RAIDER))
@@ -455,8 +459,7 @@ client/proc/one_click_antag()
candidates.Remove(G)
if(candidates.len)
var/max_raiders = 1
var/raiders = max_raiders
var/raiders = min(antnum, candidates.len)
//Spawns vox raiders and equips them.
for(var/obj/effect/landmark/L in world)
if(L.name == "voxstart")
@@ -480,8 +483,6 @@ client/proc/one_click_antag()
to_chat(new_vox, "<span class='warning'>Don't forget to turn on your nitrogen internals!</span>")
raiders--
if(raiders > max_raiders)
return 0
else
return 0
return 1
@@ -534,32 +535,26 @@ client/proc/one_click_antag()
var/list/mob/living/carbon/human/candidates = list()
var/mob/living/carbon/human/H = null
var/antnum = input(owner, "How many vampires you want to create? Enter 0 to cancel","Amount:", 0) as num
if(!antnum || antnum <= 0)
return
log_admin("[key_name(owner)] tried making Vampires with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making Vampires with One-Click-Antag")
for(var/mob/living/carbon/human/applicant in player_list)
if(ROLE_VAMPIRE in applicant.client.prefs.be_special)
if(player_old_enough_antag(applicant.client,ROLE_VAMPIRE))
if(!applicant.stat)
if(applicant.mind)
if(!applicant.mind.special_role)
if(!jobban_isbanned(applicant, "vampire") && !jobban_isbanned(applicant, "Syndicate"))
if(!(applicant.job in temp.restricted_jobs))
if(!(applicant.client.prefs.species in temp.protected_species))
candidates += applicant
if(CandCheck(ROLE_VAMPIRE, applicant, temp))
candidates += applicant
if(candidates.len)
var/numVampires = min(candidates.len, 3)
var/numVampires = min(candidates.len, antnum)
for(var/i = 0, i<numVampires, i++)
H = pick(candidates)
ticker.mode.vampires += H.mind
ticker.mode.grant_vampire_powers(H)
ticker.mode.update_vampire_icons_added(H.mind)
H.mind.make_Vampire()
candidates.Remove(H)
return 1
return 0
/datum/admins/proc/makeThunderdomeTeams() // Not strictly an antag, but this seemed to be the best place to put it.