Find Nearest Enemy Chain Lightning In Dueling Grounds

In Dueling Grounds I start off with this code.

hero.moveXY(14, 14)
hero.buildXY("fence", 12, 17)
hero.buildXY("fence", 18, 14)
enemy = hero.findNearestEnemy()

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?

could you help me with sarven road in python?

Maybe put this into while True? Also, I think you need to write if enemy: and put chain lightning there.

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)

1 Like

maybe you can no longer see the enemy because of the fences. You can’t cast spells to things that you can’t see.

try twilight glasses

Can you send a screenshot of your equipment?

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):

I only asked once I thought

I know. I said that to @Chris1.