Adds ability to have airlock wires randomized

Adds a secured_wires var to airlocks that may be set through mapping. If
not set to 0, the airlock's wires will be randomized for that airlock,
instead of using the global wiring scheme.
This commit is contained in:
mwerezak
2014-05-30 19:05:57 -04:00
parent 3ea17cefaf
commit 3a59ee0899
2 changed files with 37 additions and 8 deletions

View File

@@ -32,11 +32,19 @@
//This generates the randomized airlock wire assignments for the game. //This generates the randomized airlock wire assignments for the game.
/proc/RandomAirlockWires() /proc/RandomAirlockWires()
var/list/wire_assignments = CreateRandomAirlockWires()
globalAirlockIndexToFlag = wire_assignments[2]
globalAirlockIndexToWireColor = wire_assignments[3]
globalAirlockWireColorToIndex = wire_assignments[4]
return wire_assignments[1]
/proc/CreateRandomAirlockWires()
//to make this not randomize the wires, just set index to 1 and increment it in the flag for loop (after doing everything else). //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/wires = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) var/list/wires = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
airlockIndexToFlag = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) var/airlockIndexToFlag = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
airlockIndexToWireColor = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) var/airlockIndexToWireColor = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
airlockWireColorToIndex = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) var/airlockWireColorToIndex = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
var/flagIndex = 1 var/flagIndex = 1
for (var/flag=1, flag<4096, flag+=flag) for (var/flag=1, flag<4096, flag+=flag)
var/valid = 0 var/valid = 0
@@ -54,7 +62,7 @@
airlockWireColorToIndex[colorIndex] = flagIndex airlockWireColorToIndex[colorIndex] = flagIndex
colorList -= colorIndex colorList -= colorIndex
flagIndex+=1 flagIndex+=1
return wires return list(wires, airlockIndexToFlag, airlockIndexToWireColor, airlockWireColorToIndex)
/* Example: /* Example:
Airlock wires color -> flag are { 64, 128, 256, 2, 16, 4, 8, 32, 1 }. Airlock wires color -> flag are { 64, 128, 256, 2, 16, 4, 8, 32, 1 }.
@@ -93,6 +101,11 @@ Airlock index -> wire color are { 9, 4, 6, 7, 5, 8, 1, 2, 3 }.
normalspeed = 1 normalspeed = 1
var/obj/item/weapon/airlock_electronics/electronics = null var/obj/item/weapon/airlock_electronics/electronics = null
var/hasShocked = 0 //Prevents multiple shocks from happening var/hasShocked = 0 //Prevents multiple shocks from happening
var/secured_wires = 0 //for mapping use
var/list/airlockIndexToFlag
var/list/airlockWireColorToFlag
var/list/airlockIndexToWireColor
var/list/airlockWireColorToIndex
/obj/machinery/door/airlock/command /obj/machinery/door/airlock/command
name = "Airlock" name = "Airlock"
@@ -1319,6 +1332,22 @@ About the new airlock wires panel:
/obj/machinery/door/airlock/New() /obj/machinery/door/airlock/New()
..() ..()
//wires
if (!secured_wires)
airlockWireColorToFlag = globalAirlockWireColorToFlag
airlockIndexToFlag = globalAirlockIndexToFlag
airlockIndexToWireColor = globalAirlockIndexToWireColor
airlockWireColorToIndex = globalAirlockWireColorToIndex
else
var/wire_assignments = CreateRandomAirlockWires()
airlockWireColorToFlag = wire_assignments[1]
airlockIndexToFlag = wire_assignments[2]
airlockIndexToWireColor = wire_assignments[3]
airlockWireColorToIndex = wire_assignments[4]
/proc/CreateRandomAirlockWires()
if(src.closeOtherId != null) if(src.closeOtherId != null)
spawn (5) spawn (5)
for (var/obj/machinery/door/airlock/A in world) for (var/obj/machinery/door/airlock/A in world)

View File

@@ -176,10 +176,10 @@ var/datum/nanomanager/nanomanager = new()
//airlockWireColorToIndex takes a number representing the wire color, e.g. the orange wire is always 1, the dark red wire is always 2, etc. It returns the index for whatever that wire does. //airlockWireColorToIndex takes a number representing the wire color, e.g. the orange wire is always 1, the dark red wire is always 2, etc. It returns the index for whatever that wire does.
//airlockIndexToWireColor does the opposite thing - it takes the index for what the wire does, for example AIRLOCK_WIRE_IDSCAN is 1, AIRLOCK_WIRE_POWER1 is 2, etc. It returns the wire color number. //airlockIndexToWireColor does the opposite thing - it takes the index for what the wire does, for example AIRLOCK_WIRE_IDSCAN is 1, AIRLOCK_WIRE_POWER1 is 2, etc. It returns the wire color number.
//airlockWireColorToFlag takes the wire color number and returns the flag for it (1, 2, 4, 8, 16, etc) //airlockWireColorToFlag takes the wire color number and returns the flag for it (1, 2, 4, 8, 16, etc)
var/list/airlockWireColorToFlag = RandomAirlockWires() var/list/globalAirlockWireColorToFlag = RandomAirlockWires()
var/list/airlockIndexToFlag var/list/globalAirlockIndexToFlag
var/list/airlockIndexToWireColor var/list/globalAirlockIndexToWireColor
var/list/airlockWireColorToIndex var/list/globalAirlockWireColorToIndex
var/list/APCWireColorToFlag = RandomAPCWires() var/list/APCWireColorToFlag = RandomAPCWires()
var/list/APCIndexToFlag var/list/APCIndexToFlag
var/list/APCIndexToWireColor var/list/APCIndexToWireColor