@name God E2
@inputs [Pod Cam]:wirelink 
@outputs 
@persist Rotation 
@trigger 
interval(15)

E = entity():isWeldedTo()

if (first() | dupefinished()) {
    holoCreate(1)
    holoCreate(2)
    holoCreate(3)
    holoCreate(4)
    holoCreate(5)
    holoCreate(6)
    holoCreate(7)
    holoCreate(8)
    holoCreate(9)
    holoCreate(10)
    holoCreate(11)
    holoCreate(12)
    
    for (I = 1,12) {holoModel(I,"models/sprops/trans/miscwheels/tank30.mdl")}
}

local Seat = Pod["Entity",entity]
local Driver = Seat:driver()
local Active = Driver:isPlayer()
local W = Driver:keyForward()
local A = Driver:keyLeft()
local S = Driver:keyBack()
local D = Driver:keyRight()
local Space = Driver:keyJump()
local Shift = Driver:keySprint()
local M1 = Driver:keyAttack1()
local M2 = Driver:keyAttack2()
Cam["Activated",number] = Active

RF = array(E)

rangerFilter(RF) L1R = rangerOffset(70,E:pos()+E:right()*45.0000725-E:forward()*80.00000625,-E:up())
rangerFilter(RF) L2R = rangerOffset(70,E:pos()-E:right()*45.0000725-E:forward()*80.00000625,-E:up())
rangerFilter(RF) L3R = rangerOffset(70,E:pos()+E:right()*45.0000725-E:forward()*48.00000375,-E:up())
rangerFilter(RF) L4R = rangerOffset(70,E:pos()-E:right()*45.0000725-E:forward()*48.00000375,-E:up())
rangerFilter(RF) L5R = rangerOffset(70,E:pos()+E:right()*45.0000725-E:forward()*16.00000125,-E:up())
rangerFilter(RF) L6R = rangerOffset(70,E:pos()-E:right()*45.0000725-E:forward()*16.00000125,-E:up())

rangerFilter(RF) R1R = rangerOffset(70,E:pos()+E:right()*45.0000725+E:forward()*16.00000125,-E:up())
rangerFilter(RF) R2R = rangerOffset(70,E:pos()-E:right()*45.0000725+E:forward()*16.00000125,-E:up())
rangerFilter(RF) R3R = rangerOffset(70,E:pos()+E:right()*45.0000725+E:forward()*48.00000375,-E:up())
rangerFilter(RF) R4R = rangerOffset(70,E:pos()-E:right()*45.0000725+E:forward()*48.00000375,-E:up())
rangerFilter(RF) R5R = rangerOffset(70,E:pos()+E:right()*45.0000725+E:forward()*80.00000625,-E:up())
rangerFilter(RF) R6R = rangerOffset(70,E:pos()-E:right()*45.0000725+E:forward()*80.00000625,-E:up())

holoPos(1,L1R:pos() + vec(0,0,14.999999))
holoPos(2,L2R:pos() + vec(0,0,14.999999))
holoPos(3,L3R:pos() + vec(0,0,14.999999))
holoPos(4,L4R:pos() + vec(0,0,14.999999))
holoPos(5,L5R:pos() + vec(0,0,14.999999))
holoPos(6,L6R:pos() + vec(0,0,14.999999))

holoPos(7,R1R:pos() + vec(0,0,14.999999))
holoPos(8,R2R:pos() + vec(0,0,14.999999))
holoPos(9,R3R:pos() + vec(0,0,14.999999))
holoPos(10,R4R:pos() + vec(0,0,14.999999))
holoPos(11,R5R:pos() + vec(0,0,14.999999))
holoPos(12,R6R:pos() + vec(0,0,14.999999))

ToR = (toUnit("mph",(entity():velL():y())))
Rotation = Rotation + ToR

holoAng(1,E:toWorld(ang(-Rotation,180,0)))
holoAng(2,E:toWorld(ang(Rotation,0,0)))
holoAng(3,E:toWorld(ang(-Rotation,180,0)))
holoAng(4,E:toWorld(ang(Rotation,0,0)))
holoAng(5,E:toWorld(ang(-Rotation,180,0)))
holoAng(6,E:toWorld(ang(Rotation,0,0)))
holoAng(7,E:toWorld(ang(-Rotation,180,0)))
holoAng(8,E:toWorld(ang(Rotation,0,0)))
holoAng(9,E:toWorld(ang(-Rotation,180,0)))
holoAng(10,E:toWorld(ang(Rotation,0,0)))
holoAng(11,E:toWorld(ang(-Rotation,180,0)))
holoAng(12,E:toWorld(ang(Rotation,0,0)))

L1RD = L1R:distance()
L2RD = L2R:distance()
L3RD = L3R:distance()
L4RD = L4R:distance()
L5RD = L5R:distance()
L6RD = L6R:distance()

R1RD = R1R:distance()
R2RD = R2R:distance()
R3RD = R3R:distance()
R4RD = R4R:distance()
R5RD = R5R:distance()
R6RD = R6R:distance()

Added = (L1RD+L2RD+L3RD+L4RD+L5RD+L6RD+R1RD+R2RD+R3RD+R4RD+R5RD+R6RD)/12

Height = 35

if (Active) {
    rangerFilter(E)
    rangerFilter(Seat)
    Ranger = rangerOffset(32768,Seat:pos(),Seat:toLocalAxis(Driver:eye()))
    Yaw = (Ranger:pos() - E:pos()):toAngle():yaw()
}

if (Added < Height) {
    Diff = Height - Added
    Angle = ang((R5RD+R6RD)-(L1RD+L2RD),Yaw - 180,(L1RD+L2RD)-(R5RD+R6RD))
    E:applyForce((vec(0,0,Diff * 25) - E:vel()) * E:mass() + E:forward() * (S-W) * E:mass() * 150 * (3 + Shift))
    E:applyAngForce((E:toLocal(Angle)*200 - E:angVel()*20) * shiftL(ang(E:inertia())))
}
