HELP grim determination

hi i need help on grim determination it is saying that there is no type

"warlock"

could you help

1 Like

here is my code

def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.type != "paladin":
            continue
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend



def commandPaladin(paladin):
    # Heal the paladin with the lowest health using lowestHealthPaladin()
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
    # And don't forget, they can attack, too!
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type == "warlock":
        hero.command(paladin, "attack", "warlock")
    else:
        
        hero.command(paladin, "attack", enemy)
    pass
def comandy():
    item = hero.findNearestItem()
    if item:
        hero.command(friend, "move", (item.pos.x, item.pos.y))
def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            #commandPeasant(friend)
            pass
        elif friend.type == "griffin-rider":
            #commandGriffin(friend)
            onehundredandtwo()
            pass
        elif friend.type == "paladin":
            commandPaladin(friend)
def onehundredandtwo():
    enemy = hero.findNearestEnemy()
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
        if enemy:
            
            hero.command(griffin-rider, "attack", enemy)

    
while True:
    commandFriends()
    lowestHealthPaladin()
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    # Summon griffin riders!

on your paladin function, you are attacking "warlock" but your enemy variable is enemy

Try putting parenthases like this (“warlock”) and see if that works.

no you have to target an enemy, but you can’t target a string

also, why do you have two functions that you aren’t running?
edit: nvm

Try @CryptiCrystal suggestion first because I’m not too good at coding lol

Ah ok, that makes sense. My bad

also, in your lowestHealthPaladin, use return lowestFriend and then you can run that in your paladin function as the target for the heal command

1 Like

as @CryptiCrystal said, you can’t target a string, replace “warlock” with a variable with the enemy, and it should work

1 Like

this is my code

# Your goal is to protect Reynaldo

# Find the paladin with the lowest health.
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.type != "paladin":
            continue
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend

    return lowestFriend

def commandPaladin(paladin):
    # Heal the paladin with the lowest health using lowestHealthPaladin()
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
    # And don't forget, they can attack, too!
    warlock = hero.findNearest(hero.findByType("warlock"))
    enemy = paladin.findNearestEnemy()
    lowest = lowestHealthPaladin()
    if warlock:
        hero.command(paladin, "attack", warlock)
    elif lowest and paladin.canCast("heal",lowest):
        hero.command(paladin, "cast","heal", lowest)
    else:
        hero.command(paladin, "attack", enemy)
def commandGriffin(griffin):
    enemy = griffin.findNearestEnemy()
    warlock = hero.findNearest(hero.findByType("warlock"))
    if warlock:
        hero.command(griffin, "attack", warlock)
    elif enemy:
        hero.command(griffin, "attack", enemy)
    
def commandPeasant(peasant):
    item = peasant.findNearestItem()
    if item:
        hero.command(peasant, "move", {"x":item.pos.x,"y":item.pos.y})
    
def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    
    for friend in friends:
        if friend.type == "peasant":
            commandPeasant(friend)
            pass
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
            pass
        elif friend.type == "paladin":
            commandPaladin(friend)

while True:
    commandFriends()
    # Summon griffin riders!
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")

this is my equipment
image
I keep making it to 32.5 secs

Please avoid making duplicates Help. I need help with grim determination