@name Go Go Leifi
@persist [E P CE Dr]:entity FC FM SpinVel Ign C:wirelink Door
@model models/props_wasteland/cargo_container01b.mdl

if(first())
{
    runOnTick(1)
    
    E = entity()
    E:setMaterial("models/props_combine/metal_combinebridge001")
    E:setMass(50000)
    E:propFreeze(0)
    
    holoCreate(1, E:toWorld(vec(0, -400, 110)), vec(10), E:toWorld(ang(90, 90, 0)))
    holoModel(1, "models/player/gman_high.mdl")
    holoParent(1, E)
    holoAnim(1, "Stand_IDLE")
    
    holoCreate(2, holoEntity(1):toWorld(vec(-40, 0, 400)), vec(1.5), holoEntity(1):toWorld(ang(-90, 0 ,0)))
    holoModel(2, "models/gman_high.mdl")
    holoParent(2, E)
    
    holoCreate(3, holoEntity(2):toWorld(vec(-450, 0, 92.5)), vec(0.5, 2, 12), holoEntity(2):toWorld(ang(90, 0, 0)))
    holoModel(3, "models/player/gman_high.mdl")
    holoParent(3, 2)
    
    holoCreate(4, E:toWorld(vec(0, -190, -50)), vec(1, 5, 1.6), E:toWorld(ang(0, -90, 0)))
    holoModel(4, "models/perftest/gman.mdl")
    holoParent(4, E)
    
    Dr = propSpawn("models/sprops/rectangles/size_6/rect_96x96x3.mdl", holoEntity(4):toWorld(vec(0, 0, 55)), E:toWorld(ang(0, 0, 90)), 1)
    Dr:setColor(0, 0, 0, 0)
    Dr:parentTo(holoEntity(4))
    
    FC = 9
    
    soundPlay("heli", 0, "vehicles/airboat/fan_blade_fullthrottle_loop1.wav")
    soundPitch("heli", 0)
}

if(P:isValid())
{
    Dri = P:driver()
    Active = P:driver():isValid()
    if(Active)
    {
        W = Dri:keyPressed("W")
        A = Dri:keyPressed("A")
        S = Dri:keyPressed("S")
        D = Dri:keyPressed("D")
        Up = Dri:keyPressed("UP")
        Lft = Dri:keyPressed("LEFT")
        Dwn = Dri:keyPressed("DOWN")
        Rht = Dri:keyPressed("RIGHT")
        Shi = Dri:keyPressed("LSHIFT")
        Rk = Dri:keyPressed("R")
        Alt = Dri:keyPressed("LALT")
        
        if(changed(Rk) & Rk)
        {
            Ign = !Ign
        }
        
        if(changed(Alt) & Alt)
        {
            Door = !Door
        }
    }else
    {
        Ign = 0
    }
    FM += Ign ? 0.0025 : -0.0025
    FM = clamp(FM,0,1)
    
    if(changed(FM))
    {
        SpinVel = FM * 35
        soundPitch("heli", FM * 255)
    }
    holoAng(2, holoEntity(2):toWorld(ang(0, SpinVel, 0)))
    
    E:applyForce((E:up() * (FC + ((W-S)*2)) - (E:vel() * vec(0.0025, 0.0025, 0.015))) * E:mass() * FM)
    E:applyAngForce(((ang((Rht - Lft)*30, (A - D)*80, (Dwn - Up)*100))*4 - E:angVel()*ang(3, 6, 15)) * E:mass() * FM)
    
    if(CE:isValid())
    {
        if(changed(Active))
        {
            C["Activated", number] = Active
            C["Position", vector] = E:toWorld(vec(0, 0, 250))
            C["Angle", angle] = Dri:eyeAngles()
            C["Parent", entity] = E
            C["Distance", number] = 250
        }
    }else
    {
        findByClass("gmod_wire_cameracontroller")
        findSortByDistance(E:pos())
        if(find():pos():distance(E:pos()) < 50000)
        {
            CE = find()
            CE:setPos(E:toWorld(vec(0, 210, -15)))
            CE:setColor(0, 0, 0, 0)
            CE:setAng(E:angles())
            
            C = CE:wirelink()
            
            timer("cpnt",50)
        }
    }
    
    if(changed(Door))
    {
        holoVisible(4, players(), Door)
        Dr:propNotSolid(!Door)
    }
}else
{
    findByClass("prop_vehicle_prisoner_pod")
    findSortByDistance(E:pos())
    if(find():pos():distance(E:pos()) < 500 & find():owner() == owner())
    {
        P = find()
        
        P:propNotSolid(1)
        
        P:setPos(E:toWorld(vec(0, 225, -15)))
        P:setAng(E:toWorld(ang(0, 0, 0)))
        
        P:setColor(255, 255, 255, 255)
        P:setMaterial("models/props_combine/metal_combinebridge001")
        
        timer("ppnt",50)
    }
}

if(clk("ppnt"))
{
    stoptimer("ppnt")
    P:parentTo(E)
    P:propNotSolid(0)
}

if(clk("cpnt"))
{
    stoptimer("cpnt")
    CE:parentTo(E)
}
