Skip to content

Commit

Permalink
Allow for basic Eyebot support when AI is on a different Z level (#16240
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Azrun committed Oct 10, 2023
1 parent bd08da9 commit 57e6b3b
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 3 deletions.
44 changes: 44 additions & 0 deletions code/datums/hud/shell.dm
Expand Up @@ -5,6 +5,8 @@
var/atom/movable/screen/hud/charge
var/atom/movable/screen/hud/eyecam

var/list/statusUiElements = list() //Assoc. List STATUS EFFECT INSTANCE : UI ELEMENT add_screen(atom/movable/screen/S). Used to hold the ui elements since they shouldnt be on the status effects themselves.

var/list/last_tools = list()
var/list/atom/movable/screen/hud/tool_selector_bg = list()
var/list/obj/item/tool_selector_tools = list()
Expand Down Expand Up @@ -167,3 +169,45 @@
remove_screen(H)
for (var/obj/item/tool in tool_selector_tools)
remove_object(tool)

proc/update_status_effects()
for(var/datum/statusEffect/S as anything in src.statusUiElements) //Remove stray effects.
remove_screen(statusUiElements[S])
if(!master || !master.statusEffects || !(S in master.statusEffects))
qdel(statusUiElements[S])
src.statusUiElements.Remove(S)
qdel(S)

var/spacing = 0.6
var/pos_x = spacing - 0.2

if(master?.statusEffects)
for(var/datum/statusEffect/S as anything in master.statusEffects) //Add new ones, update old ones.
if(!S.visible) continue
if((S in statusUiElements) && statusUiElements[S])
var/atom/movable/screen/statusEffect/U = statusUiElements[S]
U.icon = 'icons/mob/hud_robot.dmi'
U.screen_loc = "EAST[pos_x < 0 ? "":"+"][pos_x],NORTH-0.7"
U.update_value()
add_screen(U)
pos_x -= spacing
else
if(S.visible)
var/atom/movable/screen/statusEffect/U = new /atom/movable/screen/statusEffect
U.init(master,S)
U.icon = 'icons/mob/hud_robot.dmi'
statusUiElements.Add(S)
statusUiElements[S] = U
U.screen_loc = "EAST[pos_x < 0 ? "":"+"][pos_x],NORTH-0.7"
U.update_value()
add_screen(U)
pos_x -= spacing
animate_buff_in(U)
return

/mob/living/silicon/hivebot
updateStatusUi()
if(src.hud && istype(src.hud, /datum/hud/shell))
var/datum/hud/shell/H = src.hud
H.update_status_effects()
return
2 changes: 2 additions & 0 deletions code/mob/living/life/Life.dm
Expand Up @@ -202,6 +202,8 @@
add_lifeprocess(/datum/lifeprocess/hivebot_statusupdate)
add_lifeprocess(/datum/lifeprocess/stuns_lying)
add_lifeprocess(/datum/lifeprocess/blindness)
add_lifeprocess(/datum/lifeprocess/hivebot_signal)


/mob/living/silicon/robot/restore_life_processes()
..()
Expand Down
5 changes: 3 additions & 2 deletions code/mob/living/silicon.dm
Expand Up @@ -185,7 +185,7 @@ ADMIN_INTERACT_PROCS(/mob/living/silicon, proc/pick_law_rack)
/mob/living/silicon/click(atom/target, params, location, control)
if (src.targeting_ability)
..()
if (!src.stat && !src.restrained() && !src.getStatusDuration("weakened") && !src.getStatusDuration("paralysis") && !src.getStatusDuration("stunned"))
if (!src.stat && !src.restrained() && !src.getStatusDuration("weakened") && !src.getStatusDuration("paralysis") && !src.getStatusDuration("stunned") && !src.getStatusDuration("low_signal"))
if(src.client.check_any_key(KEY_OPEN | KEY_BOLT | KEY_SHOCK) && istype(target, /obj) )
var/obj/O = target
if(O.receive_silicon_hotkey(src)) return
Expand All @@ -198,7 +198,8 @@ ADMIN_INTERACT_PROCS(/mob/living/silicon, proc/pick_law_rack)
if (GET_DIST(src, target) > 0) // temporary fix for cyborgs turning by clicking
set_dir(get_dir(src, target))

target.attack_ai(src, params, location, control)
if(!src.getStatusDuration("low_signal"))
target.attack_ai(src, params, location, control)

/*
/mob/living/key_down(key)
Expand Down
2 changes: 1 addition & 1 deletion code/mob/living/silicon/ai.dm
Expand Up @@ -1872,7 +1872,7 @@ or don't if it uses a custom topopen overlay
var/list/bodies = new/list()

for (var/mob/living/silicon/hivebot/H in available_ai_shells)
if (H.shell && !H.dependent && !isdead(H) && get_step(H, 0)?.z == get_step(src, 0)?.z)
if (H.shell && !H.dependent && !isdead(H))
bodies += H

for (var/mob/living/silicon/robot/R in available_ai_shells)
Expand Down
44 changes: 44 additions & 0 deletions code/mob/living/silicon/hivebot.dm
Expand Up @@ -1186,3 +1186,47 @@ Frequency:
still_needed += "an AI interface board"
boutput(user, "\The [src] needs [still_needed.len ? english_list(still_needed) : "bugfixing (please call a coder)"] before you can activate it.")
return


/datum/statusEffect/low_signal
id = "low_signal"
name = "Low Signal"
desc = "You have reduced signal to your shell."
icon_state = "low_signal"
unique = TRUE
effect_quality = STATUS_QUALITY_NEGATIVE

onAdd(optional)
. = ..()
if (!ismob(owner)) return
var/mob/M = owner
M.addOverlayComposition(/datum/overlayComposition/low_signal)

onUpdate(timePassed)
. = ..()
if (ishivebot(owner))
var/mob/living/silicon/hivebot/H = owner
if(H.module_active || H.module_states[1] || H.module_states[2] || H.module_states[3])
H.module_active = null
H.module_states[1] = null
H.module_states[2] = null
H.module_states[3] = null
H.hud.update_tools()
H.hud.update_tool_selector()
H.hud.update_active_tool()
H.show_text("Insufficient signal to maintain control of tools.")

onRemove()
. = ..()
if (QDELETED(owner) || !ismob(owner)) return
var/mob/M = owner
M.removeOverlayComposition(/datum/overlayComposition/low_signal)

/datum/lifeprocess/hivebot_signal
process(var/datum/gas_mixture/environment)
if(hivebot_owner?.mainframe)
if((get_step(hivebot_owner.mainframe, 0)?.z == get_step(hivebot_owner, 0)?.z) || (inunrestrictedz(hivebot_owner) && inonstationz(hivebot_owner.mainframe)))
hivebot_owner.delStatus("low_signal")
else
hivebot_owner.setStatus("low_signal", INFINITE_STATUS)
..()
21 changes: 21 additions & 0 deletions code/modules/overlays/OverlayManager.dm
Expand Up @@ -343,6 +343,27 @@
/datum/overlayComposition/static_noise/sub
special_blend = BLEND_SUBTRACT

/datum/overlayComposition/low_signal
New()
var/datum/overlayDefinition/dither = new()
dither.d_icon = 'icons/effects/overlays/weldingmask.dmi'
dither.d_icon_state = "weldingmask"
dither.d_alpha = 240
dither.d_blend_mode = 2
dither.d_mouse_opacity = 0
definitions.Add(dither)

var/datum/overlayDefinition/zero = new()
zero.d_icon = 'icons/effects/overlays/noise.dmi'
zero.d_icon_state = "noise"
zero.d_blend_mode = 5
zero.d_color = "#111"
zero.d_alpha = 100
zero.d_mouse_opacity = 0
definitions.Add(zero)

return ..()


/datum/overlayComposition/weldingmask
New()
Expand Down
Binary file modified icons/ui/statussystem.dmi
Binary file not shown.

0 comments on commit 57e6b3b

Please sign in to comment.