Shell Trap is a decreased priority move. The user sets up a trap at the beginning of the turn, then executes the move Shell Trap at -3 priority if it has been hit by an opponent's physical move this turn. If the user has not been hit by an opponent's physical move at the time it would execute Shell Trap, Shell Trap fails. If the user is affected by Powder, Powder will trigger when the user of Shell Trap is hit by a physical attack.
The user being hit by an ally's move or its substitute being hit is not sufficient to allow the move to be used successfully.
Due to a glitch, if a Pokémon's use of Shell Trap is preempted by Encore to lock it into another move instead, and the Pokémon is then hit by a physical attack on any turn before Encore ends, the Pokémon's next use of Shell Trap will skip the step of setting a trap, and the move will go off successfully at its normal priority regardless of whether it was hit in the current turn.