# 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!
paladin = hero.findNeares(hero.findByType("paladin"))
if paladin.canCast("heal", hero):
hero.command(paladin, "cast", "heal", hero)
pass
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!
hero.summon("griffin-rider")
For starters, you need to follow the directions in the commandPaladin(paladin) function. You havenāt done any of that:
# 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!
After that, you need to create the functions called for in the commandFriends() function. Just think about what the peasants should be doing or the griffin-riders should be doing (once you summon them).
@MunkeyShynes this is my new code, it says target not defined
# 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!
lowestHealthPaladin()
paladin.canCast("heal")
hero.command(paladin, "cast", "heal", target)
hero.command(paladin, "shield", target)
hero.command(paladin, "attack", target)
pass
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!
hero.summon("griffin-rider")
This is my code, and it says that āhealā needs something to be cast upon.
# 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!
target = lowestHealthPaladin()
if paladin.canCast("heal"):
hero.command(paladin, "cast", "heal", target)
hero.command(paladin, "shield")
hero.command(paladin, "attack", enemy)
pass
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!
hero.summon("griffin-rider")
Hi @Code_Kid13.
This is where the error is coming from:
Firstly, look at the error message:
You have defined ātargetā, but how are you sure it exists?
I would also recommend using an if, elif, else structure for this section of code as well.
Danny