@name Phantom
@persist HCN FMV SMV
@persist [E P Dri]:entity

if(first())
{
    E = entity()
    P = E:isConstrainedTo()
    
    if(P:isVehicle())
    {
        P:setColor(vec4())
        
        E:setColor(vec4())
        E:propNotSolid(1)
        
        #Chair holo
        holoCreate(1, P:toWorld(vec(0, 0, 30)), vec(5))
        holoModel(1, "hq_sphere")
        holoColor(1, vec4(0, 0, 0, 225))
        holoDisableShading(1, 1)
        holoParent(1, P)
        
        #Direction holo
        holoCreate(2, holoEntity(1):pos(), vec(0.25), owner():eyeAngles())
        holoParent(2, 1)
        holoAlpha(2, 0)
        
        TA = owner():eyeAngles()
        VA = E:angles()
        
        for(I = 3, 5)
        {
            holoCreate(I)
            holoScale(I, vec(0.1))
            holoAlpha(I, 0)
            holoEntity(I):setTrails(0, 24, 2.5, "trails/smoke", vec(), 255)
        }
        
        timer("t1", 100)
        timer("t2", 500)
    }else
    {
        #error("Spawn E2 on the chair")
    }
}elseif(clk("t1"))
{
    timer("t1", 100)
    
    Dri = P:driver()
    Act = Dri:isValid()
    
    W = Dri:keyForward()
    A = Dri:keyLeft()
    S = Dri:keyBack()
    D = Dri:keyRight()
    Shi = Dri:keySprint()
    Spc = Dri:keyJump()
    R = Dri:keyReload()
    Alt = Dri:keyWalk()
    M1 = Dri:keyAttack1()
    M2 = Dri:keyAttack2()
    
    if(Act)
    {
        if(!Alt)
        {
            holoAng(2, holoEntity(2):toWorld(holoEntity(2):toLocal(Dri:eyeAngles()) * 0.5))
        }
        
        if(changed(A | D) & (A | D))
        {
            SMV = (A - D) * 100
        }
    }
    
    FMV += (((W - S) * (75 * (1 + (Shi * 2)))) - FMV) / 4
    SMV *= 0.6
    P:setPos(P:pos() + holoEntity(2):toWorldAxis(vec(FMV, SMV, 0)) / (1 + !Act))
    
    HCN += 15
    for(I = 3, 5)
    {
        local TV = HCN + (120 * I)
        holoPos(I, holoEntity(2):toWorld(vec(FMV * 1.25, cos(TV) * 45, sin(TV) * 45)))
    }
}elseif(clk("t2"))
{
    timer("t2", 500)
    
    if(P:angles() != ang())
    {
        P:propFreeze(1)
        P:setAng(ang())   
    }
}

print(4, toString(ops()))
