示例#1
0
 def get_square_near_point(self, nowPos:CoordiPoint, v):
     center = self.get_center_point()
     if not AreaFighting.pos_in_area(nowPos, self.area_pos):
         return CoordiPoint(center.x, center.y)
     all = self.get_square_all_points(v)
     near = NvBase().getNearstPoint(nowPos, all)
     return CoordiPoint(near.x, near.y)
示例#2
0
    def get_next_pos(self):
        if self.now_pos is None:
            raise Exception("当前路点未确定,请先使用get_nearst_pos获取当前路点")

        for index in range(len(self.finder_path)):
            if self.now_pos.x == self.finder_path[index][
                    0] and self.now_pos.y == self.finder_path[index][1]:
                if index + 1 >= len(self.finder_path):
                    return CoordiPoint(self.finder_path[0][0],
                                       self.finder_path[0][1])
                return CoordiPoint(self.finder_path[index + 1][0],
                                   self.finder_path[index + 1][1])
示例#3
0
 def pos_in_area(pos: CoordiPoint, area):
     A = CoordiPoint(area["leftTop"][0], area["leftTop"][1])
     B = CoordiPoint(area["rightTop"][0], area["rightTop"][1])
     C = CoordiPoint(area["rightBottom"][0], area["rightBottom"][1])
     D = CoordiPoint(area["leftBottom"][0], area["leftBottom"][1])
     a = (B.x - A.x) * (pos.y - A.y) - (B.y - A.y) * (pos.x - A.x)
     b = (C.x - B.x) * (pos.y - B.y) - (C.y - B.y) * (pos.x - B.x)
     c = (D.x - C.x) * (pos.y - C.y) - (D.y - C.y) * (pos.x - C.x)
     d = (A.x - D.x) * (pos.y - D.y) - (A.y - D.y) * (pos.x - D.x)
     if (a > 0 and b > 0 and c > 0 and d > 0) or (a < 0 and b < 0 and c < 0
                                                  and d < 0):
         return True
     return False
示例#4
0
    def walk_to_last_point(self, tp=None):
        if self.player.getStatus()["dead"] == 1:
            return
        if os.path.exists(SysConfig.record_path + "DynamicConfig.py"):
            from run.record.path_data.DynamicConfig import DynamicConfig
        else:
            print("没有动态配置文件")
            os._exit(0)

        last_point = DynamicConfig.repair_path[::-1][0]  # repair_path的最后一个点

        if self.type == 'p':
            from lib.navigation.PathFinding import Pathfinding
            finder = Pathfinding(control=self.control, player=self.player)
            precision = 0.3
            p = tp if tp is not None else CoordiPoint(last_point[0],
                                                      last_point[1])
        else:
            finder = WorldPathFinding(control=self.control, player=self.player)
            precision = 5
            p = tp if tp is not None else WorldPoint(last_point[2],
                                                     last_point[3])

        if finder.get_distance_off_tow_pos(finder.getNowPos(), p) > precision:
            finder.walk(p,
                        move_type=self.move_type,
                        combat_exit=False,
                        checkMount=self.checkMount)
示例#5
0
 def get_circle_near_point(self, nowPos:CoordiPoint, d, r):
     center = self.get_center_point()
     if not AreaFighting.pos_in_area(nowPos, self.area_pos):
         return center
     all = self.get_circle_all_points(d, r)
     near = NvBase().getNearstPoint(nowPos, all)
     return CoordiPoint(near.x, near.y)
