Nope.
If you put a human close to a nuetral, the nuetral will attack.
Test it into the level editor.
Put like a nuetral munchkin, and a human witch or something, or an archer.
The munchkin and whatvever you put in will attack each other
Proof here:
I made a scenario.
7 nuetral throwers are attacking a human witch,
They charge at the witch, and quickly get eradicated by 1 shot from the witch.
P.S Who knew witches were that big??
Who knew throwers were that small?
Click here to see it happen
Fixed it by going in the campaign and playing it from there…
def summonTroops():
# These are just an example. Feel free to use griffin riders and/or other units!
if hero.gold >= 40:
hero.summon("archer");
hero.summon("soldier")
def commandTroops():
enemy = hero.findNearestEnemy()
friend = hero.findFriends()
if friend.type == "archer" and enemy:
hero.command(friend, "attack",Vector(30,36))
else:
hero.command(friend, "attack",Vector(30,36))
if friend.type == "soldier" and enemy:
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "attack",Vector(30,36))
def commandTheCollector():
friend = hero.findFriends()
item = hero.findNearestItem()
if friend.type == "peasant" and item:
hero.command(friend, "move",item.pos)
while True:
summonTroops()
commandTroops()
commandTheCollector()
help pls why it keep say Hero PlaceHolder need something to command
hero.findFriends()
returns a list, not a single friend, so essentially, you are commanding a list of friends at once with hero.command()
which is not possible, so it returns Hero Placeholder needs something to command. Hope that helped.
I would say use a for loop in commandTheCollector()
friend = hero.findFriends()
item = hero.findNearestItem()
for friend in friends:
#put the rest of your collector code in the for loop
I hope I am of assistance
I just tried your code, and realized your error was in line 16 sorry! I do not think that you can make your friend attack a vector, your friends do not attack x y coordinates. Instead, have your friend move to the vector. And for this section of code:
friend = hero.findFriends()
if friend.type == "archer" and enemy:
hero.command(friend, "attack", Vector(30,36))
first, the hero.findFriends() returns a list, not a single friend, like @moonwatcher348 said. Instead of making all your friends attack the enemy, which results in an error, use a for loop for friend in friends
, and then type in your if statement.
Second, why just have your archers and your soldiers attack the enemy in separate statements? Why not just say: if enemy: hero.command(friend, "attack", thang)
? From what it looks like, you are commanding your two types of soldiers separately to do the same exact thing, except your soldier is the only one actually attacking the enemy, while your archers would do nothing.
Third, why do you have your soldiers “attacking” a “vector”? If you want to move to a vector, then you should say something like hero.command(friend, "move", Vector(30,36))
. Attacking a vector is not a thing.
In short, this is what I mean:
First, and most importantly, you have GOT to use a for loop, specifically for friend in friends, because then the code knows that “friend” is something in the array “friends”.
Second, combine the soldier and archer attack statements into something like this:
enemy = hero.findNearestEnemy()
friends = hero.findFriends()
for friend in friends:
if enemy:
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", Vector(30, 36))
Third, don’t use “attack” on a vector. I have no idea what happens when you do it, but I think what happens is your soldiers start attacking an “imaginary enemy” on (30, 36).
I’m sorry if this is too complicated, I just hope you pass the level
def summonTroops():
# These are just an example. Feel free to use griffin riders and/or other units!
if hero.gold >= 40:
hero.summon("archer")
hero.summon("soldier")
def commandTroops():
enemy = hero.findNearestEnemy()
friends = hero.findByType("soldier")
frends = hero.findByType("archer")
for friend in friends:
hero.command(friend, "attack", enemy)
for frend in frends:
hero.command(frend, "attack", enemy)
def commandTheCollector():
friends = hero.findByType("peasant")
item = hero.findNearestItem()
for friend in friends:
hero.command(friend, "move", item.pos)
while True:
summonTroops()
commandTroops()
commandTheCollector()
i alr fix the code as u said but the enemy are so many of them
Actually, I’m stuck on this level too, and my code works perfectly, but I need a boss star III to win, and I don’t have that yet… I’ll just wait for star III.
I got star III, and with my code at least, the only way to beat this level is with boss star III because it allows griffin riders. Just spam griffin riders and you are good
And yes, it was very, VERY laggy. Heck, with my code, the only way that worked was to submit it, because if I ran it I got “your code is either really slow or has an infinite loop” and with submit it doesn’t error up
first of all you spelled friends incorrectly!
And if your trying to get it to match this then you might wanna fix that. I havent done this level yet so i could be wrong
Personally I would name that archers but it’s his choice
It actually doesn’t matte cause its a variable.
hey is there any way to mark this post [SOLVED]?
No because this isn’t a level help topic.
ok then… (20 characters)