Antagonist reputation system
This commit is contained in:
committed by
CitadelStationBot
parent
3690cf3309
commit
44dc6ac3a0
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user