if hero.canCast(“chain-lightning”):
# and
if hero.isReady(“chain-lightning”):
# are equivalent
hero.canCast("chain-lightning", enemy):
defines if hero can physically attain the enemy ( you can see the enemy with see-through-wall glasses, but you cannot harm him)
This was the answer to your question in How to cast "chain-lightning"
You are attacking the yaks because the bounceRange is 20m and bounceCount is 8.