@name Rainbow Orbit
@persist Counter Theta TotalProps  OrbitHeight P Y R
@persist OrbitProps:array ProtectProps:array Targets:array
@persist ProtTarg:entity FaceTarg:entity OrbitTarg:entity
@persist FaceAngle:angle
##################################### JET WANG
#hint(string,time)
#By Jet Wang
##################### Set Interval
interval(10)
if(first()){
OrbitTarg=entity()
FaceTarg=entity()
ProtTarg=owner()
}
##################### Chat Controls

##################### Set Entity Discovery Restrictions
findIncludePlayerProps(owner())         #Make it only find your own props
findByClass("prop_physics")             #Find the props

##################### Sort Props As An Array
OrbitProps = findToArray()

##################### Array Totals
TotalOrbitProps = OrbitProps:count()
TotalProtectProps = ProtectProps:count()
TotalTargets = Targets:count()

##################### Counter For Cycling Through OrbitProps
Counter = (Counter+1)%OrbitProps:count()

##################### Colour OrbitProps
OrbitProps:entity(Counter+1):setColor(randint(255),randint(255),randint(255),(250))

##################### Make OrbitProps Orbit OrbitTarg
OrbitHeight = 400
Radius = 200 + (OrbitProps:entity(Counter+1):mass()*25)
Theta = Theta+2
Theta = mod(Theta,360)
B_Pos = OrbitTarg:pos() + vec(0,0,OrbitHeight)
B_Circle = vec(Radius*cos(Theta+((360/OrbitProps:count())*Counter)),Radius*sin(Theta+((360/OrbitProps:count())*Counter)),0)
B_Pos = B_Pos + B_Circle
B_Prop_Pos = B_Pos-OrbitProps:entity(Counter+1):pos()
B_Deriv_Pos = OrbitProps:entity(Counter+1):vel()
OrbitProps:entity(Counter+1):applyForce(((OrbitProps:entity(Counter+1):mass()/4)*(Radius/2))*B_Prop_Pos - 5*B_Deriv_Pos)

##################### Make OrbitProps Face FaceTarg
#FaceAngle = angnorm((entity():pos():toAngle()) - (OrbitProps:entity(Counter+1):angles()))
#OrbitProps:entity(Counter+1):applyAngForce(FaceAngle + $FaceAngle)
