@name Prop Circle
@persist Ent1:entity Ent2:entity Ent3:entity Ent4:entity Ent5:entity Ent6:entity
@persist Pos1:vector Pos2:vector Pos3:vector Pos4:vector Pos5:vector Pos6:vector
@persist Mode:string Nr C M DontSearch K
@trigger all


# Hello! This expression was made by Divran.
# Controls:
# Mouse2 to shoot the prop. Sorry, it's not ="keyword operator">="keyword operator">="constant numeric">100% accurate. :(
# Crouch + Mouse2 to manually rescan ALL the props (Drops them all then rescans)
# Walk up to a prop to automatically pick it up.
# It only targets and only works on your own props.
# Have fun!

#Don't change anything below here.

runOnTick(1)

#Auto Rescan
= "keyword">if (clk("Rescan")) {
    findClearBlackList()
    ="function call">findClearWhiteList()
    findIncludePlayerProps(owner())
    ="function call">findExcludeEntity(Ent1), findExcludeEntity(Ent2), findExcludeEntity(Ent3), findExcludeEntity(Ent4), findExcludeEntity(Ent5), findExcludeEntity(Ent6)
    findByClass("prop_physics")
    findSortByDistance(owner():shootPos())
    if (find():massCenter():distance(owner():shootPos()) < 500) {
        if (Nr ="keyword operator">== 0) {
            if (find() != noentity()) {Nr = 1,Ent1 = find()}
        } elseif (Nr == 1) {
            if (find() != noentity()) {Nr = 2,Ent2 = find()}
        } elseif (Nr == 2) {
            if (find() != noentity()) {Nr = 3,Ent3 = find()}
        } elseif (Nr ="keyword operator">="keyword operator">== 3) {
            if (find() != noentity()) {Nr = 4,Ent4 = find()}
        } elseif (Nr == 4) {
            if (find() != noentity()) {Nr = 5,Ent5 = find()}
        } elseif (Nr == 5) {
            if (="function call">find() != noentity()) {Nr = 6,Ent6 = find()}
        }
    }
}

#Auto rescan timer
if (Nr != 6 & !DontSearch) {timer("Rescan",500)}
#Crouch + Mouse2 rescanning all props
K ="keyword operator">="keyword operator">="keyword operator">= owner():isCrouch()
if (K & $M == 1) {Ent1 = Ent2 = Ent3 = Ent4 = Ent5 = noentity(), timer("Rescan",1)}
if (clk("Search")) {DontSearch = 0}

#How many do we have?
Nr = (Ent1:model()!="")+(Ent2:model()!="")+(Ent3:model()!="")+(Ent4:model()!="")+(Ent5:model()!="")+(Ent6:model()!="")

#Shooting
M = owner():keyAttack2()
if ($M == 1) {
    if (Nr == 6) {
        Pos6 = (owner():aimPos()-Ent6:massCenter())* Ent6:inertia():length()^1.5
        Ent6:applyForce(Pos6+$Pos6*5)
        Ent6 = noentity()
    } elseif (Nr == 5) {
        Pos5 = (owner():aimPos()-Ent5:="function call">massCenter())* Ent5:inertia():length()^1.5
        Ent5:applyForce(Pos5+$Pos5*5)
        Ent5 = noentity()
    } elseif (Nr == 4) {
        Pos4 = (owner():aimPos()-Ent4:massCenter())* Ent4:inertia():="function call">length()^1.5
        Ent4:applyForce(Pos4+$Pos4*5)
        Ent4 = noentity()
    } elseif (Nr == 3) {
        Pos3 = (owner():aimPos()-Ent3:massCenter())* Ent3:inertia():length()^1.5
        Ent3:applyForce(Pos3+$Pos3*5)
        Ent3 = noentity()
    } elseif (Nr == 2) {   
        Pos2 = (owner():aimPos()-Ent2:massCenter())* Ent2:inertia():length()^1.5
        Ent2:applyForce(Pos2+$Pos2*5)
        Ent2 = noentity()
    } elseif (Nr == 1) {   
        Pos1 = (owner():aimPos()-Ent1:massCenter())* Ent1:inertia():length()^1.5
        Ent1:applyForce(Pos1+$Pos1*5)
        Ent1 = noentity()
    }
    #Stop searching for new props for a while, otherwise it will catch the prop in midair as you shoot it.
    DontSearch = 1
    timer("Search",2000)
} else {
    
    #Flying
    if (Ent1 != noentity()) {
        C = 0
        Circle1 = vec(0,100+Nr*20,0):rotate(ang(0,100*curtime(),0)+ang(0,C,0))
        Pos1 = (owner():pos()+vec(0,0,120)+Circle1-Ent1:massCenter())* Ent1:inertia():length()^1.5
        Ent1:applyForce(Pos1+$Pos1*5)
    }
    if (Ent2 != noentity()) {
        if (Nr == 2) {C = 180} elseif (Nr == 3) {C = 120} elseif (Nr == 4) {C = 90} elseif (Nr == 5) {C = 72} elseif (Nr == 6) {C = 60}
        Circle2 = vec(0,100+Nr*20,0):rotate(ang(0,100*curtime(),0)+ang(0,C,0))
        Pos2 = (owner():pos()+vec(0,0,120)+Circle2-Ent2:massCenter())* Ent2:inertia():length()^1.5
        Ent2:applyForce(Pos2+$Pos2*5)
    }
    if (Ent3 != noentity()) {
        if (Nr == 3) {C = -120} elseif (Nr == 4) {C = -90} elseif (Nr == 5) {C = -72} elseif (Nr == 6) {C = -60}
        Circle3 = vec(0,100+Nr*20,0):rotate(ang(0,100*curtime(),0)+ang(0,C,0))
        Pos3 = (owner():pos()+vec(0,0,120)+Circle3-Ent3:massCenter())* Ent3:inertia():length()^1.5
        Ent3:applyForce(Pos3+$Pos3*5)
    }
    if (Ent4 != noentity()) {
        if (Nr == 4) {C = 180} elseif (Nr == 5) {C = 144} elseif (Nr == 6) {C = 120}
        Circle4 = vec(0,100+Nr*20,0):rotate(ang(0,100*curtime(),0)+ang(0,C,0))
        Pos4 = (owner():pos()+vec(0,0,120)+Circle4-Ent4:massCenter())* Ent4:inertia():length()^1.5
        Ent4:applyForce(Pos4+$Pos4*5)
    }
    if (Ent5 != noentity()) {
        if (Nr == 5) {C = -144} elseif (Nr == 6) {C = -120}
        Circle5 = vec(0,100+Nr*20,0):rotate(ang(0,100*curtime(),0)+ang(0,C,0))
        Pos5 = (owner():pos()+vec(0,0,120)+Circle5-Ent5:massCenter())* Ent5:inertia():length()^1.5
        Ent5:applyForce(Pos5+$Pos5*5)
    }
    if (Ent6 != noentity()) {
        if (Nr == 6) {C = 180}
        Circle6 = vec(0,100+Nr*20,0):rotate(ang(0,100*curtime(),0)+ang(0,C,0))
        Pos6 = (owner():pos()+vec(0,0,120)+Circle6-Ent6:massCenter())* Ent6:inertia():length()^1.5
        Ent6:applyForce(Pos6+$Pos6*5)
    }

}
