示例#1
0
        private static void ItemWearWaist(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (CheckFunctions.CheckIfTrue(ch, !ch.CanWearLayer(obj, WearLocations.Waist),
                                           "It won't fit overtop of what you're already wearing."))
            {
                return;
            }

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n wears $p about $s waist.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You wear $p about your waist.", ch, obj, null, ToTypes.Character);
            }

            ch.Equip(obj, WearLocations.Waist);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
        }
示例#2
0
        public static bool RemoveFrom(this CharacterInstance ch, WearLocations location, bool replace)
        {
            var obj = ch.GetEquippedItem(location);

            if (obj == null)
            {
                return(true);
            }

            if (!replace && 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(false);
            }

            if (!replace)
            {
                return(false);
            }

            if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.NoRemove))
            {
                comm.act(ATTypes.AT_PLAIN, "You can't remove $p.", ch, obj, null, ToTypes.Character);
                return(false);
            }

            var tObj = ch.GetEquippedItem(WearLocations.DualWield);

            if (obj == ch.GetEquippedItem(WearLocations.Wield) && tObj != null)
            {
                tObj.WearLocation = WearLocations.Wield;
            }

            ch.Unequip(obj);

            comm.act(ATTypes.AT_ACTION, "$n stop using $p.", ch, obj, null, ToTypes.Room);
            comm.act(ATTypes.AT_ACTION, "You stop using $p.", ch, obj, null, ToTypes.Character);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Remove, ch, obj);

            return(ch.GetEquippedItem(location) == null);
        }
示例#3
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);
        }
示例#4
0
        private static void DropObject(CharacterInstance ch, string firstArg)
        {
            var obj = ch.GetCarriedObject(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, obj, "You do not have that item."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !ch.CanDrop(obj), "You can't let go of it."))
            {
                return;
            }

            obj.Split();
            comm.act(ATTypes.AT_ACTION, "$n drops $p.", ch, obj, null, ToTypes.Room);
            comm.act(ATTypes.AT_ACTION, "You drop $p.", ch, obj, null, ToTypes.Character);

            obj.RemoveFrom();
            obj = ch.CurrentRoom.AddTo(obj);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Drop, ch, obj);

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

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

            if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Drop))
            {
                save.save_char_obj(ch);
            }
        }
示例#5
0
        private static void ItemWearHold(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.DualWield) != null ||
                (ch.GetEquippedItem(WearLocations.Wield) != null &&
                 (ch.GetEquippedItem(WearLocations.WieldMissile) != null ||
                  ch.GetEquippedItem(WearLocations.Shield) != null)))
            {
                ch.SendTo(
                    ch.GetEquippedItem(WearLocations.Shield) != null
                        ? "You cannot hold something while using a weapon and a shield!"
                        : "You cannot hold something AND two weapons!");
                return;
            }

            if (!ch.RemoveFrom(WearLocations.Hold, replace))
            {
                return;
            }

            if (obj.ItemType == ItemTypes.Wand ||
                obj.ItemType == ItemTypes.Staff ||
                obj.ItemType == ItemTypes.Food ||
                obj.ItemType == ItemTypes.Cook ||
                obj.ItemType == ItemTypes.Pill ||
                obj.ItemType == ItemTypes.Potion ||
                obj.ItemType == ItemTypes.Scroll ||
                obj.ItemType == ItemTypes.DrinkContainer ||
                obj.ItemType == ItemTypes.Blood ||
                obj.ItemType == ItemTypes.Pipe ||
                obj.ItemType == ItemTypes.Herb ||
                obj.ItemType == ItemTypes.Key ||
                !MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n holds $p in $s hands.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You hold $p in your hands.", ch, obj, null, ToTypes.Character);
            }

            ch.Equip(obj, WearLocations.Hold);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
        }
示例#6
0
        private static void ItemWearNeck(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.Neck_1) != null &&
                ch.GetEquippedItem(WearLocations.Neck_2) != null &&
                !ch.RemoveFrom(WearLocations.Neck_1, replace) &&
                !ch.RemoveFrom(WearLocations.Neck_2, replace))
            {
                return;
            }

            if (ch.GetEquippedItem(WearLocations.Neck_1) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n wears $p around $s neck.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You wear $p around your neck.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.Neck_1);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            if (ch.GetEquippedItem(WearLocations.Neck_2) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n wears $p around $s neck.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You wear $p around your neck.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.Neck_2);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            ch.SendTo("You already wear two neck items.");
        }
示例#7
0
        private static void ItemWearAnkle(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.LeftAnkle) != null &&
                ch.GetEquippedItem(WearLocations.RightAnkle) != null &&
                !ch.RemoveFrom(WearLocations.LeftAnkle, replace) &&
                !ch.RemoveFrom(WearLocations.RightAnkle, replace))
            {
                return;
            }

            if (ch.GetEquippedItem(WearLocations.LeftAnkle) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n fit $p around $s left ankle.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You fit $p around your left ankle.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.LeftAnkle);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            if (ch.GetEquippedItem(WearLocations.RightAnkle) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n fit $p around $s right ankle.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You fit $p around your right ankle.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.RightAnkle);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            ch.SendTo("You already wear two ankle items.");
        }
示例#8
0
        private static void ItemWearFinger(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.LeftFinger) != null &&
                ch.GetEquippedItem(WearLocations.RightFinger) != null &&
                !ch.RemoveFrom(WearLocations.LeftFinger, replace) &&
                !ch.RemoveFrom(WearLocations.RightFinger, replace))
            {
                return;
            }

            if (ch.GetEquippedItem(WearLocations.LeftFinger) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n slips $s left finger into $p.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You slip your left finger into $p.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.LeftFinger);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            if (ch.GetEquippedItem(WearLocations.RightFinger) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n slips $s right finger into $p.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You slip your right finger into $p.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.RightFinger);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            ch.SendTo("You already wear something on both fingers.");
        }
示例#9
0
        private static void DrinkFromFountain(CharacterInstance ch, ObjectInstance obj)
        {
            if (obj.Values.Quantity <= 0)
            {
                obj.Values.QUantity = GetMaximumCondition();
            }

            LiquidData liquid = RepositoryManager.Instance.LIQUIDS.Get(obj.Values.LiquidID) ??
                                RepositoryManager.Instance.LIQUIDS.Get(0);

            if (!ch.IsNpc())
            {
                var pch = (PlayerInstance)ch;
                if (obj.Values.LiquidID != 0)
                {
                    pch.GainCondition(ConditionTypes.Thirsty, liquid.GetMod(ConditionTypes.Thirsty));
                    pch.GainCondition(ConditionTypes.Full, liquid.GetMod(ConditionTypes.Full));
                    pch.GainCondition(ConditionTypes.Drunk, liquid.GetMod(ConditionTypes.Drunk));

                    if (ch.IsVampire())
                    {
                        pch.GainCondition(ConditionTypes.Bloodthirsty, liquid.GetMod(ConditionTypes.Bloodthirsty));
                    }
                }
                else if (obj.Values.LiquidID == 0)
                {
                    pch.PlayerData.ConditionTable[ConditionTypes.Thirsty] = GetMaximumCondition();
                }
            }

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n drinks from the fountain.", ch, null, null, ToTypes.Room);
                ch.SendTo("You take a long thirst quenching drink.");
            }
        }
