acousticAlarms.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_GUMP_SEARCH):
  54. winsound.Beep(2800, 1000)
  55. # check for low life
  56. if ALERT_ON_LOW_LIFE and Player.Hits < HITPOINTS_ALERT_VALUE:
  57. winsound.Beep(1800, 1000)
  58. # check for dura
  59. if ALERT_ON_LOW_DURABILITY:
  60. for layer in LAYERS_TO_CHECK:
  61. myitem = Player.GetItemOnLayer(layer)
  62. if myitem:
  63. #print(f"{layer}:{myitem.Name}")
  64. for p in myitem.Properties:
  65. if p.ToString().startswith("durability"):
  66. [current_dur, max_dur] = p.Args.split()
  67. if int(current_dur) <= LAYERS_DURABILITY_ALERT_VALUE:
  68. winsound.Beep(1400, 300)
  69. Misc.Pause(200)
  70. winsound.Beep(1500, 300)
  71. Misc.Pause(200)
  72. winsound.Beep(1600, 300)
  73. Misc.Pause(200)
  74. break
  75. # lets pause for a while, we dont need to check all the time
  76. Misc.Pause(2500)
  77. # lastly, we check the journal for AFK messages
  78. if ALERT_ON_AFK:
  79. if Journal.Search(AFK_JOURNAL_SEARCH):
  80. winsound.Beep(2800, 1000)
  81. if __name__ == '__main__':
  82. start()