Cloudrip Treasure Pls Help (Level 5)

Hello, Here’s my code:

# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
hero.moveXY(111, 65)
while True:
    item = hero.findNearestItem()
    enemy = hero.findNearestEnemy()
    if enemy:
        if enemy.target is hero and not hero.canCast("invisibility", self) and not hero.hasEffect("invisibility") and hero.gold >= 25:
            hero.buildXY('decoy', hero.pos.x, hero.pos.y)
        elif enemy.target is hero and hero.canCast("invisibility", self):
            hero.cast("invisibility", self)
    else:
        item = hero.findNearestItem()
        if item:
            hero.move(item.pos)


My hero just don’t move.

Your hero doesn’t move because your code says so. You have “if enemy” and “else”. So, you will move to the item position only if there’s no enemy.

use ur peasants, command them to build decoys near the entrances. also use nalfar and lightning twig + skele or burl staff and spam sacrifice

but now my hero can’t survive:

# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!

def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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)
while True:
    enemy = hero.findNearestEnemy()
    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("poison-cloud", enemy):
            hero.cast("poison-cloud", enemy)
        hero.attack(enemy)
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
    

but if I build decoys, I can’t collect 256 gold

Here’s my gear:

Try to equip the blue fox and use the ability “shape-shift” instead of decoys (Don’t forget to write the onSpawn function so the hero can do something while the fox is being a fake-peasant).
Also, try to use all the abilities (not only the poison-cloud and summoning abilities). There are drain-life, chain-lightning, devour, fear (use it for the strongest ones only), raise-dead (really useful). Also, try to cast sacrifice not for burls only. If there’s no burl, cast sacrifice on the skeletons.

1 Like

I know this is off-topic, but notice that he has a level 66 item…

There’s a legit way to get it. However, it’s completely useless and is a waste of 3700 gems.

mk, anyways, I can’t help with this, I haven’t even completed 4

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 onSpawn():
    while True:
        pet.moveXY(76, 107)
        pet.shapeShift()
        
def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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)
    for undead in undeads:
        if undead and hero.canCast("sacrifice", undead):
            hero.cast("sacrifice", undead, hero)
    if enemy:
        if hero.canCast("devour", findStrongestEnemy()):
            hero.cast("devour",findStrongestEnemy())
        elif hero.canCast("poison-cloud", findStrongestEnemy()):
            hero.cast("poison-cloud", findStrongestEnemy())
        elif hero.canCast("chain-lightning", findStrongestEnemy()):
            hero.cast("chain-lightning", findStrongestEnemy())
        elif hero.canCast("drain-life", findStrongestEnemy()):
            hero.cast("drain-life", findStrongestEnemy())
        elif hero.canCast("fear", findStrongestEnemy()):
            hero.cast("fear", findStrongestEnemy())
        hero.attack(findStrongestEnemy())
    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")
                

did you know… that collect 256 gold means collect 256 gold TOTAL that means as long as you have collected 256 gold (u can spend some) u pass the level.

as u see…

2 Likes

For this reason, you might want to invest some time into a more robust collect() function.

Can you give me some examples?

I will DM my code. It’s in JavaScript, so you might need to change some stuff.

# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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)
while True:
    enemy = hero.findNearestEnemy()
    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)
        elif hero.canCast("poison-cloud", enemy):
            hero.cast("poison-cloud", enemy)
        elif hero.canCast("chain-lightning", enemy):
            hero.cast("chain-lightning", enemy)
        elif hero.canCast("drain-life", enemy):
            hero.cast("drain-life", enemy)
        elif hero.canCast("fear", enemy):
            hero.cast("fear", enemy)
        elif enemy.target == hero and hero.isReady("shape-shift"):
            pet.shapeShift()
            
        hero.attack(enemy)
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
    
