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