Converts all machines relying on RandomAPCWires() to the new wire datum system.

This commit is contained in:
PsiOmega
2014-10-13 21:46:45 +02:00
parent f190acf7c5
commit 97a5186cee
8 changed files with 209 additions and 311 deletions
+3
View File
@@ -165,6 +165,9 @@
#include "code\datums\spells\turf_teleport.dm"
#include "code\datums\spells\wizard.dm"
#include "code\datums\wires\apc.dm"
#include "code\datums\wires\smartfridge.dm"
#include "code\datums\wires\suit_storage_unit.dm"
#include "code\datums\wires\vending.dm"
#include "code\datums\wires\wires.dm"
#include "code\defines\obj.dm"
#include "code\defines\obj\weapon.dm"
+52
View File
@@ -0,0 +1,52 @@
/datum/wires/smartfridge
holder_type = /obj/machinery/smartfridge
wire_count = 3
var/const/SMARTFRIDGE_WIRE_ELECTRIFY = 1
var/const/SMARTFRIDGE_WIRE_THROW = 2
var/const/SMARTFRIDGE_WIRE_IDSCAN = 4
/datum/wires/smartfridge/CanUse(var/mob/living/L)
var/obj/machinery/smartfridge/S = holder
if(!istype(L, /mob/living/silicon))
if(S.seconds_electrified)
if(S.shock(L, 100))
return 0
if(S.panel_open)
return 1
return 0
/datum/wires/smartfridge/Interact(var/mob/living/user)
if(CanUse(user))
var/obj/machinery/smartfridge/S = holder
S.attack_hand(user)
/datum/wires/smartfridge/GetInteractWindow()
var/obj/machinery/smartfridge/S = holder
. += ..()
. += "<BR>The orange light is [S.seconds_electrified ? "off" : "on"].<BR>"
. += "The red light is [S.shoot_inventory ? "off" : "blinking"].<BR>"
. += "A [S.scan_id ? "purple" : "yellow"] light is on.<BR>"
/datum/wires/smartfridge/UpdatePulsed(var/index)
var/obj/machinery/smartfridge/S = holder
switch(index)
if(SMARTFRIDGE_WIRE_THROW)
S.shoot_inventory = !S.shoot_inventory
if(SMARTFRIDGE_WIRE_ELECTRIFY)
S.seconds_electrified = 30
if(SMARTFRIDGE_WIRE_IDSCAN)
S.scan_id = !S.scan_id
/datum/wires/smartfridge/UpdateCut(var/index, var/mended)
var/obj/machinery/smartfridge/S = holder
switch(index)
if(SMARTFRIDGE_WIRE_THROW)
S.shoot_inventory = !mended
if(SMARTFRIDGE_WIRE_ELECTRIFY)
if(mended)
S.seconds_electrified = 0
else
S.seconds_electrified = -1
if(SMARTFRIDGE_WIRE_IDSCAN)
S.scan_id = 1
+52
View File
@@ -0,0 +1,52 @@
/datum/wires/suit_storage_unit
holder_type = /obj/machinery/suit_cycler
wire_count = 3
var/const/SUIT_STORAGE_WIRE_ELECTRIFY = 1
var/const/SUIT_STORAGE_WIRE_SAFETY = 2
var/const/SUIT_STORAGE_WIRE_LOCKED = 4
/datum/wires/suit_storage_unit/CanUse(var/mob/living/L)
var/obj/machinery/suit_cycler/S = holder
if(!istype(L, /mob/living/silicon))
if(S.electrified)
if(S.shock(L, 100))
return 0
if(S.panel_open)
return 1
return 0
/datum/wires/suit_storage_unit/Interact(var/mob/living/user)
if(CanUse(user))
var/obj/machinery/suit_cycler/S = holder
S.attack_hand(user)
/datum/wires/suit_storage_unit/GetInteractWindow()
var/obj/machinery/suit_cycler/S = holder
. += ..()
. += "<BR>The orange light is [S.electrified ? "off" : "on"].<BR>"
. += "The red light is [S.safeties ? "off" : "blinking"].<BR>"
. += "The yellow light is [S.locked ? "on" : "off"].<BR>"
/datum/wires/suit_storage_unit/UpdatePulsed(var/index)
var/obj/machinery/suit_cycler/S = holder
switch(index)
if(SUIT_STORAGE_WIRE_SAFETY)
S.safeties = !S.safeties
if(SUIT_STORAGE_WIRE_ELECTRIFY)
S.electrified = 30
if(SUIT_STORAGE_WIRE_LOCKED)
S.locked = !S.locked
/datum/wires/suit_storage_unit/UpdateCut(var/index, var/mended)
var/obj/machinery/suit_cycler/S = holder
switch(index)
if(SUIT_STORAGE_WIRE_SAFETY)
S.safeties = mended
if(SUIT_STORAGE_WIRE_LOCKED)
S.locked = mended
if(SUIT_STORAGE_WIRE_ELECTRIFY)
if(mended)
S.electrified = 0
else
S.electrified = -1
+58
View File
@@ -0,0 +1,58 @@
/datum/wires/vending
holder_type = /obj/machinery/vending
wire_count = 4
var/const/VENDING_WIRE_THROW = 1
var/const/VENDING_WIRE_CONTRABAND = 2
var/const/VENDING_WIRE_ELECTRIFY = 4
var/const/VENDING_WIRE_IDSCAN = 8
/datum/wires/vending/CanUse(var/mob/living/L)
var/obj/machinery/vending/V = holder
if(!istype(L, /mob/living/silicon))
if(V.seconds_electrified)
if(V.shock(L, 100))
return 0
if(V.panel_open)
return 1
return 0
/datum/wires/vending/Interact(var/mob/living/user)
if(CanUse(user))
var/obj/machinery/vending/V = holder
V.attack_hand(user)
/datum/wires/vending/GetInteractWindow()
var/obj/machinery/vending/V = holder
. += ..()
. += "<BR>The orange light is [V.seconds_electrified ? "off" : "on"].<BR>"
. += "The red light is [V.shoot_inventory ? "off" : "blinking"].<BR>"
. += "The green light is [V.extended_inventory ? "on" : "off"].<BR>"
. += "The [V.scan_id ? "purple" : "yellow"] light is on.<BR>"
/datum/wires/vending/UpdatePulsed(var/index)
var/obj/machinery/vending/V = holder
switch(index)
if(VENDING_WIRE_THROW)
V.shoot_inventory = !V.shoot_inventory
if(VENDING_WIRE_CONTRABAND)
V.extended_inventory = !V.extended_inventory
if(VENDING_WIRE_ELECTRIFY)
V.seconds_electrified = 30
if(VENDING_WIRE_IDSCAN)
V.scan_id = !V.scan_id
/datum/wires/vending/UpdateCut(var/index, var/mended)
var/obj/machinery/vending/V = holder
switch(index)
if(VENDING_WIRE_THROW)
V.shoot_inventory = !mended
if(VENDING_WIRE_CONTRABAND)
V.extended_inventory = 0
if(VENDING_WIRE_ELECTRIFY)
if(mended)
V.seconds_electrified = 0
else
V.seconds_electrified = -1
if(VENDING_WIRE_IDSCAN)
V.scan_id = 1
+9 -98
View File
@@ -22,11 +22,14 @@
var/shoot_inventory = 0
var/locked = 0
var/panel_open = 0 //Hacking a smartfridge
var/wires = 7
var/const/WIRE_SHOCK = 1
var/const/WIRE_SHOOTINV = 2
var/const/WIRE_SCANID = 3 //Only used by the secure smartfridge, but required by the cut, mend and pulse procs.
var/scan_id = 1
var/datum/wires/smartfridge/wires = null
/obj/machinery/smartfridge/New()
wires = new(src)
/obj/machinery/smartfridge/Del()
del(wires) // qdel
/obj/machinery/smartfridge/proc/accept_check(var/obj/item/O as obj)
if(istype(O,/obj/item/weapon/reagent_containers/food/snacks/grown/) || istype(O,/obj/item/seeds/))
@@ -217,6 +220,8 @@
if(seconds_electrified != 0)
if(shock(user, 100))
return
if(panel_open)
wires.Interact(user)
ui_interact(user)
@@ -248,26 +253,6 @@
if (items.len > 0)
data["contents"] = items
var/list/vendwires = null
if (is_secure)
vendwires = list(
"Violet" = 1,
"Orange" = 2,
"Green" = 3)
else
vendwires = list(
"Blue" = 1,
"Red" = 2,
"Black" = 3)
var/list/vendor_wires[0]
for (var/wire in vendwires)
var is_uncut = wires & APCWireColorToFlag[vendwires[wire]]
vendor_wires.Add(list(list("wire" = wire, "cut" = !is_uncut, "index" = vendwires[wire])))
if (vendor_wires.len > 0)
data["wires"] = vendor_wires
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "smartfridge.tmpl", src.name, 400, 500)
@@ -306,82 +291,8 @@
return 1
return 1
if (panel_open)
if (href_list["cutwire"])
if (!( istype(usr.get_active_hand(), /obj/item/weapon/wirecutters) ))
user << "You need wirecutters!"
return 1
var/wire_index = text2num(href_list["cutwire"])
if (isWireColorCut(wire_index))
mend(wire_index)
else
cut(wire_index)
return 1
if (href_list["pulsewire"])
if (!istype(usr.get_active_hand(), /obj/item/device/multitool))
usr << "You need a multitool!"
return 1
var/wire_index = text2num(href_list["pulsewire"])
if (isWireColorCut(wire_index))
usr << "You can't pulse a cut wire."
return 1
pulse(wire_index)
return 1
return 0
/*************
* Hacking
**************/
/obj/machinery/smartfridge/proc/cut(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
var/wireIndex = APCWireColorToIndex[wireColor]
src.wires &= ~wireFlag
switch(wireIndex)
if(WIRE_SHOCK)
src.seconds_electrified = -1
if (WIRE_SHOOTINV)
if(!src.shoot_inventory)
src.shoot_inventory = 1
if(WIRE_SCANID)
src.locked = 1
/obj/machinery/smartfridge/proc/mend(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
var/wireIndex = APCWireColorToIndex[wireColor]
src.wires |= wireFlag
switch(wireIndex)
if(WIRE_SHOCK)
src.seconds_electrified = 0
if (WIRE_SHOOTINV)
src.shoot_inventory = 0
if(WIRE_SCANID)
src.locked = 0
/obj/machinery/smartfridge/proc/pulse(var/wireColor)
var/wireIndex = APCWireColorToIndex[wireColor]
switch(wireIndex)
if(WIRE_SHOCK)
src.seconds_electrified = 30
if(WIRE_SHOOTINV)
src.shoot_inventory = !src.shoot_inventory
if(WIRE_SCANID)
src.locked = -1
/obj/machinery/smartfridge/proc/isWireColorCut(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
return ((src.wires & wireFlag) == 0)
/obj/machinery/smartfridge/proc/isWireCut(var/wireIndex)
var/wireFlag = APCIndexToFlag[wireIndex]
return ((src.wires & wireFlag) == 0)
/obj/machinery/smartfridge/proc/throw_item()
var/obj/throw_item = null
var/mob/living/target = locate() in view(7,src)
+12 -88
View File
@@ -27,7 +27,6 @@
var/safetieson = 1
var/cycletime_left = 0
//The units themselves/////////////////
/obj/machinery/suit_storage_unit/standard_unit
@@ -591,13 +590,7 @@
var/locked = 1 // If locked, nothing can be taken from or added to the cycler.
var/panel_open = 0 // Hacking!
var/can_repair // If set, the cycler can repair hardsuits.
// Wiring bollocks.
var/wires = 15
var/electrified = 0
var/const/WIRE_EXTEND = 1 // Safeties
var/const/WIRE_SCANID = 2 // Locked status
var/const/WIRE_SHOCK = 3 // What it says on the tin.
//Departments that the cycler can paint suits to look like.
var/list/departments = list("Engineering","Mining","Medical","Security","Atmos")
@@ -611,12 +604,20 @@
var/obj/item/clothing/suit/space/rig/suit = null
var/obj/item/clothing/head/helmet/space/helmet = null
var/datum/wires/suit_storage_unit/wires = null
/obj/machinery/suit_cycler/New()
..()
wires = new(src)
target_department = departments[1]
target_species = species[1]
if(!target_department || !target_species) del(src)
/obj/machinery/suit_cycler/Del()
del(wires) // qdel
wires = null
/obj/machinery/suit_cycler/engineering
name = "Engineering suit cycler"
model_text = "Engineering"
@@ -820,31 +821,15 @@
dat += "<A href='?src=\ref[src];apply_paintjob=1'><br>\[apply customisation routine\]</a><br><hr>"
if(panel_open)
var/list/vendwires = list(
"Violet" = 1,
"Orange" = 2,
"Goldenrod" = 3,
)
dat += "<h2><B>Access Panel</B></h2>"
for(var/wiredesc in vendwires)
var/is_uncut = src.wires & APCWireColorToFlag[vendwires[wiredesc]]
dat += "[wiredesc] wire: "
if(!is_uncut)
dat += "<a href='?src=\ref[src];cutwire=[vendwires[wiredesc]]'>Mend</a>"
else
dat += "<a href='?src=\ref[src];cutwire=[vendwires[wiredesc]]'>Cut</a> "
dat += "<a href='?src=\ref[src];pulsewire=[vendwires[wiredesc]]'>Pulse</a> "
dat += "<br>"
dat += "<br>"
dat += "The orange light is [(electrified == 0) ? "off" : "on"].<BR>"
dat += "The red light is [safeties ? "blinking" : "off"].<BR>"
dat += "The yellow light is [locked ? "on" : "off"].<BR>"
dat += wires()
user << browse(dat, "window=suit_cycler")
onclose(user, "suit_cycler")
return
/obj/machinery/suit_cycler/proc/wires()
return wires.GetInteractWindow()
/obj/machinery/suit_cycler/Topic(href, href_list)
if(href_list["eject_suit"])
if(!suit) return
@@ -916,27 +901,6 @@
if(radiation_level > 1)
suit.clean_blood()
else if ((href_list["cutwire"]) && (src.panel_open))
var/twire = text2num(href_list["cutwire"])
if (!( istype(usr.get_active_hand(), /obj/item/weapon/wirecutters) ))
usr << "You need wirecutters!"
return
if (src.isWireColorCut(twire))
src.mend(twire)
else
src.cut(twire)
else if ((href_list["pulsewire"]) && (src.panel_open))
var/twire = text2num(href_list["pulsewire"])
if (!istype(usr.get_active_hand(), /obj/item/device/multitool))
usr << "You need a multitool!"
return
if (src.isWireColorCut(twire))
usr << "You can't pulse a cut wire."
return
else
src.pulse(twire)
src.updateUsrDialog()
return
@@ -1017,46 +981,6 @@
return
//HACKING PROCS, MOSTLY COPIED FROM VENDING MACHINES
/obj/machinery/suit_cycler/proc/isWireColorCut(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
return ((src.wires & wireFlag) == 0)
/obj/machinery/suit_cycler/proc/isWireCut(var/wireIndex)
var/wireFlag = APCIndexToFlag[wireIndex]
return ((src.wires & wireFlag) == 0)
/obj/machinery/suit_cycler/proc/cut(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
var/wireIndex = APCWireColorToIndex[wireColor]
src.wires &= ~wireFlag
switch(wireIndex)
if(WIRE_EXTEND)
safeties = 0
if(WIRE_SHOCK)
electrified = -1
if (WIRE_SCANID)
locked = 0
/obj/machinery/suit_cycler/proc/mend(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
var/wireIndex = APCWireColorToIndex[wireColor] //not used in this function
src.wires |= wireFlag
switch(wireIndex)
if(WIRE_SHOCK)
src.electrified = 0
/obj/machinery/suit_cycler/proc/pulse(var/wireColor)
var/wireIndex = APCWireColorToIndex[wireColor]
switch(wireIndex)
if(WIRE_EXTEND)
safeties = !locked
if(WIRE_SHOCK)
electrified = 30
if (WIRE_SCANID)
locked = !locked
//There HAS to be a less bloated way to do this. TODO: some kind of table/icon name coding? ~Z
/obj/machinery/suit_cycler/proc/apply_paintjob()
+23 -100
View File
@@ -56,12 +56,9 @@
var/shut_up = 1 //Stop spouting those godawful pitches!
var/extended_inventory = 0 //can we access the hidden inventory?
var/panel_open = 0 //Hacking that vending machine. Gonna get a free candy bar.
var/wires = 15
var/scan_id = 1
var/obj/item/weapon/coin/coin
var/const/WIRE_EXTEND = 1
var/const/WIRE_SCANID = 2
var/const/WIRE_SHOCK = 3
var/const/WIRE_SHOOTINV = 4
var/datum/wires/vending/wires = null
var/check_accounts = 0 // 1 = requires PIN and checks accounts. 0 = You slide an ID, it vends, SPACE COMMUNISM!
var/obj/item/weapon/spacecash/ewallet/ewallet
@@ -69,6 +66,7 @@
/obj/machinery/vending/New()
..()
wires = new(src)
spawn(4)
src.slogan_list = text2list(src.product_slogans, ";")
@@ -87,6 +85,14 @@
return
/obj/machinery/vending/Del()
del(wires) // qdel
wires = null
if(coin)
del(coin) // qdel
coin = null
..()
/obj/machinery/vending/ex_act(severity)
switch(severity)
if(1.0)
@@ -354,36 +360,19 @@
dat += "</TT>"
if(panel_open)
var/list/vendwires = list(
"Violet" = 1,
"Orange" = 2,
"Goldenrod" = 3,
"Green" = 4,
)
dat += "<br><hr><br><B>Access Panel</B><br>"
for(var/wiredesc in vendwires)
var/is_uncut = src.wires & APCWireColorToFlag[vendwires[wiredesc]]
dat += "[wiredesc] wire: "
if(!is_uncut)
dat += "<a href='?src=\ref[src];cutwire=[vendwires[wiredesc]]'>Mend</a>"
else
dat += "<a href='?src=\ref[src];cutwire=[vendwires[wiredesc]]'>Cut</a> "
dat += "<a href='?src=\ref[src];pulsewire=[vendwires[wiredesc]]'>Pulse</a> "
dat += "<br>"
dat += wires()
dat += "<br>"
dat += "The orange light is [(src.seconds_electrified == 0) ? "off" : "on"].<BR>"
dat += "The red light is [src.shoot_inventory ? "off" : "blinking"].<BR>"
dat += "The green light is [src.extended_inventory ? "on" : "off"].<BR>"
dat += "The [(src.wires & WIRE_SCANID) ? "purple" : "yellow"] light is on.<BR>"
if (product_slogans != "")
dat += "The speaker switch is [src.shut_up ? "off" : "on"]. <a href='?src=\ref[src];togglevoice=[1]'>Toggle</a>"
if(product_slogans != "")
dat += "The speaker switch is [shut_up ? "off" : "on"]. <a href='?src=\ref[src];togglevoice=[1]'>Toggle</a>"
user << browse(dat, "window=vending")
onclose(user, "")
return
// returns the wire panel text
/obj/machinery/vending/proc/wires()
return wires.GetInteractWindow()
/obj/machinery/vending/Topic(href, href_list)
if(stat & (BROKEN|NOPOWER))
return
@@ -425,9 +414,9 @@
usr << "\red The vending machine refuses to interface with you, as you are not in its target demographic!"
return
if ((!src.allowed(usr)) && (!src.emagged) && (src.wires & WIRE_SCANID)) //For SECURE VENDING MACHINES YEAH
usr << "\red Access denied." //Unless emagged of course
flick(src.icon_deny,src)
if((!allowed(usr)) && !emagged && scan_id) //For SECURE VENDING MACHINES YEAH
usr << "<span class='warning'>Access denied.</span>" //Unless emagged of course
flick(icon_deny,src)
return
var/idx=text2num(href_list["vend"])
@@ -458,27 +447,6 @@
src.updateUsrDialog()
return
else if ((href_list["cutwire"]) && (src.panel_open))
var/twire = text2num(href_list["cutwire"])
if (!( istype(usr.get_active_hand(), /obj/item/weapon/wirecutters) ))
usr << "You need wirecutters!"
return
if (src.isWireColorCut(twire))
src.mend(twire)
else
src.cut(twire)
else if ((href_list["pulsewire"]) && (src.panel_open))
var/twire = text2num(href_list["pulsewire"])
if (!istype(usr.get_active_hand(), /obj/item/device/multitool))
usr << "You need a multitool!"
return
if (src.isWireColorCut(twire))
usr << "You can't pulse a cut wire."
return
else
src.pulse(twire)
else if ((href_list["togglevoice"]) && (src.panel_open))
src.shut_up = !src.shut_up
@@ -490,8 +458,8 @@
return
/obj/machinery/vending/proc/vend(datum/data/vending_product/R, mob/user)
if ((!src.allowed(user)) && (!src.emagged) && (src.wires & WIRE_SCANID)) //For SECURE VENDING MACHINES YEAH
user << "\red Access denied." //Unless emagged of course
if((!allowed(usr)) && !emagged && scan_id) //For SECURE VENDING MACHINES YEAH
usr << "<span class='warning'>Access denied.</span>" //Unless emagged of course
flick(src.icon_deny,src)
return
src.vend_ready = 0 //One thing at a time!!
@@ -618,51 +586,6 @@
src.visible_message("\red <b>[src] launches [throw_item.name] at [target.name]!</b>")
return 1
/obj/machinery/vending/proc/isWireColorCut(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
return ((src.wires & wireFlag) == 0)
/obj/machinery/vending/proc/isWireCut(var/wireIndex)
var/wireFlag = APCIndexToFlag[wireIndex]
return ((src.wires & wireFlag) == 0)
/obj/machinery/vending/proc/cut(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
var/wireIndex = APCWireColorToIndex[wireColor]
src.wires &= ~wireFlag
switch(wireIndex)
if(WIRE_EXTEND)
src.extended_inventory = 0
if(WIRE_SHOCK)
src.seconds_electrified = -1
if (WIRE_SHOOTINV)
if(!src.shoot_inventory)
src.shoot_inventory = 1
/obj/machinery/vending/proc/mend(var/wireColor)
var/wireFlag = APCWireColorToFlag[wireColor]
var/wireIndex = APCWireColorToIndex[wireColor] //not used in this function
src.wires |= wireFlag
switch(wireIndex)
// if(WIRE_SCANID)
if(WIRE_SHOCK)
src.seconds_electrified = 0
if (WIRE_SHOOTINV)
src.shoot_inventory = 0
/obj/machinery/vending/proc/pulse(var/wireColor)
var/wireIndex = APCWireColorToIndex[wireColor]
switch(wireIndex)
if(WIRE_EXTEND)
src.extended_inventory = !src.extended_inventory
// if (WIRE_SCANID)
if (WIRE_SHOCK)
src.seconds_electrified = 30
if (WIRE_SHOOTINV)
src.shoot_inventory = !src.shoot_inventory
/*
* Vending machine types
*/
-25
View File
@@ -186,10 +186,6 @@ var/list/globalAirlockWireColorToFlag = RandomAirlockWires()
var/list/globalAirlockIndexToFlag
var/list/globalAirlockIndexToWireColor
var/list/globalAirlockWireColorToIndex
var/list/APCWireColorToFlag = RandomAPCWires()
var/list/APCIndexToFlag
var/list/APCIndexToWireColor
var/list/APCWireColorToIndex
var/list/BorgWireColorToFlag = RandomBorgWires()
var/list/BorgIndexToFlag
var/list/BorgIndexToWireColor
@@ -262,24 +258,3 @@ var/DBConnection/dbcon_old = new() //Tgstation database (Old database) - See the
//added for Xenoarchaeology, might be useful for other stuff
var/global/list/alphabet_uppercase = list("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")
// TODO: Replace
/proc/RandomAPCWires()
//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/apcwires = list(0, 0, 0, 0)
APCIndexToFlag = list(0, 0, 0, 0)
APCIndexToWireColor = list(0, 0, 0, 0)
APCWireColorToIndex = list(0, 0, 0, 0)
var/flagIndex = 1
for (var/flag=1, flag<16, flag+=flag)
var/valid = 0
while (!valid)
var/colorIndex = rand(1, 4)
if (apcwires[colorIndex]==0)
valid = 1
apcwires[colorIndex] = flag
APCIndexToFlag[flagIndex] = flag
APCIndexToWireColor[flagIndex] = colorIndex
APCWireColorToIndex[colorIndex] = flagIndex
flagIndex+=1
return apcwires