Haris
1
hero not moving at flag pos bug???
def lowHp():
friends = hero.findFriends()
for friend in friends:
if friend.health <= friend.maxHealth / 2:
pass
def comPal(paladin):
lH = lowHp()
friend = hero.findFriends()
enemy = paladin.findNearestEnemy()
if friend.health <= lH:
if paladin.canCast("heal", friend):
hero.command(paladin, "cast", "heal", friend)
elif enemy.health > 0:
hero.command(paladin, "attack", enemy)
def comGriff():
if hero.gold >= hero.costOf("griffin-rider"):
# lesgoo command giffin-rider
hero.summon("griffin-rider")
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
for friend in friends:
if enemy.health > 0:
hero.command(friend, "attack", enemy)
while True:
flag = hero.findFlag()
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
if flag:
hero.move(flag.pos)
for friend in friends:
if friend.type == "griffin-rider":
if enemy.type == "robot-walker":
comGriff()
elif friend.type == "paladin":
comPal()
elif friend.type == "archer" and friend.type == "soldier":
if enemy.type == "chieftain":
hero.command(friend, "attack", enemy)
hero.command(friend, "move", {'x': 32, 'y': 57})
hero.command(friend, "move", {'x': 26, 'y': 57})
hero.command(friend, "move", {'x': 30, 'y': 52})
hero.command(friend, "move", {'x': 54, 'y': 59})
hero.command(friend, "move", {'x': 76, 'y': 57})
hero.command(friend, "move", {'x': 78, 'y': 40})
if enemy.type == "robot-walker" and enemy.health == 0:
hero.moveXY(76, 14)
Aya
2
I think you should specify the flag’s colour. I think, not sure tho
2 Likes
Anonym
3
Yes, you’re right.It should be
hero.findFlag('[flag color]')
2 Likes
Haris
4
ok (20charsaqwadwf) 20(chars
Haris
5
and one more thing. i get error Try use "hero.findNearestEnemy()"
def comPal(paladin):
lH = lowHp()
friend = hero.findFriends()
enemy = paladin.findNearestEnemy()
if friend.health <= lH:
if paladin.canCast("heal", friend):
hero.command(paladin, "cast", "heal", friend)
elif enemy.health > 0:
hero.command(paladin, "attack", enemy)
@Aya @Anonym
Aya
6
It is possible paladin
doesn’t have property findNearestEnemy()
Aya
7
Also, there is another problem,
this returns a list, so what you should do is either make a for-loop
or get a certain index like this friend = hero.findFriends()[number]
Haris
8
like this eh? friend = hero.findFriends()[1]
??
Aya
9
Hint: from which number do indexes start in Python?
Haris
10
i don’t know what do you mean
Aya
11
Do they start from 1 or a different number 0
Haris
13
bruh still get error (20chars)
Aya
14
Can you please post your new code? And the error
1 Like
Haris
15
def comPal(paladin):
lH = lowHp()
friend = hero.findFriends()[0]
enemy = paladin.findNearestEnemy()
if friend.health <= lH:
if paladin.canCast("heal", friend):
hero.command(paladin, "cast", "heal", friend)
elif enemy.health > 0:
hero.command(paladin, "attack", enemy)
Anonym
16
Sorry, I was offline.
friend = hero.findFriends()[number]
do like this
Haris
17
and i get the same errorr
Anonym
18
ah, i see.Ok, have you tried for loop?
Haris
20
still.
def comPal(paladin):
lH = lowHp()
friends = hero.findFriends()[0]
enemy = paladin.findNearestEnemy()
for friend in friends:
if friend.health <= lH:
if paladin.canCast("heal", friend):
hero.command(paladin, "cast", "heal", friend)
elif enemy.health > 0:
hero.command(paladin, "attack", enemy)