@name Paintball Gun
@persist Speed Range BulletAmount BulletLimit RDArray:array SplatEnt:entity SplatNum Reload Shot
interval(1)  #1

if(first())
{
    runOnChat(1)
    BulletLimit = 20 
    Speed =15  #15
    Range =1.001

    #Gun
    holoCreate(1)
    holoScale(1, vec(0.12,0.12,1.5) )
    holoPos(1, entity():pos() + vec(0,0,50) )
    holoColor(1, vec(0,150,0) )
    holoAng(1, ang(90,90,90) )
    holoModel(1, "hqtube2" )
    holoParent(1, entity() )

    holoCreate(2)
    holoScale(2, vec(0.15,0.15,0.76) )
    holoPos(2, entity():pos() + vec(5.8,0,50) )
    holoColor(2, vec(50,50,50) )
    holoAng(2, ang(90,90,90) )
    holoModel(2, "hqcube2" )
    holoMaterial(2, "phoenix_storms/black_chrome" )
    holoParent(2, entity() )

    holoCreate(3)
    holoScale(3, vec(0.13,0.13,0.2) )
    holoPos(3, entity():pos() + vec(-9,0,50) )
    holoColor(3, vec(50,50,50) )
    holoAng(3, ang(90,90,90) )
    holoModel(3, "hqtube" )
    holoMaterial(3, "phoenix_storms/black_chrome" )
    holoParent(3, entity() )

    holoCreate(4)
    holoScale(4, vec(0.1,0.1,0.5) )
    holoPos(4, entity():pos() + vec(2,0,46.5) )
    holoColor(4, vec(0,200,0) )
    holoAng(4, ang(0,0,180) )
    holoModel(4, "hqcubinder" )
    holoParent(4, entity() )

    holoCreate(5)
    holoScale(5, vec(0.1,0.1,0.38) )
    holoPos(5, entity():pos() + vec(9,0,47.6) )
    holoColor(5, vec(0,200,0) )
    holoAng(5, ang(0,0,180) )
    holoModel(5, "hqcube2" )
    holoParent(5, entity() )

    holoCreate(6)
    holoScale(6, vec(0.08,0.08,0.25) )
    holoPos(6, entity():pos() + vec(4,0,44) )
    holoColor(6, vec(100,100,100) )
    holoAng(6, ang(90,90,90) )
    holoModel(6, "hqcylinder" )
    holoMaterial(6, "phoenix_storms/chrome" )
    holoParent(6, entity() )

    holoCreate(7)
    holoScale(7, vec(0.1,0.1,0.2) )
    holoPos(7, entity():pos() + vec(5,1.2,50.4) )
    holoColor(7, vec(0,200,0) )
    holoAng(7, ang(0,0,127) )
    holoModel(7, "hqcylinder2" )
    holoParent(7, entity() )

    holoCreate(8)
    holoScale(8, vec(0.1,0.1,0.21) )
    holoPos(8, entity():pos() + vec(5,1.9,51.8) )
    holoColor(8, vec(0,200,0) )
    holoAng(8, ang(0,0,0) )
    holoModel(8, "hqcylinder2" )
    holoParent(8, entity() )

    #CO2 Cartrige
    holoCreate(9)
    holoScale(9, vec(0.2,0.2,0.6) )
    holoPos(9, entity():pos() + vec(8,0,44) )
    holoColor(9, vec(100,100,100) )
    holoAng(9, ang(90,90,90) )
    holoModel(9, "hqrcylinder" )
    holoMaterial(9, "phoenix_storms/black_chrome" )
    holoParent(9, entity() )

    #Hopper
    holoCreate(10)
    holoScale(10, vec(0.25,0.25,0.5) )
    holoPos(10, entity():pos() + vec(5,2,54) )
    holoColor(10, vec(100,100,100) )
    holoAng(10, ang(90,90,90) )
    holoModel(10, "hqsphere2" )
    holoMaterial(10, "phoenix_storms/black_chrome" )
    holoParent(10, entity() )

    #Firing Pin
    holoCreate(11)
    holoScale(11, vec(0.05,0.05,0.1))
    holoPos(11, entity():pos() + vec(8,-1,50))
    holoColor(11, vec(100,100,100))
    holoAng(11, ang(0,0,90))
    holoModel(11, "hqcubinder")
    holoMaterial(11, "phoenix_storms/chrome")
    holoParent(11, entity())

    holoCreate(12)
    holoScale(12, vec(0.05,0.05,0.2))
    holoPos(12, entity():pos() + vec(7.2,-0.6,50))
    holoColor(12, vec(100,100,100))
    holoAng(12, ang(90,90,90))
    holoModel(12, "hqcube")
    holoMaterial(12, "phoenix_storms/chrome")
    holoParent(12, entity())

    #Trigger
    holoCreate(13)
    holoScale(13, vec(0.2,0.2,0.2))
    holoPos(13, entity():pos() + vec(8,0,49))
    holoColor(13, vec(255,114,0))
    holoAng(13, ang(0,0,90))
    holoModel(13, "hqtorus2")
    holoMaterial(13, "phoenix_storms/black_chrome")
    holoParent(13, entity())

    holoCreate(14)
    holoScale(14, vec(0.05,0.05,0.1))
    holoPos(14, entity():pos() + vec(8,0,49))
    holoColor(14, vec(0,200,0))
    holoAng(14, ang(0,90,25))
    holoModel(14, "hqcube2")
    holoParent(14, entity())

    holoParent(15, entity())

    for(I=1,14)
    {
        holoParent(I,holoEntity(5))
    }

    holoAng(5,owner():attachmentAng("anim_attachment_RH")+ang(180,0,0))
    holoPos(5,owner():attachmentPos("anim_attachment_RH"))
    holoParentAttachment(5,owner(),"anim_attachment_RH")
    
    BulletAmount = 0
    Reload = 0

    hint("Paintball Gun",5)
    hint("Idea and design by D3| Roach",5)
    hint("Rest of E2 by Gameace",5)
}

