Only give bots HUDs when player-controlled. (#19198)

* Only give bots HUDs when player-controlled.

* Clean up data_hud regardless of whether or not a player is present.

* No need to keep around this ref.
This commit is contained in:
warriorstar-orion
2022-10-10 15:20:55 -05:00
committed by GitHub
parent ed39233fe0
commit 71cf58d8a5
4 changed files with 15 additions and 19 deletions
@@ -77,7 +77,8 @@
var/control_freq = BOT_FREQ // bot control frequency
var/bot_filter // The radio filter the bot uses to identify itself on the network.
var/bot_type = 0 //The type of bot it is, for radio control.
var/data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC //The type of data HUD the bot uses. Diagnostic by default.
/// The type of data HUD the bot uses. Diagnostic by default.
var/data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC
//This holds text for what the bot is mode doing, reported on the remote bot control interface.
var/list/mode_name = list("In Pursuit","Preparing to Arrest", "Arresting", \
"Beginning Patrol", "Patrolling", "Summoned by PDA", \
@@ -163,15 +164,14 @@
prepare_huds()
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
diag_hud.add_to_hud(src)
diag_hud.add_hud_to(src)
permanent_huds |= diag_hud
diag_hud_set_bothealth()
diag_hud_set_botstat()
diag_hud_set_botmode()
// give us the hud too!
if(path_hud)
path_hud.add_to_hud(src)
path_hud.add_hud_to(src)
/mob/living/simple_animal/bot/med_hud_set_health()
@@ -187,6 +187,11 @@
if(path_hud)
QDEL_NULL(path_hud)
path_hud = null
var/datum/atom_hud/data_hud = GLOB.huds[data_hud_type]
if(data_hud)
data_hud.remove_hud_from(src)
GLOB.bots_list -= src
QDEL_NULL(Radio)
QDEL_NULL(access_card)
@@ -957,11 +962,17 @@ Pass a positive integer as an argument to override a bot's default speed.
/mob/living/simple_animal/bot/Login()
. = ..()
access_card.access += player_access
var/datum/atom_hud/data_hud = GLOB.huds[data_hud_type]
if(data_hud)
data_hud.add_hud_to(src)
diag_hud_set_botmode()
show_laws()
/mob/living/simple_animal/bot/Logout()
. = ..()
bot_reset()
/mob/living/simple_animal/bot/revive(full_heal = 0, admin_revive = 0)
@@ -70,12 +70,6 @@
else if (lasercolor == "r")
name = pick("RED RAMPAGE","RED ROVER","RED KILLDEATH MURDERBOT")
//SECHUD
var/datum/atom_hud/secsensor = GLOB.huds[DATA_HUD_SECURITY_ADVANCED]
secsensor.add_hud_to(src)
permanent_huds |= secsensor
/mob/living/simple_animal/bot/ed209/proc/setup_access()
if(access_card)
var/datum/job/detective/J = new/datum/job/detective
@@ -125,10 +125,6 @@
prev_access = access_card.access
qdel(J)
var/datum/atom_hud/medsensor = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED]
medsensor.add_hud_to(src)
permanent_huds |= medsensor
if(new_skin)
skin = new_skin
update_icon()
@@ -93,11 +93,6 @@
access_card.access += J.get_access()
prev_access = access_card.access
//SECHUD
var/datum/atom_hud/secsensor = GLOB.huds[DATA_HUD_SECURITY_ADVANCED]
secsensor.add_hud_to(src)
permanent_huds |= secsensor
/mob/living/simple_animal/bot/secbot/turn_on()
..()
icon_state = "[base_icon][on]"