* Fixed antag randomizing

* Reworked job randomizing
* Added some user feedback to recharger
* Added a new preference setting in job preferences. This setting will make you get a random job if your picked occupations were already filled. This defaults to on to make less graypride.
* Updated changelog

I have tested the new job randomizing with friends and it works good, not sure about large scale however. Feel free to revert this change if it fucks up everything. (and notify me of problems)

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3893 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
daniel.cf.hultgren@gmail.com
2012-06-23 13:07:50 +00:00
parent 42733daf99
commit 0b41114584
6 changed files with 116 additions and 9 deletions
+16 -2
View File
@@ -232,6 +232,7 @@ Whitespace:Seperator;
/datum/game_mode/proc/get_players_for_role(var/role, override_jobbans=1)
var/list/players = list()
var/list/candidates = list()
var/list/drafted = list()
var/datum/mind/applicant = null
@@ -246,7 +247,16 @@ Whitespace:Seperator;
if(BE_CULTIST) roletext="cultist"
// Ultimate randomizing code right here
for(var/mob/new_player/player in world)
if(player.client && player.ready)
players += player
// Shuffling, the players list is now ping-independent!!!
// Goodbye antag dante
players = shuffle(players)
for(var/mob/new_player/player in players)
if(player.client && player.ready)
if(player.preferences.be_special & role)
if(!jobban_isbanned(player, "Syndicate") && !jobban_isbanned(player, roletext)) //Nodrak/Carn: Antag Job-bans
@@ -259,7 +269,7 @@ Whitespace:Seperator;
candidates -= player
if(candidates.len < recommended_enemies)
for(var/mob/new_player/player in world)
for(var/mob/new_player/player in players)
if (player.client && player.ready)
if(!(player.preferences.be_special & role)) // We don't have enough people who want to be antagonist, make a seperate list of people who don't want to be one
if(!jobban_isbanned(player, "Syndicate") && !jobban_isbanned(player, roletext)) //Nodrak/Carn: Antag Job-bans
@@ -271,6 +281,8 @@ Whitespace:Seperator;
if(player.assigned_role == job)
drafted -= player
drafted = shuffle(drafted) // Will hopefully increase randomness, Donkie
while(candidates.len < recommended_enemies) // Pick randomlly just the number of people we need and add them to our list of candidates
if(drafted.len > 0)
applicant = pick(drafted)
@@ -282,7 +294,7 @@ Whitespace:Seperator;
break
if(candidates.len < recommended_enemies && override_jobbans) //If we still don't have enough people, we're going to start drafting banned people.
for(var/mob/new_player/player in world)
for(var/mob/new_player/player in players)
if (player.client && player.ready)
if(jobban_isbanned(player, "Syndicate") || jobban_isbanned(player, roletext)) //Nodrak/Carn: Antag Job-bans
drafted += player.mind
@@ -293,6 +305,8 @@ Whitespace:Seperator;
if(player.assigned_role == job)
drafted -= player
drafted = shuffle(drafted) // Will hopefully increase randomness, Donkie
while(candidates.len < recommended_enemies) // Pick randomlly just the number of people we need and add them to our list of candidates
if(drafted.len > 0)
applicant = pick(drafted)
+66 -4
View File
@@ -81,6 +81,24 @@ var/global/datum/controller/occupations/job_master
candidates += player
return candidates
proc/GiveRandomJob(var/mob/new_player/player)
Debug("FOC Giving random job, Player: [player]")
for(var/datum/job/job in shuffle(occupations))
if(!job)
continue
if(istype(job, GetJob("Assistant"))) // We don't want to give him assistant, that's boring!
continue
if(jobban_isbanned(player, job.title))
Debug("FOC isbanned failed, Player: [player], Job: [job.title]")
continue
if((job.current_positions < job.spawn_positions) || job.spawn_positions == -1)
Debug("FOC Random job given, Player: [player], Job: [job]")
AssignRole(player, job.title)
unassigned -= player
break
proc/ResetOccupations()
for(var/mob/new_player/player in world)
@@ -144,8 +162,8 @@ var/global/datum/controller/occupations/job_master
Debug("Running DO")
SetupOccupations()
occupations = shuffle(occupations) //Shuffles job-list at round start so that people don't have their job picks randomized
if(ticker)//Holder for Triumvirate is stored in the ticker, this just processes it
//Holder for Triumvirate is stored in the ticker, this just processes it
if(ticker)
for(var/datum/job/ai/A in occupations)
if(ticker.triai)
A.spawn_positions = 3
@@ -157,12 +175,13 @@ var/global/datum/controller/occupations/job_master
Debug("DO, Len: [unassigned.len]")
if(unassigned.len == 0) return 0
//Shuffle players and jobs
unassigned = shuffle(unassigned)
HandleFeedbackGathering()
//Assistants are checked first
//People who wants to be assistants, sure, go on.
Debug("DO, Running Assistant Check 1")
var/datum/job/assist = new /datum/job/assistant()
var/list/assistant_candidates = FindOccupationCandidates(assist, 3)
@@ -185,6 +204,46 @@ var/global/datum/controller/occupations/job_master
//Other jobs are now checked
Debug("DO, Running Standard Check")
// New job giving system by Donkie
// This will cause lots of more loops, but since it's only done once it shouldn't really matter much at all.
// Hopefully this will add more randomness and fairness to job giving.
// Loop through all levels from high to low
var/list/shuffledoccupations = shuffle(occupations)
for(var/level = 1 to 3)
// Loop through all unassigned players
for(var/mob/new_player/player in unassigned)
// Loop through all jobs
for(var/datum/job/job in shuffledoccupations) // SHUFFLE ME BABY
if(!job)
continue
if(jobban_isbanned(player, job.title))
Debug("FOC isbanned failed, Player: [player], Job:[job.title]")
continue
// If the player wants that job on this level, then try give it to him.
if(player.preferences.GetJobDepartment(job, level) & job.flag)
// If the job isn't filled
if((job.current_positions < job.spawn_positions) || job.spawn_positions == -1)
Debug("FOC pass, Player: [player], Level:[level], Job:[job.title]")
AssignRole(player, job.title)
unassigned -= player
break
// Hand out random jobs to the people who didn't get any in the last check
// Also makes sure that they got their preference correct
for(var/mob/new_player/player in unassigned)
if(player.preferences.userandomjob)
GiveRandomJob(player)
/*
Old job system
for(var/level = 1 to 3)
for(var/datum/job/job in occupations)
Debug("Checking job: [job]")
@@ -199,10 +258,13 @@ var/global/datum/controller/occupations/job_master
var/mob/new_player/candidate = pick(candidates)
Debug("Selcted: [candidate], for: [job.title]")
AssignRole(candidate, job.title)
candidates -= candidate
candidates -= candidate*/
Debug("DO, Standard Check end")
Debug("DO, Running AC2")
// For those who wanted to be assistant if their preferences were filled, here you go.
for(var/mob/new_player/player in unassigned)
Debug("AC2 Assistant located, Player: [player]")
AssignRole(player, "Assistant")
+6 -2
View File
@@ -14,12 +14,16 @@ obj/machinery/recharger/attackby(obj/item/weapon/G as obj, mob/user as mob)
if(istype(G, /obj/item/weapon/gun/energy) || istype(G, /obj/item/weapon/melee/baton))
if(charging)
return
// Checks to make sure he's not in space doing it, and that the area got proper power.
var/area/a = get_area(src)
if(!isarea(a))
return
if(a.power_equip == 0) // There's no APC in this area, don't try to cheat power!
user << "\red The [name] blinks red as you try to insert the item!"
return
if(a.power_equip == 0)
user << "\red The [name] blinks red as you try to insert the item!"
return
if (istype(G, /obj/item/weapon/gun/energy/gun/nuclear) || istype(G, /obj/item/weapon/gun/energy/crossbow))
user << "<span class='notice'>Your gun's recharge port was removed to make room for a miniaturized reactor.</span>"
return
+15 -1
View File
@@ -115,6 +115,9 @@ datum/preferences
var/job_engsec_med = 0
var/job_engsec_low = 0
// Want randomjob if preferences already filled - Donkie
var/userandomjob = 1 // Defaults to 1 for less assistants!
// OOC Metadata:
var/metadata = ""
@@ -297,7 +300,11 @@ datum/preferences
HTML += "</td'><tr></table>"
HTML += "</center></tt>"
HTML += "</center></table>"
HTML += "<center><br><u><a href=\"byond://?src=\ref[user];preferences=1;togglerandjob=1\"><font color=[userandomjob ? "green>Get random job if preferences unavailable" : "red>Be assistant if preference unavailable"]</font></a></u></center>"
HTML += "</tt>"
user << browse(null, "window=preferences")
user << browse(HTML, "window=mob_occupation;size=[width]x[height]")
@@ -415,6 +422,12 @@ datum/preferences
proc/process_link(mob/user, list/link_tags)
if(!usr)
return
if(link_tags["togglerandjob"])
userandomjob = !userandomjob
SetChoices(user)
return 1
if(link_tags["occ"])
if(link_tags["cancel"])
user << browse(null, "window=\ref[user]occupation")
@@ -700,6 +713,7 @@ datum/preferences
UI_style = "Midnight"
midis = 1
ghost_ears = 1
userandomjob = 1
ShowChoices(user)
+4
View File
@@ -33,6 +33,8 @@ datum/preferences/proc/savefile_save(mob/user)
F["job_engsec_med"] << src.job_engsec_med
F["job_engsec_low"] << src.job_engsec_low
F["userandomjob"] << src.userandomjob
//Body data
F["hair_red"] << src.r_hair
F["hair_green"] << src.g_hair
@@ -138,6 +140,8 @@ datum/preferences/proc/savefile_load(mob/user)
F["job_engsec_med"] >> src.job_engsec_med
F["job_engsec_low"] >> src.job_engsec_low
F["userandomjob"] >> src.userandomjob
F["OOC_Notes"] >> src.metadata
F["sound_adminhelp"] >> src.sound_adminhelp