示例#10
0
        public static void ProcessUpdate(this MobileInstance ch, IRepositoryManager dbManager)
        {
            handler.set_cur_char(ch);

            if (ch.CurrentRoom == null || ch.IsAffected(AffectedByTypes.Charm) ||
                ch.IsAffected(AffectedByTypes.Paralysis))
            {
                return;
            }

            if (ch.MobIndex.ID == VnumConstants.MOB_VNUM_ANIMATED_CORPSE &&
                !ch.IsAffected(AffectedByTypes.Charm))
            {
                if (ch.CurrentRoom.Persons.Any())
                {
                    comm.act(ATTypes.AT_MAGIC, "$n returns to the dust from whence $e came.", ch, null, null,
                             ToTypes.Room);
                }

                if (ch.IsNpc())
                {
                    ch.Extract(true);
                }
                return;
            }

            if (!ch.Act.IsSet((int)ActFlags.Running) && !ch.Act.IsSet((int)ActFlags.Sentinel) && ch.CurrentFighting == null &&
                ch.CurrentHunting == null)
            {
                Macros.WAIT_STATE(ch, 2 * GameConstants.GetSystemValue <int>("PulseViolence"));
                track.hunt_victim(ch);
                return;
            }

            if (!ch.Act.IsSet((int)ActFlags.Running) && ch.SpecialFunction != null)
            {
                if (ch.SpecialFunction.Value.Invoke(ch, dbManager))
                {
                    return;
                }
                if (ch.CharDied())
                {
                    return;
                }
            }

            if (ch.MobIndex.HasProg(MudProgTypes.Script))
            {
                MudProgHandler.ExecuteMobileProg(MudProgTypes.Script, ch);
                return;
            }

            if (ch != handler.CurrentCharacter)
            {
                // TODO BUG: ch does not equal CurrentCharacter after spec_fun");
                return;
            }

            if (ch.CurrentPosition != PositionTypes.Standing)
            {
                return;
            }

            if (ch.Act.IsSet((int)ActFlags.Mounted))
            {
                if (ch.Act.IsSet((int)ActFlags.Aggressive) || ch.Act.IsSet((int)ActFlags.MetaAggr))
                {
                    Emote.do_emote(ch, "snarls and growls.");
                }
                return;
            }

            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe) &&
                (ch.Act.IsSet((int)ActFlags.Aggressive) || ch.Act.IsSet((int)ActFlags.MetaAggr)))
            {
                Emote.do_emote(ch, "glares around and snarls.");
            }

            if (ch.CurrentRoom.Area.NumberOfPlayers > 0)
            {
                MudProgHandler.ExecuteMobileProg(MudProgTypes.Random, ch);
                if (ch.CharDied())
                {
                    return;
                }
                if ((int)ch.CurrentPosition < (int)PositionTypes.Standing)
                {
                    return;
                }
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Hour, ch);
            if (ch.CharDied())
            {
                return;
            }

            MudProgHandler.ExecuteRoomProg(MudProgTypes.Hour, ch);
            if (ch.CharDied())
            {
                return;
            }

            if ((int)ch.CurrentPosition < (int)PositionTypes.Standing)
            {
                return;
            }

            if (ch.Act.IsSet((int)ActFlags.Scavenger) && ch.CurrentRoom.Contents.Any() && SmaugRandom.Bits(2) == 0)
            {
                Scavenge(ch);
            }

            if (!ch.Act.IsSet((int)ActFlags.Running) &&
                !ch.Act.IsSet((int)ActFlags.Sentinel) &&
                !ch.Act.IsSet((int)ActFlags.Prototype) &&
                !ch.Act.IsSet((int)ActFlags.StayArea))
            {
                var door = SmaugRandom.Bits(5);
                if (door > 9)
                {
                    return;
                }

                var exit = ch.CurrentRoom.GetExit(door);
                if (exit == null)
                {
                    return;
                }

                if (exit.Flags.IsSet(ExitFlags.Window) || exit.Flags.IsSet(ExitFlags.Closed))
                {
                    return;
                }

                var room = exit.GetDestination();
                if (room == null)
                {
                    return;
                }

                if (room.Flags.IsSet(RoomFlags.NoMob) || room.Flags.IsSet(RoomFlags.Death))
                {
                    return;
                }

                if (room.Area != ch.CurrentRoom.Area)
                {
                    return;
                }

                var retcode = Move.move_char(ch, exit, 0);
                if (ch.CharDied())
                {
                    return;
                }
                if (retcode != ReturnTypes.None || ch.Act.IsSet((int)ActFlags.Sentinel) ||
                    (int)ch.CurrentPosition < (int)PositionTypes.Standing)
                {
                    return;
                }
            }

            if (ch.CurrentHealth < ch.MaximumHealth / 2)
            {
                var door = SmaugRandom.Bits(4);
                if (door > 9)
                {
                    return;
                }

                var exit = ch.CurrentRoom.GetExit(door);
                if (exit == null)
                {
                    return;
                }

                if (exit.Flags.IsSet(ExitFlags.Window) || exit.Flags.IsSet(ExitFlags.Closed))
                {
                    return;
                }

                var room = exit.GetDestination();
                if (room == null)
                {
                    return;
                }

                if (room.Flags.IsSet(RoomFlags.NoMob) || room.Flags.IsSet(RoomFlags.Death))
                {
                    return;
                }

                var found = false;
                foreach (var rch in ch.CurrentRoom.Persons)
                {
                    if (ch.IsFearing(rch))
                    {
                        var buf = string.Empty;
                        switch (SmaugRandom.Bits(2))
                        {
                        case 0:
                            buf = $"Get away from me, {rch.Name}!";
                            break;

                        case 1:
                            buf = $"Leave me be, {rch.Name}!";
                            break;

                        case 2:
                            buf = $"{rch.Name} is trying to kill me!  Help!";
                            break;

                        case 3:
                            buf = $"Someone save me from {rch.Name}!";
                            break;
                        }

                        Yell.do_yell(ch, buf);
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    Move.move_char(ch, exit, 0);
                }
            }
        }
示例#11
0
        private static void BrandishStaff(CharacterInstance ch, ObjectInstance obj)
        {
            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_MAGIC, "$n brandishes $p.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_MAGIC, "You brandish $p.", ch, obj, null, ToTypes.Character);
            }

            foreach (var vch in ch.CurrentRoom.Persons)
            {
                if (!vch.IsNpc())
                {
                    var pch = (PlayerInstance)ch;
                    if (pch.Act.IsSet((int)PlayerFlags.WizardInvisibility) &&
                        pch.PlayerData.WizardInvisible >= LevelConstants.ImmortalLevel)
                    {
                        continue;
                    }
                }

                var skill = RepositoryManager.Instance.SKILLS.Get(obj.Value.ToList()[3]);
                switch (skill.Target)
                {
                case TargetTypes.Ignore:
                    if (vch != ch)
                    {
                        continue;
                    }
                    break;

                case TargetTypes.OffensiveCharacter:
                    if (ch.IsNpc() ? vch.IsNpc() : !vch.IsNpc())
                    {
                        continue;
                    }
                    break;

                case TargetTypes.DefensiveCharacter:
                    if (ch.IsNpc() ? !vch.IsNpc() : vch.IsNpc())
                    {
                        continue;
                    }
                    break;

                case TargetTypes.Self:
                    if (vch != ch)
                    {
                        continue;
                    }
                    break;

                default:
                    throw new InvalidDataException(
                              $"Bad Target {skill.Target} for Skill {skill.ID} on Object {obj.ID}");
                }

                var retcode = ch.ObjectCastSpell((int)skill.ID, obj.Value.ToList()[0], vch);
                if (retcode == ReturnTypes.CharacterDied || retcode == ReturnTypes.BothDied)
                {
                    throw new InvalidDataException($"Character {ch.ID} died using Skill {skill.ID} from Object {obj.ID}");
                }
            }
        }
示例#12
0
        public static void do_apply(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Apply what?"))
            {
                return;
            }

            var secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIfNotNullObject(ch, ch.CurrentFighting, "You're too busy fighting..."))
            {
                return;
            }
            if (handler.FindObject_CheckMentalState(ch))
            {
                return;
            }

            var salve = ch.GetCarriedObject(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, salve, "You do not have that."))
            {
                return;
            }

            CharacterInstance victim;
            ObjectInstance    obj = null;

            if (string.IsNullOrEmpty(secondArg))
            {
                victim = ch;
            }
            else
            {
                victim = ch.GetCharacterInRoom(secondArg);
                obj    = ch.GetObjectOnMeOrInRoom(secondArg);

                if (CheckFunctions.CheckIfTrue(ch, victim == null && obj == null, "Apply it to what or whom?"))
                {
                    return;
                }
            }

            if (CheckFunctions.CheckIfNotNullObject(ch, obj, "You can't do that... yet."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotNullObject(ch, victim.CurrentFighting,
                                                    "Wouldn't work very well while they're fighting..."))
            {
                return;
            }

            if (salve.ItemType != ItemTypes.Salve)
            {
                ApplyNonSalve(salve, ch, victim);
                return;
            }

            salve.Split();
            salve.Values.Charges -= 1;

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, salve, null, null))
            {
                UseSalve(salve, ch, victim);
            }

            Macros.WAIT_STATE(ch, salve.Values.Delay);
            var retcode = ch.ObjectCastSpell((int)salve.Values.Skill1ID, (int)salve.Values.SpellLevel, victim);

            if (retcode == ReturnTypes.None)
            {
                retcode = ch.ObjectCastSpell((int)salve.Values.Skill2ID, (int)salve.Values.SpellLevel, victim);
            }
            if (retcode == ReturnTypes.CharacterDied || retcode == ReturnTypes.BothDied)
            {
                throw new CharacterDiedException("Salve {0}, Actor {1}, Victim {2}", salve.ID, ch.ID, victim.ID);
            }

            if (!handler.obj_extracted(salve) && salve.Values.Charges <= 0)
            {
                salve.Extract();
            }
        }
