Uninitialized players may not validate the "is unit enemy" condition.
Also throw out of the window those damn one line matching filters. Better filter them inside the unit group loop.
You may also replace Begin casting by finish casting, it would make things more reliable in a gameplay perspective.
Pyro mentioned this but you want to use
Starts the effect of an ability.
Finishes Casting is almost NEVER the Event you want to use and really only comes in handy for determining that you've finished a full channeling of a spell like Earthquake for example.
Begins Casting is not reliable either and if you're using this then your triggered spells are likely heavily abusable/buggy. You can try this for yourself, begin casting a triggered spell and then immediately interrupt it with a "Stop" order, repeat this process and watch as your trigger repeatedly fires while the ability never spends any mana/goes on cooldown.
[Events]
Begins Casting: Your Hero has reached it's target (if any), the Icon for the Ability is now glowing green and your Hero has entered the "Cast Point" phase. This will start a Timer with a Duration set to your caster's
Art - Cast Point field (modifiable in the Object Editor). Once that Timer expires, the Ability will "start it's effect", assuming that the target (if any) is still within Cast Range. There's a buffer range of 300.00 to allow some leeway here (see Gameplay Constants -> Spells - Target Motion Allowance). This Event should
NOT be used to detect when a Hero successfully casts an ability and is instead focused on preparing the cast.
Every single ability-related Event Response is available here.
Begins Channeling: I forget all of the details, but as the name implies, this is meant to be used with Channeled abilities like Earthquake as well as anything that uses Casting Time to delay the ability. Casting Time is actually considered "channeling" and fires this Event. I imagine you'd want to rely on this Event over "Begins Casting" when channeling something this way, as it likely occurs when Casting Time has started rather than finished.
Every single ability-related Event Response is available here.
Starts The Effect Of An Ability: Your Hero has finished it's "Cast Point" phase, the Timer has expired, and the ability has been confirmed as a 100% successful cast. Any effects like launching a Missile (ie: Storm Bolt) will have occurred at this phase. Mana cost has been spent, Cooldown has started, etc. This will be your go-to Event for custom triggered spells most of the time.
Every single ability-related Event Response is available here.
Stops Casting: Your Hero has either manually cancelled their cast with a new Order like "Stop" or has been Stunned, Silenced, or disabled in some way that interrupts spellcasting. This cancels and destroys the "Cast Point" timer and your Hero is now free to do something else. No costs have been paid.
You no longer have access to the (Target unit of ability being cast) or anything targeting related.
Finishes Casting: I forget all of the details, but it's behavior is basically like "Stops Casting" but only runs if "Starts The Effect" has occurred prior. This one can actually be completely bypassed in certain cases and is not reliable outside of Channeling abilities.
You no longer have access to the (Target unit of ability being cast) or anything targeting related.
So if you want to interrupt an ability or skip it's animations/cooldown/mana cost then use
Begins Casting. If you want your trigger to sync up with the ability without any issues then use
Starts The Effect. Exceptions may apply for
Channeled abilities. Also, I mentioned Heroes in this explanation but this applies to any kind of Unit. Furthermore, setting a unit's Art - Cast Point to 0.00 may cause different results since there is no delay.