Example #1
0
        public static void teleportch(CharacterInstance ch, RoomTemplate room, bool show)
        {
            if (room.IsPrivate())
            {
                return;
            }

            comm.act(ATTypes.AT_ACTION, "$n disappears suddenly!", ch, null, null, ToTypes.Room);
            ch.CurrentRoom.RemoveFrom(ch);
            room.AddTo(ch);
            comm.act(ATTypes.AT_ACTION, "$n arrives suddenly!", ch, null, null, ToTypes.Room);

            if (show)
            {
                Look.do_look(ch, "auto");
            }

            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Death) &&
                !ch.IsImmortal())
            {
                comm.act(ATTypes.AT_DEAD, "$n falls prey to a terrible death!", ch, null, null, ToTypes.Room);
                ch.SetColor(ATTypes.AT_DEAD);
                ch.SendTo("Oopsie... you're dead!");

                var buffer = $"{ch.Name} hit a DEATH TRAP in room {ch.CurrentRoom.ID}!";
                ChatManager.to_channel(buffer, ChannelTypes.Monitor, "Monitor", (short)LevelConstants.ImmortalLevel);
                ch.Extract(false);
            }
        }
        private static bool EmptyInto(CharacterInstance ch, ObjectInstance obj, RoomTemplate destroom)
        {
            var retVal = false;

            foreach (var cobj in obj.Contents)
            {
                if (ch != null && cobj.ObjectIndex.HasProg(MudProgTypes.Drop) && cobj.Count > 1)
                {
                    cobj.Split();
                    cobj.RemoveFrom(cobj);
                }
                else
                {
                    cobj.RemoveFrom(cobj);
                }

                var tObj = destroom.AddTo(cobj);

                if (ch != null)
                {
                    MudProgHandler.ExecuteObjectProg(MudProgTypes.Drop, ch, tObj);
                    if (ch.CharDied())
                    {
                        ch = null;
                    }
                }
                retVal = true;
            }
            return(retVal);
        }
        public static void CreateFire(RoomTemplate inRoom, int duration, IRepositoryManager dbManager = null)
        {
            var databaseMgr = dbManager ?? RepositoryManager.Instance;
            var fire        = databaseMgr.OBJECTS.Create(databaseMgr.OBJECTTEMPLATES.CastAs <Repository <long, ObjectTemplate> >()
                                                         .Get(VnumConstants.OBJ_VNUM_FIRE), 0);

            fire.Timer = SmaugRandom.Fuzzy(duration);
            inRoom.AddTo(fire);
        }
Example #4
0
        public static void do_atobj(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_IMMORT);

            var firstArg = argument.FirstWord();

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

            ObjectInstance obj = RepositoryManager.Instance.GetEntity <ObjectInstance>(argument);

            if (CheckFunctions.CheckIf(ch, () => obj?.InRoom == null,
                                       "No such object in existence."))
            {
                return;
            }

            RoomTemplate location = obj.InRoom;

            if (location.IsPrivate())
            {
                if (CheckFunctions.CheckIf(ch, () => ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Greater),
                                           "That room is private right now."))
                {
                    return;
                }
                ch.SendTo("Overriding private flag!");
            }

            CharacterInstance victim = location.IsDoNotDisturb(ch);

            if (victim != null)
            {
                ch.PagerPrintf("That room is \"do not disturb\" right now.");
                victim.PagerPrintf("Your do-not-disturb flag just foiled %s's atobj command.", ch.Name);
                return;
            }

            ch.SetColor(ATTypes.AT_PLAIN);
            RoomTemplate original = ch.CurrentRoom;

            ch.CurrentRoom.RemoveFrom(ch);
            location.AddTo(ch);
            interp.interpret(ch, argument);

            if (ch.CharDied())
            {
                return;
            }
            ch.CurrentRoom.RemoveFrom(ch);
            original.AddTo(ch);
        }
