Apparently chain lightning invokes projectile_attack infinitely when a target is visible but unreachable.
Upon hitting anything, it will fork to nearest visible (from last hit location) creature (never NPC or player) that doesn’t have “bounced” state. Only actually hit (not just targetted) creatures get the “bounced” state.
It could be fixed by simply applying “bounced” before attempting to fork. More “proper” solutions (actually ignoring unreachable targets) would be more complex than they sound at first, because chain lightning actually has its own dispersion, meaning it could repeatedly miss (and strike an obstacle on the way).
I’ll try to write a simple fix.