@name Robotboy655's Portal Gun
@inputs 
@outputs 
@persist Player:entity RedGo BlueGo RedShot BlueShot [BluePos BluePos2 BlueEye RedPos RedPos2 RedEye]:vector [BlueAng RedAng]:angle 
@trigger 

interval(10)


if(first())
{
    Player = owner()
    
    holoCreate(6551):setTrails(24,0,1,"trails/laser",vec(255,128,0),255)
    holoModel(6551,"hqsphere2")
    holoColor(6551,vec(255,128,0))
    holoScale(6551,vec(0,0,0))
    
    holoCreate(6552)
    holoModel(6552,"hqtorus2")
    holoColor(6552,vec(255,128,0))
    holoScale(6552,vec(0,0,0))
    
    holoCreate(6553):setTrails(24,0,1,"trails/laser",vec(0,128,255),255)
    holoModel(6553,"hqsphere2")
    holoColor(6553,vec(0,128,255))
    holoScale(6553,vec(0,0,0))
    
    holoCreate(6554)
    holoModel(6554,"hqtorus2")
    holoColor(6554,vec(0,128,255))
    holoScale(6554,vec(0,0,0))
}

if(Player:keyAttack1() & RedShot == 0)
{
    Player:soundPlay("portalopen2",0,"weapons/portalgun/portalgun_shoot_red1.wav")
    
    holoScaleUnits(6551,vec(16,16,16))
    RedPos = Player:pos() + vec(0,0,50) + Player:eye() * 50
    RedEye = Player:eye()
    holoPos(6551,RedPos)
    
    RedGo = 1
    RedShot = 1
    RedPos2 = Player:aimPos()
    RedAng = Player:aimNormal():toAngle() + ang(90,0,0)
}
elseif(Player:keyAttack2() & BlueShot == 0)
{
    Player:soundPlay("portalopen2",0,"weapons/portalgun/portalgun_shoot_blue1.wav")
    
    
    holoScaleUnits(6553,vec(16,16,16))
    BluePos = Player:pos() + vec(0,0,50) + Player:eye() * 50
    BlueEye = Player:eye()
    holoPos(6553,BluePos)
    
    BlueGo = 1
    BlueShot = 1
    BlueAng = Player:aimNormal():toAngle() + ang(90,0,0)
    BluePos2 = Player:aimPos()
}

if(RedGo == 1)
{
    RedPos = RedPos + RedEye * 10
    holoPos(6551,RedPos)
}
if(BlueGo == 1)
{
    BluePos = BluePos + BlueEye * 10
    holoPos(6553,BluePos)
}

if(!holoEntity(6551):pos():isInWorld())
{
    if(RedShot == 1)
    {
        RedShot = 0
        holoEntity(6552):soundPlay(17,0,"weapons/portalgun/portal_open"+randint(1,3)+".wav")
    }
    
    RedGo = 0
    holoScale(6551,vec(0,0,0))
    
    holoPos(6552,RedPos2)
    holoScaleUnits(6552,vec(150,75,1))
    holoAng(6552,RedAng)
}
if(!holoEntity(6553):pos():isInWorld())
{
    if(BlueShot == 1)
    {
        BlueShot = 0
        holoEntity(6554):soundPlay(17,0,"weapons/portalgun/portal_open"+randint(1,3)+".wav")
    }
        
    BlueGo = 0
    holoScale(6553,vec(0,0,0))
    
    holoPos(6554,BluePos2)
    holoScaleUnits(6554,vec(150,75,1))
    holoAng(6554,BlueAng)
}
