@name Chaqua VTOL
@persist [E P L1 L2]:entity FC FM FL
@persist B WTM WM M:entity
@persist [P2H_Mod P2H_Color P2H_Mat P2H_Pos P2H_Ang]:array P2H_Int P2H_Offset P2H_Ready
if(first())
{
    runOnTick(1)
    
    entity():setColor(0,0,0,0)
    
    E = entity():isConstrainedTo()
    if(E:isValid())
    {
        E:setMass(50000)
        
        if(E:isVehicle())
        {
            selfDestruct()
        }else
        {
            foreach(I, TE:entity = E:getConstraints())
            {
                if(TE:isVehicle())
                {
                    P = TE
                    P:setMass(0.1)
                    P:parentTo(E)
                    break
                }
            }
        }
    }else
    {
        selfDestruct()
    }
    
    FC = 9
    
    local B = holoCreate(1,P:toWorld(vec(0,0,33)))
    holoAlpha(1,0)
    holoParent(1,P)
    
    holoCreate(2,B:toWorld(vec(150,0,0)),vec(0.5),B:toWorld(ang(90,0,0)))
    holoModel(2,"hq_torus")
    holoColor(2,vec4(255,100,0,150))
    holoDisableShading(2,1)
    holoParent(2,1)
    
    holoCreate(3,B:toWorld(vec(150,0,0)),vec(0.05,0.05,0.375),B:toWorld(ang(0,0,90)))
    holoModel(3,"hq_cylinder")
    holoColor(3,vec4(255,100,0,150))
    holoDisableShading(3,1)
    holoParent(3,2)
    
    holoCreate(4,B:toWorld(vec(150,0,0)),vec(0.05,0.05,0.375))
    holoModel(4,"hq_cylinder")
    holoColor(4,vec4(255,100,0,150))
    holoDisableShading(4,1)
    holoParent(4,2)
    
    local B = holoCreate(1000,E:toWorld(vec(17.5,0,-2.5)),vec(0.75),E:toWorld(ang()))
    holoMaterial(1000,"models/props_canal/canal_bridge_railing_01c")
    holoModel(1000,"hq_sphere")
    holoParent(1000,E)
    
    holoCreate(1001,B:toWorld(vec(0,0,13)),vec(0.125,0.125,1.5),B:toWorld(ang()))
    holoColor(1001,vec(150))
    holoModel(1001,"hq_cylinder")
    holoParent(1001,1000)
    
    holoCreate(1002,holoEntity(1001):toWorld(vec(0,0,10)),vec(0.25))
    holoColor(1002,vec(255,0,0))
    holoMaterial(1002,"models/shiny")
    holoModel(1002,"hq_sphere")
    holoParent(1002,1000)
    
    E:soundPlay("ign",0,"NPC_AttackHelicopter.Rotors")
    soundPitch("ign",0)
    
    P2H_Int = 0
    P2H_Offset = 4
    P2H_Mod = array("models/sprops/rectangles/size_3/rect_24x36x3.mdl","models/props_c17/canister_propane01a.mdl","models/props_c17/canister_propane01a.mdl","models/combine_helicopter/helicopter_bomb01.mdl","models/props_c17/canister_propane01a.mdl","models/props_c17/canister_propane01a.mdl","models/sprops/triangles_thin/right/size_3/t_rtri_36x36.mdl","models/sprops/rectangles_thin/size_2_5/rect_18x36x1_5.mdl","models/sprops/rectangles_thin/size_2_5/rect_18x36x1_5.mdl","models/sprops/triangles_thin/right/size_3/t_rtri_36x36.mdl","models/sprops/rectangles/size_1/rect_3x36x3.mdl","models/sprops/rectangles/size_1/rect_3x12x3.mdl","models/sprops/rectangles/size_1/rect_3x12x3.mdl","models/sprops/rectangles/size_1/rect_3x12x3.mdl","models/sprops/rectangles/size_1_5/rect_6x24x3.mdl","models/sprops/rectangles/size_3_5/rect_30x36x3.mdl","models/sprops/rectangles/size_1_5/rect_6x24x3.mdl","models/sprops/rectangles/size_1/rect_3x36x3.mdl","models/sprops/rectangles/size_1/rect_3x36x3.mdl","models/sprops/rectangles/size_1_5/rect_6x24x3.mdl","models/props_c17/canister_propane01a.mdl","models/combine_helicopter/helicopter_bomb01.mdl","models/combine_helicopter/helicopter_bomb01.mdl","models/props_c17/oildrum001.mdl","models/props_c17/canister_propane01a.mdl","models/props_borealis/bluebarrel001.mdl","models/props_c17/oildrum001.mdl","models/props_borealis/bluebarrel001.mdl","models/props_c17/canister_propane01a.mdl","models/props_phx/wheels/magnetic_medium.mdl","models/xqm/afterburner1.mdl","models/props_trainstation/trainstation_ornament002.mdl","models/props_c17/oildrum001.mdl","models/props_c17/canister_propane01a.mdl","models/props_c17/canister_propane01a.mdl","models/props_borealis/bluebarrel001.mdl","models/props_borealis/bluebarrel001.mdl","models/sprops/cuboids/height06/size_6/cube_36x60x6.mdl","models/xqm/rails/gumball_1.mdl","models/sprops/cuboids/height06/size_5/cube_30x36x6.mdl","models/props_c17/oildrum001.mdl","models/xqm/afterburner1.mdl","models/props_phx/wheels/magnetic_medium.mdl","models/props_trainstation/trainstation_ornament002.mdl","models/props_c17/oildrum001.mdl","models/props_c17/oildrum001.mdl","models/props_borealis/bluebarrel001.mdl","models/props_borealis/bluebarrel001.mdl","models/props_c17/oildrum001.mdl","models/props_c17/oildrum001.mdl","models/combine_helicopter/helicopter_bomb01.mdl","models/xqm/jettailpiece1medium.mdl","models/xqm/jettailpiece1.mdl","models/xqm/jettailpiece1.mdl","models/xqm/jettailpiece1medium.mdl","models/xqm/wingpiece2.mdl","models/combine_helicopter/helicopter_bomb01.mdl","models/sprops/rectangles/size_2_5/rect_18x24x3.mdl","models/props_wasteland/light_spotlight01_lamp.mdl","models/sprops/rectangles/size_2/rect_12x24x3.mdl","models/props_wasteland/light_spotlight01_lamp.mdl","models/sprops/cylinders/size_5/cylinder_12x18.mdl","models/sprops/rectangles/size_2_5/rect_18x30x3.mdl","models/sprops/rectangles/size_2_5/rect_18x24x3.mdl","models/sprops/rectangles/size_1/rect_3x36x3.mdl","models/props_trainstation/trainstation_ornament002.mdl","models/xqm/afterburner1.mdl","models/props_phx/wheels/magnetic_medium.mdl","models/props_junk/popcan01a.mdl","models/props_junk/popcan01a.mdl","models/props_junk/popcan01a.mdl","models/props_junk/popcan01a.mdl","models/props_junk/popcan01a.mdl","models/xqm/wingpiece2.mdl","models/xqm/afterburner1.mdl","models/props_trainstation/trainstation_ornament002.mdl","models/props_junk/popcan01a.mdl","models/props_junk/popcan01a.mdl","models/props_phx/wheels/magnetic_medium.mdl","models/props_junk/popcan01a.mdl","models/props_junk/popcan01a.mdl","models/props_junk/popcan01a.mdl","models/sprops/rectangles/size_2/rect_12x36x3.mdl","models/sprops/rectangles/size_2/rect_12x36x3.mdl","models/sprops/rectangles/size_2/rect_12x36x3.mdl","models/props_lab/citizenradio.mdl","models/sprops/rectangles/size_1/rect_3x30x3.mdl","models/props_c17/canister_propane01a.mdl","models/sprops/rectangles/size_1/rect_3x30x3.mdl","models/props_c17/oildrum001.mdl")
    P2H_Color = array(vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255),vec4(255,255,255,255))
    P2H_Mat = array("models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","phoenix_storms/glass","phoenix_storms/glass","phoenix_storms/glass","phoenix_storms/glass","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01b","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01b","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c"," ","models/props_canal/canal_bridge_railing_01c"," ","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01b","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01b","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","phoenix_storms/glass","phoenix_storms/glass","phoenix_storms/glass","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c","models/props_canal/canal_bridge_railing_01c")
    P2H_Pos = array(vec(-17.7489,-0.0454,12.5521),vec(14.0848,-21.0109,-7.309),vec(38.02,19.0738,-3.9519),vec(34.8866,11.7454,-3.5723),vec(14.0981,20.9138,-7.2303),vec(-2.282,37.4449,1.1404),vec(0.8489,20.3188,10.8718),vec(-20.6761,19.3317,26.4653),vec(-20.6761,-19.3349,26.4649),vec(0.8489,-20.3217,10.8713),vec(14.624,-16.9576,24.0588),vec(2.4233,-10.4191,36.3038),vec(3.434,0.011,36.3024),vec(2.4233,10.4156,36.304),vec(-0.4172,-0.4164,36.3008),vec(-17.2161,0.1042,36.2501),vec(-11.5721,14.3482,36.2308),vec(-15.0162,16.4196,36.2675),vec(-15.0162,-16.423,36.2671),vec(-11.5721,-14.3517,36.2304),vec(-2.3459,-37.5499,1.1656),vec(-33.8839,1.372,22.3922),vec(-33.8839,-1.3752,22.3922),vec(-75.1964,11.6247,24.3763),vec(-24.2556,22.9461,9.3652),vec(-64.7052,0.4768,27.9534),vec(-75.1964,-11.6279,24.3755),vec(-64.7052,-0.4954,27.9538),vec(-24.2665,-23.0719,9.3628),vec(-95.2305,-29.0635,14.0892),vec(-93.2756,-25.2312,8.8698),vec(-93.828,-20.8237,13.919),vec(-33.8345,6.3462,2.9184),vec(-23.0969,10.2116,8.8201),vec(-23.0969,-10.3379,8.8218),vec(-98.2073,-7.9231,21.0066),vec(-98.2081,7.9348,21.0105),vec(-30.1953,-0.0461,-6.9715),vec(-25.291,0.2591,-3.407),vec(14.627,-0.722,-14.3771),vec(-33.8345,-6.3489,2.9182),vec(-93.2725,25.2315,8.8704),vec(-95.23,29.0655,14.0907),vec(-93.828,20.8207,13.9195),vec(-73.2309,11.6752,24.4994),vec(-100.7555,9.6234,25.8542),vec(-100.2319,0.3875,30.2178),vec(-100.2319,-0.4017,30.207),vec(-73.2309,-11.6784,24.4992),vec(-100.7555,-9.6266,25.854),vec(-146.3981,0.1656,27.4072),vec(-163.3107,36.9593,43.231),vec(-177.2592,8.8607,51.3225),vec(-177.2592,-8.8646,51.3222),vec(-163.3106,-36.9628,43.2309),vec(16.8511,-57.7488,6.0311),vec(34.8866,-11.7479,-3.5726),vec(39.6605,-8.2972,7.8522),vec(47.9774,-15.8423,-1.3587),vec(51.7407,0.0594,0.0325),vec(47.9774,15.8958,-1.3683),vec(46.4839,0.0279,-5.4143),vec(39.363,0.1381,-13.6033),vec(39.6605,8.2944,7.8524),vec(14.624,16.9544,24.0592),vec(16.8445,-77.3684,3.1353),vec(17.3016,-77.2043,-1.6535),vec(17.386,-76.8977,3.0544),vec(34.0005,-69.9338,7.6065),vec(32.3188,-71.8045,7.775),vec(34.1938,-73.648,7.9639),vec(34.2694,-74.468,5.0375),vec(33.8728,-74.8243,6.4826),vec(16.8531,57.7459,6.0325),vec(17.3016,77.1974,-1.6517),vec(16.8445,77.3656,3.1371),vec(33.9968,69.9352,7.6062),vec(32.3234,71.8055,7.7767),vec(17.3811,76.895,3.0561),vec(34.1977,73.6485,7.9625),vec(34.2748,74.4677,5.0388),vec(33.8756,74.8236,6.4795),vec(16.6804,9.7357,22.7041),vec(17.4116,0.0703,22.9039),vec(16.6804,-9.7389,22.7038),vec(32.2843,-0.0767,-5.1782),vec(26.9576,2.2943,10.907),vec(38.0516,-19.1956,-3.9561),vec(26.9576,-2.2972,10.9069),vec(-140.8572,-0.0685,34.78))
    P2H_Ang = array(ang(0,-90,115),ang(-49.9987,-85.0001,80.0002),ang(-80,-5,-10),ang(0.0001,-5,0.0013),ang(-50,85,-80),ang(-60,10,25),ang(45,170,175),ang(0,5,-70),ang(0.0001,-5,70.0013),ang(45.0002,-170.0013,-175.0018),ang(45,5,0),ang(0,80,0),ang(0,90,0),ang(0.0013,-80,0.0002),ang(0,90,0),ang(0,0,0),ang(-0.0001,5,0.0013),ang(-0.0001,5,0.0013),ang(0,-5,0),ang(0,-5,0),ang(-59.9998,-10.0022,-24.9974),ang(0.0013,-105,4.9997),ang(0,105,-5),ang(90,0,0),ang(-85.0003,14.9855,-9.9854),ang(-85,-15,15),ang(89.9987,0,0),ang(-85.0003,14.9855,-14.9854),ang(-85,-15,10),ang(10,5,-10),ang(0,45,-180),ang(20,-85,0),ang(75,0.0049,-174.9949),ang(-84.9998,-10.0148,10.0148),ang(-85,10,-10),ang(70,-140,45),ang(69.9992,139.9972,-45.0029),ang(-15,180,0),ang(0,0,0),ang(0,180,0),ang(75,0,175),ang(0.0009,-45,-179.9991),ang(10.0001,-4.9998,10.0013),ang(19.9987,85,0.0001),ang(-84.9993,-30.0129,35.013),ang(-65.0013,95.0002,-85.0002),ang(-45,90,-90),ang(-44.9987,-90,90),ang(-85,29.9999,-34.9999),ang(-65,-95,85),ang(0,-100,-5),ang(69.9989,124.9979,34.9978),ang(29.9987,94.9999,-5.0001),ang(-30,85,-5),ang(-70,55,35),ang(0,5,0),ang(0,5,0),ang(-15,-180,-180),ang(0,0,10.0013),ang(0,-90,-75),ang(0,0,-10),ang(-90,90,0),ang(0,-90,-150),ang(-15,-179.9996,179.9986),ang(45.0001,-4.9987,0.0019),ang(-0.0015,8.6254,0.0015),ang(0,-180,179.998),ang(-7.2861,-89.6148,0.2065),ang(-70,-115,75),ang(-85,55,-5),ang(55,170,115),ang(-85,-60,125),ang(-35,-20,80),ang(-0.0001,175,-0.0013),ang(0,180,-179.9993),ang(-0.0013,-8.6254,-0.0002),ang(-70.0012,115.0015,-75.0016),ang(-84.9989,-55.0086,5.0086),ang(-7.2874,89.6148,-0.2065),ang(55.0002,-170.0019,-115.0023),ang(-85.0011,59.9924,-124.9923),ang(-35.0005,19.9991,-79.9985),ang(45.0001,-4.9987,-9.9982),ang(45,0,0),ang(45,5,10),ang(0,180,0),ang(0.0013,-90,0),ang(-80.0001,4.9926,10.0075),ang(0,90,0),ang(90,180,0))
    
    rangerPersist(1)
}

