0

我一直在尝试调整这段代码以适用于我的桌面,这样我就可以在我玩的这个游戏中自动种植一些敌人。现在,代码卡在某个点上,它在某个像素处扫描 UI 以获得某种蓝色阴影。如果它是正确的阴影,则代码会继续。如果没有,它会完全停止。我不知道该怎么做,但如果有人可以看一看,我将不胜感激。下面是一些截图和代码:

此外,代码分为两部分:第一个脚本允许与游戏交互,第二个是编程自动移动,点击等。第二块很简单,不需要放在这里,也没有必要。

First Piece(主要问题在于 def is_mana_low 的 POSITION 和 COLOR 部分:

def is_mana_low(self):
        self.set_active()
        # Matches a pixel in the lower third of the mana globe
        POSITION = (79, 565)
        COLOR = (66, 13, 83)
        THRESHOLD = 10
        return not self.pixel_matches_color(POSITION, COLOR, threshold=THRESHOLD)

    def use_potion_if_needed(self):
        mana_low = self.is_mana_low()
        health_low = self.is_health_low()

        if mana_low:
            print('Mana is low, using potion')
        if health_low:
            print('Health is low, using potion')
        if mana_low or health_low:
            self.click(160, 590, delay=.2)

我的 Discord 是 APieceofString#5151,如果您想联系我以获取更多信息或更好的解释。我真的很感激这个:)

4

0 回答 0