#hasability uses hero tags that are processed very late in timing as its meant for Pre-Req's not for standard checking. Meaning I assume your problem is that you always getting the bottom calculation.
The easy way is to fix the IF statement to check for the hero ability tag.
Code:
if (hero.tagis[Ability.cWildEmp] <> 0) then