Merge pull request #5754 from Citadel-Station-13/upstream-merge-35485

[MIRROR] Antagonist reputation system
This commit is contained in:
LetterJay
2018-03-04 00:31:41 -06:00
committed by GitHub
29 changed files with 246 additions and 20 deletions
+1 -1
View File
@@ -37,7 +37,7 @@
var/datum/team/brother_team/team = new
var/team_size = prob(10) ? min(3, possible_brothers.len) : 2
for(var/k = 1 to team_size)
var/datum/mind/bro = pick(possible_brothers)
var/datum/mind/bro = antag_pick(possible_brothers)
possible_brothers -= bro
antag_candidates -= bro
team.add_member(bro)
+1 -1
View File
@@ -45,7 +45,7 @@ GLOBAL_VAR(changeling_team_objective_type) //If this is not null, we hand our th
for(var/i = 0, i < num_changelings, i++)
if(!antag_candidates.len)
break
var/datum/mind/changeling = pick(antag_candidates)
var/datum/mind/changeling = antag_pick(antag_candidates)
antag_candidates -= changeling
changelings += changeling
changeling.special_role = ROLE_CHANGELING
@@ -46,7 +46,7 @@
for(var/j = 0, j < num_changelings, j++)
if(!possible_changelings.len)
break
var/datum/mind/changeling = pick(possible_changelings)
var/datum/mind/changeling = antag_pick(possible_changelings)
antag_candidates -= changeling
possible_changelings -= changeling
changeling.special_role = ROLE_CHANGELING
+1 -1
View File
@@ -155,7 +155,7 @@ Credit where due:
starter_servants += round(number_players / 10)
starter_servants = min(starter_servants, 8) //max 8 servants (that sould only happen with a ton of players)
while(starter_servants)
var/datum/mind/servant = pick(antag_candidates)
var/datum/mind/servant = antag_pick(antag_candidates)
servants_to_serve += servant
antag_candidates -= servant
servant.assigned_role = ROLE_SERVANT_OF_RATVAR
+1 -1
View File
@@ -74,7 +74,7 @@
for(var/cultists_number = 1 to recommended_enemies)
if(!antag_candidates.len)
break
var/datum/mind/cultist = pick(antag_candidates)
var/datum/mind/cultist = antag_pick(antag_candidates)
antag_candidates -= cultist
cultists_to_cult += cultist
cultist.special_role = ROLE_CULTIST
+1 -1
View File
@@ -36,7 +36,7 @@
for(var/j = 0, j < num_devils, j++)
if (!antag_candidates.len)
break
var/datum/mind/devil = pick(antag_candidates)
var/datum/mind/devil = antag_pick(antag_candidates)
devils += devil
devil.special_role = traitor_name
devil.restricted_roles = restricted_jobs
+72 -7
View File
@@ -283,6 +283,61 @@
set_security_level(SEC_LEVEL_BLUE)
// This is a frequency selection system. You may imagine it like a raffle where each player can have some number of tickets. The more tickets you have the more likely you are to
// "win". The default is 100 tickets. If no players use any extra tickets (earned with the antagonist rep system) calling this function should be equivalent to calling the normal
// pick() function. By default you may use up to 100 extra tickets per roll, meaning at maximum a player may double their chances compared to a player who has no extra tickets.
//
// The odds of being picked are simply (your_tickets / total_tickets). Suppose you have one player using fifty (50) extra tickets, and one who uses no extra:
// Player A: 150 tickets
// Player B: 100 tickets
// Total: 250 tickets
//
// The odds become:
// Player A: 150 / 250 = 0.6 = 60%
// Player B: 100 / 250 = 0.4 = 40%
/datum/game_mode/proc/antag_pick(list/datum/candidates)
if(!CONFIG_GET(flag/use_antag_rep)) // || candidates.len <= 1)
return pick(candidates)
// Tickets start at 100
var/DEFAULT_ANTAG_TICKETS = CONFIG_GET(number/default_antag_tickets)
// You may use up to 100 extra tickets (double your odds)
var/MAX_TICKETS_PER_ROLL = CONFIG_GET(number/max_tickets_per_roll)
var/total_tickets = 0
MAX_TICKETS_PER_ROLL += DEFAULT_ANTAG_TICKETS
var/p_ckey
var/p_rep
for(var/datum/mind/mind in candidates)
p_ckey = ckey(mind.key)
total_tickets += min(SSpersistence.antag_rep[p_ckey] + DEFAULT_ANTAG_TICKETS, MAX_TICKETS_PER_ROLL)
var/antag_select = rand(1,total_tickets)
var/current = 1
for(var/datum/mind/mind in candidates)
p_ckey = ckey(mind.key)
p_rep = SSpersistence.antag_rep[p_ckey]
p_rep = p_rep == null ? 0 : p_rep
if(current <= antag_select)
var/subtract = min(p_rep + DEFAULT_ANTAG_TICKETS, MAX_TICKETS_PER_ROLL) - DEFAULT_ANTAG_TICKETS
SSpersistence.antag_rep_change[p_ckey] = -subtract
// WARNING("AR_DEBUG: Player [mind.key] won spending [subtract] tickets from starting value [SSpersistence.antag_rep[p_ckey]]")
return mind
current += min(p_rep + DEFAULT_ANTAG_TICKETS, MAX_TICKETS_PER_ROLL)
WARNING("Something has gone terribly wrong. /datum/game_mode/proc/antag_pick failed to select a candidate. Falling back to pick()")
return pick(candidates)
/datum/game_mode/proc/get_players_for_role(role)
var/list/players = list()
var/list/candidates = list()
@@ -382,19 +437,29 @@
if(L.ckey && L.client)
var/failed = FALSE
if(L.client.inactivity >= (ROUNDSTART_LOGOUT_REPORT_TIME / 2)) //Connected, but inactive (alt+tabbed or something)
msg += "<b>[L.name]</b> ([L.ckey]), the [L.job] (<font color='#ffcc00'><b>Connected, Inactive</b></font>)\n"
continue //AFK client
if(L.stat)
failed = TRUE //AFK client
if(!failed && L.stat)
if(L.suiciding) //Suicider
msg += "<b>[L.name]</b> ([L.ckey]), the [L.job] (<span class='boldannounce'>Suicide</span>)\n"
continue //Disconnected client
if(L.stat == UNCONSCIOUS)
failed = TRUE //Disconnected client
if(!failed && L.stat == UNCONSCIOUS)
msg += "<b>[L.name]</b> ([L.ckey]), the [L.job] (Dying)\n"
continue //Unconscious
if(L.stat == DEAD)
failed = TRUE //Unconscious
if(!failed && L.stat == DEAD)
msg += "<b>[L.name]</b> ([L.ckey]), the [L.job] (Dead)\n"
continue //Dead
failed = TRUE //Dead
var/p_ckey = L.client.ckey
// WARNING("AR_DEBUG: [p_ckey]: failed - [failed], antag_rep_change: [SSpersistence.antag_rep_change[p_ckey]]")
// people who died or left should not gain any reputation
// people who rolled antagonist still lose it
if(failed && SSpersistence.antag_rep_change[p_ckey] > 0)
// WARNING("AR_DEBUG: Zeroed [p_ckey]'s antag_rep_change")
SSpersistence.antag_rep_change[p_ckey] = 0
continue //Happy connected client
for(var/mob/dead/observer/D in GLOB.mob_list)
+1 -1
View File
@@ -52,7 +52,7 @@
for (var/i=1 to max_headrevs)
if (antag_candidates.len==0)
break
var/datum/mind/lenin = pick(antag_candidates)
var/datum/mind/lenin = antag_pick(antag_candidates)
antag_candidates -= lenin
headrev_candidates += lenin
lenin.restricted_roles = restricted_jobs
+2 -2
View File
@@ -49,7 +49,7 @@
for(var/j = 0, j < num_traitors, j++)
if (!antag_candidates.len)
break
var/datum/mind/traitor = pick(antag_candidates)
var/datum/mind/traitor = antag_pick(antag_candidates)
pre_traitors += traitor
traitor.special_role = traitor_name
traitor.restricted_roles = restricted_jobs
@@ -100,4 +100,4 @@
/datum/game_mode/proc/update_traitor_icons_removed(datum/mind/traitor_mind)
var/datum/atom_hud/antag/traitorhud = GLOB.huds[ANTAG_HUD_TRAITOR]
traitorhud.leave_hud(traitor_mind.current)
set_antag_hud(traitor_mind.current, null)
set_antag_hud(traitor_mind.current, null)
+1 -1
View File
@@ -19,7 +19,7 @@
var/finished = 0
/datum/game_mode/wizard/pre_setup()
var/datum/mind/wizard = pick(antag_candidates)
var/datum/mind/wizard = antag_pick(antag_candidates)
wizards += wizard
wizard.assigned_role = ROLE_WIZARD
wizard.special_role = ROLE_WIZARD