@name Paint ball gun
@inputs 
@outputs 
@persist R:array N K Ra:ranger N2 R2:array Color:vector N5 A
@trigger 
interval(1)
#creating the stickies, dont worry much about it
if(first()) {N2 = 25, Color = randvec()*255}

#slows down how fast you can shoot them, change the 250 to
#more or less depending on what you want
timer("A",250)
if(clk("A")&owner():keyAttack1()) {K = 1} else {K = 0}

#creates the main holos
if(K&$K) {
N++
if(N>15) {N = 1}
holoCreate(N,owner():shootPos()+owner():eye()*12,vec(0.2,0.2,0.2),owner():eyeAngles(),Color,"hqicosphere2")
}

#holo/ranger movement. notice theres only one ranger
for(I=1,15) {
#ranger ignoring you
rangerFilter(owner())
rangerFilter(owner():weapon())
Ra = rangerOffset(16,holoEntity(I):pos(),holoEntity(I):forward())
#timer for deleting the splat holo
R[I+24,number]=R[I+24,number]+R2[I+24,number]
if(R[I+24,number]>200) {holoDelete(I+24), R[I+24,number]=0}

#tells if the ranger hit, creates splat holo, deletes the main holo
if(Ra:hit()) {
N2++
if(N2>=40) {N2 = 25}
holoCreate(N2, Ra:position(), vec(1,1,0.05), Ra:hitNormal():toAngle()+ang(90,0,0),Color, "hqcylinder")
holoParent(N2,Ra:entity())
R2[N2,number]=1
holoDelete(I)}

#actual movement of the holo
holoPos(I,holoEntity(I):toWorld(vec(12,0,0)))
}

if(first()) {holoCreate(41),holoCreate(42),holoCreate(43),holoCreate(44),holoCreate(45),holoCreate(46),holoCreate(47),holoCreate(48),holoCreate(49)
holoPos(41,entity():pos())
holoScale(41,vec(1,0.2,0.4))
T=holoEntity(41)
holoPos(42,T:pos()+T:forward()*10+T:up()*3)
holoScale(42,vec(0.2,0.2,2.5))
holoModel(42,"hqcylinder")
holoAng(42,ang(90,0,0))
holoPos(43,T:pos()+T:forward()*-3+T:up()*-5.5)
holoScale(43,vec(0.3,0.2,0.7))
holoAng(43,ang(15,0,0))
holoPos(44,T:pos()+T:forward()*-5.5+T:up()*-10)
holoScale(44,vec(0.5,0.2,0.2))
holoPos(45,T:pos()+T:forward()*-16+T:up()*-11)
holoScale(45,vec(0.4,0.4,1.4))
holoModel(45,"hqcylinder")
holoAng(45,ang(80,0,0))
holoPos(46,T:pos()+T:forward()*3+T:up()*5)
holoScale(46,vec(0.2,0.2,1))
holoModel(46,"hqcylinder")
holoPos(47,T:pos()+T:forward()*3+T:up()*10)
holoScale(47,vec(1.3,0.6,0.7))
holoModel(47,"hqicosphere2")
holoPos(48,T:pos()+T:forward()*5+T:up()*-3)
holoScale(48,vec(0.1,0.1,1))
holoModel(48,"hqcylinder")
holoAng(48,ang(20,0,0))
holoPos(49,T:pos()+T:forward()*-0.3+T:up()*-9.5)
holoScale(49,vec(0.1,0.1,0.7))
holoModel(49,"hqcylinder")
holoAng(49,ang(70,0,0))
}

if(A<9) {A++,holoMaterial(A+40,"phoenix_storms/iron_rails")
holoColor(A+40,vec(150,150,150)),holoColor(45,vec(10,10,10))
holoMaterial(47,"models/debug/debugwhite"),holoColor(47,Color)}

if(N5<8) {
N5++
holoParent(N5+41,41)
}
timer("A",250)
if(clk("A")) {
holoAng(41,owner():attachmentAng(5))
holoPos(41,owner():attachmentPos(5)+owner():up()*5+owner():forward()*3)
holoParentAttachment(41,owner(),"anim_attachment_RH")
stoptimer("A")
}
owner():weapon():setMaterial("models/effects/vol_light001")
