@name FUCKING RACER
@inputs Pod:wirelink
@outputs Speed Campos:vector Camang:angle Sidespeed Maxspeed Str
@outputs Rangerdist
@persist E:entity Active Left Right Forward Back
@persist Ranger:ranger Rangerdist Fall Forwardranger:ranger
@persist Backranger:ranger Sidespeed Leftranger:ranger Selected
@persist Rightranger:ranger Died DiedAlpha Diedsfx
@persist Soundsfx Rear Crashspeed Vehicle:entity Steering
@persist Maxhealth Health
@trigger none
interval(1000/30)
Active=Pod["Active",number]
Left=Pod["A",number]
Right=Pod["D",number]
Forward=Pod["W",number]
Back=Pod["S",number]
Rear=Pod["Mouse2",number]
if (duped()) {reset()}
if (!Selected) {if (Forward) {Maxspeed=500,Crashspeed=500,Selected=1
    Steering=5
    Maxhealth=50
    Health=50
holoAlpha(2,255)
holoAlpha(3,255)
holoAlpha(4,255)
holoAlpha(5,255)
holoAlpha(6,255)
holoAlpha(7,255)
holoAlpha(8,255)
holoAlpha(9,255)
E:soundPlay(2,3,"ambient/energy/whiteflash.wav")
timer("Spawnfx",1500)
} elseif (Left) {Maxspeed=2000,Crashspeed=2000,Selected=1
Steering=5
Maxhealth=1000
Health=1000
E:soundPlay(2,3,"ambient/energy/whiteflash.wav")
holoColor(2,vec(0,50,0))
holoColor(5,vec(0,50,0))
holoColor(6,vec(0,50,0))
holoColor(7,vec(0,50,0))
holoAlpha(2,255)
holoAlpha(3,255)
holoAlpha(4,255)
holoAlpha(5,255)
holoAlpha(6,255)
holoAlpha(7,255)
holoAlpha(8,255)
holoAlpha(9,255)
timer("Spawnfx",1500)} elseif (Right) {Maxspeed=9
Crashspeed=10,Selected=1,Steering=6
Maxhealth=100
Health=100
E:soundPlay(2,3,"ambient/energy/whiteflash.wav")
holoColor(2,vec(0,0,0))
holoColor(5,vec(0,0,0))
holoColor(6,vec(0,0,0))
holoColor(7,vec(0,0,0))
holoAlpha(2,255)
holoAlpha(3,255)
holoAlpha(4,255)
holoAlpha(5,255)
holoAlpha(6,255)
holoAlpha(7,255)
holoAlpha(8,255)
holoAlpha(9,255)
timer("Spawnfx",1500)}
Campos=entity():toWorld(vec(0,0,50))
Camang=ang(90,0,0)}
if (first()) {
    Selected = 0
    Vehicle = Pod["Entity",entity]
    Vehicle:hintDriver("W: Standard, SPEED: 10 STEERING: 5 DURABILITY: 50,6",10)
    Vehicle:hintDriver("A: Fast, SPEED: 11 STEERING: 4 DURABILITY: 30,2", 10)
    Vehicle:hintDriver("D: Safe, SPEED: 9 STEERING: 6 DURABILITY: 100,10", 10)
    
    holoCreate(1,entity():pos()+vec(0,0,15))
    holoAng(1,entity():angles():setPitch(0))
holoScale(1,vec(0.1,0.1,0.1))
E=holoEntity(1)
holoAlpha(1,0)
holoCreate(2,E:pos())
holoScale(2,vec(1,0.25,0.25))
holoParent(2,E)
holoMaterial(2,"models/props_combine/stasisshield_sheet")
holoAlpha(2,0)
holoCreate(3,E:toWorld(vec(-4.5,-2.5,0)),vec(0.6,0.2,0.2))
holoParent(3,holoEntity(2))
holoMaterial(3,"models/props_combine/stasisshield_sheet")
holoEntity(3):setTrails(5,5,1,"trails/laser",vec(255,255,255),150)
holoAlpha(3,0)
holoCreate(4,E:toWorld(vec(-4.5,2.5,0)),vec(0.6,0.2,0.2))
holoParent(4,holoEntity(2))
holoMaterial(4,"models/props_combine/stasisshield_sheet")
holoEntity(4):setTrails(5,5,1,"trails/laser",vec(255,255,255),150)
holoAlpha(4,0)
holoCreate(5,E:toWorld(vec(-2,0,1.75)),vec(0.2,0.1,0.05))
holoParent(5,holoEntity(2))
holoMaterial(5,"models/props_combine/stasisshield_sheet")
holoAlpha(5,0)
holoCreate(6,E:toWorld(vec(-4.5,-4.25,0)),vec(0.5,0.15,0.05))
holoParent(6,holoEntity(2))
holoMaterial(6,"models/props_combine/stasisshield_sheet")
holoAlpha(6,0)
holoCreate(7,E:toWorld(vec(-4.5,4.25,0)),vec(0.5,0.15,0.05))
holoParent(7,holoEntity(2))
holoMaterial(7,"models/props_combine/stasisshield_sheet")
holoAlpha(7,0)
holoCreate(8,E:toWorld(vec(-4.5,-2.5,1.5)),vec(0.4,0.05,0.15))
holoParent(8,holoEntity(2))
holoMaterial(8,"models/props_combine/stasisshield_sheet")
holoAlpha(8,0)
holoCreate(9,E:toWorld(vec(-4.5,2.5,1.5)),vec(0.4,0.05,0.15))
holoParent(9,holoEntity(2))
holoMaterial(9,"models/props_combine/stasisshield_sheet")
holoAlpha(9,0)
}
if (clk("Spawnfx")) {
    holoMaterial(2,"models/shiny")
    holoMaterial(3,"models/shiny")
    holoMaterial(4,"models/shiny")
    holoMaterial(5,"models/shiny")
    holoMaterial(6,"models/shiny")
    holoMaterial(7,"models/shiny")
    holoMaterial(8,"models/shiny")
    holoMaterial(9,"models/shiny")
}
if (Speed>0.1|Speed<-0.1) {
    if (!Soundsfx) {
        E:soundPlay(5,0,"ambient/machines/lab_loop1.wav")
    Soundsfx=1}
    soundPitch(5,abs(Speed/Maxspeed)*1050)}
