The problem that I am facing is with dealing damage to Nalfar. I tried all the numbers from 0.1 through 0.8 for “z” in the reflect method, no use. I successfully reflect it towards him, but zero damage.
# Use hero.reflect() to reflect back Nalfar's projectiles!
while True:
enemy = hero.findNearestEnemy()
missile = hero.findEnemyMissiles()[0]
direction = Vector.normalize(Vector.subtract(enemy.pos, hero.pos))
if missile and hero.distanceTo(missile) < 5:
hero.reflect(Vector(direction.x, direction.y, 0.5))
Don’t need to find the nearest enemy. Find all missiles, it should return an array. Use a for loop to run through the missiles array and check is a missile exists before reflecting it. You don’t need to check the distance.
It sends it too high. more than 0.8 is too high, less that 0.2 is too low, what’s in between hits Nalfar but does no damage
while True:
enemy = hero.findNearestEnemy()
missiles = hero.findEnemyMissiles()
direction = Vector.normalize(Vector.subtract(enemy.pos, hero.pos))
for missile in missiles:
if missile:
hero.reflect(Vector(direction.x, direction.y, 1.9))
(nearest enemy is to find direction, which is for reflect, i dunno what else to do)