Circuit Bugfixes (#6930)

Fixes a myriad of issues with circuits:

    Fixes scanners not working with circuit clothing.
    Fixes buttons etc. not working with circuit clothing.
    Fixes circuit sensors not working, period.
    Fixes my accidental deletion of the temperature sensor aspect of the reagent sensor circuit. :'(
    Fixes circuit gloves and glasses not triggering properly.
    Makes it so that anchored items cannot be picked up. (Risky? Maybe!)
This commit is contained in:
MarinaGryphon
2019-08-31 21:08:03 +03:00
committed by Erki
parent 2e66de4205
commit d600950c56
7 changed files with 27 additions and 30 deletions
@@ -232,12 +232,8 @@
IC.assembly = src
/obj/item/device/electronic_assembly/afterattack(atom/target, mob/user, proximity)
var/scanned = FALSE
for(var/obj/item/integrated_circuit/input/sensor/S in contents)
if(S.sense(target))
scanned = TRUE
if(scanned)
visible_message("<span class='notice'>\The [user] waves \the [src] around [target].</span>")
S.sense(target, user)
/obj/item/device/electronic_assembly/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/integrated_circuit))
@@ -53,18 +53,13 @@
/obj/item/clothing/attackby(obj/item/I, mob/user)
if(IC)
// This needs to be done in a better way...
if(I.iscrowbar() || I.isscrewdriver() || istype(I, /obj/item/integrated_circuit) || istype(I, /obj/item/weapon/cell) || istype(I, /obj/item/device/integrated_electronics))
IC.attackby(I, user)
IC.attackby(I, user)
else
..()
/obj/item/clothing/attack_self(mob/user)
if(IC)
if(IC.opened)
IC.attack_self(user)
else
action_circuit.do_work()
IC.attack_self(user)
else
..()
@@ -92,7 +87,7 @@
// Jumpsuit.
/obj/item/clothing/under/circuitry
name = "electronic jumpsuit"
desc = "It's a wearable case for electronics. This on is a black jumpsuit with wiring weaved into the fabric."
desc = "It's a wearable case for electronics. This one is a black jumpsuit with wiring weaved into the fabric."
icon_state = "circuitry"
worn_state = "circuitry"
@@ -117,9 +112,10 @@
if(!A || !proximity)
return 0
if(istype(action_circuit) && action_circuit.check_then_do_work())
if(istype(action_circuit) && action_circuit.check_power())
action_circuit.set_pin_data(IC_OUTPUT, 1, A)
action_circuit.push_data() // we have to not return 1 so we can still do normal stuff like picking things up, etc.
action_circuit.activate_pin(1)
return 0
// Glasses.
@@ -128,7 +124,8 @@
desc = "It's a wearable case for electronics. This one is a pair of goggles, with wiring sticking out. \
Could this augment your vision?" // Sadly it won't, or at least not yet.
icon_state = "circuitry"
item_state = "night" // The on-mob sprite would be identical anyways.
item_state = "glasses"
off_state = "denight"
/obj/item/clothing/glasses/circuitry/Initialize()
setup_integrated_circuit(/obj/item/device/electronic_assembly/clothing/small)
@@ -138,9 +135,10 @@
if(!A)
return 0
if(istype(action_circuit) && action_circuit.check_then_do_work())
if(istype(action_circuit) && action_circuit.check_power())
action_circuit.set_pin_data(IC_OUTPUT, 1, A)
action_circuit.push_data() // we have to not return 1 so we can still do normal stuff like picking things up, etc.
action_circuit.activate_pin(1)
return 0
// Shoes
@@ -189,7 +189,7 @@
power_draw_per_use = 80
/obj/item/integrated_circuit/input/examiner/do_work()
var/atom/movable/H = get_pin_data_as_type(IC_INPUT, 1, /atom/movable)
var/atom/H = get_pin_data_as_type(IC_INPUT, 1, /atom)
var/turf/T = get_turf(src)
if(!istype(H)) //Invalid input
return
@@ -497,8 +497,8 @@
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
power_draw_per_use = 120
/obj/item/integrated_circuit/input/sensor/proc/sense(var/atom/A)
if(!src.Adjacent(A))
/obj/item/integrated_circuit/input/sensor/proc/sense(var/atom/A, mob/user)
if(!user.Adjacent(A))
return FALSE
var/ignore_bags = get_pin_data(IC_INPUT, 1)
if(ignore_bags)
@@ -508,6 +508,7 @@
set_pin_data(IC_OUTPUT, 1, A)
push_data()
activate_pin(1)
user.visible_message(span("notice", "[user] waves [assembly] around [A]."), span("notice", "You scan [A] with [assembly]."))
return TRUE
/obj/item/integrated_circuit/input/atmo_scanner
@@ -918,7 +919,7 @@
return FALSE
set_pin_data(IC_OUTPUT, 1, A)
push_data()
to_chat(user, "<span class='notice'>You scan [A] with [assembly].</span>")
user.visible_message(span("notice", "[user] points [assembly] at [A]."), span("notice", "You scan [A] with [assembly]."))
activate_pin(1)
return TRUE
@@ -210,7 +210,7 @@
var/mob/living/M = get_pin_data_as_type(IC_INPUT, 1, /mob/living)
if(!istype(M)) //Invalid input
return
if(!M.Adjacent(T))
if(!T.Adjacent(M))
return //Can't reach
to_chat(M, "<span class='danger'>You feel a sharp shock!</span>")
spark(get_turf(M), 3, 1)
@@ -103,16 +103,16 @@
if(isliving(AM))
var/mob/living/L = AM
var/turf/T = get_turf(AM)
T.visible_message("<span class='warning'>[src] is trying to inject [L]!</span>")
T.visible_message("<span class='warning'>[assembly] is trying to inject [L]!</span>")
sleep(3 SECONDS)
if(!L.can_be_injected_by(src))
activate_pin(3)
return
var/contained = reagents.get_reagents()
var/trans = reagents.trans_to_mob(L, transfer_amount, CHEM_BLOOD)
message_admins("[src] injected \the [L] with [trans]u of [contained].")
message_admins("[assembly] injected \the [L] with [trans]u of [contained].")
to_chat(AM, "<span class='notice'>You feel a tiny prick!</span>")
visible_message("<span class='warning'>[src] injects [L]!</span>")
visible_message("<span class='warning'>[assembly] injects [L]!</span>")
else
reagents.trans_to(AM, transfer_amount)
else
@@ -129,7 +129,7 @@
if(!TS.Adjacent(TT))
activate_pin(3)
return
var/tramount = Clamp(min(transfer_amount, reagents.maximum_volume - reagents.total_volume), 0, reagents.maximum_volume)
var/tramount = Clamp(min(transfer_amount, reagents.get_free_space()), 0, reagents.maximum_volume)
if(ismob(target))//Blood!
if(istype(target, /mob/living/carbon))
var/mob/living/carbon/T = target
@@ -145,7 +145,6 @@
else
activate_pin(3)
return
return
var/datum/reagent/B
if(istype(T, /mob/living/carbon/human))
var/mob/living/carbon/human/H = T
@@ -161,7 +160,7 @@
on_reagent_change()
reagents.handle_reactions()
B = null
visible_message( "<span class='notice'>Machine takes a blood sample from [target].</span>")
visible_message( "<span class='notice'>[assembly] takes a blood sample from [target].</span>")
else
activate_pin(3)
return
@@ -222,8 +221,7 @@
source = beaker_slot.get_item(FALSE)
if(!istype(source) || (!istype(target))) //Invalid input
return
var/turf/T = get_turf(src)
if((source.Adjacent(T) || istype(beaker_slot)) && target.Adjacent(T))
if((src.Adjacent(source) || istype(beaker_slot)) && src.Adjacent(target))
if(!source.reagents || !target.reagents)
return
if(ismob(source) || ismob(target))