@name Bot
@inputs
@outputs P Yaw R Stab A NEnt:vector
@persist Upper LPO:vector Spin Active Height OthEnt

interval(10)

Ent = entity():isWeldedTo()
P=Ent:angles():pitch()
Yaw=Ent:angles():yaw()
R=Ent:angles():roll()
Arr = owner():lastSaid():explode(" ")
Arr1 = Arr:string(2)
Arr2 = Arr:string(3)
Arr3 = Arr:string(4)
Arr4 = Arr:string(5)
Arr5 = Arr:string(6)
Arr6 = Arr:string(7)
Arr7 = Arr:string(8)
Arr8 = Arr:string(9)
Arr9 = Arr:string(10)
if (!owner():keyAttack2()&!OthEnt) {
NEnt = owner():shootPos()
}
if (first()&!Active) {
    Upper = 1
    Height = 100
}
if (owner():lastSaid()=="!to me") {
    Upper = 1
}
if (Upper&!Active) {
    
    LPO = NEnt - Ent:pos() + vec(0,0,Height)
    Xo=($LPO:x()*10)+(LPO:x()*2)
    Yo=($LPO:y()*10)+(LPO:y()*2)
    Zo=($LPO:z()*10)+(LPO:z()*2)
    
    Ent:applyForce( vec(Xo,Yo,Zo)*Ent:mass() )
}
if (owner():lastSaid()=="!stab on") {
    Stab = 1
}
if (owner():lastSaid()=="!stab off") {
    Stab = 0
}
if (Stab&!Active) {
    Ent:applyAngForce( -ang( ($P*10)+(P*2),0,0 )*Ent:mass()*10 )
    Ent:applyAngForce( -ang(0,0,($R*10)+(R*2) )*Ent:mass()*10 )
    if (!Spin) {
        Ent:applyAngForce( -ang(0,($Yaw*10)+(Yaw*2),0 )*Ent:mass()*10 )
    }        
}
if (owner():lastSaid():find("!spin")) {
    Spin = 1
    SpinSpeed = owner():lastSaid():explode(" "):string(2):toNumber()
}
if (owner():lastSaid()=="!stopspin") {
    Spin = 0
}
if (Spin&!Active) {
    applyAngForce( ang(0,SpinSpeed,0) )
}
if (owner():lastSaid()=="!bot off") {
    Active = 1
}
if (owner():lastSaid()=="!bot on") {
    Active = 0
}
if (owner():lastSaid():find("!height ")) {
    Height = owner():lastSaid():explode(" "):string(2):toNumber()
}
if (Upper&!Active&owner():weapon():model():find("v_crowbar.mdl")&owner():keyAttack2()) {
    NEnt = owner():aimPos()-vec(0,0,Height)
}
if (owner():lastSaid():find("!weight ")) {
    Ent:setMass(Arr1:toNumber())
}
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
