Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Force Circle
- @outputs Count Run Radius
- @persist Props:array
- runOnTick(1)
- if (Run) {
- Owner=owner()
- if (findCanQuery()) {
- findIncludePlayerProps(Owner) #The functions only work on the owner's props, so we only use them on the owner's props
- findByModel("models/props_junk/PopCan01a.mdl") #Pick a model
- Props=findToArray() #Save what we found
- Count=Props:count() #How many entities we found
- }
- if (tickClk()) { #Set stuff up first to use less ops
- Cur=curtime() #Just an easy way of getting an incrementing value
- Radius=max(Count*50/pi()/2,100) #Creates a radius with atleast 50 units between each prop
- #Pos=mix(Owner:pos(),Owner:shootPos(),(sin(Cur*45)+1)/2) #Moves the center position from the feet of the owner to the head and back
- Pos=entity():pos() #A sun
- Orbit1=vec(Radius/3,0,10):rotate(0,Cur*90,0) #A planet orbitting the sun
- Index=0
- while (Index<Count) {
- Index++,TE=Props[Index,entity] #TE=Target Entity, yay less ops
- Orbit2=vec(Radius,0,10):rotate(0,-(360/Count*Index + Cur*45),0) #Moons orbitting the planet
- TE:applyForce(((Pos+Orbit1+Orbit2-TE:massCenter())*10-TE:vel())*TE:mass()) #Standard formula
- TE:setColor(randint(128,255),randint(128,255),randint(128,255)) #Pretty colors
- }
- }
- if ($Count>0) {timer("trail",2000)} #If the amount of props has increased then set new trails
- if (clk("trail")) {
- Color=vec(255,255,255) #
- foreach (Index,Prop:entity=Props) {
- Prop:setTrails(100,0,1,"trails/physbeam",Color,255)
- }
- }
- }
- Run=(minquota()>100) #If there aren't more than 100 ops left, then the above code block will be skipped the next execution to prevent a shutdown
Add Comment
Please, Sign In to add comment