Example #5
0
        private static bool CheckAndFireObjectLoading(CharacterInstance ch, ObjectInstance obj)
        {
            if (obj.Value.ToList()[0].IsSet((int)TriggerFlags.ObjectLoad))
            {
                var template = RepositoryManager.Instance.OBJECTTEMPLATES.Get(obj.Value.ToList()[1]);
                if (template == null)
                {
                    // TODO Exception, log it!
                    return(true);
                }

                RoomTemplate room = null;
                if (obj.Value.ToList()[2] > 0)
                {
                    room = RepositoryManager.Instance.ROOMS.Get(obj.Value.ToList()[2]);
                    if (room == null)
                    {
                        // TODO Exception, log it!
                        return(true);
                    }
                }

                var level    = 0.GetNumberThatIsBetween(obj.Value.ToList()[3], LevelConstants.MaxLevel);
                var instance = RepositoryManager.Instance.OBJECTS.Create(template, level);
                if (instance == null)
                {
                    // TODO Exception, log it!
                    return(true);
                }

                if (room != null)
                {
                    room.AddTo(instance);
                }
                else
                {
                    if (obj.WearFlags.IsSet(ItemWearFlags.Take))
                    {
                        instance.AddTo(ch);
                    }
                    else
                    {
                        ch.CurrentRoom.AddTo(instance);
                    }
                }
                return(true);
            }
            return(false);
        }
Example #6
0
        public static void do_at(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_IMMORT);

            var firstArg = argument.FirstWord();

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

            RoomTemplate      location       = null;
            CharacterInstance worldCharacter = null;

            if (argument.IsNumber())
            {
                location = RepositoryManager.Instance.GetEntity <RoomTemplate>(argument);
            }
            else if (argument.EqualsIgnoreCase("pk"))
            {
                // todo get last pkroom
            }
            else
            {
                worldCharacter = RepositoryManager.Instance.GetEntity <CharacterInstance>(argument);
                if (CheckFunctions.CheckIf(ch, () => worldCharacter?.CurrentRoom == null,
                                           "No such mobile or player in the world."))
                {
                    return;
                }
            }

            if (location == null && worldCharacter != null)
            {
                location = worldCharacter.CurrentRoom;
            }

            if (CheckFunctions.CheckIfNullObject(ch, location, "No such location exists."))
            {
                return;
            }

            if (worldCharacter != null && !worldCharacter.IsNpc())
            {
                if (((PlayerInstance)worldCharacter).PlayerData.Flags.IsSet(PCFlags.DoNotDisturb))
                {
                    ch.PagerPrintf("Sorry. %s does not wish to be disturbed.", worldCharacter.Name);
                    worldCharacter.PagerPrintf("Your Do-Not-Disturb flag just foiled %s's AT command.", ch.Name);
                    return;
                }
            }

            if (location.IsPrivate())
            {
                if (CheckFunctions.CheckIf(ch, () => ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Greater),
                                           "That room is private right now."))
                {
                    return;
                }
                ch.SendTo("Overriding private flag!");
            }

            CharacterInstance victim = location.IsDoNotDisturb(ch);

            if (victim != null)
            {
                ch.PagerPrintf("That room is \"do not disturb\" right now.");
                victim.PagerPrintf("Your do-not-disturb flag just foiled %s's atmob command.", ch.Name);
                return;
            }

            ch.SetColor(ATTypes.AT_PLAIN);
            RoomTemplate original = ch.CurrentRoom;

            ch.CurrentRoom.RemoveFrom(ch);
            location.AddTo(ch);
            interp.interpret(ch, argument);

            if (!ch.CharDied())
            {
                ch.CurrentRoom.RemoveFrom(ch);
                original.AddTo(ch);
            }
        }
