@name Blood Mage
@persist O:entity [D H T M V E]:array  [S Speed ShootSpeed Max DMax Atk Y]:number Trail:string Color:vector
#by rat man
entity():propNotSolid(1)
if(tickClk()){
    if(S>=359){
        S=0
    }else{
        S+=Speed
    }
    if(Atk){
        if(!O:keyAttack2()){
            Atk=0
        }
    }
    for(X=1,Max){
        if(X==Y){
            if(O:keyAttack2()&!Atk){
                Atk=1
                if(M[X,number]==0){
                    if(Y==Max){
                        Y=1
                    }else{
                        Y++
                    }
                    if(O:aimEntity()){
                        T[X,entity]=O:aimEntity()
                        if(T[X,entity]:isPlayer()){
                            M[X,number]=2
                        }elseif(T[X,entity]:isNPC()){
                            M[X,number]=3
                        }else{
                            M[X,number]=4
                        }
                    }else{
                        M[X,number]=1
                        V[X,vector]=O:aimPos()
                    }
                }
            }
        }
        if(M[X,number]>0){
            if(M[X,number]>1){
                if(M[X,number]>2){
                    if(M[X,number]>3){
                        V[X,vector]=T[X,entity]:pos()
                    }else{
                        V[X,vector]=T[X,entity]:pos()+vec(0,0,T[X,entity]:height()/2)
                    }
                }else{
                    V[X,vector]=T[X,entity]:shootPos()
                }
            }
            Target=H[X,entity]:pos()+clamp(V[X,vector]-H[X,entity]:pos(),-ShootSpeed,ShootSpeed)
            D[X,vector]=H[X,entity]:pos()
            if(Target==V[X,vector]){
                H[X,entity]:removeTrails()
                E[X,number]=50
                holoPos(-X,Target)
                TempEnt=T[X,entity]
                TempEnt:npcRelationship(TempEnt:type(),"hate",999)
                TempEnt:npcRelationship("player","like",999)
                TempEnt:applyForce((D[X,vector]-TempEnt:pos())*TempEnt:mass()*-6)
                holoMaterial(X,"models/shiny")
                M[X,number]=-50
            }else{
                rangerDefaultZero(0)
                rangerIgnoreWorld(0)
                Ranger=rangerOffset(H[X,entity]:pos(),Target)
                if(Ranger:hit()){
                    H[X,entity]:removeTrails()
                    E[X,number]=50
                    holoPos(-X,Ranger:position())
                    TempEnt=Ranger:entity()
                    TempEnt:npcRelationship(TempEnt:type(),"hate",999)
                    TempEnt:npcRelationship("player","like",999)
                    TempEnt:applyForce((D[X,vector]-TempEnt:pos())*TempEnt:mass()*-6)
                    holoMaterial(X,"models/shiny")
                    M[X,number]=-50
                }else{
                    holoPos(X,Ranger:position())
                }
            }
        }else{
            if(M[X,number]<0){
                M[X,number]=M[X,number]+1
                if(M[X,number]==0){
                    holoMaterial(X,"models/shiny")
                   
                    holoScale(X,vec(1,1,1))
                    H[X,entity]:setTrails(15,0,0.5,Trail,Color,255,0,0)
                }
            }else{
                holoPos(X,O:shootPos()+vec(sin(S+(DMax*(X-1))),cos(S+(DMax*(X-1))),1)*30)
            }
        }
        if(E[X,number]){
            E[X,number]=E[X,number]-1
            holoAlpha(-X,E[X,number]*5.1)
            holoScale(-X,vec(50-E[X,number],50-E[X,number],50-E[X,number]))
            holoScale(X,-vec(50-E[X,number],50-E[X,number],50-E[X,number]))
            holoAng(-X,holoEntity(-X):angles()+randvec(0,50):toAngle())
        }
    }
}elseif(first()){
    O=owner()
    Speed=2.5
    ShootSpeed=20
    Max=3 # The amount of balls to have spinning round your head
    Trail="trails/smoke"
    Color=vec(200,255,50)
    DMax=360/Max
    Y=1
    runOnTick(1)
    for(X=1,Max){
        H[X,entity]=holoCreate(X,vec())
        holoColor(X,Color)
        holoModel(X,"hqicosphere2")
        holoMaterial(X,"models/shiny")
        H[X,entity]:setTrails(15,0,0.5,Trail,Color,150)
        holoCreate(-X)
        holoColor(-X,vec(150,255,0))
        holoModel(-X,"hqicosphere2")
        holoMaterial(-X,"models/shiny")
        holoAlpha(-X,0)
    }
}

