Every time we would have pulled a random ghost into a mob, we will poll the ghosts for volunteers first.

This commit is contained in:
ikarrus
2014-09-03 23:36:23 -06:00
parent e1c2f08ce0
commit dbf7392649
9 changed files with 104 additions and 135 deletions
+30 -13
View File
@@ -295,27 +295,42 @@
return M
return null
// Will return a list of active candidates. It increases the buffer 5 times until it finds a candidate which is active within the buffer.
// Will poll ghosts for volunteers
/proc/get_candidates(be_special_flag=0, rolename=null, wait_time=200)
var/list/mob/dead/observer/volunteers = list()
var/list/client/candidates = list()
var/time_passed = world.time
for(var/mob/dead/observer/G in player_list)
spawn(0)
if(!G.client)
return
if((G.client.prefs.be_special & be_special_flag) && !jobban_isbanned(G, get_roletext(be_special_flag)) || (be_special_flag < 0))
switch(alert(G,"Do you want to be considered to be a [rolename ? rolename : get_roletext(be_special_flag)]?","Please answer in [wait_time/10] seconds!","Yes","No"))
if("Yes")
if((world.time-time_passed)>wait_time)
return
volunteers += G
if("No")
return
else
return
sleep(wait_time)
for(var/mob/dead/observer/G in volunteers)
if(G.client)
candidates += G.client
/proc/get_candidates(be_special_flag=0, afk_bracket=3000)
var/list/candidates = list()
// Keep looping until we find a non-afk candidate within the time bracket (we limit the bracket to 10 minutes (6000))
while(!candidates.len && afk_bracket < 6000)
for(var/mob/dead/observer/G in player_list)
if(G.client != null)
if(!(G.mind && G.mind.current && G.mind.current.stat != DEAD))
if(!G.client.is_afk(afk_bracket) && (G.client.prefs.be_special & be_special_flag) && !jobban_isbanned(G, get_roletext(be_special_flag)))
candidates += G.client
afk_bracket += 600 // Add a minute to the bracket, for every attempt
return candidates
/proc/pick_from_candidates(be_special_flag=0)
var/list/candidates = get_candidates(be_special_flag)
/proc/pick_from_candidates(be_special_flag=0, rolename=null, wait_time=200)
var/list/candidates = get_candidates(be_special_flag, rolename, wait_time)
if(candidates.len)
var/client/C = pick(candidates)
return C
return 0 //Unable to find a valid candidate
/proc/get_roletext(role) //Translates role flag to role text
var/roletext
switch(role)
@@ -326,6 +341,8 @@
if(BE_REV) roletext="revolutionary"
if(BE_CULTIST) roletext="cultist"
if(BE_MONKEY) roletext="monkey"
if(BE_NINJA) roletext="ninja"
if(BE_ALIEN) roletext="alien"
return roletext
/proc/ScreenText(obj/O, maptext="", screen_loc="CENTER-7,CENTER-7", maptext_height=480, maptext_width=480)
+12 -3
View File
@@ -3,6 +3,7 @@
throw_range = 5
w_class = 1.0
var/used = 0
var/polling_ghosts = 0
/obj/item/weapon/antag_spawner/proc/spawn_antag(var/client/C, var/turf/T, var/type = "")
return
@@ -42,7 +43,7 @@
..()
var/mob/living/carbon/human/H = usr
if(H.stat || H.restrained())
if(H.stat || H.restrained() || polling_ghosts)
return
if(!istype(H, /mob/living/carbon/human))
return 1
@@ -53,7 +54,10 @@
if (used)
H << "You already used this contract!"
return
var/client/C = pick_from_candidates(BE_WIZARD)
H << "You send out a call for aid into the realms! It will be about 20 seconds before you get a response."
polling_ghosts = 1
var/client/C = pick_from_candidates(BE_WIZARD, "wizard's apprentice")
polling_ghosts = 0
if(C)
src.used = 1
spawn_antag(C, get_turf(H.loc), href_list["school"])
@@ -122,10 +126,15 @@
var/TC_cost = 0
/obj/item/weapon/antag_spawner/borg_tele/attack_self(mob/user as mob)
if(polling_ghosts)
return
if(used)
user << "The teleporter is out of power."
return
var/client/C = pick_from_candidates(BE_OPERATIVE)
user << "<span class='notice'>Standby for reinforcements... ETA 20 seconds.</span>"
polling_ghosts = 1
var/client/C = pick_from_candidates(BE_OPERATIVE, "Syndicate cyborg")
polling_ghosts = 0
if(C)
used = 1
spawn_antag(C, get_turf(src.loc), "syndieborg")
+12 -11
View File
@@ -73,16 +73,17 @@
var/client/C = null
if(!new_overmind)
C = pick_from_candidates(BE_BLOB)
else
C = new_overmind
spawn(0)
if(!new_overmind)
C = pick_from_candidates(BE_BLOB)
else
C = new_overmind
if(C)
var/mob/camera/blob/B = new(src.loc)
B.key = C.key
B.blob_core = src
src.overmind = B
return 1
return 0
if(C)
var/mob/camera/blob/B = new(src.loc)
B.key = C.key
B.blob_core = src
src.overmind = B
return 1
return 0
+6 -1
View File
@@ -103,7 +103,7 @@
// grant_runeword(cult_mind.current)
// grant_secondword(cult_mind.current)
update_cult_icons_added(cult_mind)
cult_mind.current << "<span class='notice'>You are a member of the cult!</span>"
cult_mind.current << "<span class='userdanger'>You are a member of the cult!</span>"
memorize_cult_objectives(cult_mind)
cult_mind.special_role = "Cultist"
..()
@@ -131,6 +131,11 @@
// grant_runeword(cult_mind.current,"blood")
// grant_runeword(cult_mind.current,"hell")
/datum/game_mode/proc/greet_cultist(mob/M)
M << "<font color=\"purple\"><b><i>Your blood pulses. Your head throbs. The world goes red. All at once you are aware of a horrible, horrible truth. The veil of reality has been ripped away and in the festering wound left behind something sinister takes root.</b></i></font>"
M << "<font color=\"purple\"><b><i>Assist your new compatriots in their dark dealings. Their goal is yours, and yours is theirs. You serve the Dark One above all else. Bring It back.</b></i></font>"
/datum/game_mode/proc/equip_cultist(mob/living/carbon/human/mob)
if(!istype(mob))
return
+14 -14
View File
@@ -117,17 +117,19 @@ var/list/sacrificed = list()
M.visible_message("<span class='warning'>[M] screams horrifically before falling limp, his mind clearly broken by something he saw.", \
"<span class='userdanger'>You are currently jobbanned from Cultist.</span>")
M.ghostize(0) //Jobbanned players are force ghosted
var/client/C = pick_from_candidates(BE_CULTIST) //Try to find a suitable observer to replace the jobbanned player
if(C)
M.key = C.key
M << "<span class='warning'>Who are you? How did you get here? You can't seem to remember anything but...</span>"
else
M.resting = 0
if(M.key)
M.resting = 1
spawn(0)
var/client/C = pick_from_candidates(BE_CULTIST) //Try to find a suitable observer to replace the jobbanned player
if(C)
M.key = C.key
M << "<span class='warning'>Who are you? How did you get here? You can't seem to remember anything but...</span>"
ticker.mode.add_cultist(M.mind)
M.mind.special_role = "Cultist"
ticker.mode.greet_cultist(M)
else
ticker.mode.add_cultist(M.mind)
M.mind.special_role = "Cultist"
M << "<font color=\"purple\"><b><i>Your blood pulses. Your head throbs. The world goes red. All at once you are aware of a horrible, horrible truth. The veil of reality has been ripped away and in the festering wound left behind something sinister takes root.</b></i></font>"
M << "<font color=\"purple\"><b><i>Assist your new compatriots in their dark dealings. Their goal is yours, and yours is theirs. You serve the Dark One above all else. Bring It back.</b></i></font>"
ticker.mode.greet_cultist(M)
else
M << "<font color=\"purple\"><b><i>Your blood pulses. Your head throbs. The world goes red. All at once you are aware of a horrible, horrible truth. The veil of reality has been ripped away and in the festering wound left behind something sinister takes root.</b></i></font>"
@@ -339,12 +341,11 @@ var/list/sacrificed = list()
body_to_sacrifice.gib()
// if(ticker.mode.name == "cult")
// ticker.mode:add_cultist(corpse_to_raise.mind)
// ticker.mode: corpse_to_raise.mind)
// else
// ticker.mode.cult |= corpse_to_raise.mind
corpse_to_raise << "<font color=\"purple\"><b><i>Your blood pulses. Your head throbs. The world goes red. All at once you are aware of a horrible, horrible truth. The veil of reality has been ripped away and in the festering wound left behind something sinister takes root.</b></i></font>"
corpse_to_raise << "<font color=\"purple\"><b><i>Assist your new compatriots in their dark dealings. Their goal is yours, and yours is theirs. You serve the Dark One above all else. Bring It back.</b></i></font>"
ticker.mode.greet_cultist(corpse_to_raise)
return
@@ -435,8 +436,7 @@ var/list/sacrificed = list()
ticker.mode.cult+=D.mind
D.mind.special_role = "Cultist"
D << "<font color=\"purple\"><b><i>Your blood pulses. Your head throbs. The world goes red. All at once you are aware of a horrible, horrible truth. The veil of reality has been ripped away and in the festering wound left behind something sinister takes root.</b></i></font>"
D << "<font color=\"purple\"><b><i>Assist your new compatriots in their dark dealings. Their goal is yours, and yours is theirs. You serve the Dark One above all else. Bring It back.</b></i></font>"
ticker.mode.greet_cultist(D)
var/mob/living/user = usr
while(this_rune && user && user.stat==CONSCIOUS && user.client && user.loc==this_rune.loc)
+9 -7
View File
@@ -88,13 +88,15 @@
M << "<span class='userdanger'>You are currently jobbanned from Revolutionary.</span>"
user << "<span class='warning'>This mind was unable to survive the rigors of conversion and has been wiped clean!</span>"
M.ghostize(0) //Jobbanned players are force ghosted
var/client/C = pick_from_candidates(BE_REV) //Try to find a suitable observer to replace the jobbanned player
if(C)
M.key = C.key
M << "<span class='warning'>Who are you? How did you get here? You can't seem to remember anything but...</span>"
else
M.resting = 0
if(M.key)
M.resting = 1
spawn(0)
var/client/C = pick_from_candidates(BE_REV) //Try to find a suitable observer to replace the jobbanned player
if(C)
M.key = C.key
M << "<span class='warning'>Who are you? How did you get here? You can't seem to remember anything but...</span>"
M.mind.has_been_rev = 1
ticker.mode.add_revolutionary(M.mind)
else
M.mind.has_been_rev = 1
ticker.mode.add_revolutionary(M.mind)
else if(revsafe == 1)
+14 -77
View File
@@ -146,35 +146,10 @@ client/proc/one_click_antag()
return 0
/datum/admins/proc/makeWizard()
var/list/mob/dead/observer/candidates = list()
var/mob/dead/observer/theghost = null
var/time_passed = world.time
var/client/C = pick_from_candidates(BE_WIZARD)
for(var/mob/dead/observer/G in player_list)
if(!jobban_isbanned(G, "wizard") && !jobban_isbanned(G, "Syndicate"))
spawn(0)
switch(alert(G, "Do you wish to be considered for the position of Space Wizard Foundation 'diplomat'?","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
else
return
sleep(300)
if(candidates.len)
shuffle(candidates)
for(var/mob/i in candidates)
if(!i || !i.client) continue //Dont bother removing them from the list since we only grab one wizard
theghost = i
break
if(theghost)
var/mob/living/carbon/human/new_character=makeBody(theghost)
if(C)
var/mob/living/carbon/human/new_character=makeBody(C.mob)
new_character.mind.make_Wizard()
return 1
@@ -216,42 +191,22 @@ client/proc/one_click_antag()
/datum/admins/proc/makeNukeTeam()
var/list/mob/dead/observer/candidates = list()
var/list/candidates = get_candidates(BE_OPERATIVE)
var/list/mob/dead/observer/chosen = list()
var/mob/dead/observer/theghost = null
var/time_passed = world.time
for(var/mob/dead/observer/G in player_list)
if(!jobban_isbanned(G, "operative") && !jobban_isbanned(G, "Syndicate"))
spawn(0)
switch(alert(G,"Do you wish to be considered for a nuke 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
else
return
sleep(300)
var/client/C = null
if(candidates.len)
var/numagents = 5
var/agentcount = 0
for(var/i = 0, i<numagents,i++)
shuffle(candidates) //More shuffles means more randoms
for(var/mob/j in candidates)
if(!j || !j.client)
candidates.Remove(j)
continue
theghost = j
candidates.Remove(theghost)
chosen += theghost
agentcount++
break
C = pick(candidates)
candidates.Remove(C)
chosen += C.mob
agentcount++
break
//Making sure we have atleast 3 Nuke agents, because less than that is kinda bad
if(agentcount < 3)
return 0
@@ -319,34 +274,16 @@ client/proc/one_click_antag()
// DEATH SQUADS
/datum/admins/proc/makeDeathsquad()
var/list/mob/dead/observer/candidates = list()
var/time_passed = world.time
var/mission = input("Assign a mission to the deathsquad", "Assign Mission", "Leave no witnesses.")
//Generates a list of commandos from active ghosts. Then the user picks which characters to respawn as the commandos.
for(var/mob/dead/observer/G in player_list)
spawn(0)
switch(alert(G,"Do you wish to be considered for an elite Nanotrasen 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
else
return
sleep(300)
for(var/mob/dead/observer/G in candidates)
if(!G.key)
candidates.Remove(G)
var/list/candidates = get_candidates(-1, "member of a Nanotrasen strike team")
if(candidates.len >= 3) //Minimum 3 to be considered a squad
//Pick the lucky players
var/numagents = min(5,candidates.len) //How many commandos to spawn
while(numagents && deathsquadspawn.len && candidates.len)
var/spawnloc = deathsquadspawn[1]
var/mob/dead/observer/chosen_candidate = pick(candidates)
var/client/C = pick(candidates)
var/mob/dead/observer/chosen_candidate = C.mob
candidates -= chosen_candidate
if(!chosen_candidate.key)
continue
+1 -1
View File
@@ -32,7 +32,7 @@
if(temp_vent.network.normal_members.len > 20) //Stops Aliens getting stuck in small networks. See: Security, Virology
vents += temp_vent
var/list/candidates = get_candidates(BE_ALIEN, ALIEN_AFK_BRACKET)
var/list/candidates = get_candidates(BE_ALIEN)
while(spawncount > 0 && vents.len && candidates.len)
var/obj/vent = pick_n_take(vents)
@@ -9,6 +9,7 @@ var/const/ALIEN_AFK_BRACKET = 450 // 45 seconds
icon_state = "larva0_dead"
var/mob/living/affected_mob
var/stage = 0
var/polling_ghosts = 0
/obj/item/alien_embryo/New()
if(istype(loc, /mob/living))
@@ -70,23 +71,20 @@ var/const/ALIEN_AFK_BRACKET = 450 // 45 seconds
affected_mob << "<span class='danger'>You feel something tearing its way out of your stomach...</span>"
affected_mob.adjustToxLoss(10)
affected_mob.updatehealth()
if(prob(50))
if(prob(50) && !polling_ghosts)
AttemptGrow()
/obj/item/alien_embryo/proc/AttemptGrow(var/gib_on_success = 1)
var/list/candidates = get_candidates(BE_ALIEN, ALIEN_AFK_BRACKET)
var/client/C = null
polling_ghosts = 1
var/client/C = pick_from_candidates(BE_ALIEN)
polling_ghosts = 0
// To stop clientless larva, we will check that our host has a client
// if we find no ghosts to become the alien. If the host has a client
// he will become the alien but if he doesn't then we will set the stage
// to 2, so we don't do a process heavy check everytime.
if(candidates.len)
C = pick(candidates)
else if(affected_mob.client)
C = affected_mob.client
else
if(!C)
stage = 4 // Let's try again later.
return