public static void towizfile(string line) { var outline = string.Empty; if (!string.IsNullOrEmpty(line)) { var filler = 78 - line.Length; if (filler < 1) { filler = 1; } filler /= 2; for (var x = 0; x < filler; x++) { outline += " "; } outline += line; } outline += "\r\n"; using ( var proxy = new TextWriterProxy(new StreamWriter(SystemConstants.GetSystemFile(SystemFileTypes.Wizards), true))) { proxy.Write(outline); } }
public static void shutdown_mud(string reason) { var path = SystemConstants.GetSystemFile(SystemFileTypes.Shutdown); using (var proxy = new TextWriterProxy(new StreamWriter(path, true))) { proxy.Write("{0}\n", reason); } }
private static void SendFileToBuffer(CharacterInstance ch, SystemFileTypes fileType) { string path = SystemConstants.GetSystemFile(fileType); using (TextReaderProxy proxy = new TextReaderProxy(new StreamReader(path))) { string buffer = proxy.ReadToEnd(); comm.write_to_buffer(ch.Descriptor, buffer, buffer.Length); } }
private static void SendFileToBuffer(this PlayerInstance ch, SystemFileTypes fileType) { var path = SystemConstants.GetSystemFile(fileType); using (var proxy = new TextReaderProxy(new StreamReader(path))) { var buffer = proxy.ReadToEnd(); ch.Descriptor.WriteToBuffer(buffer, buffer.Length); } }
public static void do_idea(CharacterInstance ch, string argument) { ch.SetColor(ATTypes.AT_PLAIN); if (CheckFunctions.CheckIfEmptyString(ch, argument, "Usage: 'idea <message>'\r\n")) { return; } db.append_file(ch, SystemConstants.GetSystemFile(SystemFileTypes.Idea), argument); ch.SendTo("Thanks, your idea has been recorded."); }
private static void InitializeManagersAndGameSettings() { LogManager = Kernel.Get <ILogManager>(); LogManager.Boot("-----------------------[ Boot Log ]----------------------"); var loaded = SystemConstants.LoadSystemDirectoriesFromConfig(GameConstants.DataPath); LogManager.Boot("{0} SystemDirectories loaded.", loaded); loaded = SystemConstants.LoadSystemFilesFromConfig(); LogManager.Boot("{0} SystemFiles loaded.", loaded); LookupManager = Kernel.Get <ILookupManager>(); LuaManager = Kernel.Get <ILuaManager>(); NetworkManager = Kernel.Get <ITcpServer>(); NetworkManager.Startup(Convert.ToInt32(ConfigurationManager.AppSettings["port"]), IPAddress.Parse(ConfigurationManager.AppSettings["host"])); NetworkManager.OnTcpUserStatusChanged += NetworkManager_OnOnTcpUserStatusChanged; RepositoryManager = Kernel.Get <IRepositoryManager>(); var luaInitializer = Kernel.Get <IInitializer>("LuaInitializer"); if (luaInitializer == null) { throw new ApplicationException("LuaInitializer failed to start"); } LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Lookups)); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.StatModLookups)); BanManager = Kernel.Get <IBanManager>(); BoardManager = Kernel.Get <IBoardManager>(); CalendarManager = Kernel.Get <ICalendarManager>(); GameManager = Kernel.Get <IGameManager>(); GameManager.SetGameTime(CalendarManager.GameTime); GameManager.GameTime.SetTimeOfDay(GameConstants.GetSystemValue <int>("HourOfSunrise"), GameConstants.GetSystemValue <int>("HourOfDayBegin"), GameConstants.GetSystemValue <int>("HourOfSunset"), GameConstants.GetSystemValue <int>("HourOfNightBegin")); WeatherManager = Kernel.Get <IWeatherManager>(); NewsManager = Kernel.Get <INewsManager>(); AuctionManager = Kernel.Get <IAuctionManager>(); ClanManager = Kernel.Get <IClanManager>(); InitializeStaticGameData(); }
public static void do_bug(CharacterInstance ch, string argument) { var tm = DateTime.Now; ch.SetColor(ATTypes.AT_PLAIN); if (CheckFunctions.CheckIfEmptyString(ch, argument, "Usage: 'bug <message>' (your location is automatically recorded)")) { return; } db.append_file(ch, SystemConstants.GetSystemFile(SystemFileTypes.PBug), $"({tm.ToLongDateString()}): {argument}"); ch.SendTo("Thanks, your bug notice has been recorded."); }
public void LoadMap(SystemFileTypes fileType, IEnumerable <string> map) { var path = SystemConstants.GetSystemFile(fileType); using (var proxy = new TextReaderProxy(new StreamReader(path))) { IEnumerable <string> lines = proxy.ReadIntoList(); if (!lines.Any()) { throw new InvalidDataException($"Missing data for {fileType}"); } map.ToList().AddRange(lines); } }
private static void LoadSystemDataFromLuaScripts() { LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Commands)); LogManager.Boot("{0} Commands loaded.", RepositoryManager.COMMANDS.Count); LookupManager.CommandLookup.UpdateFunctionReferences(RepositoryManager.COMMANDS.Values); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.SpecFuns)); LogManager.Boot("{0} SpecFuns loaded.", RepositoryManager.SPEC_FUNS.Count); //SpecFunLookupTable.UpdateCommandFunctionReferences(RepositoryManager.Instance.SPEC_FUNS.Values); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Socials)); LogManager.Boot("{0} Socials loaded.", RepositoryManager.SOCIALS.Count); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Skills)); LogManager.Boot("{0} Skills loaded.", RepositoryManager.SKILLS.Count); LookupManager.SkillLookup.UpdateFunctionReferences(RepositoryManager.SKILLS.Values); LookupManager.SpellLookup.UpdateFunctionReferences(RepositoryManager.SKILLS.Values); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Liquids)); LogManager.Boot("{0} Liquids loaded.", RepositoryManager.LIQUIDS.Count); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Mixtures)); LogManager.Boot("{0} Mixtures loaded.", RepositoryManager.GetRepository <MixtureData>(RepositoryTypes.Mixtures).Count); // TODO: Update function references LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Herbs)); LogManager.Boot("{0} Herbs loaded.", RepositoryManager.HERBS.Count); LookupManager.SkillLookup.UpdateFunctionReferences(RepositoryManager.HERBS.Values); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Tongues)); LogManager.Boot("{0} Tongues loaded.", RepositoryManager.LANGUAGES.Count); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Planes)); LogManager.Boot("{0} Planes loaded.", RepositoryManager.PLANES.Count); LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Morphs)); LogManager.Boot("{0} Morphs loaded.", RepositoryManager.MORPHS.Count); }
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."); }
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); }
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); }
public static void talk_channel(CharacterInstance ch, string argument, ChannelTypes channel, string verb) { #if !SCRAMBLE var speaking = -1; /*foreach (int key in GameConstants.LanguageTable.Keys * .Where(key => (key & ch.Speaking) > 0)) * { * speaking = key; * break; * }*/ #endif if (ch.IsNpc()) { var message = string.Empty; switch (channel) { case ChannelTypes.Clan: message = "Mobs can't be in clans.\r\n"; break; case ChannelTypes.Order: message = "Mobs can't be in orders.\r\n"; break; case ChannelTypes.Guild: message = "Mobs can't be in guilds.\r\n"; break; case ChannelTypes.Council: message = "Mobs can't be in councils.\r\n"; break; default: if (ch.IsAffected(AffectedByTypes.Charm)) { if (ch.Master != null) { ch.Master.SendTo("I don't think so..."); return; } } break; } if (!string.IsNullOrEmpty(message)) { ch.SendTo(message); return; } } if (!ch.IsPKill() && channel == ChannelTypes.WarTalk && !ch.IsImmortal()) { ch.SendTo("Peacefuls have no need to use wartalk."); return; } if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Silence)) { ch.SendTo("You can't do that here."); return; } if (!ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Silence)) { ch.Printf("You can't %s.\r\n", verb); return; } if (string.IsNullOrEmpty(argument)) { ch.SendTo($"{verb} what?\r\n".CapitalizeFirst()); return; } ch.Deaf.RemoveBit((int)channel); ch.SetColor(GetColorForChannelTalk(channel)); var buffer = string.Empty; switch (channel) { case ChannelTypes.RaceTalk: ch.Printf("You %s '%s'\r\n", verb, argument); buffer = $"$n {verb}s '$t'"; break; case ChannelTypes.Traffic: ch.Printf("You %s: %s\r\n", verb, argument); buffer = $"$n {verb}s: $t"; break; case ChannelTypes.WarTalk: ch.Printf("You %s '%s'\r\n", verb, argument); buffer = $"$n {verb}s '$t'"; break; case ChannelTypes.AvTalk: case ChannelTypes.ImmTalk: { var position = ch.CurrentPosition; comm.act(ATTypes.AT_IMMORT, $"$n{(channel == ChannelTypes.ImmTalk ? '>' : ':')} $t", ch, argument, null, ToTypes.Character); ch.CurrentPosition = position; } break; default: ch.Printf("You %s '%s'\r\n", verb, argument); buffer = $"$n {verb}s '$t'"; break; } if (ch.CurrentRoom.Flags.IsSet(RoomFlags.LogSpeech)) { db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log), $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argument} ({verb})"); } foreach (var d in db.DESCRIPTORS) { var och = d.Original ?? d.Character; var vch = d.Character; if (d.ConnectionStatus == ConnectionTypes.Playing && vch != ch && !och.Deaf.IsSet((int)channel)) { var sbuf = argument; if (och.IsIgnoring(ch) && (ch.Trust <= och.Trust)) { continue; } if (channel != ChannelTypes.Newbie && och.IsNotAuthorized()) { continue; } if (channel == ChannelTypes.ImmTalk && !och.IsImmortal()) { continue; } if (channel == ChannelTypes.WarTalk && och.IsNotAuthorized()) { continue; } if (channel == ChannelTypes.AvTalk && !och.IsHero()) { continue; } if (channel == ChannelTypes.Highgod && och.Trust < GameManager.Instance.SystemData.GetMinimumLevel(PlayerPermissionTypes.MuseLevel)) { continue; } if (channel == ChannelTypes.High && och.Trust < GameManager.Instance.SystemData.GetMinimumLevel(PlayerPermissionTypes.ThinkLevel)) { continue; } if (channel == ChannelTypes.Traffic && !och.IsImmortal() && !ch.IsImmortal()) { if ((ch.IsHero() && !och.IsHero()) || (!ch.IsHero() && och.IsHero())) { continue; } } if (channel == ChannelTypes.Newbie && !och.IsImmortal() && !och.IsNotAuthorized() && !(och.PlayerData.Council != null && och.PlayerData.Council.Name.Equals("Newbie Council"))) { continue; } if (vch.CurrentRoom.Flags.IsSet((int)RoomFlags.Silence)) { continue; } if (channel == ChannelTypes.Yell && vch.CurrentRoom.Area != ch.CurrentRoom.Area) { continue; } if ((channel == ChannelTypes.Clan || channel == ChannelTypes.Order || channel == ChannelTypes.Guild) && (vch.IsNpc() || vch.PlayerData.Clan != ((PlayerInstance)ch).PlayerData.Clan)) { continue; } if (channel == ChannelTypes.Council && (vch.IsNpc() || vch.PlayerData.Council != ((PlayerInstance)ch).PlayerData.Council)) { continue; } if (channel == ChannelTypes.RaceTalk && vch.CurrentRace != ch.CurrentRace) { continue; } var lbuf = string.Empty; if (ch.Act.IsSet((int)PlayerFlags.WizardInvisibility) && vch.CanSee(ch) && vch.IsImmortal()) { lbuf = $"({(!ch.IsNpc() ? ((PlayerInstance)ch).PlayerData.WizardInvisible : ch.MobInvisible)})"; } var position = vch.CurrentPosition; if (channel != ChannelTypes.Shout && channel != ChannelTypes.Yell) { vch.CurrentPosition = PositionTypes.Standing; } #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 < 85) * 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 if (!ch.IsNpc() && ((PlayerInstance)ch).PlayerData.Nuisance != null && ((PlayerInstance)ch).PlayerData.Nuisance.Flags > 7 && (SmaugRandom.D100() < (((PlayerInstance)ch).PlayerData.Nuisance.Flags - 7) * 10 * ((PlayerInstance)ch).PlayerData.Nuisance.Power)) { sbuf = argument.Scramble(SmaugRandom.Between(1, 10)); } if (!vch.IsNpc() && vch.PlayerData.Nuisance != null && vch.PlayerData.Nuisance.Flags > 7 && (SmaugRandom.D100() < (vch.PlayerData.Nuisance.Flags - 7) * 10 * vch.PlayerData.Nuisance.Power)) { sbuf = argument.Scramble(SmaugRandom.Between(1, 10)); } // TODO Toggle global mobtrigger flag lbuf = lbuf + buffer; switch (channel) { case ChannelTypes.ImmTalk: case ChannelTypes.AvTalk: comm.act(ATTypes.AT_IMMORT, lbuf, ch, sbuf, vch, ToTypes.Victim); break; case ChannelTypes.WarTalk: comm.act(ATTypes.AT_WARTALK, lbuf, ch, sbuf, vch, ToTypes.Victim); break; case ChannelTypes.RaceTalk: comm.act(ATTypes.AT_RACETALK, lbuf, ch, sbuf, vch, ToTypes.Victim); break; default: comm.act(ATTypes.AT_GOSSIP, lbuf, ch, sbuf, vch, ToTypes.Victim); break; } vch.CurrentPosition = position; } } }
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); }
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); }