Hello ,
I have started to learn the Programmation so it’s probably a stupid mistake ^^’.
So I have created a function “countEnnemyClose()” it worked when I used it in the code.
But when I used it in another function I have had “Fix Your Code Line 18 TypeError: Cannot read property ‘value’ of undefined”.
can anybody help me with my problem
#Programm
while True:
findAndAttack()
#enemy = countEnnemyClose()
#hero.say(enemy)
#Fonction
def findAndAttack(close) :
enemy = hero.findNearestEnemy()
close = countEnnemyClose()
if enemy:
distance = hero.distanceTo(enemy)
if distance > 20:
hero.attack(enemy)
if distance < 10:
if close >= 3 :
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
if hero.isReady("bash"):
hero.bash(enemy)
else:
hero.shield(enemy)
hero.attack(enemy)
def countEnnemyClose() :
enemies = hero.findEnemies()
count = 0
for enemy in enemies:
distance = hero.distanceTo(enemy)
if distance < 12:
count += 1
return count