Example #7
0
        private static void SupplicateForRecall(PlayerInstance ch, string argument)
        {
            var oldfavor = ch.PlayerData.Favor;

            if (CheckFunctions.CheckIfTrue(ch, ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SupplicateRecallCost,
                                           "Your favor is inadequate for such a supplication."))
            {
                return;
            }
            if (CheckFunctions.CheckIfSet(ch, ch.CurrentRoom.Flags, RoomFlags.NoSupplicate, "You have been forsaken!"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.RecentFight) && !ch.IsImmortal(),
                                           "You cannot supplicate recall under adrenaline!"))
            {
                return;
            }

            RoomTemplate location = null;

            if (!ch.IsNpc() && ch.PlayerData.Clan != null)
            {
                location = RepositoryManager.Instance.ROOMS.Get(ch.PlayerData.Clan.RecallRoom);
            }

            if (!ch.IsNpc() && location == null && ch.Level >= 5 && ch.PlayerData.Flags.IsSet(PCFlags.Deadly))
            {
                location = RepositoryManager.Instance.ROOMS.Get(VnumConstants.ROOM_VNUM_DEADLY);
            }

            if (location == null)
            {
                var raceRecallRoom = RepositoryManager.Instance.RACES.Get(ch.CurrentRace.GetValue()).RaceRecallRoom;
                location = RepositoryManager.Instance.ROOMS.Get(raceRecallRoom);
            }

            if (location == null)
            {
                location = RepositoryManager.Instance.ROOMS.Get(VnumConstants.ROOM_VNUM_TEMPLE);
            }

            if (CheckFunctions.CheckIfNullObject(ch, location, "You are completely lost."))
            {
                return;
            }

            comm.act(ATTypes.AT_MAGIC, "$n disappears in a column of divine power.", ch, null, null, ToTypes.Room);

            var oldRoom = ch.CurrentRoom;

            oldRoom.RemoveFrom(ch);
            location.AddTo(ch);

            if (ch.CurrentMount != null)
            {
                oldRoom.RemoveFrom(ch.CurrentMount);
                location.AddTo(ch.CurrentMount);
            }

            comm.act(ATTypes.AT_MAGIC, "$n appears in the room from a column of divine power.", ch, null, null, ToTypes.Room);

            Look.do_look(ch, "auto");
            ch.PlayerData.Favor -= ch.PlayerData.CurrentDeity.SupplicateRecallCost;

            if (ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SusceptNum)
            {
                ch.Susceptibility.SetBit(ch.PlayerData.CurrentDeity.Suscept);
            }

            if ((oldfavor > ch.PlayerData.CurrentDeity.AffectedNum &&
                 ch.PlayerData.Favor <= ch.PlayerData.CurrentDeity.AffectedNum) ||
                (oldfavor > ch.PlayerData.CurrentDeity.ElementNum &&
                 ch.PlayerData.Favor <= ch.PlayerData.CurrentDeity.ElementNum) ||
                (oldfavor < ch.PlayerData.CurrentDeity.SusceptNum &&
                 ch.PlayerData.Favor >= ch.PlayerData.CurrentDeity.SusceptNum))
            {
                ch.update_aris();
            }
        }
Example #8
0
        /// <summary>
        ///This function shared by do_transfer and do_mptransfer
        /// Immortals bypass most restrictions on where to transfer victims.
        /// NPCs cannot transfer victims who are:
        /// 1. Not authorized yet.
        /// 2. Outside of the level range for the target room's area.
        /// 3. Being sent to private rooms.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        /// <param name="location"></param>
        public static void transfer_char(CharacterInstance ch, CharacterInstance victim, RoomTemplate location)
        {
            if (victim.CurrentRoom == null)
            {
                LogManager.Instance.Bug("Victim {0} in null room", victim.Name);
                return;
            }

            if (ch.IsNpc() && location.IsPrivate())
            {
                //progbug("Mptransfer - Private room", ch);
                return;
            }

            if (!ch.CanSee(victim))
            {
                return;
            }

            if (ch.IsNpc() && victim.IsNotAuthorized() &&
                location.Area != victim.CurrentRoom.Area)
            {
                var buffer = $"Mptransfer - unauthed char ({victim.Name})";
                //progbug(buffer, ch);
                return;
            }

            // if victim not in area's level range, do not transfer
            if (ch.IsNpc() && !location.Area.IsInHardRange(victim) &&
                !location.Flags.IsSet((int)RoomFlags.Prototype))
            {
                return;
            }

            if (victim.CurrentFighting != null)
            {
                victim.StopFighting(true);
            }

            if (!ch.IsNpc())
            {
                comm.act(ATTypes.AT_MAGIC, "$n disappears in a cloud of swirling colors.", victim, null, null, ToTypes.Room);
                victim.retran = (int)victim.CurrentRoom.ID;
            }

            victim.CurrentRoom.RemoveFrom(victim);
            location.AddTo(victim);

            if (!ch.IsNpc())
            {
                comm.act(ATTypes.AT_MAGIC, "$n arrives from a puff of smoke.", victim, null, null, ToTypes.Room);
                if (ch != victim)
                {
                    comm.act(ATTypes.AT_IMMORT, "$n has transferred you.", ch, null, victim, ToTypes.Victim);
                }
                Look.do_look(victim, "auto");
                if (!victim.IsImmortal() &&
                    !victim.IsNpc() &&
                    !location.Area.IsInHardRange(victim))
                {
                    comm.act(ATTypes.AT_DANGER, "Warning: this player's level is not within the area's level range.", ch, null, null, ToTypes.Character);
                }
            }
        }