示例#13
0
        private static void DrinkFromContainer(CharacterInstance ch, ObjectInstance obj)
        {
            if (CheckFunctions.CheckIfTrue(ch, obj.Values.Quantity <= 0, "It is already empty."))
            {
                return;
            }

            if (!ch.IsNpc())
            {
                var pch = (PlayerInstance)ch;
                if (CheckFunctions.CheckIfTrue(ch, pch.GetCondition(ConditionTypes.Full) == GetMaximumCondition() ||
                                               pch.GetCondition(ConditionTypes.Thirsty) == GetMaximumCondition(),
                                               "Your stomach is too full to drink more!"))
                {
                    return;
                }
            }

            LiquidData liquid = RepositoryManager.Instance.LIQUIDS.Get(obj.Values.LiquidID) ??
                                RepositoryManager.Instance.LIQUIDS.Get(0);

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n drinks $T from $p.", ch, obj, liquid.ShortDescription, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You drink $T from $p.", ch, obj, liquid.ShortDescription, ToTypes.Character);
            }

            if (!ch.IsNpc())
            {
                var pch = (PlayerInstance)ch;
                pch.GainCondition(ConditionTypes.Thirsty, liquid.GetMod(ConditionTypes.Thirsty));
                pch.GainCondition(ConditionTypes.Full, liquid.GetMod(ConditionTypes.Full));
                pch.GainCondition(ConditionTypes.Drunk, liquid.GetMod(ConditionTypes.Drunk));
                if (ch.IsVampire())
                {
                    pch.GainCondition(ConditionTypes.Bloodthirsty, liquid.GetMod(ConditionTypes.Bloodthirsty));
                }
            }

            if (liquid.Type == LiquidTypes.Poison)
            {
                DrinkPoison(ch, obj);
            }

            if (!ch.IsNpc())
            {
                var pch = (PlayerInstance)ch;

                EvaluateDrunkCondition(pch);
                EvaluateThirstCondition(pch);

                if (ch.IsVampire())
                {
                    EvaluateBloodthirstCondition(pch);
                }
                else if (!ch.IsVampire() && pch.GetCondition(ConditionTypes.Bloodthirsty) >= GetMaximumCondition())
                {
                    pch.PlayerData.ConditionTable[ConditionTypes.Bloodthirsty] = GetMaximumCondition();
                }
            }

            obj.Values.Quantity -= 1;
            if (CheckFunctions.CheckIfTrue(ch, obj.Values.Quantity <= 0, "You drink the last drop from your container."))
            {
                obj.Values.Quantity = 0;
            }
        }
示例#14
0
        public static void do_say(CharacterInstance ch, string argument)
        {
#if !SCRAMBLE
            var speaking = -1;

            /*foreach (int key in GameConstants.LanguageTable.Keys
             *  .Where(key => (key & ch.Speaking) > 0))
             * {
             *  speaking = key;
             *  break;
             * }*/
#endif

            if (CheckFunctions.CheckIfEmptyString(ch, argument, "Say what?"))
            {
                return;
            }
            if (CheckFunctions.CheckIf(ch,
                                       args => ((CharacterInstance)args[0]).CurrentRoom.Flags.IsSet((int)RoomFlags.Silence),
                                       "You can't do that here.", new List <object> {
                ch
            }))
            {
                return;
            }

            var actflags = ch.Act;
            if (ch.IsNpc())
            {
                ch.Act.RemoveBit((int)ActFlags.Secretive);
            }

            foreach (var vch in ch.CurrentRoom.Persons.Where(vch => vch != ch))
            {
                var sbuf = argument;
                if (vch.IsIgnoring(ch))
                {
                    if (!ch.IsImmortal() || vch.Trust > ch.Trust)
                    {
                        continue;
                    }

                    vch.SetColor(ATTypes.AT_IGNORE);
                    vch.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name);
                }

#if !SCRAMBLE
                /*if (speaking != -1 && (!ch.IsNpc() || ch.Speaking != 0))
                 * {
                 *  int speakswell = vch.KnowsLanguage(ch.Speaking, ch).GetLowestOfTwoNumbers(ch.KnowsLanguage(ch.Speaking, vch));
                 *  if (speakswell < 75)
                 *      sbuf = act_comm.TranslateLanguage(speakswell, argument, GameConstants.LanguageTable[speaking]);
                 * }*/
#else
                if (KnowsLanguage(vch, ch.Speaking, ch) == 0 &&
                    (!ch.IsNpc() || ch.Speaking != 0))
                {
                    sbuf = ScrambleText(argument, ch.Speaking);
                }
#endif
                sbuf = sbuf.Drunkify(ch);

                // TODO Toggle global mobtrigger flag
                comm.act(ATTypes.AT_SAY, "$n says '$t'", ch, sbuf, vch, ToTypes.Victim);
            }

            ch.Act = actflags;
            // TODO Toggle global mobtrigger flag
            comm.act(ATTypes.AT_SAY, "You say '%T'", ch, null, argument.Drunkify(ch), ToTypes.Character);

            if (ch.CurrentRoom.Flags.IsSet((int)RoomFlags.LogSpeech))
            {
                db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log),
                                  $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argument}");
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Speech, argument, ch);
            if (ch.CharDied())
            {
                return;
            }
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Speech, argument, ch);
            if (ch.CharDied())
            {
                return;
            }
            MudProgHandler.ExecuteRoomProg(MudProgTypes.Speech, argument, ch);
        }
