Added proper support for infinite custom animations and animation terminators (nerverending frames).

This will permit to remove a lot of ugly hacks in the script files.
I already removed some but I'll fix the rest in another commit.