@name Proper Disco Ball
@persist [Entity Owner]:entity

if(first()) {
    Entity=entity()
    Owner=owner()
    
    # "models/effects/vol_light64x256.mdl"
    function array pointsInSphere4(PointsCt,Radius,Center:vector) {
        local Points=array()
        local Pi=pi()
        local Pi2=Pi*2
        local LatStep=Pi/(PointsCt-1)
        local Slice=-0.5*Pi
        for(I=0,PointsCt-1,1) {
            local R=cosr(Slice)
            local Z=sinr(Slice)
            local Nb=ceil(Pi2*R/LatStep)
            local Db=Pi2/Nb
            if(I>=PointsCt) {Nb=1 Db=0}
            local B=0
            for(V=0,Nb-1) {
                B+=Db
                local X=R*cosr(B)
                local Y=R*sinr(B)
                Points:pushVector(vec(X,Y,Z)*Radius+Center)
            }
            Slice+=LatStep
        }
        return Points
    }
    
    local Center=entity():pos()
    local Index=1
    
    foreach(I,V:vector=pointsInSphere4(8,50,Entity:pos())) {
        holoCreate(
            Index,
            V,
            vec(0.3,0.3,0.5)*3,
            (V-Center):toAngle()+ang(270,0,0),
            vec(255),
            "models/effects/vol_light64x256.mdl"
        )
        holoParent(Index,Entity)
        
        Index++
    }
    
}
