This gets me in a corner and Isolates me. But when I try to cast chain lighting with Emperor Gloves in a if condition.
(
if hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
)
I get a error saying : “Cast Argument target should have been a object but got null You need something to cast upon.” But I already did find nearest enemy. Some help please?
I know you are new on the Forum, but please, don’t ask for help several times. That won’t give you help faster. Especially in topics that are not about your problem.
P.S. Welcome to the forum! It will be nice if you see this topic. (if you didn’t see it yet)
Just to clarify, Peter is right. It’s because you haven’t checked if the enemy exists. Just because you’ve defined enemy as the nearestEnemy it doesn’t mean it exists, the variable could be empty. The enemy you defined it as may be gone, or as the others said, behind one of your fences now. The best option would be to use if enemy and hero.canCast(“chain-lightning”, enemy):