For those of you who weren't aware TargetFindData.xml and ValidatorData.xml in the game data folder contain some of the logic for targeting and using of abilities. For example here is the stimpack section of ValidatorData:
Code Select
<!--
StimPack
if (already buffed)
return false;
if (!attacking)
return false;
if (nearby medivac can heal)
relax next two constraints:
if (recently damaged)
return false;
if (!hostile targets)
return false;
return true;
-->
<CValidatorCombine id="TacticalStimPack">
<Type value="And"/>
<CombineArray value="TacticalStimPackTestBuff"/>
<CombineArray value="CasterIsAttacking"/>
<CombineArray value="CasterNotInCombat"/>
<CombineArray value="TacticalStimPackHostiles"/>
</CValidatorCombine>