Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Double Cheat solution in Creative category for Shooting Range by Tinus_Trotyl
def shot(tp1, tp2, sp1, sp2):
x1, y1, x2, y2 = *sp1, *sp2
if x1 == x2: x1, x2= x1-1E-9*x1, x2+1E-9*x2 # CHEAT #1
dx, dy = x2 - x1, y2 - y1
xdir_s, xs = (dx > 0), x1 # x direction resp. x position of the shot
a_s, b_s = dy/dx, y1 - (dy/dx) * x1 # shot equation
x1, y1, x2, y2 = *tp1, *tp2
if x1 == x2: x1, x2= x1-1E-9*x1, x2+1E-9*x2 # CHEAT #2
dx, dy = x2 - x1, y2 - y1
a_t, b_t = dy/dx, y1 - (dy/dx) * x1 # target equation
x = (b_s - b_t) / (a_t - a_s) # x of hitpoint on target
xdir_t =(x - xs > 0) # x direction of hitpoint
if not xdir_s == xdir_t: return -1 # return -1 when shooting in the wrong direction
xm, xM = min(x1, x2), max(x1, x2) # domain of the wall (xm <= wall <= xM)
xm, xM = xm - 1E-6*(xM-xm), xM + 1E-6*(xM-xm) # make it a little less accurate to hide the cheats
if not xm <= x <= xM: return -1 # return -1 when hit target was not on wall
accurateness = round(100 * (1 - (abs(((xm + xM) / 2) - x) / (xM - xm)) * 2))
return accurateness # return the accurateness of the hit
July 17, 2017