Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Dungeon Arena, python, self.say()


Hello, friends. Sorry for my english.
I want give “Attack” command to all my units.
See, if i use:

enemy = self.getNearest(enemies)
self.say(“Defend!”, “targetPos”: {x: 10, y: 20}})


self.say(“Attack!”, “target”:enemy)

"Unexpected token, Your parentheses must match"
What can i do, for attacking enemy hero all my units?


I have no idea what you are trying to accomplish here but say only has one parameter you pass in, a string of text for your character to say. You can not force it to attack from a say. and i’m not sure what you are trying to do with the defend one.


Actually, in the Dungeon Arena level only, they do listen to you, and you can pass more parameters. The second parameter has to be an object, though, and you are missing one or both curly braces in your examples. Try like this:

self.say("Defend!", {"targetPos": {x: 10, y: 20}})
self.say("Attack!", {"target": enemy})


This code - self.say(“Defend!”, {“targetPos”: {x: 10, y: 20}}) - works well, many thanks, but
self.say(“Attack!”, {“target”: boss}) - don’t work. My units continue attacking nearest enemy.
please, see and test my code. I simplify it:

friends = self.getFriends()
enemies = self.getEnemies()
if enemies.length is 0:
____return # Chill if all enemies are dead.
enemy = self.getNearest(enemies)
friend = self.getNearest(friends)
def whois(arrays, types):
____for i in arrays:
________if i.type == types:
____________return i
if boss and self.distance(boss.pos)<20 and not self.getCooldown(“terrify”):
____self.attack(“Ogre Base”)
____self.say(“Attack!”, {“target”: boss}) - “”"(, did not work too)"""
Please, check this, and help me to understand this features about self.say().


Ah nick to the rescue. :slight_smile: I haven’t done much with that map. Must be one of the older ones that doesn’t adhere to the consistency of the newer levels?


Yeah, that looks like it should work. Probably it’s a new bug in an old level.

You might want to try Sky Span, which is an upgraded version of Dungeon Arena that uses the command API instead of say, which is much more precise.