示例#6
0
 def to_repair_run(self):
     if os.path.exists(SysConfig.record_path + "DynamicConfig.py"):
         from run.record.path_data.DynamicConfig import DynamicConfig
         if DynamicConfig.repair_path == 0 or DynamicConfig.repair_path == []:
             return False
     else:
         print("没有动态配置文件")
         os._exit(0)
     print(
         "to cap #################################################################qr"
     )
     all_pos = []
     reverse = DynamicConfig.repair_path[::
                                         -1]  # 因为录制的时候是从修理点到区域的,现在回去修理所以需要反转
     for i in reverse:
         if self.type == 'p':
             point = CoordiPoint(float(i[0]), float(i[1]))
         else:
             point = WorldPoint(float(i[2]), float(i[3]))
         all_pos.append(point)
     run_ret = self.inner_run(all_pos)
     if not run_ret:
         return False
     print("路点已完成")
     print("路点已完成: " + str(datetime.datetime.now()),
           file=self.hander_reapir)
     #self.control.driver.tap_str(" ")
     #sendmail(UserConfig.email, self.playerName + " arrive repair point", "", img=self.screenshot("arraive_repair_point"))
     return True
示例#7
0
 def get_next_point(self, nowPos, cut):
     from lib.navigation.AreaFighting import AreaFighting
     from lib.navigation.NvBase import NvBase
     if not AreaFighting.pos_in_area(nowPos, self.area):
         return False
     all = self.divide_line(cut)
     near = NvBase().getNearstPoint(nowPos, all)
     return CoordiPoint(near.x, near.y)
示例#8
0
 def __get_center_of_area(self):
     left_top = self.area_pos["leftTop"]
     right_bottom = self.area_pos["rightBottom"]
     center = [(left_top[0] + right_bottom[0]) / 2,
               (left_top[1] + right_bottom[1]) / 2]
     print("center:")
     print(center)
     return CoordiPoint(center[0], center[1])
示例#9
0
 def get_nearst_pos(self):
     start_distance = float("inf")
     for tmp in self.finder_path:
         pos = CoordiPoint(x=tmp[0], y=tmp[1])
         now_distance = self.get_distance_off_tow_pos(
             pos, self.player.getCoordi())
         if now_distance < start_distance:
             near_pos = pos
             start_distance = now_distance
     self.now_pos = near_pos
     return near_pos  # 别担心,这里肯定能找到,难道还有比无穷大更大的么!!!
示例#10
0
 def get_coordi_from_file(filename):
     fp = open(SysConfig.record_path + filename, 'r')
     content = fp.read()
     fp.close()
     array = content.split("\n")
     coords = []
     for i in array:
         if i == "":
             continue
         pos = i.split(",")  # 将坐标转换成数组
         coords.append(CoordiPoint(float(pos[0]), float(pos[1])))
     return coords
示例#11
0
    def grave_run(self):
        corpseCoordi = self.player.getCropsCoordi()
        if corpseCoordi.x == 0 or corpseCoordi.y == 0:
            sendmail(UserConfig.email, self.player.getName() + "can't get corpse pos", "", img=self.screenshot("cant_get_corpse_pos"))
            os._exit(0)

        grave_path = []
        if os.path.exists(SysConfig.record_path + "DynamicConfig.py"):
            from run.record.path_data.DynamicConfig import DynamicConfig
            grave_path = DynamicConfig.grave_path

        all_points = []
        if grave_path == 0 or grave_path == []:
            print("没有路点配置,直接跑向尸体")
            print("没有路点配置,直接跑向尸体", file=self.hander_grave)
            all_points = [corpseCoordi]
        else:
            for i in grave_path:
                #pos = i.split(",")  # 将坐标转换成数组
                all_points.append(CoordiPoint(float(i[0]), float(i[1])))
            all_points = self.reduceAllPoints(all_points)

        for coordi in all_points:
            if self.player.getStatus()["dead"] == 0:
                break
            print("grave run target pos:")
            print("grave run target pos:", file=self.hander_grave)
            print(coordi.toString())

            # 先跑到区域中点
            self.walk(
                coordi,
                move_type=self.move_type,
                alive_exit=True, # 一旦复活就停止寻路
                combat_exit=True, # 这里需要进入战斗退出,因为复活的时候可能路点还没有走完
                checkMount=False
            )

        if self.player.getStatus()["dead"] == 0:
            print("路点没有走完就复活,666")
            print("路点没有走完就复活,666", file=self.hander_grave)
            sendmail(UserConfig.email, self.player.getName() + "resurrected not walk all points", "", img=self.screenshot("resurrected"))
            return True

        print("路点已完成,即将走向尸体坐标")
        print("路点已完成,即将走向尸体坐标", file=self.hander_grave)
        self.control.driver.tap_str(" ")
        print(self.player.getCoordi().toString(), corpseCoordi.toString())
        while self.player.getStatus()["dead"] == 1:
            self.walk(corpseCoordi, self.move_type,combat_exit=True,alive_exit=True) # 只要是复活了或者进入战斗了,就退出寻路
        sendmail(UserConfig.email, self.player.getName() + "resurrected", "", img=self.screenshot("resurrected"))
