The API macros that have been implemented for the game enforce a way of handling combat, especially initiative and surprise.
In many situations, each side in a combat will be aware of each other at the point that combat begins. In this case everybody rolls initiative normally, and there is no surprise round.
Initiative is rolled at the point combat begins - not whilst preparing or waiting. As soon as it is possible for a combat action to occur, initiative is rolled, and not before. e.g., if one side is waiting to open a door to charge in and attack the other side, then initiative is rolled when the door is opened.
If everyone was expecting combat, there is no chance of surprise.
If combat was unexpected, say two groups walking casually into each other, everyone makes a DC 10 Perception check to see if they are surprised. On success, they get to act in the surprise round.
If combat was really unexpected, say two groups running into each other, then it's a DC 20 Perception check to not be surprised.
One Person Begins Combat
If there is one creature that clearly begins the combat, then they get surprise and also get to take 20 on their initiative check. This doesn't guarantee that they will go first, but greatly increases the likelihood. Situations where one creature begins the combat can include:
- Someone who opens a door ready to fight.
- Someone who initiates an ambush.
- Someone who draws a weapon during a conversation.
This is implemented in the scripts by starting combat with a single token. If only one token is added at the start of combat, then that token takes 20 and has surprise.
Everybody else then gets added to the initiative, with a possibility of either being surprised, or having surprise.
In an ambush, the initiator makes a Stealth check, and anyone who was not aware of them makes a Perception check against that. If they succeed, they are not surprised. If they fail (get lower than the Stealth roll), then they are surprised. In either case they roll initiative and are added to the combat track.
In an ambush situation, one person on the ambushing team must be designated as the initiator. The rest of the team don't need to make a surprise check - they automatically have surprise and roll initiative.
Where everyone is aware of each other, but the initiator surprises people by suddenly starting a fight, then they instead make a Bluff check. Everyone else makes a Sense Motive check, and on success get to act in the surprise round, otherwise they are surprised.
Readying Before Combat
It is not possible to ready or delay an action before combat actually begins. Regardless of whether people were aware of the possibility of combat or not, everyone is always flatfooted at the start of combat. If this weren't the case, guards would be 'alert' and ready to hit anyone who tries to sneak past all the time.
You can have your weapon out, but creatures always take a moment to start acting once combat actually begins.
In the surprise round, you can ready an action (but cannot move beforehand, since you only get a single standard or move action in the surprise round), but cannot delay. You can select to do nothing if you want to.
Alice is waiting round a corner for Bob to walk past. Alice is initiating the combat, so as Bob is about to round the corner, she makes a Stealth check, and takes 20 on her initiative, automatically gaining surprise.
Bob makes a Perception check, and if he equals or exceeds Alice's stealth then he is aware (and gets to act in the surprise round, along with Alice), otherwise he is surprised. Bob then rolls his initiative.
Assuming that Alice beats Bob's initiative, then she can ready an action to hit him as soon as he comes within range.