Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

I am a CodeCombat noob please help

I was dueling a cpu so I can duel other people but I dont know how to attack the cpu. I know I have to type down the code but i dont know what to put in the target section.

1 Like

@NappaTemp you need to enter a variable like
The Name Of Your Variable = hero.findNearestEnemy())
while item:
attack (The name of your variable)
If you don’t understand this try letting @Deadpool198 help you out.

1 Like

ok, thanks greg! I understand this

No Problem, if this won’t work just tell me or even ask a moderator! :smiley:

And read the hints and goals.

Sorry, This was solved already

Oh it’s okay just next time use hints , iT helps a lot

while True:
    enemy = hero.findnearestEnemy()
    if enemy:
        hero.say("bring on the fight enemy!")
        while > 0:
        hero.say("there's no enemy here!")

or something more advanced

while True:
    enemies = hero.find(enemies)
    enemyIndex = 0
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
        hero.say("ooh a enemy, a enemy!")
        while > 0:
    enemyIndex += 1

or use something even more advanced

while True:
    enemies = hero.find(enemies)
    for enemy in enemies:
        hero.say("yo enemy, get outta here")
        while > 0:
    return enemy

You can just use the first one if you are new to this

wow thats cool(hehehe)

hehe!!! (20 chars no prob)

so Funny(“yo enemy, get outta here”)

u use hurl and throw the enemy in da air

Ok(20 chars so anoyying)