Alright:
EUDs have to be preplaced or PREDICTABLY CREATED. That means you have to make sure they are created in a certain spot in the unit table. I haven't gone through testing yet, since I haven't needed to, but I think newly created units will always be created in the lowest vacant spot. In memory it looks something like this:
1 1700 1699 1698 ... 3 2. The first unit created is first in the unit table. The second unit created is the last in the unit table.
When you kill a unit, it goes through its death animation, then is removed from the unit table, creating a vacancy. This
might be correct. That means if you wait a little while after the unit dies, and then create your unit, it will be placed in that unit slot on the table.
Now, for detecting stimpacks. There's a bit of a problem here, as three things change when using stim packs. First, health is decreased by 10 exactly. This can be detected by detecting ALL of the unit's health values (you probably only need the whole numbers and not the extra precision). Then, set a DC to that number. Use binary countoffs to compare the previous frame with the current frame. If it's 10, then you have stimmed.
Another alternative is to detect the unit's speed. I don't know how to do this, but it's probably somewhere in the iscript area. Perhaps a modder can tell you how 2 is added to the unit's iscript, and that can be detected.
The same goes for the 3rd aspect, where you detect cooldown. However, I've never been able to detect cooldown on any unit, even though you can detect the timer for the cooldown, just not what it's supposed to be set to.
For detecting a spell: do you want to detect when the queen/kerrigan casts it, or whether or not the unit is ensnared? If you want to detect when it is ensnared, you can detect the top speed if it's controlled by flingy.dat. I'm not sure how to detect iscript ensnares. If you want to detect when it's cast, you can either detect cooldown timer, or detect the energy difference.
"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"