Beispiel #1
0
        private static void ItemWearWield(ObjectInstance obj, CharacterInstance ch, bool replace, ItemWearFlags wearFlag)
        {
            var strWieldMod = (int)LookupManager.Instance.GetStatMod("Strength", ch.GetCurrentStrength(),
                                                                     StrengthModTypes.Wield);

            if (!ch.CouldDualWield())
            {
                if (!ch.RemoveFrom(WearLocations.WieldMissile, replace) ||
                    !ch.RemoveFrom(WearLocations.Wield, replace))
                {
                    return;
                }
            }
            else
            {
                var tobj = ch.GetEquippedItem(WearLocations.Wield);
                var mw   = ch.GetEquippedItem(WearLocations.WieldMissile);
                var dw   = ch.GetEquippedItem(WearLocations.DualWield);
                var hd   = ch.GetEquippedItem(WearLocations.Hold);
                var sd   = ch.GetEquippedItem(WearLocations.Shield);

                if (CheckFunctions.CheckIfTrue(ch, hd != null && sd != null,
                                               "You are already holding something and wearing a shield."))
                {
                    return;
                }

                if (tobj != null)
                {
                    if (!ch.CanDualWield())
                    {
                        return;
                    }

                    if (CheckFunctions.CheckIfTrue(ch,
                                                   obj.GetWeight() + tobj.GetWeight() > strWieldMod, "It is too heavy for you to wield."))
                    {
                        return;
                    }

                    if (CheckFunctions.CheckIfTrue(ch, hd != null || sd != null,
                                                   "You're already wielding a weapon AND holding something."))
                    {
                        return;
                    }

                    if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                    {
                        comm.act(ATTypes.AT_ACTION, "$n dual-wields $p.", ch, obj, null, ToTypes.Room);
                        comm.act(ATTypes.AT_ACTION, "You dual-wield $p.", ch, obj, null, ToTypes.Character);
                    }

                    ch.Equip(obj, wearFlag == ItemWearFlags.MissileWield
                        ? WearLocations.WieldMissile : WearLocations.DualWield);
                    MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                    return;
                }

                if (mw != null)
                {
                    ItemEquipMissileWeapon(obj, ch, mw, dw, hd, sd);
                    return;
                }
            }

            if (CheckFunctions.CheckIfTrue(ch, obj.GetWeight() > strWieldMod, "It is too heavy for you to wield."))
            {
                return;
            }

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n wields $p.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You wield $p.", ch, obj, null, ToTypes.Character);
            }

            ch.Equip(obj, wearFlag == ItemWearFlags.MissileWield ? WearLocations.WieldMissile : WearLocations.Wield);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
        }