示例#1
0
        public static int GetLevelExperience(this CharacterInstance ch, int cexp)
        {
            var x = LevelConstants.GetLevel(ImmortalTypes.Supreme);
            var y = 0;

            while (y == 0)
            {
                var tmp   = ch.GetExperienceLevel(x);
                int lastx = x;
                if (tmp > cexp)
                {
                    x /= 2;
                }
                else if (lastx != x)
                {
                    x += x / 2;
                }
                else
                {
                    y = x;
                }
            }

            return(y <1 ? 1 : y> LevelConstants.GetLevel(ImmortalTypes.Supreme)
                ? LevelConstants.GetLevel(ImmortalTypes.Supreme) : y);
        }
示例#2
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);
        }
示例#3
0
    /// <summary>
    /// Updates the overview of the lobby and receives the signal to start the level per remote.
    ///
    /// CALLBACK FUNCTION FOR TCP-Request.
    /// </summary>
    /// <param name="response">Response.</param>
    private void UpdateView(string[][] response)
    {
        headline.text = "Wait for Players in Session " + UserStatics.SessionId.ToString();
        string ret = "";

        foreach (string[] pair in response)
        {
            if (pair [0].Equals("playerInSession"))
            {
                ret += pair [1];
            }
            string   pattern   = @"//";
            string[] usernames = Regex.Split(ret, pattern);

            for (int i = 0; i < usernames.Length; i++)
            {
                users [i].text      = usernames [i];
                users [i].fontStyle = FontStyle.Bold;
                if (UserStatics.GetUserName(UserStatics.IdSelf).Equals(usernames [i]))
                {
                    users [i].color = Constants.userColor;
                }
                else if (usernames[i].Equals(Constants.noUser))
                {
                    users [i].text      = Constants.freeUser;
                    users [i].fontStyle = FontStyle.Normal;
                    users [i].color     = Constants.textColor;
                }
                else
                {
                    users [i].color = Constants.textColor;
                }
            }

            if (pair [0].Equals(Constants.sfLevelindex))
            {
                int levelindex = 0;
                int.TryParse(pair [1], out levelindex);
                currentLevelIndex = levelindex;
                AssignLevel(LevelConstants.GetLevel(levelindex));
            }

            // Check if the session is ment to be started.
            if (pair [0].Equals(Constants.sfState) && pair [1].Equals(Constants.sfStarting))
            {
                // Start the session.
                gameObject.GetComponent <StartSession> ().StartTheSession();
            }
        }
    }
        private void AddToLists(Employee employee, LevelConstants level, ref List <string> emails, ref List <string> names)
        {
            Employee workOn = null;

            switch (level)
            {
            case LevelConstants.Self:
                workOn = employee;
                break;

            case LevelConstants.Boss:
                workOn = employee?.Supervisor;
                break;

            case LevelConstants.BossesBoss:
                workOn = employee?.Supervisor?.Supervisor;
                break;
            }

            if (workOn == null)
            {
                return;
            }

            var name = workOn.OwnerText(false);

            if (!string.IsNullOrWhiteSpace(name))
            {
                names.Add(name);
            }

            var email = workOn.Email?.ToLower();

            if (!string.IsNullOrWhiteSpace(email))
            {
                emails.Add(email);
            }
        }
示例#5
0
    /// <summary>
    /// Assigns the session just created (on server) to the user on this client.
    ///
    /// CALLBACK FUNCTION FOR TCP-Request.
    /// </summary>
    /// <param name="response">Response.</param>
    public void AssignSessionToUser(string[][] response)
    {
        int SsIdTmp = -1;

        foreach (string[] pair in response)
        {
            if (pair [0].Equals("type") && pair [1].Equals("ERROR"))
            {
                GameObject.Find("ErrorText").GetComponent <ErrorText> ().ShowError("Couldn't create Session!");
                return;
            }
            if (pair[0].Equals("sessionId"))
            {
                int.TryParse(pair[1], out SsIdTmp);
                UserStatics.SessionId = SsIdTmp;
                mainMenuCanvas.SetActive(false);
                createSessionCanvas.SetActive(true);
                ChooseLevel(LevelConstants.GetLevel(currentLevelIndex));
                StartUpdateLobby();
                return;
            }
        }
    }