if(owner():weapon():getAlpha() != 0)
{
    owner():weapon():setAlpha(0)
}

Key = owner():keyAttack1()

if(Key && Reload == 0 && Shot == 0)
{
    #Paintball
    holoCreate(BulletAmount+15)
    holoScale(BulletAmount+15, vec(0.1,0.1,0.1))
    holoPos(BulletAmount+15, entity():pos() + vec(0,0,0))
    holoColor(BulletAmount+15, vec(255,114,0))
    holoModel(BulletAmount+15, "hqsphere2")
    holoMaterial(BulletAmount+15, "models/weapons/v_crossbow/rebar_glow")
    holoPos(BulletAmount+15,holoEntity(1):pos())
    holoAng(BulletAmount+15,(owner():aimPos()-owner():attachmentPos("anim_attachment_RH")):toAngle()+ang(180,0,0))
    BulletAmount++
    owner():soundPlay(1,100,"/items/pegleg_01.wav")
    Shot = 1
}

elseif(Reload == 1 && owner():keyAttack1())
{
    owner():soundPlay(3,100,"/items/nvg_off.wav")
}

if(!Key)
{
    Shot = 0
}

for(I=0,BulletAmount)
{
    holoPos(I+15,holoEntity(I+15):pos()-holoEntity(I+15):forward()*Speed)
    I++
}

if(BulletAmount>0)
{
    for(I=0,BulletAmount)
    {
        rangerFilter(owner())
        rangerIgnoreWorld(0)
        RDArray[I,ranger] = rangerOffset(holoEntity(I+15):pos()*Range,holoEntity(I+15):pos())
        
        if(RDArray[I,ranger]:hit())
        {
            #hint("HIT! "+I,1)
            holoEntity(I+15):soundPlay(2,100,"npc/antlion_grub/squashed.wav")
            SplatEnt = RDArray[I,ranger]:entity()
            RDArray:removeRanger(I)
            holoCreate(66+SplatNum,holoEntity(I+15):pos())
            holoMaterial(66+SplatNum,"decals/yblood6")
            holoScale(66+SplatNum,vec(0.5,0.5,0.5))
            holoParent(66+SplatNum,SplatEnt)
            SplatNum++
            holoDelete(I+15)
        }
    }
}

if(BulletAmount>BulletLimit)
{
    Reload = 1
}

if(owner():keyReload() && BulletAmount>=1)
{
    hint("Reloading",1)
    
    for(I=0,BulletAmount)
    {
        holoDelete(I+15)
        rangerReset()
    }

    BulletAmount = 0
    Reload = 0
}

if(removing())
{
    owner():weapon():setAlpha(255)
}

if(chatClk(owner()) & owner():lastSaid():lower() == "!clear")
{
    hideChat(1)
    for(I=0,SplatNum)
    {
        holoDelete(66+I)
        rangerReset()
    }
    
    for(I=0,BulletAmount)
    {
        holoDelete(I+15)
        rangerReset()
    }

    NumSplats = 0
    BulletAmount = 0
    Reload = 0
}

#############################################
#############################################
###########                       ###########
###########   Made by D3|Roach    ###########
###########      And Gameace      ###########
###########                       ###########
###########        DO NOT         ###########
###########Redisribute as your own###########
###########  Remove the hints     ###########
###########      Or modify        ###########
###########  without permission   ###########
#############################################
#############################################
