@name E2 Minigun Vehicles
@inputs GC:entity
@outputs Fire
@persist I Milliseconds Turret O:entity Ang [E T]:entity Array:array Ac P F
interval(20)
if(first())
{
    entity():setColor(0,0,0,0)
    
    holoCreate(13)
    holoPos(13,entity():toWorld(vec(-6,0,0)))
    holoParent(13,entity())
    ###spin###
    holoCreate(1)
    holoModel(1,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(1,entity():toWorld(vec(-5,0,0)))
    holoAng(1,entity():toWorld(ang(90,0,0)))
    holoScale(1,vec(1,1,1.3))
    holoMaterial(1,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(1,vec(50,50,50))
    holoParent(1,13)
    ###spin###
    ###barrels###
    holoCreate(2)
    holoModel(2,"models/Holograms/hq_tube.mdl")
    holoPos(2,entity():toWorld(vec(25,0,4)))
    holoAng(2,entity():toWorld(ang(90,0,0)))
    holoScale(2,vec(0.2,0.2,4))
    holoMaterial(2,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(2,vec(50,50,50))
    holoParent(2,1)
    
    holoCreate(3)
    holoModel(3,"models/Holograms/hq_tube.mdl")
    holoPos(3,entity():toWorld(vec(25,3.5,2)))
    holoAng(3,entity():toWorld(ang(90,0,0)))
    holoScale(3,vec(0.2,0.2,4))
    holoMaterial(3,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(3,vec(50,50,50))
    holoParent(3,1)
    
    holoCreate(4)
    holoModel(4,"models/Holograms/hq_tube.mdl")
    holoPos(4,entity():toWorld(vec(25,3.5,-2)))
    holoAng(4,entity():toWorld(ang(90,0,0)))
    holoScale(4,vec(0.2,0.2,4))
    holoMaterial(4,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(4,vec(50,50,50))
    holoParent(4,1)
    
    holoCreate(5)
    holoModel(5,"models/Holograms/hq_tube.mdl")
    holoPos(5,entity():toWorld(vec(25,0,-4)))
    holoAng(5,entity():toWorld(ang(90,0,0)))
    holoScale(5,vec(0.2,0.2,4))
    holoMaterial(5,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(5,vec(50,50,50))
    holoParent(5,1)
    
    holoCreate(6)
    holoModel(6,"models/Holograms/hq_tube.mdl")
    holoPos(6,entity():toWorld(vec(25,-3.5,2)))
    holoAng(6,entity():toWorld(ang(90,0,0)))
    holoScale(6,vec(0.2,0.2,4))
    holoMaterial(6,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(6,vec(50,50,50))
    holoParent(6,1)
    
    holoCreate(7)
    holoModel(7,"models/Holograms/hq_tube.mdl")
    holoPos(7,entity():toWorld(vec(25,-3.5,-2)))
    holoAng(7,entity():toWorld(ang(90,0,0)))
    holoScale(7,vec(0.2,0.2,4))
    holoMaterial(7,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(7,vec(50,50,50))
    holoParent(7,1)
    
    holoCreate(8)
    holoModel(8,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(8,entity():toWorld(vec(25,0,0)))
    holoAng(8,entity():toWorld(ang(90,0,0)))
    holoScale(8,vec(1,1,0.5))
    holoMaterial(8,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(8,vec(50,50,50))
    holoParent(8,1)
    
    holoCreate(9)
    holoModel(9,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(9,entity():toWorld(vec(47,0,0)))
    holoAng(9,entity():toWorld(ang(90,0,0)))
    holoScale(9,vec(1,1,0.1))
    holoMaterial(9,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(9,vec(50,50,50))
    holoParent(9,1)
    
    holoCreate(10)
    holoModel(10,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(10,entity():toWorld(vec(42,0,0)))
    holoAng(10,entity():toWorld(ang(90,0,0)))
    holoScale(10,vec(1,1,0.1))
    holoMaterial(10,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(10,vec(50,50,50))
    holoParent(10,1)
    
    holoCreate(11)
    holoModel(11,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(11,entity():toWorld(vec(37,0,0)))
    holoAng(11,entity():toWorld(ang(90,0,0)))
    holoScale(11,vec(1,1,0.1))
    holoMaterial(11,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(11,vec(50,50,50))
    holoParent(11,1)
    
    holoCreate(12)
    holoModel(12,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(12,entity():toWorld(vec(-8,9,-5)))
    holoAng(12,entity():toWorld(ang(90,0,0)))
    holoScale(12,vec(0.7,0.7,1))
    holoMaterial(12,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(12,vec(50,50,50))
    holoParent(12,13)
    
    holoColor(13,vec4(0,0,0,0))
    
    holoCreate(14)
    holoModel(14,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(14,entity():toWorld(vec(-5,9,-5)))
    holoAng(14,entity():toWorld(ang(90,0,0)))
    holoScale(14,vec(0.5,0.5,1))
    holoMaterial(14,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(14,vec(50,50,50))
    holoParent(14,13)
    
    holoCreate(15)
    holoModel(15,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(15,entity():toWorld(vec(-8,-9,-5)))
    holoAng(15,entity():toWorld(ang(90,0,0)))
    holoScale(15,vec(0.7,0.7,1))
    holoMaterial(15,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(15,vec(50,50,50))
    holoParent(15,13)
    
    holoCreate(16)
    holoModel(16,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(16,entity():toWorld(vec(-5,-9,-5)))
    holoAng(16,entity():toWorld(ang(90,0,0)))
    holoScale(16,vec(0.5,0.5,1))
    holoMaterial(16,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(16,vec(50,50,50))
    holoParent(16,13)
    
    holoCreate(17)
    holoModel(17,"models/Holograms/hq_rcube.mdl")
    holoPos(17,entity():toWorld(vec(-5,-4,0)))
    holoAng(17,entity():toWorld(ang(45,90,0)))
    holoScale(17,vec(0.2,0.2,1))
    holoMaterial(17,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(17,vec(50,50,50))
    holoParent(17,13)
    
    holoCreate(18)
    holoModel(18,"models/Holograms/hq_rcube.mdl")
    holoPos(18,entity():toWorld(vec(-5,4,0)))
    holoAng(18,entity():toWorld(ang(-45,90,0)))
    holoScale(18,vec(0.2,0.2,1))
    holoMaterial(18,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(18,vec(50,50,50))
    holoParent(18,13)
    
    holoCreate(19)
    holoModel(19,"models/Holograms/hq_rcube.mdl")
    holoPos(19,entity():toWorld(vec(-10,-4,0)))
    holoAng(19,entity():toWorld(ang(45,90,0)))
    holoScale(19,vec(0.2,0.2,1))
    holoMaterial(19,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(19,vec(50,50,50))
    holoParent(19,13)
    
    holoCreate(20)
    holoModel(20,"models/Holograms/hq_rcube.mdl")
    holoPos(20,entity():toWorld(vec(-10,4,0)))
    holoAng(20,entity():toWorld(ang(-45,90,0)))
    holoScale(20,vec(0.2,0.2,1))
    holoMaterial(20,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(20,vec(50,50,50))
    holoParent(20,13)
    
    holoCreate(21)
    holoModel(21,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(21,entity():toWorld(vec(-3,-9,-5)))
    holoAng(21,entity():toWorld(ang(90,0,0)))
    holoScale(21,vec(0.72,0.72,0.07))
    holoMaterial(21,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(21,vec(150,150,150))
    holoParent(21,13)
    
    holoCreate(22)
    holoModel(22,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(22,entity():toWorld(vec(-14,-9,-5)))
    holoAng(22,entity():toWorld(ang(90,0,0)))
    holoScale(22,vec(0.72,0.72,0.07))
    holoMaterial(22,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(22,vec(150,150,150))
    holoParent(22,13)
    
    holoCreate(23)
    holoModel(23,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(23,entity():toWorld(vec(-3,9,-5)))
    holoAng(23,entity():toWorld(ang(90,0,0)))
    holoScale(23,vec(0.72,0.72,0.07))
    holoMaterial(23,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(23,vec(150,150,150))
    holoParent(23,13)
    
    holoCreate(24)
    holoModel(24,"models/Holograms/hq_rcylinder_thin.mdl")
    holoPos(24,entity():toWorld(vec(-14,9,-5)))
    holoAng(24,entity():toWorld(ang(90,0,0)))
    holoScale(24,vec(0.72,0.72,0.07))
    holoMaterial(24,"phoenix_storms/mat/mat_phx_metallic")
    holoColor(24,vec(150,150,150))
    holoParent(24,13)
    
    holoCreate(100)
    holoModel(100,"hq_sphere")
    holoScale(100,vec(1.5))
    holoColor(100,vec4(255,100,0,100))
}
if(clk("final")){
    for(I=1,30){
        holoVisible(I,players(),1)    
    }
}

if(!Ac)
{
    findByClass("gmod_wire_turret")
    findSortByDistance(entity():pos())
    if(find():owner()==owner()&find():pos():distance(entity():pos())<100)
    {
        T = find()
        T:setPos(holoEntity(1):toWorld(vec(0,0,40)))
        T:setAng(holoEntity(1):toWorld(ang(-90,0,0)))
        T:createWire(entity(),"Fire","Fire")
        if(T:parent()==holoEntity(1))
        {
            Ac = 1
        }else
        {
            timer("prnt",50)
        }
    }
    if(clk("prnt"))
    {
        stoptimer("prnt")
        T:parentTo(holoEntity(1))
        Ac = 1
    }
}else
{
    Fire = P>0.75
    if(F)
    {
        P+=0.0125
    }else
    {
        P-=0.0125
    }
    P = clamp(P,0,1)
    holoAng(1,holoEntity(1):toWorld(ang(0,P*60,0)))
}

if(GC:driver():isValid())
{
    holoAng(13,(GC:driver():aimPos()-entity():pos()):toAngle())
    F = GC:driver():keyAttack1()
    holoPos(100,GC:driver():aimPos())
}

holoVisible(100,players(),0)
holoVisible(100,GC:driver(),1)

if(duped()|dupefinished())
{
    reset()
}

