[# This level is intended to be for advanced players. The solution should be pretty complex with a lot of moving parts. It might also be a bit of a gear check unless you use "creative" methods.
# You need to make your way to the first trial (Oasis of Marr) killing enemies along the way. When you reach it, pick all the mushrooms to trigger the trial to begin. If you survive the onslaught, make your way to the next Oasis for the second trial, then the Temple. When all trials are complete you will have to face the final boss. Good luck!
# HINT: Glasses with a high visual range help tremendously on this level so buy the best you can get.
# HINT: the unit 'type' for the oasis guardians is 'oasis-guardian'
loop:
closestEnemy = None
minDistance = 150
enemyIndex = 0
enemies = self.findEnemies()
mushrooms = self.findItems()
mushroom = self.findNearest(mushrooms)
while enemyIndex < len(enemies):
currentEnemy = enemies[enemyIndex]
enemyIndex += 1
currentDistance = self.distanceTo(currentEnemy)
if currentDistance < minDistance and self.isPathClear(self.pos, currentEnemy):
minDistance = currentDistance
closestEnemy = currentEnemy
else:
pass
if closestEnemy:
while closestEnemy.health > 0:
if closestEnemy.health > 150:
if self.isReady("power-up"):
self.powerUp()
elif self.isReady("bash"):
self.bash(closestEnemy)
else:
self.attack(closestEnemy)
else:
self.attack(closestEnemy)
elif mushroom:
self.move(mushroom.pos)
elif self.pos.y < 40:
self.move({"x": 10, "y":10})
elif self.pos.y > 100:
if self.pos.x > 90:
self.move({"x": 75, "y":125})
if self.pos.x < 40:
self.moveXY(100, 125)
if self.pos.x > 50 and self.pos.x <= 90:
newEnemy = self.findNearest(self.findEnemies())
if not newEnemy:
self.move({"x": 55, "y":115})
self.moveXY(27, 121)
self.moveXY(56, 122)
self.moveXY(45, 96)
self.move({"x": 45, "y":70})
self.moveXY(80, 70)
else:
pass
Because I’ve even tried a shortcut by replacing the while-true loop with closestEnemy = self.FindNearest(enemy)
but that only made it worse at least with this my player would attack some troops instead of moving to the xy coordinates
I’m on the first trial because I skipped these extra levels to finish everything else, and I came back took about 20 min to write this rudimentary code, debugged it, and I still can’t get past the first trial.
Just tested your updated code - I can confirm that it works great with higher tier gear. It stops on {x: 75, y: 125} instead of going for the oracle, but I’m sure you knew that.
When I did this problem I completed it with a flags function to help guide my hero. Once I knew exactly on how the level pans out I adjusted my code to complete the level with out flags. What I found out from completing the level is that finding the nearest enemy was very unrealiable because I would first kill the guys on the bottom right trial. Then I would go to the top right trial and skip the top left trial. So instead I created a range on how far to look when finding enemies. I also found out that once you kill all the enemies on each trial the next set of gems appear. I would kill all the enemies at each trial then move once the next set of gems appeared and that helped my hero navigate to each trial. Then you have to get to the last trial. The boss. You can look for the nearest enemy at that point.