acousticAlarms.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import winsound
  2. # ---------------------------------------------------------------------
  3. # CONFIGURE SECTION
  4. # ---------------------------------------------------------------------
  5. # Enable alerts for specified conditions
  6. ALERT_ON_LOW_DURABILITY = True
  7. ALERT_ON_AFK = True
  8. ALERT_ON_LOW_LIFE = True
  9. # LAYERS_TO_CHECK defines all the items slots the should be checked
  10. # for low durability.
  11. #
  12. # Possible values (string):
  13. # RightHand, LeftHand, Shoes, Pants, Shirt, Head, Gloves, Ring,
  14. # Neck, Hair, Waist, InnerTorso, Bracelet, FacialHair, MiddleTorso,
  15. # Earrings, Arms, Cloak, OuterTorso, OuterLegs, InnerLegs, Talisman
  16. LAYERS_TO_CHECK = ["Head",
  17. "Gloves",
  18. "Ring",
  19. "Neck",
  20. "Hair",
  21. "Waist",
  22. "InnerTorso",
  23. "Bracelet",
  24. "MiddleTorso",
  25. "Earrings",
  26. "Cloak",
  27. "OuterTorso",
  28. "OuterLegs",
  29. "InnerLegs"]
  30. # LAYERS_LOW_DURABILITY_TRESHOLD defines the treshold value for
  31. # acoustic alert on low durability.
  32. LAYERS_DURABILITY_ALERT_VALUE = 3
  33. # AFK_GUMP_SEARCH defined the a search string to look for in current
  34. # gump. When found there will be an acoustic alert.
  35. AFK_GUMP_SEARCH = 'AFK'
  36. # AFK_JOURNAL_SEARCH defined the a search string to look for in journal.
  37. # When found there will be an acoustic alert.
  38. AFK_JOURNAL_SEARCH = 'You cannot fight while being afk checked.'
  39. # HITPOINTS_ALERT_VALUE defines the treshold value for acoustic
  40. # acoustic alert on low life.
  41. HITPOINTS_ALERT_VALUE = 100
  42. # ---------------------------------------------------------------------
  43. # SCRIPT SECTION - DO NOT EDIT BELOW HERE
  44. # ---------------------------------------------------------------------
  45. # cold start until player is logged in
  46. if not Player.Connected:
  47. while not Player.Connected:
  48. Misc.Pause(5000)
  49. def start():
  50. while Player.Connected:
  51. Journal.Clear()
  52. # check for AFK in Gump
  53. if ALERT_ON_AFK and Gumps.LastGumpTextExist("AFK"):
  54. print("there is an AFK check!")
  55. winsound.Beep(2800, 1000)
  56. # check for low life
  57. if ALERT_ON_LOW_LIFE and Player.Hits < 100:
  58. winsound.Beep(1800, 1000)
  59. # check for dura
  60. if ALERT_ON_LOW_DURABILITY:
  61. for layer in LAYERS_TO_CHECK:
  62. myitem = Player.GetItemOnLayer(layer)
  63. if myitem:
  64. #print(f"{layer}:{myitem.Name}")
  65. for p in myitem.Properties:
  66. if p.ToString().startswith("durability"):
  67. [current_dur, max_dur] = p.Args.split()
  68. if int(current_dur) <= LAYERS_DURABILITY_ALERT_VALUE:
  69. winsound.Beep(1400, 300)
  70. Misc.Pause(200)
  71. winsound.Beep(1500, 300)
  72. Misc.Pause(200)
  73. winsound.Beep(1600, 300)
  74. Misc.Pause(200)
  75. break
  76. # lets pause for a while, we dont need to check all the time
  77. Misc.Pause(2500)
  78. # lastly, we check the journal for AFK messages
  79. if ALERT_ON_AFK:
  80. if Journal.Search('You cannot fight while being afk checked.'):
  81. winsound.Beep(2800, 1000)
  82. if __name__ == '__main__':
  83. start()