Advertisement
FocusedWolf

EFT: Turning Speed Penalty

Jul 26th, 2023 (edited)
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.65 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. # Online post:
  4. # https://pastebin.com/NMFSUWwL
  5. # https://www.reddit.com/r/EscapefromTarkov/comments/159rv3i/turn_speed/jtho4dq/
  6.  
  7. ALIGN_LEFT = '<'
  8. ALIGN_RIGHT = '>'
  9. ALIGN_CENTER = '^'
  10.  
  11. DIVIDER = '┃'
  12. SEPARATOR = ' → '
  13. COLUMNS = 3
  14. def printCounterTurningSpeedHipfireSensTable(adsSensitivity, maxTurningSpeedDelay = 99):
  15.     print(f' Turning Speed Penalty{SEPARATOR}Mouse Sensitivity (Hip Fire)\n')
  16.     TURNING_SPEED_PENALTY_MAX_WIDTH = len(str(-maxTurningSpeedDelay))
  17.     HIPFIRE_SENSITIVITY_MAX_WIDTH = len(roundStr(calculateCounterTurningSpeedHipfireSens(adsSensitivity, maxTurningSpeedDelay), 2))
  18.     for turningSpeedDelay in range(1, maxTurningSpeedDelay + 1):
  19.         hipfireSensitivity = calculateCounterTurningSpeedHipfireSens(adsSensitivity, turningSpeedDelay)
  20.         print(f' {DIVIDER} {-turningSpeedDelay:{ALIGN_LEFT}{TURNING_SPEED_PENALTY_MAX_WIDTH}}{SEPARATOR}{roundStr(hipfireSensitivity, 2):{ALIGN_RIGHT}{HIPFIRE_SENSITIVITY_MAX_WIDTH}}', end='')
  21.         if turningSpeedDelay % COLUMNS == 0 or turningSpeedDelay == maxTurningSpeedDelay:
  22.             print(f' {DIVIDER}')
  23.  
  24. # SOURCE: https://www.reddit.com/r/EscapefromTarkov/comments/epc7ly/turn_speed_spreadsheet/
  25. # SOURCE: https://drive.google.com/file/d/1iiGsLmaxB-Ijagh17ibg94dymToH7nT9/view
  26. def calculateCounterTurningSpeedHipfireSens(adsSensitivity, turningSpeedDelay):
  27.     turningSpeedDelayPercent = turningSpeedDelay / 100
  28.     inputTurningSpeedBoostPercent = 1 - turningSpeedDelayPercent
  29.     hipfireSensitivity = adsSensitivity / inputTurningSpeedBoostPercent
  30.     return hipfireSensitivity
  31.  
  32. def roundStr(number, digits=0):
  33.     return ('{{:.{}f}}'.format(digits)).format(roundHalfAwayFromZero(number, digits))
  34.  
  35. # Round half-away-from-zero.
  36. # SOURCE: https://realpython.com/python-rounding/
  37. # SOURCE: https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero
  38. import math
  39. def roundHalfAwayFromZero(number, decimals=0):
  40.     multiplier = 10 ** decimals
  41.     if number >= 0:
  42.         return math.floor(number * multiplier + 0.5) / multiplier
  43.     else:
  44.         return math.ceil(number * multiplier - 0.5) / multiplier
  45.  
  46. import os
  47. def clear():
  48.     os.system('cls' if os.name in ('nt', 'dos') else 'clear')
  49.  
  50. def wait_for_enter_keypress():
  51.     import getpass
  52.     getpass.getpass('Press ENTER to continue . . . ')
  53.  
  54. def main():
  55.     while True:
  56.         try:
  57.             adsSensitivity = float(input(' Mouse Sensitivity (ADS): '))
  58.         except:
  59.             clear()
  60.         else:
  61.             break
  62.  
  63.     print()
  64.     printCounterTurningSpeedHipfireSensTable(adsSensitivity)
  65.     print()
  66.  
  67.     wait_for_enter_keypress()
  68.  
  69. if __name__ == '__main__':
  70.      main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement