Auto-translated
I have a hunch that the GetObjectArmySlotCreature() function was primarily created to retrieve the ID from a slot, rather than the number of units, and it returns the total number of creature data.
Added 19 minutes later
Or maybe sleep() isn't sufficient, which is why the number of creatures gets counted twice.