Here is what I tried with the editor:
Make a custom tower by copy and pasting a guard tower. Make a custom ability by copy and pasting Chain lightning. Set the Chain Lightning property "Hero Ability" to false, "mana cost" to 0. To "targets allowed" you might want to add mechanical to be able to target demolishers for example. Change damage and cooldown to whatever you like. And maybe "levels" to 1 and remove the "tooltip text" level1 -part.
Then change the custom tower "attacks enabled" to none. Add to "normal abilities" the Chain Lightning you just made.
Then use these triggers:
============================
This trigger sets a target for the tower, when a unit becomes inside the towers range(700). If the tower already has a targe, it doesn't change it.
TowerShoot
Events
Unit - A unit comes within 700.00 of Guard Tower 0050 <gen>
Conditions
(Owner of (Triggering unit)) Not equal to Player 3 (Teal)
Actions
Unit Group - Add (Entering unit) to TowerTargets
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
Attacker Equal to No unit
(Attacker is dead) Equal to True
Then - Actions
Set Attacker = (Entering unit)
Else - Actions
Do nothing
====================================================
This trigger makes the tower to constantly shoot the target as long as it is alive or leaves the towers range. If the target leaves the range, the tower no longer tries to shoot it and acquires a new target, if inside range.
ShootUnits
Events
Time - Every 0.10 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
Attacker Not equal to No unit
(Attacker is dead) Equal to True
And - All (Conditions) are true
Conditions
(Distance between (Position of Attacker) and (Position of Guard Tower 0050 <gen>)) Less than or equal to 700.00
(Attacker is dead) Equal to False
Then - Actions
Unit - Order Guard Tower 0050 <gen> to Orc Far Seer - Chain Lightning Attacker
Else - Actions
Unit Group - Remove Attacker from TowerTargets
Set Attacker = No unit
Set Attacker = (Random unit from TowerTargets)
Unit - Order Guard Tower 0050 <gen> to Orc Far Seer - Chain Lightning Attacker
======================================================
There might be some way you could optimize these triggers, but try it out =)