i just moved on from the level before this and I started of really well and when I did the cleave attack to the ogres they all get knocked out but one and I fail it somehow.
# You are trapped. Don't move, it'll be painful.
# This function checks if the enemy is in your attack range.
distance = hero.distanceTo(enemy)
# Almost all swords have attack range of 3.
if distance <= 3:
# Attack ogres only when they're within reach.
# Find the nearest enemy and store it in a variable.
# Call inAttackRange(enemy), with the enemy as the argument
# and save the result in the variable canAttack.
# If the result stored in canAttack is True, then attack!
is this what your supposed to do? Try to read the comments carefully.
how do i store the nearest ogre in an variable then?
i will reply to yall tommorow i need to go do something but thanks
Mod edit: please do not post solutions: it is against the purpose of this forum. Thank you.
you have to find the enemy frist!
Uhh do you need help? If not please do not post solutions or post in dead topics unless you have something to add to them and don’t post in them if your not asking for help. And I’m assuming its a solution cause the code works for me.
Hi @James_Pfiffner, as @Eric_Tang said, please do not post solutions to levels, as per the rules of the forum.
(see: Welcome to CodeCombat Discourse Forums!)
The reason for this is that the forum is a place to learn how to be a better coder, and to overcome problems with the help and guidance of the other forum members. Simply copying and pasting someone else’s code just so that you can move on in CodeCombat is a waste of time: you’re cheating yourself out of a valuable learning experience.
Don’t worry though, you’re not in trouble , we just have to stick to the rules, because they’re there for good reason.
sorry, I am new here, I will know that in the future. ( I read the Welcome to CodeCombat Discourse Forums!