When choosing a new primaryweaponprioritytarget to shoot (that is not the current target) only use the priority number, do not attempt to get the health of each prioritytarget as we may not have it targeted yet and thus not have the shields/armor/hull values to use.