please help if you know how to do this level
enemy=hero.findNearestEnemy()
if hero.distanceTo(enemy) == 4:
if self.isReady("cleave"):
self.cleave(enemy)
else:
self.attack(enemy)
please help if you know how to do this level
enemy=hero.findNearestEnemy()
if hero.distanceTo(enemy) == 4:
if self.isReady("cleave"):
self.cleave(enemy)
else:
self.attack(enemy)
Have you tried using flags? It’s also about strategy, not just the code.
okay i’ll try that.
for some reason my hero will not move??
flag=hero.findFlag("green")
if flag:
hero.pickUpFlag()
enemy=hero.findNearestEnemy()
if enemy:
if self.isReady("power-up"):
self.powerUp()
else:
self.attack(enemy)
oh wait i was using progamation I
now my hero just keeps on diying ???
Put that code into a while True loop to make it check every frame
Okay i tried that but now my hero keeps on dying.???
Ok, it depends on your strategy. This level has many many solutions, so it depends on your strategy whether you manage to win or not.
then what strategy should i use depending on my gear
Read this post and develop a strategy. Start writing your code. If the code fails, post it here and we’ll help you with it. No one is going to tell you how to develop a strategy. That’s up to you.
Be sure to read all you can about this level for some hints on how you want your strategy to work.
thanks MunkeyShynes but here’s my code
while True:
flag=hero.findFlag("green")
if flag:
hero.moveXY(flag.pos.x, flag.pos.y)
enemy=hero.findNearestEnemy()
if enemy:
if hero.isReady("bash"):
hero.bash(enemy)
if hero.isReady("power-up"):
hero.powerUp()
else:
hero.attack(enemy)
hero.findNearestEnemy()
if enemy.type=="yak":
hero.say("leave me alone")
You don’t have any code to pick up the flag. Click on the methods in the middle of the game screen to see how to properly use them. Also, always remember that any time you use hero.say, this takes a whole second of time. Often this time can be costly if you’re being attacked. Also, just a suggestion but try if enemy.type != "yak":
for attacking enemies. That way, you won’t attack yaks.