mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-04 05:51:54 +00:00
Adds circutry to diagnostic hud, adds action flags to circuits (#35718)
cl add: Circuits integrity, charge, and overall circuit composition is displayed on diagnostic huds. If the assembly has dangerous circuits then the status icon will display exclamation points, if the assembly can communicate with something far away a wifi icon will appear next to the status icon, and if the circuit can not operate the status icon will display an 'X'. add: AR interface circuit which can modify the status icon if it is not displaying the exclamation points or the 'X'. tweak: Locomotive circuits can no longer be added to assemblies that can't use them. spellcheck: Fixed a typo in the grenade primer description. code: Added flags to circuits that help group subsets of circuits and regulate them. /cl The diagnostic hud addition is meant to allow more counter play to circuits by seeing the assemblies's healths and how dangerous they are. The flags are a useful addition to the code because players shouldn't be able to put circuits in assemblies if the assembly can't use that circuit (this can also be used later for other assemblies which could use unique circuits). The following circuits are flagged as dangerous: weapon firing mechanism grenade primer thrower The following circuits are flagged as long range: NTNet networking circuit integrated signaler video camera circuit possible AR interface displays: default alert move
This commit is contained in:
@@ -20,6 +20,11 @@
|
||||
var/charge_tick = FALSE
|
||||
var/charge_delay = 4
|
||||
var/use_cyborg_cell = TRUE
|
||||
var/allowed_circuit_action_flags = IC_ACTION_COMBAT | IC_ACTION_LONG_RANGE //which circuit flags are allowed
|
||||
var/combat_circuits = 0 //number of combat cicuits in the assembly, used for diagnostic hud
|
||||
var/long_range_circuits = 0 //number of long range cicuits in the assembly, used for diagnostic hud
|
||||
var/prefered_hud_icon = "hudstat" // Used by the AR circuit to change the hud icon.
|
||||
hud_possible = list(DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_TRACK_HUD, DIAG_CIRCUIT_HUD) //diagnostic hud overlays
|
||||
max_integrity = 50
|
||||
armor = list("melee" = 50, "bullet" = 70, "laser" = 70, "energy" = 100, "bomb" = 10, "bio" = 100, "rad" = 100, "fire" = 0, "acid" = 0)
|
||||
|
||||
@@ -32,14 +37,29 @@
|
||||
START_PROCESSING(SScircuit, src)
|
||||
materials[MAT_METAL] = round((max_complexity + max_components) / 4) * SScircuit.cost_multiplier
|
||||
|
||||
//sets up diagnostic hud view
|
||||
prepare_huds()
|
||||
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
|
||||
diag_hud.add_to_hud(src)
|
||||
diag_hud_set_circuithealth()
|
||||
diag_hud_set_circuitcell()
|
||||
diag_hud_set_circuitstat()
|
||||
diag_hud_set_circuittracking()
|
||||
|
||||
/obj/item/device/electronic_assembly/Destroy()
|
||||
STOP_PROCESSING(SScircuit, src)
|
||||
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
|
||||
diag_hud.remove_from_hud(src)
|
||||
return ..()
|
||||
|
||||
/obj/item/device/electronic_assembly/process()
|
||||
handle_idle_power()
|
||||
check_pulling()
|
||||
|
||||
//updates diagnostic hud
|
||||
diag_hud_set_circuithealth()
|
||||
diag_hud_set_circuitcell()
|
||||
|
||||
/obj/item/device/electronic_assembly/proc/handle_idle_power()
|
||||
// First we generate power.
|
||||
for(var/obj/item/integrated_circuit/passive/power/P in assembly_components)
|
||||
@@ -127,6 +147,7 @@
|
||||
playsound(src, 'sound/items/Crowbar.ogg', 50, 1)
|
||||
to_chat(usr, "<span class='notice'>You pull \the [battery] out of \the [src]'s power supplier.</span>")
|
||||
battery = null
|
||||
diag_hud_set_circuitstat() //update diagnostic hud
|
||||
|
||||
if(href_list["component"])
|
||||
var/obj/item/integrated_circuit/component = locate(href_list["component"]) in assembly_components
|
||||
@@ -170,6 +191,22 @@
|
||||
|
||||
interact(usr) // To refresh the UI.
|
||||
|
||||
/obj/item/device/electronic_assembly/pickup(mob/living/user)
|
||||
. = ..()
|
||||
//update diagnostic hud when picked up, true is used to force the hud to be hidden
|
||||
diag_hud_set_circuithealth(TRUE)
|
||||
diag_hud_set_circuitcell(TRUE)
|
||||
diag_hud_set_circuitstat(TRUE)
|
||||
diag_hud_set_circuittracking(TRUE)
|
||||
|
||||
/obj/item/device/electronic_assembly/dropped(mob/user)
|
||||
. = ..()
|
||||
//update diagnostic hud when dropped
|
||||
diag_hud_set_circuithealth()
|
||||
diag_hud_set_circuitcell()
|
||||
diag_hud_set_circuitstat()
|
||||
diag_hud_set_circuittracking()
|
||||
|
||||
/obj/item/device/electronic_assembly/proc/rename()
|
||||
var/mob/M = usr
|
||||
if(!check_interactivity(M))
|
||||
@@ -232,6 +269,9 @@
|
||||
if((total_complexity + IC.complexity) > max_complexity)
|
||||
to_chat(user, "<span class='warning'>You can't seem to add the '[IC]', since this setup's too complicated for the case.</span>")
|
||||
return FALSE
|
||||
if((allowed_circuit_action_flags & IC.action_flags) != IC.action_flags)
|
||||
to_chat(user, "<span class='warning'>You can't seem to add the '[IC]', since the case doesn't support the circuit type.</span>")
|
||||
return FALSE
|
||||
|
||||
if(!user.transferItemToLoc(IC, src))
|
||||
return FALSE
|
||||
@@ -249,6 +289,16 @@
|
||||
component.assembly = src
|
||||
assembly_components |= component
|
||||
|
||||
//increment numbers for diagnostic hud
|
||||
if(component.action_flags & IC_ACTION_COMBAT)
|
||||
combat_circuits += 1;
|
||||
if(component.action_flags & IC_ACTION_LONG_RANGE)
|
||||
long_range_circuits += 1;
|
||||
|
||||
//diagnostic hud update
|
||||
diag_hud_set_circuitstat()
|
||||
diag_hud_set_circuittracking()
|
||||
|
||||
|
||||
/obj/item/device/electronic_assembly/proc/try_remove_component(obj/item/integrated_circuit/IC, mob/user, silent)
|
||||
if(!opened)
|
||||
@@ -276,6 +326,16 @@
|
||||
component.assembly = null
|
||||
assembly_components.Remove(component)
|
||||
|
||||
//decriment numbers for diagnostic hud
|
||||
if(component.action_flags & IC_ACTION_COMBAT)
|
||||
combat_circuits -= 1;
|
||||
if(component.action_flags & IC_ACTION_LONG_RANGE)
|
||||
long_range_circuits -= 1;
|
||||
|
||||
//diagnostic hud update
|
||||
diag_hud_set_circuitstat()
|
||||
diag_hud_set_circuittracking()
|
||||
|
||||
|
||||
/obj/item/device/electronic_assembly/afterattack(atom/target, mob/user, proximity)
|
||||
for(var/obj/item/integrated_circuit/input/S in assembly_components)
|
||||
@@ -313,6 +373,7 @@
|
||||
user.transferItemToLoc(I, loc)
|
||||
cell.forceMove(src)
|
||||
battery = cell
|
||||
diag_hud_set_circuitstat() //update diagnostic hud
|
||||
playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
to_chat(user, "<span class='notice'>You slot \the [cell] inside \the [src]'s power supplier.</span>")
|
||||
interact(user)
|
||||
@@ -498,6 +559,7 @@
|
||||
w_class = WEIGHT_CLASS_BULKY
|
||||
max_components = IC_MAX_SIZE_BASE * 3
|
||||
max_complexity = IC_COMPLEXITY_BASE * 3
|
||||
allowed_circuit_action_flags = IC_ACTION_MOVEMENT | IC_ACTION_COMBAT | IC_ACTION_LONG_RANGE
|
||||
|
||||
/obj/item/device/electronic_assembly/drone/can_move()
|
||||
return TRUE
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
var/power_draw_per_use = 0 // How much power is drawn when work()'d.
|
||||
var/power_draw_idle = 0 // How much power is drawn when doing nothing.
|
||||
var/spawn_flags // Used for world initializing, see the #defines above.
|
||||
var/action_flags = NONE // Used for telling circuits that can do certain actions from other circuits.
|
||||
var/category_text = "NO CATEGORY THIS IS A BUG" // To show up on circuit printer, and perhaps other places.
|
||||
var/removable = TRUE // Determines if a circuit is removable from the assembly.
|
||||
var/displayed_name = ""
|
||||
|
||||
@@ -180,6 +180,11 @@
|
||||
var/obj/item/device/electronic_assembly/E = built
|
||||
E.opened = TRUE
|
||||
E.update_icon()
|
||||
//reupdate diagnostic hud because it was put_in_hands() and not pickup()'ed
|
||||
E.diag_hud_set_circuithealth()
|
||||
E.diag_hud_set_circuitcell()
|
||||
E.diag_hud_set_circuitstat()
|
||||
E.diag_hud_set_circuittracking()
|
||||
|
||||
to_chat(usr, "<span class='notice'>[capitalize(built.name)] printed.</span>")
|
||||
playsound(src, 'sound/items/jaws_pry.ogg', 50, TRUE)
|
||||
@@ -214,6 +219,8 @@
|
||||
to_chat(usr, "<span class='notice'>It uses advanced component designs.</span>")
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>It uses unknown component designs. Printer upgrade is required to proceed.</span>")
|
||||
if(program["unsupported_circuit"])
|
||||
to_chat(usr, "<span class='warning'>This program uses components not supported by the specified assembly. Please change the assembly type in the save file to a supported one.</span>")
|
||||
to_chat(usr, "<span class='notice'>Used space: [program["used_space"]]/[program["max_space"]].</span>")
|
||||
to_chat(usr, "<span class='notice'>Complexity: [program["complexity"]]/[program["max_complexity"]].</span>")
|
||||
to_chat(usr, "<span class='notice'>Metal cost: [program["metal_cost"]].</span>")
|
||||
@@ -224,6 +231,8 @@
|
||||
|
||||
if(program["requires_upgrades"] && !upgraded)
|
||||
to_chat(usr, "<span class='warning'>This program uses unknown component designs. Printer upgrade is required to proceed.</span>")
|
||||
if(program["unsupported_circuit"])
|
||||
to_chat(usr, "<span class='warning'>This program uses components not supported by the specified assembly. Please change the assembly type in the save file to a supported one.</span>")
|
||||
else
|
||||
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
|
||||
if(debug || materials.use_amount_type(program["metal_cost"], MAT_METAL))
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
// Returns assembly (type: list) if the save is valid.
|
||||
// Returns error code (type: text) if loading has failed.
|
||||
// The following parameters area calculated during validation and added to the returned save list:
|
||||
// "requires_upgrades", "metal_cost", "complexity", "max_complexity", "used_space", "max_space"
|
||||
// "requires_upgrades", "unsupported_circuit", "metal_cost", "complexity", "max_complexity", "used_space", "max_space"
|
||||
/datum/controller/subsystem/processing/circuit/proc/validate_electronic_assembly(program)
|
||||
var/list/blocks = json_decode(program)
|
||||
if(!blocks)
|
||||
@@ -275,6 +275,10 @@
|
||||
if(!(component.spawn_flags & IC_SPAWN_DEFAULT))
|
||||
blocks["requires_upgrades"] = TRUE
|
||||
|
||||
// Check if the assembly supports the circucit
|
||||
if((component.action_flags & assembly.allowed_circuit_action_flags) != component.action_flags)
|
||||
blocks["unsupported_circuit"] = TRUE
|
||||
|
||||
|
||||
// Check complexity and space limitations
|
||||
if(blocks["used_space"] > blocks["max_space"])
|
||||
|
||||
@@ -523,6 +523,7 @@
|
||||
"on signal sent" = IC_PINTYPE_PULSE_OUT,
|
||||
"on signal received" = IC_PINTYPE_PULSE_OUT)
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
action_flags = IC_ACTION_LONG_RANGE
|
||||
power_draw_idle = 5
|
||||
power_draw_per_use = 40
|
||||
|
||||
@@ -609,6 +610,7 @@
|
||||
)
|
||||
activators = list("send data" = IC_PINTYPE_PULSE_IN, "on data received" = IC_PINTYPE_PULSE_OUT)
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
action_flags = IC_ACTION_LONG_RANGE
|
||||
power_draw_per_use = 50
|
||||
var/datum/ntnet_connection/exonet = null
|
||||
var/address
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
)
|
||||
var/obj/item/gun/energy/installed_gun = null
|
||||
spawn_flags = IC_SPAWN_RESEARCH
|
||||
action_flags = IC_ACTION_COMBAT
|
||||
power_draw_per_use = 0
|
||||
var/mode = FALSE
|
||||
|
||||
@@ -142,6 +143,7 @@
|
||||
outputs = list()
|
||||
activators = list("step towards dir" = IC_PINTYPE_PULSE_IN,"on step"=IC_PINTYPE_PULSE_OUT,"blocked"=IC_PINTYPE_PULSE_OUT)
|
||||
spawn_flags = IC_SPAWN_RESEARCH
|
||||
action_flags = IC_ACTION_MOVEMENT
|
||||
power_draw_per_use = 100
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/locomotion/do_work()
|
||||
@@ -163,7 +165,7 @@
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/grenade
|
||||
name = "grenade primer"
|
||||
desc = "This circuit comes with the ability to attach most types of grenades at prime them at will."
|
||||
desc = "This circuit comes with the ability to attach most types of grenades and prime them at will."
|
||||
extended_desc = "Time between priming and detonation is limited to between 1 to 12 seconds but is optional. \
|
||||
If unset, not a number, or a number less than 1 then the grenade's built-in timing will be used. \
|
||||
Beware: Once primed there is no aborting the process!"
|
||||
@@ -173,6 +175,7 @@
|
||||
outputs = list()
|
||||
activators = list("prime grenade" = IC_PINTYPE_PULSE_IN)
|
||||
spawn_flags = IC_SPAWN_RESEARCH
|
||||
action_flags = IC_ACTION_COMBAT
|
||||
var/obj/item/grenade/attached_grenade
|
||||
var/pre_attached_grenade_type
|
||||
|
||||
@@ -410,6 +413,7 @@
|
||||
"fire" = IC_PINTYPE_PULSE_IN
|
||||
)
|
||||
spawn_flags = IC_SPAWN_RESEARCH
|
||||
action_flags = IC_ACTION_COMBAT
|
||||
power_draw_per_use = 50
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/thrower/do_work()
|
||||
|
||||
@@ -248,6 +248,7 @@
|
||||
outputs = list()
|
||||
activators = list()
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
action_flags = IC_ACTION_LONG_RANGE
|
||||
power_draw_idle = 0 // Raises to 20 when on.
|
||||
var/obj/machinery/camera/camera
|
||||
var/updating = FALSE
|
||||
@@ -336,3 +337,32 @@
|
||||
text_output += "\an ["\improper[name]"] labeled '[displayed_name]'"
|
||||
text_output += " which is currently [get_pin_data(IC_INPUT, 1) ? "lit <font color=[led_color]>*</font>" : "unlit"]."
|
||||
to_chat(user, text_output)
|
||||
|
||||
/obj/item/integrated_circuit/output/diagnostic_hud
|
||||
name = "AR interface"
|
||||
desc = "Takes an icon name as an input, and will update the status hud when data is written to it."
|
||||
extended_desc = "Takes an icon name as an input, and will update the status hud when data is written to it, this means it can change the icon and have the icon stay that way even if the circuit is removed. The acceptable inputs are 'alert' and 'move'. Any input other than that will return the icon to its default state. The danger warning and offline status will appear over any input from this circuit."
|
||||
var/list/icons = list(
|
||||
"alert" = "hudalert",
|
||||
"move" = "hudmove"
|
||||
)
|
||||
complexity = 1
|
||||
icon_state = "led"
|
||||
inputs = list(
|
||||
"icon" = IC_PINTYPE_STRING
|
||||
)
|
||||
outputs = list()
|
||||
activators = list()
|
||||
power_draw_idle = 0
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
|
||||
/obj/item/integrated_circuit/output/diagnostic_hud/on_data_written()
|
||||
var/ID = get_pin_data(IC_INPUT, 1)
|
||||
var/selected_icon = icons[ID]
|
||||
if(assembly)
|
||||
if(selected_icon)
|
||||
assembly.prefered_hud_icon = selected_icon
|
||||
else
|
||||
assembly.prefered_hud_icon = "hudstat"
|
||||
//update the diagnostic hud
|
||||
assembly.diag_hud_set_circuitstat()
|
||||
Reference in New Issue
Block a user