示例#15
0
        public static void char_update()
        {
            //lc = trworld_create(TR_CHAR_WORLD_BACK)

            foreach (var ch in RepositoryManager.Instance.CHARACTERS.Values)
            {
                handler.CurrentCharacter = ch;

                if (!ch.IsNpc())
                {
                    MudProgHandler.ExecuteRoomProg(MudProgTypes.Random, ch);
                }
                if (ch.CharDied())
                {
                    continue;
                }

                if (ch.IsNpc())
                {
                    MudProgHandler.ExecuteMobileProg(MudProgTypes.Time, ch);
                }
                if (ch.CharDied())
                {
                    continue;
                }

                MudProgHandler.ExecuteRoomProg(MudProgTypes.Time, ch);
                if (ch.CharDied())
                {
                    continue;
                }

                CharacterInstance ch_save = null;
                if (!ch.IsNpc() && (((PlayerInstance)ch).Descriptor == null || ((PlayerInstance)ch).Descriptor.ConnectionStatus == ConnectionTypes.Playing) &&
                    ch.Level >= 2 && CheckSaveFrequency(ch))
                {
                    ch_save = ch;
                }

                if ((int)ch.CurrentPosition >= (int)PositionTypes.Stunned)
                {
                    if (ch.CurrentHealth < ch.MaximumHealth)
                    {
                        ch.CurrentHealth += ch.HealthGain();
                    }
                    if (ch.CurrentMana < ch.MaximumMana)
                    {
                        ch.CurrentMana += ch.ManaGain();
                    }
                    if (ch.CurrentMovement < ch.MaximumMovement)
                    {
                        ch.CurrentMovement += ch.MovementGain();
                    }
                }

                if (ch.CurrentPosition == PositionTypes.Stunned)
                {
                    ch.UpdatePositionByCurrentHealth();
                }

                // TODO Variables

                if (ch.CurrentMorph?.timer > 0)
                {
                    --ch.CurrentMorph.timer;
                    if (ch.CurrentMorph.timer == 0)
                    {
                        UnmorphChar.do_unmorph_char(ch, string.Empty);
                    }
                }

                // TODO Nuisance

                if (!ch.IsNpc() && ch.Level < LevelConstants.ImmortalLevel)
                {
                    var obj = ch.GetEquippedItem(WearLocations.Light);
                    if (obj != null && obj.ItemType == ItemTypes.Light && obj.Value.ToList()[2] > 0)
                    {
                        ProcessLightObject(ch, obj);
                    }

                    if (++ch.Timer >= 12)
                    {
                        ProcessIdle(ch);
                    }

                    if (((PlayerInstance)ch).PlayerData.GetConditionValue(ConditionTypes.Drunk) > 8)
                    {
                        ((PlayerInstance)ch).WorsenMentalState(((PlayerInstance)ch).PlayerData.GetConditionValue(ConditionTypes.Drunk) / 8);
                    }

                    if (((PlayerInstance)ch).PlayerData.GetConditionValue(ConditionTypes.Full) > 1)
                    {
                        // todo fix this
                        //IEnumerable<MentalStateAttribute> attribs =
                        //    ch.CurrentPosition.GetAttributes<MentalStateAttribute>();
                        //if (attribs.Any())
                        //{
                        //    MentalStateAttribute attrib =
                        //        attribs.FirstOrDefault(x => x.Condition.HasFlag(ConditionTypes.Full));
                        //    ch.ImproveMentalState(attrib == null ? 1 : attrib.ModValue);
                        //}
                    }

                    if (((PlayerInstance)ch).PlayerData.GetConditionValue(ConditionTypes.Thirsty) > 1)
                    {
                        // todo fix this
                        //IEnumerable<MentalStateAttribute> attribs =
                        //    ch.CurrentPosition.GetAttributes<MentalStateAttribute>();
                        //if (attribs.Any())
                        //{
                        //    MentalStateAttribute attrib =
                        //        attribs.FirstOrDefault(x => x.Condition.HasFlag(ConditionTypes.Thirsty));
                        //    ch.ImproveMentalState(attrib == null ? 1 : attrib.ModValue);
                        //}
                    }

                    ch.CheckAlignment();
                    ((PlayerInstance)ch).GainCondition(ConditionTypes.Drunk, -1);

                    var race = RepositoryManager.Instance.GetRace(ch.CurrentRace);
                    ((PlayerInstance)ch).GainCondition(ConditionTypes.Full, -1 + race.HungerMod);

                    if (ch.IsVampire() && ch.Level >= 10)
                    {
                        if (GameManager.Instance.GameTime.Hour < 21 && GameManager.Instance.GameTime.Hour >= 10)
                        {
                            ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -1);
                        }
                    }

                    if (ch.CanPKill() && ((PlayerInstance)ch).PlayerData.GetConditionValue(ConditionTypes.Thirsty) - 9 > 10)
                    {
                        ((PlayerInstance)ch).GainCondition(ConditionTypes.Thirsty, -9);
                    }

                    // TODO Nuisance
                }

                if (!ch.IsNpc() && !ch.IsImmortal() && ((PlayerInstance)ch).PlayerData.release_date > DateTime.MinValue &&
                    ((PlayerInstance)ch).PlayerData.release_date <= DateTime.Now)
                {
                    var location =
                        RepositoryManager.Instance.ROOMS.Get(((PlayerInstance)ch).PlayerData.Clan?.RecallRoom ??
                                                             VnumConstants.ROOM_VNUM_TEMPLE) ?? ch.CurrentRoom;

                    ch.CurrentRoom.RemoveFrom(ch);
                    location.AddTo(ch);
                    ch.SendTo("The gods have released you from hell as your sentence is up!");
                    Look.do_look(ch, "auto");
                    ((PlayerInstance)ch).PlayerData.helled_by    = string.Empty;
                    ((PlayerInstance)ch).PlayerData.release_date = DateTime.MinValue;
                    save.save_char_obj(ch);
                }

                if (!ch.CharDied())
                {
                    if (ch.IsAffected(AffectedByTypes.Poison))
                    {
                        comm.act(ATTypes.AT_POISON, "$n shivers and suffers.", ch, null, null, ToTypes.Room);
                        comm.act(ATTypes.AT_POISON, "You shiver and suffer.", ch, null, null, ToTypes.Character);

                        var minMentalState = CalculateMinMentalStateWhilePoisoned(ch);
                        ch.MentalState = 20.GetNumberThatIsBetween(minMentalState, 100);
                        ch.CauseDamageTo(ch, 6, RepositoryManager.Instance.LookupSkill("poison"));
                    }
                    else
                    {
                        switch (ch.CurrentPosition)
                        {
                        case PositionTypes.Incapacitated:
                            ch.CauseDamageTo(ch, 1, Program.TYPE_UNDEFINED);
                            break;

                        case PositionTypes.Mortal:
                            ch.CauseDamageTo(ch, 4, Program.TYPE_UNDEFINED);
                            break;
                        }
                    }
                    if (ch.CharDied())
                    {
                        continue;
                    }

                    if (ch.IsAffected(AffectedByTypes.RecurringSpell))
                    {
                        var died  = false;
                        var found = false;
                        foreach (var paf in ch.Affects.Where(x => x.Location == ApplyTypes.RecurringSpell))
                        {
                            found = true;
                            if (Macros.IS_VALID_SN(paf.Modifier))
                            {
                                var skill = RepositoryManager.Instance.SKILLS.Get(paf.Modifier);
                                if (skill == null || skill.Type != SkillTypes.Spell)
                                {
                                    continue;
                                }

                                var retCode = skill.SpellFunction.Value.Invoke(paf.Modifier, ch.Level, ch, ch);
                                if (retCode == ReturnTypes.CharacterDied || ch.CharDied())
                                {
                                    died = true;
                                    break;
                                }
                            }
                        }

                        if (died)
                        {
                            continue;
                        }
                        if (!found)
                        {
                            ch.AffectedBy.RemoveBit((int)AffectedByTypes.RecurringSpell);
                        }
                    }

                    if (ch.MentalState >= 30)
                    {
                        var val = (ch.MentalState + 5) / 10;
                        if (HighMentalStateTable.ContainsKey(val))
                        {
                            ch.SendTo(HighMentalStateTable[val].Key);
                            comm.act(ATTypes.AT_ACTION, HighMentalStateTable[val].Value, ch, null, null, ToTypes.Room);
                        }
                    }

                    if (ch.MentalState <= -30)
                    {
                        var val = (Math.Abs(ch.MentalState) + 5) / 10;
                        if (LowMentalStateTable.ContainsKey(val))
                        {
                            if (val > 7)
                            {
                                if ((int)ch.CurrentPosition > (int)PositionTypes.Sleeping)
                                {
                                    if ((ch.CurrentPosition == PositionTypes.Standing ||
                                         (int)ch.CurrentPosition < (int)PositionTypes.Fighting) &&
                                        (SmaugRandom.D100() + (100 - val * 10) + 10 < Math.Abs(ch.MentalState)))
                                    {
                                        Sleep.do_sleep(ch, string.Empty);
                                    }
                                    else
                                    {
                                        ch.SendTo(LowMentalStateTable[val]);
                                    }
                                }
                            }
                            else
                            {
                                if ((int)ch.CurrentPosition > (int)PositionTypes.Resting)
                                {
                                    ch.SendTo(LowMentalStateTable[val]);
                                }
                            }
                        }
                    }

                    if (ch.Timer > 24)
                    {
                        Quit.do_quit(ch, string.Empty);
                    }
                    else if (ch == ch_save && GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Auto))
                    {
                        save.save_char_obj(ch);
                    }
                }
            }

            //trowlrd_dispose
        }
示例#16
0
        public static ReturnTypes CauseDamageTo(this ObjectInstance obj)
        {
            var ch = obj.CarriedBy;

            obj.Split();

            if (!ch.IsNpc() && (!ch.IsPKill() || (ch.IsPKill() && !((PlayerInstance)ch).PlayerData.Flags.IsSet(PCFlags.Gag))))
            {
                comm.act(ATTypes.AT_OBJECT, "($p gets damaged)", ch, obj, null, ToTypes.Character);
            }
            else if (obj.InRoom?.Persons.First() != null)
            {
                ch = obj.InRoom.Persons.First();
                comm.act(ATTypes.AT_OBJECT, "($p gets damaged)", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_OBJECT, "($p gets damaged)", ch, obj, null, ToTypes.Character);
                ch = null;
            }

            if (obj.ItemType != ItemTypes.Light || !ch.IsInArena())
            {
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Damage, ch, obj);
            }

            if (handler.obj_extracted(obj))
            {
                return(handler.GlobalObjectCode);
            }

            ReturnTypes returnVal;

            switch (obj.ItemType)
            {
            default:
                ObjectFactory.CreateScraps(obj);
                returnVal = ReturnTypes.ObjectScrapped;
                break;

            case ItemTypes.Container:
            case ItemTypes.KeyRing:
            case ItemTypes.Quiver:
                returnVal = CauseDamageToContainer(obj, ch);
                break;

            case ItemTypes.Light:
                returnVal = CauseDamageToLight(obj, ch);
                break;

            case ItemTypes.Armor:
                returnVal = CauseDamageToArmor(obj, ch);
                break;

            case ItemTypes.Weapon:
                returnVal = CauseDamageToWeapon(obj, ch);
                break;
            }

            if (ch != null)
            {
                save.save_char_obj(ch);
            }

            return(returnVal);
        }
