[Adventurer] The One Wizard


#22

how do you avoid the firetraps?


#23

I said use lightning bolt. It has unlimited range, and it should kill it in one shot.


#24

Nope.

Experiment and try different methods. Think as a player which just completed early forest levels.
<health property is introduced later>


#25

OK this is my new code. Can you help me to make it better?

enemy = hero.findNearestEnemy()
hero.cast("chain-lightning", enemy)
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
        if hero.isReady("root"):
            hero.cast("root", enemy)
        if hero.isReady("chain-lightning"):
            hero.cast("chain-lightning", enemy)
        elif hero.isReady("lightning-bolt") and enemy.type == "scout" or enemy.type == "catapult":
            hero.cast("lightning-bolt", enemy)
        elif hero.isReady("regen") and hero.health<70:
            hero.cast("regen", hero)
        elif hero.isReady("shockwave") and hero.distanceTo(enemy) < 20:
            hero.cast("shockwave", enemy)
        elif hero.distanceTo(enemy) < 5:
            hero.moveXY(8, 36)


#26

Hmm, why do root and shockwave work??? Thanks. I will find and remove them.


#27

Why do you need to remove it? Isn’t it better if we have more abilities?


#28

Also it said in the Hints that we can use root and shockwave.


#29

Nope. It’s in the spell pallet and it’s automatically

No. If you add all spells and all thangs on the field it doesn’t help to make a good level.


#30

Oh ok i understand. :smile:


#31

we can’t attack the catapults until we see it, and we can’t see it until it is within 60 meters, and it isn’t within 60 meters.


#32

The hero’s visual range is 65 in this level. Anyway what the problem?
Guys. This is a level for early Forest. Don’t complicate it. Try to make your solution step by step. Attack first. Then add some spell, another. The keyword for this level is IF-ELSE-IF.


#33

This is a great little puzzle that took me a few tries. I think the important part (for anyone having trouble as I did) is to understand the way the if-else statements interact and more importantly, understand how to properly nest them.

For example, I originally had my hero check for the ogre AFTER checking the distances to the enemies, like this:

if distance <= 30:
    if hero.canCast("chain-lightning"):
        hero.cast("chain-lightning", enemy)
    else:
        hero.attack(enemy)
elif distance > 30:
    if hero.canCast("lightning-bolt"):
        hero.cast("lightning-bolt", enemy)
elif enemy.type == "ogre":
    hero.moveXY(7, 32)

But because the hero notices the enemy distance first, the enemy.type == “ogre” statement never runs. I needed the hero to check the enemy type first.


#34

Try to set type checking before distance checking


#35

Wow this level really gets you thinking out of the box.

Before I had a complicated code, then I decided to restart.

The simpler code I wrote after I restarted allowed to get all the bonuses when the complicated one can’t.

Great level!

Hint to the people who are stuck on the level:

Hint

Try moving back a bit, so the ogres take longer to reach you.


#36

you still have to be withing 65 meters.


#37

yep. that too. (20 chars)


#38

So then i can’t attack the catapult.


#39

I pass this level, using the plan array

plan = ["lightning-bolt", 'attack', 'attack', 'attack', 'attack', 'attack', "lightning-bolt", "chain-lightning",
        "regen", 'attack', "regen", "lightning-bolt", "chain-lightning", 'attack', 'attack', "lightning-bolt", 'attack',
        "regen", "lightning-bolt", 'say', "away", 'armagedon']

#40

what’s armagedon? (20)


#41

No need to do that… You just need to move back so you have more time to attack the ogres…