@name DroneDavid
@inputs Active Launch
@outputs 
@persist T Cloak Inertia:angle
@model models/sprops/geometry/sphere_36.mdl
interval(100)
if(first()|dupefinished()) { 
    Inertia = shiftL(ang(entity():inertia())):setYaw(0)
    entity():propFreeze(0)
    
    holoCreate(1)
    holoModel(1,"models/sprops/geometry/fring_42.mdl")
    holoAng(1,entity():toWorld(ang(90,0,0)))
    holoColor(1,vec(0,0,0))
    holoScale(1,vec(0.9,1,0.9))
    holoParent(1,entity())
    
    holoCreate(2)
    holoPos(2,entity():toWorld(vec(0,0,-18.5)))
    holoModel(2,"models/sprops/misc/domes/size_0/dome_3x1_5.mdl")
    holoAng(2,entity():toWorld(ang(0,0,180)))
    holoParent(2,entity())
}elseif(clk("Launch")){stoptimer("Launch"),Launch=0}

if(Active==1){
    if(changed(Active)){entity():soundPlay("idling",0,"/ambient/machines/combine_shield_loop3.wav"),soundVolume("idling",0.3),entity():propNotSolid(0)}
    
    T=T+50
    #holoAng(1,ang(sin(T)*300,cos(T)*300,90+sin(T)*30))
    holoAng(1,ang(0,T,0))
    
    Force=(-entity():angles()*500-entity():angVel()*15)
    entity():applyAngForce(Force*Inertia)
}

if(Cloak==1){
    holoMaterial(1,"models/shadertest/predator")
    holoMaterial(2,"models/shadertest/predator")
    entity():setMaterial("models/shadertest/predator")
}else{
    holoMaterial(1,"models/shiny")
    holoMaterial(2,"models/shiny")
    entity():setMaterial("models/shiny")
}
if(Launch==1&changed(Launch)){
    print("321")
    entity():removeAllConstraints()
    entity():propFreeze(0)
    entity():applyForce(entity():pos()+vec(0,0,1)*100)
    timer("Launch",50)
    Active=1
}
