[SOLVED] Help on Rentangle Formation

i need help on this level

# Form up soldiers and archers in rectangle formations.

# The distance between units.
step = 8

# First form up soldiers.
sergeant = hero.findNearest(hero.findByType("soldier"))
# The coordinates of the bottom left corner.
soldierX = 8
soldierY = 8
# The width and height of the formation.
width = sergeant.rectWidth
height = sergeant.rectHeight

for x in range(soldierX, soldierX + width + 1, 8):
    for y in range(soldierY, soldierY + height + 1, 8):
        hero.summon("soldier")
        lastUnit = hero.built[len(hero.built)-1]
        # Command the last built unit by using the  x/y variables:


#0 Next form up archers.
sniper = hero.findNearest(hero.findByType("archer"))
# The coordinates of the bottom left corner.
archerX1 = 48
archerY1 = 8
# The coordinates of the top right corner.
archerX2 = sniper.archerX2
archerY2 = sniper.archerY2

for x in range(archerX1, archerX2 + 1, 8):
    for y in range(archerY1, archerY2 + 1, 8):
        # Summon an archer.
        hero.summon("archer")
        # Find the last built unit.
        lastUnit = hero.built[len(hero.built)-1]
        # Command the last built unit by using the  x/y variables:
        
        pass

help in this part

# Command the last built unit by using the  x/y variables:

Just do a move command like: hero.command(someUnit, "move", {'x': someX, 'y': someY })

2 Likes

:expressionless: i think thats right ok mmm
ok i having problems with this

for x in range(soldierX, soldierX + width + 1, 8):
    for y in range(soldierY, soldierY + height + 1, 8):
        hero.summon("soldier")
        lastUnit = hero.built[len(hero.built)-1]
        # Command the last built unit by using the  x/y variables:
        hero.command(lastUnit, "move", {'x':soldierX + width, "y": soldierY + height})

this

hero.command(lastUnit, "move", {'x':soldierX + width, "y": soldierY + height})

someone help :confused:

well im gonna look on youtube :pensive:

i can help you here now

1 Like

I dont think that last part is wrong it works fine for me

1 Like

or not, sorry i have bad eyesight

hero.command(lastUnit, "move", {'x':soldierX + width, "y": soldierY + height})

Instead of using {‘x’:soldierX + width, “y”: soldierY + height} try to use {“x”: x, "y:, y}

2 Likes

Yes, now I looked over his code and I think that this is the mistake he made.

Andrei

1 Like

And don’t forget to also command the archers to move

Andrei

Which campaign is this level in?

In the mountain.

Andrei

I can’t find it. Where exactly is it? A screenshot would help.

@AnSeDra where is Rectangle Formation.

doesn’t matter it is way ahead of me.

thank you fo that i gonna try to look over my code thank you

1 Like

yes! but how did that i didn’t figure out of that
solve

1 Like

What do you mean by that? Would you like for I to explain the algorithm of this level clearly?

Andrei

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.