[Adventurer] The One Wizard


#62

get wrecked. (20 argh.)


#63

@Chaboi_3000 why must you do this to me :sob:


#64

I really love this level. It took me quite a while to get all the bonus goals but I finally did it. I was over complicating it in my code so I restarted and it was a breeze. The catapult did catch me off guard the first time but after knowing about it a small addition to my code and no problem.


#65

Hello! This was a fun level to figure out. However, there’s one quirk in my code that’s bothering me. I designated the left button for the Scout unit since my hero otherwise can’t defeat it. But then the next time a scout unit appears, my hero insists on running against the left button instead of using other spells, even though the button doesn’t work again. How do I fix this so my wizard at least tries to defeat the second scout? I tried moving down the relevant code into the elif chain but it doesn’t seem to change things.

By the way, I saw the hero.health bit in this thread but I don’t recall learning about it in the first two free campaigns. When does it appear?

My code
while True:
    enemy = hero.findNearestEnemy()
    
    if enemy:
        if hero.canCast("chain-lightning") and hero.distanceTo(enemy) < 30:
            hero.cast("chain-lightning", enemy)
        elif hero.canCast("lightning-bolt"):
            hero.cast("lightning-bolt", enemy)
        elif enemy.type == "scout" or enemy.type == "catapult":
            hero.moveXY(5, 36)
        else:
            hero.attack(enemy)
    elif hero.canCast("regen") and hero.health < 75:
        hero.cast("regen", hero)

#66

create a variable. Call it “triggered” or something. triggered = False in the beginning. Then, when you use the button, set triggered = True. Then change elif enemy.type == “scout” or enemy.type == “catapult” to elif (enemy.type == “scout” or enemy.type == “catapult”) and triggered = False:


#67

Thanks! I’ll try it out next time I log into CodeCombat. It’s not something I’ve encountered in the campaign yet, but variables are a basic.


#68

whats the code for that? Mod edit: Please do not request solutions. The purpose of this board is to assist people with their code. Simply providing solutions is counter productive to the learning process. There are many people here willing and able to assist you with your code but we do not just give the answers. Thanks.


#69

Please stop asking for code.