@name Aquarium (Chiss & Maso)
@inputs 
@outputs
@persist E:entity SV:vector [A SA]:angle Start
#Fish 1 Persist
@persist Waypoint1:vector FishPos1:vector Bearing1 Elevation1 WaypointDistance1 Tail1 Mod1
#Fish 2 Persist
@persist Waypoint2:vector FishPos2:vector Bearing2 Elevation2 WaypointDistance2 Tail2 Mod2
#Fish 3 Persist
@persist Waypoint3:vector FishPos3:vector Bearing3 Elevation3 WaypointDistance3 Tail3 Mod3
#Fish 4 Persist
@persist Waypoint4:vector FishPos4:vector Bearing4 Elevation4 WaypointDistance4 Tail4 Mod4
#Fish 5 Persist
@persist Waypoint5:vector FishPos5:vector Bearing5 Elevation5 WaypointDistance5 Tail5 Mod5
#Bubble
@persist X B0 B1 B2 B3 B4 B5 B6 B7 Total
@trigger 

if(duped()) {reset()}
if(first()) {
    
    Frame = "models/props_canal/metalwall005b"
    runOnTick(1)
    E = entity()
    E:setAlpha(0)
    soundPurge()
    #Base
    holoCreate(0)
    holoAng(0,E:angles())
    holoScaleUnits(0,vec(48,90,6))
    holoParent(0,E)
    holoMaterial(0,Frame)

    #Leg1
    holoCreate(1)
    holoScaleUnits(1,vec(6,6,75))    
    holoParent(1,E)
    holoPos(1,E:pos() + E:forward()*20.5 + E:right()*40.5 + E:up()*10)
    holoMaterial(1,Frame)

    #Leg2
    holoCreate(2)
    holoScaleUnits(2,vec(6,6,75))    
    holoParent(2,E)
    holoPos(2,E:pos() - E:forward()*20.5 + E:right()*40.5 + E:up()*10)
    holoMaterial(2,Frame)

    #Leg3
    holoCreate(3)
    holoScaleUnits(3,vec(6,6,75))    
    holoParent(3,E)
    holoPos(3,E:pos() - E:forward()*20.5 - E:right()*40.5 + E:up()*10)
    holoMaterial(3,Frame)

    #Leg4
    holoCreate(4)
    holoScaleUnits(4,vec(6,6,75))    
    holoParent(4,E)
    holoPos(4,E:pos() + E:forward()*20.5 - E:right()*40.5 + E:up()*10)
    holoMaterial(4,Frame)

    #Top1
    holoCreate(5)
    holoAng(5,E:angles())
    holoScaleUnits(5,vec(48.5,6,6))
    holoParent(5,E)
    holoPos(5,E:pos() + E:up()*43.25 - E:right()*40.5)
    holoMaterial(5,Frame)

    #Top2
    holoCreate(6)
    holoAng(6,E:angles())
    holoScaleUnits(6,vec(48.5,6,6))
    holoParent(6,E)
    holoPos(6,E:pos() + E:up()*43.25 + E:right()*40.5)
    holoMaterial(6,Frame)

    #Top3
    holoCreate(7)
    holoAng(7,E:angles())
    holoScaleUnits(7,vec(6,90,6))
    holoParent(7,E)
    holoPos(7,E:pos() + E:up()*43.25 + E:forward()*20.5)
    holoMaterial(7,Frame)

    #Top4
    holoCreate(8)
    holoAng(8,E:angles())
    holoScaleUnits(8,vec(6,90,6))
    holoParent(8,E)
    holoPos(8,E:pos() + E:up()*43.25 - E:forward()*20.5)
    holoMaterial(8,Frame)


    #Water
    holoCreate(9)
    holoAng(9,E:angles())
    holoScaleUnits(9,vec(37.5,79.5,0.1))
    holoParent(9,E)
    holoPos(9,E:pos() + E:up()*35)
    holoMaterial(9,"models/shadertest/predator")

    #Water Cube Bubbles
    holoCreate(10)
    holoAng(10,E:angles())
    holoScaleUnits(10,vec(37.5,79.5,38))
    holoParent(10,E)
    holoAlpha(10,20)
    holoPos(10,E:pos() + E:up()*17)
    holoMaterial(10,"models/props_lab/warp_sheet")   
    
    #Water Cube Blue Tinge
    holoCreate(11)
    holoAng(11,E:angles())
    holoScaleUnits(11,vec(37.5,79.5,38))
    holoParent(11,E)
    holoColor(11,vec(100,150,255))
    holoAlpha(11,30)
    holoPos(11,E:pos() + E:up()*17)
    holoMaterial(11,"models/debug/debugwhite")
    
    #Sand Cube
    holoCreate(12)
    holoAng(12,E:angles())
    holoScaleUnits(12,vec(37.5,79.5,3))
    holoParent(12,E)
    holoColor(12,vec(200,200,120))
    holoPos(12,E:pos() + E:up()*2)
    holoMaterial(12,"models/XQM/Rails/gumball_1")  

    #Glass1
    holoCreate(13)
    holoAng(13,E:angles())
    holoScaleUnits(13,vec(40,3,40))
    holoParent(13,E)
    holoPos(13,E:pos() + E:up()*22 - E:right()*39.5)
    holoAlpha(13,150)
    holoMaterial(13,"models/props_combine/health_charger_glass")

    #Glass1
    holoCreate(14)
    holoAng(14,E:angles())
    holoScaleUnits(14,vec(40,3,40))
    holoParent(14,E)
    holoPos(14,E:pos() + E:up()*22 + E:right()*39.5)
    holoAlpha(14,150)
    holoMaterial(14,"models/props_combine/health_charger_glass")

    #Glass3
    holoCreate(15)
    holoAng(15,E:angles())
    holoScaleUnits(15,vec(3,84,40))
    holoParent(15,E)
    holoPos(15,E:pos() + E:up()*22 + E:forward()*19.5)
    holoAlpha(15,150)
    holoMaterial(15,"models/props_combine/health_charger_glass")

    #Background
    holoCreate(16)
    holoAng(16,E:angles())
    holoScaleUnits(16,vec(5,84,40))
    holoParent(16,E)
    holoPos(16,E:pos() + E:up()*22 - E:forward()*20)
    holoMaterial(16,"models/XQM/woodplanktexture")

    
    #Fish 1
    holoCreate(17,entity():pos(),vec(0.45,0.2,0.3),ang(0,0,0),vec(235,205,0))
    holoModel(17,"hqsphere2")
    holoMaterial(17,"phoenix_storms/metalfloor_2-3")
    holoParent(17,E)
    holoCreate(18,entity():pos()+vec(-2.1,0,0),vec(0.25,0.032,0.3),ang(90,0,0),vec(235,205,0))
    holoModel(18,"prism")
    holoMaterial(18,"phoenix_storms/metalfloor_2-3")
    holoParent(18,17)
    holoCreate(19,entity():pos()+vec(2,0,0),vec(0.16,0.05,0.05),ang(0,90,0),vec(10,10,10))
    holoModel(19,"icosphere3")
    holoParent(19,17)
    holoCreate(20,entity():pos()+vec(2,0,-0.5),vec(0.1,0.07,0.1),ang(-5,0,0),vec(255,100,100))
    holoModel(20,"torus")
    holoMaterial(20,"models/props_c17/furniturefabric002a")
    holoParent(20,17)
    holoCreate(21,entity():pos()+vec(2,0,-0.55),vec(0.1,0.07,0.1),ang(0,0,0),vec(255,100,100))
    holoModel(21,"torus")
    holoMaterial(21,"models/props_c17/furniturefabric002a")
    holoParent(21,17)
    
    #Fish 2
    holoCreate(22,entity():pos(),vec(0.45,0.1,0.15),ang(0,0,0),vec(235,205,0))
    holoModel(22,"hqsphere2")
    holoMaterial(22,"models/props_c17/furniturefabric003a")
    holoParent(22,E)
    holoCreate(23,entity():pos()+vec(-2.1,0,0),vec(0.2,0.032,0.2),ang(90,0,0),vec(235,205,0))
    holoModel(23,"prism")
    holoMaterial(23,"models/props_c17/furniturefabric003a")
    holoParent(23,22)
    holoCreate(24,entity():pos()+vec(2,0,0),vec(0.1,0.05,0.05),ang(0,90,0),vec(10,10,10))
    holoModel(24,"icosphere3")
    holoParent(24,22)
    
    #Fish 3
    holoCreate(25,entity():pos(),vec(0.35,0.08,0.10),ang(0,0,0),vec(235,205,0))
    holoModel(25,"hqsphere2")
    holoMaterial(25,"models/props_c17/metalladder003")
    holoColor(25,vec(80,120,250))
    holoParent(25,E)
    holoCreate(26,entity():pos()+vec(-2.1,0,0),vec(0.14,0.032,0.14),ang(90,0,0),vec(235,205,0))
    holoModel(26,"prism")
    holoMaterial(26,"models/props_c17/metalladder003")
    holoColor(26,vec(90,120,250))
    holoParent(26,25)
    holoCreate(27,entity():pos()+vec(1,0,0),vec(0.08,0.05,0.05),ang(0,90,0),vec(10,10,10))
    holoModel(27,"icosphere3")
    holoParent(27,25)

    #Old Fish Textures
    #models/weapons/v_crossbow/rebar_glow
    #models/XQM/WoodTexture_1
    SV = E:pos()
    SA = E:angles()
    
    timer("wait",1000)
    timer("wait2",2000)
}

