New extension called ATTACKER_ID with a self explanatory name, allowed me to get ID of a unit that is attacking caller unit. Since knowing ID means - being able to access all info about the unit, i can calculate distance between attacked and attacker unit. Based on that i've made a simple weapon switcher (primary weapon: laser / flame thrower).
I've heard that in some modern RTS games if player builds a unit plant, it starts creating units automatically (starts with some predefined queue). Here's that idea moved into TA: