Hiding behind a wall
If you have partial cover, you may use Stealth. If you have total cover (wall is taller than you, or floor-to-ceiling, or whatever), you don’t even need Stealth. So you may hide behind a wall.
Readying an attack
You may then ready an attack for when he enters a square next to you, since an Attack Action may be done as a Standard and you are allowed to ready those. Your DM may require that you specify which square; the rules leave it up to the DM how specific you have to be. In any event, if this readied action is triggered, however specific your DM requires it to be, you then attack the target.
Sneak Attack?
The most recent errata gives you Total Concealment until after you make an attack. So what does that give you? Well, it means he doesn’t know what square you’re in and takes a 50% miss chance even if he guesses the right square. Does that let you Sneak Attack?
No. It does not. Sneaking does not actually let you Sneak Attack.
Commentary on this errata seems to indicate that the point of the errata was to allow rogues to Sneak Attack while, ya know, sneaking, but that doesn’t actually seem borne out by the rules.
So the rules don’t actually give you a Sneak Attack, even though you are considered “hidden” for that first attack (the one you readied). If your DM is sane, he’ll allow sneaking to trigger Sneak Attacks, because it’s ridiculous that the rules don’t allow it. Paizo’s lead dev has even stated (if you go digging through the forums) that it’s supposed to work; why he doesn’t just fix the rules is anyone’s guess, but there it is. Ultimately, this is something you’ll have to ask your DM about.
Does this sound flawed...or brilliant?
Considering that it doesn’t work, quite flawed, but even if we assume it’s allowed to work, it’s still pretty poor damage most of the time. Rogues tend to have very little combat presence at mid-to-high levels if they can’t get full attacks with Two-Weapon Fighting to multiply their Sneak Attack damage. At low levels, it could be a useful trick.
Of course, with the various ways that Pathfinder has shafted rogues’ ability to Sneak Attack multiple times in a round, it may be the best you can hope for. Unfortunately, it’s not very good.
No, because the two conditions do not encompass every possibility.
If the Swashbuckler (S) has interposed himself between an Ally (A) and an Opponent (O). Each occupies a single five by five square.
Such as:
ASO
In this scenario, an ally is within 5 feet from the swashbuckler, but there isn't an ally within 5 feet of the opponent. Lacking an additional effect that will provide advantage to the Swashbuckler, Sneak Attack won't be available.
Similarly, if the Swashbuckler (S) is facing two Opponents (O and X), there are several configurations in which Sneak Attack isn't available.
To summarize, the following conditions will prohibit you from using Sneak Attack, assuming there isn't an external effect providing Advantage.
- Swashbuckler is within 5 feet of more than one hostile creature or character.
- Swashbuckler is attacking the target at melee range and a friendly character or creature is within 5 feet of him but isn't within 5 feet of the target.
Per a twitter post by Jeremy Crawford, Rules as Intended want the Swashbuckler to be within 5 feet of the target. In effect, Rackish Audacity should be written with "except" instead of "other."
Best Answer
Yes, rogues can sneak attack at range pretty effectively.
You're reading the rules right, and all a ranged rogue needs for sneak attack is an ally's adjacency. (Actually, an enemy-of-my-enemy's adjacency, not necessarily an ally.)
Shooting in to melee...
may, at your GMs discretion, call cover into question. Review PHB p. 196: intervening combatants might grant your target +2 or +5 AC, or might make them untargetable (total cover).
Personally, I'm pretty liberal about throwing that +2 AC around during combat (in both directions), but pretty stingy on the higher penalties. As long as it's well-known ahead of time my players haven't seemed to mind. (And I'm very clear about applying it to enemies.)