if(clk("wait")) {
    #Fish 4
    holoCreate(28,entity():pos(),vec(0.45,0.1,0.15),ang(0,0,0),vec(235,205,0))
    holoModel(28,"hqsphere2")
    holoMaterial(28,"models/XQM/Rails/gumball_1")
    holoColor(28,vec(240,180,50))
    holoParent(28,E)
    holoCreate(29,entity():pos()+vec(-2.1,0,0),vec(0.2,0.032,0.2),ang(90,0,0),vec(235,205,0))
    holoModel(29,"prism")
    holoMaterial(29,"models/XQM/Rails/gumball_1")
    holoColor(29,vec(255,100,50))
    holoParent(29,28)
    holoCreate(30,entity():pos()+vec(2,0,0),vec(0.1,0.05,0.05),ang(0,90,0),vec(10,10,10))
    holoModel(30,"icosphere3")
    holoParent(30,28)
    
    ########
    #Filter#
    ########

    #Filter Sphere
    holoCreate(31)
    holoModel(31,"hqsphere2")
    holoAng(31,angnorm(E:angles()))
    holoScaleUnits(31,vec(10,10,8))
    holoPos(31,E:pos() + E:up()*35 - E:right()*31 - E:forward()*12)
    holoMaterial(31,"models/XQM/Rails/gumball_1")  
    holoColor(31,vec(200,120,120))
    
    #Filter Tube
    holoCreate(32)
    holoModel(32,"hqtorus2")
    holoAng(32,angnorm(angnorm(E:angles()+ang(vec(0,270,0)))))
    holoScaleUnits(32,vec(5,5,80))
    holoParent(32,31)
    holoPos(32,E:pos() + E:up()*24 - E:right()*31 - E:forward()*12)
    holoMaterial(32,"models/XQM/Rails/gumball_1") 
    holoColor(32,vec(150,150,150)) 
    holoAlpha(32,150)
}

