Example #1
0
def kaitu(proc, dtaClass):
    hlper = helper.ProcessHelper()
    hwnd = hlper.getHwndByProc(proc)
    assert isinstance(dtaClass, kaituDta.kaituDtaBase)
    
    def __printLastLog(depth = 5):
        print 'last log'
        logList = dolScript.readLog(proc, depth)
        for log in logList:
            print log
    
    def __stopSkill():
        while(True):
            sc, _ = dolScript.getSkill(proc)
            if(sc != 0):
                dll.Mouse('LClick', hwnd, 780, 290)
                time.sleep(0.5)
                dll.Key('KeyClick', hwnd, win32con.VK_RETURN)
                time.sleep(1)
            else:
                break
    
    while(True):
        while(True):
            x, y = dtaClass.kaiPos
            dolCall.walk(proc, x, y)
            
            while(dolScript.getHP(proc) < 20):
                dolCall.custom_safe(proc, 7)
                time.sleep(1)
            
            dolCall.custom_safe(proc, 4)
            
            statAddr = 0x00B72FB8
            
            statArr = []
            
            while(not dolScript.inLog(proc, '點經驗。', 2) and not dolScript.inLog(proc, '冒險等級上升到', 2) and not dolScript.inLog(proc, '冒險經驗值達到了', 2)):
                
                sub = '這附近好像有什麼東西'
                if(dolScript.inLog(proc, sub, 2)):
                    print '好像有什麼東西, 繼續'
                    dolCall.custom_safe(proc, 4)
                    time.sleep(2)
                if(dolScript.inLog(proc, '未能發現任何物品')):
                    if(not dolScript.inLog(proc, '開鎖失敗了')):    
                        __printLastLog()
                        print "can't find any item"
                        __stopSkill()
                        beep('', '没图了!')
                        
                        return    
                    else:
                        dolCall.custom_safe(proc, 4)
                        
                time.sleep(0.2)
                
                print 'wait ... %d' % (dolScript.getByte(proc, statAddr))
                statArr.append(dolScript.getByte(proc, statAddr))
            print 'final wait ... %d' % (dolScript.getByte(proc, statAddr))
            statArr.append(dolScript.getByte(proc, statAddr))
            
            logger = TextLogger('kaituLog.txt')
            logger.log(repr(statArr))
            
            if(dolScript.inLog(proc, '未能發現任何物品')):
                if(not dolScript.inLog(proc, '開鎖失敗了')):  
                    __printLastLog() 
                    print "can't find any item"
                    __stopSkill() 
                    beep('', '没图了!')
                    return
                else:
                    continue
            __printLastLog()
            break
        
        __stopSkill()
            
        
        x, y = dtaClass.churchOutPos
        dolCall.walk(proc, x, y)
        dolCall.enterDoor(proc, dtaClass.churchOutID)
        
        x, y = dtaClass.reportEnterPos
        dolCall.walk(proc, x, y)
        dolCall.enterDoor(proc, dtaClass.reportEnterID)
        
        x, y = dtaClass.reportPos
        dolCall.walk(proc, x, y)
        bossid = dtaClass.reportNPCID
        
        while(not dolScript.isDialogOpen(proc)):
            dolCall.openDialog(proc, bossid, 0x65)
            time.sleep(0.5)
        dountil(dolScript.isDialogOpen, [proc])
        
        while(dolScript.getReportSeq(proc) != dtaClass.subSeq):
            dll.Key('KeyClick', hwnd, win32con.VK_DOWN)
            time.sleep(0.5)
        
        
        dll.Key('KeyClick', hwnd, win32con.VK_RETURN)
        time.sleep(1)
        while(not dolScript.inLog(proc, '已經做了報告。', 2) and not dolScript.inLog(proc, '點聲望', 2) ):
            
            dll.Key('KeyClick', hwnd, win32con.VK_RETURN)
            time.sleep(1)
        
        dolCall.enterDoor(proc, dtaClass.reportOutID)
        x, y = dtaClass.churchPos
        dolCall.walk(proc, x, y)
        dolCall.enterDoor(proc, dtaClass.churchEnterID)
