@name Zap Sat Controller
@inputs On ID1 ID2 ID3 F1 F2 F3 Reset Packed EntID
#@inputs R H Step
@outputs S1:vector S2:vector S3:vector T1F T2F T3F 
@outputs T1N T2N T3N C1a C2a C3a
@persist Sat1 Sat2 Sat3 Setup T1:entity T2:entity T3:entity 
@persist C1:vector C2:vector C3:vector C1a C2a C3a
if (!Setup) {Sat1 = 0 Sat2 = 120 Sat3 = 240 Setup = 1
Target = "turret"
findInSphere(entity():pos(),100)
findSortByDistance(entity():pos())
findClipToClass(Target)
T1 = findResult(1)
T2 = findResult(2)
T3 = findResult(3)
#T1:setColor(255,0,0)
#T2:setColor(0,255,0)
#T3:setColor(0,0,255)
C1 = T1:getColor()
C2 = T2:getColor()
C3 = T3:getColor()
if 
(C1:x()==255) {C1a = 1}
if
(C1:y()==255) {C1a = 2} 
if
(C1:z()==255) {C1a = 3}

if 
(C2:x()==255) {C2a = 1} 
if
(C2:y()==255) {C2a = 2} 
if
(C2:z()==255) {C2a = 3}

if 
(C3:x()==255) {C3a = 1} 
if
(C3:y()==255) {C3a = 2} 
if
(C3:z()==255) {C3a = 3}

entity():setColor(255,255,0)
T1N = T1:id()
T2N = T2:id()
T3N = T3:id()
}
if (Reset) {Setup = 0}
if (On) {
interval(20)

Self = entity(EntID):pos()


if (!Packed) {
Step = 3
R = 60
H = 110} else 
{Step = 3
R = 15
H = 80}
S1 = vec(Self:x() + R * cos(Sat1),Self:y() + R * sin(Sat1),Self:z() + H)
S2 = vec(Self:x() + R * cos(Sat2),Self:y() + R * sin(Sat2),Self:z() + H)
S3 = vec(Self:x() + R * cos(Sat3),Self:y() + R * sin(Sat3),Self:z() + H)


Sat1 += Step
Sat2 += Step
Sat3 += Step
O1 = 0 + 359
O2 = 120 + 359
O3 = 240 + 359
if (Sat1>O1) {Sat1 = 0}
if (Sat1>O2) {Sat1 = 120}
if (Sat1>O3) {Sat1 = 240}
}
if (C1a==1 & On) {T1F = F1} elseif
   (C1a==2 & On) {T1F = F2} elseif
   (C1a==3 & On) {T1F = F3} else {T1F = 0}

if (C2a==1 & On) {T2F = F1} elseif
   (C2a==2 & On) {T2F = F2} elseif
   (C2a==3 & On) {T2F = F3} else {T2F = 0}

if (C3a==1 & On) {T3F = F1} elseif
   (C3a==2 & On) {T3F = F2} elseif
   (C3a==3 & On) {T3F = F3} else {T3F = 0}
