@name Explosive Multi Puck Controller
@inputs On T:entity Target Timer Active Alive
@outputs Mode Launch Ents DataS PulseRate Timer Alive2 Target Count
@persist Tog Active Explode Zenith1 Kill PeakTimer Regen Count
interval(20)
Tog = !Tog
if (Tog) {Offset = 0.1} else {Offset = 0.2}
Mode = 1
PulseRate = 1
TargID = T:id()
BaseID = entity():id()

Alive1 = entity(Alive):mass()
if (Alive1!=1) {Alive2 = 0} else {Alive2 = 1}
#if (InRange) {Kill = 0 Zenith1 = 1}
R1 = Regen==3
Ready = Regen==3 & ~Regen
R = ~Regen
if (Count > 0 | !Target) {Stop = 0} else {Stop = 1}
if (!Alive2) {Count = 0}
if (Regen==3 & Timer & Target & Stop) {Launch = 1 Count += 1} else {Launch = 0}

Regen += Timer
if (Regen==4) {Regen = 0}

if (Count!=0 & !Target) {Explode = 1}

DataS = 0
DataS += (Active ? 1 : 0) * 2^0
DataS += (Explode ? 1 : 0) * 2^1
DataS += (Zenith1 ? 1 : 0) * 2^2
DataS += (Kill ? 1 : 0) * 2^3
DataS += Offset


B1 = floor(BaseID / 2^0) % 2
B2 = floor(BaseID / 2^1) % 2
B3 = floor(BaseID / 2^2) % 2
B4 = floor(BaseID / 2^3) % 2
B5 = floor(BaseID / 2^4) % 2
B6 = floor(BaseID / 2^5) % 2
B7 = floor(BaseID / 2^6) % 2
B8 = floor(BaseID / 2^7) % 2
B9 = floor(BaseID / 2^8) % 2

B10 = floor(TargID / 2^0) % 2
B11 = floor(TargID / 2^1) % 2
B12 = floor(TargID / 2^2) % 2
B13 = floor(TargID / 2^3) % 2
B14 = floor(TargID / 2^4) % 2
B15 = floor(TargID / 2^5) % 2
B16 = floor(TargID / 2^6) % 2
B17 = floor(TargID / 2^7) % 2
B18 = floor(TargID / 2^8) % 2

Ents = 0
Ents += (B1 ? 1 : 0) * 2^0
Ents += (B2 ? 1 : 0) * 2^1
Ents += (B3 ? 1 : 0) * 2^2
Ents += (B4 ? 1 : 0) * 2^3
Ents += (B5 ? 1 : 0) * 2^4
Ents += (B6 ? 1 : 0) * 2^5
Ents += (B7 ? 1 : 0) * 2^6
Ents += (B8 ? 1 : 0) * 2^7
Ents += (B9 ? 1 : 0) * 2^8
Ents += (B10 ? 1 : 0) * 2^9
Ents += (B11 ? 1 : 0) * 2^10
Ents += (B12 ? 1 : 0) * 2^11
Ents += (B13 ? 1 : 0) * 2^12
Ents += (B14 ? 1 : 0) * 2^13
Ents += (B15 ? 1 : 0) * 2^14
Ents += (B16 ? 1 : 0) * 2^15
Ents += (B17 ? 1 : 0) * 2^16
Ents += (B18 ? 1 : 0) * 2^17
Ents += Offset
