Teleport lasso help CPP [SOLVED]

        auto enemy = hero.findNearestEnemy();
        if (enemy){
           float distance = hero.distanceTo(enemy);
           if (enemy.type == "munchkin" &&  distance < 20)
            // Then attack it.
        }

I don’t think the default code is perfect