示例#6
0
        public static void do_typo(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_PLAIN);

            if (CheckFunctions.CheckIfEmptyString(ch, argument,
                                                  "Usage:  'typo <message>'  (your location is automatically recorded)"))
            {
                if (ch.Trust >= LevelConstants.GetLevel(ImmortalTypes.Ascendant))
                {
                    ch.SendTo("Usage:  'typo list' or 'typo clear now'");
                }
                return;
            }

            if (!argument.EqualsIgnoreCase("clear now") || ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Ascendant))
            {
                return;
            }
            var path = SystemConstants.GetSystemFile(SystemFileTypes.Typo);

            using (var proxy = new TextWriterProxy(new StreamWriter(path, false)))
                proxy.Write(string.Empty);
            ch.SendTo("Typo file cleared.");
        }
示例#7
0
 /// <summary>
 /// Toggles to the next level in list of all levels in game.
 /// </summary>
 public void ToggleNextLevel()
 {
     currentLevelIndex = currentLevelIndex > LevelConstants.NumberOfLevels() - 2 ? 0 : ++currentLevelIndex;
     ChooseLevel(LevelConstants.GetLevel(currentLevelIndex));
 }
示例#8
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);
        }
示例#9
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);
            }
        }
示例#10
0
 private static int GetVnumFromArgumentIfImmortal(CharacterInstance ch, string arg)
 {
     return(ch.Trust >= LevelConstants.GetLevel(ImmortalTypes.Savior) && arg.IsNumber() ? arg.ToInt32() : -1);
 }
示例#11
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);
        }
示例#12
0
        public static void ShowToCharacter(this CharacterInstance victim, PlayerInstance ch)
        {
            var buffer = string.Empty;

            ch.SetColor(ATTypes.AT_PERSON);
            if (!victim.IsNpc())
            {
                if (victim.Switched == null)
                {
                    ch.SendTo("&P[(Link Dead)]");
                }
                else if (!victim.IsAffected(AffectedByTypes.Possess))
                {
                    buffer += "(Switched) ";
                }
            }

            if (victim.IsNpc() &&
                victim.IsAffected(AffectedByTypes.Possess) &&
                ch.IsImmortal() && ch.Switched != null)
            {
                buffer += "(" + victim.Switched.Name + ")";
            }

            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.AwayFromKeyboard))
            {
                buffer += PlayerFlags.AwayFromKeyboard.GetAttribute <DescriptorAttribute>().Messages.ToList()[0];
            }

            if ((!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.WizardInvisibility)) ||
                (victim.IsNpc() && victim.Act.IsSet((int)ActFlags.MobInvisibility)))
            {
                if (!victim.IsNpc())
                {
                    buffer += $"(Invis {((PlayerInstance)victim).PlayerData.WizardInvisible}) ";
                }
                else
                {
                    buffer += $"(MobInvis {victim.MobInvisible}) ";
                }
            }

            if (!victim.IsNpc())
            {
                var vict = (PlayerInstance)victim;
                if (vict.IsImmortal() && vict.Level > LevelConstants.GetLevel(ImmortalTypes.Avatar))
                {
                    ch.SendTo("&P(&WImmortal&P) ");
                }
                if (vict.PlayerData.Clan != null &&
                    vict.PlayerData.Flags.IsSet(PCFlags.Deadly) &&
                    !string.IsNullOrEmpty(vict.PlayerData.Clan.Badge) &&
                    (vict.PlayerData.Clan.ClanType != ClanTypes.Order ||
                     vict.PlayerData.Clan.ClanType != ClanTypes.Guild))
                {
                    ch.PrintfColor("%s ", vict.PlayerData.Clan.Badge);
                }
                else if (vict.CanPKill() && vict.Level < LevelConstants.ImmortalLevel)
                {
                    ch.SendTo("&P(&wUnclanned&P) ");
                }
            }

            ch.SetColor(ATTypes.AT_PERSON);

            buffer += GenerateBufferForAffectedBy(victim, ch);

            ch.SetColor(ATTypes.AT_PERSON);
            if ((victim.CurrentPosition == victim.CurrentDefensivePosition && !string.IsNullOrEmpty(victim.LongDescription)) ||
                (victim.CurrentMorph?.Morph != null && victim.CurrentMorph.Morph.Position == (int)victim.CurrentPosition))
            {
                if (victim.CurrentMorph != null)
                {
                    if (!ch.IsImmortal())
                    {
                        if (victim.CurrentMorph.Morph != null)
                        {
                            buffer += victim.CurrentMorph.Morph.LongDescription;
                        }
                        else
                        {
                            buffer += victim.LongDescription;
                        }
                    }
                    else
                    {
                        buffer += Macros.PERS(victim, ch);
                        if (!victim.IsNpc() && !ch.Act.IsSet((int)PlayerFlags.Brief))
                        {
                            buffer += ((PlayerInstance)victim).PlayerData.Title;
                        }
                        buffer += ".\r\n";
                    }
                }
                else
                {
                    buffer += victim.LongDescription;
                }
                ch.SendTo(buffer);
                ch.ShowVisibleAffectsOn(victim);
                return;
            }

            if (victim.CurrentMorph?.Morph != null && !ch.IsImmortal())
            {
                buffer += Macros.MORPHERS(victim, ch);
            }
            else
            {
                buffer += Macros.PERS(victim, ch);
            }

            if (!victim.IsNpc() && !ch.Act.IsSet((int)PlayerFlags.Brief))
            {
                buffer += ((PlayerInstance)victim).PlayerData.Title;
            }

            var timer = ch.GetTimer(TimerTypes.DoFunction);

            if (timer != null)
            {
                var attributes = timer.Action.Value.Method.GetCustomAttributes(typeof(DescriptorAttribute), false);
                var attrib     =
                    (DescriptorAttribute)attributes.FirstOrDefault(x => x is DescriptorAttribute);
                buffer += attrib == null ? " is looking rather lost." : attrib.Messages.First();
            }
            else
            {
                buffer += GenerateBufferDescriptorFromVictimPosition(victim, ch);
            }

            buffer += "\r\n";
            buffer  = buffer.CapitalizeFirst();
            ch.SendTo(buffer);
            ch.ShowVisibleAffectsOn(victim);
        }
