The physics
Split the launch velocity into two parts. The sideways part, ux = u cos θ, stays the same. The upward part, uy = u sin θ, falls by g every second.
x = u cos θ · t y = u sin θ · t − ½ g t²
R = u² sin 2θ / g H = u² sin² θ / 2g T = 2u sin θ / g
On a slope of angle α, fire from its foot. The range along the slope is:
R = 2u² sin(θ − α) cos θ / (g cos² α)
It is largest at θ = 45° + α/2.