Example #2
0
 def read(self, hwnd, proc, isFellow = False):
     print 'read'
     myname = dolScript.getRoleName(proc)
     print '[%s](%d) start to read. (isFellow = %s)' % (myname, hwnd, isFellow)
     statusAddr = 0xAFD700
     
     def __markOK(_hwnd):
         procGuard = helper.ProcGuard(_hwnd)
         dolCall.writeMem(procGuard.proc, statusAddr, dolCall.c_uint(0))
     
     def __whenRead():
         log('讀到圖')
         bossid = dolScript.getPCID(proc)
         dolCall.openDialog(proc, bossid, 0x20)
         myname = dolScript.getRoleName(proc)
         dountil(dolScript.isDialogOpen, [proc])
         
         l = MutexGuard(msgBoxMutex)
         msgBox(myname, '读到图。准备弹出窗口……')
         
         win32gui.ShowWindow(hwnd, win32con.SW_RESTORE)
         win32gui.SetActiveWindow(hwnd)
         
         win32gui.SetForegroundWindow(hwnd)
         msgBox(myname, '请在摆好露天后点击确定。(将会有购买窗口弹出……)')
         dowhile(dolScript.isDialogOpen, [proc])
         win32gui.ShowWindow(hwnd, win32con.SW_MINIMIZE)
         
         
         tarhwnd = self.serHwnd
         
         self.makeBuy(tarhwnd, hwnd)
         print 'one read loop end'
     
     x, y = self.cityRead.toReadPos
     if(dolScript.getLandFollow(proc) == 0):
         dolCall.walk(proc, x, y)
     
     if(not isFellow):
         for _hwnd in self.fellowList:
             __markOK(_hwnd)
         self.makeAllDo(self.read, [True], hwndPos = 0, procPos = 1)
         self.nextDoFunc = self.lib2Dock
         
         self.nextDoPara = []
     
     
     
     
     while(True):
         while(not dolScript.isDialogOpen(proc)):
             dolCall.openDialog(proc, self.cityRead.manID, 0x83)
             time.sleep(0.5)
         dountil(dolScript.isDialogOpen, [proc])
         
         while(dolScript.getToRead(proc) != 5): #5是美术
             print '[%s](%d) press left arrow' % (myname, hwnd)
             dll.Key('KeyClick', hwnd, win32con.VK_LEFT)
             time.sleep(1)
         
         print 'Click begin'
         print "-------%s %s-------" % (dolScript.getInt(proc, dolCall.CALLADDR.DIALOG) != 0, not dolScript.isReading(proc))
         while(dolScript.getInt(proc, dolCall.CALLADDR.DIALOG) != 0 and not dolScript.isReading(proc)):
             print "%s %s" % (dolScript.getInt(proc, dolCall.CALLADDR.DIALOG) != 0, not dolScript.isReading(proc))
             
             dll.Mouse('LClick', hwnd, 547, 240)
             time.sleep(2)
         print 'Click end'
             
         #547, 240
         
         while(True):
             print '[' + myname + ('] reading... (Money = %d)' % (dolScript.getMoney(proc)))
             if(dolScript.inLog(proc, '頭腦疲勞', 3)):
                 log('疲勞了...')
                 startTime = time.time()
                 if(isFellow):
                     procGuard = helper.ProcGuard(hwnd)
                     print '[%s] 疲劳了, 写内存' % (myname)
                     dolCall.writeMem(procGuard.proc, statusAddr, dolCall.c_uint(1))
                 else:
                     okFellowDict = {}
                     if(len(self.fellowList) > 0):
                         while(True):
                             if(len(okFellowDict) == len(self.fellowList)):
                                 #timeout一分钟也走人
                                 log('全部疲倦了,走人')
                                 return
                             
                             for _hwnd in self.fellowList:
                                 if(okFellowDict.has_key(_hwnd)):
                                     continue
                                 procGuard = helper.ProcGuard(_hwnd)
                                 if(not dolScript.isOnline(procGuard.proc)):
                                     okFellowDict[_hwnd] = -1
                                 
                                 
                                 if(dolScript.getInt(procGuard.proc, statusAddr) != 0):
                                     okFellowDict[_hwnd] = 1
                             time.sleep(0.5) 
                 
                 return
             
             
             if(dolScript.inLog(proc, self.readMsg, 3)):
                 __whenRead()
                 break
                 
             time.sleep(0.2)