Guest User

Alerter

a guest
Jan 12th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 63.02 KB | None | 0 0
  1. #!/usr/bin/env python  
  2. # -*- coding: ISO-8859-1 -*-
  3.  
  4. '''
  5. sku wrote this program. As long as you retain this notice you
  6. can do whatever you want with this stuff. If we meet some day, and you think
  7. this stuff is worth it, you can buy me a beer in return.
  8. '''
  9.  
  10.  
  11. from os import system as OMGDONT
  12. from ModifierList import getModifier, getModifierName
  13. from ItemList import getItem, getItemName
  14. from NotifyItems import shouldNotify, isSearchItem, isFlaskItem, isQuestItem, isQuiverItem, isShieldItem, isBeltItem, isGemItem, isArmourItem, isCurrencyItem, isMapItem, isJewelleryItem, getSocketColor
  15. from ByteBuffer import ByteBuffer
  16. import ctypes
  17. import sys
  18. import threading
  19. import winsound
  20. import atexit
  21. import datetime
  22. import traceback
  23.  
  24. from colorama import init, Fore, Back, Style
  25.  
  26. init(autoreset=True)
  27.  
  28. try:
  29.     from pydbg import *
  30.     from pydbg.defines import *
  31. except:
  32.     print 'You seem to be missing pydbg or pydasm.'
  33.     print 'Precompiled binaries can be downloaded from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pydbg'
  34.     sys.exit(1)
  35.  
  36. ALERT_VERSION = 'Sep-11-2014'
  37. POE_VERSION = '1.2.2'
  38.  
  39. ###########################################################################################
  40. # Configuration for itemalerter. Only change these values.
  41. ###########################################################################################
  42.  
  43. # Debug settings#
  44. DEBUG = False # Logs output, also alerts to unknown items (in console and with sound)
  45. DEBUG_ALL = False #logs player joining, leaving, packets unrelated to loot
  46.  
  47. # Steam or standalone version of Path of Exile
  48. STEAM = True
  49.  
  50. ALIGN = 0x00400000
  51.  
  52. ################
  53. # Console Alerts
  54. ################
  55. ALERT_rares = True
  56. ALERT_quest = True # Alert for quest drops (medicine chest etc)
  57. ALERT_gems = True # Alert for special gems & superior gems
  58. ALERT_specialgems = True #portal/multistrike
  59. ALERT_quality = False # alert for quality equipment
  60. ALERT_flask = True # Alert for superior flasks & Granite Flask
  61. ALERT_maps = True
  62. ALERT_curr = True #currency alerts
  63. ALERT_5slot5link = True
  64. ALERT_6slot = True
  65. ALERT_6slot5link = True
  66. ALERT_6slot6link = True
  67. ALERT_jewellry = True #jewelry (gold amulet, etc)
  68. ALERT_race = False #race sockets (RRR, GGG, BBB)
  69.  
  70. ##############
  71. # Sound Alerts
  72. ##############
  73. SOUND_curr = True # Currency sounds, needs to be on to play any/all
  74. SOUND_rares = False
  75. SOUND_quest = False
  76. SOUND_superior = True #Alert for superior equipment
  77. SOUND_supflask = False
  78. SOUND_supgem = True # Alert for superior quality gems
  79. SOUND_uniques = True
  80. SOUND_slots = True # Alert if 5/6S and 5/6L.
  81. SOUND_specialgems = True # Alert if portal/multistrike
  82. SOUND_maps = True
  83. SOUND_rgb = False # Alert for RGB (Chromatic vendor recipe)
  84. SOUND_race = False # Alert if race sockets
  85. SOUND_graniteflask = False
  86.  
  87. ################
  88. #Currency Sounds
  89. ################
  90. SOUND_eternal = True
  91. SOUND_exalted = True
  92. SOUND_divine = True
  93. SOUND_gcp = True
  94. SOUND_regal = True
  95. SOUND_regret = True
  96. SOUND_vaal = True
  97. SOUND_chaos = True
  98. SOUND_blessed = True
  99. SOUND_scour = True
  100. SOUND_alc = False
  101. SOUND_fuse = False
  102. SOUND_chis = False
  103. SOUND_chroma = False
  104. SOUND_chance = True
  105. SOUND_jew = False
  106. SOUND_glass = False
  107. SOUND_mirror = True
  108. SOUND_feather = True # Albino Rhoa Feather
  109. SOUND_alter = False
  110. SOUND_trans = False
  111. SOUND_augmen = False
  112.  
  113. # Quality Modifiers & Other misc configurations
  114. ringmf = 15 # 6% is lowest a ring can have (0 to disable)
  115. amuletmf = 20 # 12% is the lowest an amulet can have (0 to disable)
  116. whiteitemqual = 15 # White Equipment quality modifier (0 to disable)
  117. rarityqual = 15 # Magic/Rare/Unique equipment quality modifier (0 to disable)
  118. gemqual = 5 # Gem quality modifier
  119. flaskqual = 15 # Flask quality modifier
  120. specialGems = '0x4C32EEEE,0x26856055' # Special gems. (Multistrike and Portal)
  121. race_sockets = ('R-R-R', 'G-G-G', 'B-B-B') # Special race related sockets.
  122.  
  123.  
  124. ################################
  125. ## UNUSED or Work-In-Progress ##
  126. ################################
  127.  
  128. #SHOW_OWN_ITEMS_ONLY = True
  129.  
  130. #Search special item, do NOT set to True, the required ilvl doesnt always work
  131. SEARCH_special = False
  132. special_class = 'CraftingChest'
  133. special_mod = 'Armour'
  134. special_ilvl = 62
  135. special_rlvl = 62
  136. ################################
  137.  
  138.  
  139.  
  140. ###########################################################################################
  141. # END OF CONFIG. Do not change whats below here unless you know what you are doing
  142. ###########################################################################################
  143.  
  144. RUN_START = 0
  145. RUN_END = 0
  146.  
  147. RUN = False
  148.  
  149. number_of_uniques = 0
  150. number_of_rares = 0
  151. number_of_orbs = 0
  152. number_of_maps = 0
  153.  
  154. class PlaySoundGraniteFlask(threading.Thread):
  155.     def run(self):
  156.         winsound.PlaySound(r'sounds\GraniteFlask.wav', winsound.SND_FILENAME)
  157.  
  158. class PlaySoundSup(threading.Thread):
  159.     def run(self):
  160.         winsound.PlaySound(r'sounds\SuperiorItem.wav', winsound.SND_FILENAME)
  161.  
  162. class PlaySoundFeather(threading.Thread):
  163.     def run(self):
  164.         winsound.PlaySound(r'sounds\Feather.wav', winsound.SND_FILENAME)
  165.  
  166. class PlaySoundChaos(threading.Thread):
  167.     def run(self):
  168.         winsound.PlaySound(r'sounds\ChaosOrb.wav', winsound.SND_FILENAME)
  169.  
  170. class PlaySoundRace(threading.Thread):
  171.     def run(self):
  172.         winsound.PlaySound(r'sounds\RaceItem.wav', winsound.SND_FILENAME)
  173.  
  174. class PlaySoundRGB(threading.Thread):
  175.     def run(self):
  176.         winsound.PlaySound(r'sounds\RGB.wav', winsound.SND_FILENAME)
  177.  
  178. class PlaySoundMaps(threading.Thread):
  179.     def run(self):
  180.         winsound.PlaySound(r'sounds\MapItem.wav', winsound.SND_FILENAME)
  181.  
  182. class PlaySound6Sockets(threading.Thread):
  183.     def run(self):
  184.         winsound.PlaySound(r'sounds\SixSockets.wav', winsound.SND_FILENAME)
  185.  
  186. class PlaySoundSixLink(threading.Thread):
  187.     def run(self):
  188.         winsound.PlaySound(r'sounds\SixLink.wav', winsound.SND_FILENAME)
  189.  
  190. class PlaySoundFiveLink(threading.Thread):
  191.     def run(self):
  192.         winsound.PlaySound(r'sounds\FiveLink.wav', winsound.SND_FILENAME)
  193.  
  194. class PlaySoundSixSlotFiveLink(threading.Thread):
  195.     def run(self):
  196.         winsound.PlaySound(r'sounds\SixSlotFiveLink.wav', winsound.SND_FILENAME)
  197.  
  198. class PlaySoundCraftingItem(threading.Thread):
  199.     def run(self):
  200.         winsound.PlaySound(r'sounds\CraftingItem.wav', winsound.SND_FILENAME)
  201.  
  202. class PlaySoundWorker(threading.Thread):
  203.     def run(self):
  204.         winsound.PlaySound(r'sounds\RaceItem.wav', winsound.SND_FILENAME)
  205.  
  206. class PlaySoundUnique(threading.Thread):
  207.     def run(self):
  208.         winsound.PlaySound(r'sounds\LegendaryPoE.wav', winsound.SND_FILENAME)
  209.  
  210. class PlaySoundSuperiorGem(threading.Thread):
  211.     def run(self):
  212.         winsound.PlaySound(r'sounds\SuperiorGem.wav', winsound.SND_FILENAME)
  213.  
  214. class PlaySoundExalted(threading.Thread):
  215.     def run(self):
  216.         winsound.PlaySound(r'sounds\ExaltedOrb.wav', winsound.SND_FILENAME)
  217.  
  218. class PlaySoundEternal(threading.Thread):
  219.     def run(self):
  220.         winsound.PlaySound(r'sounds\EternalOrb.wav', winsound.SND_FILENAME)
  221.  
  222. class PlaySoundKalandra(threading.Thread):
  223.     def run(self):
  224.         winsound.PlaySound(r'sounds\Eternalkalandra.wav', winsound.SND_FILENAME)
  225.  
  226. class PlaySoundHolyShit(threading.Thread):
  227.     def run(self):
  228.         winsound.PlaySound(r'sounds\HolyShit.wav', winsound.SND_FILENAME)
  229.  
  230. class PlaySoundQuest(threading.Thread):
  231.     def run(self):
  232.         winsound.PlaySound(r'sounds\QuestItem.wav', winsound.SND_FILENAME)
  233.  
  234. class PlaySoundSuperiorFlask(threading.Thread):
  235.     def run(self):
  236.         winsound.PlaySound(r'sounds\SuperiorFlask.wav', winsound.SND_FILENAME)
  237.  
  238. class PlaySoundUnknownItem(threading.Thread):
  239.     def run(self):
  240.         winsound.PlaySound(r'sounds\UnknownItem.wav', winsound.SND_FILENAME)
  241.  
  242. class PlaySoundSpecialItem(threading.Thread):
  243.     def run(self):
  244.         winsound.PlaySound(r'sounds\SpecialItem.wav', winsound.SND_FILENAME)
  245.  
  246. class PlaySoundVaal(threading.Thread):
  247.     def run(self):
  248.         winsound.PlaySound(r'sounds\VaalOrb.wav', winsound.SND_FILENAME)
  249.  
  250. class PlaySoundDivine(threading.Thread):
  251.     def run(self):
  252.         winsound.PlaySound(r'sounds\DivineOrb.wav', winsound.SND_FILENAME)
  253.  
  254. ##############################
  255. #### Not in use currently ####
  256. ##############################
  257. #class SoundPlayer(threading.Thread):
  258. #    def run(self, sound):
  259. #        winsound.PlaySound(r'sounds\\' + sound, winsound.SND_FILENAME)
  260. #        print >>self.logFile, str.format('Playing: {0!s}', sound)
  261.  
  262. ##############################
  263.  
  264. class ItemAlert(object):
  265.  
  266.     if not STEAM:
  267.         BP0 = 0x00281EDC + ALIGN
  268.         BP1 = 0x00281ED4 + ALIGN
  269.         BP2 = 0x00281F24 + ALIGN
  270.  
  271.     else:
  272.  
  273.         BP0 = 0x00281EDC + ALIGN
  274.         BP1 = 0x00281ED4 + ALIGN
  275.         BP2 = 0x00281F24 + ALIGN
  276.  
  277.  
  278. ####################################
  279. #               1.3.0
  280. #    if not STEAM:
  281. #        BP0 = 0x00281B39 + ALIGN
  282. #        BP1 = 0x00281B31 + ALIGN
  283. #        BP2 = 0x00281B7B + ALIGN
  284. #
  285. #    else:
  286. #
  287. #        BP0 = 0x00281B39 + ALIGN
  288. #        BP1 = 0x00281B31 + ALIGN
  289. #        BP2 = 0x00281B7B + ALIGN
  290. #
  291. ####################################
  292. #               1.2.1b
  293. #    if not STEAM:
  294. #
  295. #        BP0 = 0x002C1489 + ALIGN
  296. #        BP1 = 0x002C1481 + ALIGN
  297. #        BP2 = 0x006C2ACB + ALIGN
  298. #
  299. #    else:
  300. #
  301. #        BP0 = 0x002C4189 + ALIGN
  302. #        BP1 = 0x002C4181 + ALIGN
  303. #        BP2 = 0x002C41CB + ALIGN
  304. #    
  305. ######################################
  306. #               HISTORY
  307. ######################################
  308. ####################################
  309. #               1.1.3_r2
  310. #    if not STEAM:
  311. #
  312. #        BP0 = 0x00285FA9 + ALIGN
  313. #        BP1 = 0x00285FA1 + ALIGN
  314. #        BP2 = 0x00285FEB + ALIGN
  315. #
  316. #    else:
  317. #
  318. #        BP0 = 0x00287B79 + ALIGN
  319. #        BP1 = 0x00287B71 + ALIGN
  320. #        BP2 = 0x00287BBB + ALIGN
  321. ######################################
  322. #               1.1.3_r2
  323. #    Non-Steam
  324. #        BP0 = 0x00286079 + 0x00400000
  325. #        BP1 = 0x00286071 + 0x00400000
  326. #        BP2 = 0x002860bb + 0x00400000
  327. #    Steam
  328. #         BP0 = 0x00287B09 + 0x00400000
  329. #        BP1 = 0x00287B01 + 0x00400000
  330. #        BP2 = 0x00287B4B + 0x00400000
  331. ######################################
  332. #               1.1.3
  333. #    Non-Steam
  334. #        BP0 = 0x00285349 + 0x00400000
  335. #        BP1 = 0x00285341 + 0x00400000
  336. #        BP2 = 0x0028538B + 0x00400000
  337. #    Steam
  338. #        BP0 = 0x002881F9 + 0x00400000
  339. #        BP1 = 0x002881F1 + 0x00400000
  340. #        BP2 = 0x0028823B + 0x00400000
  341. ######################################
  342. #               1.1.2b
  343. #   Non-Steam
  344. #        BP0 = 0x00282719 + 0x00400000
  345. #        BP1 = 0x00282711 + 0x00400000
  346. #        BP2 = 0x0028275B + 0x00400000
  347. #   Steam
  348. #        BP0 = 0x002850D9 + 0x00400000
  349. #        BP1 = 0x002850D1 + 0x00400000
  350. #        BP2 = 0x0028511B + 0x00400000
  351. ######################################
  352. #               1.1.2
  353. #   Non-Steam
  354. #        BP0 = 0x00282619 + 0x00400000
  355. #        BP1 = 0x00282611 + 0x00400000
  356. #        BP2 = 0x0028265B + 0x00400000
  357. #   Steam
  358. #        BP0 = 0x00285129 + 0x00400000
  359. #        BP1 = 0x00285121 + 0x00400000
  360. #        BP2 = 0x0028516B + 0x00400000
  361. ######################################
  362. #               1.1.1c_r2
  363. #   Non-Steam
  364. #        BP0 = 0x00280E49 + 0x00400000
  365. #        BP1 = 0x00280E41 + 0x00400000
  366. #        BP2 = 0x00280E8B + 0x00400000
  367. #   Steam
  368. #        BP0 = 0x002842D9 + 0x00400000
  369. #        BP1 = 0x002842D1 + 0x00400000
  370. #        BP2 = 0x0028431B + 0x00400000
  371. ######################################
  372. #               1.1.1c
  373. #    Non-Steam
  374. #        BP0 = 0x002814D9 + 0x00400000
  375. #        BP1 = 0x002814D1 + 0x00400000
  376. #        BP2 = 0x0028151B + 0x00400000
  377. #    Steam
  378. #        BP0 = 0x00283FF9 + 0x00400000
  379. #        BP1 = 0x00283FF1 + 0x00400000
  380. #        BP2 = 0x0028403B + 0x00400000
  381. ######################################
  382. #               1.1.1b
  383. #   Non-Steam
  384. #        BP0 = 0x00280CA9 + 0x00400000
  385. #        BP1 = 0x00280CA1 + 0x00400000
  386. #        BP2 = 0x00280CEB + 0x00400000
  387. #   Steam
  388. #        BP0 = 0x00284169 + 0x00400000
  389. #        BP1 = 0x00284161 + 0x00400000
  390. #        BP2 = 0x002841AB + 0x00400000
  391. ######################################
  392. #               1.1.1
  393. #   Non-Steam
  394. #        BP0 = 0x002806D9 + 0x00400000
  395. #        BP1 = 0x002806D1 + 0x00400000
  396. #        BP2 = 0x0028071B + 0x00400000
  397. #   Steam
  398. #        BP0 = 0x00283479 + 0x00400000
  399. #        BP1 = 0x00283471 + 0x00400000
  400. #        BP2 = 0x002834BB + 0x00400000
  401. ######################################
  402. #               1.1.0e/f
  403. #    Non-Steam
  404. #        BP0 = 0x002804A9 + 0x00400000
  405. #        BP1 = 0x002804A1 + 0x00400000
  406. #        BP2 = 0x002804EB + 0x00400000
  407. #    Steam
  408. #        BP0 = 0x00283269 + 0x00400000
  409. #        BP1 = 0x00283261 + 0x00400000
  410. #        BP2 = 0x002832AB + 0x00400000
  411. ######################################
  412. #               1.1.0d
  413. #   Non-Steam    
  414. #        BP0 = 0x0027FEE9 + 0x00400000
  415. #        BP1 = 0x0027FEE1 + 0x00400000
  416. #        BP2 = 0x0027FF2B + 0x00400000
  417. #   Steam
  418. #        BP0 = 0x00282B99 + 0x00400000
  419. #        BP1 = 0x00282B91 + 0x00400000
  420. #        BP2 = 0x00282BDB + 0x00400000
  421. ######################################
  422.  
  423.     number_of_uniques = 0
  424.     number_of_rares = 0
  425.     number_of_orbs = 0
  426.     number_of_maps = 0
  427.    
  428.     RUN = False
  429.    
  430.     def __init__(self):
  431.         atexit.register(self.atExit)
  432.         self.logFile = open('log.txt', 'a', 0)
  433.         self.statFile = open('stats.txt', 'a', 0)
  434.         print >>self.logFile, 40 * '='
  435.         print >>self.logFile, str.format('Started ItemAlertPoE version {0} at {1!s}.', ALERT_VERSION, datetime.datetime.now())
  436.         print >>self.logFile, str.format('Python version: {0!s}', sys.version_info)
  437.         self.dbg = pydbg()
  438.         self.dbg.attach(self.getProcessId())
  439.         print Style.BRIGHT + Fore.CYAN + 'Success'
  440.         print ''
  441.         self.baseAddress = self.getBaseAddress()
  442.         adjustment = self.baseAddress - 0x00400000
  443.         ItemAlert.BP0 += adjustment
  444.         ItemAlert.BP1 += adjustment
  445.         ItemAlert.BP2 += adjustment
  446.         self.lastPacketBufferAddress = 0
  447.         self.lastPacketSize = 0
  448.  
  449.     def __enter__(self):
  450.         return self
  451.  
  452.     def __exit__(self, type, value, traceback):
  453.         #print ''
  454.         #print '__exit__'
  455.         #print ''
  456.         print Fore.RED + 'Unloading'
  457.         self.dbg.detach()
  458.         self.logFile.close()
  459.         self.statFile.close()
  460.  
  461.     def grabPacketSize(self, dbg):
  462.         self.lastPacketSize = dbg.get_register('eax')
  463.         return DBG_CONTINUE
  464.  
  465.     def beforeDemanglingPacket(self, dbg):
  466.         self.lastPacketBufferAddress = dbg.get_register('eax')
  467.         return DBG_CONTINUE
  468.  
  469.  
  470.     def playerJoined(self,packetData):
  471.    
  472.         try:
  473.        
  474.             buffer = ByteBuffer(packetData)
  475.             buffer.setEndian(ByteBuffer.BIG_ENDIAN)
  476.  
  477.             id = buffer.nextByte()
  478.             unk1 = buffer.nextDword()
  479.             unk2 = buffer.nextByte()
  480.             player_name_len = buffer.nextByte()
  481.            
  482.             playername = buffer.getString(player_name_len)
  483.            
  484.             print Fore.WHITE + str.format('Player joined the area: {0}',playername)
  485.             return
  486.            
  487.         except:pass
  488.        
  489.     def playerLeft(self,packetData):
  490.    
  491.         try:
  492.        
  493.             buffer = ByteBuffer(packetData)
  494.             buffer.setEndian(ByteBuffer.BIG_ENDIAN)
  495.  
  496.             id = buffer.nextByte()
  497.             unk1 = buffer.nextDword()
  498.             unk2 = buffer.nextByte()
  499.             player_name_len = buffer.nextByte()
  500.            
  501.             playername = buffer.getString(player_name_len)
  502.            
  503.             print Fore.WHITE + str.format('Player left the area: {0}',playername)
  504.             return
  505.            
  506.         except:pass
  507.  
  508.     def playerChat(self, packetData):
  509.    
  510.         try:
  511.            
  512.             buffer = ByteBuffer(packetData)
  513.             buffer.setEndian(ByteBuffer.BIG_ENDIAN)
  514.  
  515.             id = buffer.nextByte()
  516.            
  517.             unk1 = buffer.nextByte()
  518.            
  519.             player_name_len = buffer.nextByte()
  520.            
  521.             playername = buffer.getString(player_name_len)
  522.             #print Fore.WHITE + str.format('Player is chatting: {0}',playername)
  523.             return
  524.        
  525.         except: pass
  526.  
  527.     def parseWorldItemPacket(self, packetData):
  528.    
  529.         global number_of_uniques
  530.         global number_of_rares
  531.         global number_of_orbs
  532.         global number_of_maps
  533.         global RUN
  534.    
  535.         try:
  536.             ts = datetime.datetime.now().strftime("%H:%M:%S") + ' '
  537.             buffer = ByteBuffer(packetData)
  538.             buffer.setEndian(ByteBuffer.BIG_ENDIAN)
  539.  
  540.             id = buffer.nextByte()
  541.             #print >>self.logFile, str.format('id = {0}', id)
  542.  
  543.             objectType = buffer.nextDword()
  544.             #print >>self.logFile, str.format('ObjectType = {0}', objectType)
  545.  
  546.             unk1 = buffer.nextDword()
  547.             #print >>self.logFile, str.format('unk1 = {0}', unk1)
  548.  
  549.             unk2 = buffer.nextByte()
  550.             #print >>self.logFile, str.format('unk2 = {0}', unk2)
  551.  
  552.             if unk2 != 0:
  553.                 print >>self.logFile, 'The following packet has an odd unk2 field:'
  554.                 print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
  555.                 return
  556.  
  557.             xcoord = buffer.nextDword()
  558.             #print >>self.logFile, str.format('x coord = {0}', xcoord)
  559.            
  560.             ycoord = buffer.nextDword()
  561.             #print >>self.logFile, str.format('y coord = {0}', ycoord)
  562.            
  563.             rot = buffer.nextDword()
  564.             #print >>self.logFile, str.format('rot = {0}', rot)
  565.  
  566.             unk3 = buffer.nextDword(ByteBuffer.LITTLE_ENDIAN)
  567.             #print >>self.logFile, str.format('unk3 = {0}', unk3)
  568.            
  569.             unk4 = buffer.nextDword()
  570.             #print >>self.logFile, str.format('unk4 = {0}', unk4)
  571.            
  572.             if unk3 >> 2 != 0:
  573.                 print >>self.logFile, 'The following packet has an odd unk3 field:'
  574.                 print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
  575.                 buffer.nextDword()
  576.                 buffer.nextDword()
  577.  
  578.             unk5 = buffer.nextDword()
  579.             #print >>self.logFile, str.format('unk5 = {0}', unk5)
  580.  
  581.             unk6 = buffer.nextDword()
  582.             #print >>self.logFile, str.format('unk6 = {0}', unk6)
  583.  
  584.             unk7 = buffer.nextByte()
  585.             #print >>self.logFile, str.format('unk7 = {0}', unk7)
  586.            
  587.             unk8 = buffer.nextDword()
  588.             #print >>self.logFile, str.format('unk8 = {0}', unk8)
  589.  
  590.            
  591.             if unk8 >= 2:
  592.  
  593.                 unk8 = buffer.nextDword()
  594.  
  595.             dropped_by_entity = buffer.nextByte()
  596.             if DEBUG:
  597.                 print >>self.logFile, str.format('dropped by player or mob : {0}', dropped_by_entity)
  598.            
  599.             itemId = buffer.nextDword()
  600.             print >>self.logFile, 'itemId = ' + "0x%x"%(itemId&0xffffffff)
  601.  
  602.             #remaining = buffer.getRemainingBytes()
  603.            
  604.             itemName = getItemName(itemId)
  605.             print >>self.logFile, str.format('itemName = {0}', itemName)
  606.  
  607.             if itemName == "unknown item":
  608.                
  609.                 if DEBUG:
  610.                     print ts + Style.BRIGHT + Fore.RED + 'UNKNOWN ITEM:' + "0x%x"%(itemId&0xffffffff)
  611.                     unk_item = PlaySoundUnknownItem()
  612.                     unk_item.start()
  613.  
  614.                 print >>self.logFile, '---------------------------------'
  615.                 return
  616.  
  617.             if isCurrencyItem(itemName):
  618.            
  619.                 if itemId !=0x50880BAF and itemId !=0x4F2B00ED:
  620.                     print ts + Style.BRIGHT + Fore.WHITE + 'CUR' + Style.NORMAL + str.format(': {0}',itemName)
  621.                     number_of_orbs += 1
  622.  
  623.                     if ALERT_curr == True and SOUND_curr == True:
  624.                    
  625.                         if itemId == 0x61B2F5ED and SOUND_eternal == True: # Eternal Orb
  626.                             crafting_drop = PlaySoundEternal()
  627.                             crafting_drop.start()
  628.                         if itemId == 0xC04F5629 and SOUND_exalted == True: # Exalted Orb
  629.                             crafting_drop = PlaySoundExalted()
  630.                             crafting_drop.start()
  631.                         if itemId == 0x1C1E192B and SOUND_chroma == True: # Chromatic
  632.                             crafting_drop = PlaySoundCraftingItem()
  633.                             crafting_drop.start()
  634.                         if itemId == 0x80047CFD and SOUND_divine == True: # Divine Orb
  635.                             crafting_drop = PlaySoundDivine()
  636.                             crafting_drop.start()
  637.                         if itemId == 0x07A992EB and SOUND_gcp == True: # Gemcutter's Prism
  638.                             crafting_drop = PlaySoundCraftingItem()
  639.                             crafting_drop.start()
  640.                         if itemId == 0xD8BD4F5D and SOUND_regal == True: # Regal Orb
  641.                             crafting_drop = PlaySoundCraftingItem()
  642.                             crafting_drop.start()
  643.                         if itemId == 0x9B4B42A5 and SOUND_regret == True: # Orb of Regret
  644.                             crafting_drop = PlaySoundCraftingItem()
  645.                             crafting_drop.start()
  646.                         if itemId == 0x716F588 and SOUND_vaal == True: #Vaal Orb
  647.                             crafting_drop = PlaySoundVaal()
  648.                             crafting_drop.start()
  649.                         if itemId == 0x7353DDF9 and SOUND_chaos == True: # Chaos Orb
  650.                             crafting_drop = PlaySoundChaos()
  651.                             crafting_drop.start()
  652.                         if itemId == 0x2D8E7632 and SOUND_blessed == True: # Blessed Orb
  653.                             crafting_drop = PlaySoundCraftingItem()
  654.                             crafting_drop.start()
  655.                         if itemId == 0x7F0EF637 and SOUND_scour == True: # Orb of Scouring
  656.                             crafting_drop = PlaySoundCraftingItem()
  657.                             crafting_drop.start()
  658.                         if itemId == 0x9110493F and SOUND_alc == True: # Orb of Alchemy
  659.                             crafting_drop = PlaySoundCraftingItem()
  660.                             crafting_drop.start()
  661.                         if itemId == 0xC71BF58D and SOUND_fuse == True: # Orb of Fusing
  662.                             crafting_drop = PlaySoundCraftingItem()
  663.                             crafting_drop.start()
  664.                         if itemId == 0xDC217297 and SOUND_chis == True: # Cartographer's Chisel
  665.                             crafting_drop = PlaySoundCraftingItem()
  666.                             crafting_drop.start()
  667.                         if itemId == 0xC5732C85 and SOUND_chance == True: # Orb of Chance
  668.                             crafting_drop = PlaySoundCraftingItem()
  669.                             crafting_drop.start()
  670.                         if itemId == 0xDD917991 and SOUND_jew == True: # Jeweller's Orb
  671.                             crafting_drop = PlaySoundCraftingItem()
  672.                             crafting_drop.start()
  673.                         if itemId == 0xDD74C4BF and SOUND_glass == True: # Glassblower's Bauble
  674.                             crafting_drop = PlaySoundCraftingItem()
  675.                             crafting_drop.start()
  676.                         if itemId == 0x79C23B15 and SOUND_mirror == True: # Mirror of Kalandra
  677.                             crafting_drop = PlaySoundKalandra()
  678.                             crafting_drop.start()
  679.                         if itemId == 0x77662604 and SOUND_feather == True: # Albino Rhoa Feather
  680.                             crafting_drop = PlaySoundFeather()
  681.                             crafting_drop.start()
  682.                         if itemId == 0xD7328257 and SOUND_alter == True: # Alteration Orb
  683.                             crafting_drop = PlaySoundCraftingItem()
  684.                             crafting_drop.start()
  685.                         if itemId == 0xF5BB66E2 and SOUND_augmen == True: # Augmentation Orb
  686.                             crafting_drop = PlaySoundCraftingItem()
  687.                             crafting_drop.start()
  688.                         if itemId == 0x4E6C4D33 and SOUND_trans == True: # Transmutation Orb
  689.                             crafting_drop = PlaySoundCraftingItem()
  690.                             crafting_drop.start()
  691.  
  692.  
  693.                 print >>self.logFile, '---------------------------------'
  694.                 return
  695.  
  696.                
  697.             actual = buffer.nextByte()
  698.             actual = buffer.nextByte()
  699.             actual = buffer.nextByte()
  700.             actual = buffer.nextByte() # required for 1.1.0 compatibility
  701.             actual = buffer.nextByte() # required for 1.2.3 compatibility
  702.             actual = buffer.nextDword() # required for 1.2.1b compatibility
  703.             actual = buffer.nextDword()
  704.  
  705.             itemlevel = int(buffer.nextDword())
  706.             if DEBUG:
  707.                 print >>self.logFile, str.format('itemlevel = {0}', itemlevel)
  708.  
  709.             if isGemItem(itemName) and ALERT_gems == True:
  710.  
  711.                 if shouldNotify(itemName):
  712.                     print ts + Fore.WHITE + str.format('SPC: {0}', itemName)
  713.                     worker = PlaySoundSpecialItem()
  714.                     worker.start()
  715.  
  716.                 actual = buffer.nextByte()
  717.                 quality = int(buffer.nextDword())
  718.                
  719.                 if quality >= gemqual:
  720.                     print ts + Fore.CYAN + 'GEM' + Fore.WHITE + str.format(': {0}, quality: {1}',itemName,quality)
  721.                     if SOUND_supgem == True:
  722.                         supgem_drop = PlaySoundSuperiorGem()
  723.                         supgem_drop.start()
  724.                 return
  725.  
  726.                 if str(hex(itemId)) in specialGems and ALERT_specialgems == True:
  727.                     print ts + Fore.CYAN + 'Special Gem' + Fore.WHITE +str.format(': {0}, quality: {1}',itemName,quality)
  728.                    
  729.                     if SOUND_specialgems == True:
  730.                         spcgem_drop = PlaySoundHolyShit()
  731.                         spcgem_drop.start()
  732.                    
  733.                 print >>self.logFile, '---------------------------------'
  734.                 return
  735.  
  736.             if isFlaskItem(itemName) and ALERT_flask == True:
  737.                 actual = buffer.lastDword()
  738.                 quality = int(buffer.lastDword())
  739.                 actual = buffer.nextDword()
  740.                 actual = buffer.nextDword()
  741.                 actual = buffer.nextDword()
  742.                 ilvl = buffer.nextDword()
  743.                 rlvl = buffer.nextDword()
  744.  
  745.                 #Granite Flask
  746.                 if itemId == 0x41BA1FB3 and ALERT_flask == True:
  747.                     print ts + Style.BRIGHT + Fore.CYAN + 'Special Flask' + Style.NORMAL + Fore.WHITE + str.format(': {0}, quality: {1}, itemlvl: {2}',itemName,quality,ilvl)
  748.                     if SOUND_graniteflask == True:
  749.                         granflask_drop = PlaySoundGraniteFlask()
  750.                         granflask_drop.start()
  751.  
  752.                 if quality >= flaskqual:
  753.  
  754.                     print ts + Style.BRIGHT + Fore.CYAN + 'Flask' + Style.NORMAL + Fore.WHITE + str.format(': {0}, quality: {1}, itemlvl: {2}',itemName,quality,ilvl)
  755.  
  756.                     if SOUND_supflask == True:
  757.                         supflask_drop = PlaySoundSuperiorFlask()
  758.                         supflask_drop.start()
  759.                 print >>self.logfile, '--------------------------------'
  760.  
  761.                 return
  762.  
  763.             req_lvl = buffer.nextDword()
  764.             if DEBUG:
  765.                 print >>self.logFile, str.format('req lvl = {0}', req_lvl)
  766.                
  767.             if SEARCH_special:
  768.  
  769.                 if isSearchItem(itemName,special_class):    
  770.  
  771.                     if  itemlevel == special_ilvl and special_rlvl == req_lvl:
  772.                    
  773.                         sound = PlaySound6Sockets()
  774.                         sound.start()
  775.                         print ts + Style.BRIGHT + Fore.RED + str.format('Special Item: {0}, itemlevel: {1}',itemName,itemlevel)
  776.            
  777.             actual = buffer.nextDword()
  778.             actual = buffer.nextByte()
  779.             rarity = buffer.nextDword()
  780.             if DEBUG:
  781.                 print >>self.logFile, str.format('rarity = {0}', rarity)
  782.  
  783.             identified = buffer.nextDword()
  784.             if DEBUG:
  785.                 print >>self.logFile, str.format('identified = {0}', identified)
  786.                
  787.            
  788.             if isMapItem(itemName) and ALERT_maps == True:
  789.                
  790.                 #if shouldNotify(itemName):
  791.                     #print ts + Fore.WHITE + str.format('SPC: {0}', itemName)
  792.                     #worker = PlaySoundSpecialItem()
  793.                     #worker.start()
  794.  
  795.                 actual = buffer.nextDword()
  796.                 actual = buffer.nextDword()
  797.                 actual = buffer.nextByte()
  798.                
  799.                 actual = buffer.nextDword()
  800.                 actual = buffer.nextDword()
  801.                 quality = int(buffer.nextDword())
  802.                 actual = int(buffer.nextByte())
  803.                 if DEBUG:
  804.                     print >>self.logFile, str.format('quality = {0}', quality)
  805.                
  806.                 if quality == 0 and actual == 0:
  807.                     quality = int(buffer.nextDword())
  808.                     if DEBUG:
  809.                         print >>self.logFile, str.format('quality new = {0}', quality)
  810.                
  811.                 print ts + Style.BRIGHT + Fore.CYAN + 'MAP' + Style.NORMAL + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}, quality: {3}',itemName,rarity,itemlevel,quality)
  812.  
  813.                 print >>self.logFile, '---------------------------------'
  814.  
  815.                 if SOUND_maps == True:
  816.                     map = PlaySoundMaps()
  817.                     map.start()
  818.        
  819.                 number_of_maps += 1
  820.                 return
  821.  
  822.             if isBeltItem(itemName):
  823.                
  824.                 if shouldNotify(itemName) and rarity == 0:
  825.                     print ts + Fore.WHITE + str.format('SPC: {0}', itemName)
  826.                     worker = PlaySoundSpecialItem()
  827.                     worker.start()                
  828.                
  829.                 if rarity == 3:
  830.                
  831.                     print ts + Style.NORMAL + Fore.YELLOW + 'UNI BELT' + Fore.YELLOW + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  832.                     if SOUND_uniques == True:
  833.                         unique = PlaySoundUnique()
  834.                         unique.start()
  835.  
  836.                     number_of_uniques += 1
  837.            
  838.                 elif rarity == 2 and ALERT_rares == True:
  839.                
  840.                     print ts + Style.BRIGHT + Fore.YELLOW + 'BELT' + Style.NORMAL + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  841.  
  842.                     if SOUND_rares == True:
  843.                         worker = PlaySoundWorker()
  844.                         worker.start()
  845.  
  846.                 print >>self.logFile, '---------------------------------'
  847.                
  848.                 return
  849.  
  850.             if isQuestItem(itemName) and ALERT_quest == True:
  851.  
  852.                 print ts + Style.BRIGHT + Fore.GREEN + 'Quest Item' + Style.NORMAL + Fore.WHITE + str.format(': {0}',itemName)
  853.                 if SOUND_quest == True:
  854.                     quest = PlaySoundQuest()
  855.                     quest.start()
  856.                 print >>self.logfile, '--------------------------------'
  857.                 return
  858.  
  859.  
  860.             if isQuiverItem(itemName):
  861.  
  862.                 if shouldNotify(itemName) and rarity == 0:
  863.                     print ts + Fore.WHITE + str.format('SPC: {0}', itemName)
  864.                     worker = PlaySoundSpecialItem()
  865.                     worker.start()                
  866.                
  867.                 if rarity == 3:
  868.                
  869.                     print ts + Style.NORMAL + Fore.YELLOW + 'UNI Quiver' + Fore.YELLOW + str.format('UNI Quiver: {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  870.                     if SOUND_uniques == True:
  871.                         unique = PlaySoundUnique()
  872.                         unique.start()
  873.  
  874.                     number_of_uniques += 1
  875.            
  876.                 elif rarity == 2 and ALERT_rares == True:
  877.                
  878.                     print ts + Style.BRIGHT + Fore.YELLOW + 'QUIV' + Style.NORMAL + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  879.                    
  880.                     if SOUND_rares == True:
  881.                         worker = PlaySoundWorker()
  882.                         worker.start()
  883.  
  884.                 print >>self.logFile, '---------------------------------'
  885.                
  886.                 return
  887.  
  888.             if isJewelleryItem(itemName):
  889.                 # 0x29F77698 = gold ring
  890.                 # 0xDE069771 = gold amulet
  891.  
  892.                 _implicitmods = int(buffer.nextDword())
  893.                 _mod = buffer.nextDword()
  894.                 _modvalues = buffer.nextByte()
  895.                 _modvalue = int(buffer.nextDword())
  896.  
  897.                 if shouldNotify(itemName) and rarity == 0:
  898.                         print ts + Fore.WHITE + 'SPC:' + str.format(' {0}', itemName)
  899.                         worker = PlaySoundSpecialItem()
  900.                         worker.start()
  901.                
  902.                 if rarity == 2 and ALERT_rares == True:
  903.  
  904.                     print ts + Style.BRIGHT + Fore.YELLOW + 'JEW' + Style.NORMAL + Fore.WHITE + str.format(': {0}, rarity: {1}',itemName,rarity)
  905.                     number_of_rares += 1
  906.  
  907.                     if SOUND_rares == True:
  908.                         worker = PlaySoundWorker()
  909.                         worker.start()
  910.                    
  911.                 if (rarity == 0) and (itemId == 0x29F77698 or itemId == 0xDE069771) and ALERT_jewellry == True:
  912.  
  913.                     if _modvalue >= ringmf and itemId == 0x29F77698:
  914.                         if ringmf >= 0:
  915.                             print ts + Fore.WHITE + str.format('JEW: {0}, Value: {1}',itemName,_modvalue)
  916.                        
  917.                     if _modvalue >= amuletmf and itemId == 0xDE069771:
  918.                         if amuletmf >= 0:
  919.                             print ts + Fore.WHITE + str.format('JEW: {0}, Value: {1}',itemName,_modvalue)
  920.  
  921.  
  922.                 elif (rarity == 1) and (itemId == 0x29F77698 or itemId == 0xDE069771) and ALERT_jewellry == True:
  923.  
  924.                     if _modvalue >= ringmf and itemId == 0x29F77698:
  925.                         if ringmf >= 0:
  926.                             print ts + Fore.WHITE + 'JEW' + Fore.CYAN + str.format(': {0}, Value: {1}', itemName, _modvalue)
  927.  
  928.                     if _modvalue >= amuletmf and itemId == 0xDE069771:
  929.                         if amuletmf >= 0:
  930.                             print ts + Fore.WHITE + 'JEW' + Fore.CYAN + str.format(': {0}, Value: {1}', itemName, _modvalue)
  931.                    
  932.                 elif (rarity == 2) and (itemId == 0x29F77698 or itemId == 0xDE069771) and ALERT_jewellry == True and ALERT_rares == False:
  933.  
  934.                     if _modvalue >= ringmf and itemId == 0x29F77698:
  935.                         if ringmf >= 0:
  936.                             print ts + Fore.WHITE + 'JEW' + Fore.YELLOW + str.format(': {0}, Value: {1}', itemName, _modvalue)
  937.  
  938.                     if _modvalue >= amuletmf and itemId == 0xDE069771:
  939.                         if amuletmf >= 0:
  940.                             print ts + Fore.WHITE + 'JEW' + Fore.YELLOW + str.format(': {0}, Value: {1}', itemName, _modvalue)
  941.  
  942.                 elif rarity == 3:
  943.                
  944.                     if identified == 1 and itemId == 0x29F77698:
  945.                        
  946.                         if RUN == False:
  947.                             RUN = True
  948.                             number_of_uniques = 0
  949.                             number_of_rares = 0
  950.                             number_of_orbs = 0
  951.                             number_of_maps = 0
  952.                            
  953.                             staTime= datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
  954.                             startTime = str.format('{0}',staTime)
  955.                            
  956.                             print ts + Style.BRIGHT + Fore.GREEN + str.format('==== {0} ===== RUN started ===========',startTime)
  957.                            
  958.                             #print >>self.logFile, str.format('{0}', startTime)
  959.                             # measure runtime later on here, get the start time
  960.                            
  961.                         else:
  962.                        
  963.                             RUN = False
  964.                             stoTime = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
  965.                             stopTime = str.format('{0}',stoTime)
  966.                             print ts + Style.BRIGHT + Fore.GREEN + str.format('==== {0} ===== RUN stopped ===========',stopTime)                            
  967.                             print >>self.statFile, str.format('{0},{1},{2},{3},{4}', stopTime,number_of_uniques,number_of_rares,number_of_orbs,number_of_maps)
  968.                            
  969.                     else:
  970.                         print ts + Style.NORMAL + Fore.YELLOW + 'UNI JEW' + Style.BRIGHT + Fore.YELLOW + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  971.                         if SOUND_uniques == True:
  972.                             unique = PlaySoundUnique()
  973.                             unique.start()
  974.                        
  975.                         number_of_uniques += 1
  976.  
  977.                        
  978.                 print >>self.logFile, '---------------------------------'
  979.                 return
  980.  
  981.             if isArmourItem(itemName):
  982.                    
  983.                 if rarity == 0:
  984.  
  985.                     if shouldNotify(itemName):
  986.                         print ts + Fore.WHITE + str.format('SPC: {0}, itemlevel: {1}', itemName, itemlevel)
  987.                         worker = PlaySoundSpecialItem()
  988.                         worker.start()
  989.  
  990.                         print >>self.logFile, '---------------------------------'
  991.                         return
  992.                        
  993.                 elif rarity == 2:
  994.                     number_of_rares += 1
  995.                
  996.                 if identified == 1:
  997.  
  998.                     if isShieldItem(itemName):
  999.                    
  1000.                         if DEBUG:
  1001.                             print >>self.logFile, str.format('identified as SHIELD', '1')
  1002.  
  1003.                         _implicitmod = int(buffer.nextDword())
  1004.                        
  1005.                         if _implicitmod == 2:
  1006.                             actual=buffer.nextDword()
  1007.                                
  1008.                             _skipnext = int(buffer.nextByte())
  1009.  
  1010.                             if _skipnext >= 1:
  1011.                                 actual=buffer.nextDword()
  1012.  
  1013.                                 _impl_mod = int(buffer.nextDword())
  1014.                                 if DEBUG:
  1015.                                     print >>self.logFile, str.format('implicit mod = {0}', _impl_mod)
  1016.  
  1017.                                 _impl_mod_values = int(buffer.nextByte())
  1018.                                
  1019.                                 for i in range(0,_impl_mod_values):
  1020.                                     # needs to be worked out
  1021.                                     _mod_value = int(buffer.nextDword())
  1022.                                    
  1023.                                 _skipnext = int(buffer.nextByte())
  1024.                                    
  1025.                                 if _skipnext >= 1:
  1026.                                     for i in range(0,_skipnext):
  1027.                                         actual = int(buffer.nextDword())
  1028.  
  1029.                                    
  1030.                         else:
  1031.                        
  1032.                             actual=buffer.nextDword()
  1033.                        
  1034.                             _skipnext = int(buffer.nextByte())            
  1035.  
  1036.                             if _skipnext >= 1:                        
  1037.                                 for i in range(0,_skipnext):
  1038.                                     actual=buffer.nextDword()
  1039.                    
  1040.                                 _skipnext = int(buffer.nextByte())            
  1041.  
  1042.                                 if _skipnext >= 1:                        
  1043.                                     for i in range(0,_skipnext):
  1044.                                         actual=buffer.nextDword()
  1045.                    
  1046.                     else:
  1047.                         _implicitmods = int(buffer.nextDword())
  1048.                        
  1049.                         if _implicitmods == 2:
  1050.                        
  1051.                             if DEBUG:
  1052.                                 print >>self.logFile, str.format('_implicitmods = {0}', _implicitmods)
  1053.            
  1054.                         elif _implicitmods == 1:
  1055.  
  1056.                             _implicitmod = buffer.nextDword()
  1057.                             if DEBUG:
  1058.                                 print >>self.logFile, str.format('_implicitmod = {0}', _implicitmod)
  1059.                            
  1060.                             _impl_mod_values = int(buffer.nextByte())
  1061.                             if DEBUG:
  1062.                                 print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
  1063.                            
  1064.                            
  1065.                             for i in range(0,_impl_mod_values):
  1066.                                 # needs to be worked out
  1067.                                 _mod_value = int(buffer.nextDword())
  1068.                                
  1069.                         unk_mod=int(buffer.nextByte())
  1070.  
  1071.                         if unk_mod >= 0:
  1072.                             _mod_value = buffer.nextDword() #added removed int()
  1073.                                                    
  1074.                     number_of_mods = int(buffer.nextDword())
  1075.  
  1076.                 else:
  1077.                
  1078.                     if isShieldItem(itemName):
  1079.                    
  1080.                         if DEBUG:
  1081.                             print >>self.logFile, str.format('identified as SHIELD', '1')
  1082.                    
  1083.                
  1084.                         _implicitmod = int(buffer.nextDword())
  1085.                        
  1086.                         if _implicitmod == 2:
  1087.                        
  1088.                             actual=buffer.nextDword()
  1089.                                
  1090.                             _skipnext = int(buffer.nextByte())
  1091.  
  1092.                             if _skipnext >= 1:
  1093.                                 actual=buffer.nextDword()
  1094.  
  1095.                                 _impl_mod = int(buffer.nextDword())
  1096.                                
  1097.                                 if DEBUG:
  1098.                                     print >>self.logFile, str.format('implicit mod = {0}', _impl_mod)
  1099.  
  1100.                                 _impl_mod_values = int(buffer.nextByte())
  1101.  
  1102.                                 if DEBUG:
  1103.                                     print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
  1104.                                
  1105.                                
  1106.                                 if _impl_mod_values > 0:
  1107.                                     for i in range(0,_impl_mod_values):
  1108.                                         # needs to be worked out
  1109.                                         _mod_value = int(buffer.nextDword())
  1110.                                         if DEBUG:
  1111.                                             print >>self.logFile, str.format('_mod_value = {0}', _mod_value)
  1112.  
  1113.                         elif _implicitmod == 1:
  1114.                        
  1115.                             actual=buffer.nextDword()
  1116.                        
  1117.                             _skipnext = int(buffer.nextByte())            
  1118.  
  1119.                             if _skipnext >= 1:                        
  1120.                                 for i in range(0,_skipnext):
  1121.                                     actual=buffer.nextDword()
  1122.  
  1123.                     else:
  1124.  
  1125.                         _implicitmods = int(buffer.nextDword())
  1126.                        
  1127.                         if _implicitmods == 2:
  1128.                        
  1129.                             if DEBUG:
  1130.                                 print >>self.logFile, str.format('_implicitmods = {0}', _implicitmods)
  1131.            
  1132.                         elif _implicitmods == 1:
  1133.  
  1134.                             _implicitmod = buffer.nextDword()
  1135.                             if DEBUG:
  1136.                                 print >>self.logFile, str.format('_implicitmod = {0}', _implicitmod)
  1137.                            
  1138.                             _impl_mod_values = int(buffer.nextByte())
  1139.                             if DEBUG:
  1140.                                 print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
  1141.                            
  1142.                            
  1143.                             for i in range(0,_impl_mod_values):
  1144.                                 # needs to be worked out
  1145.                                 _mod_value = int(buffer.nextDword())
  1146.  
  1147.                     number_of_mods = 0
  1148.                                
  1149.                 if DEBUG:
  1150.                     print >>self.logFile, str.format('number of explicit mods = {0}', number_of_mods)
  1151.                
  1152.                 if number_of_mods > 6:
  1153.                     print >>self.logFile, 'The last packet had an odd number_of_mods field:'
  1154.                     print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
  1155.  
  1156.                     print >>self.logFile, '---------------------------------'                        
  1157.                     return
  1158.                
  1159.                
  1160.                 for i in range(0,number_of_mods):
  1161.                     mod_id = buffer.nextDword()
  1162.                     if DEBUG:
  1163.                         print >>self.logFile, str.format('mod id = {0}', mod_id)
  1164.                     sub_mod_count = buffer.nextByte()
  1165.                     if sub_mod_count > 3:
  1166.                         print >>self.logFile, 'The last packet had an odd sub_mod_count field:'
  1167.                         if DEBUG:
  1168.                             print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
  1169.  
  1170.                         print >>self.logFile, '---------------------------------'                        
  1171.                         return
  1172.                    
  1173.                     for ii in range(0,sub_mod_count):
  1174.                         mod_value=buffer.nextDword()
  1175.                         if sub_mod_count == 1:
  1176.                             if DEBUG:
  1177.                                 print >>self.logFile, str.format('Modifier: {0}{1}', mod_value, getModifierName(mod_id))
  1178.                         elif sub_mod_count == 2:
  1179.                             if mod_value != 0:
  1180.                                 sub_mods = getModifierName(mod_id).split("/")
  1181.                                 sub_mod = sub_mods[ii]
  1182.                                 if DEBUG:
  1183.                                     print >>self.logFile, str.format('Modifier: {0}{1}', mod_value, sub_mod)
  1184.                    
  1185.                 quality = buffer.nextDword()
  1186.                 if DEBUG:
  1187.                     print >>self.logFile, str.format('quality = {0}', quality)
  1188.  
  1189.                 #Superior Quality modifier
  1190.                 if quality >= whiteitemqual and ALERT_quality == True:
  1191.                     if rarity == 0:
  1192.                         print ts + Style.BRIGHT + Fore.WHITE + 'SUP' + Style.NORMAL + Fore.WHITE + str.format(': {0}, quality: {1}, itemlevel: {2}',itemName,quality,itemlevel)
  1193.                
  1194.                 if quality >= rarityqual and ALERT_quality == True and rarityqual != 0:
  1195.                     if rarity == 1:
  1196.                         print ts + Style.BRIGHT + Fore.CYAN + 'SUP' + Style.NORMAL + Fore.WHITE + str.format(': {0}, quality: {1}, itemlevel: {2}',itemName,quality,itemlevel)
  1197.                     if rarity == 2:
  1198.                         print ts + Style.BRIGHT + Fore.YELLOW + 'SUP' + Style.NORMAL + Fore.WHITE + str.format(': {0}, quality: {1}, itemlevel: {2}',itemName,quality,itemlevel)
  1199.  
  1200.                     if ALERT_quality == True and SOUND_superior == True:
  1201.                         sup = PlaySoundSup()
  1202.                         sup.start()
  1203.  
  1204.                 actual = buffer.nextByte()
  1205.                 sockets = int(buffer.nextDword())
  1206.                 if DEBUG:
  1207.                     print >>self.logFile, str.format('sockets = {0}', sockets)
  1208.  
  1209.                 if sockets == 0 or sockets > 6:
  1210.                     print >>self.logFile, 'The last packet had an odd sockets field:'
  1211.                     if DEBUG:
  1212.                         print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
  1213.                    
  1214.                     print >>self.logFile, '---------------------------------'                        
  1215.                     return
  1216.                
  1217.                 _all_color = []
  1218.                
  1219.                 sock_color_tmp = ""
  1220.                 sock_color_tmp = getSocketColor(int(buffer.nextByte()))
  1221.                
  1222.                 actual = buffer.nextByte()
  1223.                 _all_color.append(sock_color_tmp)
  1224.                
  1225.                 for i in range(1,sockets):
  1226.                     sock_color_tmp = getSocketColor(int(buffer.nextByte()))
  1227.                     actual = buffer.nextByte()
  1228.                     _all_color.append(sock_color_tmp)
  1229.  
  1230.                 if DEBUG:
  1231.                     print >>self.logFile, str.format('socket colors = {0}', _all_color)
  1232.                
  1233.                 sock_fragments = int(buffer.nextDword())
  1234.                
  1235.                 if DEBUG:
  1236.                     print >>self.logFile, str.format('socket fragments = {0}', sock_fragments)
  1237.  
  1238.                 if sock_fragments > 6 or sock_fragments == 0:
  1239.                     print >>self.logFile, 'The last packet had an odd sock_fragments field:'
  1240.                     if DEBUG:
  1241.                         print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
  1242.  
  1243.                     print >>self.logFile, '---------------------------------'                        
  1244.                     return
  1245.                
  1246.                 listlen = len(_all_color)
  1247.                
  1248.                 if sock_fragments == 1:
  1249.                     if DEBUG:
  1250.                         print >>self.logFile, str.format('Fully linked = {0}', sock_fragments)
  1251.                     ii=0
  1252.                     for i in range(1,listlen):
  1253.                         _all_color.insert(i+ii,"-")
  1254.                         ii=ii+1
  1255.                        
  1256.                 else:
  1257.                     iii=0
  1258.                     maxfrag = 1
  1259.                     for i in range(0,sock_fragments):
  1260.                         frag = int(buffer.nextByte())
  1261.                         if frag > 1:
  1262.                             if maxfrag < frag:
  1263.                                 maxfrag = frag
  1264.                             for ii in range(1,frag):
  1265.                                 _all_color.insert(ii+iii,"-")
  1266.                                 iii=iii+1
  1267.                             iii=iii+ii+1
  1268.                         else:
  1269.                             iii=iii+1
  1270.                
  1271.                 socketsetup = ''.join(_all_color)
  1272.                
  1273.                 if DEBUG:
  1274.                     print >>self.logFile, str.format('Socket Setup = {0}', socketsetup)
  1275.  
  1276.                 rare_alerted = False
  1277.  
  1278.                 if ALERT_race:
  1279.                
  1280.                     if any(i in socketsetup for i in race_sockets):
  1281.                    
  1282.                         if rarity == 0:
  1283.                             print ts + Style.BRIGHT + Fore.RED + "Race item" + Style.BRIGHT + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  1284.                         if rarity == 1:
  1285.                             print ts + Style.BRIGHT + Fore.RED + "Race item" + Style.BRIGHT + Fore.CYAN + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  1286.                         if rarity == 2:
  1287.                             print ts + Style.BRIGHT + Fore.RED + "Race item" + Style.BRIGHT + Fore.YELLOW + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  1288.                             rare_alerted = True
  1289.  
  1290.                         if SOUND_race:
  1291.                             sound = PlaySoundRace()
  1292.                             sound.start()
  1293.  
  1294.                
  1295.                 if any(i in socketsetup for i in ('R-G-B','R-B-G','G-B-R','G-R-B','B-R-G','B-G-R','R-B-B-G','G-R-R-B','G-B-B-R','B-G-G-R','B-R-R-G','R-G-G-B')):
  1296.                
  1297.                     if rarity == 0:
  1298.                         print ts + Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.CYAN + "B" + Style.NORMAL + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  1299.                     if rarity == 1:
  1300.                         print ts + Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.CYAN + "B" + Style.BRIGHT + Fore.CYAN + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  1301.                     if rarity == 2:
  1302.                         print ts + Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.CYAN + "B" + Style.BRIGHT + Fore.YELLOW + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  1303.                         rare_alerted = True
  1304.  
  1305.                     if SOUND_rgb:
  1306.                         sound = PlaySoundRGB()
  1307.                         sound.start()
  1308.  
  1309.                    
  1310.                 msg = ""
  1311.                 if sockets == 5:
  1312.                     if sock_fragments == 1:
  1313.                         msg = "5-SLOT 5-LINK"
  1314.                 if sockets == 6:
  1315.                     if sock_fragments == 1:
  1316.                         msg = "6-SLOT 6-LINK"
  1317.                     elif sock_fragments == 2:
  1318.                         if maxfrag == 5:
  1319.                             msg = "6-SLOT 5-LINK"
  1320.                         else:
  1321.                             msg = "6-SLOT"
  1322.                     else:
  1323.                         msg = "6-SLOT"
  1324.                
  1325.                 if msg != "":
  1326.                     print >>self.logFile, msg
  1327.  
  1328.                     if rarity == 0:
  1329.                         print ts + Style.BRIGHT + Fore.MAGENTA + msg + Style.BRIGHT + Fore.WHITE + str.format(' : {0}, rarity: {1}, ilvl: {2}, qual: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup)
  1330.                     if rarity == 1:
  1331.                         print ts + Style.BRIGHT + Fore.MAGENTA + msg + Style.BRIGHT + Fore.CYAN + str.format(' : {0}, rarity: {1}, ilvl: {2}, qual: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup)
  1332.                     if rarity == 2:
  1333.                         print ts + Style.BRIGHT + Fore.MAGENTA + msg + Style.BRIGHT + Fore.YELLOW + str.format(' : {0}, rarity: {1}, ilvl: {2}, qual: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup)
  1334.                         rare_alerted = True
  1335.  
  1336.                     if SOUND_slots == True and msg == "5-SLOT 5-LINK" and ALERT_5slot5link == True:
  1337.                         sound = PlaySoundFiveLink()
  1338.                         sound.start()
  1339.                     elif SOUND_slots == True and msg == "6-SLOT 5-LINK" and ALERT_6slot5link == True:
  1340.                         sound = PlaySoundSixSlotFiveLink()
  1341.                         sound.start()
  1342.                     elif SOUND_slots == True and msg == "6-SLOT 6-LINK" and ALERT_6slot6link == True:
  1343.                         sound = PlaySoundSixLink()
  1344.                         sound.start()
  1345.                     elif SOUND_slots == True and msg == "6-SLOT" and ALERT_6slot == True:
  1346.                         sound = PlaySound6Sockets()
  1347.                         sound.start()
  1348.                        
  1349.                 if rarity == 3:
  1350.                     print >>self.logFile, 'UNIQUE !'
  1351.                     number_of_uniques += 1
  1352.                    
  1353.                     print ts + Style.NORMAL + Fore.YELLOW + 'UNI' + Style.NORMAL + Fore.YELLOW + str.format(': {0}, rarity: {1}, ilvl: {2}, qual: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup)
  1354.                    
  1355.                     if SOUND_uniques == True:
  1356.                         unique = PlaySoundUnique()
  1357.                         unique.start()
  1358.  
  1359.                 if rarity == 2 and ALERT_rares == True:
  1360.                
  1361.                     print ts + Style.BRIGHT + Fore.YELLOW + 'RARE' + Style.NORMAL + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
  1362.  
  1363.                     if SOUND_rares == True:
  1364.                         worker = PlaySoundWorker()
  1365.                         worker.start()
  1366.                    
  1367.                    
  1368.                 print >>self.logFile, '---------------------------------'
  1369.                 return
  1370.                    
  1371.            
  1372.             print >>self.logFile, '---------------------------------'            
  1373.                
  1374.         except: pass
  1375.  
  1376.     def afterDemanglingPacket(self, dbg):
  1377.         if self.lastPacketBufferAddress != 0 and self.lastPacketSize > 1:
  1378.             packetData = dbg.read_process_memory(self.lastPacketBufferAddress, self.lastPacketSize)
  1379.             packetData = map(lambda x: ord(x), packetData)
  1380.             if DEBUG_ALL:
  1381.                 print >>self.logFile, packetData[0:4]
  1382.                 if packetData[0:2] != [0x45, 0x00] and packetData[0:3] != [0xf1, 0x00, 0x00]:
  1383.                     print >>self.logFile, '_____________ new packet ________________________________________________________________________________________________________'
  1384.                     print >>self.logFile, str.format('Packet size: {0}',self.lastPacketSize)
  1385.                     print >>self.logFile, packetData
  1386.                     print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
  1387.                     print >>self.logFile, '__________________________________________________________________________________________________________________________________'
  1388.             for i in range(self.lastPacketSize):
  1389.                 if packetData[i:i+5] == [0xbe, 0x54, 0x92, 0x8a, 0x3a]:
  1390.                     if DEBUG:
  1391.        
  1392.                         print >>self.logFile, '---------------------------------'                    
  1393.                         print >>self.logFile, 'loot packet:'
  1394.                         print >>self.logFile, '   0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f'
  1395.                         print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData[i:]))
  1396.                        
  1397.                     self.parseWorldItemPacket(packetData[i:])
  1398.        
  1399.             # player joined the area packet
  1400.             if packetData[0:4] == [0x08, 0x75, 0xff, 0x00]:
  1401.                 if DEBUG_ALL:
  1402.                     self.playerJoined(packetData)
  1403.  
  1404.             # player left the area packet
  1405.             if packetData[0:4] == [0x08, 0x74, 0xff, 0x00]:
  1406.                 if DEBUG_ALL:
  1407.                     self.playerLeft(packetData)
  1408.  
  1409.             # player chat packet
  1410.             if packetData[0:2] == [0x07, 0x00]:
  1411.                 if DEBUG_ALL:
  1412.                     self.playerChat(packetData)
  1413.        
  1414.         return DBG_CONTINUE
  1415.  
  1416.     def getProcessId(self):
  1417.    
  1418.         if not STEAM:
  1419.             clients = [x[0] for x in self.dbg.enumerate_processes() if x[1].lower() == 'pathofexile.exe']
  1420.             print >>self.logFile, str.format('"pathofexile.exe" processes found: {0!s}', clients)
  1421.         else:
  1422.             clients = [x[0] for x in self.dbg.enumerate_processes() if x[1].lower() == 'pathofexilesteam.exe']
  1423.             print >>self.logFile, str.format('"pathofexilesteam.exe" processes found: {0!s}', clients)
  1424.  
  1425.  
  1426.         pid = None
  1427.        
  1428.         if not STEAM:
  1429.             if not clients or len(clients) == 0:
  1430.                 print ''
  1431.                 print '-----------------------------------------'
  1432.                 print Style.BRIGHT + Fore.YELLOW + 'No "PathOfExile.exe" process found.'
  1433.                 print 'Did you set the STEAM flag properly?'
  1434.                 print '-----------------------------------------'
  1435.                 print ''
  1436.             elif len(clients) > 1:
  1437.                 print 'Found more than one "pathofexile.exe" process.'
  1438.             else:
  1439.                 pid = clients[0]
  1440.         else:
  1441.             if not clients or len(clients) == 0:
  1442.                 print ''
  1443.                 print '-----------------------------------------'
  1444.                 print Style.BRIGHT + Fore.YELLOW + 'No "PathOfExileSteam.exe" process found.'
  1445.                 print 'Did you set the STEAM flag properly?'
  1446.                 print '-----------------------------------------'
  1447.                 print ''
  1448.             elif len(clients) > 1:
  1449.                 print 'Found more than one "pathofexilesteam.exe" process.'
  1450.             else:
  1451.                 pid = clients[0]
  1452.        
  1453.         return pid
  1454.  
  1455.     def getBaseAddress(self):
  1456.         if not STEAM:
  1457.             base = [x[1] for x in self.dbg.enumerate_modules() if x[0].lower() == 'pathofexile.exe'][0]
  1458.         else:
  1459.             base = [x[1] for x in self.dbg.enumerate_modules() if x[0].lower() == 'pathofexilesteam.exe'][0]
  1460.            
  1461.         print >>self.logFile, str.format('Base address: 0x{0:08x}', base)
  1462.         return base
  1463.  
  1464.     def run(self):
  1465.         print >>self.logFile, str.format('bp0: 0x{0:08x}: {1}', ItemAlert.BP0, self.dbg.disasm(ItemAlert.BP0))
  1466.         print >>self.logFile, str.format('bp1: 0x{0:08x}: {1}', ItemAlert.BP1, self.dbg.disasm(ItemAlert.BP1))
  1467.         print >>self.logFile, str.format('bp2: 0x{0:08x}: {1}', ItemAlert.BP2, self.dbg.disasm(ItemAlert.BP2))
  1468.         try:
  1469.             self.dbg.bp_set(ItemAlert.BP0, handler=self.grabPacketSize)
  1470.             self.dbg.bp_set(ItemAlert.BP1, handler=self.beforeDemanglingPacket)
  1471.             self.dbg.bp_set(ItemAlert.BP2, handler=self.afterDemanglingPacket)
  1472.         except Exception as inst:
  1473.             print >>self.logFile, type(inst)
  1474.             print >>self.logFile, inst.args
  1475.             print >>self.logFile, inst
  1476.             traceback.print_exc(file=self.logFile)
  1477.         print >>self.logFile, 'Starting main loop.'
  1478.         try: self.dbg.debug_event_loop()
  1479.         except: pass
  1480.  
  1481.     def atExit(self):
  1482.         #print ''
  1483.         #print 'atExit()'
  1484.         #print ''
  1485.         try: self.dbg.detach()
  1486.         except: pass
  1487.  
  1488. def checkVersion():
  1489.     if ctypes.sizeof(ctypes.c_voidp) != 4:
  1490.         print 'This program only works with a 32-bit Python installation!'
  1491.         print 'The preferred (tested) version is Python 2.7, 32-bit.'
  1492.         print 'You can download it from here: http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi'
  1493.         sys.exit(1)
  1494.  
  1495. def main():
  1496.    
  1497.     if not STEAM:
  1498.         OMGDONT('title Path of Exile ItemAlert')
  1499.     else:
  1500.         OMGDONT('title Path of Exile (Steam) ItemAlert')
  1501.        
  1502.     checkVersion()
  1503.    
  1504.     if not STEAM:
  1505.         print Style.BRIGHT + Fore.YELLOW + str.format('Starting ItemAlert {0} for Path of Exile {1}', ALERT_VERSION, POE_VERSION)
  1506.         print ''
  1507.     else:
  1508.         print Style.BRIGHT + Fore.YELLOW + str.format('Starting ItemAlert {0} for Path of Exile (Steam) {1}', ALERT_VERSION, POE_VERSION)
  1509.         print ''
  1510.     with ItemAlert() as alerter: alerter.run()
  1511.  
  1512. if __name__ == '__main__':
  1513.     main()
Advertisement
Add Comment
Please, Sign In to add comment