If the battle takes place in a town, the walls protect against ranged damage. If a shot is fired along a direct line passing through a breach in the wall, created by a catapult, then the walls no longer provide protection.
Auto-translated