示例#17
0
        /// <summary>
        /// Wear one object. Optional replacement of existing objects.
        /// Restructured a bit to allow for specifying body location and
        /// added support for layering on certain body locations
        /// </summary>
        public static void WearItem(this CharacterInstance ch, ObjectInstance obj, bool replace, ItemWearFlags wearFlag)
        {
            obj.Split();
            if (ch.Trust < obj.Level)
            {
                ch.Printf("You must be level %d to use this object.", obj.Level);
                comm.act(ATTypes.AT_ACTION, "$n tries to use $p, but is too inexperienced.", ch, obj, null, ToTypes.Room);
                return;
            }

            if (!ch.IsImmortal() && !ch.IsAllowedToUseObject(obj))
            {
                comm.act(ATTypes.AT_MAGIC, "You are forbidden to use that item.", ch, null, null, ToTypes.Character);
                comm.act(ATTypes.AT_ACTION, "$n tries to use $p, but is forbidden to do so.", ch, obj, null, ToTypes.Room);
                return;
            }

            if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Personal) && ch.Name.EqualsIgnoreCase(obj.Owner))
            {
                ch.SendTo("That item is personalized and belongs to someone else.");
                if (obj.CarriedBy != null)
                {
                    obj.RemoveFrom();
                }
                ch.CurrentRoom.AddTo(obj);
                return;
            }

            // TODO Is this going to replace an item already equipped?

            /*int bit;
             * if (wear_bit > -1)
             * {
             *  bit = wear_bit;
             *  if (!obj.WearFlags.IsSet(1 << bit))
             *  {
             *      if (replace)
             *      {
             *          switch (1 << bit)
             *          {
             *              case (int)ItemWearFlags.Hold:
             *                  ch.SetColor("You cannot hold that.\r\n", ch);
             *                  break;
             *              case (int)ItemWearFlags.Wield:
             *              case (int)ItemWearFlags.MissileWield:
             *                  ch.SetColor("You cannot wield that.\r\n", ch);
             *                  break;
             *              default:
             *                  color.ch_printf(ch, "You cannot wear that on your %s.\r\n", BuilderConstants.w_flags[bit]);
             *                  break;
             *          }
             *      }
             *      return;
             *  }
             * }
             * else
             * {
             *  bit = -1;
             *  for (int x = 1; x < 31; x++)
             *  {
             *      if (obj.WearFlags.IsSet(1 << x))
             *      {
             *          bit = x;
             *          break;
             *      }
             *  }
             * }*/

            if (obj.ItemType == ItemTypes.Light)
            {
                if (!ch.RemoveFrom(WearLocations.Light, replace))
                {
                    return;
                }
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n holds $p as a light.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You hold $p as your light.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.Light);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            /*if (bit == -1)
             * {
             *  if (replace)
             *      ch.SetColor("You can't wear, wield, or hold that.\r\n", ch);
             *  return;
             * }*/

            if (ItemWearMap.ContainsKey(wearFlag))
            {
                ItemWearMap[wearFlag].Invoke(obj, ch, replace);
            }
            else
            {
                if (wearFlag == ItemWearFlags.Wield || wearFlag == ItemWearFlags.MissileWield)
                {
                    ItemWearWield(obj, ch, replace, wearFlag);
                }
                else
                {
                    LogManager.Instance.Bug("Unknown/Unused ItemWearFlag {0}", wearFlag);
                    if (replace)
                    {
                        ch.SendTo("You can't wear, wield, or hold that.");
                    }
                }
            }
        }
示例#18
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);
        }
示例#19
0
        public static void do_whisper(CharacterInstance ch, string argument)
        {
#if !SCRAMBLE
            var speaking = -1;

            /*foreach (int key in GameConstants.LanguageTable.Keys
             *                           .Where(key => (key & ch.Speaking) > 0))
             * {
             *  speaking = key;
             *  break;
             * }*/
#endif

            ch.Deaf.RemoveBit((int)ChannelTypes.Whisper);
            var firstArgument  = argument.FirstWord();
            var argumentString = argument.RemoveWord(1);
            if (string.IsNullOrWhiteSpace(argumentString))
            {
                ch.SendTo("Whisper to whom what?");
                return;
            }

            var victim = ch.GetCharacterInRoom(firstArgument);
            if (victim == null)
            {
                ch.SendTo("They aren't here.");
                return;
            }

            if (ch == victim)
            {
                ch.SendTo("You have a nice little chat with yourself.");
                return;
            }

            if (!victim.IsNpc() && victim.Switched != null &&
                !victim.Switched.IsAffected(AffectedByTypes.Possess))
            {
                ch.SendTo("That player is switched.");
                return;
            }

            if (!victim.IsNpc() && ((PlayerInstance)victim).Descriptor == null)
            {
                ch.SendTo("That player is link-dead.");
                return;
            }

            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.AwayFromKeyboard))
            {
                ch.SendTo("That player is afk.");
                return;
            }

            if (victim.Deaf.IsSet(ChannelTypes.Whisper) &&
                (!ch.IsImmortal() || (ch.Trust < victim.Trust)))
            {
                comm.act(ATTypes.AT_PLAIN, "$E has $S whispers turned off.", ch, null, victim,
                         ToTypes.Character);
                return;
            }

            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.Silence))
            {
                ch.SendTo("That player is silenced.  They will receive your message but cannot respond.");
            }

            if (((PlayerInstance)victim).Descriptor != null &&
                (((PlayerInstance)victim).Descriptor.ConnectionStatus == ConnectionTypes.Editing) &&
                (ch.Trust < LevelConstants.GetLevel(ImmortalTypes.God)))
            {
                comm.act(ATTypes.AT_PLAIN, "$E is currently in a writing buffer.  Please try again in a few minutes.",
                         ch, 0, victim, ToTypes.Character);
                return;
            }

            if (victim.IsIgnoring(ch))
            {
                if (!ch.IsImmortal() || victim.Trust > ch.Trust)
                {
                    ch.SetColor(ATTypes.AT_IGNORE);
                    ch.Printf("%s is ignoring you.\r\n", victim.Name);
                    return;
                }

                victim.SetColor(ATTypes.AT_IGNORE);
                victim.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name);
            }

            comm.act(ATTypes.AT_WHISPER, "You whisper to $N '$t'", ch, argumentString, victim, ToTypes.Character);
            var position = victim.CurrentPosition;
            victim.CurrentPosition = PositionTypes.Standing;

#if !SCRAMBLE
            /* if (speaking != -1 && (!ch.IsNpc() || ch.Speaking > 0))
             * {
             *   int speakswell = victim.KnowsLanguage(ch.Speaking, ch).GetLowestOfTwoNumbers(ch.KnowsLanguage(ch.Speaking, victim));
             *   if (speakswell < 85)
             *       comm.act(ATTypes.AT_WHISPER, "$n whispers to you '$t'",
             *                ch, act_comm.TranslateLanguage(speakswell, argumentString,
             *                              GameConstants.LanguageTable[speaking]), victim, ToTypes.Victim);
             *   else
             *       comm.act(ATTypes.AT_WHISPER, "$n whispers to you '$t'",
             *                ch, argumentString, victim, ToTypes.Victim);
             * }
             * else
             *   comm.act(ATTypes.AT_WHISPER, "$n whispers to you '$t'", ch, argument, victim, ToTypes.Victim);*/
#else
            int speakswell = SmaugCS.Common.Check.Minimum(KnowsLanguage(victim, ch.Speaking, ch),
                                                          KnowsLanguage(ch, ch.Speaking, victim));

            if (act_comm.KnowsLanguage(victim, ch.Speaking, ch) == 0 &&
                (!ch.IsNpc() || ch.Speaking != 0))
            {
                comm.act(ATTypes.AT_WHISPER, "$n whispers to you '$t'", ch,
                         TranslateLanguage(speakswell, argument, GameConstants.LanguageTable[speaking]),
                         victim, ToTypes.Victim);
            }
            else
            {
                comm.act(ATTypes.AT_WHISPER, "$n whispers something to $N.",
                         ch, argument, victim, ToTypes.NotVictim);
            }
#endif

            if (!ch.CurrentRoom.Flags.IsSet((int)RoomFlags.LogSpeech))
            {
                db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log),
                                  $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argument} (whisper to) {(victim.IsNpc() ? victim.ShortDescription : victim.Name)}");
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Tell, argument, ch);
        }
