Capture The Flag help


#1

i tried several codes but they just won’t work this is my currunet code

placeFlag - this should be called three times at the beginning of your code to hide your 3 flags

def moveTo(position, fast=True):
if (hero.isReady(“jump”) and fast):
hero.jumpTo(position)
else:
hero.move(position)

route = [[128, 36, True], [75, 66, False], [129, 82, False], [80, 103, False], [129, 107, False]]
index = 0

def moveHero():
if len(route) > index:
moveTo({‘x’: route[index][0], ‘y’: route[index][1]}, route[index][2])
if (hero.pos.x == route[index][0] and hero.pos.y == route[index][1]):
return True
else:
return False

hero.placeFlag({‘x’: 20, ‘y’: 60})
hero.placeFlag({‘x’: -6, ‘y’: 109})
hero.placeFlag({‘x’: -7, ‘y’: 9})
hero.moveXY(121, 46)
while True:
target = None
flags = hero.findByType(‘flag’)
for flag in flags:
if flag.team == ‘ogres’:
target = flag
break
if target and hero.distanceTo(target) < 3:
flag = hero.findEnemyFlags()
hero.captureFlag(flag[0])
elif len(flag) > 0 and hero.distanceTo(target) < 3:
hero.move(target)
elif (moveHero()):
index = index + 1 # findEnemyFlags - this should be called in order to locate enemy flags, it returns an array of any enemy flag within 5 units of you
# captureFlag - this is called on a flag you’ve found and captures it if you are within 3 units of the flag, then you can run the flag back to your side of the map
# you also have the ability to control your robot-walker, though he can only fire, not move


#2

Please post your code according to the FAQ.


#3

@nick
I need help with capture the flag, but for a different reason. I completed all that I can, for levels that do not need to subscribe. The last level at the bottom left actually can’t be completed, since certain players are restricted, only one player that needs subscription to unlocked can play the level. Also, I can’t seem to play the ??? level. Thanks.


#4

Umm, can someone help pls. Thanks


#5

If you need help with that, click here. Click there to do “Capture their flag”.


#6

How do I find where the flag is if each opponent moves their flag somewhere? In order to find the opponent’s flags, I have to be within 5 units of it.