Multiplayer Combat in Codecombat


#1

Hello,
I’m having a problem on PvP arenas. Well, I actually don’t know if it is a bug, but:
I want to get enemy hero’s position (cause I’m playing a mage and I would like to cause fear on him but so he goes on traps, some vector stuff). Enemy hero is “Hero Placeholder 1”, but when I want to get his position it is a “Reference Error: true”. I’m wondering if making a loop with enemies and testing if they’re the hero would work. I think the problem is Python is reading my “EnemyHero” variable as a string, not enemy. This is why I’d need some help.


#2

whats your code?
don’t forget to format it with triple backticks


#3

Try this
enemy_hero = [e for e in hero.findEnemies() if e.id in ["Hero Placeholder", "Hero Placeholder 1"]][0]
But ALWAYS check if enemy_hero variable not None. You would not find enemy hero if he/she cast invisible, or your hero glasses can’t see through walls.


#4

This is level editor and he’s using referee, please don’t post stuff that you don’t know


#5

Im not using it to edit levels. I’m playing a mage in duel and I want to cast fear so enemy goes on a trap, and I’m using vectors to find the position so I get the enemy hero on traps.


#6

Thanks! Your answer was really helpful.