@name HoloGraphic Man Pet
@inputs P:wirelink
@outputs Pos:vector Ang:angle Parent:entity Camdist Squack
@persist Hit Distance Jump T Squack Ent:entity
@trigger

interval(1)
if(first()|duped()){
    holoCreate(2)
    holoAlpha(2,0)
    holoCreate(1)
    holoAlpha(1,0)
    holoModel(1,"cube")
    holoScale(1,vec(0.25,0.25,0.25))
    holoScale(2,vec(0.25,0.25,0.25))
    holoCreate(3)
    holoModel(3,"models/seagull.mdl")
    holoScale(3,vec(1,1,1))
     Squack = 1
    
}
E = entity():isWeldedTo()
D1 = E:driver()

W = P["W",number]
A = P["A",number]
S = P["S",number]
D = P["D",number]
Space = P["Space",number]
Active = P["Active",number]
Shift = P["Shift",number]
NextWeapon = P["NextWeapon",number]
PrevWeapon = P["PrevWeapon",number]
Mouse1 = P["Mouse1",number]

holoPos(3,holoEntity(1):pos()-holoEntity(1):up()*7)
holoAng(3,ang(0,holoEntity(1):angles():yaw(),0))

Pos = holoEntity(3):pos()+(D1:eye()*Camdist*5-D1:up())*(Camdist*5)+vec(0,0,25)
Ang = D1:eyeAngles()
holoAng(1,D1:eyeAngles())
Parent = holoEntity(1)

rangerFilter(E)
Ranger = rangerOffset(10,holoEntity(1):pos(),-E:up())
holoPos(2,Ranger:position())
Hit = Ranger:hit()
Distance = Ranger:distance()

if(!Hit&!Space){
    holoPos(1,holoEntity(1):pos()-E:up()*5)
}
if(!Hit){
    holoPos(1,holoEntity(1):pos()+vec(D1:eye():x(),D1:eye():y(),0))
}
if(Distance<6.03 & Hit &!Space){
    holoPos(1,holoEntity(1):pos()+E:up()*3)
}
if(!Active){
    holoPos(1,entity():pos()+E:right()*10)
    T = 0
}

if(W&Hit){
    holoPos(1,holoEntity(1):pos()+vec(D1:eye():x(),D1:eye():y(),0)*2)
    T += 1
    
}
if(changed(W) & W & !Space){
    holoAnim(3,4)
}
if((changed(W)|changed(S)|changed(Space))&!W & !S & !Space){
    holoAnim(3,2)
}
if(changed(Space)&Space){
    holoAnim(3,0)
}
if(Space){
        holoPos(1,holoEntity(1):pos()+vec(0,0,D1:eye():z())*5*(W))        
}

if(changed(S) & S & !Space){
    holoAnim(3,4)
}

if(S & !Space&Hit){
    holoPos(1,holoEntity(1):pos()-vec(D1:eye():x(),D1:eye():y(),0)*2)
    T -= 1
}
if(changed(Mouse1)&Mouse1&Squack){
    holoEntity(1):soundPlay(1,100,"ambient/bumper_car_quack9.wav")
    timer("S",1000)
    Squack = 0
    Ent = propSpawn("models/props_phx/misc/egg.mdl",holoEntity(3):pos()-vec(0,0,0),holoEntity(3):angles(),0)
    Ent:applyForce(holoEntity(3):forward()*10000000*Ent:mass())
}
if(clk("S")){
    Squack = 1
    soundStop(1)
}
if(A){
    holoPos(1,holoEntity(1):pos()-D1:right()*2)
}
if(D){
    holoPos(1,holoEntity(1):pos()+D1:right()*2)
}
if(Shift & W){
    holoPos(1,holoEntity(1):pos()+vec(D1:eye():x(),D1:eye():y(),0)*3)
}
if(Shift & S){
    holoPos(1,holoEntity(1):pos()-vec(D1:eye():x(),D1:eye():y(),0)*3)
}
if(Space){
    Jump = 1
    timer("Timer",100)
}
if(NextWeapon|PrevWeapon){
    Camdist += PrevWeapon-NextWeapon
}
