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
ok i will try.
my questions are:
1.iām confused i donāt understand how this is working.
2.how does this finish the level 3.it barely uses anything iāve learned from the previous levels i.e.while(1==1),phase_counter
plz reply because iām eager to learn how this works:)
p.s.i have infinity glasses!
sir-sonic-Destroyer
Starting with summitGate, codeCombat switches from ātake my hand and Iāll guide youā levels to āhere is a challenge, Google and sweat it until you can solve itā levels.
There are python tutorials at:
I will gladly help you but your questions are too ambiguous:
this meaning?
And ?
You could actually break it into separate loops for each part of the level. I think this was taught in the desert where you had to: kill enemies, then collect gold, then kill enemies again.
so the code that you helped me with that you put on your post,
1.does "end"mean return?
2.what do i command my soldiers to do cause it didnāt work i canāt think of an another stragety. 3.is this a ādefā or a code?
ty for help so far:cold_sweat:
The simbol # introduces a comment line in Python. It is better to put comment line in your code to explain what the code does and decrease of making a coding mistake:
# I'm going to attack the enemy until is dead:
if (enemy.health > 0):
self.attack(enemy)
```
So the #end comment tells me what loop just ended. Useful if I have many very long loops
3) It is supposed to by your code's main loop (you have your `while(1==1)` ).
But it is not complete, it contains psedo_code:
```
detect_enemies_friends
command_friends
```
These lines are not the final codes but reminders of what you are supposed to do in this place. You have to replace these lines with the proper code.
2) "What should I command my friends to do" ?
Kill the witch, ogres and skeletons