How Do You Beat Kelvintaph defiler Bonus

I need some help with getting the bonus in KelvinTaph defiler, can u help?

Specifically, the problems I have seen are,

  • Archer dies in spike trap by getting pushed by soldier

  • Soldier dies to yeti after swap

P.S. it is @AnSeDra 's code that has been modified greatly.

#command the paladin
def commandPaladin(paladin):
    if hero.time >= 2:
        #if it can heal, heal
        if paladin.canCast("heal") and paladin.health < paladin.maxHealth * 0.7:
            hero.command(paladin, "cast", "heal", paladin)
        elif hero.time >= 32:
            #attack Nalfar when soldiers arrive
            hero.command(paladin, "attack", "Nalfar")
            
        else:
            #otherwise, shield against spell
            hero.command(paladin, "shield")
        if hero.time == 34:
            #RUN FROM YETI AAAAAAAAHHHHH
            hero.command(paladin, "move", {"x": 70, "y": 84})
            hero.wait(2)
            hero.command(paladin, "move", {"x": 41, "y": 71})
    

def commandArcher(friend):
    if step == 1:
        #attack nearest enemy
        enemy = friend.findNearestEnemy()
        if enemy and enemy.type != "yeti":
            hero.command(friend, "attack", enemy)
    elif step == 2:
        #if step is 2, move
        hero.command("Mirana", "move", {"x":9, "y":77})
    elif step == 2:
        hero.command(friend, "move", {"x":28, "y":49})
    if hero.time == 46:
        #attack last shaman at the end
        hero.command(friend, "move", {"x": 7, "y": 78})
        hero.wait(2)
        hero.command(friend, "attack", "Ugoki")

    
def commandSolider(friend):
    if hero.time >= 3:
        #first attack
        if hero.time <= 7:
            hero.command(friend, "move", {"x":21, "y":73})
        elif hero.time <= 9:
            #attack nearest enemy
            enemy = friend.findNearestEnemy()
            if enemy and enemy.type != "yeti":
                hero.command(friend, "attack", enemy)
        elif hero.time == 10:
            step = 2
        elif hero.time > 12:
            #kill shaman
            hero.command(friend, "attack", "Drun")
        if hero.time >= 17:
            #Rush to the paladin's aid
            hero.command(friend, "move", {"x": 81, "y": 73})
        if hero.time >= 32:
            #Attack Nalfar
            hero.command(friend, "attack", "Nalfar")
        if hero.time == 34:
            #run.
            hero.command(friend, "move", {"x": 31, "y": 66})
    elif step == 2:
        hero.command(friend, "move", {"x":24, "y":66})

def commandAllies():
    #put everything together
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            commandPaladin(friend)
        elif friend.type == "archer":
            commandArcher(friend)
        else:
            commandSolider(friend)
#move out of the way of energy balls from robot walkers
hero.move({"x":32, "y":17})
#hero.cast("invisibility", hero)
while True:
    step = 0
    #ifs checking hero.time
    if hero.time == 2.2:
        step = 1
    elif hero.time >= 6:
        step == 2
    #break at the end
    if hero.time > 46:
        break
    commandAllies()
#defeat the last ogres
hero.moveXY(80, 15)
hero.attack("Grognar")
hero.attack("Grognar")
hero.attack("Grognar")
#brawler down
enemy = hero.findNearestEnemy()
hero.attack(enemy)
#thrower down
enemy = hero.findNearestEnemy()
hero.attack(enemy)
#second thrower down
hero.moveXY(70, 42)
#kill ogre and munchkin
enemy = hero.findNearestEnemy()
hero.attack(enemy)
enemy = hero.findNearestEnemy()
hero.attack(enemy)
#finished yay
hero.say("Now I can say I beat Kelvintaph defiler. Yay!")



Pls tell me where the issues are, thnks :grinning:

Welcome welcome to the forum! :smiley:
We hope you have a lovely, enjoyable, and fun time here on the CodeCombat Discourse.
This forum is a homely place, where you can share ideas, share made levels, report bugs, get help on code, and so much more!
We hope you review this topic for all the rules of the forum!
Thanks and enjoy your time here!!!
:partying_face:

3 Likes

never mind I got it! :smiley: :smiley: :smiley:

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.