예제 #1
0
파일: Object.cs 프로젝트: ramseur/ModernMUD
        public static void GetObject(CharData ch, Object obj, Object container)
        {
            if (!obj.HasWearFlag(ObjTemplate.WEARABLE_CARRY))
            {
                ch.SendText("You can't pick that up.\r\n");
                return;
            }

            if (obj._itemType != ObjTemplate.ObjectType.money)
            {
                if (ch.CarryWeight + obj.GetWeight() > ch.MaxCarryWeight())
                {
                    SocketConnection.Act("$p&n is quite literally the &+Ystraw&n that would break the &n&+ycamel&n's back.", ch, obj, null, SocketConnection.MessageTarget.character);
                    return;
                }
            }

            if (container != null)
            {
                SocketConnection.Act("You get $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n retrieves $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.room);
                obj.RemoveFromObject();
                // Fix for corpse EQ dupe on crash
                if (container._itemType == ObjTemplate.ObjectType.pc_corpse)
                {
                    Database.CorpseList.Save();
                }
            }
            else
            {
                SocketConnection.Act("You get $p&n.", ch, obj, container, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n picks up $p&n.", ch, obj, container, SocketConnection.MessageTarget.room);
                obj.RemoveFromRoom();
            }

            if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil())
            {
                SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L.  Ouch!&n", ch, obj, null,
                     SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room);
                Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic);
                obj.AddToRoom(ch.InRoom);
                return;
            }

            if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil())
            {
                SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L.  Ouch!&n", ch, obj, null,
                     SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room);
                Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic);
                obj.AddToRoom(ch.InRoom);
                return;
            }

            if (obj.HasFlag(ObjTemplate.ITEM_ANTI_GOOD) && ch.IsGood())
            {
                SocketConnection.Act("&+LYou are &n&+rconsumed&+L by &+Rfire&+L and &+Ldespair&n from $p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&+L is &n&+rengulfed&+L by an abundancy of &+Rflames&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room);
                Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic);
                obj.AddToRoom(ch.InRoom);
                return;
            }

            if (obj._itemType == ObjTemplate.ObjectType.money)
            {
                int amount = obj._values[0] + obj._values[1] + obj._values[2] + obj._values[3];
                ch.ReceiveCopper(obj._values[0]);
                ch.ReceiveSilver(obj._values[1]);
                ch.ReceiveGold(obj._values[2]);
                ch.ReceivePlatinum(obj._values[3]);

                if (amount > 1)
                {
                    string text = String.Format("You pick up");
                    string text2;
                    if (obj._values[3] > 0)
                    {
                        text2 = String.Format(" {0} &+Wplatinum&n", obj._values[3]);
                        if (obj._values[0] > 0 || obj._values[1] > 0 || obj._values[2] > 0)
                        {
                            text2 += ",";
                        }
                        text += text2;
                    }
                    if (obj._values[2] > 0)
                    {
                        text2 = String.Format(" {0} &+Ygold&n", obj._values[2]);
                        if (obj._values[0] > 0 || obj._values[1] > 0)
                        {
                            text2 += ",";
                        }
                        text += text2;
                    }
                    if (obj._values[1] > 0)
                    {
                        text2 = String.Format(" {0} &n&+wsilver&n", obj._values[1]);
                        if (obj._values[0] > 0)
                        {
                            text2 += ",";
                        }
                        text += text2;
                    }
                    if (obj._values[0] > 0)
                    {
                        text2 = String.Format(" {0} &n&+ycopper&n", obj._values[0]);
                        text += text2;
                    }
                    text += " coins.\r\n";
                    ch.SendText(text);
                }

                obj.RemoveFromWorld();
            }
            else
            {
                obj.ObjToChar(ch);
                // Prevent item duplication.
                CharData.SavePlayer(ch);
            }

            return;
        }