if(!P2H_Ready)
{
    while(holoCanCreate() & perf() & P2H_Int < P2H_Mod:count())
    {
        P2H_Int++
        local P2H_TempInt = P2H_Int+P2H_Offset
        holoCreate(P2H_TempInt,E:toWorld(P2H_Pos[P2H_Int,vector]+vec(0,0,10)),vec(1),E:toWorld(P2H_Ang[P2H_Int,angle]))
        holoColor(P2H_TempInt,P2H_Color[P2H_Int,vector4])
        holoModel(P2H_TempInt,P2H_Mod[P2H_Int,string])
        holoMaterial(P2H_TempInt,P2H_Mat[P2H_Int,string])
        holoParent(P2H_TempInt,E)
    }
    P2H_Ready = P2H_Int >= P2H_Mod:count()
}elseif(changed(P2H_Ready))
{
    L1 = holoEntity(63)
    L2 = holoEntity(65)
    lightCreate(1,L1:toWorld(vec(100,0,0)),vec(255),300,100)
    lightToggle(1,0)
    lightCreate(2,L2:toWorld(vec(100,0,0)),vec(255),300,100)
    lightToggle(2,0)
}

R1 = rangerOffsetHull(500000,L1:pos(),L1:forward(), vec(250))
lightPos(1,R1:pos())