else {soundStop(5),Soundsfx=0}
if (Selected) {
    rangerHitWater(1)
    rangerDefaultZero(0)
Ranger=rangerOffset(20, E:pos(),vec(0,0,-1))
Forwardranger=rangerOffset(20,E:pos(),E:eye())
Backranger=rangerOffset(20,E:pos(),-E:eye())
Leftranger=rangerOffset(20,E:pos(),-E:right())
Rightranger=rangerOffset(20,E:pos(),E:right())
if (Speed|Sidespeed) {holoPos(1,E:toWorld(vec(Speed,Sidespeed,0)))}
if (Forwardranger:distance()<12&!Died) {if (Speed>Crashspeed) {
#Pod["Terminate",number]=1
Died=1} else {Health-=abs(Speed),Speed=-3
#E:soundPlay(6,0.7,"vehicles/v8/vehicle_impact_heavy3.wav")
}}
if (Backranger:distance()<12&!Died) {
    Health-=abs(Speed),Speed=3
    #E:soundPlay(6,0.7,"vehicles/v8/vehicle_impact_heavy3.wav")
    }
if (Leftranger:distance()<12&!Died) {
    Health-=abs(Speed*0.5),Sidespeed=-3
    #E:soundPlay(6,0.7,"vehicles/v8/vehicle_impact_heavy3.wav")
    }
if (Rightranger:distance()<12&!Died) {
    Health-=abs(Speed*0.5),Sidespeed=3
    #E:soundPlay(6,0.7,"vehicles/v8/vehicle_impact_heavy3.wav")
    }
if (Sidespeed>0) {Sidespeed-=0.1} elseif (Sidespeed<0) {
Sidespeed+=0.1}
if (Health<0) {Died=1}
if (Forward&Speed<Maxspeed) {Speed+=0.1} 
elseif (Speed>0) {Speed-=0.1}
if (Back&Speed>-Maxspeed/2) {Speed-=0.1} 
elseif (Speed<0) {Speed+=0.1}
if (Left&!Died) {holoAng(1,E:angles()+ang(0,
    Steering-Steering*abs((Speed/Maxspeed)*0.2),0))
    if (holoEntity(2):angles():roll()>-40) {
    holoAng(2,holoEntity(2):angles()+ang(0,0,-4))}
if (E:angles():yaw()>=360) {holoAng(1,E:angles()-ang(0,360,0))}}
if (Right&!Died) {holoAng(1,E:angles()-ang(0,
    Steering-Steering*abs((Speed/Maxspeed)*0.2),0))
    if (holoEntity(2):angles():roll()<40) {
    holoAng(2,holoEntity(2):angles()+ang(0,0,4))}
if (E:angles():yaw()<=0) {holoAng(1,E:angles()+ang(0,360,0))}}
Str=Steering-Steering*abs((Speed/Maxspeed)*0.2)
if (!Right&!Left&!Died) {
if (holoEntity(2):angles():roll()>2) {
    holoAng(2,holoEntity(2):angles()+ang(0,0,-2))} 
    elseif
    (holoEntity(2):angles():roll()<-2) {
holoAng(2,holoEntity(2):angles()+ang(0,0,+2))}
if (holoEntity(2):angles():roll()<4&
holoEntity(2):angles():roll()>-4) {
holoAng(2,ang(0,holoEntity(2):angles():yaw(),0))}}
Rangerdist=Ranger:distance()
if (Ranger:entity():getColor()==vec(0,255,0)) {Speed=20}
if (Rear) {
Camang=E:angles()+ang(0,180,0)
Campos = E:pos()+vec(0,0,8)+E:eye()*22
} else
{Camang=E:angles():setRoll(holoEntity(2):angles():roll()/3)
Campos = E:pos()+vec(0,0,8)-E:eye()*22}
if (Rangerdist>=10) {
    holoPos(1,E:pos()-vec(0,0,-Fall))
    Fall-=0.1
    if (Fall<-7.5) {Died=1}
    }
elseif
(Rangerdist<9) {
    holoPos(1,E:pos()+vec(0,0,10-Rangerdist))
    Fall=0
    }
else {Fall=0}
    
    
if (Died) {if (!Diedsfx) {holoCreate(1337,E:pos(),vec(3,3,3))
    E:soundPlay(1,1,"ambient/explosions/explode_9.wav")
    DiedAlpha = 250
    holoAlpha(1,0)
    holoAlpha(2,0)
    holoAlpha(3,0)
    holoAlpha(4,0)
    holoAlpha(5,0)
    holoAlpha(6,0)
    holoAlpha(7,0)
    holoAlpha(8,0)
    holoAlpha(9,0)
    holoModel(1337,"hqsphere2")
    holoColor(1337,vec(255,100,0))
    Diedsfx=1}
    Speed=0
    Sidespeed=0
if (DiedAlpha>0) {DiedAlpha-=10}
holoAlpha(1337,DiedAlpha)
if (DiedAlpha==0) {reset()}}}
