[Adventurer] The One Wizard

Misspelling, the ultimate archenemy of coding!! :crazy_face:

1 Like

Finally got to the desert phase. Pretty stoked. Doing this all in conjunction with W3 and Free Coding Camp (and a few other resources) is extremely helpful.

“…how do I see about how many enemies are there?”
You don’t need (any) glasses to have access to some functions in any CoCo level.
So the answer for the last enemy wave will be 10 ogres and 2 catapults:

console.log('count enemies:' + hero.findEnemies().length);
// console: count enemies:12 


It’s funny I read recently for the first time the hints and noticed there is a “magic kill them all button” :-). Till then i had the third bonus being in good health but with no time left to succeed…
Ready to swap my code with anyone who has all four bonuses.

Can you guys help me, I’ve been working on this for much longer than I care to admit. For some reason, the game doesn’t register the enemy as a target and would stop reading at “enemy = hero.findNearestEnemy()”

while True:
enemy = hero.findNearestEnemy()
if enemy:
LightningSpam
#this is a defined function
elif hero.canCast(“regen”):
hero.cast(“regen”, hero)
else:
hero.moveXY(8, 43)

Hi @John_Moone, welcome to the CodeCombat Discourse.
I think what’s stopping your code is this line:

If you want to call a function you need to use brackets ().
Please could you post all your code, formatted:

And then I’ll be able to help you more.
It may also be something to do with hero.debug(), I’m not sure that’s actually a method and it may be causing the error.
Thanks
Danny

Blockquote
If you want to call a function you need to use brackets ().
Please could you post all your code, formatted:

You’re right. Sorry, I’m a complete beginner in coding (and forums). I did a little double-checking and found that I also turned enemy into a string (“enemy”) when I defined it. I’ve also removed debugging. Thanks a lot!

This is my code now, it still doesn’t solve the puzzle but I plan on coming back to this after I finish the other levels so I’m likely to redo it completely some other time.

# Defeat as many ogres as you can.
# Use 'cast' and 'canCast' for spells.

def LightningSpam(target):
    if enemy:
        if hero.canCast ("lightning-bolt"):
            hero.cast("lightning-bolt", "enemy")
        elif hero.canCast("chain-lightning"):
            hero.cast("chain-lightning","enemy")
        elif hero.canCast("Root"):
            hero.cast("Root","enemy")
    pass

 
    
while True:
    enemy = hero.findNearestEnemy()
    if enemy: 
        LightningSpam
        #this is a defined function
    elif hero.canCast("regen"):
        hero.cast("regen", hero)
    else:
        hero.moveXY(8, 43)  

Hi, did you mean to leave this line as it was:

This is the line I meant when I said you needed ().
E.g.

def attackEnemy():
    enemy = hero.findNearestEnemy()
    if enemy:
        if hero.isReady("bash", enemy):
            hero.bash(enemy)
        else:
            hero.attack(enemy)

while True:
    attackEnemy() # you need the two brackets at the end

–LightningSpam()
I hope this helps,
Danny

Hi,

not sure if anyone reading this still. But I am about to get into some programing skills, because my Network skills aren´t enough for todays world. I am also about to get into some Linux and deeper python skills, so if you guys have something where I can learn (meaning recommendations) it would be great.
I am coming here with request about the catapult.
I have built up the code for now until the catapult comes on scene and I am not sure why, but the hero does not sees him :frowning:
Can someone help me (little hint) why? Why I don´t “enemy = hero.findNearestEnemy()” catapult?
thanks guys for help.

Regards,

Tomas

Summary
catapult = "catapult"
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        if hero.isReady("chain-lightning"):
            hero.cast("chain-lightning", enemy)
        elif enemy.type == "catapult":
            hero.moveXY(9, 30)
            hero.cast("lightning-bolt", catapult)
        else:
            hero.attack(enemy)
            
    if not enemy:
        hero.cast("regen", hero)

Edit:Sorry I am too lame and cannot pass it with “tabs” :confused: dunno why

1 Like

Hi there, @Tomas_Zima! Welcome to the CodeCombat Discourse. :partying_face:
Could you post your equipment(send a screenshot of what your hero is wearing)?
Thanks. :slight_smile:

Rachel

image

Thank you for fast answer.
It is the mision with “Challenge The One Wizard”

Thanks with best regards :wink:

Hey @Tomas_Zima, please go through the link to understand the rules. Also, try finishing the discobot tutorial.

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

P.S. i have no clue about the catapult, i just spammed the lightning and regen spells.

Could you show an image of the error or when you’re hero dies/teleports?

Hi Ashmit,

sorry if i typed something Wrond.
Do you mean the “blue” page at top of the website?
I will go through and thank you for reminding.
And also thank you for your hint :smiley:

1 Like

yeah, you’re welcome, also, i think you used the chinese “” so it wont work. I’m not sure

Oh yeah, like @Ashmit_Singh said, it looks like you’re using Chinese Quotation marks, instead of the quotation marks the system recognizes…
Though we can’t be sure. Could you format your code using the </> button?

Thanks :slight_smile:

Ah I see…
I used only this => image

I am having trouble with that when the catapult appears on scene my hero does nothing (or maybe regen) but does not detect the catapult at all, or at least, it seems to me :confused:

Hm. I don’t see anything wrong with your code :thinking:

Maybe @milton.jinich, @Deadpool198, @xython, @abc and/or @Falcons118 could help, sorry :frowning:

Rachel

2 Likes

its the regen!! regen cancels all movements and actions for the time being, thats why my code only uses it when im below 50 hp

2 Likes

Hmm… to find a specific type of enemy, you would do
catapult = hero.findNearest(hero.findByType("catapult")
Just replace catapult with the type of enemy or friend you want to find.
Lydia

Hi Lydia,

it is mess in the code :slight_smile: I will burn it, it was trying to “specify” catapult at all, because I didn´t know how to specify it at all, once I “killed” it after hero “died” I knew, and forget to delete this line. But thank you for hint :wink:
I used var, because I didn´t know about if enemy.type " "

Aha, didn’t see that regen do smthin like this, I should read more prblby… :slight_smile: Thanks much, I will try to fix my code and do better next time :stuck_out_tongue: