Help please with code


#1

Help please - why its dont work?
How was parallel command?
If palladin heal - hero dont attack…

[spoiler] def commhero():
e = hero.findNearest(hero.findEnemies())
if e:
if hero.isReady(“bash”):
hero.bash(e)
else:
hero.attack(e)

def commpal(p,fri):
    for i in range(len(p)):
        if p[i].canCast("heal"):
            if hero.health<hero.maxHealth/2:
                hero.command(p[i], "cast","heal", hero)
            else:
                hero.command(p[i], "defend", hero)
            for j in range(len(fri)):
                if fri[j]!=p[i]:
                    if fri[j].health<fri[j].maxHealth/2 and fri[j].health!=0:
                        hero.command(p[i], "cast","heal", fri[j])



while True:
    s = hero.findByType("soldier")
    a = hero.findByType("archer")
    p = hero.findByType("paladin")
    g = hero.findByType("griffin-rider")
    fri = hero.findFriends()    
    f = hero.findFlag()
    commhero()
    commpal(p,fri)[/spoiler]

#2

Please format your code, Now it’s not readable :frowning:


#3

@GAIGAL Use the “Formatted Text” button on the forum editor to allow your code to appear as it does in the Code Combat editor. As Python requires proper tab spacing as part of its formatting, we cannot tell if your code is correct or not unless the tab spacing is preserved.

For example:

if e:
if hero.isReady(“bash”):
hero.bash(e)
else:
hero.attack(e)

vs

if e: 
	if hero.isReady("bash"): 
		hero.bash(e) 
	else: 
		hero.attack(e)

Also which campaign and level is this for?


#4

Sorry=)
Its mountain, summits gate… i try with flag, but i think this wrong way…


#5

I cannot get the issue to recreate itself.

I can tell you this though. Summits Gate was the first level I found challenging. I actually choreographed the entire assault. And I had to load up on premium gear to be able to complete the level.

If you get passed this level consider it an accomplishment.


#6

But can you tell me - really finished this level without flag or not?
Sorry i teach english and not very well understand and write…)


#7

Using the placement of a flag would be up to you to control things.

I used a time based, pathing system where the troops changed actions based on what time it was. So like actors in a play, they did their part on cue. I finished it without using the flag. However if used wisely the flag system might aid you.

There should be more than one way to complete the level.


#8

yes! I do it! =) Thanks =)