- Find by type will return a list of enemies.
whiches = self.findByType("witch")
if len(whiches):
witch=witches[0]
else:
witch = None
-
Do you have see through wall glasses? Buy the most advanced pair with see through wall and infinite range
-
loop and while(True) add a one time frame wait after each cycle to advance the time
If you use while(1==1) you do not have the wait frame so your action will be faster. But then you are required in each loop to perform either an action that takes time or an self.wait(0.001) to advance the time.
Check:
to see how to write a loop that always takes one action. Just replace the move at the end with an wait.
- I understand your problem: you want all the moves at the end to be executed on after each other, but you need to command your soldiers continuously.
You do not know how to code this: during the loop you will command the soldiers and then take only one of the actions from the end list.
Here is how you do it. This code:
- moves to 1 place,
- says something - bad idea actually since say takes 0.9s and your soldiers will idle.
- moves to the second place:
point1 = {'x':20, 'y':30}
point2 = {'x':30, 'y':20}
phase_counter=0
while(1==1):
detect_enemies_friends
command_friends
switch (phase_counter):
case 0:
if distance2(self.pos, point1) > 1:
self.move(point1)
elif:
phase_counter+=1
break
case 1:
self.say("wasted time")
phase_counter+=1
break
case 2:
if distance2(self.pos, point2) > 1:
self.move(point2)
elif:
phase_counter+=1
break
# end switch
#end while(1==1)
You must write your distance2 function. Use vectors
Put the whole switch into a separate function: commandHero()
Keep the phase_counter as a global variable