Allows roundstart observers to freely use antag HUD without losing respawnability (#23009)

* First pass

* do away with old antag hud variable

* rework cannotPossess

* some verification + cleanups

* Update code/modules/mob/dead/observer/observer_base.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* splits up log call

* Slightly refactor proc calls, continuing contra's review

* Log admin

---------

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
This commit is contained in:
Luc
2023-11-21 08:00:13 -05:00
committed by GitHub
parent f70b534aee
commit 9384c2a074
19 changed files with 74 additions and 34 deletions
+2 -3
View File
@@ -26,10 +26,9 @@ GLOBAL_LIST_EMPTY(dead_mob_list) //List of all dead mobs, including clientles
GLOBAL_LIST_EMPTY(non_respawnable_keys) //List of ckeys that are excluded from respawning for remainder of round.
GLOBAL_LIST_INIT(simple_animals, list(list(), list(), list(), list())) //One for each AI_* status define, List of all simple animals, including clientless
GLOBAL_LIST_EMPTY(bots_list) //List of all bots(beepsky, medibots,etc)
GLOBAL_LIST_EMPTY(roundstart_observer_keys) //List of ckeys who ghosted before the game began.
GLOBAL_LIST_EMPTY(antag_hud_users) // ckeys of (non-admin) users who have enabled ahud at some point during the game
GLOBAL_LIST_EMPTY(med_hud_users)
GLOBAL_LIST_EMPTY(sec_hud_users)
GLOBAL_LIST_EMPTY(antag_hud_users)
GLOBAL_LIST_EMPTY(surgeries_list)
GLOBAL_LIST_EMPTY(hear_radio_list) //Mobs that hear the radio even if there's no client
+4 -2
View File
@@ -178,8 +178,10 @@ SUBSYSTEM_DEF(ghost_spawns)
if(GLOB.configuration.jobs.enable_exp_restrictions && min_hours)
if(M.client.get_exp_type_num(EXP_TYPE_LIVING) < min_hours * 60)
return
if(check_antaghud && cannotPossess(M))
return
if(check_antaghud && isobserver(M))
var/mob/dead/observer/O = M
if(!O.check_ahud_rejoin_eligibility())
return
return TRUE
+1 -1
View File
@@ -947,7 +947,7 @@ structure_check() searches for nearby cultist structures required for the invoca
continue
if(iscultist(O) || jobban_isbanned(O, ROLE_CULTIST))
continue
if(O.has_enabled_antagHUD || QDELETED(src) || QDELETED(O))
if(!HAS_TRAIT(ghost, TRAIT_RESPAWNABLE) || QDELETED(src) || QDELETED(O))
continue
if(O.mind.current && HAS_TRAIT(O.mind.current, SCRYING))
continue
+2
View File
@@ -118,6 +118,8 @@ GLOBAL_VAR_INIT(nologevent, 0)
body += "<b>Related accounts by IP:</b> [jointext(M.client.related_accounts_ip, " - ")]<br><br>"
if(M.ckey)
body += "<b>Enabled AntagHUD</b>: [M.has_ahudded() ? "<b><font color='red'>TRUE</font>" : "false"]<br>"
body += "<b>Roundstart observer</b>: [M.is_roundstart_observer() ? "<b>true</b>" : "false"]<br>"
body += "<A href='?_src_=holder;boot2=[M.UID()]'>Kick</A> | "
body += "<A href='?_src_=holder;newban=[M.UID()];dbbanaddckey=[M.ckey]'>Ban</A> | "
body += "<A href='?_src_=holder;jobban2=[M.UID()];dbbanaddckey=[M.ckey]'>Jobban</A> | "
+2 -2
View File
@@ -291,10 +291,10 @@
var/action=""
if(GLOB.configuration.general.allow_antag_hud)
GLOB.antag_hud_users.Cut()
for(var/mob/dead/observer/g in get_ghosts())
if(g.antagHUD)
g.antagHUD = FALSE // Disable it on those that have it enabled
g.has_enabled_antagHUD = FALSE // We'll allow them to respawn
to_chat(g, "<span class='danger'>The Administrators have disabled AntagHUD </span>")
GLOB.configuration.general.allow_antag_hud = FALSE
to_chat(src, "<span class='danger'>AntagHUD usage has been disabled</span>")
@@ -332,7 +332,7 @@
to_chat(g, "<span class='danger'>The administrator has placed restrictions on joining the round if you use AntagHUD</span>")
to_chat(g, "<span class='danger'>Your AntagHUD has been disabled, you may choose to re-enabled it but will be under restrictions </span>")
g.antagHUD = FALSE
g.has_enabled_antagHUD = FALSE
GLOB.antag_hud_users -= g.ckey
action = "placed restrictions"
GLOB.configuration.general.restrict_antag_hud_rejoin = TRUE
to_chat(src, "<span class='danger'>AntagHUD restrictions have been enabled</span>")
+7 -2
View File
@@ -82,9 +82,14 @@
if(jobban_isbanned(user, banType) || jobban_isbanned(user, ROLE_SYNDICATE))
to_chat(user, "<span class='warning'>You are jobanned!</span>")
return FALSE
if(cannotPossess(user))
to_chat(user, "<span class='warning'>Upon using the antagHUD you forfeited the ability to join the round.</span>")
if(!HAS_TRAIT(user, TRAIT_RESPAWNABLE))
to_chat(user, "<span class='warning'>You currently do not have respawnability!</span>")
return FALSE
if(isobserver(user))
var/mob/dead/observer/O = user
if(!O.check_ahud_rejoin_eligibility())
to_chat(user, "<span class='warning'>Upon using the antagHUD you forfeited the ability to join the round.</span>")
return FALSE
if(time_check(user))
return FALSE
return TRUE
@@ -221,7 +221,7 @@
if(ready_to_deploy)
if(!istype(user)) // No revs allowed
return
if(cannotPossess(user))
if(!user.check_ahud_rejoin_eligibility())
to_chat(user, "<span class='warning'>Upon using the antagHUD you forfeited the ability to join the round.</span>")
return
var/be_helper = alert("Become a Lightgeist? (Warning, You can no longer be cloned!)",,"Yes","No")
@@ -828,3 +828,17 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
var/datum/spawners_menu/menu = new /datum/spawners_menu(src)
menu.ui_interact(src)
/**
* Check if a player has antag-hudded, and if so, if they can rejoin.
* Returns TRUE if the player can rejoin, and FALSE if the player is ineligible to rejoin.
* If allow_roundstart_observers is FALSE (TRUE by default), then any observers who were able to ahud due to joining roundstart will be excluded as well.
*/
/mob/dead/observer/proc/check_ahud_rejoin_eligibility(allow_roundstart_observers = TRUE)
if(!GLOB.configuration.general.restrict_antag_hud_rejoin || !has_ahudded())
return TRUE
if(is_roundstart_observer())
return allow_roundstart_observers
return FALSE
@@ -62,7 +62,7 @@
to_chat(O, "<span class='boldnotice'>\A [src] has been activated. (<a href='?src=[O.UID()];jump=\ref[src]'>Teleport</a> | <a href='?src=[UID()];signup=\ref[O]'>Sign Up</a>)</span>")
/obj/item/mmi/robotic_brain/proc/check_observer(mob/dead/observer/O)
if(cannotPossess(O))
if(!O.check_ahud_rejoin_eligibility())
return FALSE
if(jobban_isbanned(O, "Cyborg") || jobban_isbanned(O, "nonhumandept"))
return FALSE
@@ -121,6 +121,10 @@
to_chat(brainmob, "<b>Remember, the purpose of your existence is to serve [imprinted_master]'s every word, unless lawed or placed into a mech in the future.</b>")
brainmob.mind.assigned_role = "Positronic Brain"
if(brainmob.has_ahudded())
log_admin("[key_name(brainmob)] has joined as a robot brain, after having toggled antag hud.")
message_admins("[key_name(brainmob)] has joined as a robot brain, after having toggled antag hud.")
visible_message("<span class='notice'>[src] chimes quietly.</span>")
become_occupied(occupied_icon)
@@ -155,7 +159,7 @@
if(!check_observer(O))
to_chat(O, "<span class='warning'>You cannot be \a [src].</span>")
return
if(cannotPossess(O))
if(!O.check_ahud_rejoin_eligibility())
to_chat(O, "<span class='warning'>Upon using the antagHUD you forfeited the ability to join the round.</span>")
return
if(jobban_isbanned(O, "Cyborg") || jobban_isbanned(O, "nonhumandept"))
@@ -114,6 +114,10 @@
var/datum/data/pda/app/messenger/M = pda.find_program(/datum/data/pda/app/messenger)
M.toff = TRUE
if(has_ahudded())
message_admins("[key_name(src)] has joined as a pAI, having previously enabled antag hud.")
log_admin("[key_name(src)] has joined as a pAI, having previously enabled antag hud.")
// Software modules. No these var names have nothing to do with photoshop
for(var/PS in subtypesof(/datum/pai_software))
var/datum/pai_software/PSD = new PS(src)
@@ -355,7 +355,7 @@ GLOBAL_DATUM_INIT(paiController, /datum/paiController, new) // Global handler fo
return 0
if(!player_old_enough_antag(O.client,ROLE_PAI))
return 0
if(cannotPossess(O))
if(!O.check_ahud_rejoin_eligibility())
return 0
if(!HAS_TRAIT(O, TRAIT_RESPAWNABLE))
return 0
@@ -121,7 +121,7 @@
var/joinedasobserver = FALSE
if(isobserver(src))
var/mob/dead/observer/G = src
if(cannotPossess(G))
if(!G.check_ahud_rejoin_eligibility())
to_chat(usr, "<span class='warning'>Upon using the antagHUD you forfeited the ability to join the round.</span>")
return
if(G.started_as_observer == TRUE)
@@ -291,7 +291,7 @@
/mob/living/silicon/robot/drone/proc/request_player()
for(var/mob/dead/observer/O in GLOB.player_list)
if(cannotPossess(O))
if(!O.check_ahud_rejoin_eligibility())
continue
if(jobban_isbanned(O, "nonhumandept") || jobban_isbanned(O, "Drone"))
continue
@@ -16,8 +16,10 @@
humanize_prompt += " Role: [spider_role_summary]"
if(user.ckey in GLOB.ts_ckey_blacklist)
error_on_humanize = "You are not able to control any terror spider this round."
else if(cannotPossess(user))
error_on_humanize = "You have enabled antag HUD and are unable to re-enter the round."
else if(isobserver(user))
var/mob/dead/observer/O = user
if(!O.check_ahud_rejoin_eligibility())
error_on_humanize = "You have enabled antag HUD and are unable to re-enter the round."
else if(!ai_playercontrol_allowtype)
error_on_humanize = "This specific type of terror spider is not player-controllable."
else if(degenerate)
+6 -7
View File
@@ -137,13 +137,6 @@
return 1
/proc/cannotPossess(A)
var/mob/dead/observer/G = A
if(G.has_enabled_antagHUD && GLOB.configuration.general.restrict_antag_hud_rejoin)
return 1
return 0
/proc/iscuffed(A)
if(iscarbon(A))
var/mob/living/carbon/C = A
@@ -808,6 +801,12 @@ GLOBAL_LIST_INIT(intents, list(INTENT_HELP,INTENT_DISARM,INTENT_GRAB,INTENT_HARM
/mob/proc/attempt_listen_to_deadsay()
/mob/proc/is_roundstart_observer()
return (ckey in GLOB.roundstart_observer_keys)
/mob/proc/has_ahudded()
return (ckey in GLOB.antag_hud_users)
/// Proc to PROPERLY set mob invisibility, huds gotta get set too!
/mob/proc/set_invisible(invis_value)
if(invis_value)
-2
View File
@@ -122,8 +122,6 @@
var/move_on_shuttle = TRUE // Can move on the shuttle.
/// Whether antagHUD has been enabled previously.
var/has_enabled_antagHUD = FALSE
var/antagHUD = FALSE // Whether AntagHUD is active right now
var/can_change_intents = TRUE //all mobs can change intents by default.
///Override for sound_environments. If this is set the user will always hear a specific type of reverb (Instead of the area defined reverb)
+3 -2
View File
@@ -186,8 +186,9 @@
src << browse(null, "window=playersetup")
spawning = TRUE
stop_sound_channel(CHANNEL_LOBBYMUSIC)
if(SSticker.current_state < GAME_STATE_PLAYING)
GLOB.roundstart_observer_keys |= ckey
to_chat(src, "<span class='notice'>As you observed before the round started, you can freely toggle antag-hud without losing respawnability.</span>")
observer.started_as_observer = 1
close_spawn_windows()
var/obj/O = locate("landmark*Observer-Start")
+5 -3
View File
@@ -48,12 +48,14 @@ GLOBAL_LIST_EMPTY(ert_request_messages)
to_chat(src, "<span class='warning'>This role is not yet available to you. You need to wait another [player_age_check] days.</span>")
return FALSE
if(cannotPossess(src))
return TRUE
/mob/dead/observer/JoinResponseTeam()
. = ..()
if(!check_ahud_rejoin_eligibility())
to_chat(src, "<span class='boldnotice'>Upon using the antagHUD you forfeited the ability to join the round.</span>")
return FALSE
return TRUE
/proc/trigger_armed_response_team(datum/response_team/response_team_type, commander_slots, security_slots, medical_slots, engineering_slots, janitor_slots, paranormal_slots, cyborg_slots, cyborg_security)
GLOB.response_team_members = list()
GLOB.active_team = response_team_type
+10 -2
View File
@@ -62,14 +62,22 @@ GLOBAL_DATUM_INIT(ghost_hud_panel, /datum/ui_module/ghost_hud_panel, new)
to_chat(ghost, "<span class='danger'>You have been banned from using this feature.</span>")
return FALSE
// Check if this is the first time they're turning on Antag HUD.
if(!check_rights(R_ADMIN | R_MOD, FALSE) && !ghost.has_enabled_antagHUD && GLOB.configuration.general.restrict_antag_hud_rejoin)
if(!check_rights(R_ADMIN | R_MOD, FALSE) && !ghost.is_roundstart_observer() && GLOB.configuration.general.restrict_antag_hud_rejoin && !ghost.has_ahudded())
var/response = alert(ghost, "If you turn this on, you will not be able to take any part in the round.", "Are you sure you want to enable antag HUD?", "Yes", "No")
if(response == "No")
return FALSE
ghost.has_enabled_antagHUD = TRUE
ghost.can_reenter_corpse = FALSE
REMOVE_TRAIT(ghost, TRAIT_RESPAWNABLE, GHOSTED)
log_admin("[key_name(ghost)] has enabled antaghud as an observer and forfeited respawnability.")
message_admins("[key_name(ghost)] has enabled antaghud as an observer and forfeited respawnability.")
else if(ghost.is_roundstart_observer() && !ghost.has_ahudded())
log_admin("[key_name(ghost)] has enabled antaghud for the first time as a roundstart observer, keeping respawnability.")
GLOB.antag_hud_users |= ghost.ckey
ghost.antagHUD = TRUE
for(var/datum/atom_hud/antag/H in GLOB.huds)