diff --git a/code/modules/integrated_electronics/core/assemblies.dm b/code/modules/integrated_electronics/core/assemblies.dm index 3b6cd5ffd2..152eb94577 100644 --- a/code/modules/integrated_electronics/core/assemblies.dm +++ b/code/modules/integrated_electronics/core/assemblies.dm @@ -475,10 +475,18 @@ // Bump functionality, for pathfinding circuits. (Droid circuit assembly types) /obj/item/electronic_assembly/Bump(atom/AM) ..() - if(istype(AM, /obj/machinery/door) && can_move()) - var/obj/machinery/door/D = AM - if(D.check_access(src)) - D.open() + if(can_move()) + // Check if it's an airlock or windoor. (Prevents opening blast doors and shutters) + if(istype(AM, /obj/machinery/door/airlock) || istype(AM, /obj/machinery/door/window)) + var/obj/machinery/door/D = AM + // Only open doors that we have access to + if(D.check_access(src)) + D.open() + +/obj/item/electronic_assembly/check_access(obj/item/I) + if(access_card) + return access_card.check_access(I) + return ..() // Fall back to default behavior if no access_card // Returns TRUE if I is something that could/should have a valid interaction. Used to tell circuitclothes to hit the circuit with something instead of the clothes /obj/item/electronic_assembly/proc/is_valid_tool(var/obj/item/I) diff --git a/code/modules/integrated_electronics/subtypes/converters.dm b/code/modules/integrated_electronics/subtypes/converters.dm index b9026e54c3..47d68c2642 100644 --- a/code/modules/integrated_electronics/subtypes/converters.dm +++ b/code/modules/integrated_electronics/subtypes/converters.dm @@ -12,6 +12,7 @@ desc = "This circuit can convert a number variable into a string." extended_desc = "Because of game limitations null/false variables will output a '0' string." icon_state = "num-string" + complexity = 2 inputs = list("input" = IC_PINTYPE_NUMBER) outputs = list("output" = IC_PINTYPE_STRING) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -33,6 +34,7 @@ name = "string to number" desc = "This circuit can convert a string variable into a number." icon_state = "string-num" + complexity = 2 inputs = list("input" = IC_PINTYPE_STRING) outputs = list("output" = IC_PINTYPE_NUMBER) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -52,6 +54,7 @@ name = "reference to string" desc = "This circuit can convert a reference to something else to a string, specifically the name of that reference." icon_state = "ref-string" + complexity = 2 inputs = list("input" = IC_PINTYPE_REF) outputs = list("output" = IC_PINTYPE_STRING) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -71,6 +74,7 @@ name = "reference encoder" desc = "This circuit can encode a reference into a string, which can then be read by an EPV2 circuit." icon_state = "ref-string" + complexity = 2 inputs = list("input" = IC_PINTYPE_REF) outputs = list("output" = IC_PINTYPE_STRING) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -90,6 +94,7 @@ name = "reference decoder" desc = "This circuit can convert an encoded reference to actual reference." icon_state = "ref-string" + complexity = 2 inputs = list("input" = IC_PINTYPE_STRING) outputs = list("output" = IC_PINTYPE_REF) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -105,6 +110,7 @@ name = "lowercase string converter" desc = "this will cause a string to come out in all lowercase." icon_state = "lowercase" + complexity = 2 inputs = list("input" = IC_PINTYPE_STRING) outputs = list("output" = IC_PINTYPE_STRING) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -124,6 +130,7 @@ name = "uppercase string converter" desc = "THIS WILL CAUSE A STRING TO COME OUT IN ALL UPPERCASE." icon_state = "uppercase" + complexity = 2 inputs = list("input" = IC_PINTYPE_STRING) outputs = list("output" = IC_PINTYPE_STRING) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -142,7 +149,7 @@ /obj/item/integrated_circuit/converter/concatenator name = "concatenator" desc = "This joins many strings together to get one big string." - complexity = 4 + complexity = 2 inputs = list( "A" = IC_PINTYPE_STRING, "B" = IC_PINTYPE_STRING, @@ -256,6 +263,7 @@ /obj/item/integrated_circuit/converter/radians2degrees name = "radians to degrees converter" desc = "Converts radians to degrees." + complexity = 3 inputs = list("radian" = IC_PINTYPE_NUMBER) outputs = list("degrees" = IC_PINTYPE_NUMBER) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -274,6 +282,7 @@ /obj/item/integrated_circuit/converter/degrees2radians name = "degrees to radians converter" desc = "Converts degrees to radians." + complexity = 3 inputs = list("degrees" = IC_PINTYPE_NUMBER) outputs = list("radians" = IC_PINTYPE_NUMBER) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index ff7f4b236f..bea163b281 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -11,7 +11,7 @@ desc = "A handheld mechanism that can be aimed to attain distant references." extended_desc = "When used, it will capture the reference of the target, and output coordinates relative to the user." icon_state = "video_camera" - complexity = 4 + complexity = 10 inputs = list() outputs = list( "clicked ref" = IC_PINTYPE_REF, @@ -94,7 +94,7 @@ name = "text pad" desc = "This small text pad allows someone to input a string into the system." icon_state = "textpad" - complexity = 2 + complexity = 1 can_be_asked_input = 1 inputs = list() outputs = list("string entered" = IC_PINTYPE_STRING) @@ -132,7 +132,7 @@ name = "integrated medical analyser" desc = "A very small version of the common medical analyser. This allows the machine to know how healthy someone is." icon_state = "medscan" - complexity = 4 + complexity = 5 inputs = list("target" = IC_PINTYPE_REF) outputs = list( "total health %" = IC_PINTYPE_NUMBER, @@ -166,7 +166,7 @@ This type is much more precise, allowing the machine to know much more about the target than a normal analyzer." icon_state = "medscan_adv" - complexity = 12 + complexity = 10 inputs = list("target" = IC_PINTYPE_REF) outputs = list( "total health %" = IC_PINTYPE_NUMBER, @@ -226,7 +226,7 @@ activators = list("scan" = IC_PINTYPE_PULSE_IN, "on scanned" = IC_PINTYPE_PULSE_OUT, "not scanned" = IC_PINTYPE_PULSE_OUT) spawn_flags = IC_SPAWN_RESEARCH origin_tech = list(TECH_ENGINEERING = 3, TECH_DATA = 3, TECH_BIO = 4) - power_draw_per_use = 80 + power_draw_per_use = 40 /obj/item/integrated_circuit/input/examiner/do_work() var/atom/movable/H = get_pin_data_as_type(IC_INPUT, 1, /atom/movable) @@ -260,6 +260,7 @@ desc = "This is needed for certain devices that demand a reference for a target to act upon. This type only locates something \ that is holding the machine containing it." inputs = list() + complexity = 3 outputs = list("located ref") activators = list("locate" = IC_PINTYPE_PULSE_IN) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -283,6 +284,7 @@ random." inputs = list("desired type ref") outputs = list("located ref") + complexity = 4 activators = list("locate" = IC_PINTYPE_PULSE_IN,"found" = IC_PINTYPE_PULSE_OUT, "not found" = IC_PINTYPE_PULSE_OUT) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH @@ -332,7 +334,7 @@ outputs = list("located ref") activators = list("locate" = IC_PINTYPE_PULSE_IN,"found" = IC_PINTYPE_PULSE_OUT,"not found" = IC_PINTYPE_PULSE_OUT) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH - power_draw_per_use = 30 + power_draw_per_use = 50 var/radius = 1 /obj/item/integrated_circuit/input/advanced_locator/on_data_written() @@ -346,7 +348,7 @@ var/datum/integrated_io/O = outputs[1] O.data = null var/turf/T = get_turf(src) - var/list/nearby_things = range(radius, T) & view(T) + var/list/nearby_things = range(radius, T) var/list/valid_things = list() if(isweakref(I.data)) var/atom/A = I.data.resolve() @@ -359,6 +361,9 @@ continue if(thing.is_incorporeal()) continue + // Skip invisible & incorporeal players. + if(ismob(M) && M:invisibility > 0) + continue if(istype(thing, desired_type)) valid_things.Add(thing) else if(istext(I.data)) @@ -371,6 +376,9 @@ continue if(thing.is_incorporeal()) continue + // Skip invisible & incorporeal players. + if(ismob(M) && M:invisibility > 0) + continue if(istype(thing, desired_type)) valid_things.Add(thing) var/DT = I.data @@ -380,6 +388,9 @@ var/atom/movable/M = thing if(ismob(M) && M == DEAD && get_pin_data(IC_INPUT, 3) == TRUE) // Ignore dead mobs if requested. continue + // Skip invisible & incorporeal players. + if(ismob(M) && M:invisibility > 0) + continue if(findtext(addtext(thing.name," ",thing.desc), DT, 1, 0) ) valid_things.Add(thing) if(valid_things.len) @@ -410,7 +421,7 @@ "on signal received" = IC_PINTYPE_PULSE_OUT) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH origin_tech = list(TECH_ENGINEERING = 2, TECH_DATA = 2, TECH_MAGNET = 2) - power_draw_idle = 5 + // power_draw_idle = 5 // Breaks recharging cells, and unnecessary for this circuit. power_draw_per_use = 40 var/frequency = RSD_FREQ @@ -497,9 +508,10 @@ outputs = list( "address received" = IC_PINTYPE_STRING, "data received" = IC_PINTYPE_STRING, - "secondary text received" = IC_PINTYPE_STRING + "secondary text received" = IC_PINTYPE_STRING, + "self address" = IC_PINTYPE_STRING ) - activators = list("send data" = IC_PINTYPE_PULSE_IN, "on data received" = IC_PINTYPE_PULSE_OUT) + activators = list("send data" = IC_PINTYPE_PULSE_IN, "on data received" = IC_PINTYPE_PULSE_OUT, "on data sent" = IC_PINTYPE_PULSE_OUT) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH origin_tech = list(TECH_ENGINEERING = 2, TECH_DATA = 2, TECH_MAGNET = 2, TECH_BLUESPACE = 2) power_draw_per_use = 50 @@ -529,6 +541,7 @@ var/target_address = get_pin_data(IC_INPUT, 1) var/message = get_pin_data(IC_INPUT, 2) var/text = get_pin_data(IC_INPUT, 3) + set_pin_data(IC_OUTPUT, 4, exonet.address) var/is_communicator = FALSE // improved communicator support for(var/obj/item/communicator/comm in all_communicators) @@ -640,7 +653,7 @@ is only triggered if it sees someone speaking a language other than sign language, which it will attempt to \ lip-read." icon_state = "video_camera" - complexity = 12 + complexity = 5 inputs = list() outputs = list( "speaker ref", @@ -705,7 +718,7 @@ desc = "Scans and obtains a reference for any objects or persons near you. All you need to do is shove the machine in their face." extended_desc = "If 'ignore storage' pin is set to true, the sensor will disregard scanning various storage containers such as backpacks." icon_state = "recorder" - complexity = 12 + complexity = 8 inputs = list("ignore storage" = IC_PINTYPE_BOOLEAN) outputs = list("scanned" = IC_PINTYPE_REF) activators = list("on scanned" = IC_PINTYPE_PULSE_OUT) @@ -807,7 +820,7 @@ desc = "The same atmospheric analysis module that is integrated into every PDA. \ This allows the machine to know the composition, temperature and pressure of the surrounding atmosphere." icon_state = "medscan_adv" - complexity = 9 + complexity = 6 inputs = list() outputs = list( "pressure" = IC_PINTYPE_NUMBER, diff --git a/code/modules/integrated_electronics/subtypes/logic.dm b/code/modules/integrated_electronics/subtypes/logic.dm index 21055118ea..82b069320d 100644 --- a/code/modules/integrated_electronics/subtypes/logic.dm +++ b/code/modules/integrated_electronics/subtypes/logic.dm @@ -2,7 +2,7 @@ name = "logic gate" desc = "This tiny chip will decide for you!" extended_desc = "Logic circuits will treat a null, 0, and a \"\" string value as FALSE and anything else as TRUE." - complexity = 3 + complexity = 1 outputs = list("result") activators = list("compare" = IC_PINTYPE_PULSE_IN) category_text = "Logic" @@ -12,6 +12,7 @@ push_data() /obj/item/integrated_circuit/logic/binary + complexity = 1 inputs = list("A","B") activators = list("compare" = IC_PINTYPE_PULSE_IN, "on true result" = IC_PINTYPE_PULSE_OUT, "on false result" = IC_PINTYPE_PULSE_OUT) @@ -32,6 +33,7 @@ return FALSE /obj/item/integrated_circuit/logic/unary + complexity = 1 inputs = list("A") activators = list("compare" = IC_PINTYPE_PULSE_IN, "on compare" = IC_PINTYPE_PULSE_OUT) @@ -50,6 +52,7 @@ name = "equal gate" desc = "This gate compares two values, and outputs the number one if both are the same." icon_state = "equal" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/equals/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -60,6 +63,7 @@ /obj/item/integrated_circuit/logic/binary/jklatch name = "JK latch" desc = "This gate is a synchronysed JK latch." + complexity = 1 icon_state = "jklatch" inputs = list("J","K") outputs = list("Q","!Q") @@ -93,6 +97,7 @@ name = "RS latch" desc = "This gate is synchronysed a RS latch. If both R and S are true, the state will not change." icon_state = "sr_nor" + complexity = 2 inputs = list("S","R") outputs = list("Q","!Q") activators = list("pulse in C" = IC_PINTYPE_PULSE_IN, "pulse out Q" = IC_PINTYPE_PULSE_OUT, "pulse out !Q" = IC_PINTYPE_PULSE_OUT) @@ -123,6 +128,7 @@ name = "gated D latch" desc = "This gate is a synchronysed gated D latch." icon_state = "gated_d" + complexity = 2 inputs = list("D","E") outputs = list("Q","!Q") activators = list("pulse in C" = IC_PINTYPE_PULSE_IN, "pulse out Q" = IC_PINTYPE_PULSE_OUT, "pulse out !Q" = IC_PINTYPE_PULSE_OUT) @@ -153,6 +159,7 @@ name = "not equal gate" desc = "This gate compares two values, and outputs the number one if both are different." icon_state = "not_equal" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/not_equals/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -164,6 +171,7 @@ name = "and gate" desc = "This gate will output 'one' if both inputs evaluate to true." icon_state = "and" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/and/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -173,6 +181,7 @@ name = "or gate" desc = "This gate will output 'one' if one of the inputs evaluate to true." icon_state = "or" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/or/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -182,6 +191,7 @@ name = "less than gate" desc = "This will output 'one' if the first input is less than the second input." icon_state = "less_than" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/less_than/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -191,6 +201,7 @@ name = "less than or equal gate" desc = "This will output 'one' if the first input is less than, or equal to the second input." icon_state = "less_than_or_equal" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/less_than_or_equal/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -200,6 +211,7 @@ name = "greater than gate" desc = "This will output 'one' if the first input is greater than the second input." icon_state = "greater_than" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/greater_than/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -209,6 +221,7 @@ name = "greater_than or equal gate" desc = "This will output 'one' if the first input is greater than, or equal to the second input." icon_state = "greater_than_or_equal" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/binary/greater_than_or_equal/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B) @@ -218,6 +231,7 @@ name = "not gate" desc = "This gate inverts what's fed into it." icon_state = "not" + complexity = 1 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH activators = list("invert" = IC_PINTYPE_PULSE_IN, "on inverted" = IC_PINTYPE_PULSE_OUT) @@ -225,28 +239,48 @@ return !A.data /obj/item/integrated_circuit/logic/toggler // Allows parts of circuits to be toggled on/off. - name = "circuit toggler" - desc = "Outputs its input data if enabled, otherwise does nothing. Used for enable/disabling parts of your circuit boards" + name = "Circuit Gate" + desc = "A circuit gate, only sending out data, and pulses when it is enabled." icon_state = "toggle_button" + complexity = 2 inputs = list( "input" = IC_PINTYPE_ANY, "enabled" = IC_PINTYPE_BOOLEAN, - "toggle enable" = IC_PINTYPE_PULSE_IN, ) inputs_default = list("2" = TRUE) outputs = list("output" = IC_PINTYPE_ANY) activators = list( "pulse in" = IC_PINTYPE_PULSE_IN, "pulse out" = IC_PINTYPE_PULSE_OUT - ) + ) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/logic/toggler/do_work() pull_data() var/enabled_input = get_pin_data(IC_INPUT, 2) - if(!enabled_input) - return - else + + if(enabled_input) set_pin_data(IC_OUTPUT, 1, get_pin_data(IC_INPUT, 1)) push_data() - activate_pin(2) + activate_pin(2) // Only activate downstream circuits if enabled + else + set_pin_data(IC_OUTPUT, 1, null) + +/obj/item/integrated_circuit/logic/toggle_output + name = "boolean toggle" + desc = "A simple toggle circuit that starts TRUE and switches between TRUE and FALSE each time it's pulsed." + icon_state = "toggle_button" + complexity = 2 + inputs = list() + outputs = list("state" = IC_PINTYPE_BOOLEAN) + outputs_default = list("1" = TRUE) + activators = list("toggle" = IC_PINTYPE_PULSE_IN, "on toggle" = IC_PINTYPE_PULSE_OUT) + spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH + +/obj/item/integrated_circuit/logic/toggle_output/do_work() + // Toggle the output boolean + var/current_state = get_pin_data(IC_OUTPUT, 1) + var/new_state = !current_state + set_pin_data(IC_OUTPUT, 1, new_state) + push_data() + activate_pin(2) // Pulse out after toggling) diff --git a/code/modules/integrated_electronics/subtypes/manipulation.dm b/code/modules/integrated_electronics/subtypes/manipulation.dm index 4c48916862..31c3051299 100644 --- a/code/modules/integrated_electronics/subtypes/manipulation.dm +++ b/code/modules/integrated_electronics/subtypes/manipulation.dm @@ -8,7 +8,7 @@ The first and second inputs need to be numbers. They are coordinates for the gun to fire at, relative to the machine itself. \ The 'fire' activator will cause the mechanism to attempt to fire the weapon at the coordinates, if possible. Note that the \ normal limitations to firearms, such as ammunition requirements and firing delays, still hold true if fired by the mechanism." - complexity = 20 + complexity = 30 // Increased due to clear balance necessity. w_class = ITEMSIZE_NORMAL size = 3 inputs = list( diff --git a/code/modules/integrated_electronics/subtypes/memory.dm b/code/modules/integrated_electronics/subtypes/memory.dm index 63ac8bdd36..6adb44bd07 100644 --- a/code/modules/integrated_electronics/subtypes/memory.dm +++ b/code/modules/integrated_electronics/subtypes/memory.dm @@ -86,6 +86,10 @@ var/datum/integrated_io/O = outputs[1] O.push_data() +/obj/item/integrated_circuit/memory/constant/emp_act(severity) + // Prevents default EMP behavior for single-slot constants memory. + return + /obj/item/integrated_circuit/memory/constant/attack_self(mob/user) var/datum/integrated_io/O = outputs[1] var/type_to_use = tgui_input_list(user, "Please choose a type to use.","[src] type setting", list("string","number","ref", "null")) diff --git a/code/modules/integrated_electronics/subtypes/output.dm b/code/modules/integrated_electronics/subtypes/output.dm index be0788effd..03c2f977fd 100644 --- a/code/modules/integrated_electronics/subtypes/output.dm +++ b/code/modules/integrated_electronics/subtypes/output.dm @@ -122,7 +122,7 @@ desc = "A miniature speaker is attached to this component. It is able to transpose any valid text to speech." extended_desc = "This will emit an audible message to anyone who can hear the assembly." icon_state = "speaker" - complexity = 12 + complexity = 5 cooldown_per_use = 4 SECONDS inputs = list("text" = IC_PINTYPE_STRING) outputs = list() @@ -168,7 +168,7 @@ name = "speaker circuit" desc = "A miniature speaker is attached to this component." icon_state = "speaker" - complexity = 8 + complexity = 5 cooldown_per_use = 4 SECONDS inputs = list( "sound ID" = IC_PINTYPE_STRING, diff --git a/code/modules/integrated_electronics/subtypes/smart.dm b/code/modules/integrated_electronics/subtypes/smart.dm index 9315b3ea79..efbd3bf0d1 100644 --- a/code/modules/integrated_electronics/subtypes/smart.dm +++ b/code/modules/integrated_electronics/subtypes/smart.dm @@ -53,10 +53,18 @@ origin_tech = list(TECH_ENGINEERING = 4, TECH_DATA = 5) power_draw_per_use = 40 +/obj/item/integrated_circuit/smart/targeted_pathfinder + var/turf/last_known_position = null + var/datum/weakref/last_target = null + /obj/item/integrated_circuit/smart/targeted_pathfinder/do_work() var/datum/integrated_io/I = inputs[1] set_pin_data(IC_OUTPUT, 1, null) + if(!istype(I.data, /datum/weakref) || I.data != last_target) + last_known_position = null + last_target = I.data + if(!isweakref(I.data)) push_data() activate_pin(2) @@ -75,12 +83,16 @@ activate_pin(2) return - if(!(A in view(start))) - push_data() - activate_pin(2) - return // Can't see the target. + if(A in view(start)) + last_known_position = goal - // Pathfinding start + // If target not visible but we have last known position, use that instead + if(!(A in view(start))) + if(!last_known_position) + push_data() + activate_pin(2) + return + goal = last_known_position var/list/path = AStar(start, goal, /turf/proc/AdjacentTurfsWithAccess, /turf/proc/Distance, 0, 30, id = assembly) if(path && path.len > 1) var/turf/next = path[2] // path[1] is current location @@ -117,8 +129,19 @@ power_draw_per_use = 60 cooldown_per_use = 2 // 3 delay on a ticker circuit from testing. +/obj/item/integrated_circuit/smart/pathfinding_locomotion + // Add these two variables + var/turf/last_known_position = null + var/datum/weakref/last_target = null + /obj/item/integrated_circuit/smart/pathfinding_locomotion/do_work() var/datum/integrated_io/I = inputs[1] + + // Reset last known position when target changes + if(!istype(I.data, /datum/weakref) || I.data != last_target) + last_known_position = null + last_target = I.data + if(!isweakref(I.data)) activate_pin(3) return @@ -134,25 +157,36 @@ activate_pin(3) return + // Update last known position when target is visible + if(A in view(start)) + last_known_position = goal + + // If target not visible but we have last known position, use that instead + if(!(A in view(start))) + if(!last_known_position) + // No idea where target is + set_pin_data(IC_OUTPUT, 1, null) + set_pin_data(IC_OUTPUT, 2, null) + push_data() + activate_pin(3) + return + goal = last_known_position + var/desired_dir - // Only calculate full path if target is in view - if(A in view(start)) - var/list/path = AStar(start, goal, /turf/proc/AdjacentTurfsWithAccess, /turf/proc/Distance, 0, 30, id = assembly) - if(path && path.len > 1) - var/turf/next = path[2] - desired_dir = get_dir(start, next) - else - desired_dir = get_dir(start, goal) + // Calculate path to either current position or last known position + var/list/path = AStar(start, goal, /turf/proc/AdjacentTurfsWithAccess, /turf/proc/Distance, 0, 30, id = assembly) + if(path && path.len > 1) + var/turf/next = path[2] + desired_dir = get_dir(start, next) else - // If we can't see the target, just move in its direction desired_dir = get_dir(start, goal) set_pin_data(IC_OUTPUT, 1, desired_dir) set_pin_data(IC_OUTPUT, 2, get_dist(start, goal)) push_data() - // Move the assembly. + // Move the assembly if(assembly && !assembly.anchored && assembly.can_move()) var/move_result = step(assembly, desired_dir) if(move_result) @@ -161,3 +195,40 @@ activate_pin(3) else activate_pin(3) + + // Normal pulse in (ord == 1) + pull_data() + var/enabled_input = get_pin_data(IC_INPUT, 2) + + // Always set the output data, but make it null if disabled + if(enabled_input) + set_pin_data(IC_OUTPUT, 1, get_pin_data(IC_INPUT, 1)) + push_data() + activate_pin(3) // Only activate downstream circuits if enabled + else // Clear output when disabled + push_data() + + +/obj/item/integrated_circuit/smart/z_level_sensor + name = "Z-level sensor" + desc = "A specialized circuit that reports the current Z-level when pulsed." + extended_desc = "This circuit will output the current Z-level coordinate of the assembly when activated. Useful for navigation and location tracking." + icon_state = "numberpad" + complexity = 5 + inputs = list() + outputs = list("Z-level" = IC_PINTYPE_NUMBER) + activators = list("get Z-level" = IC_PINTYPE_PULSE_IN, "on read" = IC_PINTYPE_PULSE_OUT) + spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH + origin_tech = list(TECH_ENGINEERING = 2, TECH_DATA = 3) + power_draw_per_use = 10 + +/obj/item/integrated_circuit/smart/z_level_sensor/do_work() + var/turf/current_turf = get_turf(src) + var/z_level = 1 // Default fallback + + if(current_turf) + z_level = current_turf.z + + set_pin_data(IC_OUTPUT, 1, z_level) + push_data() + activate_pin(2) diff --git a/code/modules/integrated_electronics/subtypes/time.dm b/code/modules/integrated_electronics/subtypes/time.dm index 1acaea0f3b..a1c337f7ac 100644 --- a/code/modules/integrated_electronics/subtypes/time.dm +++ b/code/modules/integrated_electronics/subtypes/time.dm @@ -35,18 +35,19 @@ The power consumption will scale based on how fast this ticks. Also, note that most components have a short \ internal cooldown when activated." icon_state = "tick-f" - complexity = 10 + complexity = 1 inputs = list("enable ticking" = IC_PINTYPE_BOOLEAN, "delay time" = IC_PINTYPE_NUMBER) activators = list("outgoing pulse" = IC_PINTYPE_PULSE_OUT) spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH - power_draw_per_use = 5 + power_draw_per_use = 1 var/delay = 2 SECONDS var/next_fire = 0 var/is_running = FALSE // Power consumption scales based on how fast it ticks. // This, plus the fact it ticks more often will increase consumption non-linearly, // and the circuit cooldown and will hopefully discourage stupidly fast ticking machines. - var/max_power_draw = 500 + // Modified due to this simlpe circuit being able to drain a cell in seconds. + var/max_power_draw = 250 /obj/item/integrated_circuit/time/ticker/on_data_written() var/delay_input = get_pin_data(IC_INPUT, 2)