Bonemender seem to be bugging

Hi,

It seems like the mission Bonemender (python) is bugged.

When ever I am trying to cast regen on Chandra it just says “ArgumentError: Target is null. Is there always a target to attack? (Use if?)”. I have spent like 2-3 hours in just trying to find the correct code for this but then I gave up and look up online and found several people who have used the exact same code as I am but they do succeed this mission. I also see a post on youtube that another person tried the same and cannot get though this mission of the same error.

The code itself

# Heal allied soldiers to survive the siege.
while True:
    if hero.canCast("regen"):
        bernardDistance = hero.distanceTo("Bernard")
        if bernardDistance < 10:
            # "Bernard" needs regeneration!
            hero.cast("regen", "Bernard")
        
        # Use "if" and "distanceTo" to regenerate "Chandra"
        # if she is closer than 10 meters away.
        chandraDistance = hero.distanceTo("Chandra")

* List item

if chandraDistance < 10:
                hero.cast("regen", "Chandra")
        
    else:
        # If you aren't casting "regen", use "if" and "distanceTo"
        # to attack enemies that are closer than hero.attackRange.
        enemy = hero.findNearestEnemy()
        hero.attackRange - 30
        hero.attack(enemy)
        pass

i used this one which worked

# https://codecombat.com/play/level/bonemender
# Лечите дружественных солдат, чтобы победить в осаде.
while True:
    if hero.canCast("regen"):
        bernardDistance = hero.distanceTo("Bernard")
        if bernardDistance < 10:
            # Бернарду нужна регенерация!
            hero.cast("regen", "Bernard")
        chandraDistance = hero.distanceTo("Chandra")
        # Используйте "if" и "distanceTo" для регенерации "Chandra"
        # Если она ближе 10 метров.
        if chandraDistance < 10:
            hero.cast("regen", "Chandra")

    else:
        # Если вы не колдуете "regen", используйте "if" и "distanceTo"
        # чтобы атаковать врагов, которые ближе, чем hero.attackRange.
        enemy = hero.findNearestEnemy()
        if enemy and hero.distanceTo(enemy) < hero.attackRange:
            hero.attack(enemy)

And i have no idea why that s* worked and my script didn’t.
I did change

        hero.attackRange - 30
        hero.attack(enemy)
        pass

to

    enemy = hero.findNearestEnemy()
    hero.attackRange - 30
    hero.attack(enemy)
    pass

And now it’s working.

nevermind this.

you have to check if the enemy exists:

if enemy:

also, you no longer need the pass if you have other stuff inside

1 Like