Each turn of a pet battle has a structure, but the order that the various events happen in is not well documented. I'm trying to figure out when the game assigns each type of damage or effect, and in particular which effects benefit from going first (or second).
1. Initiative -- the game determines which pet gets to go first. This happens instantaneously from our perspective, as one pet gets the little speed icon immediately as the turn starts.
2. Pets choose actions. If a pet chooses Reflection as an action, the Reflection buff will be applied before phase 3, regardless of speed. If either pet chooses 'swap pet' as an action, then the rest of the turn is skipped, and the new pet becomes the active pet at the beginning of the new turn (and doesn't get an action on that turn).
3. Pet 1 performs its action. If this results in Pet 2's defeat*, then you skip # 4.
4. Pet 2 performs its action.
5. DoTs deal their damage. Pet 1's DoTs (ie the DoTs that are on Pet 1) will deal damage first, but regardless whether Pet 1 dies in this phase, Pet 2's DoTs will still deal damage. This also includes delayed damage effects such as Elementium Bolt or Whirlpool, and aura/environmental effects such as Immolation or Scorched Earth.
6. Reflection phase. If a pet used Reflection, then the most recently prevented ability will be performed after all DoTs and delayed effects.
7. Humanoid passive ability phase. As far as I can tell, this always happens at the very end of the turn--if a humanoid pet dealt any damage in phases 3-6, it will receive one heal for 7% of its max health in this phase.
When a pet dies, the round continues through to the end. This includes reducing the duration of any field effects (Flamethrower), and any delayed damage abilities that would have triggered that round will trigger (e.g. Elementium Bolt). There's no pet to deal damage to, but they trigger nonetheless. On the next round, the new pet will swap in. When the new pet swaps in due to prior pet death, this actually gets its own round, with no other phases, and then the battle will skip to the next round. If the new pet swapped in due to a pet swap action, then the new pet doesn't get an action, but the other phases occur.
I chose to separate phases this way according to when a winner can be determined. Ie, I chose each pet's action phase to be separate because a winner can be determined after the first pet's action. In contrast, I lumped DoT damage from both pets into one phase, since even if pet 2 dies from DoT damage (and is the last pet on its team), this will not cause pet 1's team to immediately win. Instead, pet 1 still takes DoT damage in this phase, and if it dies and is the last pet on its team, the match is a draw.
* I changed this to 'defeat', because in the case of Mechanicals or Undead, the pet immediately gets back up after dying, and the turn continues as if the pet didn't die.
Last edited by Poofah
on January 4th, 2013, 1:15 pm, edited 5 times in total.