R2 = rangerOffsetHull(500000,L2:pos(),L2:forward(), vec(250))
lightPos(2,R2:pos())

if(clk("dl"))
{
    stoptimer("dl")
    holoDelete(5)
}

Dri = P:driver()
Active = P:driver():isValid()
if(Active)
{
    W = Dri:keyForward()
    A = Dri:keyLeft()
    S = Dri:keyBack()
    D = Dri:keyRight()
    Spc = Dri:keyJump()
    Shift = Dri:keySprint()
    M1 = Dri:keyAttack1()
    M2 = Dri:keyAttack2()
    R = Dri:keyReload()
    Alt = Dri:keyWalk()
    KZ = Dri:keyZoom()
    
    holoAng(63,Dri:eyeAngles())
    holoAng(65,Dri:eyeAngles())
    
    local A = holoEntity(1):toLocal(Dri:eyeAngles())
    holoAng(1,holoEntity(1):toWorld(A/10))
    holoAng(1,Dri:eyeAngles())
    holoAng(2,Dri:eyeAngles()-ang(90,0,0))
    
    if(changed(Alt)&Alt)
    {
        FL = !FL
        lightToggle(1,FL)
        lightToggle(2,FL)
        E:soundPlay("fl",0.608,"items/flashlight1.wav")
    }
    
    if(WM)
    {
        if(!M:isValid())
        {
            if(M1&!B)
            {
                M = propSpawn("models/props_phx/amraam.mdl",holoEntity(1):toWorld(vec(500,0,0)),holoEntity(1):angles(),1)
                M:setColor(0,0,0,0)
                M:setTrails(100,0,3,"trails/laser",vec(255),255)
                
                soundPlay("nwtms",1.835,"weapons/cow_mangler_main_shot.wav")
                
                WTM = 0
                
                B = 1
                timer("ub",300)
                
                cameraCreate(1,M:pos(),M:angles())
                cameraParent(1,M)
            }elseif(changed(M2)&M2)
            {
                M = propSpawn("models/props_phx/amraam.mdl",holoEntity(1):toWorld(vec(350,0,0)),holoEntity(1):angles(),1)
                M:setTrails(15,300,2,"trails/smoke",vec(255),150)
                
                soundPlay("wtms",1.8,"weapons/sentry_rocket.wav")
                M:soundPlay("rocket",0,"weapons/rpg/rocket1.wav")
                
                WTM = 1
                
                cameraCreate(1,M:pos(),M:angles())
                cameraParent(1,M)
            }
        }
    }
    
    FM+=0.005
}else
{
    FM-=0.005
}
FM = clamp(FM,0,1)

