that is, check the caste raw flags in addition to the curse flags.
might want to implement this in Lua (from Units.cpp):
#define IS_ACTIVE_CASTE_FLAG(cf) !unit->curse.rem_tags1.bits.cf && \
(unit->curse.add_tags1.bits.cf || casteFlagSet(unit->race, unit->caste, caste_raw_flags::cf))