Calculate the diffusion coefficient from a random walk with stay.

The approach you have is covered as Position Jump Process II in

Erban, Radek, and S. Jonathan Chapman. "Reactive boundary conditions for stochastic simulations of reaction–diffusion processes." Physical Biology 4.1 (2007): 16.

One important thing, normal distribution approximation of Brownian Motion, i.e.,

$$ P(x,t)=\frac{1}{\sqrt{2\pi Dt}}\exp(\frac{x^2}{4Dt}) $$

is only valid for no stay cases. If you have a stay probability, depending on how large the stay probability is, you will observe deviations from that formula. The reason is that this formula is derived as a limiting case of a binomial distribution where there are only two outcomes at each step using the Stirling approximation.

Back to the question, $D$ for no stay case is defined as

$$ D=\frac{l^2}{2\Delta{t}}, $$ where $l$ is the jump length. As you said, you can use mean squared displacement to calculate $D$ and for your case, it looks like

$$ D=\frac{\Delta{x}^2(1-2r\Delta{t})}{2\Delta{t}}. $$

PS: There are many other derivations of normal distribution, starting from binomial distribution is just one of them.