예제 #2
0
파일: Object.cs 프로젝트: ramseur/ModernMUD
        public static string WearString(Object obj)
        {
            string text = String.Empty;
            int count;

            for (count = 0; BitvectorFlagType.WearFlags[count].BitvectorData; count++)
            {
                if (obj.HasWearFlag(BitvectorFlagType.WearFlags[count].BitvectorData))
                {
                    text += " ";
                    text += BitvectorFlagType.WearFlags[count].Name;
                }
            }

            return (!String.IsNullOrEmpty(text)) ? text + 1 : "none";
        }
예제 #3
0
파일: Object.cs 프로젝트: ramseur/ModernMUD
        /// <summary>
        /// Recoding of the WearObject function into a table-based system which is fairly
        /// complex, but easy to maintain via the table. Bitshifting is used to check
        /// each wear location for a piece of equipment.
        /// 
        /// (not enabled)
        /// 
        /// TODO: Enable/finish this or remove it. See WearObject for what it is intended
        /// to replace.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="obj"></param>
        /// <param name="replaceExisting"></param>
        static void NewWearObject(CharData ch, ref Object obj, bool replaceExisting)
        {
            int count;

            for (count = 0; count < WearData.Table.Length; ++count)
            {
                if (obj.HasWearFlag(new Bitvector(0, (1 << count))))
                {
                    if (WearData.Table[count].BodyPartNeeded == 0 ||
                            Macros.IsSet((int)Race.RaceList[ch.GetRace()].BodyParts, WearData.Table[count].BodyPartNeeded))
                    {
                        if (WearData.Table[count].RacesNotAllowed == -1 ||
                                ch.GetRace() != WearData.Table[(1 << count)].RacesNotAllowed)
                        {
                            bool found = false;
                            int wearLoc = 0;
                            foreach (int wear in WearData.Table[count].WearLocations)
                            {
                                if (wear != 0 && !ch.RemoveObject((ObjTemplate.WearLocation)wear, replaceExisting))
                                {
                                    continue;
                                }
                                wearLoc = wear;
                                found = true;
                                break;
                            }
                            if (!found)
                            {
                                return;
                            }
                            SocketConnection.Act(WearData.Table[(1 << count)].WearMessageToWearer, ch, obj, null, SocketConnection.MessageTarget.character);
                            SocketConnection.Act(WearData.Table[(1 << count)].WearMessageToRoom, ch, obj, null, SocketConnection.MessageTarget.room);
                            // Need to allow for multiple wear locations rather than just picking the first one.
                            ch.EquipObject(ref obj, (ObjTemplate.WearLocation)wearLoc);
                            return;

                        }
                        ch.SendText("Your race cannot wear that type of equipment.\r\n");
                        return;
                    }
                    ch.SendText("The design of your body prevents you from using that.\r\n");
                    return;
                }
            }
        }
