Where are these flags handled?
It's an attribute within the creature object.
Attributes of interest:
Bytes0 - I don't know
Bytes1 - Sitting, standing, 'dead', lying down, etc
Bytes2 - Weapon sheathe - main weapon out, second weapon out, both out, ranged out, etc
Bytes3 - Run state, swimming, flying, etc...
UInt32 Value - Many different flags such as unselectable, unattackable, player, etc.
UInt64 Value - I don't know, GUID?
In the server-side Lua API I can call this code:
obj:SetUInt32Value(0x0006 + 0x0003, 0x1) -- untargetable
That's using the true exact values though, which is hacky. In C++ You should use the enum provided. So in pseudocode:
pUnit->SetUInt32Value(UNIT_FIELD_FLAG_UNSELECTABLE, 1);
These values are also stored in the database for persistent creatures:
http://collab.kpsn.org/display/tc/creature