@name Bionic Commando
@inputs 
@outputs 
@persist S1 S:string Targets:array  On
@persist Target:entity Gravity Run Players:array Play:array Kl
Time=15
interval(Time)
if(first()){Gravity=1/2 Run=15000}
O=owner()
#string table
Command="BC"
Menu = "menu"
Attack = "get" 
List = "list"
P1 = "1"
P2 = "2"
P3 = "3"
P4 = "4"
P5 = "5"
P6 = "6"
P7 = "7"
P8 = "8"
P9 = "9"
P10 = "0"
Breaker="<"
Suicide="destruct"
Gravy="G"
Run1="R"
S = " "
Slash="/"

Chat = O:lastSaid()
K = curtime() - O:lastSaidWhen() < (Time*2)/1000
if (K) {Once=1}
C=Chat:find(Command)
M = Chat:find(Menu)
A = Chat:find(Attack)
L = Chat:find(List)
C1 = Chat:find(P1)
C2 = Chat:find(P2)
C3 = Chat:find(P3)
C4 = Chat:find(P4)
C5 = Chat:find(P5)
C6 = Chat:find(P6)
C7 = Chat:find(P7)
C8 = Chat:find(P8)
C9 = Chat:find(P9)
C10 = Chat:find(P10)
Grav=Chat:find(Gravy)
Run2=Chat:find(Run1)
Sui=Chat:find(Suicide)
Slash1=Chat:find(Slash)
if(Sui){print("Self Destructing") selfDestruct()}


Origin=entity():owner():pos()
findInSphere(Origin,100000)
findSortByDistance(Origin)
findIncludeClass("player")
Play=findToArray()

if (C&K){
    if(Grav){
        if(!Slash1){GArray=Chat:explode(Gravy) 
            Gravity=GArray:string(2):toNumber()
            print("Personal Gravity set to: "+Gravity)
        }else{
            GArray=Chat:explode(Gravy)
            G1Array=GArray:string(2):explode(Slash)
            Gravity1=G1Array:string(1):toNumber()
            Gravity2=G1Array:string(2):toNumber()
            Gravity=Gravity1/Gravity2
            print("Personal Gravity set to: "+Gravity1+Slash+Gravity2+" Or "+Gravity)
        }
    }
    if(Run2){
        RArray=Chat:explode(Run1) Run=RArray:string(2):toNumber()
        print("Persinal Runspeed set to: "+Run) 
    }
    
    if (M){
        Players = Play:clone()
        Players:remove(1)
        Concat = array()
        if (Players:count()>0) {
            Concat:setString(0,Command)
            Concat:setString(1,"Targets: ")
            Concat:setString(2,P1+S)
            Concat:setString(3,Players:entity(1):name())
        }
        if (Players:count()>1) {
            Concat:setString(4,S+P2+S)
            Concat:setString(5,Players:entity(2):name())
        }
        if (Players:count()>2) {
            Concat:setString(6,S+P3+S)
            Concat:setString(7,Players:entity(3):name())
        }
        if (Players:count()>3) {
            Concat:setString(8,S+P4+S)
            Concat:setString(9,Players:entity(4):name())
        }
        if (Players:count()>4) {
            Concat:setString(10,S+P5+S)
            Concat:setString(11,Players:entity(5):name())
        }
        if (Players:count()>5) {
            Concat:setString(12,S+P6+S)
            Concat:setString(13,Players:entity(6):name())
        }
        if (Players:count()>6) {
            Concat:setString(14,S+P7+S)
            Concat:setString(15,Players:entity(7):name())
        }
        if (Players:count()>7) {
            Concat:setString(16,S+P8+S)
            Concat:setString(17,Players:entity(8):name())
        }
        if (Players:count()>8) {
            Concat:setString(18,S+P9+S)
            Concat:setString(19,Players:entity(9):name())
        }
        if (Players:count()>9) {
            Concat:setString(20,S+P10+S)
            Concat:setString(21,Players:entity(10):name())
        }
    }
    print(Command+Concat:concat())
}
if(A){
Targets = array()
E = 1
if (C1) {Targets:setEntity(E,Players:entity(1)) E+=1}
if (C2) {Targets:setEntity(E,Players:entity(2)) E+=1}
if (C3) {Targets:setEntity(E,Players:entity(3)) E+=1}
if (C4) {Targets:setEntity(E,Players:entity(4)) E+=1}
if (C5) {Targets:setEntity(E,Players:entity(5)) E+=1}
if (C6) {Targets:setEntity(E,Players:entity(6)) E+=1}
if (C7) {Targets:setEntity(E,Players:entity(7)) E+=1}
if (C8) {Targets:setEntity(E,Players:entity(8)) E+=1}
if (C9) {Targets:setEntity(E,Players:entity(9)) E+=1}
if (C10) {Targets:setEntity(E,Players:entity(10)) E+=1}
}
#TID = Targets:entity(N):id()
if (Targets:count()==0) {Error1 = Command+"No Targets Spesified"} else {Error1 = ""}
if (C& L & K) {print(Command+Targets:concat()+Error1)}

Count = Targets:count()
D1=D2=D3=D4=D5=D6=D7=D8=D9=D10=1000000
Dist = array()
if (Count>0) {D1 = Targets:entity(1):pos():distance(Origin)} 
if (Count>1) {D2 = Targets:entity(2):pos():distance(Origin)} 
if (Count>2) {D3 = Targets:entity(3):pos():distance(Origin)} 
if (Count>3) {D4 = Targets:entity(4):pos():distance(Origin)} 
if (Count>4) {D5 = Targets:entity(5):pos():distance(Origin)} 
if (Count>5) {D6 = Targets:entity(6):pos():distance(Origin)} 
if (Count>6) {D7 = Targets:entity(7):pos():distance(Origin)} 
if (Count>7) {D8 = Targets:entity(8):pos():distance(Origin)} 
if (Count>8) {D9 = Targets:entity(9):pos():distance(Origin)} 
if (Count>9) {D10 = Targets:entity(10):pos():distance(Origin)} 
Dist:setNumber(1,D1)
Dist:setNumber(2,D2)
Dist:setNumber(3,D3)
Dist:setNumber(4,D4)
Dist:setNumber(5,D5)
Dist:setNumber(6,D6)
Dist:setNumber(7,D7)
Dist:setNumber(8,D8)
Dist:setNumber(9,D9)
Dist:setNumber(10,D10)
K1=Dist:minIndex()
T1=Targets:entity(K1)



#Personal gravity
setGravity(Gravity)
#Personal Runspeed
setRunSpeed(Run)


#Player Turret
Co=Chat:find("hunt")
Off=Chat:find("stop")
Self=entity():owner()
if(C&K){
if(Co){ On=1}
if(Off|!Targets:count()){On=0}
}
Target=T1
#if((Target:health()<=0)&(Target:isNPC()|Target:isPlayer())){
#Targets:remove(K1) Target=T1}

if(Target:isNPC()|Target:isPlayer()){Offset=vec(0,0,Target:height()*1/2)}
Ang=(Target:pos()-Self:shootPos()+Offset):toAngle()

if(On){Self:setEyeAngle(Ang)

Target=entity():owner():aimEntity()
if(Self:isAlive()){
if(Target:isAlive()&!S1) {S1=1 concmd("+attack") Kl=1} }}
if(!Target:isAlive()&S1&Kl){S1=0 concmd("-attack") Kl=0}

#End Player Turret Code