예제 #4
0
파일: Object.cs 프로젝트: ramseur/ModernMUD
        /// <summary>
        /// Wear an object with optional replacement of existing worn object in
        /// the same location.
        /// 
        /// TODO: Finish NewWearObject, update the wear table with the strings in this
        /// function, and remove this function.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="obj"></param>
        /// <param name="replaceExisting"></param>
        public static void WearObject(CharData ch, Object obj, bool replaceExisting)
        {
            if (!obj.IsWearableBy(ch))
                return;

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_TAIL)
                    && Macros.IsSet((int)Race.RaceList[ch.GetRace()].BodyParts, (int)Race.Parts.tail))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.tail, replaceExisting))
                    return;
                SocketConnection.Act("You wear $p&n on your &+Ltail&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n wears $p&n on $s &+Ltail&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.tail);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_HORNS)
                    && Macros.IsSet((int)Race.RaceList[ch.GetRace()].BodyParts, (int)Race.Parts.horns))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.horns, replaceExisting))
                    return;
                SocketConnection.Act("You wear $p&n on your &+Whorns&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n wears $p&n on $s &+Whorns&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.horns);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_EYES))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.eyes, replaceExisting))
                    return;
                SocketConnection.Act("You place $p&n over your eyes.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n places $p&n over $s eyes.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.eyes);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_FINGER) && ch.GetRace() != Race.RACE_THRIKREEN)
            {
                if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.finger_left)
                        && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.finger_right)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.finger_left, replaceExisting)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.finger_right, replaceExisting))
                    return;

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.finger_left))
                {
                    SocketConnection.Act("You slip $p&n onto a finger of your left hand.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n slips $p&n onto a finger of $s left hand.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.finger_left);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.finger_right))
                {
                    SocketConnection.Act("You slide $p&n onto a finger of your right hand.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n slides $p&n onto a finger of $s right hand.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.finger_right);
                    return;
                }

                Log.Error("Object.WearObject: no free finger.", 0);
                ch.SendText("Anymore rings and you would severly hinder finger movement.\r\n");
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_NECK))
            {
                if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.neck_one)
                        && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.neck_two)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.neck_one, replaceExisting)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.neck_two, replaceExisting))
                    return;

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.neck_one))
                {
                    SocketConnection.Act("You place $p&n around your neck.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n wears $p&n around $s neck.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.neck_one);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.neck_two))
                {
                    SocketConnection.Act("You wear $p&n around your neck.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n places $p&n around $s neck.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.neck_two);
                    return;
                }

                Log.Error("Object.WearObject: no free neck.", 0);
                ch.SendText("You can't fit anything else around your neck.\r\n");
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_BODY) && ch.GetRace() != Race.RACE_THRIKREEN)
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.body, replaceExisting))
                    return;
                SocketConnection.Act("You slide your body into $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n wears $p&n on $s body.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.body);
                return;
            }
            // Added check for mino and head gear prevention due to horns
            if (obj.HasWearFlag(ObjTemplate.WEARABLE_HEAD))
            {
                if (ch.GetRace() != Race.RACE_MINOTAUR)
                {
                    if (!ch.RemoveObject(ObjTemplate.WearLocation.head, replaceExisting))
                        return;
                    SocketConnection.Act("You don $p&n on your head.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n places $p&n on $s head.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.head);
                    return;
                }
                SocketConnection.Act("Your &+Lhorns&n prevent you from wearing $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n foolishly attempts to place $p&n on over $s &+Lhorns&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_LEGS)
                    && ch.GetRace() != Race.RACE_CENTAUR)
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.legs, replaceExisting))
                    return;
                SocketConnection.Act("You pull $p&n onto your legs.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n slides $s legs into $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.legs);
                return;
            }

            // Added Minotaur to the Following ObjIndex.WEARABLE_FEET check
            // Check some over the syntax, Vey, if you wouldn't mind.
            if (obj.HasWearFlag(ObjTemplate.WEARABLE_FEET))
            {
                if (ch.GetRace() != Race.RACE_CENTAUR && ch.GetRace() != Race.RACE_MINOTAUR && ch.GetRace() != Race.RACE_THRIKREEN)
                {
                    if (!ch.RemoveObject(ObjTemplate.WearLocation.feet, replaceExisting))
                        return;
                    SocketConnection.Act("You wear $p&n on your feet.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n wears $p&n on $s feet.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.feet);
                    return;
                }
                if (ch.GetRace() != Race.RACE_THRIKREEN)
                {
                    SocketConnection.Act("Your &+Lhooves&n prevent you from wearing $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n foolishly attempts to place $p&n on $s &+Lhooves&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                    return;
                }
                SocketConnection.Act("Your underdeveloped feet prevent you from wearing $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n foolishly attempts to place $p&n on $s feet.", ch, obj, null, SocketConnection.MessageTarget.room);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_HANDS))
            {
                if (ch.GetRace() != Race.RACE_THRIKREEN)
                {
                    if (!ch.RemoveObject(ObjTemplate.WearLocation.hands, replaceExisting))
                        return;
                    SocketConnection.Act("You wear $p&n on your hands.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n pulls $p&n onto $s hands.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.hands);
                    return;
                }
                if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hands)
                    && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hands_lower)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.hands, replaceExisting)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.hands_lower, replaceExisting))
                    return;

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hands))
                {
                    SocketConnection.Act("You wear $p&n on your hands.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n pulls $p&n onto $s hands.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.hands);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hands_lower))
                {
                    SocketConnection.Act("You wear $p&n on your hands.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n pulls $p&n onto $s hands.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.hands_lower);
                    return;
                }
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_ARMS))
            {
                if (ch.GetRace() != Race.RACE_THRIKREEN)
                {
                    if (!ch.RemoveObject(ObjTemplate.WearLocation.arms, replaceExisting))
                        return;
                    SocketConnection.Act("You slip your arms into $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n slides $p&n over $s arms.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.arms);
                    return;
                }
                if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.arms)
                    && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.arms_lower)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.arms, replaceExisting)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.arms_lower, replaceExisting))
                    return;

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.arms))
                {
                    SocketConnection.Act("You slip your arms into $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n slides $p&n over $s arms.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.arms);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.arms_lower))
                {
                    SocketConnection.Act("You slip your arms into $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n slides $p&n over $s arms.", ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.arms_lower);
                    return;
                }

                Log.Error("WearObject: no free ear.", 0);
                ch.SendText("You already wear an earring in each ear.\r\n");
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_ONBACK))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.on_back, replaceExisting))
                    return;
                SocketConnection.Act("You strap $p&n to your back.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n straps $p&n to $s back.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.on_back);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_QUIVER))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.quiver, replaceExisting))
                    return;
                SocketConnection.Act("You adjust $p&n across your shoulders.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n straps $p&n across $s shoulders.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.quiver);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_ABOUT))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.about_body, replaceExisting))
                    return;
                SocketConnection.Act("You drape $p&n about your body.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n wraps $p&n about $s body.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.about_body);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_WAIST))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.waist, replaceExisting))
                    return;
                SocketConnection.Act("You secure $p&n about your waist.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n secures $p&n about $s waist.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.waist);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_FACE))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.face, replaceExisting))
                    return;
                SocketConnection.Act("You place $p&n over your face.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n covers $s his face with $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.face);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_BADGE))
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.badge, replaceExisting))
                    return;
                SocketConnection.Act("You pin $p&n over your right breast.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n pins $p&n over $s right breast.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.badge);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_WRIST))
            {
                if (ch.GetRace() != Race.RACE_THRIKREEN)
                {
                    if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_left)
                            && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_right)
                            && !ch.RemoveObject(ObjTemplate.WearLocation.wrist_left, replaceExisting)
                            && !ch.RemoveObject(ObjTemplate.WearLocation.wrist_right, replaceExisting))
                        return;

                    if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_left))
                    {
                        SocketConnection.Act("You wear $p&n around your left wrist.",
                             ch, obj, null, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$n&n wears $p&n around $s left wrist.",
                             ch, obj, null, SocketConnection.MessageTarget.room);
                        ch.EquipObject(ref obj, ObjTemplate.WearLocation.wrist_left);
                        return;
                    }

                    if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_right))
                    {
                        SocketConnection.Act("You wear $p&n about your right wrist.",
                             ch, obj, null, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$n&n wears $p&n about $s right wrist.",
                             ch, obj, null, SocketConnection.MessageTarget.room);
                        ch.EquipObject(ref obj, ObjTemplate.WearLocation.wrist_right);
                        return;
                    }

                    Log.Error("Object.WearObject: no free wrist.", 0);
                    ch.SendText("You already wear something upon both wrists.\r\n");
                    return;
                }
                if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_left)
                    && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_right)
                    && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_lower_left)
                    && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_lower_right)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.wrist_left, replaceExisting)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.wrist_right, replaceExisting)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.wrist_lower_left, replaceExisting)
                    && !ch.RemoveObject(ObjTemplate.WearLocation.wrist_lower_right, replaceExisting))
                    return;

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_left))
                {
                    SocketConnection.Act("You wear $p&n around your left wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n wears $p&n around $s left wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.wrist_left);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_right))
                {
                    SocketConnection.Act("You wear $p&n about your right wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n wears $p&n about $s right wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.wrist_right);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_lower_left))
                {
                    SocketConnection.Act("You wear $p&n around your lower left wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n wears $p&n around $s lower left wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.wrist_lower_left);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.wrist_lower_right))
                {
                    SocketConnection.Act("You wear $p&n about your lower right wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n wears $p&n about $s lower right wrist.",
                                         ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.wrist_lower_right);
                    return;
                }

                Log.Error("Object.WearObject: no free wrist.", 0);
                ch.SendText("You already wear something upon all four wrists.\r\n");
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_EAR) && ch.GetRace() != Race.RACE_THRIKREEN)
            {
                if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.ear_left)
                        && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.ear_right)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.ear_left, replaceExisting)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.ear_right, replaceExisting))
                    return;

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.ear_left))
                {
                    SocketConnection.Act("You wear $p&n in your left ear.",
                         ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n hangs $p&n from $s left ear.",
                         ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.ear_left);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.ear_right))
                {
                    SocketConnection.Act("You hang $p&n from your right ear.",
                         ch, obj, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n wears $p&n in $s right ear.",
                         ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.ear_right);
                    return;
                }

                Log.Error("Object.WearObject: no free ear.", 0);
                ch.SendText("You already wear an earring in each ear.\r\n");
                return;
            }

            // Moved these before belt check so as to avoid weapons flagged both
            // wieldable and wear_belt from defaulting to belt position

            // The following code looks way to repetitive, leading one
            // to believe it can be highly optimized.
            if (obj._itemType == ObjTemplate.ObjectType.light)
            {
                EquipInHand(ch, obj, EQUIP_LIGHT);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_WIELD) && obj._itemType == ObjTemplate.ObjectType.weapon)
            {
                EquipInHand(ch, obj, EQUIP_WIELD);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_SHIELD))
            {
                EquipInHand(ch, obj, EQUIP_SHIELD);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_HOLD))
            {
                EquipInHand(ch, obj, EQUIP_HOLD);
                return;
            }

            // Only two belt slots for now, should be three.
            if (obj.HasWearFlag(ObjTemplate.WEARABLE_ATTACH_BELT))
            {
                Object obj2;
                string text;

                if (!(obj2 = GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.waist)))
                {
                    ch.SendText("You don't have a &n&+ybelt&n to attach it to.\r\n");
                    return;
                }

                if (GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.belt_attach_one)
                        && GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.belt_attach_two)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.belt_attach_one, replaceExisting)
                        && !ch.RemoveObject(ObjTemplate.WearLocation.belt_attach_two, replaceExisting))
                    return;

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.belt_attach_one))
                {
                    text = String.Format("You attach $p&n to {0}&n.", obj2._shortDescription);
                    SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character);
                    text = String.Format("$n&n attaches $p&n to {0}&n.", obj2._shortDescription);
                    SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.belt_attach_one);
                    return;
                }

                if (!GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.belt_attach_two))
                {
                    text = String.Format("You attach $p&n to {0}&n.", obj2._shortDescription);
                    SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character);
                    text = String.Format("$n&n attaches $p&n to {0}&n.", obj2._shortDescription);
                    SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.room);
                    ch.EquipObject(ref obj, ObjTemplate.WearLocation.belt_attach_two);
                    return;
                }

                Log.Error("Wear_obj: no free belt slot.", 0);
                ch.SendText("Your &n&+ybelt&n is already full.\r\n");
                return;
            }

            /* This will be fixed when we have something better to check against. */
            if (obj.HasWearFlag(ObjTemplate.WEARABLE_HORSE_BODY)
                    && ch.GetRace() == Race.RACE_CENTAUR)
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.horse_body, replaceExisting))
                    return;
                SocketConnection.Act("You strap $p&n onto your body.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n straps $p&n onto $s body.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.horse_body);
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_NOSE) && ch.GetRace() == Race.RACE_MINOTAUR)
            {
                if (!ch.RemoveObject(ObjTemplate.WearLocation.nose, replaceExisting))
                    return;
                SocketConnection.Act("You attach $p&n to your nose.", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n wears $p&n in $s nose.", ch, obj, null, SocketConnection.MessageTarget.room);
                ch.EquipObject(ref obj, ObjTemplate.WearLocation.nose);
                return;
            }

            if (replaceExisting)
                ch.SendText("You can't wear, wield, or hold that.\r\n");

            return;
        }