@name Droney
@inputs [Pod Cam]:wirelink 
@outputs 
@persist Base:entity 
@trigger 
interval(100)
runOnLast(1)

E = entity()

if (first()) {
    Base = propSpawn("models/hunter/plates/plate075x075.mdl",E:toWorld(vec(-40,0,20)),0)
    Base:propGravity(0)
    Base:setMass(50000)
    
    holoCreate(1)
    holoPos(1,Base:toWorld(vec(-30,-6,20)))
    holoAng(1,Base:toWorld(ang(0,-90,0)))
    holoParent(1,Base)
}

Cam["Position", vector] = holoEntity(1):pos()
Cam["Parent", entity] = holoEntity(1)

local Seat = Pod["Entity",entity]
local Driver = Seat:driver()
local W = Pod["W",number]
local A = Pod["A",number]
local S = Pod["S",number]
local D = Pod["D",number]
local Space = Pod["Space",number]
local Shift = Pod["Shift",number]
local Mouse1 = Pod["Mouse1",number]
local Mouse2 = Pod["Mouse2",number]
local Alt = Pod["Alt",number]
local Active = Driver:isPlayer()
Cam["Activated", number] = Active

Base:applyForce(Base:forward()*(W-S)*Base:mass()*50)

Base:applyForce(Base:right()*(D-A)*Base:mass()*50)

Base:applyForce(Base:up()*(Space-Shift)*Base:mass()*25)

Base:applyForce(-Base:vel()*Base:mass()/7.5)

Base:applyForce(Base:forward()*(Alt)*Base:mass()*50)

if (Active) {
    rangerFilter(Base)
    Ranger = rangerOffset(32768,Seat:pos(),Seat:toLocalAxis(Driver:eye()))
    Yaw = (Ranger:pos() - Base:pos()):toAngle():yaw()
    Angle = ang(Yaw,Yaw,Yaw)
    Base:applyAngForce((Base:toLocal(Angle)*200 - Base:angVel()*20) * shiftL(ang(Base:inertia())))
}

if (last()) {propDeleteAll()}
