What I want to do in the game is pick a completely arbitrary NPC. Generic, Unique, Quest, whatever. And I want to use a script (from an item, of course) to remove every script package they have (and then attach some others, depending). The problem is, with any given NPC, I have no idea how to determine (using a script in a running game) how many packages they have. I want to do this without manually deleting anything in the GECK and without having to use Console Commands in the game.
Is there a way (in a script) to either:
1) iterate the script packages on a reference
or
2) remove all script packages in one fell swoop (like how RemoveFromAllFactions works)
I'm cool with using NVSE, but from what I've seen, it doesn't have the functionality I need either.