if(clk("wait2")) {
    

    
    ########
    #Plants#
    ########
    
    #Plant 1
    holoCreate(33)
    holoModel(33,"dome2")
    holoScale(33,vec(0.26,0.26,2.7))
    holoParent(33,E)
    holoMaterial(33,"models/props/de_inferno/bushgreen")

    holoCreate(34)
    holoModel(34,"dome2")
    holoScale(34,vec(0.23,0.23,2.3))
    holoParent(34,E)
    holoMaterial(34,"models/props/de_inferno/bushgreen")

    holoCreate(35)
    holoModel(35,"dome2")
    holoScale(35,vec(0.2,0.2,2))
    holoParent(35,E)
    holoMaterial(35,"models/props/de_inferno/bushgreen")
    
    #Plant 2
    holoCreate(36)
    holoModel(36,"dome2")
    holoScale(36,vec(0.2,0.2,2.1))
    holoParent(36,E)
    holoMaterial(36,"models/props/de_inferno/bushgreen")

    holoCreate(37)
    holoModel(37,"dome2")
    holoScale(37,vec(0.17,0.17,1.7))
    holoParent(37,E)
    holoMaterial(37,"models/props/de_inferno/bushgreen")

    holoCreate(38)
    holoModel(38,"dome2")
    holoScale(38,vec(0.14,0.14,1.4))
    holoParent(38,E)
    holoMaterial(38,"models/props/de_inferno/bushgreen")
    
    #Plant 3
    holoCreate(39)
    holoModel(39,"dome2")
    holoScale(39,vec(0.23,0.23,2.4))
    holoParent(39,E)
    holoMaterial(39,"models/props/de_inferno/bushgreen")

    holoCreate(40)
    holoModel(40,"dome2")
    holoScale(40,vec(0.2,0.2,2))
    holoParent(40,E)
    holoMaterial(40,"models/props/de_inferno/bushgreen")

    holoCreate(41)
    holoModel(41,"dome2")
    holoScale(41,vec(0.17,0.17,1.7))
    holoParent(41,E)
    holoMaterial(41,"models/props/de_inferno/bushgreen")
        
    #######
    #Sound#
    #######     
    soundPlay(0,0,"ambient/water/underwater.wav")
    soundVolume(0,0.6)
        
    Start = 1
}

