diff --git a/code/datums/wires/alarm.dm b/code/datums/wires/alarm.dm
new file mode 100644
index 00000000000..2c826e6d527
--- /dev/null
+++ b/code/datums/wires/alarm.dm
@@ -0,0 +1,94 @@
+
+/datum/wires/alarm
+ holder_type = /obj/machinery/alarm
+ wire_count = 5
+
+var/const/AALARM_WIRE_IDSCAN = 1
+var/const/AALARM_WIRE_POWER = 2
+var/const/AALARM_WIRE_SYPHON = 4
+var/const/AALARM_WIRE_AI_CONTROL = 8
+var/const/AALARM_WIRE_AALARM = 16
+
+
+/datum/wires/alarm/CanUse(var/mob/living/L)
+ var/obj/machinery/alarm/A = holder
+ if(A.wiresexposed)
+ return 1
+ return 0
+
+/datum/wires/alarm/GetInteractWindow()
+ var/obj/machinery/alarm/A = holder
+ . += ..()
+ . += text("
\n[(A.locked ? "The Air Alarm is locked." : "The Air Alarm is unlocked.")]
\n[((A.shorted || (A.stat & (NOPOWER|BROKEN))) ? "The Air Alarm is offline." : "The Air Alarm is working properly!")]
\n[(A.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")]")
+
+/datum/wires/alarm/UpdateCut(var/index, var/mended)
+ var/obj/machinery/alarm/A = holder
+ switch(index)
+ if(AALARM_WIRE_IDSCAN)
+ if(!mended)
+ A.locked = 1
+ //world << "Idscan wire cut"
+
+ if(AALARM_WIRE_POWER)
+ A.shock(usr, 50)
+ A.shorted = !mended
+ A.update_icon()
+ //world << "Power wire cut"
+
+ if (AALARM_WIRE_AI_CONTROL)
+ if (A.aidisabled == !mended)
+ A.aidisabled = mended
+ //world << "AI Control Wire Cut"
+
+ if(AALARM_WIRE_SYPHON)
+ if(!mended)
+ A.mode = 3 // AALARM_MODE_PANIC
+ A.apply_mode()
+ //world << "Syphon Wire Cut"
+
+ if(AALARM_WIRE_AALARM)
+ if (A.alarm_area.atmosalert(2))
+ A.post_alert(2)
+ A.update_icon()
+
+/datum/wires/alarm/UpdatePulsed(var/index)
+ var/obj/machinery/alarm/A = holder
+ switch(index)
+ if(AALARM_WIRE_IDSCAN)
+ A.locked = !A.locked
+ // world << "Idscan wire pulsed"
+
+ if (AALARM_WIRE_POWER)
+ // world << "Power wire pulsed"
+ if(A.shorted == 0)
+ A.shorted = 1
+ A.update_icon()
+
+ spawn(12000)
+ if(A.shorted == 1)
+ A.shorted = 0
+ A.update_icon()
+
+
+ if (AALARM_WIRE_AI_CONTROL)
+ // world << "AI Control wire pulsed"
+ if (A.aidisabled == 0)
+ A.aidisabled = 1
+ A.updateDialog()
+ spawn(100)
+ if (A.aidisabled == 1)
+ A.aidisabled = 0
+
+ if(AALARM_WIRE_SYPHON)
+ // world << "Syphon wire pulsed"
+ if(A.mode == 1) // AALARM_MODE_SCRUB
+ A.mode = 3 // AALARM_MODE_PANIC
+ else
+ A.mode = 1 // AALARM_MODE_SCRUB
+ A.apply_mode()
+
+ if(AALARM_WIRE_AALARM)
+ // world << "Aalarm wire pulsed"
+ if (A.alarm_area.atmosalert(0))
+ A.post_alert(0)
+ A.update_icon()
diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm
index dccfb930f63..eb25e49cfad 100644
--- a/code/game/machinery/alarm.dm
+++ b/code/game/machinery/alarm.dm
@@ -1,28 +1,4 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
-
-
-/proc/RandomAAlarmWires()
- //to make this not randomize the wires, just set index to 1 and increment it in the flag for loop (after doing everything else).
- var/list/AAlarmwires = list(0, 0, 0, 0, 0)
- AAlarmIndexToFlag = list(0, 0, 0, 0, 0)
- AAlarmIndexToWireColor = list(0, 0, 0, 0, 0)
- AAlarmWireColorToIndex = list(0, 0, 0, 0, 0)
- var/flagIndex = 1
- for (var/flag=1, flag<32, flag+=flag)
- var/valid = 0
- while (!valid)
- var/colorIndex = rand(1, 5)
- if (AAlarmwires[colorIndex]==0)
- valid = 1
- AAlarmwires[colorIndex] = flag
- AAlarmIndexToFlag[flagIndex] = flag
- AAlarmIndexToWireColor[flagIndex] = colorIndex
- AAlarmWireColorToIndex[colorIndex] = flagIndex
- flagIndex+=1
- return AAlarmwires
-
-
-
// A datum for dealing with threshold limit values
// used in /obj/machinery/alarm
/datum/tlv
@@ -51,6 +27,20 @@
max1 = other.max1
max2 = other.max2
+#define AALARM_MODE_SCRUBBING 1
+#define AALARM_MODE_VENTING 2 //makes draught
+#define AALARM_MODE_PANIC 3 //constantly sucks all air
+#define AALARM_MODE_REPLACEMENT 4 //sucks off all air, then refill and swithes to scrubbing
+#define AALARM_MODE_OFF 5
+
+#define AALARM_SCREEN_MAIN 1
+#define AALARM_SCREEN_VENT 2
+#define AALARM_SCREEN_SCRUB 3
+#define AALARM_SCREEN_MODE 4
+#define AALARM_SCREEN_SENSORS 5
+
+#define AALARM_REPORT_TIMEOUT 100
+
/obj/machinery/alarm
name = "alarm"
icon = 'icons/obj/monitors.dmi'
@@ -64,36 +54,19 @@
var/frequency = 1439
//var/skipprocess = 0 //Experimenting
var/alarm_frequency = 1437
-#define AALARM_REPORT_TIMEOUT 100
+
var/datum/radio_frequency/radio_connection
var/locked = 1
+ var/datum/wires/alarm/wires = null
var/wiresexposed = 0 // If it's been screwdrivered open.
var/aidisabled = 0
var/AAlarmwires = 31
var/shorted = 0
var/buildstage = 2 // 2 = complete, 1 = no wires, 0 = circuit gone
- // Uses code from apc.dm
-#define AALARM_WIRE_IDSCAN 1 //Added wires
-#define AALARM_WIRE_POWER 2
-#define AALARM_WIRE_SYPHON 3
-#define AALARM_WIRE_AI_CONTROL 4
-#define AALARM_WIRE_AALARM 5
-
-
-#define AALARM_MODE_SCRUBBING 1
-#define AALARM_MODE_VENTING 2 //makes draught
-#define AALARM_MODE_PANIC 3 //constantly sucks all air
-#define AALARM_MODE_REPLACEMENT 4 //sucks off all air, then refill and swithes to scrubbing
-#define AALARM_MODE_OFF 5
var/mode = AALARM_MODE_SCRUBBING
-#define AALARM_SCREEN_MAIN 1
-#define AALARM_SCREEN_VENT 2
-#define AALARM_SCREEN_SCRUB 3
-#define AALARM_SCREEN_MODE 4
-#define AALARM_SCREEN_SENSORS 5
var/screen = AALARM_SCREEN_MAIN
var/area_uid
var/area/alarm_area
@@ -145,6 +118,7 @@
/obj/machinery/alarm/New(nloc, ndir, nbuild)
..()
+ wires = new(src)
if(nloc)
loc = nloc
@@ -201,31 +175,6 @@
user << browse(null, "window=air_alarm")
return
- if(wiresexposed && (!istype(user, /mob/living/silicon)))
- var/t1 = text("Access Panel
\n")
- var/list/AAlarmwires = list(
- "Orange" = 1,
- "Dark red" = 2,
- "White" = 3,
- "Yellow" = 4,
- "Black" = 5,
- )
- for(var/wiredesc in AAlarmwires)
- var/is_uncut = src.AAlarmwires & AAlarmWireColorToFlag[AAlarmwires[wiredesc]]
- t1 += "[wiredesc] wire: "
- if(!is_uncut)
- t1 += "Mend"
-
- else
- t1 += "Cut "
- t1 += "Pulse "
-
- t1 += "
"
- t1 += text("
\n[(src.locked ? "The Air Alarm is locked." : "The Air Alarm is unlocked.")]
\n[((src.shorted || (stat & (NOPOWER|BROKEN))) ? "The Air Alarm is offline." : "The Air Alarm is working properly!")]
\n[(src.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")]")
- t1 += text("