My troops attack everyone even though I said only brawler
I need help with my code
RenziYT
#1
taylerzy
#2
Your OR: ||
should be an AND: &&
as such:
enemy && enemy.type == "brawler" && hero.distanceTo(enemy) < 50
As it reads right now, you’re saying if it’s a brawler or it’s ANYTHING within 50 units of the player, say “fire”
taylerzy
#6
That code works fine for me, but I have about 3x more health. I’ll try it with less in a moment.
What’s the problem you’re having with it?
Edit:
My bad. You have an extra curly brace right under hero.attack(enemy);
RenziYT
#12
I gotta go, bye, oh and if you wanna join clan, here is the link https://codecombat.com/clans/572e74fffc0cb1a80176a206
we need people like you.