public void ProcessMessage(string text, byte clientId) { var num = Main.rand.Next(1, 101); NetMessage.BroadcastChatMessage( NetworkText.FromFormattable("*{0} {1} {2}", (object)Main.player[clientId].name, (object)Lang.mp[9].ToNetworkText(), (object)num), RESPONSE_COLOR, -1); }
public static void BroadcastChatMessageWithoutTCRFormattable(string text, int excludedPlayer) { NetPacket packet = Terraria.GameContent.NetModules.NetTextModule.SerializeServerMessage( NetworkText.FromFormattable(text), new Color(255, 255, 255), byte.MaxValue); NetManager.Instance.Broadcast(packet, excludedPlayer); }
/// <summary> /// Sends data from the given player. /// </summary> /// <param name="msgType">The sent packet.</param> /// <param name="ply">The packet sender.</param> /// <param name="text">The packet text.</param> /// <param name="number2"></param> /// <param name="number3"></param> /// <param name="number4"></param> /// <param name="number5"></param> public virtual void SendDataFromPlayer(PacketTypes msgType, int ply, string text = "", float number2 = 0f, float number3 = 0f, float number4 = 0f, int number5 = 0) { if (RealPlayer && !ConnectionAlive) { return; } NetMessage.SendData((int)msgType, Index, -1, NetworkText.FromFormattable(text), ply, number2, number3, number4, number5); }
// Token: 0x06001368 RID: 4968 RVA: 0x0041B8AC File Offset: 0x00419AAC public void ProcessMessage(string text, byte clientId) { int num = Main.rand.Next(1, 101); NetMessage.BroadcastChatMessage(NetworkText.FromFormattable("*{0} {1} {2}", new object[] { Main.player[(int)clientId].name, Lang.mp[9].ToNetworkText(), num }), RollCommand.RESPONSE_COLOR, -1); }
public void BroadcastChatMessage(string msg, int excludedPlayerId) { if (msg == null) { return; } NetPacket packet = Terraria.GameContent.NetModules.NetTextModule.SerializeServerMessage( NetworkText.FromFormattable(msg), new Color(255, 255, 255), byte.MaxValue); NetManager.Instance.Broadcast(packet, excludedPlayerId); }
public static void Load() { ChatManager.Register <ColorTagHandler>("c", "color"); ChatManager.Register <ItemTagHandler>("i", "item"); ChatManager.Register <NameTagHandler>("n", "name"); ChatManager.Register <AchievementTagHandler>("a", "achievement"); ChatManager.Register <GlyphTagHandler>("g", "glyph"); ChatManager.Commands.AddCommand <PartyChatCommand>().AddCommand <RollCommand>().AddCommand <EmoteCommand>().AddCommand <ListPlayersCommand>().AddCommand <RockPaperScissorsCommand>().AddCommand <EmojiCommand>().AddCommand <HelpCommand>().AddDefaultCommand <SayChatCommand>(); for (int index = 0; index < 145; ++index) { string name = EmoteID.Search.GetName(index); string key = "EmojiCommand." + name; ChatManager.Commands.AddAlias(Language.GetText(key), NetworkText.FromFormattable("{0} {1}", (object)Language.GetText("ChatCommand.Emoji_1"), (object)Language.GetText("EmojiName." + name))); } }
private static NetworkText ComposeMessage( Dictionary <string, List <LocalizedText> > aliases) { string text = ""; for (int index = 0; index < aliases.Count; ++index) { text = text + "{" + (object)index + "}\n"; } List <NetworkText> networkTextList = new List <NetworkText>(); foreach (KeyValuePair <string, List <LocalizedText> > aliase in aliases) { networkTextList.Add(Language.GetText("ChatCommandDescription." + aliase.Key).ToNetworkText()); } return(NetworkText.FromFormattable(text, (object[])networkTextList.ToArray())); }
private static NetworkText ComposeMessage(Dictionary <string, List <LocalizedText> > aliases) { string text = ""; for (int i = 0; i < aliases.Count; i++) { text = text + "{" + i + "}\n"; } List <NetworkText> list = new List <NetworkText>(); foreach (KeyValuePair <string, List <LocalizedText> > alias in aliases) { list.Add(Language.GetText("ChatCommandDescription." + alias.Key).ToNetworkText()); } string text2 = text; object[] substitutions = list.ToArray(); return(NetworkText.FromFormattable(text2, substitutions)); }
private void OnServerJoin(JoinEventArgs args) { try { var player = Main.player[args.Who]; // -1 is hacky, but works NetPacket packet = Terraria.GameContent.NetModules.NetTextModule.SerializeServerMessage( NetworkText.FromFormattable("This chat is powered by TerrariaChatRelay."), Color.LawnGreen, byte.MaxValue); NetManager.Instance.SendToClient(packet, args.Who); Core.RaiseTerrariaMessageReceived(this, Main.player[args.Who].ToTCRPlayer(-1), $"{Main.player[args.Who].name} has joined."); } catch (Exception) { PrettyPrint.Log("OnServerJoin could not be broadcasted."); } }
public override void NPCLoot(NPC npc) { if (npc.lastInteraction == 255) { //Main.NewText("Accidental Death, score unchanged"); return; } int TEScoreBoardType = TileEntityType <TEScoreBoard>(); foreach (TileEntity current in TileEntity.ByID.Values) { if (current.type == TEScoreBoardType) { //QuickBox is a neat tool for visualizing things while modding. //Dust.QuickBox(npc.position, npc.position + new Vector2(npc.width, npc.height), 1, Color.White, null); var scoreboard = current as TEScoreBoard; if (scoreboard.GetPlayArea().Intersects(npc.getRect())) { Player scoringPlayer = Main.player[npc.lastInteraction]; int score = 0; // Using HalfVector2 and ReinterpretCast.UIntAsFloat is a way to pack a Vector2 into a single float variable. HalfVector2 halfVector = new HalfVector2((current.Position.X + 1) * 16, (current.Position.Y + 1) * 16); Projectile.NewProjectile(npc.Center, Vector2.Zero, ProjectileType <Projectiles.ScorePoint>(), 0, 0, Main.myPlayer, ReLogic.Utilities.ReinterpretCast.UIntAsFloat(halfVector.PackedValue), npc.lastInteraction); scoreboard.scores.TryGetValue(scoringPlayer.name, out score); scoreboard.scores[scoringPlayer.name] = score + 1; if (Main.dedServ) { NetworkText text = NetworkText.FromFormattable("{0}: {1}", scoringPlayer.name, scoreboard.scores[scoringPlayer.name]); NetMessage.BroadcastChatMessage(text, Color.White); } else { Main.NewText(scoringPlayer.name + ": " + scoreboard.scores[scoringPlayer.name]); } scoreboard.scoresChanged = true; } } } }
public void ProcessIncomingMessage(string text, byte clientId) { int num = Main.rand.Next(1, 101); ChatHelper.BroadcastChatMessage(NetworkText.FromFormattable("*{0} {1} {2}", Main.player[clientId].name, Lang.mp[9].ToNetworkText(), num), RESPONSE_COLOR); }
public void ProcessIncomingMessage(string text, byte clientId) { int num = Main.rand.Next(1, 101); ChatHelper.BroadcastChatMessage(NetworkText.FromFormattable("*{0} {1} {2}", (object)Main.player[(int)clientId].name, (object)Lang.mp[9].ToNetworkText(), (object)num), RollCommand.RESPONSE_COLOR, -1); }
public override void ProcessTriggers(TriggersSet triggersSet) { if (AIDistort.AIScrambleHotKey.JustPressed && hotkeyCooldown == 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { #region Hotkey if (!GetInstance <AIScramblerConfig>().AIScrambleBoolean) { GetInstance <AIScramblerConfig>().AIScrambleBoolean = true; if (Main.dedServ) { NetworkText text = NetworkText.FromFormattable("[c/0AFF00:AI Scramble is ON!]"); NetMessage.BroadcastChatMessage(text, Color.White); } else { Main.NewText("[c/0AFF00:AI Scramble is ON!]"); } if (GetInstance <AIScramblerConfig>().HotkeyCooldown) { hotkeyCooldown = 600; } } else if (GetInstance <AIScramblerConfig>().AIScrambleBoolean) { GetInstance <AIScramblerConfig>().AIScrambleBoolean = false; if (Main.dedServ) { NetworkText text = NetworkText.FromFormattable("[c/FF0000:AI Scramble is OFF!]"); NetMessage.BroadcastChatMessage(text, Color.White); } else { Main.NewText("[c/FF0000:AI Scramble is OFF!]"); } if (GetInstance <AIScramblerConfig>().HotkeyCooldown) { hotkeyCooldown = 600; } } #endregion } else if (Main.netMode == NetmodeID.MultiplayerClient && GetInstance <AIScramblerConfig>().ClientHotkeyPermission) { #region Hotkey if (!GetInstance <AIScramblerConfig>().AIScrambleBoolean) { GetInstance <AIScramblerConfig>().AIScrambleBoolean = true; if (Main.dedServ) { NetworkText text = NetworkText.FromFormattable("[c/0AFF00:AI Scramble is ON!]"); NetMessage.BroadcastChatMessage(text, Color.White); } else { Main.NewText("[c/0AFF00:AI Scramble is ON!]"); } hotkeyCooldown = 600; } else if (GetInstance <AIScramblerConfig>().AIScrambleBoolean) { GetInstance <AIScramblerConfig>().AIScrambleBoolean = false; if (Main.dedServ) { NetworkText text = NetworkText.FromFormattable("[c/FF0000:AI Scramble is OFF!]"); NetMessage.BroadcastChatMessage(text, Color.White); } else { Main.NewText("[c/FF0000:AI Scramble is OFF!]"); } hotkeyCooldown = 600; } #endregion } } #region Randomize Player Hotkey if (AIDistort.PlayerRandomize.JustPressed && !GetInstance <PlayerRandomizeConfig>().NoRandom&& !reset && !rainbow) { ItemLoader.UpdateVanitySet(player); if (GetInstance <PlayerRandomizeConfig>().RandomizeEyeColor) { player.eyeColor = randomizeColor(); } if (GetInstance <PlayerRandomizeConfig>().RandomizeSkinColor) { player.skinColor = randomizeColor(); if (GetInstance <PlayerRandomizeConfig>().SkinChangeType) { float num13 = (float)Main.rand.Next(60, 120) * 0.01f; if (num13 > 1f) { num13 = 1f; } player.skinColor.R = (byte)((float)Main.rand.Next(240, 255) * num13); player.skinColor.G = (byte)((float)Main.rand.Next(110, 140) * num13); player.skinColor.B = (byte)((float)Main.rand.Next(75, 110) * num13); } } if (GetInstance <PlayerRandomizeConfig>().RandomizeShoeColor) { player.shoeColor = randomizeColor(); } if (GetInstance <PlayerRandomizeConfig>().RandomizePantsColor) { player.pantsColor = randomizeColor(); } if (GetInstance <PlayerRandomizeConfig>().RandomizeShirtColor) { player.shirtColor = randomizeColor(); } if (GetInstance <PlayerRandomizeConfig>().RandomizeUndershirtColor) { player.underShirtColor = randomizeColor(); } if (GetInstance <PlayerRandomizeConfig>().RandomizeHairColor) { player.hairColor = randomizeColor(); } if (GetInstance <PlayerRandomizeConfig>().RandomizeHair) { if (player.name == "The Chosen One") { player.hair = Main.rand.Next(0, 134); } else { if (NPC.savedStylist) { player.hair = Main.rand.Next(0, 124); } else if (NPC.savedStylist && NPC.downedMartians) { player.hair = Main.rand.Next(0, 134); } else if (NPC.savedStylist && NPC.downedMartians && NPC.downedMoonlord) { player.hair = Main.rand.Next(0, 135); } else { player.hair = Main.rand.Next(0, 52); } } } if (GetInstance <PlayerRandomizeConfig>().RandomizeClothes) { CycleClothingStyle(player); } if (GetInstance <PlayerRandomizeConfig>().RandomizeGender) { int gender = Main.rand.Next(2); if (gender == 0) { player.Male = true; if (GetInstance <PlayerRandomizeConfig>().IndicatorAGender) { Main.PlaySound(SoundID.PlayerHit, player.position); } if (GetInstance <PlayerRandomizeConfig>().IndicatorVGender) { for (int i = 0; i < 25; i++) { Vector2 position = player.Center + Vector2.UnitX.RotatedBy(MathHelper.ToRadians(360f / 25 * i)); Dust dust = Dust.NewDustPerfect(position, DustID.BlueCrystalShard); dust.noGravity = true; dust.velocity = Vector2.Normalize(dust.position - player.Center) * 4; dust.noLight = false; dust.fadeIn = 1f; } } } if (gender == 1) { player.Male = false; if (GetInstance <PlayerRandomizeConfig>().IndicatorAGender) { Main.PlaySound(SoundID.FemaleHit, player.position); } if (GetInstance <PlayerRandomizeConfig>().IndicatorVGender) { for (int i = 0; i < 25; i++) { Vector2 position = player.Center + Vector2.UnitX.RotatedBy(MathHelper.ToRadians(360f / 25 * i)); Dust dust = Dust.NewDustPerfect(position, DustID.PinkCrystalShard); dust.noGravity = true; dust.velocity = Vector2.Normalize(dust.position - player.Center) * 4; dust.noLight = false; dust.fadeIn = 1f; } } } } } #endregion if (AIDistort.ButcherHotKey.JustReleased && !AIWorld.butcher) { AIWorld.butcher = true; } }