How do I find how many enemies are around at a area for fireball in Giant's Gate?

Here is my code:

hero.summon('brawler', 'A')
while True:
    if hero.time >= 4.50:
        hero.summon('brawler', 'D')
        break
while True:
    hero.summon('shaman','A')
    hero.summon('shaman','A')
    if hero.canSummonAt(79, 40):
        hero.summon("ogre", 79, 40)
        hero.summon("ogre", 79, 40)
        hero.summon("ogre", 79, 40)
        hero.summon("ogre", 79, 40)
        hero.summon("ogre", 79, 40)
        hero.summon("ogre", 79, 40)
        hero.summon("ogre", 79, 40)
        hero.cast('heal',89, 40)
        hero.cast('fireball', 10, 40)

Now it works well, as I am high on the leaderboard for Giant’s Gate, but I do lose some of my matches. I battle them, and I see that the ones I lose to usually find how many enemies are around an area, and fire a fireball at them. So how do I do this?

Welcome to the forum! This is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your code correctly), or just hang out with other coders. But before you proceed, please check out our guidelines: this topic.
Have a great time! :partying_face:

You can do:

if enemy.pos.x == x and enemy.pos.y == y:
    hero.cast("fireball", x, y)

@Ironwolfyyy

But it does not cast it at groups. I only want to cast it if there are 4+ enemies.

Use hero.findEnemies, then find a “radius” of a group and shoot at the center point of the group

1 Like

How do I find a radius? is it like this?

enemy=hero.findEnemies
if enemy > 3:
     hero.cast('fireball', enemy.x, enemy.y)

maybe:

enemies=hero.findEnemies
if len(enemies)>3:
    #whatever

Sadly, it didnt work

if you dont want to count giants or the enemy hero do:

for enemy in emeies:
    if enemy and enemy.type!="giant" and enemy.type!="hero.type":
        #whatever

How do I find the cords for group

also i tried

    if len(enemies)>3:
        for enemy in enemies:
            if enemy and enemy.type!="giant" and enemy.type!="hero.type":
                hero.cast('fireball', enemy.x, enemy.y)

it also didn’t work.

I CAN DEFEAT YOU lol

Please, if you have nothing contructive to add to any topic, especially if it’s been dead for years, don’t post