function ai()
    if player then
        local at = player.Center
        while true do
            if not (nodeIndex == 0) then
                if (nodeIndex == 2) then
                    beginCharge()
                    beam({followTime = 0.5,rotationSpeed = 600})
                    wait(0.15)
                end
                if (nodeIndex == 1) then
                    beginCharge()
                    shoot({speed=70})
                    wait(0.15)
                end
                if (nodeIndex >= 3) then
                    beginCharge()
                    shoot({speed=140,angleOffset=10})
                    shoot({speed=140})
                    shoot({speed=140,angleOffset=-10})
                    beam({followTime = 0.5,rotationSpeed = 600,lockTime=0.3})
                    wait(0.1)
                end
            else
                wait()
            end
        end
    end
end