@name Delivery Quadcopter
@inputs Grabber:wirelink
@persist TargetPos:vector Current:table HoverY
@persist Nodelist:array CurNode
@persist [NodeA NodeB NodeC]:string LowestValue 
@persist Path:array
@persist Grab:entity
@model models/hunter/plates/plate05x05.mdl
interval(100)

Global=gTable("Quadnet")

if (first()) {
    HoverY=120
    
    # foreach(I,V:table=Graph) {Nodelist:pushString(I)}
    function makeFan(ID,Center:vector){
        holoCreate(ID)
        holoPos(ID,Center)
        holoModel(ID,"models/hunter/tubes/tube2x2x025.mdl")
        holoScale(ID,vec(0.1))
        holoParent(ID,1)
        
        holoCreate(ID+1)
        holoPos(ID+1,Center)
        holoModel(ID+1,"models/hunter/plates/plate025x2.mdl")
        holoScale(ID+1,vec(0.1,0.095,0.1))
        holoParent(ID+1,ID)
        
        holoCreate(ID+2)
        holoPos(ID+2,Center)
        holoModel(ID+2,"models/hunter/plates/plate025x2.mdl")
        holoScale(ID+2,vec(0.1,0.095,0.1))
        holoAng(ID+2,ang(0,90,0))
        holoParent(ID+2,ID+1)
        
        holoMaterial(ID,"phoenix_storms/iron_rails")
        holoMaterial(ID+1,"phoenix_storms/iron_rails")
        holoMaterial(ID+2,"phoenix_storms/iron_rails")
        
        holoColor(ID+1,vec(128))
        holoColor(ID+2,vec(128))
    }
    
    function setupHolos(){
        Grab=Grabber:entity()
        
        #Base
        holoCreate(1)
        holoPos(1,vec())
        holoModel(1,"models/Mechanics/robotics/stand.mdl")
        holoScale(1,vec(0.1))
        
        #Beams
        holoCreate(2)
        holoAng(2,ang(0,45,0))
        holoPos(2,vec(0,0,2.5))
        holoModel(2,"models/Mechanics/robotics/a2.mdl")
        holoScale(2,vec(0.3,0.1,0.1))
        holoParent(2,1)
        
        holoCreate(3)
        holoAng(3,ang(0,-45,0))
        holoPos(3,vec(0,0,2.5))
        holoModel(3,"models/Mechanics/robotics/a2.mdl")
        holoScale(3,vec(0.3,0.1,0.1))
        holoParent(3,1)
        
        # Grabber
        holoCreate(4)
        holoPos(4,vec(0,0,0.8))
        holoModel(4,"models/XQM/cylinderx1.mdl")
        holoScale(4,vec(0.3))
        holoAng(4,ang(90,0,0))
        holoParent(4,1)
        Grab:setMaterial("models/effects/comball_glow2")
        Grab:setAlpha(255)
        
        #Fans        
        makeFan(5,vec(8.3,8.3,2.5))
        makeFan(8,vec(-8.3,8.3,2.5))
        makeFan(11,vec(-8.3,-8.3,2.5))
        makeFan(14,vec(8.3,-8.3,2.5))
        
        holoCreate(20)
        holoScale(20,vec(1))
        holoColor(20,vec(255,0,0))
        
        #Finalize
        holoPos(1,Grab:toWorld(vec(0,0,2)))
        holoAng(1,Grab:angles()+ang(180,0,0))
        holoParent(1,Grab)
        
        holoEntity(1):soundPlay(0,0,"npc/manhack/mh_engine_loop1.wav")
        soundPitch(0,120)
        soundVolume(0,0.1)
        
        Grab:propGravity(0)
        
    }
    
    if (Grabber) {setupHolos()}
}


local FanAng=ang(0,curtime()*800,0)
holoAng(6,FanAng)
holoAng(9,FanAng)
holoAng(12,FanAng)
holoAng(15,FanAng)
