@name Dic

@persist E:entity
@persist Count

# each holo will have an ang-vel and an ang-vel-old

interval(100)

if(first())
{
    E = entity()
    Count = 3
    
    # holo functions
    function handleAngVel(Index, TargetAng:angle, ForceMult, Drag)
    {
        local H = holoEntity(Index)
        
        local ApplyForce = H:toLocal(TargetAng) * ForceMult
        
        H["ang_vel", angle] = (H["ang_vel", angle] + ApplyForce) * Drag
        
        H["ang", angle] = H["ang", angle] + H["ang_vel", angle]
        
        holoAng(Index, H["ang", angle] + H["ang_vel", angle])
    }
    
    function entity prevEnt(I)
    {
        return (I == 1) ? E : holoEntity(I - 1)
    }
    
    for(I = 1, Count)
    {
        local H = holoCreate(I, E:toWorld(vec(0, 0, (I-1) * 35)))
        holoParent(I, prevEnt(I))
        H["ang", angle] = E:angles()
        H["ang_vel", angle] = ang()
    }
}

for(I = 1, Count)
{
    handleAngVel(I, prevEnt(I):angles(), 0.05, 0.95 - 0.25*(I/7))
}
