This is my code
points = [{"x": 33, "y": 42},
{"x": 47, "y": 42},
{"x": 33, "y": 26},
{"x": 47, "y": 26}]
while True:
item = hero.findNearestItem()
if item and hero.gold < 80:
hero.move(item.pos)
elif hero.gold >= 80:
hero.moveXY(40, 25)
for i in range(4):
hero.summon("soldier")
while True:
friends = hero.findFriends()
for j in range(len(friends)):
point = points[j]
friend = friends[j]
enemy = friend.findNearestEnemy()
if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
hero.command(friend, "attack", target)
pass
else:
hero.command(friend, point, enemy)
pass
you dont have a break in the first while true i think so it wont go out
Oh, thanks, I will see if that works.
That helped. And I summon soldiers now, but I don’t command them. Since for-loops are like while loops I tried to is break, but it only summoned one soldier, What if statment could help with that?
for i in range(4):
hero.summon("soldier")
if blahblahblah:
break
I wish there was soldier.amount, then I could do
If soldier.amount == 4:
break.
My problem is in here now,
while True:
friends = hero.findFriends()
for j in range(len(friends)):
point = points[j]
friend = friends[j]
enemy = friend.findNearestEnemy()
if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
hero.command(friend, "attack", enemy)
pass
else:
hero.command(friend, "move", points[].pos)
pass
this should just be hero.command(friend, "move", point)
I tried that, didn’t work.
abc
September 1, 2021, 6:54pm
9
hellodaddy:
if blahblahblah:
break
You don’t need the if statement or the break.
That should be hero.command(friend, "move", point)
(if you define point as points[j]) or hero.command(friend, "move", points[j])
1 Like
Thank you, abc, that worked!
system
Closed
September 2, 2021, 6:55am
11
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.