Think about how a trigger runs, first the Events happen -> then the Conditions happen -> then if those Conditions are met the Actions happen.
An Event is something that happens in the game. We can then respond to it with our own game logic. So an Event is what causes our Trigger to run:
-
Unit - A unit Takes damage
So this trigger is running whenever any unit takes damage. Once that happens we move on to the Conditions block.
Conditions are used to determine whether or not our Actions should occur. Questions are asked, such as which unit dealt the damage? How much damage was dealt? Did this damaging unit have a specific ability? These are all questions that can be answered with Conditions.
In this case we're checking if our (Damage source), which is the Unit that dealt the damage in the Event, has the Polymorph Passive ability:
-
(Level of Polymorph Passive for (Damage source)) Greater than 0
If that's true then we move on to the Actions. Otherwise, the trigger stops early and never reaches the Actions.
In this case our Actions use an If Then Else statement which is a way for you to ask even more questions throughout your trigger. In this case our If Then Else is generating a random number ranging from 1.00 to 100.00 and then checking if that number is <= the chance to cast Polymorph:
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-

If - Conditions
-


(Random real number between 1.00 and 100.00) Less than or equal to (15.00 + (5.00 x (Real(TempInt))))
If that's true then we move on to the Then - Actions part of our If Then Else statement.
Finally, you can see in the Then - Actions part that we're running the logic for casting Polymorph on the (Damage Target), aka the Unit that took the damage.
-
Unit - Order TempUnit to Human Sorceress - Polymorph (Damage Target)
So as you can see, nowhere in this trigger are we asking any questions about the (Damage Target). For example:
Is the (Damage Target) a Hero? Is the (Damage Target) a Building? Is the (Damage Target) owned by an Ally/Enemy?
The trigger is going to do EXACTLY what you tell it to do! Or, in this case, it's going to do something that you never told it NOT to do.
Now also take into consideration the fact that we're using the Polymorph ability which has it's own Targets Allowed field inside of the Object Editor. This also determines which units the ability can target. So you're actually controlling the targets for this ability in both the Trigger AND in the Object Editor as well. With this in mind, it makes sense that Polymorph can target Heroes since nowhere on the Ability (that I made) does it say otherwise. If you look at the ability you can see that I edited the Targets Allowed to be less restrictive since I figured we'd want to handle the target filtering inside of the Trigger instead.