Lacrc, I used the 2nd code snippet you mentioned and modified it with and additional check for our UNIQUE_ITEM flag. In addition to this, an, "int i;" insertion at the beginning of the function was required. I inserted this check prior to any other checks included in the code so that it checks for duplicate uniques prior to anything else.
I tested this code and found that it performed exactly as I desired without any issues. It prevented me from wearing duplicate uniques, but it allowed me to continue to wear duplicate non-uniques. Additionally, this performed as I had hoped in that it was a global check for all player eq slots (Rings, neck, ears, wield, hold).
I included a bit of the code here for you to see, starting at the beginning of the void function.
Code:
void perform_wear(struct char_data *ch, struct obj_data *obj, int where)
{
int i;
/*
* ITEM_WEAR_TAKE is used for objects that do not require special bits
* to be put into that position (e.g. you can hold any object, not just
* an object with a HOLD bit.)
*/
int wear_bitvectors[] = {
ITEM_WEAR_TAKE, ITEM_WEAR_FINGER, ITEM_WEAR_FINGER, ITEM_WEAR_NECK,
ITEM_WEAR_NECK, ITEM_WEAR_BODY, ITEM_WEAR_HEAD, ITEM_WEAR_LEGS,
ITEM_WEAR_FEET, ITEM_WEAR_HANDS, ITEM_WEAR_ARMS, ITEM_WEAR_SHIELD,
ITEM_WEAR_ABOUT, ITEM_WEAR_WAIST, ITEM_WEAR_WRIST, ITEM_WEAR_WRIST,
ITEM_WEAR_WIELD, ITEM_WEAR_TAKE, ITEM_WEAR_EAR, ITEM_WEAR_EAR, ITEM_WEAR_MASK
};
const char *already_wearing[] = {
"You're already using a light.\r\n",
"YOU SHOULD NEVER SEE THIS MESSAGE. PLEASE REPORT.\r\n",
"You're already wearing something on both of your ring fingers.\r\n",
"YOU SHOULD NEVER SEE THIS MESSAGE. PLEASE REPORT.\r\n",
"You can't wear anything else around your neck.\r\n",
"You're already wearing something on your body.\r\n",
"You're already wearing something on your head.\r\n",
"You're already wearing something on your legs.\r\n",
"You're already wearing something on your feet.\r\n",
"You're already wearing something on your hands.\r\n",
"You're already wearing something on your arms.\r\n",
"You're already using a shield.\r\n",
"You're already wearing something about your body.\r\n",
"You already have something around your waist.\r\n",
"YOU SHOULD NEVER SEE THIS MESSAGE. PLEASE REPORT.\r\n",
"You're already wearing something around both of your wrists.\r\n",
"You're already wielding a weapon.\r\n",
"You're already holding something.\r\n",
"YOU SHOULD NEVER SEE THIS MESSAGE. PLEASE REPORT.\r\n",
"You're already wearing something in both ears.\r\n",
"You're already wearing something as a mask.\r\n"
};
/* lacrc from TBAMud Forums credits for core code, modified for uniques: Duplicate/Unique wear prevention */
for (i = 0; i < NUM_WEARS; i++) {
if (GET_EQ(ch, i) && (OBJ_FLAGGED(obj, ITEM_UNIQUE)) && GET_OBJ_VNUM(GET_EQ(ch, i)) == GET_OBJ_VNUM(obj)) {
send_to_char(ch, "You already have one of those equipped.\r\n");
return;
}
}
/* first, make sure that the wear position is valid. */
if (!CAN_WEAR(ch, obj, wear_bitvectors[where])) {
act("You can't wear $p there.", FALSE, ch, obj, 0, TO_CHAR);
return;
}
/* for neck, finger, and wrist, try pos 2 if pos 1 is already full */
if ((where == WEAR_FINGER_R) || (where == WEAR_NECK_1) || (where == WEAR_WRIST_R) || (where == WEAR_EAR_R))
if (GET_EQ(ch, where))
where++;