if(Start) {
    if(!E:isPlayerHolding()) {
        R = rangerOffset(E:pos(),E:pos() - vec(0,0,99999))
        V = (vec(SV:x(),SV:y(),R:position():z() + 25) - E:massCenter())*25
        applyForce((V-E:vel())*E:mass())
    
        A = angnorm(ang(0,SA:yaw(),0) - E:angles())*5
        applyAngForce(A + $A*5)
    }
    else{
        SV = E:pos()
        SA = E:angles()
    }

    #################
    #Fish Movement 1#
    #################

    #Set new waypoint when fish reaches old one
    WaypointDistance1 = abs((holoEntity(17):pos() - (entity():pos()+Waypoint1)):length())
    if (WaypointDistance1 < 10)  {Waypoint1 = random(-8,8)*entity():forward() + random(-35,35)*entity():right() + random(8,26)*entity():up()}


    #Get Bearing/Elevation to Waypoint and turn to it
    Bearing1 = holoEntity(17):bearing(entity():pos() + Waypoint1)
    Elevation1 = holoEntity(17):elevation(entity():pos() + Waypoint1)

    if (abs(Bearing1) > 3 )      {holoAng(17,holoEntity(17):angles()+ang(vec(0,-sign(Bearing1),sign(Bearing1)/10)))}
    else                        {holoAng(17,holoEntity(17):angles()+ang(vec(0,0,-sign(holoEntity(17):angles():roll())/10)))}
    if (abs(Elevation1) > 2 )    {holoAng(17,holoEntity(17):angles()+ang(vec(-sign(Elevation1)/3,0,0)))}

    #Clamp Pitch
    holoAng(17,ang(vec(clamp(holoEntity(17):angles():pitch(),-30,30),holoEntity(17):angles():yaw(), clamp(holoEntity(17):angles():roll(),-20,20))))

    FishPos1 = FishPos1 + holoEntity(17):forward()/random(10,20)
    holoPos(17,entity():pos()+FishPos1)

    #Tail Movement
    if (Tail1 >= 30){Mod1 = -random(0.3,3)}
    if (Tail1 <= 0) {Mod1 =  random(0.3,3)}
    Tail1 += Mod1
    holoAng(18,holoEntity(17):angles() + ang(90,0,Tail1-15))



    #################
    #Fish Movement 2#
    #################

    #Set new waypoint when fish reaches old one
    WaypointDistance2 = abs((holoEntity(22):pos() - (entity():pos()+Waypoint2)):length())
    if (WaypointDistance2 < 10)  {Waypoint2 = random(-6,6)*entity():forward() + random(-35,35)*entity():right() + random(10,24)*entity():up()}


    #Get Bearing/Elevation to Waypoint and turn to it
    Bearing2 = holoEntity(22):bearing(entity():pos() + Waypoint2)
    Elevation2 = holoEntity(22):elevation(entity():pos() + Waypoint2)

    if (abs(Bearing2) > 3 )      {holoAng(22,holoEntity(22):angles()+ang(vec(0,-sign(Bearing2)*1.5,sign(Bearing2)/6)))}
    else                         {holoAng(22,holoEntity(22):angles()+ang(vec(0,0,-sign(holoEntity(22):angles():roll())/6)))}
    if (abs(Elevation2) > 2 )    {holoAng(22,holoEntity(22):angles()+ang(vec(-sign(Elevation2)/3,0,0)))}

    #Clamp Pitch
    holoAng(22,ang(vec(clamp(holoEntity(22):angles():pitch(),-30,30),holoEntity(22):angles():yaw(), clamp(holoEntity(22):angles():roll(),-20,20))))

    FishPos2 = FishPos2 + holoEntity(22):forward()/random(6,12)
    holoPos(22,entity():pos()+FishPos2)

    #Tail Movement
    if (Tail2 >= 30){Mod2 = -random(0.3,3)}
    if (Tail2 <= 0) {Mod2 =  random(0.3,3)}
    Tail2 += Mod2
    holoAng(23,holoEntity(22):angles() + ang(90,0,Tail2-15))



    #################
    #Fish Movement 3#
    #################

    #Set new waypoint when fish reaches old one
    WaypointDistance3 = abs((holoEntity(25):pos() - (entity():pos()+Waypoint3)):length())
    if (WaypointDistance3 < 10)  {Waypoint3 = random(-6,6)*entity():forward() + random(-35,35)*entity():right() + random(10,24)*entity():up()}


    #Get Bearing/Elevation to Waypoint and turn to it
    Bearing3 = holoEntity(25):bearing(entity():pos() + Waypoint3)
    Elevation3 = holoEntity(25):elevation(entity():pos() + Waypoint3)

    if (abs(Bearing3) > 3 )      {holoAng(25,holoEntity(25):angles()+ang(vec(0,-sign(Bearing3)*1.5,sign(Bearing3)/5)))}
    else                         {holoAng(25,holoEntity(25):angles()+ang(vec(0,0,-sign(holoEntity(25):angles():roll())/5)))}
    if (abs(Elevation3) > 2 )    {holoAng(25,holoEntity(25):angles()+ang(vec(-sign(Elevation3)/3,0,0)))}

    #Clamp Pitch
    holoAng(25,ang(vec(clamp(holoEntity(25):angles():pitch(),-30,30),holoEntity(25):angles():yaw(), clamp(holoEntity(25):angles():roll(),-20,20))))

    FishPos3 = FishPos3 + holoEntity(25):forward()/random(5,10)
    holoPos(25,entity():pos()+FishPos3)

    #Tail Movement
    if (Tail3 >= 30){Mod3 = -random(0.3,3)}
    if (Tail3 <= 0) {Mod3 =  random(0.3,3)}
    Tail3 += Mod3
    holoAng(26,holoEntity(25):angles() + ang(90,0,Tail3-15))



    #################
    #Fish Movement 4#
    #################

    #Set new waypoint when fish reaches old one
    WaypointDistance4 = abs((holoEntity(28):pos() - (entity():pos()+Waypoint4)):length())
    if (WaypointDistance4 < 10)  {Waypoint4 = random(-6,6)*entity():forward() + random(-35,35)*entity():right() + random(14,22)*entity():up()}


    #Get Bearing/Elevation to Waypoint and turn to it
    Bearing4 = holoEntity(28):bearing(entity():pos() + Waypoint4)
    Elevation4 = holoEntity(28):elevation(entity():pos() + Waypoint4)

    if (abs(Bearing4) > 3 )      {holoAng(28,holoEntity(28):angles()+ang(vec(0,-sign(Bearing4)*2.5,sign(Bearing4)/2)))}
    else                         {holoAng(28,holoEntity(28):angles()+ang(vec(0,0,-sign(holoEntity(28):angles():roll())/2)))}
    if (abs(Elevation4) > 2 )    {holoAng(28,holoEntity(28):angles()+ang(vec(-sign(Elevation4)/1,0,0)))}

    #Clamp Pitch
    holoAng(28,ang(vec(clamp(holoEntity(28):angles():pitch(),-30,30),holoEntity(28):angles():yaw(), clamp(holoEntity(28):angles():roll(),-20,20))))

    FishPos4 = FishPos4 + holoEntity(28):forward()/random(3,6)
    holoPos(28,entity():pos()+FishPos4)

    #Tail Movement
    if (Tail4 >= 30){Mod4 = -random(0.3,3)}
    if (Tail4 <= 0) {Mod4 =  random(0.3,3)}
    Tail4 += Mod4
    holoAng(29,holoEntity(28):angles() + ang(90,0,Tail4-15))
    
    

    #################
    #Plants Movement#
    #################
    
    #Plant 1
    holoPos(33,E:pos() + E:up() - E:right()*12 - E:forward()*15)
    holoAng(33,E:angles() + ang(0,0,sin(curtime()*50)*8))
    
    holoPos(34,holoEntity(33):pos() + holoEntity(33):up()*11)
    holoAng(34,E:angles() + ang(0,0,sin(curtime()*50+100)*8))
    
    holoPos(35,holoEntity(34):pos() + holoEntity(34):up()*9)
    holoAng(35,E:angles() + ang(0,0,sin(curtime()*50+200)*8))

    #Plant 2
    holoPos(36,E:pos() + E:up() - E:right()*24 + E:forward()*3)
    holoAng(36,E:angles() + ang(0,0,sin(curtime()*50+100)*8))
    
    holoPos(37,holoEntity(36):pos() + holoEntity(36):up()*7)
    holoAng(37,E:angles() + ang(0,0,sin(curtime()*50+200)*8))
    
    holoPos(38,holoEntity(37):pos() + holoEntity(37):up()*7)
    holoAng(38,E:angles() + ang(0,0,sin(curtime()*50+300)*8))
    
    #Plant 3
    holoPos(39,E:pos() + E:up() - E:right()*30 + E:forward()*15)
    holoAng(39,E:angles() + ang(0,0,sin(curtime()*50+200)*8))
    
    holoPos(40,holoEntity(39):pos() + holoEntity(39):up()*9)
    holoAng(40,E:angles() + ang(0,0,sin(curtime()*50+300)*8))
    
    holoPos(41,holoEntity(40):pos() + holoEntity(40):up()*7)
    holoAng(41,E:angles() + ang(0,0,sin(curtime()*50+400)*8))
    
    ################
    #Filter Bobbing#
    ################
    
    holoAng(31,angnorm(E:angles()))
    holoPos(31,E:pos() + E:up()*35 - E:right()*31 - E:forward()*12 + vec(0,0,sinr(curtime())/2))   
    
    
    ###############
    #Bubbles Spawn#
    ###############
    
    Total = 8
    timer("bubble",1500)
    if (clk("bubble") & X < Total)
    {
        holoCreate(X+100)
        holoModel(X+100,"hqsphere2")
        holoPos(X+100,holoEntity(31):pos())
        holoMaterial(X+100,"phoenix_storms/glass")
        X++
    } 
    
    #########
    #Bubbles#
    #########
    DensityLift =  random(0.004,0.006)
    RandomLow   = -0.3
    RandomHigh  =  0.3 
    Forward     =  0.04
    Right       =  0.04
    
    #Bubble 0    
        if (holoEntity(100):pos():z() > holoEntity(31):pos():z() & X > 0)
    {
        holoAlpha(100,0)
        B0 = -0.5
        Size = random(0.2,0.35)
        holoPos(100,holoEntity(31):pos())
        holoScale(100,vec(Size,Size,Size))  
    }
      
    #Bubble 1     
    elseif (holoEntity(101):pos():z() > holoEntity(31):pos():z() & X > 1)
    {
        holoAlpha(101,0)
        B1 = -0.5
        Size = random(0.2,0.35)
        holoPos(101,holoEntity(31):pos())
        holoScale(101,vec(Size,Size,Size))  
    } 
     
    #Bubble 2    
    elseif (holoEntity(102):pos():z() > holoEntity(31):pos():z() & X > 2)
    {
        holoAlpha(102,0)
        B2 = -0.5
        Size = random(0.2,0.35)
        holoPos(102,holoEntity(31):pos())
        holoScale(102,vec(Size,Size,Size))  
    }  
    
    #Bubble 3    
    elseif (holoEntity(103):pos():z() > holoEntity(31):pos():z() & X > 3)
    {
        holoAlpha(103,0)
        B3 = -0.5
        Size = random(0.2,0.35)
        holoPos(103,holoEntity(31):pos())
        holoScale(103,vec(Size,Size,Size))  
    }   
    
    #Bubble 4    
    elseif (holoEntity(104):pos():z() > holoEntity(31):pos():z() & X > 4)
    {
        holoAlpha(104,0)
        B4 = -0.5
        Size = random(0.2,0.35)
        holoPos(104,holoEntity(31):pos())
        holoScale(104,vec(Size,Size,Size))  
    }
    
    #Bubble 5    
    elseif (holoEntity(105):pos():z() > holoEntity(31):pos():z() & X > 5)
    {
        holoAlpha(105,0)
        B5 = -0.5
        Size = random(0.2,0.35)
        holoPos(105,holoEntity(31):pos())
        holoScale(105,vec(Size,Size,Size))  
    }
    
    #Bubble 6   
    elseif (holoEntity(106):pos():z() > holoEntity(31):pos():z() & X > 6)
    {
        holoAlpha(106,0)
        B6 = -0.5 
        Size = random(0.2,0.35)
        holoPos(106,holoEntity(31):pos())
        holoScale(106,vec(Size,Size,Size)) 
    } 
    
    #Bubble 7   
    elseif (holoEntity(107):pos():z() > holoEntity(31):pos():z() & X > 7)
    {
        holoAlpha(107,0)
        B7 = -0.5
        Size = random(0.2,0.35)
        holoPos(107,holoEntity(31):pos())
        holoScale(107,vec(Size,Size,Size))  
    }


    #Bubble Movement
    B0 = clamp(B0 + DensityLift,-0.5,0.3)
    holoPos(100,holoEntity(100):pos() + B0*E:up() + Right*E:right()*(B0 > -0.2) + Forward*E:forward()*(B0 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B0 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B0 > -0.1))
    holoAlpha(100,255)
    
    B1 = clamp(B1 + DensityLift,-0.5,0.3)
    holoPos(101,holoEntity(101):pos() + B1*E:up() + Right*E:right()*(B1 > -0.2) + Forward*E:forward()*(B1 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B1 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B1 > -0.1))
    holoAlpha(101,255)
    
    B2 = clamp(B2 + DensityLift,-0.5,0.3)
    holoPos(102,holoEntity(102):pos() + B2*E:up() + Right*E:right()*(B2 > -0.2) + Forward*E:forward()*(B2 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B2 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B2 > -0.1))
    holoAlpha(102,255)
    
    B3 = clamp(B3 + DensityLift,-0.5,0.3)
    holoPos(103,holoEntity(103):pos() + B3*E:up() + Right*E:right()*(B3 > -0.2) + Forward*E:forward()*(B3 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B3 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B3 > -0.1))
    holoAlpha(103,255)
    
    B4 = clamp(B4 + DensityLift,-0.5,0.3)
    holoPos(104,holoEntity(104):pos() + B4*E:up() + Right*E:right()*(B4 > -0.2) + Forward*E:forward()*(B4 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B4 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B4 > -0.1))
    holoAlpha(104,255)
    
    B5 = clamp(B5 + DensityLift,-0.5,0.3)
    holoPos(105,holoEntity(105):pos() + B5*E:up() + Right*E:right()*(B5 > -0.2) + Forward*E:forward()*(B5 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B5 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B5 > -0.1))
    holoAlpha(105,255)
    
    B6 = clamp(B6 + DensityLift,-0.5,0.3)
    holoPos(106,holoEntity(106):pos() + B6*E:up() + Right*E:right()*(B6 > -0.2) + Forward*E:forward()*(B6 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B6 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B6 > -0.1))
    holoAlpha(106,255)
    
    B7 = clamp(B7 + DensityLift,-0.5,0.3)
    holoPos(107,holoEntity(107):pos() + B7*E:up() + Right*E:right()*(B7 > -0.2) + Forward*E:forward()*(B7 > -0.2) + random(RandomLow,RandomHigh)*E:right()*(B7 > -0.1) + random(RandomLow,RandomHigh)*E:forward()*(B7 > -0.1))
    holoAlpha(107,255)
    
    ########
    #Sounds#
    ########
    
    timer("sound",2200)

    if(clk("sound")) 
    {
        soundPlay(1,2,"player/footsteps/wade"+randint(1,8)+".wav")
        soundVolume(1,random(0.2,0.4))
    }
}


   

