Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, math
- import time as emit
- # Approximate target size - target relative to ground and approximate middle; all xyz from here on in meters
- sidehead = [[-0.047, 1.8], [0.166, 1.8], [0.166, 1.562], [0.036, 1.562], [-0.047, 1.645], 2.0]
- sidebody = [[-0.032, 1.63], [0.036, 1.562], [0.083, 1.562], [0.133, 1.367], [0.209, 1.299], [0.137, 1.223], [0.426, 1.151], [0.386, 1.079], [0.076, 1.136], [0.087, 0.963], [-0.173, 0.963], [-0.126, 1.104], [-0.198, 1.288], [-0.191, 1.504], [-0.032, 1.584], 1.0]
- sidelegs = [[-0.173, 0.963], [0.087, 0.963], [0.173, 0.66], [0.076, 0.357], [0.17, 0.278], [0.245, 0.278], [0.245, 0.213], [-0.014, 0.213], [-0.014, 0.548], [0.029, 0.628], [0.018, 0.667], [-0.011, 0.563], [-0.195, 0.227], [-0.162, 0.119], [-0.083, 0.069], [-0.083, 0.025], [-0.17, 0.004], [-0.314, 0.072], [-0.314, 0.249], [-0.137, 0.61], 0.9]
- fronthead = [[-0.095, 1.8], [0.07, 1.8], [0.07, 1.573], [-0.095, 1.573], 2.0]
- frontbody = [[-0.062, 1.573], [0.07, 1.573], [0.227, 1.477], [0.301, 1.147], [0.147, 1.103], [0.154, 1.224], [0.132, 1.356], [0.198, 1.228], [0.154, 1.224], [0.147, 1.103], [0.172, 0.946], [-0.132, 0.946], [-0.125, 1.254], [-0.194, 1.202], [-0.224, 1.257], [-0.29, 1.21], [-0.345, 1.276], [-0.062, 1.51], 1.0]
- frontlegs = [[-0.132, 0.946], [0.172, 0.946], [0.187, 0.583], [0.286, 0.319], [0.286, 0.004], [0.180, 0.004], [0.187, 0.268], [0.048, 0.594], [0.022, 0.851], [-0.066, 0.583], [-0.066, 0.213], [-0.293, 0.176], [-0.315, 0.246], [-0.158, 0.304], [-0.187, 0.781], 0.9]
- mite = emit.time()
- for acc in range(0, 101, 10): # Accuracy skill
- for z in range(1, 101, 9): # Range
- fail = open('acc' + str(acc) + ' z' + str(z) + '.txt', 'w')
- for tary in range(20, -1, -1):
- for tarx in range(11):
- tarx, tary = tarx / 10.0 - 0.5, tary / 10.0
- ytar = tary + 5.625 * (z / 600.0) ** 2
- xaim, yaim = 0.0, math.atan((ytar - 1.6) / z) # Aim angle
- xrec, yrec, cof = 0.0, 0.0, 0.1 # Recoil and CoF
- aimt, dmg = 0.08, 0
- for x in range(3):
- # Hit location
- angle = random.uniform(0, 2 * math.pi)
- rad = cof * random.random() ** 0.5
- xang = math.tan((rad * math.sin(angle) + xrec + xaim) / 180 * math.pi)
- yang = math.tan((rad * math.cos(angle) + yrec + yaim) / 180 * math.pi)
- px = x * xang
- py = x * yang + 1.6
- l = (z ** 2 * (1 + xang ** 2 + yang ** 2)) ** 0.5
- py -= 5.625 * (l / 600) ** 2
- # Hit detection
- hit = False
- for target in [fronthead, frontbody, frontlegs]:
- p1x = target[-2][0] + tarx
- p1y = target[-2][1]
- for p2x, p2y in target[:-1]:
- p2x += tarx
- if py >= min(p1y, p2y) and py <= max(p1y, p2y) and px >= min(p1x, p2x):
- if p1y != p2y:
- xinter = (py - p1y) * (p2x - p1x) / (p2y - p1y) + p1x
- if p1x == p2x or px >= xinter:
- hit = not hit
- p1x, p1y = p2x, p2y
- if hit:
- dmg += 10 * target[-1]
- break
- # Recoil
- if xrec >= 0.5:
- direct = -1
- elif xrec <= -0.5:
- direct = 1
- else:
- direct = (-1) ** random.randint(1, 2)
- angle = random.uniform(-2, 2) / 180 * math.pi
- horiz = random.uniform(0.2, 0.2) * direct
- verti = 0.4
- if x == 0:
- verti *= 2
- xrec += verti * math.sin(angle) + horiz * math.cos(angle)
- yrec += verti * math.cos(angle) - horiz * math.sin(angle)
- if cof <= 29.95:
- cof += 0.05
- else:
- cof = 3
- # Recoil compensation
- verti = 0.4 * acc / 100
- verti = random.uniform(verti, 0.8 - verti)
- if x == 0 and acc > 75:
- verti += 0.4 * (acc - 75) / 25
- yaim -= verti
- aimt += 0.08
- if aimt >= 0.25:
- angle = (-xaim - xrec) * acc / 100
- xaim += random.uniform(angle, 2 * (-xaim - xrec) - angle)
- angle = math.atan((ytar - 1.6) / z) - yaim - yrec
- yaim += random.uniform(angle * acc / 100, 2 * angle - angle * acc / 100)
- aimt -= 0.25
- # Lead moving targets by 0 - 2x with 0 acc, and x with 100 acc
- fail.write(str(int(dmg)).rjust(3) + ' ')
- fail.write('\n')
- fail.close()
- print emit.time() - mite
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement