Could someone please tell me where and how to set the unidentified item flag when I wish to swap an existing magic item in an enemy npc's inventory? Thank you very much.
First of all, there is no unidentified flag, it's vice versa - there is identified flag - OIF_IDENTIFIED see here. You can set item's flag by using this: item.item_flag_set(OIF_IDENTIFIED). Essentially if an Item is magical (e.g. has OIF_IS_MAGICAL flag set), then for player it's unidentified (e.g. no OIF_IDENTIFIED flag set) by default. https://www.moddb.com/mods/toeezprotoed