Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help with the one wizard


#1

hey guys i need some help i can get the first 2 objectives but not the last 2 so here my code and tell me if theres a way you can help me get the last 2.

index = 0
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']
while True:
    current_plan = plan[index % len(plan)]
    if (current_plan == 'regen'):
        if hero.isReady("regen"):
            hero.cast("regen", hero)
            index += 1
        else:
            hero.moveXY(8, 30)
    elif (current_plan == 'away'):
        hero.moveXY(18, 41)
        index += 1
    elif (current_plan == 'say'):
        hero.say("booring")
        index += 1
    elif (current_plan == 'armagedon'):
        hero.moveXY(7, 41)
        index += 1
    else:
        enemy = hero.findNearestEnemy()
        if (enemy):
            if (enemy and enemy.health > 0):
                dist = hero.distanceTo(enemy)
                if (current_plan == 'attack'):
                    hero.attack(enemy)
                elif (current_plan == "chain-lightning" and hero.isReady("chain-lightning")):
                    hero.cast("chain-lightning", enemy)
                elif current_plan == "lightning-bolt" and hero.isReady("lightning-bolt"):
                    hero.cast("lightning-bolt", enemy)
            if (enemy.health <= 0):
                index += 1
        else:
            hero.moveXY(8, 30)


#2

Please keep posts on topic.


#3

Please do not post finished code.


#4

Since the level doesn’t have seeds, I just used code without ifs and loops. My strategy was lightning-bolt the catapults, chain-lightning the little guys, and regen whenever you can.


#5

“I just used code without ifs and loops” - Using this “feature” ( i see it as a flaw…)? :

var snortt = 'Snortt',
    goreball = 'Goreball',
    zock = 'Zock',
    zozo = 'Zozo';
hero.attack(snortt);
hero.attack(snortt);
hero.attack(goreball);
hero.attack(zock);
hero.attack(zozo);
hero.attack(zozo);

@DaPandaKing - I like your approach - didn’t debug it


#6

Mod edit: [Please don’t post successful solutions.]