@name Fallout Robot
@inputs [Pod Cam EGP]:wirelink 
@outputs 
@persist Rotation AbleJump 
@trigger 
interval(16)

E = entity():isWeldedTo()
Height = 60

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

if (first() | dupefinished()) {
    holoCreate(1)
    holoModel(1,"models/xeon133/offroad/off-road-30.mdl")
    holoAng(1,E:toWorld(ang(0,90,0)))
    holoParent(1,E)
    
    holoCreate(2)
    holoPos(2,E:toWorld(vec(0,0,0)))
    holoAng(2,E:toWorld(ang(0,180,0)))
    holoAlpha(2,0)
    holoParent(2,E)
    
    holoCreate(3)
    holoPos(3,holoEntity(2):toWorld(vec(-30,0,40)))
    holoAlpha(3,0)
    holoParent(3,2)
    
    holoCreate(4)
    holoModel(4,"models/props_c17/signpole001.mdl")
    holoPos(4,E:toWorld(vec(0,-11,-43)))
    holoAng(4,E:toWorld(ang(90,90,0)))
    holoScale(4,vec(0.6,0.6,0.2))
    holoParent(4,E)
    
    holoCreate(5)
    holoMaterial(5,"models/props_combine/metal_combinebridge001")
    holoModel(5,"models/props_c17/canister01a.mdl")
    holoPos(5,E:toWorld(vec(0,10,-33)))
    holoAng(5,E:toWorld(ang(0,0,180)))
    holoScale(5,vec(0.4,0.4,0.4))
    holoParent(5,E)
    
    holoCreate(6)
    holoMaterial(6,"models/props_combine/metal_combinebridge001")
    holoModel(6,"models/props_c17/canister01a.mdl")
    holoPos(6,E:toWorld(vec(0,-10,-33)))
    holoAng(6,E:toWorld(ang(0,0,180)))
    holoScale(6,vec(0.4,0.4,0.4))
    holoParent(6,E)
    
    holoCreate(7)
    holoMaterial(7,"models/props_combine/metal_combinebridge001")
    holoModel(7,"models/props_c17/FurnitureShelf001b.mdl")
    holoPos(7,E:toWorld(vec(0,0,-21)))
    holoAng(7,E:toWorld(ang(0,0,0)))
    holoScale(7,vec(0.4,0.6,2))
    holoParent(7,E)
    
    holoCreate(8)
    holoModel(8,"models/props_c17/oildrum001.mdl")
    holoPos(8,E:toWorld(vec(0,0,-21)))
    holoAng(8,E:toWorld(ang(0,0,0)))
    holoScale(8,vec(0.2,0.2,0.2))
    holoParent(8,E)
    
    holoCreate(9)
    holoMaterial(9,"models/props_combine/metal_combinebridge001")
    holoModel(9,"models/props_c17/oildrum001.mdl")
    holoPos(9,E:toWorld(vec(0,0,-15)))
    holoAng(9,E:toWorld(ang(0,0,0)))
    holoScale(9,vec(1,1,0.2))
    holoColor(9,vec(200))
    holoParent(9,E)
    
    holoCreate(10)
    holoMaterial(10,"models/props_debris/metalwall001a")
    holoModel(10,"models/props_c17/oildrum001.mdl")
    holoPos(10,E:toWorld(vec(0,0,-6)))
    holoAng(10,E:toWorld(ang(0,0,0)))
    holoScale(10,vec(1.8,1.8,0.5))
    holoColor(10,vec(200))
    holoParent(10,E)
    
    holoCreate(11)
    holoMaterial(11,"models/props_combine/metal_combinebridge001")
    holoPos(11,E:toWorld(vec(0,0,38.5)))
    holoAng(11,E:toWorld(ang(0,0,0)))
    holoScale(11,vec(4.2,4.2,3.7))
    holoParent(11,E)
    
    holoCreate(12)
    holoMaterial(12,"models/props_combine/metal_combinebridge001")
    holoPos(12,E:toWorld(vec(0,31,46)))
    holoAng(12,E:toWorld(ang(0,0,45)))
    holoScale(12,vec(2.2,3.2,2.4))
    holoParent(12,E)
    
    holoCreate(13)
    holoMaterial(13,"models/props_combine/metal_combinebridge001")
    holoPos(13,E:toWorld(vec(0,-31,46)))
    holoAng(13,E:toWorld(ang(0,0,-45)))
    holoScale(13,vec(2.2,3.2,2.4))
    holoParent(13,E)
    
    holoCreate(14)
    holoMaterial(14,"models/props_combine/metal_combinebridge001")
    holoPos(14,E:toWorld(vec(0,48.8,55.4)))
    holoAng(14,E:toWorld(ang(0,0,0)))
    holoScale(14,vec(2.22,2.4,2.4))
    holoParent(14,E)
    
    holoCreate(15)
    holoMaterial(15,"models/props_combine/metal_combinebridge001")
    holoPos(15,E:toWorld(vec(0,-48.8,55.4)))
    holoAng(15,E:toWorld(ang(0,0,0)))
    holoScale(15,vec(2.22,2.4,2.4))
    holoParent(15,E)
    
    holoCreate(16)
    holoMaterial(16,"models/props_debris/metalwall001a")
    holoModel(16,"hq_sphere")
    holoPos(16,E:toWorld(vec(0,35,35)))
    holoAng(16,E:toWorld(ang(90,0,0)))
    holoScale(16,vec(1.5,1.5,1.5))
    holoParent(16,E)
    
    holoCreate(17)
    holoMaterial(17,"models/props_debris/metalwall001a")
    holoModel(17,"hq_sphere")
    holoPos(17,E:toWorld(vec(0,-35,35)))
    holoAng(17,E:toWorld(ang(-90,0,0)))
    holoScale(17,vec(1.5,1.5,1.5))
    holoParent(17,E)
    
    holoCreate(18)
    holoMaterial(18,"models/props_combine/metal_combinebridge001")
    holoPos(18,E:toWorld(vec(-23,0,56)))
    holoAng(18,E:toWorld(ang(0,0,0)))
    holoScale(18,vec(1,3,1))
    holoParent(18,E)
    
    holoCreate(19)
    holoModel(19,"models/cheeze/wires/speaker.mdl")
    holoPos(19,E:toWorld(vec(-28,-8,58)))
    holoAng(19,E:toWorld(ang(0,-90,90)))
    holoScale(19,vec(1,1,1))
    holoColor(19,vec(150))
    holoParent(19,E)
    
    holoCreate(20)
    holoModel(20,"models/props_interiors/Radiator01a.mdl")
    holoPos(20,E:toWorld(vec(-28.5,8,58)))
    holoAng(20,E:toWorld(ang(0,180,0)))
    holoScale(20,vec(0.2,0.2,0.1))
    holoParent(20,E)
    
    holoCreate(21)
    holoMaterial(21,"models/props_debris/metalwall001a")
    holoModel(21,"hq_stube_thin")
    holoPos(21,E:toWorld(vec(-26,0,33.5)))
    holoAng(21,E:toWorld(ang(0,90,90)))
    holoScale(21,vec(2.6,2,0.2))
    holoParent(21,E)
    
    holoClipEnabled(21,1,1)
    holoClip(21,vec(0,4.5,0),vec(0,-1,0),0)
    
    holoCreate(22)
    holoMaterial(22,"models/props_debris/metalwall001a")
    holoModel(22,"models/props_interiors/Furniture_Couch01a.mdl")
    holoPos(22,E:toWorld(vec(-25.5,0,41)))
    holoAng(22,E:toWorld(ang(90,180,0)))
    holoScale(22,vec(0.3,0.41,0.3))
    holoParent(22,E)
    
    holoCreate(23)
    holoMaterial(23,"models/props_combine/metal_combinebridge001")
    holoModel(23,"hq_cylinder")
    holoPos(23,E:toWorld(vec(-23,8,58)))
    holoAng(23,E:toWorld(ang(0,0,0)))
    holoScale(23,vec(0.3,0.3,1))
    holoParent(23,E)
    
    holoCreate(24)
    holoMaterial(24,"models/props_combine/metal_combinebridge001")
    holoModel(24,"hq_cylinder")
    holoPos(24,E:toWorld(vec(-23,8,65)))
    holoAng(24,E:toWorld(ang(0,0,0)))
    holoScale(24,vec(0.2,0.2,1))
    holoParent(24,E)
    
    holoCreate(25)
    holoMaterial(25,"models/props_combine/metal_combinebridge001")
    holoModel(25,"hq_tube_thin")
    holoPos(25,E:toWorld(vec(-23,8,74)))
    holoAng(25,E:toWorld(ang(0,90,90)))
    holoScale(25,vec(0.6,0.6,0.1))
    holoParent(25,E)
    
    Offset = holoEntity(3):pos()
    Self = holoEntity(3)
    Cam["Parent", entity] = Self
    Cam["Position", vector] = Offset
    
    EGP:egpClear()
    
    #Screen
    EGP:egpBox(1,vec2(256,341),vec2(90,92))
    EGP:egpBox(2,vec2(307,351),vec2(13,68))
    EGP:egpBox(3,vec2(205,351),vec2(13,68))
    EGP:egpCircle(4,vec2(215,316),vec2(20,20))
    EGP:egpCircle(5,vec2(295,316),vec2(20,20))
    for (Col = 1,5) {EGP:egpColor(Col,vec(150))}
    
    #Mouth
    EGP:egpBox(6,vec2(256,366),vec2(60,22))
    EGP:egpColor(6,vec(0))
    
    EGP:egpBox(7,vec2(222,370),vec2(30,22))
    EGP:egpAngle(7,-55)
    EGP:egpColor(7,vec(150))
    
    EGP:egpBox(8,vec2(290,370),vec2(30,22))
    EGP:egpAngle(8,55)
    EGP:egpColor(8,vec(150))
    
    EGP:egpBox(9,vec2(244,378),vec2(40,8))
    EGP:egpAngle(9,-25)
    EGP:egpColor(9,vec(150))
    
    EGP:egpBox(10,vec2(268,378),vec2(40,8))
    EGP:egpAngle(10,25)
    EGP:egpColor(10,vec(150))
    
    #Mouth Inside
    EGP:egpCircle(11,vec2(256,356),vec2(20,6))
    EGP:egpColor(11,vec(160))
    
    EGP:egpBox(12,vec2(256,356),vec2(59,2))
    EGP:egpColor(12,vec(0))
    
    EGP:egpBox(13,vec2(256,352),vec2(59,6))
    EGP:egpColor(13,vec(150))
    
    EGP:egpCircle(14,vec2(253,373),vec2(2,5))
    EGP:egpAngle(14,75)
    EGP:egpColor(14,vec(160))
    
    EGP:egpCircle(15,vec2(259,373),vec2(2,5))
    EGP:egpAngle(15,-75)
    EGP:egpColor(15,vec(160))
    
    EGP:egpRoundedBox(16,vec2(256,346),vec2(80,22))
    EGP:egpColor(16,vec(0))
    
    EGP:egpRoundedBox(17,vec2(256,344),vec2(78,22))
    EGP:egpColor(17,vec(150))
    
    EGP:egpBox(18,vec2(256,338),vec2(82,22))
    EGP:egpColor(18,vec(150))
    
    #Eyes
    EGP:egpCircle(19,vec2(241,330),vec2(10,15))
    EGP:egpAngle(19,-25)
    EGP:egpColor(19,vec(0))
    
    EGP:egpCircle(20,vec2(241,330),vec2(8,13))
    EGP:egpAngle(20,-25)
    EGP:egpColor(20,vec(150))
    
    EGP:egpCircle(21,vec2(241,332),vec2(3,4))
    EGP:egpAngle(21,-25)
    EGP:egpColor(21,vec(0))
    
    EGP:egpCircle(22,vec2(270,330),vec2(10,15))
    EGP:egpAngle(22,25)
    EGP:egpColor(22,vec(0))
    
    EGP:egpCircle(23,vec2(270,330),vec2(8,13))
    EGP:egpAngle(23,25)
    EGP:egpColor(23,vec(150))
    
    EGP:egpCircle(24,vec2(270,332),vec2(3,4))
    EGP:egpAngle(24,25)
    EGP:egpColor(24,vec(0))
}

rangerFilter(E)
rangerFilter(players())
Rng = rangerOffset(Height,E:pos(),-E:up())

rangerFilter(E)
Ranger = rangerOffset(999999,entity():pos(),Driver:eye())

holoPos(1,Rng:pos() + vec(0,0,17.030203))

Yaw = (Ranger:position() - entity():pos()):toAngle():yaw()

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

if ((W-S)) {holoAng(1,entity():toWorld(ang(0,0,-Rotation)))}

if (Rng:hit()) {
    Diff = Height - Rng:distance()
    E:applyForce((vec(0,0,Diff * 25) - E:vel()) * E:mass() + E:forward()*(S-W) * E:mass() * 150 * (2 + Shift))
    
    AbleJump = 1
}

if (AbleJump == 1 & changed(Space) & Space) {
    Diff = 0
    E:applyForce(E:up() * E:mass()*210)
    
    AbleJump = 0
} 

E:applyAngForce((E:toLocal(ang((S-W)*6 * (1 + Shift),Yaw + 180,0))*200 - E:angVel()*20) * shiftL(ang(E:inertia())))