示例#20
0
        public static void act(ATTypes attype, string format, CharacterInstance ch, object arg1, object arg2,
                               ToTypes type)
        {
            if (string.IsNullOrEmpty(format) || ch == null)
            {
                return;
            }

            var flags1 = (int)ActFFlags.None;
            var flags2 = (int)ActFFlags.None;
            var obj1   = arg1.CastAs <ObjectInstance>();
            var obj2   = arg2.CastAs <ObjectInstance>();
            var vch    = arg2.CastAs <CharacterInstance>();
            CharacterInstance to;

            #region Nasty type checking

            // Do some proper type checking here..  Sort of.  We base it on the $* params.
            // This is kinda lame really, but I suppose in some weird sense it beats having
            // to pass like 8 different NULL parameters every time we need to call act()..
            if (format.Contains("$t"))
            {
                flags1 |= (int)ActFFlags.Text;
                obj1    = null;
            }
            if (format.Contains("$T") || format.Contains("$d"))
            {
                flags2 |= (int)ActFFlags.Text;
                vch     = null;
                obj2    = null;
            }

            if (format.Contains("$N") ||
                format.Contains("$E") ||
                format.Contains("$M") ||
                format.Contains("$S") ||
                format.Contains("$Q"))
            {
                flags2 |= (int)ActFFlags.CH;
                obj2    = null;
            }

            if (format.Contains("$p"))
            {
                flags1 |= (int)ActFFlags.OBJ;
            }

            if (format.Contains("$P"))
            {
                flags2 |= (int)ActFFlags.OBJ;
                vch     = null;
            }

            if (flags1 != (int)ActFFlags.None && flags1 != (int)ActFFlags.Text &&
                flags1 != (int)ActFFlags.CH && flags1 != (int)ActFFlags.OBJ)
            {
                LogManager.Instance.Bug("More than one type {0} defined. Setting all null.", flags1);
                obj1 = null;
            }

            if (flags2 != (int)ActFFlags.None && flags2 != (int)ActFFlags.Text &&
                flags2 != (int)ActFFlags.CH && flags2 != (int)ActFFlags.OBJ)
            {
                LogManager.Instance.Bug("More than one type {0} defined. Setting all null.", flags2);
                vch  = null;
                obj2 = null;
            }

            if (ch.CurrentRoom == null)
            {
                to = null;
            }
            else if (type == ToTypes.Character)
            {
                to = ch;
            }
            else
            {
                to = ch.CurrentRoom.Persons.First();
            }

            #endregion

            if (ch.IsNpc() && ch.Act.IsSet((int)ActFlags.Secretive) && type != ToTypes.Character)
            {
                return;
            }

            if (type == ToTypes.Victim)
            {
                if (vch?.CurrentRoom == null)
                {
                    return;
                }
                to = vch;
            }

            var txt = string.Empty;
            if (to != null && type != ToTypes.Character && type != ToTypes.Victim)
            {
                txt = act_string(format, null, ch, arg1, arg2, Program.STRING_IMM);
                if (to.CurrentRoom.HasProg(MudProgTypes.Act))
                {
                    MudProgHandler.ExecuteRoomProg(MudProgTypes.Act, txt, to.CurrentRoom, ch, (ObjectInstance)arg1, arg2);
                }

                foreach (var toObj in to.CurrentRoom.Contents
                         .Where(toObj => to.CurrentRoom.HasProg(MudProgTypes.Act)))
                {
                    MudProgHandler.ExecuteObjectProg(MudProgTypes.Act, txt, toObj, ch, (ObjectInstance)arg1, arg2);
                }
            }

            if (type == ToTypes.Character || type == ToTypes.Victim)
            {
                return;
            }

            foreach (var rch in ch.CurrentRoom.Persons)
            {
                var playerInstance = to as PlayerInstance;
                if (playerInstance != null && playerInstance.Descriptor == null)
                {
                    continue;
                }

                var instance = to as MobileInstance;
                if (instance != null && !instance.MobIndex.HasProg(MudProgTypes.Act))
                {
                    continue;
                }

                if (!to.IsAwake())
                {
                    continue;
                }

                if (type == ToTypes.Character && to != ch)
                {
                    continue;
                }
                if (type == ToTypes.Victim && (to != vch || to == ch))
                {
                    continue;
                }
                if (type == ToTypes.Room && to == ch)
                {
                    continue;
                }
                if (type == ToTypes.NotVictim && (to == ch || to == vch))
                {
                    continue;
                }
                if (type == ToTypes.CanSee &&
                    (to == ch ||
                     (!to.IsImmortal() && !ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.WizardInvisibility) && to.Trust <
                      (playerInstance != null
                          ? (playerInstance.PlayerData?.WizardInvisible ?? 0)
                          : 0))))
                {
                    continue;
                }

                txt = act_string(format, to, ch, arg1, arg2, to.IsImmortal() ? Program.STRING_IMM : Program.STRING_NONE);

                if (playerInstance != null)
                {
                    to.SetColor(attype);
                    to.SendTo(txt);
                }

                MudProgHandler.ExecuteMobileProg(MudProgTypes.Act, txt, to, ch, arg1, arg2);
            }
        }
示例#21
0
        public static void do_reply(CharacterInstance ch, string argument)
        {
#if !SCRAMBLE
            var speaking = -1;

            /*foreach (int key in GameConstants.LanguageTable.Keys
             *                           .Where(key => (key & ch.Speaking) > 0))
             * {
             *  speaking = key;
             *  break;
             * }*/
#endif

            ch.Deaf.RemoveBit(ChannelTypes.Tells);
            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Silence))
            {
                ch.SendTo("You can't do that here.\r\n");
                return;
            }

            if (!ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Silence))
            {
                ch.SendTo("Your message didn't get through.\r\n");
                return;
            }

            var victim = ((PlayerInstance)ch).ReplyTo;
            if (victim == null)
            {
                ch.SendTo("They aren't here.\r\n");
                return;
            }

            if (!victim.IsNpc() &&
                victim.Switched != null &&
                ch.CanSee(victim) &&
                ch.Trust > LevelConstants.AvatarLevel)
            {
                ch.SendTo("That player is switched.\r\n");
                return;
            }

            if (!victim.IsNpc() && ((PlayerInstance)victim).Descriptor == null)
            {
                ch.SendTo("That player is link-dead.\r\n");
                return;
            }

            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.AwayFromKeyboard))
            {
                ch.SendTo("That player is afk.\r\n");
                return;
            }

            if (victim.Deaf.IsSet(ChannelTypes.Tells) &&
                (!ch.IsImmortal() || ch.Trust < victim.Trust))
            {
                comm.act(ATTypes.AT_PLAIN, "$E has $S tells turned off.", ch, null, victim, ToTypes.Character);
                return;
            }

            if ((!ch.IsImmortal() && !victim.IsAwake()) ||
                (!victim.IsNpc() && victim.CurrentRoom.Flags.IsSet(RoomFlags.Silence)))
            {
                comm.act(ATTypes.AT_PLAIN, "$E can't hear you.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (((PlayerInstance)victim).Descriptor != null &&
                ((PlayerInstance)victim).Descriptor.ConnectionStatus == ConnectionTypes.Editing &&
                ch.Trust < LevelConstants.GetLevel(ImmortalTypes.God))
            {
                comm.act(ATTypes.AT_PLAIN, "$E is currently in a writing buffer. Please try again later.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (victim.IsIgnoring(ch))
            {
                if (!ch.IsImmortal() || victim.Trust > ch.Trust)
                {
                    ch.SetColor(ATTypes.AT_IGNORE);
                    ch.Printf("%s is ignoring you.\r\n", victim.Name);
                    return;
                }

                victim.SetColor(ATTypes.AT_IGNORE);
                victim.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name);
            }

            comm.act(ATTypes.AT_TELL, "You tell $N '$t'", ch, argument, victim, ToTypes.Character);
            var position = victim.CurrentPosition;
            victim.CurrentPosition = PositionTypes.Standing;

#if !SCRAMBLE
            /*if (speaking != -1 && (!ch.IsNpc() || ch.Speaking > 0))
             * {
             *  int speakswell = victim.KnowsLanguage(ch.Speaking, ch).GetLowestOfTwoNumbers(ch.KnowsLanguage(ch.Speaking, victim));
             *  if (speakswell < 85)
             *      comm.act(ATTypes.AT_TELL, "$n tells you '$t'",
             *               ch, act_comm.TranslateLanguage(speakswell, argument,
             *                             GameConstants.LanguageTable[speaking]), victim, ToTypes.Victim);
             *  else
             *      comm.act(ATTypes.AT_TELL, "$n tells you '$t'",
             *               ch, argument, victim, ToTypes.Victim);
             * }
             * else
             *  comm.act(ATTypes.AT_TELL, "$n tells you '$t'", ch, argument, victim, ToTypes.Victim);*/
#else
            if (act_comm.KnowsLanguage(victim, ch.Speaking, ch) == 0 &&
                (ch.IsNpc() || ch.Speaking != 0))
            {
                comm.act(ATTypes.AT_TELL, "$n tells you '$t'", ch,
                         TranslateLanguage(speakswell, argument, GameConstants.LanguageTable[speaking]),
                         victim, ToTypes.Victim);
            }
            else
            {
                comm.act(ATTypes.AT_TELL, "$n tells you '$t'",
                         ch, scramble(argument, ch.Speaking), victim, ToTypes.Victim);
            }
#endif

            victim.CurrentPosition           = position;
            ((PlayerInstance)victim).ReplyTo = ch;
            ((PlayerInstance)ch).RetellTo    = victim;

            if (ch.CurrentRoom.Flags.IsSet((int)RoomFlags.LogSpeech))
            {
                var buffer =
                    $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argument} (tell to) {(victim.IsNpc() ? victim.ShortDescription : victim.Name)}";
                db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log), buffer);
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Tell, argument, ch);
        }
