Пример #1
0
 def makeBuy(self, tarhwnd, myhwnd):
     tarprocGuard = helper.ProcGuard(tarhwnd)
     myprocGuard = helper.ProcGuard(myhwnd)
     
     proc = myprocGuard.proc
     tarproc = tarprocGuard.proc
     
     myid = dolScript.getPCID(proc)
     myname = dolScript.getRoleName(proc)
     tarname = dolScript.getRoleName(tarproc)
     print tarname
     
     lock = MutexGuard(mutex)
     
     dolCall.openDialog(tarproc, myid, 0x32)
     dountil(dolScript.isDialogOpen, [tarproc])
     
     l = MutexGuard(msgBoxMutex)
     
     win32gui.ShowWindow(tarhwnd, win32con.SW_RESTORE)
     win32gui.SetActiveWindow(tarhwnd)
     win32gui.SetForegroundWindow(tarhwnd)
     msgBox(tarname, '請購買 [' + myname + '] 的露天……')
     win32gui.ShowWindow(tarhwnd, win32con.SW_MINIMIZE)
     dowhile(dolScript.isDialogOpen, [proc])
     print 'makeBuy end'
Пример #2
0
def gotoCity(proc, cityid, wayPointList):
    
    def isClose(x1, y1):
        x, y = dolScript.getSeaPos(proc)
        return dolLib.distance(x1, y1, x, y) <= 10
    
    print 'Go to City %x' % (cityid)

    for x1, y1 in wayPointList:
        x, y = dolScript.getSeaPos(proc)
        log('Going to %d, %d' % (x1, y1))
        log('My pos = %d, %d' % (x, y))
        while(dolLib.distance(x1, y1, x, y) > 5):
            log('---Going to %d, %d' % (x1, y1))
            dolLib.turnPos(proc, x1, y1)
            time.sleep(2)
            
            state = dolScript.getSailState(proc)
            if(state < 4):
                dolCall.sail(proc, 4)
                time.sleep(2)
            
            if(not isClose(x1, y1) and not dolScript.isSceneChange(proc) and not dolScript.isAutoSail(proc) and dolScript.getHP(proc) >= 10):
                dolCall.custom_safe(proc, 1)
                time.sleep(2)
                
            sCount, sList = dolScript.getSkill(proc) 
    
            if(not isClose(x1, y1) and not dolScript.isSceneChange(proc) and sCount != 3 and 75 not in sList): #75 == 警戒
                log("发动警戒技能") 
                dolCall.custom_safe(proc, 3)#f3 警戒
                time.sleep(2)
            
            
            
            if(not isClose(x1, y1) and dolScript.getHPRatio(proc) < 0.4):
                if(not dolScript.isOnline(proc)):
                    break
                    
                hp1 = dolScript.getHP(proc)
                log("要补行动力, 行动力 = %d" % (hp1))
                dountil(dolScript.isNormal, [proc])
                
                dolCall.custom_safe(proc, 7) #f7 要设置为料理
                time.sleep(2)
                hp2 = dolScript.getHP(proc)
                log("吃了一个料理, 行动力 = %d" % (hp2))
                if(hp1 == hp2):
                    time.sleep(5)
                time.sleep(0.2)
            x, y = dolScript.getSeaPos(proc)
            print "Now in (%d, %d), distance to (%d, %d) is %d" % (x,y, x1, y1, dolLib.distance(x1, y1, x, y))
    dolCall.sail(proc, 0)
    dolCall.enterDoor(proc, cityid)
            
        
    
Пример #3
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'
Пример #4
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)
Пример #5
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)
Пример #6
0
 def searchGoods(self):
     helper = ProcessHelper()
     hwnd = helper.getHwndByProc(self.proc)
     
     
     
     bossid = dolScript.getTabId(self.proc)
     
     if(bossid == 0):
         print "no tab!"
         return
     
     addr = getInt(self.proc, FIRM_BASE_ADDR)
     if(addr == 0):
         dolCall.openDialog(self.proc, bossid, 0x7b)
         
         dountil(waitLoad, [self.proc])
         addr = getInt(self.proc, FIRM_BASE_ADDR)
         
     print "%x" % (addr)
     if(addr > 0):
         
         rank = getByte(self.proc, addr + 0x5e4)
         nameList = self.getFirmNameList()
         nowrank = rank
         if(nowrank == rank):
             self.writer.write('ID', 'name', 'price', 'count', 'firm', 'firmseq')
             while(nowrank == rank and nowrank < 250):
                 
                 print "-----------search [%s]------------- (%d/%d)" % (nameList[rank], nowrank, len(nameList))
                 self.currentFirmSeq = nowrank
                 
                 
                 num4 = getInt(self.proc, FIRM_BASE_ADDR) # 当前窗口为商会一览 或者 商会店铺, 这个值会不同
                 Mouse('LClick', hwnd, 0x248, 0x179) #点击"商会店铺"按钮
                 time.sleep(2)
                 num5 = getInt(self.proc, FIRM_BASE_ADDR + 4)
                 
                 waitCount = 0
                 while(num4 == getInt(self.proc, FIRM_BASE_ADDR) or num5 == 0):
                     time.sleep(0.5)
                     num5 = getInt(self.proc, FIRM_BASE_ADDR + 4)
                     if (waitCount > 15):
                         break
                     waitCount += 1
                 
                 
                 
                 if(waitCount < 10 or num4 != getInt(self.proc, FIRM_BASE_ADDR)):
                     #readinfo
                     infoList = self.getGoodsInfo()
                     
                     
                     
                     num4 = getInt(self.proc, FIRM_BASE_ADDR)
                     Key('KeyClick', hwnd, 0x1b) #ESC
                     
                     waitCount = 0
                     while(num4 == getInt(self.proc, FIRM_BASE_ADDR)):
                         time.sleep(0.5)
                         waitCount += 1
                     
                 Key('KeyClick', hwnd, 40) #down arrow
                 time.sleep(0.5)
                 
                 while(getByte(self.proc, addr + 0x6ac) != rank + 1):
                     if(getByte(self.proc, addr + 0x6ac) == 0):
                         return
                     time.sleep(0.5)
                 
                 rank = getByte(self.proc, addr + 0x5e4)     
                     
                 nowrank += 1
                 
                 #print rank
                 #print nowrank
     else:
         print "Dialog Not opened"