if(changed(FM))
{
    soundPitch("ign",FM*100)
}

if(changed(Active))
{
    rangerFilter(array(E,P,Dri))
    if(Active)
    {
        
    }else
    {
        WM = 0
        
        FL = 0
        lightToggle(1,0)
        lightToggle(2,0)
    }
}

if(changed(WM))
{
    holoAlpha(2,WM*75)
    holoAlpha(3,WM*75)
    holoAlpha(4,WM*75)
}

if(clk("ub"))
{
    stoptimer("ub")
    B = 0
}

if(M:isValid())
{
    rangerFilter(array(E,P,Dri,M))
    local RD = rangerOffset(200-(100*WTM),M:pos(),M:forward())
    if(RD:hit())
    {
        WTM = 0
        
        M:propBreak()
        
        cameraRemove(1)
    }else
    {
        cameraToggle(1,R,P)
        cameraPos(1,vec(0,0,KZ ? 20 : 50)+M:pos()-Dri:eye()*(KZ ? 50 : 200))
        cameraAng(1,Dri:eyeAngles())
        cameraZoom(1,KZ ? 30 : 90)
        
        if(WTM)
        {
            M:setPos(M:toWorld(vec(50,0,0)))
            
            if(R)
            {
                local A = M:toLocal(Dri:eyeAngles())
                M:setAng(M:toWorld(A/10))
            }else
            {
                local A = ((Dri:shootPos()+Dri:eye()*(M:pos():distance(Dri:shootPos())+1000))-M:pos()):toAngle()
                local B = M:toLocal(A)
                
                M:setAng(M:toWorld(B/10))
            }
        }else
        {
            M:setPos(M:toWorld(vec(150,0,0)))
        }
    }
}elseif(changed(R)&R)
{
    WM = !WM
    E:soundPlay("wm",WM ? 0.276 : 0.571,WM ? "buttons/blip2.wav" : "buttons/button6.wav")
}

E:applyForce((E:up()*(FC+((Spc-Shift)*4))-(E:vel()*vec(0.0025,0.0025,0.005)))*E:mass()*FM)
E:applyAngForce((ang((W-S)*60,(M1-M2)*80*!WM,(D-A)*60)-(E:angles()*ang(3,0,3))-E:angVel()*1)*E:mass()*FM)

holoAng(1000,holoEntity(1000):toWorld(holoEntity(1000):toLocal(E:toWorld(ang((W-S)*10,0,(D-A)*10)))/10))

if(duped()|dupefinished())
{
    timer("rst",500)
}

if(clk("rst"))
{
    reset()
}
