currentHealth = self.health
healingThreshold = self.maxHealth / 2
# If your current health is less than the threshold,
if self.health < healingThreshold:
# move to the healing point and say, “heal me”.
It keeps saying that "Target is null. Is there always an enemy to attack?(Use if)"
Can someone tell me how to fix it? Thanks
To format your code correctly, please highlight it and click the </> button. Reading the FAQ first helps.
That error message, in my experience, usually means that you should change [quote=“DiamondsGaming, post:1, topic:6145”]
[/quote]to something like this:
enemy = self.findNearestEnemy() if enemy: self.attack(enemy)
This keeps your hero from trying to attack an enemy that doesn’t exist.