@name portals by maiha
@inputs 
@outputs 
@persist Key Key2 Use [Ent1 Ent2]:entity
@trigger 

interval(10)

Key = owner():keyAttack2()
Key2 = owner():keyAttack1()
Use = owner():keyUse()

if ($Use & Use)
{
    holoDeleteAll()
    owner():soundPlay(10,0,"weapons/portalgun/portal_close" + randint(1,2) + ".wav")
} 


if($Key & Key)
{
    owner():soundPlay(0,0,"weapons/portalgun/portalgun_shoot_red1.wav")
    holoCreate(1)
    holoScale(1,vec(10,5,0.1))
    holoModel(1,"hqsphere2")
    holoColor(1,vec(255,128,0))
    holoPos(1,owner():aimPos() + vec(0,0,0))
    holoAng(1,owner():aimNormal():toAngle() + ang(90,0,0))
    holoCreate(2)
    holoEntity(2):soundPlay(6,0,"weapons/portalgun/portal_open" + randint(1,3) + ".wav")
    holoScale(2,vec(7,3,0.2))
    holoModel(2,"hqsphere2")
    holoColor(2,vec(150,75,0))
    holoPos(2,owner():aimPos() + vec(0,0,0))
    holoAng(2,owner():aimNormal():toAngle() + ang(90,0,0))
    Ent1 = owner():aimEntity()
}

if($Key2 & Key2)
{
    owner():soundPlay(0,0,"weapons/portalgun/portalgun_shoot_blue1.wav")
    holoCreate(3)
    holoScale(3,vec(10,5,0.1))
    holoModel(3,"hqsphere2")
    holoColor(3,vec(0,128,255))
    holoPos(3,owner():aimPos() + vec(0,0,0))
    holoAng(3,owner():aimNormal():toAngle() + ang(90,0,0))
    holoCreate(4)
    holoEntity(4):soundPlay(7,0,"weapons/portalgun/portal_open" + randint(1,3) + ".wav")
    holoScale(4,vec(7,3,0.2))
    holoModel(4,"hqsphere2")
    holoColor(4,vec(0,75,150))
    holoPos(4,owner():aimPos() + vec(0,0,0))
    holoAng(4,owner():aimNormal():toAngle() + ang(90,0,0))
    Ent2 = owner():aimEntity()
}

if(owner():pos():distance(holoEntity(1):pos()) < 75)
{
    owner():tele(holoEntity(4):pos() + holoEntity(4):up() * 100)
    holoEntity(4):soundPlay(5,0,"player/portal_enter" + randint(1,2) + ".wav")
}
if(owner():pos():distance(holoEntity(3):pos()) < 75)
{
    owner():tele(holoEntity(1):pos() + holoEntity(2):up() * 100)
    holoEntity(1):soundPlay(5,0,"player/portal_exit" + randint(1,2) + ".wav")
}

if(first())
{
    owner():soundPlay("gogogo",0,"ambient/wind/tube_suck.wav")
}

soundPitch("gogogo",100)
soundVolume("gogogo",owner():vel():length() / 5000 * !owner():isOnGround())