示例#22
0
        public static void repair_one_obj(CharacterInstance ch, MobileInstance keeper, ObjectInstance obj,
                                          string arg, int maxgold, string fixstr, string fixstr2)
        {
            int    cost;
            string buffer;

            if (!ch.CanDrop(obj))
            {
                ch.Printf("You can't let go of %s.\r\n", obj.Name);
            }
            else if ((cost = Appraise.GetAdjustedRepairCost(keeper, obj)) < 0)
            {
                if (cost < 0)
                {
                    comm.act(ATTypes.AT_TELL,
                             cost != -2
                                 ? "$n tells you, 'Sorry, I can't do anything with $p.'"
                                 : "$n tells you, '$p looks fine to me!'", keeper, obj, ch, ToTypes.Victim);
                }
            }

            // repair all gets a 10% surcharge
            else if ((cost = arg.Equals("all") ? cost : 11 * (cost / 10)) > ch.CurrentCoin)
            {
                buffer =
                    $"$N tells you, 'It will cost {cost} piece{(cost == 1 ? "" : "s")} of gold to {fixstr} {obj.Name}...'";
                comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character);
                comm.act(ATTypes.AT_TELL, "$n tells you, 'Which I see you can't afford.'", ch, null, keeper, ToTypes.Character);
            }
            else
            {
                buffer = $"$n gives $p to $N, who quickly {fixstr2} it.";
                comm.act(ATTypes.AT_ACTION, buffer, ch, obj, keeper, ToTypes.Room);

                buffer = $"$n charges you {cost} gold piece{(cost == 1 ? "" : "s")} to {fixstr} $p.";
                comm.act(ATTypes.AT_ACTION, buffer, ch, obj, keeper, ToTypes.Character);

                ch.CurrentCoin     -= cost;
                keeper.CurrentCoin += cost;

                if (keeper.CurrentCoin < 0)
                {
                    keeper.CurrentCoin = 0;
                }
                else if (keeper.CurrentCoin > maxgold)
                {
                    keeper.CurrentRoom.Area.BoostEconomy(keeper.CurrentCoin - maxgold / 2);
                    keeper.CurrentCoin = maxgold / 2;
                    comm.act(ATTypes.AT_ACTION, "$n puts some gold into a large safe.", keeper, null, null, ToTypes.Room);
                }

                switch (obj.ItemType)
                {
                default:
                    ch.SendTo("For some reason, you think you got ripped off...");
                    break;

                case ItemTypes.Armor:
                    obj.Values.CurrentAC = obj.Values.OriginalAC;
                    break;

                case ItemTypes.Weapon:
                    obj.Values.Condition = GameConstants.GetConstant <int>("InitWeaponCondition");
                    break;

                case ItemTypes.Wand:
                case ItemTypes.Staff:
                    obj.Values.Charges = obj.Values.MaxCharges;
                    break;
                }

                MudProgHandler.ExecuteObjectProg(MudProgTypes.Repair, ch, obj);
            }
        }
示例#23
0
        public static void obj_update()
        {
            // lc = trworld_create(TR_OBJ_WORLD_BACK);

            foreach (var obj in RepositoryManager.Instance.OBJECTS.Values)
            {
                handler.CurrentObject = obj;

                if (obj.CarriedBy != null)
                {
                    MudProgHandler.ExecuteObjectProg(MudProgTypes.Random, obj);
                }
                else if (obj.InRoom != null && obj.InRoom.Area.NumberOfPlayers > 0)
                {
                    MudProgHandler.ExecuteObjectProg(MudProgTypes.Random, obj);
                }

                if (handler.obj_extracted(obj))
                {
                    continue;
                }

                if (obj.ItemType == ItemTypes.Pipe)
                {
                    UpdatePipe(obj);
                }

                if (obj.ItemType == ItemTypes.PlayerCorpse || obj.ItemType == ItemTypes.NpcCorpse)
                {
                    UpdateCorpse(obj);
                }

                if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Inventory))
                {
                    continue;
                }

                if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.GroundRot) && obj.InRoom == null)
                {
                    continue;
                }

                if (obj.Timer <= 0 || --obj.Timer > 0)
                {
                    continue;
                }

                var AT_TEMP = ATTypes.AT_PLAIN;
                var message = "$p mysteriously vanishes.";

                if (ObjectExpireTable.ContainsKey(obj.ItemType))
                {
                    message = ObjectExpireTable[obj.ItemType].Key;
                    AT_TEMP = ObjectExpireTable[obj.ItemType].Value;

                    if (obj.ItemType == ItemTypes.Portal)
                    {
                        remove_portal(obj);
                        obj.ItemType = ItemTypes.Trash;
                    }
                }

                if (obj.CarriedBy != null)
                {
                    comm.act(AT_TEMP, message, obj.CarriedBy, obj, null, ToTypes.Character);
                }
                else if (obj.InRoom != null && obj.InRoom.Persons.Any() && !obj.ExtraFlags.IsSet((int)ItemExtraFlags.Buried))
                {
                    var rch = obj.InRoom.Persons.FirstOrDefault();
                    comm.act(AT_TEMP, message, rch, obj, null, ToTypes.Room);
                    comm.act(AT_TEMP, message, rch, obj, null, ToTypes.Character);
                }

                if (obj == handler.CurrentObject)
                {
                    handler.GlobalObjectCode = ReturnTypes.ObjectExpired;
                }
                obj.Extract();
            }

            //trworld_dispose
        }
示例#24
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);
        }
