Advertisement
FocusedWolf

EFT: Clock

Jul 26th, 2023 (edited)
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 15.67 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. # Version 38 - A tarkov reddit moderator permanently banned me for saying this so i feel obligated to repost it here because i hate censorship: "Don't play Arenas. That's the sink for autist cheaters. Every game has someone that walks around like a bot with a crosshair locked on your forehead".
  4.  
  5. # POSTED ONLINE: https://pastebin.com/BZV5c4a6
  6.  
  7. # SOURCE: https://tarkov-time.adam.id.au/
  8. # SOURCE: https://www.reddit.com/r/EscapefromTarkov/comments/u89ccn/i_made_a_physical_eft_clock_so_i_can_tell_when/i5kg22h/
  9. # SOURCE: https://escapefromtarkov.fandom.com/wiki/How_to_Play_Guide_for_Escape_from_Tarkov#IRL_time_vs_EFT_time
  10. # SOURCE: https://www.reddit.com/r/EscapefromTarkov/comments/ur05bc/at_what_time_of_the_raid_is_it_the_most_dark/
  11.  
  12. # -----
  13.  
  14. # Added text to prevent emoji replacement which tend to be smaller.
  15. CULTIST = '~&' # Cultist with a poison knife.
  16. #  CULTIST = "🗡\uFE0E"
  17. #  CULTIST = "🥷"
  18. #  CULTIST = "⛧\uFE0E"
  19. #  CULTIST = "🕯\uFE0E" # Only Windows 11 terminal can show this emoji.
  20. CULTIST = "🕯 " # Only Windows 11 terminal can show this emoji. Suddenly now i need to replace \uFE0E with space to fix alignment issue?
  21.  
  22. LEFT_ARROW = '<'
  23. LEFT_ARROW = "â—€"
  24.  
  25. RIGHT_ARROW = '>'
  26. RIGHT_ARROW = "â–¶"
  27.  
  28. # -----
  29.  
  30. PURPLE = '\033[38;2;177;72;198m' # Mingw64 purple.
  31. #  PURPLE = '\033[38;2;128;0;128m' # True purple.
  32. #  PURPLE = '\033[38;2;255;0;255m' # Brighter.
  33.  
  34. BLACK = '\033[30m'
  35. RED = '\033[31m'
  36. GREEN = '\033[32m'
  37. YELLOW = '\033[33m'
  38. BLUE = '\033[34m'
  39. MAGENTA = '\033[35m'
  40. CYAN = '\033[36m'
  41. WHITE = '\033[37m'
  42. BRIGHT_BLACK = '\033[90m'
  43. BRIGHT_RED = '\033[91m'
  44. BRIGHT_GREEN = '\033[92m'
  45. BRIGHT_YELLOW = '\033[93m'
  46. BRIGHT_BLUE = '\033[94m'
  47. BRIGHT_MAGENTA = '\033[95m'
  48. BRIGHT_CYAN = '\033[96m'
  49. BRIGHT_WHITE = '\033[97m'
  50. RESET = '\033[0m'
  51. BOLD = '\033[1m'
  52. HALF_BRIGHT = '\033[2m'
  53. ITALIC = '\033[3m'
  54. UNDERLINE = '\033[4m'
  55. REVERSED = '\033[7m'
  56.  
  57. # -----
  58.  
  59. DAY_BRIGHT = BRIGHT_YELLOW
  60. DAY_MORB = YELLOW
  61. NIGHT = BRIGHT_BLACK
  62. UI_CHEVRON = RED
  63. UI_CULTIST = RED
  64. UI_ETA = BRIGHT_WHITE #BRIGHT_CYAN
  65. UI_LABELS = CYAN
  66.  
  67. DAY_BRIGHT = WHITE
  68. DAY_MORB = YELLOW
  69. NIGHT = BRIGHT_BLACK
  70. UI_CHEVRON = RED
  71. UI_CULTIST = PURPLE #BRIGHT_MAGENTA
  72. UI_ETA = CYAN
  73. UI_LABELS = BRIGHT_GREEN #RED #BRIGHT_MAGENTA
  74.  
  75. #
  76. #  DAY_BRIGHT = WHITE
  77. #  DAY_MORB = YELLOW
  78. #  NIGHT = BRIGHT_BLACK
  79. #  UI_CHEVRON = RED
  80. #  UI_CULTIST = RED
  81. #  UI_ETA = RED
  82. #  UI_LABELS = RED#MAGENTA #BRIGHT_MAGENTA #BRIGHT_GREEN
  83.  
  84. # -----
  85.  
  86. #  DAY_BRIGHT = BOLD + BRIGHT_CYAN
  87. #  DAY_MORB = BOLD + BRIGHT_BLUE
  88. #  NIGHT = BOLD + BRIGHT_GREEN
  89. #  UI_CHEVRON = BOLD + RED
  90. #  UI_ETA = BOLD + BRIGHT_BLACK
  91. #  UI_LABELS = BOLD + BRIGHT_BLACK
  92.  
  93. # -----
  94.  
  95. import datetime
  96.  
  97. TARKOV_SECONDS_PER_SECOND = 7 # Seven seconds in Tarkov is one second IRL.
  98. CHARLIE_TIMEZONE = datetime.timezone(datetime.timedelta(hours=3)) # Tarkov uses St. Petersburg - MSK (UTC+3) timezone.
  99. TWELVE_HOUR_SHIFT = datetime.timedelta(hours=12) # Right time is +12 hours ahead of left time.
  100. def get_tarkov_time():
  101.     utc_time = datetime.datetime.now(datetime.timezone.utc)
  102.     tarkov_left_time = datetime.datetime.fromtimestamp(utc_time.timestamp() * TARKOV_SECONDS_PER_SECOND, CHARLIE_TIMEZONE)
  103.     tarkov_right_time = tarkov_left_time + TWELVE_HOUR_SHIFT
  104.     return tarkov_left_time, tarkov_right_time
  105.  
  106. def convert_tarkov_timedelta_to_irl(tarkov_time_delta):
  107.     irl_time_delta = tarkov_time_delta / TARKOV_SECONDS_PER_SECOND
  108.     # Zero the microseconds created by the division because this is the easiest way to hide them.
  109.     irl_time_delta_without_microseconds = irl_time_delta - datetime.timedelta(microseconds=irl_time_delta.microseconds)
  110.     return irl_time_delta_without_microseconds
  111.  
  112. # -----
  113.  
  114. TIME_PERIODS = [
  115.     (0,  'Moonrise'),
  116.     (1,  'Low Moon'),
  117.     (2,  'Medium Moon'),
  118.     (3,  'High Moon'),
  119.     (4,  'No Moon'),
  120.     (5,  'Dawn'),
  121.  
  122.     (6,  'Sunrise'),
  123.     (7,  'Morning'),
  124.     (8,  'Early Day'),
  125.     (9,  'Mid Morning'),
  126.     (10, 'Late Morning'),
  127.     (11, 'Pre Noon'),
  128.  
  129.     (12, 'High Noon'),
  130.     (13, 'Post Meridiem'),
  131.     (14, 'Early Afternoon'),
  132.     (15, 'Mid Afternoon'),
  133.     (16, 'Late Afternoon'),
  134.     (17, 'Pre Dusk'),
  135.  
  136.     (18, 'Early Dusk'),
  137.     (19, 'Late Dusk'),
  138.     (20, 'Sunset'),
  139.     (21, 'Twilight'),
  140.     (22, 'Early Night'),
  141.     (23, 'Deep Night'),
  142. ]
  143.  
  144. MAX_TIME_PERIOD_WIDTH = max(len(time_period[1]) for time_period in TIME_PERIODS)
  145. def get_time_period_name(date_time):
  146.     for hour, time_period in sorted(TIME_PERIODS, reverse=True):
  147.         if date_time.hour >= hour:
  148.             return time_period
  149.  
  150. def format_time(date_time):
  151.     return date_time.strftime('%H:%M:%S')
  152.  
  153. def format_hour(date_time):
  154.     return date_time.strftime('%H')
  155.  
  156. def format_eta(time_delta):
  157.     total_seconds = int(time_delta.total_seconds())
  158.     days, remainder = divmod(total_seconds, 86400)
  159.     hours, remainder = divmod(remainder, 3600)
  160.     minutes, seconds = divmod(remainder, 60)
  161.     return f'T-{f"{days:02d}:" if days > 0 else ""}{hours:02d}:{minutes:02d}:{seconds:02d}'
  162.  
  163. # -----
  164.  
  165. def day_night_rotate_eta(date_time):
  166.     if is_bright_daylight(date_time):
  167.         future_time = datetime.time(hour=BRIGHT_DAYLIGHT_END, minute=0, second=0)
  168.     else:
  169.         future_time = datetime.time(hour=BRIGHT_DAYLIGHT_START, minute=0, second=0)
  170.     return eta(date_time, future_time)
  171.  
  172. # The left and right times are 12 hours apart.
  173. DAY_START = 6
  174. DAY_END = DAY_START + 12
  175. def is_day(date_time):
  176.     return DAY_START <= date_time.hour < DAY_END
  177.  
  178. # SOURCE: https://www.reddit.com/r/EscapefromTarkov/comments/7wwbmw/bsg_why_are_there_16_hours_of_daylight_in_this/
  179. DAYLIGHT_END = DAY_START + 16 # Dim daylight end time.
  180. def is_any_daylight(date_time):
  181.     return DAY_START <= date_time.hour < DAYLIGHT_END
  182.  
  183. BRIGHT_DAYLIGHT_START = DAY_START + 2 # Bright daylight start time.
  184. BRIGHT_DAYLIGHT_END = DAY_END + 2 # Sun is setting.
  185. def is_bright_daylight(date_time):
  186.     return BRIGHT_DAYLIGHT_START <= date_time.hour < BRIGHT_DAYLIGHT_END
  187.  
  188. # SOURCE: ["Cultists appear between 22:00 and 7:00"] https://escapefromtarkov.fandom.com/wiki/Cultists
  189. # SOURCE: ["Between the times of 22:00 and 6:00"] https://youtu.be/pwIWGq6QACQ?si=fIPJFb-DrPObOzl_&t=269
  190. # SOURCE: ["So approximately 6:00 by Tarkov time they stand up and go into some place to despawn and just disappear. Their dead bodies do not disappear."] https://www.reddit.com/r/EscapefromTarkov/comments/14kan9b/i_always_was_wonder_how_when_and_does_cultists/
  191. # SOURCE: ["The Boss (Priest) spawns from 11PM to 6AM. After sunrise, the cultists disappear from the map."] https://tarkov.help/en/article/cultists
  192. # SOURCE: ["They absolutely despawn around 5:30 am"] https://www.reddit.com/r/EscapefromTarkov/comments/r14frs/cultist_despawn_at_daylight/
  193. # SOURCE: ["Cultists spawn from 23:00 (11 PM) to 5:00 (5 AM)"] https://www.reddit.com/r/EscapefromTarkov/comments/l69pvx/i_found_the_cultist_priest_on_day_time_woods/gkzxjpb/
  194. # SOURCE: ["I always thought they stopped spawning at 5 am not 7 am...22-5 you are correct."] https://www.reddit.com/r/EscapefromTarkov/comments/wvq6a4/how_do_cultist_spawns_really_work/
  195. # SOURCE: Cultist Spawn Locations: https://escapefromtarkov.fandom.com/wiki/Cultists
  196. #         Customs=1 priest + 4 warriors at scav base (ZB-013 extraction).
  197. #         Woods=1 priest + 4 warriors near their ritual places which are located west of sawmill and also at the dilapidated village in the north.
  198. #         Shoreline= 1 priest + 3 warriors at health resort and(rare)/or north-east of the swamp village.
  199. #         Night Factory=1 priest + 2 warriors.
  200. CULTIST_SPAWN_START = 22
  201. CULTIST_SPAWN_END = 5 # 7 # TODO: The wiki says 7 but a lot of sources say this should be 5, to represent 05:00 - 05:59, with 06:00 being when cultists despawn but need more info.
  202. #  CULTIST_SPAWN_END = 7 # This guy says 7 AM but probably just quoting wiki. https://www.reddit.com/r/EscapefromTarkov/comments/1eq4n55/discussion_cultist_dagger_farming_for_night_sweep/
  203. CULTIST_SPAWN_END = 6 # AI says its between 06:00 and 06:59 and then thats it, they are despawned.
  204. def is_cultist_time(date_time):
  205.     return not (CULTIST_SPAWN_END < date_time.hour < CULTIST_SPAWN_START)
  206.  
  207. def eta(date_time, future_time):
  208.     future_date_time = date_time.replace(hour=future_time.hour, minute=future_time.minute, second=future_time.second)
  209.     if future_date_time < date_time:
  210.         future_date_time += datetime.timedelta(days=1)
  211.     remaining_time_delta = future_date_time - date_time
  212.     return remaining_time_delta, future_date_time
  213.  
  214. def color_hour(string, date_time):
  215.     return color(string, DAY_BRIGHT if is_bright_daylight(date_time) else DAY_MORB if is_any_daylight(date_time) else NIGHT)
  216.  
  217. def color(var, color):
  218.     return color + str(var) + RESET
  219.  
  220. def color_ljust(string, width, fillchar=' '):
  221.     if color_len(string) >= width:
  222.         return string
  223.     return string + fillchar * (width - color_len(string))
  224.  
  225. def color_rjust(string, width, fillchar=' '):
  226.     if color_len(string) >= width:
  227.         return string
  228.     return fillchar * (width - color_len(string)) + string
  229.  
  230. import re
  231. def color_len(string):
  232.     # Remove color codes to measure visible characters.
  233.     return len(re.sub(r'\033\[\d+m', '', string))
  234.  
  235. import os
  236. def clear():
  237.     os.system('cls' if os.name in ('nt', 'dos') else 'clear')
  238.  
  239. import time
  240. def sleep(milliseconds):
  241.     time.sleep(milliseconds / 1000)
  242.  
  243. ALIGN_LEFT = '<'
  244. ALIGN_RIGHT = '>'
  245. ALIGN_CENTER = '^'
  246.  
  247. # -----
  248.  
  249. def main():
  250.     while True:
  251.         clear() # Need to clear before color(...) can be used.
  252.         print()
  253.  
  254.         left_time, right_time = get_tarkov_time()
  255.         left_cultist = color(f'{" " + CULTIST if is_cultist_time(left_time) else ""}', UI_CULTIST)
  256.         right_cultist = color(f'{CULTIST + " " if is_cultist_time(right_time) else ""}', UI_CULTIST)
  257.         left_time_display = color_hour(f'{get_time_period_name(left_time)} {format_time(left_time)}', left_time) + left_cultist
  258.         right_time_display = right_cultist + color_hour(f'{format_time(right_time)} {get_time_period_name(right_time)}', right_time)
  259.  
  260.         day_night_composition = 'â–›' if is_day(left_time) else 'â–œ'
  261.         bright_daylight_eta, left_day_night_sector_time = day_night_rotate_eta(left_time)
  262.         #  print(f' {color(f" Tarkov Times:", UI_LABELS)} {color("[", UI_LABELS)} {left_time_display} {color("-", UI_LABELS)} {right_time_display} {color("]", UI_LABELS)} {color(day_night_composition, DAY_MORB)} {color(format_eta(convert_tarkov_timedelta_to_irl(bright_daylight_eta)), UI_ETA)}')
  263.         print(f' {color(f" Tarkov Times:", UI_LABELS)} {color("[", UI_LABELS)} {left_time_display} {color("-", UI_LABELS)} {right_time_display} {color("]", UI_LABELS)} {color(day_night_composition, DAY_BRIGHT)} {color(format_eta(convert_tarkov_timedelta_to_irl(bright_daylight_eta)), UI_ETA)}')
  264.  
  265.         # -----
  266.  
  267.         # TODO: commented out because its redundant with cultist-spawn indicators on the vertical times.
  268.         #
  269.         # Print horizontal time-progressbar.
  270.         #  print()
  271.         #  print('  ', end='')
  272.         #  # For [0,24).
  273.         #  for h in range(24):
  274.         #      h_time = datetime.time(hour=h)
  275.         #      if is_cultist_time(h_time):
  276.         #          print(color(f'{CULTIST} ', UI_CULTIST), end='')
  277.         #      else:
  278.         #          print('   ', end='')
  279.         #  print()
  280.         #  print('  ', end='')
  281.         #  # For [0,24).
  282.         #  for h in range(24):
  283.         #      h_time = datetime.time(hour=h)
  284.         #      if h == left_time.hour or h == right_time.hour:
  285.         #          print(color_hour(f'╳╳ ', h_time), end='')
  286.         #          #  print(color_hour(f'◀▶ ', h_time), end='')
  287.         #      else:
  288.         #          print(color_hour(f'██ ', h_time), end='')
  289.         #  print()
  290.         #  print('  ', end='')
  291.         #  # For [0,24).
  292.         #  for h in range(24):
  293.         #      h_time = datetime.time(hour=h)
  294.         #      print(color_hour(h_time.strftime('%H '), h_time), end='')
  295.         #  print()
  296.  
  297.         # -----
  298.  
  299.         # V2 - Added cultist-spawn indicators.
  300.         #
  301.         # Print time-period names while indicating which slot we are in.
  302.         print()
  303.         for h in range(DAY_START, DAY_END):
  304.             h_time = datetime.datetime.now().replace(hour=h, minute=0, second=0)
  305.             if not is_day(left_time):
  306.                 h_time -= TWELVE_HOUR_SHIFT
  307.             left_game_time = color_hour(f'{get_time_period_name(h_time):{ALIGN_RIGHT}{MAX_TIME_PERIOD_WIDTH}} {format_hour(h_time)}', h_time)
  308.             left_cultist = color(f'{CULTIST if is_cultist_time(h_time) else "  "}', UI_CULTIST)
  309.             left_arrow_time = color_hour(f'{LEFT_ARROW if left_time.hour == h_time.hour else " "}', h_time)
  310.             h_time += TWELVE_HOUR_SHIFT
  311.             right_arrow_time = color_hour(f'{RIGHT_ARROW if right_time.hour == h_time.hour else " "}', h_time)
  312.             right_cultist = color(f'{CULTIST if is_cultist_time(h_time) else "  "}', UI_CULTIST)
  313.             right_game_time = color_hour(f'{format_hour(h_time)} {get_time_period_name(h_time)}', h_time)
  314.             on_time = left_time.hour == h or right_time.hour == h
  315.             closest_time_eta = min(eta(left_time, h_time)[0], eta(right_time, h_time)[0])
  316.             irl_time = color(format_eta(convert_tarkov_timedelta_to_irl(closest_time_eta)), UI_ETA)
  317.             print(f' {left_game_time} {left_cultist} {left_arrow_time} {irl_time} {right_arrow_time} {right_cultist} {right_game_time}')
  318.  
  319.         # V1 - Arrows are colored based on the hour.
  320.         #
  321.         # Print time-period names while indicating which slot we are in.
  322.         #  print()
  323.         #  for h in range(DAY_START, DAY_END):
  324.         #      h_time = datetime.datetime.now().replace(hour=h, minute=0, second=0)
  325.         #      if not is_day(left_time):
  326.         #          h_time -= TWELVE_HOUR_SHIFT
  327.         #      left_game_time = color_hour(f'{get_time_period_name(h_time):{ALIGN_RIGHT}{MAX_TIME_PERIOD_WIDTH}} {format_hour(h_time)} {LEFT_ARROW if left_time.hour == h_time.hour else " "}', h_time)
  328.         #      h_time += TWELVE_HOUR_SHIFT
  329.         #      right_game_time = color_hour(f'{RIGHT_ARROW if right_time.hour == h_time.hour else " "} {format_hour(h_time)} {get_time_period_name(h_time)}', h_time)
  330.         #      on_time = left_time.hour == h or right_time.hour == h
  331.         #      closest_time_eta = min(eta(left_time, h_time)[0], eta(right_time, h_time)[0])
  332.         #      irl_time = color(format_eta(convert_tarkov_timedelta_to_irl(closest_time_eta)), UI_ETA)
  333.         #      print(f' {left_game_time} {irl_time} {right_game_time}')
  334.  
  335.         # V0 - Arrows are colored UI_CHEVRON.
  336.         #
  337.         # Print time-period names while indicating which slot we are in.
  338.         #  print()
  339.         #  for h in range(DAY_START, DAY_END):
  340.         #      h_time = datetime.datetime.now().replace(hour=h, minute=0, second=0)
  341.         #      if not is_day(left_time):
  342.         #          h_time -= TWELVE_HOUR_SHIFT
  343.         #      left_game_time = color_hour(f'{get_time_period_name(h_time):{ALIGN_RIGHT}{MAX_TIME_PERIOD_WIDTH}} {format_hour(h_time)}', h_time)
  344.         #      h_time += TWELVE_HOUR_SHIFT
  345.         #      right_game_time = color_hour(f'{format_hour(h_time)} {get_time_period_name(h_time)}', h_time)
  346.         #      on_time = left_time.hour == h or right_time.hour == h
  347.         #      left_arrow = color(LEFT_ARROW if on_time else ' ', UI_CHEVRON)
  348.         #      closest_time_eta = min(eta(left_time, h_time)[0], eta(right_time, h_time)[0])
  349.         #      irl_time = color(format_eta(convert_tarkov_timedelta_to_irl(closest_time_eta)), UI_ETA)
  350.         #      right_arrow = color(RIGHT_ARROW if on_time else ' ', UI_CHEVRON)
  351.         #      print(f' {left_game_time} {left_arrow} {irl_time} {right_arrow} {right_game_time}')
  352.  
  353.         sleep(1000)
  354.  
  355. if __name__ == '__main__':
  356.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement