Don't attack units who were left next to a settlement in order to capture it on the same turn in order to cheat the garrison script. In fact don't cheat the garrison script period. (this only applies vs AI factions)
What happens if we set the garrison script off, then attack an army outside the settlement?