Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.73 KB | None | 0 0
  1. # 00 - Name
  2. # 01 - Empire
  3. # 02 - Type
  4. # 03 - Max Damage
  5. # 04 - Max Range
  6. # 05 - Min Damage
  7. # 06 - Min Range
  8. # 07 - Fire Mode
  9. # 08 - Short Reload
  10. # 09 - Long Reload
  11. # 10 - Mag Size
  12. # 11 - Ammo Pool
  13. # 12 - Vertical Recoil
  14. # 13 - Minimum Horizontal Recoil
  15. # 14 - Maximum Horizontal Recoil
  16. # 15 - Horizontal Recoil Tolerance
  17. # 16 - Minimum Recoil Angle
  18. # 17 - Maximum Recoil Angle
  19. # 18 - Horizontal Recoil Bias
  20. # 19 - Recoil Decrease
  21. # 20 - First Shot Recoil Multiplier
  22. # 21 - ADS Move Speed Multiplier
  23. # 22 - ADS COF Stand Still
  24. # 23 - ADS COF Stand Move
  25. # 24 - ADS COF Crouch Still
  26. # 25 - ADS COF Crouch Move
  27. # 26 - Hip COF Stand Still
  28. # 27 - Hip COF Stand Move
  29. # 28 - Hip COF Stand Sprint
  30. # 29 - Hip COF Crouch Still
  31. # 30 - Hip COF Crouch Move
  32. # 31 - ADS COF Bloom
  33. # 32 - Hip COF Bloom
  34. # 33 - Rate of Fire
  35. # 34 - Bullet Speed
  36. # 35 - Pellet Count
  37. # 36 - Pellet Spread
  38.  
  39. import random, math
  40. import time as emit
  41. # Data in
  42. weps, fail = [], open('weps.txt', 'r')
  43. for line in fail:
  44.     weps.append(line.split('\t'))
  45. fail.close()
  46. for x in range(len(weps)):
  47.     for y in range(len(weps[x])):
  48.         try: weps[x][y] = float(weps[x][y])
  49.         except: pass
  50.  
  51. # Approximate target size - target relative to ground and (soon not) approximate middle; all xyz from here on in meters.
  52. sidehead = [[-0.047, 1.8], [0.166, 1.8], [0.166, 1.562], [0.036, 1.562], [-0.047, 1.645], 2.0]
  53. 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]
  54. 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]
  55. fronthead = [[-0.095, 1.8], [0.07, 1.8], [0.07, 1.573], [-0.095, 1.573], 2.0]
  56. 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]
  57. 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]
  58.  
  59. for wep in weps: # Replace with cycling through all the weapons (X), as many ranges as possible (X), add mutiple passes for each for an approximation. (Density of ranges and amount of passes is dependent on how much time the program takes.)
  60.     print 'Starting', wep[0]
  61.     for stance in [0, 1, 5]:
  62.         fail = open(str(wep[0]) + ' ' + str(stance) + '.txt', 'w')
  63.         fail.write('\t')
  64.         for x in range(1, 101):
  65.             fail.write(str(x).rjust(3) + '\t')
  66.         fail.write('\n')
  67.         #print wep[0], str(stance) + ':',
  68.         for acc in range(0, 101): # Accuracy skill
  69.             fail.write(str(acc).rjust(3) + '\t')
  70.             for z in range(1, 101): # Range
  71.                 ytar = 1.2 + 5.625 * (z / wep[34]) ** 2 # Go through the test program
  72.                 xaim, yaim = 0.0, math.atan((ytar - 1.6) / z) # Aim angle
  73.                 xrec, yrec, cof = 0.0, 0.0, wep[22 + stance] # Recoil and CoF
  74.                 ammo, hp, ttk, aimt = wep[10], 1000.0, -60 / wep[33] + z / wep[34], 60 / wep[33]
  75.                 while ammo != 0 and hp > 0:
  76.                                        
  77.                     # Hit location
  78.                     angle = random.uniform(0, 2 * math.pi)
  79.                     rad = cof * random.random() ** 0.5
  80.                     xang = math.tan((rad * math.sin(angle) + xrec + xaim) / 180 * math.pi)
  81.                     yang = math.tan((rad * math.cos(angle) + yrec + yaim) / 180 * math.pi)
  82.                     px = z * xang
  83.                     py = z * yang + 1.6
  84.                     l = (z ** 2 * (1 + xang ** 2 + yang ** 2)) ** 0.5
  85.                     py -= 5.625 * (l / wep[34]) ** 2
  86.                    
  87.                     # Hit detection
  88.                     hit = False
  89.                     for target in [fronthead, frontbody, frontlegs]:
  90.                         p1x = target[-2][0]
  91.                         p1y = target[-2][1]
  92.                         for p2x, p2y in target[:-1]:
  93.                             if py >= min(p1y, p2y) and py <= max(p1y, p2y) and px >= min(p1x, p2x):
  94.                                 if p1y != p2y:
  95.                                     xinter = (py - p1y) * (p2x - p1x) / (p2y - p1y) + p1x
  96.                                 if p1x == p2x or px >= xinter:
  97.                                     hit = not hit
  98.                             p1x, p1y = p2x, p2y
  99.                         if hit:
  100.                             if l <= wep[4]:
  101.                                 hp -= wep[3] * target[-1]
  102.                             elif l >= wep[6]:
  103.                                 hp -= wep[5] * target[-1]
  104.                             else:
  105.                                 hp -= (wep[3] - (l - wep[4]) * ((wep[3] - wep[5]) / (wep[6] - wep[4]))) * target[-1]
  106.                             break
  107.  
  108.                     # Recoil
  109.                     if xrec >= wep[15]:
  110.                         direct = -1
  111.                     elif xrec <= -wep[15]:
  112.                         direct = 1
  113.                     else:
  114.                         direct = (-1) ** random.randint(1, 2)
  115.                     angle = random.uniform(wep[16], wep[17]) / 180 * math.pi
  116.                     horiz = random.uniform(wep[13], wep[14]) * direct
  117.                     verti = wep[12]
  118.                     if ammo == wep[10]: # First Shot Recoil (Would have to re-do for burst fire.)
  119.                         verti *= wep[20]
  120.                     xrec += verti * math.sin(angle) + horiz * math.cos(angle)
  121.                     yrec += verti * math.cos(angle) - horiz * math.sin(angle)
  122.                     stan = (stance + 1) / 5
  123.                     if cof <= [3, 7][stan] - wep[31 + stan]:
  124.                         cof += wep[31 + stan]
  125.                     else:
  126.                         cof = [3, 7][stan]
  127.  
  128.                     # Recoil compensation
  129.                     angle = (wep[16] + wep[17]) / 360 * math.pi
  130.                     angle = random.uniform(angle * acc / 100, 2 * angle - angle * acc / 100)
  131.                     verti = wep[12] * acc / 100
  132.                     verti = random.uniform(verti, 2 * wep[12] - verti)
  133.                     if ammo == wep[10] and acc > 75:
  134.                         verti +=  wep[12] * (wep[20] - 1) * (acc - 75) / 25
  135.                     xaim -= verti * math.sin(angle)
  136.                     yaim -= verti * math.cos(angle)
  137.                     aimt += 60 / wep[33]
  138.                     if aimt >= 0.25:
  139.                         angle = (-xaim - xrec) * acc / 100
  140.                         xaim += random.uniform(angle, 2 * (-xaim - xrec) - angle)
  141.                         angle = math.atan((ytar - 1.6) / z) - yaim - yrec
  142.                         yaim += random.uniform(angle * acc / 100, 2 * angle - angle * acc / 100)
  143.                         aimt -= 0.25
  144.                     # Lead moving targets by 0 - 2x with 0 acc, and x with 100 acc
  145.  
  146.                     ammo -= 1
  147.                     ttk += 60 / wep[33]
  148.                 if hp <= 0:
  149.                     fail.write(str(ttk) + '\t')
  150.                     #print 'Dead in', ttk, 'sec.'
  151.                 else:
  152.                     fail.write('999\t')
  153.                     #print 'Alive with', hp, 'hp.'
  154.             fail.write('\n')
  155.         fail.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement