예제 #1
0
    def parseWorldItemPacket(self, packetData):
    
        global number_of_uniques
        global number_of_rares 
        global number_of_orbs 
        global number_of_maps
        global RUN
    
        try:
            buffer = ByteBuffer(packetData)
            buffer.setEndian(ByteBuffer.BIG_ENDIAN)

            id = buffer.nextByte()
            #print >>self.logFile, str.format('id = {0}', id)

            objectType = buffer.nextDword()
            #print >>self.logFile, str.format('ObjectType = {0}', objectType)

            unk1 = buffer.nextDword()
            #print >>self.logFile, str.format('unk1 = {0}', unk1)

            unk2 = buffer.nextByte()
            #print >>self.logFile, str.format('unk2 = {0}', unk2)

            if unk2 != 0: 
                print >>self.logFile, 'The following packet has an odd unk2 field:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                return

            xcoord = buffer.nextDword()
            #print >>self.logFile, str.format('x coord = {0}', xcoord)
            
            ycoord = buffer.nextDword()
            #print >>self.logFile, str.format('y coord = {0}', ycoord)
            
            rot = buffer.nextDword()
            #print >>self.logFile, str.format('rot = {0}', rot)

            unk3 = buffer.nextDword(ByteBuffer.LITTLE_ENDIAN)
            #print >>self.logFile, str.format('unk3 = {0}', unk3)
            
            unk4 = buffer.nextDword()
            #print >>self.logFile, str.format('unk4 = {0}', unk4)
            
            if unk3 >> 2 != 0:
                print >>self.logFile, 'The following packet has an odd unk3 field:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                buffer.nextDword()
                buffer.nextDword()

            unk5 = buffer.nextDword()
            #print >>self.logFile, str.format('unk5 = {0}', unk5)

            unk6 = buffer.nextDword()
            #print >>self.logFile, str.format('unk6 = {0}', unk6)

            unk7 = buffer.nextByte()
            #print >>self.logFile, str.format('unk7 = {0}', unk7)
            
            unk8 = buffer.nextDword()
            #print >>self.logFile, str.format('unk8 = {0}', unk8)
			
            
            if unk8 >= 2:

                unk8 = buffer.nextDword()

            dropped_by_entity = buffer.nextByte()
            if DEBUG:
                print >>self.logFile, str.format('dropped by player or mob : {0}', dropped_by_entity)
            
            itemId = buffer.nextDword()
            print >>self.logFile, 'itemId = ' + "0x%x"%(itemId&0xffffffff)

            #remaining = buffer.getRemainingBytes()
            
            itemName = getItemName(itemId)
            print >>self.logFile, str.format('itemName = {0}', itemName)

            if itemName == "unknown item":
                
                if DEBUG:
                    print Style.BRIGHT + Fore.RED + 'UNKNOWN ITEM:' + "0x%x"%(itemId&0xffffffff)

                print >>self.logFile, '---------------------------------'
                return

            if isCurrencyItem(itemName):
            
                if itemId !=0x50880BAF and itemId != 0x4F2B00ED: 
                    print Fore.WHITE + str.format('CUR: {0}',itemName)
                    number_of_orbs += 1

                    if itemId == 0x61B2F5ED and SOUND_eternal == True: # Eternal Orb
                        crafting_drop = PlaySoundholy()
                        crafting_drop.start()
                    if itemId == 0xC04F5629 and SOUND_exalted == True: # Exalted Orb
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x80047CFD and SOUND_divine == True: # Divine Orb
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x07A992EB and SOUND_gcp == True: # Gemcutter's Prism
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0xD8BD4F5D and SOUND_regal == True: # Regal Orb
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x9B4B42A5 and SOUND_regret == True: # Orb of Regret
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x7353DDF9 and SOUND_chaos == True: # Chaos Orb
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x2D8E7632 and SOUND_blessed == True: # Blessed Orb
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x7F0EF637 and SOUND_scour == True: # Orb of Scouring
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x9110493F and SOUND_alc == True: # Orb of Alchemy
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0xC71BF58D and SOUND_fuse == True: # Orb of Fusing
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0xDC217297 and SOUND_chis == True: # Cartographer's Chisel
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0xC5732C85 and SOUND_chance == True: # Orb of Chance
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0xDD917991 and SOUND_jew == True: # Jeweller's Orb
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0xDD74C4BF and SOUND_glass == True: # Glassblower's Bauble
                        crafting_drop = PlaySoundCraftingItem()
                        crafting_drop.start()
                    if itemId == 0x79C23B15 and SOUND_mirror == True: # Mirror of Kalandra
                        crafting_drop = PlaySoundholy()
                        crafting_drop.start()
                
                print >>self.logFile, '---------------------------------'
                return
                
            actual = buffer.nextByte()
            actual = buffer.nextByte()
            actual = buffer.nextByte()
            actual = buffer.nextDword()
            itemlevel = buffer.nextDword()
            if DEBUG:
                print >>self.logFile, str.format('itemlevel = {0}', itemlevel)

            if isGemItem(itemName) and ALERT_GEMS == True:

                actual = buffer.nextByte()
                quality = int(buffer.nextDword())
                if DEBUG:
                    print >>self.logFile, str.format('Gem quality = {0}', quality)
                if quality >= gemqual:
                    print Fore.CYAN + str.format('GEM: {0}, quality: {1}',itemName,quality)

                if str(hex(itemId)) in specialGems and ALERT_SPECIALGEMS == True:
                    print Fore.CYAN + str.format('Special GEM: {0}, quality: {1}',itemName,quality)
                    
                    if SOUND_specialgems == True:
                        gem_drop = PlaySoundholy()
                        gem_drop.start()
                    
                print >>self.logFile, '---------------------------------'
                return

            req_lvl = buffer.nextDword()
            if DEBUG:
                print >>self.logFile, str.format('req lvl = {0}', req_lvl)
                
            if SEARCH_special:

                if isSearchItem(itemName,special_class):    

                    if  itemlevel >= special_ilvl and special_rlvl <= req_lvl:
                    
                        sound = PlaySound6Sockets()
                        sound.start()
                        print Style.BRIGHT + Fore.RED + str.format('Special Item: {0}, itemlevel: {1}',itemName,itemlevel)
            
            actual = buffer.nextDword()
            actual = buffer.nextByte()
            rarity = buffer.nextDword()
            if DEBUG:
                print >>self.logFile, str.format('rarity = {0}', rarity)

            identified = buffer.nextDword()
            if DEBUG:
                print >>self.logFile, str.format('identified = {0}', identified)
                
            
            if isMapItem(itemName) and ALERT_MAPS == True:
                
                actual = buffer.nextDword()
                actual = buffer.nextDword()
                actual = buffer.nextByte()
                
                actual = buffer.nextDword()
                actual = buffer.nextDword()
                quality = int(buffer.nextDword())
                actual = int(buffer.nextByte())
                if DEBUG:
                    print >>self.logFile, str.format('quality = {0}', quality)
                
                if quality == 0 and actual == 0:
                    quality = int(buffer.nextDword())
                    if DEBUG:
                        print >>self.logFile, str.format('quality new = {0}', quality)
                
                print Style.BRIGHT + Fore.BLUE + str.format('MAP: {0}, rarity: {1}, itemlevel: {2}, quality: {3}',itemName,rarity,itemlevel,quality)

                print >>self.logFile, '---------------------------------'

                if SOUND_maps == True:
                    map = PlaySoundMaps()
                    map.start()
       
                number_of_maps += 1
                return

            if isBeltItem(itemName):
                
                if rarity == 3:
                
                    print Fore.YELLOW + str.format('UNI BELT: {0}, rarity: {1}',itemName,rarity)
                    if SOUND_uniques == True:
                        unique = PlaySoundUnique()
                        unique.start()

                    number_of_uniques += 1
            
                elif rarity == 2 and ALERT_RARES == True:
                
                    print Style.BRIGHT + Fore.YELLOW + str.format('BELT: {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)

                print >>self.logFile, '---------------------------------'
                
                return

            if isQuiverItem(itemName):
                
                if rarity == 3:
                
                    print Fore.YELLOW + str.format('UNI Quiver: {0}, rarity: {1}',itemName,rarity)
                    if SOUND_uniques == True:
                        unique = PlaySoundUnique()
                        unique.start()

                    number_of_uniques += 1
            
                elif rarity == 2 and ALERT_RARES == True:
                
                    print Style.BRIGHT + Fore.YELLOW + str.format('QUIV: {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)

                print >>self.logFile, '---------------------------------'
                
                return

            if isJewelleryItem(itemName):
                
                if rarity == 2 and ALERT_RARES == True:
                    print Style.BRIGHT + Fore.YELLOW + str.format('JEW: {0}, rarity: {1}',itemName,rarity)
                    number_of_rares += 1
                    
                if (rarity == 0 or rarity == 1) and (itemId == 0x29F77698 or itemId == 0xDE069771) and ALERT_JEW_VALUES == True:

                    _implicitmods = int(buffer.nextDword())
                    _mod = buffer.nextDword()
                    _modvalues = buffer.nextByte()
                    _modvalue = int(buffer.nextDword())
                    
                    if _modvalue >= 13 and itemId == 0x29F77698:

                        print Fore.WHITE + str.format('JEW: {0}, Value: {1}',itemName,_modvalue)
                        
                    if _modvalue >= 18 and itemId == 0xDE069771:

                        print Fore.WHITE + str.format('JEW: {0}, Value: {1}',itemName,_modvalue)
                    
                elif rarity == 3:
                
                    if identified == 1 and itemId == 0x29F77698:
                        
                        if RUN == False:
                            RUN = True
                            number_of_uniques = 0
                            number_of_rares = 0
                            number_of_orbs = 0
                            number_of_maps = 0
                            
                            staTime= datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
                            startTime = str.format('{0}',staTime)
                            
                            print Style.BRIGHT + Fore.GREEN + str.format('==== {0} ===== RUN started ===========',startTime)
                            
                            #print >>self.logFile, str.format('{0}', startTime)
                            # measure runtime later on here, get the start time
                            
                        else:
                        
                            RUN = False
                            stoTime = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
                            stopTime = str.format('{0}',stoTime)
                            print Style.BRIGHT + Fore.GREEN + str.format('==== {0} ===== RUN stopped ===========',stopTime)                            
                            print >>self.statFile, str.format('{0},{1},{2},{3},{4}', stopTime,number_of_uniques,number_of_rares,number_of_orbs,number_of_maps)
                            
                    else:
                        print Fore.YELLOW + str.format('UNI JEW: {0}, rarity: {1}',itemName,rarity)
                        if SOUND_uniques == True:
                            unique = PlaySoundUnique()
                            unique.start()
                        
                        number_of_uniques += 1

                        
                print >>self.logFile, '---------------------------------'
                return

            if isArmourItem(itemName):
                    
                if rarity == 0:

                    if shouldNotify(itemName):
                        print Fore.WHITE + str.format('SPC: {0}', itemName)
                        # worker = PlaySoundWorker()
                        # worker.start()

                        print >>self.logFile, '---------------------------------'
                        return
                        
                elif rarity == 2:
                    number_of_rares += 1
                
                if identified == 1:

                    if isShieldItem(itemName):
                    
                        if DEBUG:
                            print >>self.logFile, str.format('identified as SHIELD', '1')

                        _implicitmod = int(buffer.nextDword())
                        
                        if _implicitmod == 2:
                            actual=buffer.nextDword()
                                
                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual=buffer.nextDword()

                                _impl_mod = int(buffer.nextDword())
                                if DEBUG:
                                    print >>self.logFile, str.format('implicit mod = {0}', _impl_mod)

                                _impl_mod_values = int(buffer.nextByte())
                                
                                for i in range(0,_impl_mod_values):
                                    # needs to be worked out
                                    _mod_value = int(buffer.nextDword())
                                    
                                _skipnext = int(buffer.nextByte())
                                    
                                if _skipnext >= 1:
                                    for i in range(0,_skipnext):
                                        actual = int(buffer.nextDword())

                                    
                        else:
                        
                            actual=buffer.nextDword()
                        
                            _skipnext = int(buffer.nextByte())            

                            if _skipnext >= 1:                        
                                for i in range(0,_skipnext):
                                    actual=buffer.nextDword()
                    
                                _skipnext = int(buffer.nextByte())            

                                if _skipnext >= 1:                        
                                    for i in range(0,_skipnext):
                                        actual=buffer.nextDword()
                    
                    else:
                        _implicitmods = int(buffer.nextDword())
                        
                        if _implicitmods == 2:
                        
                            if DEBUG:
                                print >>self.logFile, str.format('_implicitmods = {0}', _implicitmods)
            
                        elif _implicitmods == 1:

                            _implicitmod = buffer.nextDword()
                            if DEBUG:
                                print >>self.logFile, str.format('_implicitmod = {0}', _implicitmod)
                            
                            _impl_mod_values = int(buffer.nextByte())
                            if DEBUG:
                                print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
                            
                            
                            for i in range(0,_impl_mod_values):
                                # needs to be worked out
                                _mod_value = int(buffer.nextDword())
                                
                        unk_mod=int(buffer.nextByte())
                        
                        if unk_mod >=0:
                            for i in range(0,unk_mod):
                                # needs to be worked out
                                _mod_value = int(buffer.nextDword())
                            
                    
                    number_of_mods = int(buffer.nextDword())

                else:
                
                    if isShieldItem(itemName):
                    
                        if DEBUG:
                            print >>self.logFile, str.format('identified as SHIELD', '1')
                    
                
                        _implicitmod = int(buffer.nextDword())
                        
                        if _implicitmod == 2:
                        
                            actual=buffer.nextDword()
                                
                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual=buffer.nextDword()

                                _impl_mod = int(buffer.nextDword())
                                
                                if DEBUG:
                                    print >>self.logFile, str.format('implicit mod = {0}', _impl_mod)

                                _impl_mod_values = int(buffer.nextByte())

                                if DEBUG:
                                    print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
                                
                                
                                if _impl_mod_values > 0:
                                    for i in range(0,_impl_mod_values):
                                        # needs to be worked out
                                        _mod_value = int(buffer.nextDword())
                                        if DEBUG:
                                            print >>self.logFile, str.format('_mod_value = {0}', _mod_value)

                        elif _implicitmod == 1:
                        
                            actual=buffer.nextDword()
                        
                            _skipnext = int(buffer.nextByte())            

                            if _skipnext >= 1:                        
                                for i in range(0,_skipnext):
                                    actual=buffer.nextDword()

                    else:

                        _implicitmods = int(buffer.nextDword())
                        
                        if _implicitmods == 2:
                        
                            if DEBUG:
                                print >>self.logFile, str.format('_implicitmods = {0}', _implicitmods)
            
                        elif _implicitmods == 1:

                            _implicitmod = buffer.nextDword()
                            if DEBUG:
                                print >>self.logFile, str.format('_implicitmod = {0}', _implicitmod)
                            
                            _impl_mod_values = int(buffer.nextByte())
                            if DEBUG:
                                print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
                            
                            
                            for i in range(0,_impl_mod_values):
                                # needs to be worked out
                                _mod_value = int(buffer.nextDword())

                    number_of_mods = 0
                                
                if DEBUG:
                    print >>self.logFile, str.format('number of explicit mods = {0}', number_of_mods)
                
                if number_of_mods > 6:
                    print >>self.logFile, 'The last packet had an odd number_of_mods field:'
                    print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))

                    print >>self.logFile, '---------------------------------'                        
                    return
                
                
                for i in range(0,number_of_mods):
                    mod_id = buffer.nextDword()
                    if DEBUG:
                        print >>self.logFile, str.format('mod id = {0}', mod_id)
                    sub_mod_count = buffer.nextByte()
                    if sub_mod_count > 3:
                        print >>self.logFile, 'The last packet had an odd sub_mod_count field:'
                        if DEBUG:
                            print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))

                        print >>self.logFile, '---------------------------------'                        
                        return
                    
                    for ii in range(0,sub_mod_count):
                        mod_value=buffer.nextDword()
                        if sub_mod_count == 1:
                            if DEBUG:
                                print >>self.logFile, str.format('Modifier: {0}{1}', mod_value, getModifierName(mod_id))
                        elif sub_mod_count == 2:
                            if mod_value != 0:
                                sub_mods = getModifierName(mod_id).split("/")
                                sub_mod = sub_mods[ii]
                                if DEBUG:
                                    print >>self.logFile, str.format('Modifier: {0}{1}', mod_value, sub_mod)
                    
                quality = buffer.nextDword()
                if DEBUG:
                    print >>self.logFile, str.format('quality = {0}', quality)
                actual = buffer.nextByte()
                sockets = int(buffer.nextDword())
                if DEBUG:
                    print >>self.logFile, str.format('sockets = {0}', sockets)

                if sockets == 0 or sockets > 6:
                    print >>self.logFile, 'The last packet had an odd sockets field:'
                    if DEBUG:
                        print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                    
                    print >>self.logFile, '---------------------------------'                        
                    return
                
                _all_color = []
                
                sock_color_tmp = ""
                sock_color_tmp = getSocketColor(int(buffer.nextByte()))
                
                actual = buffer.nextByte()
                _all_color.append(sock_color_tmp)
                
                for i in range(1,sockets):
                    sock_color_tmp = getSocketColor(int(buffer.nextByte()))
                    actual = buffer.nextByte()
                    _all_color.append(sock_color_tmp)

                if DEBUG:
                    print >>self.logFile, str.format('socket colors = {0}', _all_color)
                    
                sock_fragments = int(buffer.nextDword())
                
                if DEBUG:
                    print >>self.logFile, str.format('socket fragments = {0}', sock_fragments)

                if sock_fragments > 6 or sock_fragments == 0:
                    print >>self.logFile, 'The last packet had an odd sock_fragments field:'
                    if DEBUG:
                        print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))

                    print >>self.logFile, '---------------------------------'                        
                    return
                
                listlen = len(_all_color)
                
                if sock_fragments == 1:
                    if DEBUG:
                        print >>self.logFile, str.format('Fully linked = {0}', sock_fragments)
                    ii=0
                    for i in range(1,listlen):
                        _all_color.insert(i+ii,"-")
                        ii=ii+1
                        
                else:
                    iii=0
                    maxfrag = 1
                    for i in range(0,sock_fragments):
                        frag = int(buffer.nextByte())
                        if frag > 1:
                            if maxfrag < frag:
                                maxfrag = frag
                            for ii in range(1,frag):
                                _all_color.insert(ii+iii,"-")
                                iii=iii+1
                            iii=iii+ii+1
                        else:
                            iii=iii+1
                
                socketsetup = ''.join(_all_color)
                
                if DEBUG:
                    print >>self.logFile, str.format('Socket Setup = {0}', socketsetup)

                rare_alerted = False 

                if ALERT_RACE:
                
                    if any(i in socketsetup for i in race_sockets):
                    
                        if rarity == 0:
                            print Style.BRIGHT + Fore.RED + "Race item" + Style.BRIGHT + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                        if rarity == 1:
                            print Style.BRIGHT + Fore.RED + "Race item" + Style.BRIGHT + Fore.BLUE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                        if rarity == 2:
                            print Style.BRIGHT + Fore.RED + "Race item" + Style.BRIGHT + Fore.YELLOW + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                            rare_alerted = True 

                        if SOUND_race:
                            sound = PlaySoundRace()
                            sound.start()

                
                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')):
                
                    if rarity == 0:
                        print Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.BLUE + "B" + Style.BRIGHT + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                    if rarity == 1:
                        print Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.BLUE + "B" + Style.BRIGHT + Fore.BLUE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                    if rarity == 2:
                        print Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.BLUE + "B" + Style.BRIGHT + Fore.YELLOW + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                        rare_alerted = True 

                    if SOUND_rgb:
                        sound = PlaySoundRGB()
                        sound.start()

                    
                msg = ""
                if sockets == 5:
                    if sock_fragments == 1:
                        msg = "5-SLOT 5-LINK"
                if sockets == 6:
                    if sock_fragments == 1:
                        msg = "6-SLOT 6-LINK"
                    elif sock_fragments == 2:
                        if maxfrag == 5:
                            msg = "6-SLOT 5-LINK"
                        else:
                            msg = "6-SLOT"
                    else:
                        msg = "6-SLOT"
                
                if msg != "":
                    print >>self.logFile, msg

                    if rarity == 0:
                        print 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)
                    if rarity == 1:
                        print Style.BRIGHT + Fore.MAGENTA + msg + Style.BRIGHT + Fore.BLUE + str.format(' : {0}, rarity: {1}, ilvl: {2}, qual: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup)
                    if rarity == 2:
                        print 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)
                        rare_alerted = True 

                    if SOUND_slots == True and msg != "6-SLOT":
                        sound = PlaySoundholy()
                        sound.start()
                    else:
                        if SOUND_6sockets == True:
                            sound = PlaySound6Sockets()
                            sound.start()
                        
                if rarity == 3:
                    print >>self.logFile, 'UNIQUE !'
                    number_of_uniques += 1
                    
                    print Fore.YELLOW + str.format('UNI: {0}, rarity: {1}, ilvl: {2}, qual: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup)
                    
                    if SOUND_uniques == True:
                        unique = PlaySoundUnique()
                        unique.start()

                if rarity == 2 and ALERT_RARES == True and rare_alerted == False:
                
                    print Style.BRIGHT + Fore.YELLOW + str.format('RARE: {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                    
                    
                print >>self.logFile, '---------------------------------'
                return
                    
            
            print >>self.logFile, '---------------------------------'            
                
예제 #2
0
    def parseWorldItemPacket(self, packetData):
        try:
            buffer = ByteBuffer(packetData)
            buffer.setEndian(ByteBuffer.BIG_ENDIAN)

            id = buffer.nextByte()
            objectType = buffer.nextDword()
            unk1 = buffer.nextDword()
            unk2 = buffer.nextByte()
            if unk2 != 0: 
                print >>self.logFile, 'The following packet has an odd unk2 field:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                return

            x = buffer.nextDword()
            y = buffer.nextDword()
            rot = buffer.nextDword()

            unk3 = buffer.nextDword(ByteBuffer.LITTLE_ENDIAN)
            unk4 = buffer.nextDword()

            if unk3 >> 2 != 0:
                print >>self.logFile, 'The following packet has an odd unk3 field:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                buffer.nextDword()
                buffer.nextDword()

            unk5 = buffer.nextByte()
            if unk5 != 0:
                print >>self.logFile, 'The following packet has an odd unk5 field:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                return

            unk5 = buffer.nextDword()
            if unk5 != 0: buffer.nextDword()

            unk6 = buffer.nextByte()
            itemId = buffer.nextDword()

            itemName = getItemName(itemId)
            if shouldNotify(itemName):
                print str.format('Detected item drop: {0}', itemName)
                worker = PlaySoundWorker()
                worker.start()
            
            #Specified items (like gems)
            sPlayer = SoundPlayer()
            if itemId == 0xC04F5629:
                sPlayer.start('exaltedorb.wav');
            if itemId == 0x07A992EB:
                sPlayer.start('gemcuttersprism.wav');
            
            remaining = buffer.getRemainingBytes()
            actual = buffer.nextDword()
            actual = buffer.nextDword()
            actual = buffer.nextDword()
            actual = buffer.nextDword()
            if isGemItem(itemName):
                if actual & 0x0000FF00 > 0:
                    superiorgem = PlaySoundSuperiorGem()
                    superiorgem.start()
                else:
                    worker = PlaySoundWorker()
                    worker.start()
            if isFlaskItem(itemName):
                if actual & 0x0000FF00 > 0:
                    superiorflask = PlaySoundSuperiorFlask()
                    superiorflask.start()
                    
            actual = buffer.nextDword()
            actual = buffer.nextDword()
            if actual == 0x00000300:
                unique = PlaySoundUnique()
                unique.start()
                
        except: pass
예제 #3
0
    def parseWorldItemPacket(self, packetData):
    
        global number_of_uniques
        global number_of_rares 
        global number_of_orbs 
        global number_of_maps
        global RUN
    
        try:
            buffer = ByteBuffer(packetData)
            buffer.setEndian(ByteBuffer.BIG_ENDIAN)

            if DEBUG:
                print >>self.logFile, '---------------------------------'
                print >>self.logFile, 'packet:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                            
            
            id = buffer.nextByte()
            #print >>self.logFile, str.format('id = {0}', id)
            
            objectType = buffer.nextDword()
            #print >>self.logFile, str.format('ObjectType = {0}', objectType)
            
            unk1 = buffer.nextDword()
            #print >>self.logFile, str.format('unk1 = {0}', unk1)
            
            unk2 = buffer.nextByte()
            #print >>self.logFile, str.format('unk2 = {0}', unk2)
            
            if unk2 != 0: 
                print >>self.logFile, 'The following packet has an odd unk2 field:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                return

            x = buffer.nextDword()
            #print >>self.logFile, str.format('x = {0}', x)
            
            y = buffer.nextDword()
            #print >>self.logFile, str.format('y = {0}', y)
            
            rot = buffer.nextDword()
            #print >>self.logFile, str.format('rot = {0}', rot)

            unk3 = buffer.nextDword(ByteBuffer.LITTLE_ENDIAN)
            #print >>self.logFile, str.format('unk3 = {0}', unk3)
            
            unk4 = buffer.nextDword()
            #print >>self.logFile, str.format('unk4 = {0}', unk4)
            
            if unk3 >> 2 != 0:
                print >>self.logFile, 'The following packet has an odd unk3 field:'
                print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                buffer.nextDword()
                buffer.nextDword()

            unk5 = buffer.nextDword()
            #print >>self.logFile, str.format('unk5 = {0}', unk5)

            unk6 = buffer.nextDword()
            #print >>self.logFile, str.format('unk6 = {0}', unk6)

            unk7 = buffer.nextByte()
            #print >>self.logFile, str.format('unk7 = {0}', unk7)
            
            unk8 = buffer.nextDword()
            #print >>self.logFile, str.format('unk8 = {0}', unk8)
			
            if unk8 >= 2:
                unk8 = buffer.nextDword()

            quantity = buffer.nextByte()
            #print >>self.logFile, str.format('quantity = {0}', quantity)
            
            itemId = buffer.nextDword()
            print >>self.logFile, str.format('itemId = {0}', itemId)

            #remaining = buffer.getRemainingBytes()
            
            itemName = getItemName(itemId)
            print >>self.logFile, str.format('itemName = {0}', itemName)
            

            if isCurrencyItem(itemName):
                print Fore.WHITE + str.format('CUR: {0}',itemName)
                number_of_orbs += 1
                
                #Specified items (like gems)
                sPlayer = SoundPlayer()
                if itemId == 0xC04F5629:
                    sPlayer.start('exaltedorb.wav');
                if itemId == 0x07A992EB:
                    sPlayer.start('gemcuttersprism.wav');
                
                return
                
            actual = buffer.nextByte()
            actual = buffer.nextByte()
            actual = buffer.nextByte()
            actual = buffer.nextDword()
            itemlevel = buffer.nextDword()
            if DEBUG:
                print >>self.logFile, str.format('itemlevel = {0}', itemlevel)

            if isGemItem(itemName) and ALERT_GEMS == True:

                actual = buffer.nextByte()
                quality = int(buffer.nextDword())
                #print >>self.logFile, str.format('quality = {0}', quality)
                if quality >= 5:
                    print Fore.CYAN + str.format('GEM: {0}, quality: {1}',itemName,quality)
                    #unique = PlaySoundUnique()
                    #unique.start()

                print >>self.logFile, '---------------------------------'
                return

            req_lvl = buffer.nextDword()
            actual = buffer.nextDword()
            actual = buffer.nextByte()
            rarity = buffer.nextDword()
            if DEBUG:
                print >>self.logFile, str.format('rarity = {0}', rarity)

            identified = buffer.nextDword()
            if DEBUG:
                print >>self.logFile, str.format('identified = {0}', identified)
                
            
            if isMapItem(itemName) and ALERT_MAPS == True:
                
                actual = buffer.nextDword()
                actual = buffer.nextDword()
                actual = buffer.nextByte()
                
                actual = buffer.nextDword()
                actual = buffer.nextDword()
                quality = int(buffer.nextDword())
                actual = int(buffer.nextByte())
                if DEBUG:
                    print >>self.logFile, str.format('quality = {0}', quality)
                
                if quality == 0 and actual == 0:
                    quality = int(buffer.nextDword())
                    if DEBUG:
                        print >>self.logFile, str.format('quality new = {0}', quality)
                
                print Style.BRIGHT + Fore.BLUE + str.format('MAP: {0}, rarity: {1}, itemlevel: {2}, quality: {3}',itemName,rarity,itemlevel,quality)

                print >>self.logFile, '---------------------------------'
                
                number_of_maps += 1
                return

            if isBeltItem(itemName):
                
                if rarity == 3:
                
                    print Fore.YELLOW + str.format('UNI BELT: {0}, rarity: {1}',itemName,rarity)
                    unique = PlaySoundUnique()
                    unique.start()

                    number_of_uniques += 1
            
                elif rarity == 2 and ALERT_RARES == True:
                
                    print Style.BRIGHT + Fore.YELLOW + str.format('BELT: {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)

                print >>self.logFile, '---------------------------------'
                
                return

            if isJewelleryItem(itemName):
                
                if rarity == 2 and ALERT_RARES == True:
                    print Style.BRIGHT + Fore.YELLOW + str.format('JEW: {0}, rarity: {1}',itemName,rarity)
                    number_of_rares += 1
                    
                if (rarity == 0 or rarity == 1) and (itemId == 0x29F77698 or itemId == 0xDE069771) and ALERT_JEW_VALUES == True:

                    _implicitmods = int(buffer.nextDword())
                    _mod = buffer.nextDword()
                    _modvalues = buffer.nextByte()
                    _modvalue = int(buffer.nextDword())
                    
                    if _modvalue >= 13 and itemId == 0x29F77698:

                        print Fore.WHITE + str.format('JEW: {0}, Value: {1}',itemName,_modvalue)
                        
                    if _modvalue >= 18 and itemId == 0xDE069771:

                        print Fore.WHITE + str.format('JEW: {0}, Value: {1}',itemName,_modvalue)
                    
                elif rarity == 3:
                
                    if identified == 1 and itemId == 0x29F77698:
                        
                        if RUN == False:
                            RUN = True
                            number_of_uniques = 0
                            number_of_rares = 0
                            number_of_orbs = 0
                            number_of_maps = 0
                            
                            staTime= datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
                            startTime = str.format('{0}',staTime)
                            
                            print Style.BRIGHT + Fore.GREEN + str.format('==== {0} ===== RUN started ===========',startTime)
                            
                            #print >>self.logFile, str.format('{0}', startTime)
                            # measure runtime later on here, get the start time
                            
                        else:
                        
                            RUN = False
                            stoTime = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
                            stopTime = str.format('{0}',stoTime)
                            print Style.BRIGHT + Fore.GREEN + str.format('==== {0} ===== RUN stopped ===========',stopTime)                            
                            print >>self.statFile, str.format('{0},{1},{2},{3},{4}', stopTime,number_of_uniques,number_of_rares,number_of_orbs,number_of_maps)
                            
                    else:
                        print Fore.YELLOW + str.format('UNI JEW: {0}, rarity: {1}',itemName,rarity)
                        unique = PlaySoundUnique()
                        unique.start()
                        
                        number_of_uniques += 1

                        
                print >>self.logFile, '---------------------------------'
                return

            if isArmourItem(itemName):
                    
                if rarity == 0:

                    if shouldNotify(itemName):
                        print Fore.WHITE + str.format('SPC: {0}', itemName)
                        # worker = PlaySoundWorker()
                        # worker.start()

                        print >>self.logFile, '---------------------------------'
                        return
                        
                elif rarity == 2:
                    number_of_rares += 1
                
                if identified == 1:

                    if isShieldItem(itemName):
                    
                        if DEBUG:
                            print >>self.logFile, str.format('identified as SHIELD', '1')

                        _implicitmod = int(buffer.nextDword())
                        
                        if _implicitmod == 2:
                            actual=buffer.nextDword()
                                
                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual=buffer.nextDword()

                                _impl_mod = int(buffer.nextDword())
                                if DEBUG:
                                    print >>self.logFile, str.format('implicit mod = {0}', _impl_mod)

                                _impl_mod_values = int(buffer.nextByte())
                                
                                for i in range(0,_impl_mod_values):
                                    # needs to be worked out
                                    _mod_value = int(buffer.nextDword())
                                    
                                _skipnext = int(buffer.nextByte())
                                    
                                if _skipnext >= 1:
                                    for i in range(0,_skipnext):
                                        actual = int(buffer.nextDword())

                                    
                        else:
                        
                            actual=buffer.nextDword()
                        
                            _skipnext = int(buffer.nextByte())            

                            if _skipnext >= 1:                        
                                for i in range(0,_skipnext):
                                    actual=buffer.nextDword()
                    
                                _skipnext = int(buffer.nextByte())            

                                if _skipnext >= 1:                        
                                    for i in range(0,_skipnext):
                                        actual=buffer.nextDword()
                    
                    else:
                        _skipnext = int(buffer.nextDword())
                        
                        if _skipnext >= 1:
                            actual=buffer.nextDword()
                                
                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual=buffer.nextDword()

                                _skipnext = int(buffer.nextByte())

                                if _skipnext >= 1:
                                    actual=buffer.nextDword()
                        else:
                        
                            _skipnext = int(buffer.nextByte())            

                            if _skipnext >= 1:                        
                                for i in range(0,_skipnext):
                                    actual=buffer.nextDword()
                    
                    number_of_mods = int(buffer.nextDword())

                else:
                
                    if isShieldItem(itemName):
                    
                        if DEBUG:
                            print >>self.logFile, str.format('identified as SHIELD', '1')
                    
                
                        _implicitmod = int(buffer.nextDword())
                        
                        if _implicitmod == 2:
                        
                            actual=buffer.nextDword()
                                
                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual=buffer.nextDword()

                                _impl_mod = int(buffer.nextDword())
                                
                                if DEBUG:
                                    print >>self.logFile, str.format('implicit mod = {0}', _impl_mod)

                                _impl_mod_values = int(buffer.nextByte())

                                if DEBUG:
                                    print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
                                
                                
                                if _impl_mod_values > 0:
                                    for i in range(0,_impl_mod_values):
                                        # needs to be worked out
                                        _mod_value = int(buffer.nextDword())
                                        if DEBUG:
                                            print >>self.logFile, str.format('_mod_value = {0}', _mod_value)

                        elif _implicitmod == 1:
                        
                            actual=buffer.nextDword()
                        
                            _skipnext = int(buffer.nextByte())            

                            if _skipnext >= 1:                        
                                for i in range(0,_skipnext):
                                    actual=buffer.nextDword()

                    else:

                        _implicitmods = int(buffer.nextDword())
                        
                        if _implicitmods == 2:
                        
                            if DEBUG:
                                print >>self.logFile, str.format('_implicitmods = {0}', _implicitmods)
            
                        elif _implicitmods == 1:

                            _implicitmod = buffer.nextDword()
                            if DEBUG:
                                print >>self.logFile, str.format('_implicitmod = {0}', _implicitmod)
                            
                            _impl_mod_values = int(buffer.nextByte())
                            if DEBUG:
                                print >>self.logFile, str.format('_impl_mod_values = {0}', _impl_mod_values)
                            
                            
                            for i in range(0,_impl_mod_values):
                                # needs to be worked out
                                _mod_value = int(buffer.nextDword())

                    number_of_mods = 0
                                
                if DEBUG:
                    print >>self.logFile, str.format('number of explicit mods = {0}', number_of_mods)
                
                if number_of_mods > 6:
                    print >>self.logFile, 'The last packet had an odd number_of_mods field:'
                    print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))

                    print >>self.logFile, '---------------------------------'                        
                    return
                
                
                for i in range(0,number_of_mods):
                    mod_id = buffer.nextDword()
                    if DEBUG:
                        print >>self.logFile, str.format('mod id = {0}', mod_id)
                    sub_mod_count = buffer.nextByte()
                    if sub_mod_count > 3:
                        print >>self.logFile, 'The last packet had an odd sub_mod_count field:'
                        if DEBUG:
                            print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))

                        print >>self.logFile, '---------------------------------'                        
                        return
                    
                    for ii in range(0,sub_mod_count):
                        mod_value=buffer.nextDword()
                        if sub_mod_count == 1:
                            if DEBUG:
                                print >>self.logFile, str.format('Modifier: {0}{1}', mod_value, getModifierName(mod_id))
                        elif sub_mod_count == 2:
                            if mod_value != 0:
                                sub_mods = getModifierName(mod_id).split("/")
                                sub_mod = sub_mods[ii]
                                if DEBUG:
                                    print >>self.logFile, str.format('Modifier: {0}{1}', mod_value, sub_mod)
                    
                quality = buffer.nextDword()
                if DEBUG:
                    print >>self.logFile, str.format('quality = {0}', quality)
                actual = buffer.nextByte()
                sockets = int(buffer.nextDword())
                if DEBUG:
                    print >>self.logFile, str.format('sockets = {0}', sockets)

                if sockets == 0 or sockets > 6:
                    print >>self.logFile, 'The last packet had an odd sockets field:'
                    if DEBUG:
                        print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))
                    
                    print >>self.logFile, '---------------------------------'                        
                    return
                
                _all_color = []
                
                sock_color_tmp = ""
                sock_color_tmp = getSocketColor(int(buffer.nextByte()))
                
                actual = buffer.nextByte()
                _all_color.append(sock_color_tmp)
                
                for i in range(1,sockets):
                    sock_color_tmp = getSocketColor(int(buffer.nextByte()))
                    actual = buffer.nextByte()
                    _all_color.append(sock_color_tmp)

                if DEBUG:
                    print >>self.logFile, str.format('socket colors = {0}', _all_color)
                    
                sock_fragments = int(buffer.nextDword())
                
                if DEBUG:
                    print >>self.logFile, str.format('socket fragments = {0}', sock_fragments)

                if sock_fragments > 6 or sock_fragments == 0:
                    print >>self.logFile, 'The last packet had an odd sock_fragments field:'
                    if DEBUG:
                        print >>self.logFile, self.dbg.hex_dump(map(lambda x: chr(x), packetData))

                    print >>self.logFile, '---------------------------------'                        
                    return
                
                listlen = len(_all_color)
                
                if sock_fragments == 1:
                    if DEBUG:
                        print >>self.logFile, str.format('Fully linked = {0}', sock_fragments)
                    ii=0
                    for i in range(1,listlen):
                        _all_color.insert(i+ii,"-")
                        ii=ii+1
                        
                else:
                    iii=0
                    maxfrag = 1
                    for i in range(0,sock_fragments):
                        frag = int(buffer.nextByte())
                        if frag > 1:
                            if maxfrag < frag:
                                maxfrag = frag
                            for ii in range(1,frag):
                                _all_color.insert(ii+iii,"-")
                                iii=iii+1
                            iii=iii+ii+1
                        else:
                            iii=iii+1
                
                socketsetup = ''.join(_all_color)
                
                if DEBUG:
                    print >>self.logFile, str.format('Socket Setup = {0}', socketsetup)

                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')):
                
                    print Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.BLUE + "B" + Style.BRIGHT + Fore.WHITE + str.format(': {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                    
                msg = ""
                if sockets == 5:
                    if sock_fragments == 1:
                        msg = "5-SLOT 5-LINK"
                if sockets == 6:
                    if sock_fragments == 1:
                        msg = "6-SLOT 6-LINK"
                    elif sock_fragments == 2:
                        if maxfrag == 5:
                            msg = "6-SLOT 5-LINK"
                        else:
                            msg = "6-SLOT"
                    else:
                        msg = "6-SLOT"
                
                if msg != "":
                    print >>self.logFile, msg
                    print Style.BRIGHT + Fore.MAGENTA + str.format('{5}: {0}, rarity: {1}, ilvl: {2}, quality: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup, msg)

                if rarity == 3:
                    print >>self.logFile, 'UNIQUE !'
                    number_of_uniques += 1
                    
                    print Fore.YELLOW + str.format('UNI: {0}, rarity: {1}, ilvl: {2}, quality: {3}, sockets: {4}',itemName,rarity,itemlevel,quality, socketsetup)
                    unique = PlaySoundUnique()
                    unique.start()

                if rarity == 2 and ALERT_RARES == True:
                
                    print Style.BRIGHT + Fore.YELLOW + str.format('RARE: {0}, rarity: {1}, itemlevel: {2}',itemName,rarity,itemlevel)
                    
                    
                print >>self.logFile, '---------------------------------'
                return
                    
            
            print >>self.logFile, '---------------------------------'            
                
        except: pass
예제 #4
0
    def parseWorldItemPacket(self, packetData):

        global number_of_uniques
        global number_of_rares
        global number_of_orbs
        global number_of_maps
        global RUN

        try:
            buffer = ByteBuffer(packetData)
            buffer.setEndian(ByteBuffer.BIG_ENDIAN)

            if DEBUG:
                print >> self.logFile, '---------------------------------'
                print >> self.logFile, 'packet:'
                print >> self.logFile, self.dbg.hex_dump(
                    map(lambda x: chr(x), packetData))

            id = buffer.nextByte()
            #print >>self.logFile, str.format('id = {0}', id)

            objectType = buffer.nextDword()
            #print >>self.logFile, str.format('ObjectType = {0}', objectType)

            unk1 = buffer.nextDword()
            #print >>self.logFile, str.format('unk1 = {0}', unk1)

            unk2 = buffer.nextByte()
            #print >>self.logFile, str.format('unk2 = {0}', unk2)

            if unk2 != 0:
                print >> self.logFile, 'The following packet has an odd unk2 field:'
                print >> self.logFile, self.dbg.hex_dump(
                    map(lambda x: chr(x), packetData))
                return

            x = buffer.nextDword()
            #print >>self.logFile, str.format('x = {0}', x)

            y = buffer.nextDword()
            #print >>self.logFile, str.format('y = {0}', y)

            rot = buffer.nextDword()
            #print >>self.logFile, str.format('rot = {0}', rot)

            unk3 = buffer.nextDword(ByteBuffer.LITTLE_ENDIAN)
            #print >>self.logFile, str.format('unk3 = {0}', unk3)

            unk4 = buffer.nextDword()
            #print >>self.logFile, str.format('unk4 = {0}', unk4)

            if unk3 >> 2 != 0:
                print >> self.logFile, 'The following packet has an odd unk3 field:'
                print >> self.logFile, self.dbg.hex_dump(
                    map(lambda x: chr(x), packetData))
                buffer.nextDword()
                buffer.nextDword()

            unk5 = buffer.nextDword()
            #print >>self.logFile, str.format('unk5 = {0}', unk5)

            unk6 = buffer.nextDword()
            #print >>self.logFile, str.format('unk6 = {0}', unk6)

            unk7 = buffer.nextByte()
            #print >>self.logFile, str.format('unk7 = {0}', unk7)

            unk8 = buffer.nextDword()
            #print >>self.logFile, str.format('unk8 = {0}', unk8)

            if unk8 >= 2:
                unk8 = buffer.nextDword()

            quantity = buffer.nextByte()
            #print >>self.logFile, str.format('quantity = {0}', quantity)

            itemId = buffer.nextDword()
            print >> self.logFile, str.format('itemId = {0}', itemId)

            #remaining = buffer.getRemainingBytes()

            itemName = getItemName(itemId)
            print >> self.logFile, str.format('itemName = {0}', itemName)

            if isCurrencyItem(itemName):
                print Fore.WHITE + str.format('CUR: {0}', itemName)
                number_of_orbs += 1

                #Specified items (like gems)
                sPlayer = SoundPlayer()
                if itemId == 0xC04F5629:
                    sPlayer.start('exaltedorb.wav')
                if itemId == 0x07A992EB:
                    sPlayer.start('gemcuttersprism.wav')

                return

            actual = buffer.nextByte()
            actual = buffer.nextByte()
            actual = buffer.nextByte()
            actual = buffer.nextDword()
            itemlevel = buffer.nextDword()
            if DEBUG:
                print >> self.logFile, str.format('itemlevel = {0}', itemlevel)

            if isGemItem(itemName) and ALERT_GEMS == True:

                actual = buffer.nextByte()
                quality = int(buffer.nextDword())
                #print >>self.logFile, str.format('quality = {0}', quality)
                if quality >= 5:
                    print Fore.CYAN + str.format('GEM: {0}, quality: {1}',
                                                 itemName, quality)
                    #unique = PlaySoundUnique()
                    #unique.start()

                print >> self.logFile, '---------------------------------'
                return

            req_lvl = buffer.nextDword()
            actual = buffer.nextDword()
            actual = buffer.nextByte()
            rarity = buffer.nextDword()
            if DEBUG:
                print >> self.logFile, str.format('rarity = {0}', rarity)

            identified = buffer.nextDword()
            if DEBUG:
                print >> self.logFile, str.format('identified = {0}',
                                                  identified)

            if isMapItem(itemName) and ALERT_MAPS == True:

                actual = buffer.nextDword()
                actual = buffer.nextDword()
                actual = buffer.nextByte()

                actual = buffer.nextDword()
                actual = buffer.nextDword()
                quality = int(buffer.nextDword())
                actual = int(buffer.nextByte())
                if DEBUG:
                    print >> self.logFile, str.format('quality = {0}', quality)

                if quality == 0 and actual == 0:
                    quality = int(buffer.nextDword())
                    if DEBUG:
                        print >> self.logFile, str.format(
                            'quality new = {0}', quality)

                print Style.BRIGHT + Fore.BLUE + str.format(
                    'MAP: {0}, rarity: {1}, itemlevel: {2}, quality: {3}',
                    itemName, rarity, itemlevel, quality)

                print >> self.logFile, '---------------------------------'

                number_of_maps += 1
                return

            if isBeltItem(itemName):

                if rarity == 3:

                    print Fore.YELLOW + str.format(
                        'UNI BELT: {0}, rarity: {1}', itemName, rarity)
                    unique = PlaySoundUnique()
                    unique.start()

                    number_of_uniques += 1

                elif rarity == 2 and ALERT_RARES == True:

                    print Style.BRIGHT + Fore.YELLOW + str.format(
                        'BELT: {0}, rarity: {1}, itemlevel: {2}', itemName,
                        rarity, itemlevel)

                print >> self.logFile, '---------------------------------'

                return

            if isJewelleryItem(itemName):

                if rarity == 2 and ALERT_RARES == True:
                    print Style.BRIGHT + Fore.YELLOW + str.format(
                        'JEW: {0}, rarity: {1}', itemName, rarity)
                    number_of_rares += 1

                if (rarity == 0 or rarity == 1) and (
                        itemId == 0x29F77698
                        or itemId == 0xDE069771) and ALERT_JEW_VALUES == True:

                    _implicitmods = int(buffer.nextDword())
                    _mod = buffer.nextDword()
                    _modvalues = buffer.nextByte()
                    _modvalue = int(buffer.nextDword())

                    if _modvalue >= 13 and itemId == 0x29F77698:

                        print Fore.WHITE + str.format('JEW: {0}, Value: {1}',
                                                      itemName, _modvalue)

                    if _modvalue >= 18 and itemId == 0xDE069771:

                        print Fore.WHITE + str.format('JEW: {0}, Value: {1}',
                                                      itemName, _modvalue)

                elif rarity == 3:

                    if identified == 1 and itemId == 0x29F77698:

                        if RUN == False:
                            RUN = True
                            number_of_uniques = 0
                            number_of_rares = 0
                            number_of_orbs = 0
                            number_of_maps = 0

                            staTime = datetime.datetime.today().strftime(
                                "%Y-%m-%d %H:%M:%S")
                            startTime = str.format('{0}', staTime)

                            print Style.BRIGHT + Fore.GREEN + str.format(
                                '==== {0} ===== RUN started ===========',
                                startTime)

                            #print >>self.logFile, str.format('{0}', startTime)
                            # measure runtime later on here, get the start time

                        else:

                            RUN = False
                            stoTime = datetime.datetime.today().strftime(
                                "%Y-%m-%d %H:%M:%S")
                            stopTime = str.format('{0}', stoTime)
                            print Style.BRIGHT + Fore.GREEN + str.format(
                                '==== {0} ===== RUN stopped ===========',
                                stopTime)
                            print >> self.statFile, str.format(
                                '{0},{1},{2},{3},{4}', stopTime,
                                number_of_uniques, number_of_rares,
                                number_of_orbs, number_of_maps)

                    else:
                        print Fore.YELLOW + str.format(
                            'UNI JEW: {0}, rarity: {1}', itemName, rarity)
                        unique = PlaySoundUnique()
                        unique.start()

                        number_of_uniques += 1

                print >> self.logFile, '---------------------------------'
                return

            if isArmourItem(itemName):

                if rarity == 0:

                    if shouldNotify(itemName):
                        print Fore.WHITE + str.format('SPC: {0}', itemName)
                        # worker = PlaySoundWorker()
                        # worker.start()

                        print >> self.logFile, '---------------------------------'
                        return

                elif rarity == 2:
                    number_of_rares += 1

                if identified == 1:

                    if isShieldItem(itemName):

                        if DEBUG:
                            print >> self.logFile, str.format(
                                'identified as SHIELD', '1')

                        _implicitmod = int(buffer.nextDword())

                        if _implicitmod == 2:
                            actual = buffer.nextDword()

                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual = buffer.nextDword()

                                _impl_mod = int(buffer.nextDword())
                                if DEBUG:
                                    print >> self.logFile, str.format(
                                        'implicit mod = {0}', _impl_mod)

                                _impl_mod_values = int(buffer.nextByte())

                                for i in range(0, _impl_mod_values):
                                    # needs to be worked out
                                    _mod_value = int(buffer.nextDword())

                                _skipnext = int(buffer.nextByte())

                                if _skipnext >= 1:
                                    for i in range(0, _skipnext):
                                        actual = int(buffer.nextDword())

                        else:

                            actual = buffer.nextDword()

                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                for i in range(0, _skipnext):
                                    actual = buffer.nextDword()

                                _skipnext = int(buffer.nextByte())

                                if _skipnext >= 1:
                                    for i in range(0, _skipnext):
                                        actual = buffer.nextDword()

                    else:
                        _skipnext = int(buffer.nextDword())

                        if _skipnext >= 1:
                            actual = buffer.nextDword()

                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual = buffer.nextDword()

                                _skipnext = int(buffer.nextByte())

                                if _skipnext >= 1:
                                    actual = buffer.nextDword()
                        else:

                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                for i in range(0, _skipnext):
                                    actual = buffer.nextDword()

                    number_of_mods = int(buffer.nextDword())

                else:

                    if isShieldItem(itemName):

                        if DEBUG:
                            print >> self.logFile, str.format(
                                'identified as SHIELD', '1')

                        _implicitmod = int(buffer.nextDword())

                        if _implicitmod == 2:

                            actual = buffer.nextDword()

                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                actual = buffer.nextDword()

                                _impl_mod = int(buffer.nextDword())

                                if DEBUG:
                                    print >> self.logFile, str.format(
                                        'implicit mod = {0}', _impl_mod)

                                _impl_mod_values = int(buffer.nextByte())

                                if DEBUG:
                                    print >> self.logFile, str.format(
                                        '_impl_mod_values = {0}',
                                        _impl_mod_values)

                                if _impl_mod_values > 0:
                                    for i in range(0, _impl_mod_values):
                                        # needs to be worked out
                                        _mod_value = int(buffer.nextDword())
                                        if DEBUG:
                                            print >> self.logFile, str.format(
                                                '_mod_value = {0}', _mod_value)

                        elif _implicitmod == 1:

                            actual = buffer.nextDword()

                            _skipnext = int(buffer.nextByte())

                            if _skipnext >= 1:
                                for i in range(0, _skipnext):
                                    actual = buffer.nextDword()

                    else:

                        _implicitmods = int(buffer.nextDword())

                        if _implicitmods == 2:

                            if DEBUG:
                                print >> self.logFile, str.format(
                                    '_implicitmods = {0}', _implicitmods)

                        elif _implicitmods == 1:

                            _implicitmod = buffer.nextDword()
                            if DEBUG:
                                print >> self.logFile, str.format(
                                    '_implicitmod = {0}', _implicitmod)

                            _impl_mod_values = int(buffer.nextByte())
                            if DEBUG:
                                print >> self.logFile, str.format(
                                    '_impl_mod_values = {0}', _impl_mod_values)

                            for i in range(0, _impl_mod_values):
                                # needs to be worked out
                                _mod_value = int(buffer.nextDword())

                    number_of_mods = 0

                if DEBUG:
                    print >> self.logFile, str.format(
                        'number of explicit mods = {0}', number_of_mods)

                if number_of_mods > 6:
                    print >> self.logFile, 'The last packet had an odd number_of_mods field:'
                    print >> self.logFile, self.dbg.hex_dump(
                        map(lambda x: chr(x), packetData))

                    print >> self.logFile, '---------------------------------'
                    return

                for i in range(0, number_of_mods):
                    mod_id = buffer.nextDword()
                    if DEBUG:
                        print >> self.logFile, str.format(
                            'mod id = {0}', mod_id)
                    sub_mod_count = buffer.nextByte()
                    if sub_mod_count > 3:
                        print >> self.logFile, 'The last packet had an odd sub_mod_count field:'
                        if DEBUG:
                            print >> self.logFile, self.dbg.hex_dump(
                                map(lambda x: chr(x), packetData))

                        print >> self.logFile, '---------------------------------'
                        return

                    for ii in range(0, sub_mod_count):
                        mod_value = buffer.nextDword()
                        if sub_mod_count == 1:
                            if DEBUG:
                                print >> self.logFile, str.format(
                                    'Modifier: {0}{1}', mod_value,
                                    getModifierName(mod_id))
                        elif sub_mod_count == 2:
                            if mod_value != 0:
                                sub_mods = getModifierName(mod_id).split("/")
                                sub_mod = sub_mods[ii]
                                if DEBUG:
                                    print >> self.logFile, str.format(
                                        'Modifier: {0}{1}', mod_value, sub_mod)

                quality = buffer.nextDword()
                if DEBUG:
                    print >> self.logFile, str.format('quality = {0}', quality)
                actual = buffer.nextByte()
                sockets = int(buffer.nextDword())
                if DEBUG:
                    print >> self.logFile, str.format('sockets = {0}', sockets)

                if sockets == 0 or sockets > 6:
                    print >> self.logFile, 'The last packet had an odd sockets field:'
                    if DEBUG:
                        print >> self.logFile, self.dbg.hex_dump(
                            map(lambda x: chr(x), packetData))

                    print >> self.logFile, '---------------------------------'
                    return

                _all_color = []

                sock_color_tmp = ""
                sock_color_tmp = getSocketColor(int(buffer.nextByte()))

                actual = buffer.nextByte()
                _all_color.append(sock_color_tmp)

                for i in range(1, sockets):
                    sock_color_tmp = getSocketColor(int(buffer.nextByte()))
                    actual = buffer.nextByte()
                    _all_color.append(sock_color_tmp)

                if DEBUG:
                    print >> self.logFile, str.format('socket colors = {0}',
                                                      _all_color)

                sock_fragments = int(buffer.nextDword())

                if DEBUG:
                    print >> self.logFile, str.format('socket fragments = {0}',
                                                      sock_fragments)

                if sock_fragments > 6 or sock_fragments == 0:
                    print >> self.logFile, 'The last packet had an odd sock_fragments field:'
                    if DEBUG:
                        print >> self.logFile, self.dbg.hex_dump(
                            map(lambda x: chr(x), packetData))

                    print >> self.logFile, '---------------------------------'
                    return

                listlen = len(_all_color)

                if sock_fragments == 1:
                    if DEBUG:
                        print >> self.logFile, str.format(
                            'Fully linked = {0}', sock_fragments)
                    ii = 0
                    for i in range(1, listlen):
                        _all_color.insert(i + ii, "-")
                        ii = ii + 1

                else:
                    iii = 0
                    maxfrag = 1
                    for i in range(0, sock_fragments):
                        frag = int(buffer.nextByte())
                        if frag > 1:
                            if maxfrag < frag:
                                maxfrag = frag
                            for ii in range(1, frag):
                                _all_color.insert(ii + iii, "-")
                                iii = iii + 1
                            iii = iii + ii + 1
                        else:
                            iii = iii + 1

                socketsetup = ''.join(_all_color)

                if DEBUG:
                    print >> self.logFile, str.format('Socket Setup = {0}',
                                                      socketsetup)

                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')):

                    print Style.BRIGHT + Fore.RED + "R" + Style.BRIGHT + Fore.GREEN + "G" + Style.BRIGHT + Fore.BLUE + "B" + Style.BRIGHT + Fore.WHITE + str.format(
                        ': {0}, rarity: {1}, itemlevel: {2}', itemName, rarity,
                        itemlevel)

                msg = ""
                if sockets == 5:
                    if sock_fragments == 1:
                        msg = "5-SLOT 5-LINK"
                if sockets == 6:
                    if sock_fragments == 1:
                        msg = "6-SLOT 6-LINK"
                    elif sock_fragments == 2:
                        if maxfrag == 5:
                            msg = "6-SLOT 5-LINK"
                        else:
                            msg = "6-SLOT"
                    else:
                        msg = "6-SLOT"

                if msg != "":
                    print >> self.logFile, msg
                    print Style.BRIGHT + Fore.MAGENTA + str.format(
                        '{5}: {0}, rarity: {1}, ilvl: {2}, quality: {3}, sockets: {4}',
                        itemName, rarity, itemlevel, quality, socketsetup, msg)

                if rarity == 3:
                    print >> self.logFile, 'UNIQUE !'
                    number_of_uniques += 1

                    print Fore.YELLOW + str.format(
                        'UNI: {0}, rarity: {1}, ilvl: {2}, quality: {3}, sockets: {4}',
                        itemName, rarity, itemlevel, quality, socketsetup)
                    unique = PlaySoundUnique()
                    unique.start()

                if rarity == 2 and ALERT_RARES == True:

                    print Style.BRIGHT + Fore.YELLOW + str.format(
                        'RARE: {0}, rarity: {1}, itemlevel: {2}', itemName,
                        rarity, itemlevel)

                print >> self.logFile, '---------------------------------'
                return

            print >> self.logFile, '---------------------------------'

        except:
            pass