DEFCON 1 said:
OOC: As the beetle swarm moves into my space, I get an AoO. So I get two attacks this round (one from the AoO which technically occurs before the beetles attack me, and then my attack as part of the surprise round.)
Actually, technically not. You are flat-footed when they attack and cannot make an attack of opportunity.
From the SRD:
HOW COMBAT WORKS
Combat is cyclical; everybody acts in turn in a regular cycle of rounds. Combat follows this sequence:
1. Each combatant starts out flat-footed. Once a combatant acts, he or she is no longer flat-footed.
2. Determine which characters are aware of their opponents at the start of the battle. If some but not all of the combatants are aware of their opponents, a surprise round happens before regular rounds of combat begin. The combatants who are aware of the opponents can act in the surprise round, so they roll for initiative. In initiative order (highest to lowest), combatants who started the battle aware of their opponents each take one action (either a standard action or a move action) during the surprise round. Combatants who were unaware do not get to act in the surprise round. If no one or everyone starts the battle aware, there is no surprise round.
3. Combatants who have not yet rolled initiative do so. All combatants are now ready to begin their first regular round of combat.
4. Combatants act in initiative order (highest to lowest).
5. When everyone has had a turn, the combatant with the highest initiative acts again, and steps 4 and 5 repeat until combat ends.
Flat-Footed: At the start of a battle, before you have had a chance to act (specifically, before your first regular turn in the initiative order), you are flat-footed. You can’t use your Dexterity bonus to AC (if any) while flat-footed. Barbarians and rogues have the uncanny dodge extraordinary ability, which allows them to avoid losing their Dexterity bonus to AC due to being flat-footed.
A flat-footed character can’t make attacks of opportunity.