@name BFG 9001
@inputs [Boom1 Boom2 Boom3 Boom4 Boom5 Boom6 Boom7 Boom8 Boom9 Boom0]:wirelink
@outputs [Pos Pos1 Ang]:vector 
@persist Flight Scan Step UseC Pos:vector Hurt Ouch Sight:array
@trigger 

interval(15)
O=owner()

if(first()){Scan=1}

function array snapshot(){
    findInCone(O:pos(),O:eye(),10000,45)
    findIncludeClass("player")
    findIncludeClass("npc")
    return findToArray()
}
function entity:movepos(XYZ:vector){
    Bomb=This
   Speed=100*(Bomb:mass()/3)
    Bomb:applyForce(Speed*(XYZ-Bomb:pos())-Bomb:vel()*Bomb:mass()) 
    
}


timer("delay",5)

if(O:weapon():type():find("physcannon")&clk("delay")){
    UseC=changed(O:keyUse())
    if(O:keyUse()&UseC&!holoEntity(1)){
        Ang=O:eye()
        Pos1=O:shootPos()+Ang*20
        
        Flight=1
        Step=10
        #print(Ang)
        holoCreate(1,Pos1)
        holoMaterial(1,"models/Alyx/emptool_glow")
        holoColor(1,vec(0,255,0))
        holoModel(1,"models/Combine_Helicopter/helicopter_bomb01.mdl")
        #holoCreate(2,Pos1)
        #Ranger=rangerOffset(10000,Pos1,Ang)
        Scan=0
        
        
    }
}
if(!Scan&clk("delay")){
 
    
    Pos=Pos1+Ang*Flight*Step
    
    holoPos(1,Pos)
    Probe=rangerOffset(10,Pos,Ang)
    Scan=Probe:hit()
    #print(Scan:distance())
    #print(round(Pos))
    if(Scan){
        
        if(Probe:entity()){Probe:entity():takeDamage(100)}
        Sight=snapshot()
        Hurt=1
        Ouch=1
        holoDelete(1)
        print("I hit something!")
    }
    Flight++
 
    
}
if(Hurt){
    while(Ouch<=Sight:count()&perf()){
        Sight[Ouch,entity]:takeDamage(randint(50,120))
        Ouch++
    }
    if(Ouch>Sight:count()){Hurt=0}
}

