Pokémon Ruby Version, Sapphire Version, and Emerald Version - During the attack
If the attack hits and the attack deals damage, its damage is calculated.
Otherwise, if the attack hits, the attack’s effect happens, if possible.
If damage was dealt to a target and the target has a substitute and the substitute was defeated, it fades.