示例#25
0
        public static ObjectInstance RawKill(this CharacterInstance ch, CharacterInstance victim)
        {
            var victimPc = (PlayerInstance)victim;

            if (victim.IsNotAuthorized())
            {
                LogManager.Instance.Bug("Killing unauthorized");
                return(null);
            }

            victim.StopFighting(true);

            if (victim.CurrentMorph != null)
            {
                UnmorphChar.do_unmorph_char(victim, string.Empty);
                return(ch.RawKill(victim));
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Death, ch, victim);
            if (victim.CharDied())
            {
                return(null);
            }

            MudProgHandler.ExecuteRoomProg(MudProgTypes.Death, victim);
            if (victim.CharDied())
            {
                return(null);
            }

            var corpse = ObjectFactory.CreateCorpse(victim, ch);

            switch (victim.CurrentRoom.SectorType)
            {
            case SectorTypes.OceanFloor:
            case SectorTypes.Underwater:
            case SectorTypes.ShallowWater:
            case SectorTypes.DeepWater:
                comm.act(ATTypes.AT_BLOOD, "$n's blood slowly clouds the surrounding water.", victim, null, null, ToTypes.Room);
                break;

            case SectorTypes.Air:
                comm.act(ATTypes.AT_BLOOD, "$n's blood sprays wildly through the air.", victim, null, null, ToTypes.Room);
                break;

            default:
                ObjectFactory.CreateBlood(victim);
                break;
            }

            if (victim.IsNpc())
            {
                ((MobileInstance)victim).MobIndex.TimesKilled++;
                victim.Extract(true);
                victim = null;
                return(corpse);
            }

            victim.SetColor(ATTypes.AT_DIEMSG);
            Help.do_help(victim,
                         ((PlayerInstance)victim).PlayerData.PvEDeaths + ((PlayerInstance)victim).PlayerData.PvPDeaths < 3 ? "new_death" : "_DIEMSG_");

            victim.Extract(false);

            while (victim.Affects.Count > 0)
            {
                victim.RemoveAffect(victim.Affects.First());
            }

            var victimRace = RepositoryManager.Instance.GetRace(victim.CurrentRace);

            victim.AffectedBy       = victimRace.AffectedBy;
            victim.Resistance       = 0;
            victim.Susceptibility   = 0;
            victim.Immunity         = 0;
            victim.CarryWeight      = 0;
            victim.ArmorClass       = 100 + victimRace.ArmorClassBonus;
            victim.Attacks          = victimRace.Attacks;
            victim.Defenses         = victimRace.Defenses;
            victim.ModStrength      = 0;
            victim.ModDexterity     = 0;
            victim.ModWisdom        = 0;
            victim.ModIntelligence  = 0;
            victim.ModConstitution  = 0;
            victim.ModCharisma      = 0;
            victim.ModLuck          = 0;
            victim.DamageRoll       = new DiceData();
            victim.HitRoll          = new DiceData();
            victim.MentalState      = -10;
            victim.CurrentAlignment = Macros.URANGE(-1000, victim.CurrentAlignment, 1000);
            victim.SavingThrows     = victimRace.SavingThrows;
            victim.CurrentPosition  = PositionTypes.Resting;
            victim.CurrentHealth    = Macros.UMAX(1, victim.CurrentHealth);
            victim.CurrentMana      = victim.Level < GetLevelAvatar() ? Macros.UMAX(1, victim.CurrentMana) : 1;
            victim.CurrentMovement  = Macros.UMAX(1, victim.CurrentMovement);

            if (victim.Act.IsSet((int)PlayerFlags.Killer))
            {
                victim.Act.RemoveBit((int)PlayerFlags.Killer);
                victim.SendTo("The gods have pardoned you for your murderous acts.");
            }

            if (victim.Act.IsSet((int)PlayerFlags.Thief))
            {
                victim.Act.RemoveBit((int)PlayerFlags.Thief);
                victim.SendTo("The gods have pardoned you for your thievery.");
            }

            victimPc.PlayerData.SetConditionValue(ConditionTypes.Full, 12);
            victimPc.PlayerData.SetConditionValue(ConditionTypes.Thirsty, 12);

            if (victimPc.IsVampire())
            {
                victimPc.PlayerData.SetConditionValue(ConditionTypes.Bloodthirsty, victim.Level / 2);
            }

            // TODO if (IS_SET(sysdata.save_flags, SV_DEATH))
            //      save_char_obj(victim);

            return(corpse);
        }
示例#26
0
        public static void do_tell(CharacterInstance ch, string argument)
        {
#if !SCRAMBLE
            var speaking = -1;

            /*foreach (int key in GameConstants.LanguageTable.Keys
             *  .Where(key => (key & ch.Speaking) > 0))
             * {
             *  speaking = key;
             *  break;
             * }*/
#endif

            ch.Deaf.RemoveBit(ChannelTypes.Tells);
            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Silence))
            {
                ch.SendTo("You can't do that here.\r\n");
                return;
            }

            if (!ch.IsNpc() &&
                (ch.Act.IsSet((int)PlayerFlags.Silence) || ch.Act.IsSet((int)PlayerFlags.NoTell)))
            {
                ch.SendTo("You can't do that.\r\n");
                return;
            }

            var firstArgument  = argument.FirstWord();
            var argumentString = argument.RemoveWord(1);
            if (string.IsNullOrWhiteSpace(argumentString))
            {
                ch.SendTo("Tell whom what?\r\n");
                return;
            }

            var victim = ch.GetCharacterInWorld(firstArgument);
            if (victim == null ||
                (victim.IsNpc() && victim.CurrentRoom != ch.CurrentRoom) ||
                (!ch.IsNotAuthorized() && victim.IsNotAuthorized() && !ch.IsImmortal()))
            {
                ch.SendTo("They aren't here.\r\n");
                return;
            }

            if (ch == victim)
            {
                ch.SendTo("You have a nice little chat with yourself.\r\n");
                return;
            }

            if (ch.IsNotAuthorized() && !victim.IsNotAuthorized() && !victim.IsImmortal())
            {
                ch.SendTo("They can't hear you because you are not authorized.\r\n");
                return;
            }

            if (!victim.IsNpc() && victim.Switched != null &&
                (ch.Trust > LevelConstants.AvatarLevel) &&
                !victim.Switched.IsAffected(AffectedByTypes.Possess))
            {
                ch.SendTo("That player is switched.\r\n");
                return;
            }

            CharacterInstance switchedVictim = null;
            if (!victim.IsNpc() && victim.Switched != null &&
                victim.Switched.IsAffected(AffectedByTypes.Possess))
            {
                switchedVictim = victim.Switched;
            }
            else if (!victim.IsNpc() && ((PlayerInstance)victim).Descriptor == null)
            {
                ch.SendTo("That player is link-dead.\r\n");
                return;
            }

            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.AwayFromKeyboard))
            {
                ch.SendTo("That player is afk.");
                return;
            }

            if (victim.Deaf.IsSet((int)ChannelTypes.Tells) &&
                (!ch.IsImmortal() || ch.Trust < victim.Trust))
            {
                comm.act(ATTypes.AT_PLAIN, "$E has $S tells turned off.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.Silence))
            {
                ch.SendTo("That player is silenced. They will receive your message but cannot respond.");
            }

            if (!ch.IsImmortal() && !victim.IsAwake())
            {
                comm.act(ATTypes.AT_PLAIN, "$E is too tired to discuss such matters with you.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (!victim.IsNpc() && victim.CurrentRoom.Flags.IsSet((int)RoomFlags.Silence))
            {
                comm.act(ATTypes.AT_PLAIN, "A magic force prevents your message from being heard.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (((PlayerInstance)victim).Descriptor != null &&
                ((PlayerInstance)victim).Descriptor.ConnectionStatus == ConnectionTypes.Editing &&
                ch.Trust < LevelConstants.GetLevel(ImmortalTypes.God))
            {
                comm.act(ATTypes.AT_PLAIN, "$E is currently in a writing buffer. Please try again later.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (victim.IsIgnoring(ch))
            {
                if (!ch.IsImmortal() || victim.Trust > ch.Trust)
                {
                    ch.SetColor(ATTypes.AT_IGNORE);
                    ch.Printf("%s is ignoring you.\r\n", victim.Name);
                    return;
                }

                victim.SetColor(ATTypes.AT_IGNORE);
                victim.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name);
            }

            ((PlayerInstance)ch).RetellTo = victim;

            if (!victim.IsNpc() && victim.IsImmortal() &&
                ((PlayerInstance)victim).PlayerData.TellHistory != null &&
                char.IsLetter(ch.IsNpc() ? ch.ShortDescription.ToCharArray()[0] : ch.Name.ToCharArray()[0]))
            {
                var buffer =
                    $"{(ch.IsNpc() ? ch.ShortDescription.CapitalizeFirst() : ch.Name.CapitalizeFirst())} told you '{argumentString}'\r\n";
                ((PlayerInstance)victim).PlayerData.TellHistory.Add(buffer);
            }

            if (switchedVictim != null)
            {
                victim = switchedVictim;
            }

            //MOBTrigger = false;

            comm.act(ATTypes.AT_TELL, "You tell $N '$t'", ch, argumentString, victim, ToTypes.Character);
            var position = victim.CurrentPosition;
            victim.CurrentPosition = PositionTypes.Standing;

            /*if (speaking != -1 && (!ch.IsNpc() || ch.Speaking > 0))
             * {
             *  int speakswell = victim.KnowsLanguage(ch.Speaking, ch).GetLowestOfTwoNumbers(ch.KnowsLanguage(ch.Speaking, victim));
             *  if (speakswell < 85)
             *      comm.act(ATTypes.AT_TELL, "$n tells you '$t'", ch, act_comm.TranslateLanguage(speakswell, argumentString,
             *          GameConstants.LanguageTable[speaking]), victim, ToTypes.Victim);
             *  else
             *      comm.act(ATTypes.AT_TELL, "$n tells you '$t'", ch, argumentString, victim, ToTypes.Victim);
             * }
             * else
             *  comm.act(ATTypes.AT_TELL, "$n tells you '$t'", ch, argumentString, victim, ToTypes.Victim);*/

            //MOBtrigger = true;

            victim.CurrentPosition           = position;
            ((PlayerInstance)victim).ReplyTo = ch;

            if (ch.CurrentRoom.Flags.IsSet((int)RoomFlags.LogSpeech))
            {
                var buffer =
                    $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argumentString} (tell to) {(victim.IsNpc() ? victim.ShortDescription : victim.Name)}";
                db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log), buffer);
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Tell, argumentString, ch);
        }