Pity to know. But anyway, thx.He means "be like Wietlol"
The best approach (afaik) is to not let units use their regular basic attacks any more and trigger that behavior instead.
There is a sort of workaround but it is not 100% safe.
You can check if the first attack index is ranged or melee (according to their weapon type).
But if you fire an arrow, then morph into a melee unit, that arrow will be detected as melee.
Depending on what you want to use it for, this will do, but it will not work for everything.