If an encounter begins, shift to encounter mode by having everyone roll initiative, as described in
Starting the Encounter. Call for initiative once a trap is triggered, as soon as two opposing groups come into contact, or when a creature on one side decides to take action against the other. In some cases, a trap or a foe has a reaction that tells you to roll initiative. For instance, a complex trap that's triggered might make an attack with its reaction before the initiative order begins. In these cases, resolve all the results of the reaction before calling for initiative rolls.