示例#13
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);
        }
示例#14
0
        public static CharacterInstance scan_for_victim(CharacterInstance ch, ExitData pexit, string name)
        {
            if (ch.IsAffected(AffectedByTypes.Blind) || pexit == null)
            {
                return(null);
            }

            var was_in_room  = ch.CurrentRoom;
            var max_distance = 8;

            if (ch.IsVampire() && GameManager.Instance.GameTime.Hour < 21 && GameManager.Instance.GameTime.Hour > 5)
            {
                max_distance = 1;
            }

            if (ch.Level < 50)
            {
                --max_distance;
            }
            if (ch.Level < 40)
            {
                --max_distance;
            }
            if (ch.Level < 30)
            {
                --max_distance;
            }

            for (int dist = 1; dist <= max_distance; dist++)
            {
                if (pexit.Flags.IsSet(ExitFlags.Closed))
                {
                    break;
                }

                if (pexit.GetDestination().IsPrivate() &&
                    ch.Level < LevelConstants.GetLevel(ImmortalTypes.Greater))
                {
                    break;
                }

                ch.CurrentRoom.RemoveFrom(ch);
                pexit.GetDestination().AddTo(ch);

                var victim = ch.GetCharacterInRoom(name);
                if (victim != null)
                {
                    ch.CurrentRoom.RemoveFrom(ch);
                    was_in_room.AddTo(ch);
                    return(victim);
                }

                switch (ch.CurrentRoom.SectorType)
                {
                default:
                    dist++;
                    break;

                case SectorTypes.Air:
                    if (SmaugRandom.D100() < 80)
                    {
                        dist++;
                    }
                    break;

                case SectorTypes.Forest:
                case SectorTypes.City:
                case SectorTypes.Desert:
                case SectorTypes.Hills:
                    dist += 2;
                    break;

                case SectorTypes.ShallowWater:
                case SectorTypes.DeepWater:
                    dist += 3;
                    break;

                case SectorTypes.Mountain:
                case SectorTypes.Underwater:
                case SectorTypes.OceanFloor:
                    dist += 4;
                    break;
                }

                if (dist >= max_distance)
                {
                    break;
                }

                var dir  = pexit.Direction;
                var exit = ch.CurrentRoom.GetExit(dir);
                if (exit == null)
                {
                    break;
                }
            }

            ch.CurrentRoom.RemoveFrom(ch);
            was_in_room.AddTo(ch);

            return(null);
        }