Cloudrip Treasure Pls Help (Level 5)

A def collect function is really what you need. Your code doesn’t have a problem, you just need to improve your strategy.

2 Likes

try comparing 2 coins and finding the most valuble one

def findStrongestEnemy():
    strongest = None
    strongestHealth = 0
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy.health > strongestHealth:
            strongestHealth = enemy.health
            strongest = enemy
    return strongest
def collectCoins():
    
    pass
def onSpawn():
    while True:
        pet.moveXY(76, 107)
        pet.shapeShift()
        
def collect():
    peasants = hero.findByType("peasant")
    items = hero.findItems()
    far = None
    farDist = 0
    maxValue = 0
    bestItem = None
    for item in items:
        for peasant in peasants:
            d = peasant.distanceTo(item)
            if item.value > farDist:
                far = item.pos
                farDist = item.value
            if item.value / d > maxValue:
                maxValue = item.value / d
                bestItem = item
    
    for peasant in peasants:
        if bestItem and peasant.distanceTo(bestItem)<20:
            if peasant and peasant.team == hero.team:
                hero.command(peasant, "move", bestItem.pos)
        else:
            item = peasant.findNearestItem()
            if item:
                hero.command(peasant, "move", item.pos)

hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    burls = hero.findByType("burl")
    undeads = hero.findByType("skeleton")
    collect()
    
    for burl in burls:
        if burl and hero.canCast("sacrifice", burl):
            hero.cast("sacrifice", burl, hero)
    if enemy:
        if hero.canCast("devour", enemy):
            hero.cast("devour",enemy)
        if hero.canCast("poison-cloud", findStrongestEnemy()):
            hero.cast("poison-cloud", enemy)
        if hero.canCast("chain-lightning", findStrongestEnemy()):
            hero.cast("chain-lightning", enemy)
        if hero.canCast("drain-life", findStrongestEnemy()):
            hero.cast("drain-life", enemy)
        if hero.canCast("fear", findStrongestEnemy()):
            hero.cast("fear", enemy)
        else:
            hero.attack(enemy)
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
    for dead in hero.findCorpses():
        if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
            hero.cast("raise-dead")
        else:
            if dead and hero.canCast("raise-dead"):
                hero.move(dead.pos)
                hero.cast("raise-dead")

Now my hero dies:


But 117 gold

And how can a devour() do?

it does decent dmg :grin: btw summon soldiers and sacrifice the to gain as much hp and defence as possible

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.