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
@@ -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")