@name alabama black snake
@inputs 
@outputs HV:vector
@persist E:entity LENGTH [AVPIT AVYAW EVPIT EVYAW] HP:vector HV:vector PITCH SND:array RD XX
@model models/hunter/blocks/cube025x025x025.mdl

if (first())    {
    E = entity(), E:setAlpha(0), E:setMass(50)

    LENGTH = 12
    FACTOR = 1

    for (I = 1, LENGTH)   {
        holoCreate(I)
        holoParent(I, I > 1 ? holoEntity(I - 1) : E)
        holoModel(I, "hq_rcylinder")
        holoScale(I, vec(2,2,2)*FACTOR)
        holoPos(I, E:toWorld(vec(8, 0, -2 + (I * 8))*FACTOR))
        holoMaterial(I, "phoenix_storms/egg")
        holoColor(I, vec(90,75,45))
    }
    
    holoCreate(LENGTH+1), holoParent(LENGTH+1, E), holoModel(LENGTH+1, "hq_dome")
    holoScale(LENGTH+1, vec(3,2,2)*FACTOR), holoPos(LENGTH+1, E:toWorld(vec(-4,10,-5)*FACTOR))
    holoCreate(LENGTH+2), holoParent(LENGTH+2, E), holoModel(LENGTH+2, "hq_dome")
    holoScale(LENGTH+2, vec(3,2,2)*FACTOR), holoPos(LENGTH+2, E:toWorld(vec(-4,-10,-5)*FACTOR))
    holoColor(LENGTH+1, vec(90,75,45)+10)
    holoColor(LENGTH+2, vec(90,75,45)+10)
    holoAng(LENGTH+1, E:toWorld(ang(90,0,0)))
    holoAng(LENGTH+2, E:toWorld(ang(90,0,0)))
    
    holoCreate(LENGTH+3)
    holoParent(LENGTH+3, LENGTH)
    holoPos(LENGTH+3, holoEntity(LENGTH):toWorld(vec(0,0,5)*1.5*FACTOR))
    holoScaleUnits(LENGTH+3, vec(16,16,16)*1.5*FACTOR)
    holoModel(LENGTH+3, "hq_sphere")
    holoColor(LENGTH+3, vec(255,225,255)-100)

    holoCreate(LENGTH+4)
    holoParent(LENGTH+4, LENGTH)
    holoPos(LENGTH+4, holoEntity(LENGTH):toWorld(vec(0,0,5)*1.5*FACTOR))
    holoAng(LENGTH+4, holoEntity(LENGTH):toWorld(ang(-25,0,0)))
    holoScaleUnits(LENGTH+4, vec()+19*1.5*FACTOR)
    holoModel(LENGTH+4, "hq_torus_thick")
    holoColor(LENGTH+4, vec(90,75,45)+10)
    
    holoCreate(LENGTH+5)
    holoParent(LENGTH+5, LENGTH)
    holoPos(LENGTH+5, holoEntity(LENGTH):toWorld(vec(0,0,3.5)*1.5*FACTOR))
    holoAng(LENGTH+5, holoEntity(LENGTH):toWorld(ang(-9.5,0,0)))
    holoScaleUnits(LENGTH+5, vec()+19*1.5*FACTOR)
    holoModel(LENGTH+5, "hq_torus_thick")
    holoColor(LENGTH+5, vec(90,75,45)+10)
    
    holoCreate(LENGTH+6)
    holoParent(LENGTH+6, LENGTH)
    holoPos(LENGTH+6, holoEntity(LENGTH):toWorld(vec(0,0,4.25)*1.5*FACTOR))
    holoAng(LENGTH+6, holoEntity(LENGTH):toWorld(ang(-17,0,0)))
    holoScaleUnits(LENGTH+6, vec(19,19,30)*1.5*FACTOR)
    holoModel(LENGTH+6, "hq_torus_thick")
    holoColor(LENGTH+6, vec(90,75,45)+10)
    
    for (I = 1, LENGTH+6) { holoDisableShading(I, 1) }
    
    entity():soundPlay(500, 0, "misc/halloween/hwn_dance_loop.wav")
    soundPitch(500, 69)
    soundVolume(500, 0.5)

    for (I = 1, 4)   {
        holoEntity(I):soundPlay(I, 0, "misc/clap_single_2.wav")
    }
    
    SND[1, string] = "vo/npc/Alyx/gasp02.wav"
    SND[2, string] = "vo/npc/Alyx/gasp03.wav"
    
    SND[3, string] = "vo/npc/Alyx/hurt04.wav"
    SND[4, string] = "vo/npc/Alyx/hurt05.wav"
    SND[5, string] = "vo/npc/Alyx/hurt06.wav"
    SND[6, string] = "vo/npc/Alyx/hurt08.wav"
    
    SND[7, string] = "vo/npc/Alyx/ohgod01.wav"
    SND[8, string] = "vo/npc/Alyx/ohgod01.wav"
    SND[9, string] = "vo/npc/Alyx/ohgod01.wav"

    SND[10, string] = "vo/npc/Alyx/no01.wav"
    SND[11, string] = "vo/npc/Alyx/no02.wav"
    SND[12, string] = "vo/npc/Alyx/no03.wav"

    SND[13, string] = "vo/npc/Alyx/uggh01.wav"
    SND[14, string] = "vo/npc/Alyx/uggh02.wav"
 
    SND[15, string] = "vo/npc/Alyx/ohno_startle01.wav"
    SND[16, string] = "vo/npc/Alyx/ohno_startle02.wav"

    interval(90)#, particleBounce(0), particleGravity( vec(0,0,-500) )
} elseif (clk())    {
    interval(90)
    
    XX = randint(1,100)
    if (changed(XX) & XX > 90)  {
        RDI = randint(1,6)
        holoEntity(LENGTH + RDI):soundPlay(RDI, 0, SND[randint(1, SND:count()), string])
    }

    AV = E:angVel()
    EV = E:velL()
   
    AVPIT += AV[1] / 250, AVPIT /= 2
    AVYAW += AV[2] / 250, AVYAW /= 2

    EVPIT += EV[3] / 250, EVPIT /= 2
    EVYAW += EV[2] / 250, EVYAW /= 2
    
    ANGLE = -ang(AVPIT*5 - EVPIT*3, 0, -AVYAW*5 - EVYAW*3)
    
    for (I = 1, LENGTH)   {
        holoAng(I, I > 1 ? holoEntity(I-1):toWorld(ANGLE) : E:toWorld(ANGLE + ang(90,0,0)))
    }
    
    HP = holoEntity(LENGTH+3):pos()
    HV = $HP*66
    
    if (HV:length() > 50) {
        #particle(30, 20, 20, "effects/splash4", vec(255,255,255), HP, holoEntity(LENGTH+3):up()*1300)
    }
}
