Пример #1
0
        private static void ItemEquipMissileWeapon(ObjectInstance obj, CharacterInstance ch, ObjectInstance mw,
                                                   ObjectInstance dw, ObjectInstance hd, ObjectInstance sd)
        {
            if (!ch.CanDualWield())
            {
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, obj.ItemType == ItemTypes.MissileWeapon,
                                           "You're already wielding a missile weapon."))
            {
                return;
            }

            var strWieldMod = (int)LookupManager.Instance.GetStatMod("Strength", ch.GetCurrentStrength(),
                                                                     StrengthModTypes.Wield);

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

            if (CheckFunctions.CheckIfNotNullObject(ch, dw, "You're already wielding two weapons."))
            {
                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 wields $p.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You wield $p.", ch, obj, null, ToTypes.Character);
            }

            ch.Equip(obj, WearLocations.Wield);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
        }
Пример #2
0
        public static ObjectInstance FindObject(CharacterInstance ch, string argument, bool carryonly)
        {
            var tuple = argument.FirstArgument();
            var arg1  = tuple.Item1;

            tuple = tuple.Item2.FirstArgument();
            var arg2      = tuple.Item1;
            var remainder = tuple.Item2;

            if (arg2.EqualsIgnoreCase("from") && !string.IsNullOrEmpty(remainder))
            {
                tuple     = remainder.FirstArgument();
                arg2      = tuple.Item1;
                remainder = tuple.Item2;
            }

            ObjectInstance obj;

            if (string.IsNullOrEmpty(arg2))
            {
                obj = carryonly ? ch.GetCarriedObject(arg1) : ch.GetObjectOnMeOrInRoom(arg1);
                if (CheckFunctions.CheckIfTrue(ch, obj == null && carryonly, "You do not have that item."))
                {
                    return(null);
                }

                if (obj == null)
                {
                    comm.act(ATTypes.AT_PLAIN, "I see no $T here.", ch, null, arg1, ToTypes.Character);
                    return(null);
                }

                return(obj);
            }

            ObjectInstance container = null;

            if (CheckFunctions.CheckIfTrue(ch,
                                           carryonly && (container = ch.GetCarriedObject(arg2)) == null &&
                                           (container = ch.GetWornObject(arg2)) == null, "You do not have that item."))
            {
                return(null);
            }

            if (!carryonly && (container = ch.GetObjectOnMeOrInRoom(arg2)) == null)
            {
                comm.act(ATTypes.AT_PLAIN, "I see no $T here.", ch, null, arg2, ToTypes.Character);
                return(null);
            }

            if (!container.ExtraFlags.IsSet((int)ItemExtraFlags.Covering) && container.Value.ToList()[1].IsSet(ContainerFlags.Closed))
            {
                comm.act(ATTypes.AT_PLAIN, "The $d is closed.", ch, null, container.Name, ToTypes.Character);
                return(null);
            }

            obj = ch.GetObjectInList(container.Contents, arg1);
            if (obj == null)
            {
                comm.act(ATTypes.AT_PLAIN, container.ExtraFlags.IsSet((int)ItemExtraFlags.Covering)
                    ? "I see nothing like that beneath $p."
                    : "I see nothing like that in $p.", ch, container, null, ToTypes.Character);
            }

            return(obj);
        }
Пример #3
0
        public static bool check_social(CharacterInstance ch, string command, string argument)
        {
            var social = RepositoryManager.Instance.GetEntity <SocialData>(command);

            if (social == null)
            {
                return(false);
            }

            if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.NoEmote), "You are anti-social!"))
            {
                return(true);
            }

            switch (ch.CurrentPosition)
            {
            case PositionTypes.Dead:
                ch.SendTo("Lie still; you are DEAD.");
                return(true);

            case PositionTypes.Incapacitated:
            case PositionTypes.Mortal:
                ch.SendTo("You are hurt far too badly for that.");
                return(true);

            case PositionTypes.Stunned:
                ch.SendTo("You are too stunned to do that.");
                return(true);

            case PositionTypes.Sleeping:
                if (social.Name.EqualsIgnoreCase("snore"))
                {
                    break;
                }
                ch.SendTo("In your dreams, or what?");
                return(true);
            }

            var i = 0;
            // search the room for characters ignoring the social-sender and
            // temporarily remove them from the room until the social has
            // been completed
            var room         = ch.CurrentRoom;
            var ignoringList = new List <CharacterInstance>();

            foreach (var victim in ch.CurrentRoom.Persons)
            {
                if (i == 127)
                {
                    break;
                }
                if (victim.IsIgnoring(ch))
                {
                    if (!ch.IsImmortal() || victim.Trust > ch.Trust)
                    {
                        ignoringList.Add(victim);
                        i++;
                        room.Persons.Remove(victim);
                    }
                    else
                    {
                        victim.SetColor(ATTypes.AT_IGNORE);
                        victim.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name);
                    }
                }
            }

            // TODO
            return(false);
        }