'''
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 onSpawn():
    while True:
        pet.moveXY(76, 107)
        pet.shapeShift()
        
def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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 undead in undeads:
        if undead and hero.canCast("sacrifice", undead):
            hero.cast("sacrifice", undead, hero)
    for burl in burls:
        if burl and hero.canCast("sacrifice", burl):
            hero.cast("sacrifice", burl, hero)
    
    
    if enemy:
        if hero.canCast("devour", findStrongestEnemy()):
            hero.cast("devour",findStrongestEnemy())
        elif hero.canCast("poison-cloud", findStrongestEnemy()):
            hero.cast("poison-cloud", findStrongestEnemy())
        elif hero.canCast("chain-lightning", findStrongestEnemy()):
            hero.cast("chain-lightning", findStrongestEnemy())
        elif hero.canCast("drain-life", findStrongestEnemy()):
            hero.cast("drain-life", findStrongestEnemy())
        elif hero.canCast("fear", findStrongestEnemy()):
            hero.cast("fear", findStrongestEnemy())
        hero.attack(findStrongestEnemy())
    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")
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if hero.gold >= 25 and enemy.target == hero or enemy.target == peasant and enemy:
            hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)


check if the enemy exists before checking the target

something still went wrong:

# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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)
while True:
    enemy = hero.findNearestEnemy()
    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)
        elif hero.canCast("poison-cloud", enemy):
            hero.cast("poison-cloud", enemy)
        elif hero.canCast("chain-lightning", enemy):
            hero.cast("chain-lightning", enemy)
        elif hero.canCast("drain-life", enemy):
            hero.cast("drain-life", enemy)
        elif hero.canCast("fear", enemy):
            hero.cast("fear", enemy)
        elif enemy.target == hero and hero.isReady("shape-shift"):
            pet.shapeShift()
            
        hero.attack(enemy)
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
    
'''
'''
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 onSpawn():
    while True:
        pet.moveXY(76, 107)
        pet.shapeShift()
        
def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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 undead in undeads:
        if undead and hero.canCast("sacrifice", undead):
            hero.cast("sacrifice", undead, hero)
    for burl in burls:
        if burl and hero.canCast("sacrifice", burl):
            hero.cast("sacrifice", burl, hero)
    
    
    if enemy:
        if hero.canCast("devour", findStrongestEnemy()):
            hero.cast("devour",findStrongestEnemy())
        elif hero.canCast("poison-cloud", findStrongestEnemy()):
            hero.cast("poison-cloud", findStrongestEnemy())
        elif hero.canCast("chain-lightning", findStrongestEnemy()):
            hero.cast("chain-lightning", findStrongestEnemy())
        elif hero.canCast("drain-life", findStrongestEnemy()):
            hero.cast("drain-life", findStrongestEnemy())
        elif hero.canCast("fear", findStrongestEnemy()):
            hero.cast("fear", findStrongestEnemy())
        hero.attack(findStrongestEnemy())
    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")
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if hero.gold >= 25 and  enemy:
            hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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)
while True:
    enemy = hero.findNearestEnemy()
    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)
        elif hero.canCast("poison-cloud", enemy):
            hero.cast("poison-cloud", enemy)
        elif hero.canCast("chain-lightning", enemy):
            hero.cast("chain-lightning", enemy)
        elif hero.canCast("drain-life", enemy):
            hero.cast("drain-life", enemy)
        elif hero.canCast("fear", enemy):
            hero.cast("fear", enemy)
        elif enemy.target == hero and hero.isReady("shape-shift"):
            pet.shapeShift()
            
        hero.attack(enemy)
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
    
'''
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 onSpawn():
    while True:
        pet.moveXY(76, 107)
        pet.shapeShift()
        
def collect():
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if peasant and peasant.team == hero.team:
            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 undead in undeads:
        if undead and hero.canCast("sacrifice", undead):
            hero.cast("sacrifice", undead, hero)
    for burl in burls:
        if burl and hero.canCast("sacrifice", burl):
            hero.cast("sacrifice", burl, hero)
    
    
    if enemy:
        if hero.canCast("devour", findStrongestEnemy()):
            hero.cast("devour",findStrongestEnemy())
        elif hero.canCast("poison-cloud", findStrongestEnemy()):
            hero.cast("poison-cloud", findStrongestEnemy())
        elif hero.canCast("chain-lightning", findStrongestEnemy()):
            hero.cast("chain-lightning", findStrongestEnemy())
        elif hero.canCast("drain-life", findStrongestEnemy()):
            hero.cast("drain-life", findStrongestEnemy())
        elif hero.canCast("fear", findStrongestEnemy()):
            hero.cast("fear", findStrongestEnemy())
        hero.attack(findStrongestEnemy())
    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")
    peasants = hero.findByType("peasant")
    for peasant in peasants:
        if hero.gold >= 25 and enemy and enemy.target == hero or enemy.target == peasant:
            hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)

still wrong