示例#12
0
 def get_circle_all_points(self, d, r):
     center = self.get_center_point()
     n = 0
     ret = []
     done = False
     while not done:
         while n < 2 * math.pi:
             x = center.x + r * math.cos(n)
             y = center.y - r * math.sin(n)
             p = CoordiPoint(x, y)
             if not AreaFighting.pos_in_area(p, self.area_pos):
                 return ret
             ret.append(p)
             n = n + d / r
         n = 0
         r = r + r
     return ret
示例#13
0
    def to_area_run(self):
        if os.path.exists(SysConfig.record_path + "DynamicConfig.py"):
            from run.record.path_data.DynamicConfig import DynamicConfig
        else:
            print("没有动态配置文件")
            os._exit(0)

        all_pos = []
        for i in DynamicConfig.repair_path:
            if self.type == 'p':
                point = CoordiPoint(float(i[0]), float(i[1]))
            else:
                point = WorldPoint(float(i[2]), float(i[3]))
            all_pos.append(point)
        run_ret = self.inner_run(all_pos)
        if not run_ret:
            return False
        print("路点已完成,已到区域")
        print("路点已完成,已到区域: " + str(datetime.datetime.now()),
              file=self.hander_reapir)
        #self.control.driver.tap_str(" ")
        #sendmail(UserConfig.email, self.playerName + " arrive area point", "", img=self.screenshot("arraive_area_point"))
        return True
示例#14
0
 def get_square_all_points(self, v):
     center = self.get_center_point()
     x = center.x
     y = center.y
     tmp = 1
     ret = []
     done = False
     while not done:
         j = 0
         k = v
         for t in range(2):
             for i in range(tmp):
                 x = x + j
                 y = y + k
                 p = CoordiPoint(x, y)
                 if not AreaFighting.pos_in_area(p, self.area_pos):
                     return ret
                 ret.append(p)
             j = v
             k = 0
         tmp = tmp + 1
         v = v * -1
     return ret
示例#15
0
文件: Party.py 项目: sadnecc/pb
 def getCropsCoordi(self):
     xPoint = PixelData.getPointByIndex(self.rang['start'] + 2)
     yPoint = PixelData.getPointByIndex(self.rang['start'] + 3)
     x = xPoint.getFloat(10000)
     y = yPoint.getFloat(10000)
     return CoordiPoint(x, y)
示例#16
0
 def get_center_point(self):
     left_top = self.area_pos["leftTop"]
     right_bottom = self.area_pos["rightBottom"]
     center = [(left_top[0] + right_bottom[0]) / 2, (left_top[1] + right_bottom[1]) / 2]
     return CoordiPoint(center[0], center[1])
示例#17
0
 def getCropsCoordi(self):
     xPoint = PixelData.getPointByIndex(SysConfig.pixelIndex["xCorpse"])
     yPoint = PixelData.getPointByIndex(SysConfig.pixelIndex["yCorpse"])
     x = xPoint.getFloat(10000)
     y = yPoint.getFloat(10000)
     return CoordiPoint(x, y)