Пример #4
0
        public static void get_obj(CharacterInstance ch, ObjectInstance obj, ObjectInstance container)
        {
            if (CheckFunctions.CheckIfTrue(ch, !obj.WearFlags.IsSet(ItemWearFlags.Take) &&
                                           (ch.Level < GameManager.Instance.SystemData.GetMinimumLevel(PlayerPermissionTypes.LevelGetObjectNoTake)),
                                           "You can't take that."))
            {
                return;
            }

            if (obj.MagicFlags.IsSet(ItemMagicFlags.PKDisarmed) && !ch.IsNpc())
            {
                var timer = ch.GetTimer(TimerTypes.PKilled);
                if (ch.CanPKill() && timer == null)
                {
                    if (ch.Level - obj.Value.ToList()[5] > 5 || obj.Value.ToList()[5] - ch.Level > 5)
                    {
                        ch.SendTo("\r\n&bA godly force freezes your outstretched hand.");
                        return;
                    }

                    obj.MagicFlags.RemoveBit(ItemMagicFlags.PKDisarmed);
                    obj.Value.ToList()[5] = 0;
                }
            }
            else
            {
                ch.SendTo("\r\n&BA godly force freezes your outstretched hand.");
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, obj.ExtraFlags.IsSet((int)ItemExtraFlags.Prototype) && !ch.CanTakePrototype(),
                                           "A godly force prevents you from getting close to it."))
            {
                return;
            }

            if (ch.CarryNumber + obj.ObjectNumber > ch.CanCarryN())
            {
                comm.act(ATTypes.AT_PLAIN, "$d: you can't carry that many items.", ch, null, obj.ShortDescription, ToTypes.Character);
                return;
            }

            var weight = obj.ExtraFlags.IsSet((int)ItemExtraFlags.Covering)
                             ? obj.Weight
                             : obj.GetWeight();

            if (obj.ItemType != ItemTypes.Money)
            {
                if (obj.InObject != null)
                {
                    var tObject     = obj.InObject;
                    var inobj       = 1;
                    var checkweight = tObject.ItemType == ItemTypes.Container &&
                                      tObject.ExtraFlags.IsSet((int)ItemExtraFlags.Magical);

                    while (tObject.InObject != null)
                    {
                        tObject = tObject.InObject;
                        inobj++;

                        checkweight = tObject.ItemType == ItemTypes.Container &&
                                      tObject.ExtraFlags.IsSet((int)ItemExtraFlags.Magical);
                    }

                    if (tObject.CarriedBy == null || tObject.CarriedBy != ch || checkweight)
                    {
                        if (ch.CarryWeight + weight > ch.CanCarryMaxWeight())
                        {
                            comm.act(ATTypes.AT_PLAIN, "$d: you can't carry that much weight.", ch, null, obj.ShortDescription, ToTypes.Character);
                            return;
                        }
                    }
                }
                else if (ch.CarryWeight + weight > ch.CanCarryMaxWeight())
                {
                    comm.act(ATTypes.AT_PLAIN, "$d: you can't carry that much weight.", ch, null, obj.ShortDescription, ToTypes.Character);
                    return;
                }
            }

            if (container != null)
            {
                GetObjectFromContainer(ch, obj, container);
            }
            else
            {
                GetObjectFromRoom(ch, obj);
            }

            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.ClanStoreroom) &&
                (container?.CarriedBy == null))
            {
                foreach (var clan in RepositoryManager.Instance.CLANS.Values)
                {
                    if (clan.StoreRoom == ch.CurrentRoom.ID)
                    {
                        save_clan_storeroom(ch, clan);
                    }
                }
            }

            if (obj.ItemType != ItemTypes.Container)
            {
                ch.CheckObjectForTrap(obj, TrapTriggerTypes.Get);
            }
            if (ch.CharDied())
            {
                return;
            }

            if (obj.ItemType == ItemTypes.Money)
            {
                int amt = obj.Values.NumberOfCoins * obj.Count;
                ch.CurrentCoin += amt;
                obj.Extract();
            }
            else
            {
                obj = obj.AddTo(ch);
            }

            if (ch.CharDied() || handler.obj_extracted(obj))
            {
                return;
            }

            MudProgHandler.ExecuteObjectProg(MudProgTypes.Get, ch, obj);
        }
Пример #5
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);
        }
Пример #6
0
 public static bool CHECK_SUBRESTRICTED(PlayerInstance ch)
 {
     return(!CheckFunctions.CheckIfTrue(ch, ch.SubState == CharacterSubStates.Restricted,
                                        "You cannot use this command from within another command."));
 }