public static void CheckNight() { var flag = false; if (BirthdayParty.GenuineParty) { flag = true; BirthdayParty.GenuineParty = false; BirthdayParty.CelebratingNPCs.Clear(); } if (BirthdayParty.ManualParty) { flag = true; BirthdayParty.ManualParty = false; } if (!flag) { return; } var color = new Color((int)byte.MaxValue, 0, 160); WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[99].Key), color); }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (Sandstorm.Happening == true) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(sandoff), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(sandoff), messageColor); } Sandstorm.Happening = false; Sandstorm.TimeLeft = 0; SandstormStuff(); return(true); } else if (Sandstorm.Happening == false) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(sandon), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(sandon), messageColor); } Sandstorm.Happening = true; Sandstorm.TimeLeft = (int)(3600.0 * (8.0 + (double)Main.rand.NextFloat() * 16.0)); SandstormStuff(); return(true); } return(false); }
public override bool UseItem(Player player) { if (Main.moonPhase == 4) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey("The moon phase advanced in order to start the blood moon."), new Color(255, 255, 0)); } else if (Main.netMode == 0) // Single Player { Main.NewText("The moon phase advanced in order to start the blood moon.", 255, 255, 0); } Main.moonPhase++; } Main.bloodMoon = true; if (Main.netMode == 0) { Main.NewText(Lang.misc[8].Value, 50, byte.MaxValue, 130); } else if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(Lang.misc[8].ToNetworkText(), new Color(50, 255, 130)); } return(true); }
public override bool UseItem(Player player) { if (Main.moonPhase == 4) { if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("The moon phase advanced in order to start the blood moon."), new Color(255, 255, 0)); } else if (Main.netMode == NetmodeID.SinglePlayer) // Single Player { Main.NewText("The moon phase advanced in order to start the blood moon.", 255, 255, 0); } Main.moonPhase++; } Main.bloodMoon = true; AchievementsHelper.NotifyProgressionEvent(4); if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(Lang.misc[8].Value, 50, byte.MaxValue, 130); } else if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(Lang.misc[8].ToNetworkText(), new Color(50, 255, 130)); } if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(7); } return(true); }
private static void StartRain() { if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("The rain started to fade in."), new Color(0, 128, 255)); } else { Main.NewText("The rain started to fade in.", 0, 128, 255); } int num = 86400; int num2 = num / 24; Main.rainTime = Main.rand.Next(num2 * 8, num); if (Main.rand.Next(3) == 0) { Main.rainTime += Main.rand.Next(0, num2); } if (Main.rand.Next(4) == 0) { Main.rainTime += Main.rand.Next(0, num2 * 2); } if (Main.rand.Next(5) == 0) { Main.rainTime += Main.rand.Next(0, num2 * 2); } if (Main.rand.Next(6) == 0) { Main.rainTime += Main.rand.Next(0, num2 * 3); } if (Main.rand.Next(7) == 0) { Main.rainTime += Main.rand.Next(0, num2 * 4); } if (Main.rand.Next(8) == 0) { Main.rainTime += Main.rand.Next(0, num2 * 5); } float num3 = 1f; if (Main.rand.Next(2) == 0) { num3 += 0.05f; } if (Main.rand.Next(3) == 0) { num3 += 0.1f; } if (Main.rand.Next(4) == 0) { num3 += 0.15f; } if (Main.rand.Next(5) == 0) { num3 += 0.2f; } Main.rainTime = (int)((float)Main.rainTime * num3); ChangeRain(); Main.raining = true; }
public override bool UseItem(Player player) { if (Sandstorm.Happening == true) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(sandoff), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(sandoff), messageColor); } Sandstorm.Happening = false; Sandstorm.TimeLeft = 0; SandstormStuff(); return(true); } else if (Sandstorm.Happening == false) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(sandon), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(sandon), messageColor); } Sandstorm.Happening = true; Sandstorm.TimeLeft = (int)(3600.0 * (8.0 + (double)Main.rand.NextFloat() * 16.0)); SandstormStuff(); return(true); } return(false); }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (Main.expertMode) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(expertoff), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(expertoff), messageColor); } } else { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(experton), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(experton), messageColor); } } Main.expertMode = !Main.expertMode; return(true); }
public override void AI() { if (npc.ai[0] < 1) { if (Main.netMode != NetmodeID.Server) { string text = Language.GetTextValue("A suspious looking capsule appears nearby...", Lang.GetNPCNameValue(npc.type)); Main.NewText(text, 171, 64, 255); } else { NetworkText text = NetworkText.FromKey("A suspious looking capsule appears nearby the meteorite...", Lang.GetNPCNameValue(npc.type)); NetMessage.BroadcastChatMessage(text, new Color(171, 64, 255)); } npc.ai[0]++; } if (Main.rand.Next(6) == 0) { int dust = Dust.NewDust(npc.position * Main.rand.Next(1, 2), npc.width, npc.height, mod.DustType("AncientDust")); Main.dust[dust].scale = Main.rand.Next(6, 12) * .1f; Main.dust[dust].velocity.X *= (Main.rand.Next(-2, 2) - npc.life) * .1f; Main.dust[dust].velocity.Y = -npc.life * .1f; Main.dust[dust].alpha = 130; } }
public void SpawnBoss(Player player, string name, string displayName) { if (Main.netMode != 1) { int bossType = mod.NPCType(name); if (NPC.AnyNPCs(bossType)) { return; } //don't spawn if there's already a boss! int npcID = NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, bossType, 0); Main.npc[npcID].Center = player.Center - new Vector2(MathHelper.Lerp(-2000, 2000, (float)Main.rand.NextDouble()), 1200f); Main.npc[npcID].netUpdate2 = true; string npcName = !string.IsNullOrEmpty(Main.npc[npcID].GivenName) ? Main.npc[npcID].GivenName : displayName; if (Main.netMode == NetmodeID.SinglePlayer) { if (Main.netMode != 1) { BaseUtility.Chat(Language.GetTextValue("Announcement.HasAwoken", npcName), 175, 75, 255, false); } } else if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { NetworkText.FromLiteral(npcName) }), new Color(175, 75, 255), -1); } } }
public static void CheckNight() { bool flag = false; if (BirthdayParty.GenuineParty) { flag = true; BirthdayParty.GenuineParty = false; BirthdayParty.CelebratingNPCs.Clear(); } if (BirthdayParty.ManualParty) { flag = true; BirthdayParty.ManualParty = false; } if (!flag) { return; } Color color; // ISSUE: explicit reference operation ((Color)@color).\u002Ector((int)byte.MaxValue, 0, 160); WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[99].Key), color); }
public static NetworkText GetInvasionWaveText(int wave, params short[] npcIds) { NetworkText[] array = new NetworkText[npcIds.Length + 1]; for (int i = 0; i < npcIds.Length; i++) { array[i + 1] = NetworkText.FromKey(GetNPCName(npcIds[i]).Key); } switch (wave) { case -1: array[0] = NetworkText.FromKey("Game.FinalWave"); break; case 1: array[0] = NetworkText.FromKey("Game.FirstWave"); break; default: array[0] = NetworkText.FromKey("Game.Wave", wave); break; } string key = "Game.InvasionWave_Type" + npcIds.Length; object[] substitutions = array; return(NetworkText.FromKey(key, substitutions)); }
private void Talk(string message) { if (bEoC) { if (Main.netMode != NetmodeID.Server) { string text = Language.GetTextValue("Eye of Cthulhu has been defeated", message); Main.NewText(text, 255, 0, 255); } else { NetworkText text = NetworkText.FromKey("Eye of Cthulhu has been defeated", message); NetMessage.BroadcastChatMessage(text, new Color(255, 0, 255)); } bEoC = false; } if (bSkeletron) { if (Main.netMode != NetmodeID.Server) { string text = Language.GetTextValue("Skeletron has been defeated", message); Main.NewText(text, 255, 0, 255); } else { NetworkText text = NetworkText.FromKey("Skeletron has been defeated", message); NetMessage.BroadcastChatMessage(text, new Color(255, 0, 255)); } bSkeletron = false; } }
public override bool UseItem(Player player) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey("The Celestial Invasion was stopped."), new Color(255, 0, 255)); } else if (Main.netMode == 0) // Single Player { Main.NewText("The Celestial Invasion was stopped.", 255, 0, 255); } NPC.TowerActiveVortex = false; NPC.TowerActiveNebula = false; NPC.TowerActiveSolar = false; NPC.TowerActiveStardust = false; NPC.LunarApocalypseIsUp = false; for (int i = 0; i < Main.npc.Length; i++) { if ((Main.npc[i].type >= 402 && Main.npc[i].type <= 429) || Main.npc[i].type == 507 || (Main.npc[i].type >= 516 && Main.npc[i].type <= 519) || Main.npc[i].type == 493) //Celestial Pillars and all of their enemy spawns { Main.npc[i].life = 0; } } Terraria.GameContent.Events.CultistRitual.delay = 0; return(true); }
public void Initialize() { if (Progress == Main.netMode) { bullets.Clear(); if (Main.netMode == 0) { Main.NewText("The Spirit of Purity is losing control!"); } else if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("Mods.Bluemagic.TerraSpiritExpert"), Color.White); } npc.life = 1; if (Main.netMode == 0) { Main.player[Main.myPlayer].GetModPlayer <BluemagicPlayer>().terraLives += 3; Main.NewText("You have been granted 3 extra lives!"); } if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("Mods.Bluemagic.ExtraLives"), Color.White); ModPacket packet = mod.GetPacket(); packet.Write((byte)MessageType.ExtraLives); packet.Send(); } } if (Progress >= 120) { Stage++; Progress = -1; } }
public override bool UseItem(Player player) { if (Main.expertMode) { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(expertoff), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(expertoff), messageColor); } } else { if (Main.netMode == 2) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(experton), messageColor); } else if (Main.netMode == 0) // Single Player { Main.NewText(Language.GetTextValue(experton), messageColor); } } Main.expertMode = !Main.expertMode; return(true); }
public override void AI() { if (npc.ai[0] < 1) { if (Main.netMode != NetmodeID.Server) { string text = Language.GetTextValue("Ancient Mage has awoken", Lang.GetNPCNameValue(npc.type)); Main.NewText(text, 171, 64, 255); } else { NetworkText text = NetworkText.FromKey("Ancient Mage has awoken", Lang.GetNPCNameValue(npc.type)); NetMessage.BroadcastChatMessage(text, new Color(171, 64, 255)); } npc.ai[0]++; } if (npc.ai[0] < 2) { npc.velocity.Y--; if (npc.velocity.Y < -12) { npc.ai[0]++; } } }
public static void PutBallInCup_Actual( Point hitLocation, int plr, int numberOfHits, int projid) { if (numberOfHits == 0) { return; } Wiring.HitSwitch(hitLocation.X, hitLocation.Y); NetMessage.SendData(59, -1, -1, (NetworkText)null, hitLocation.X, (float)hitLocation.Y, 0.0f, 0.0f, 0, 0, 0); GolfHelper.ContactListener.EmitGolfballExplosion(hitLocation.ToWorldCoordinates(8f, 0.0f)); string key = "Game.BallBounceResultGolf_Single"; if (numberOfHits != 1) { key = "Game.BallBounceResultGolf_Plural"; } NetworkText text = NetworkText.FromKey(key, (object)Main.player[plr].name, (object)NetworkText.FromKey(Lang.GetProjectileName(projid).Key), (object)numberOfHits); switch (Main.netMode) { case 0: case 1: Main.NewText(text.ToString(), byte.MaxValue, (byte)240, (byte)20); break; case 2: ChatHelper.BroadcastChatMessage(text, new Color((int)byte.MaxValue, 240, 20), -1); break; } }
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { if (Main.netMode != 1) { string key1 = "The shields of Artorias were destroyed!"; string key2 = "The shields of Witchking were destroyed!"; if (target.type == mod.NPCType("Artorias")) { target.AddBuff(mod.BuffType("Vulnerable"), 10000, false); if (Main.netMode == 0) { Main.NewText("The shields of Artorias were destroyed!", 175, 75, 255); } else if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key1), new Color(175, 75, 255)); } } if (target.type == mod.NPCType("Witchking")) { target.AddBuff(mod.BuffType("Vulnerable"), 10000, false); if (Main.netMode == 0) { Main.NewText("The shields of Witchking were destroyed!", 175, 75, 255); } else if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key2), new Color(175, 75, 255)); } } if (target.type == mod.NPCType("Sauron")) { target.AddBuff(mod.BuffType("Vulnerable"), 10000, false); if (Main.netMode == 0) { Main.NewText("The shields of Sauron were destroyed!", 175, 75, 255); } else if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key1), new Color(175, 75, 255)); } } if (target.type == mod.NPCType("Nazgul")) { target.AddBuff(mod.BuffType("Vulnerable"), 10000, false); if (Main.netMode == 0) { Main.NewText("The shields of Nazgul were destroyed!", 175, 75, 255); } else if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key1), new Color(175, 75, 255)); } } } }
public override void PreUpdate() { #region Ore Event MaxOreKills = 100; MaxOreKillsHard = 150; if (!Main.hardMode) { if (OreKills >= MaxOreKills && OreEvent) { OreEvent = false; downedOres = true; if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.WorldData); // Immediately inform clients of new world state. } string key = "The ores have been defeated"; Color messageColor = Color.Orange; if (Main.netMode == NetmodeID.Server) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); } else if (Main.netMode == NetmodeID.SinglePlayer) // Single Player { Main.NewText(Language.GetTextValue(key), messageColor); } OreKills = 0; } } else { if (OreKills >= MaxOreKillsHard) { OreEvent = false; downedOresHard = true; if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.WorldData); // Immediately inform clients of new world state. } string key = "The ores have been defeated"; Color messageColor = Color.Orange; if (Main.netMode == NetmodeID.Server) // Server { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); } else if (Main.netMode == NetmodeID.SinglePlayer) // Single Player { Main.NewText(Language.GetTextValue(key), messageColor); } OreKills = 0; } } #endregion Ore Event }
public void Kick(string msg = "") { if (RealPlayer && ConnectionAlive) { var netmsg = ((msg == "") ? NetworkText.FromKey("CLI.KickMessage", new object[0]) : NetworkText.FromLiteral(msg)); NetMessage.SendData(2, playerID, -1, netmsg, 0, 0f, 0f, 0f, 0, 0, 0); CommandBoardcast.ConsoleMessage($"玩家 {Name} 被踢出服务器,原因是:msg"); } }
// SpawnBoss(player, mod.NPCType("MyBoss"), true, player.Center + new Vector2(0, 800f), "DerpFromBelow", false); internal static int SpawnBoss(Player player, int bossType, bool spawnMessage = true, Vector2 npcCenter = default, string overrideDisplayName = "", bool namePlural = false) { if (npcCenter == default) { npcCenter = player.Center; } if (Main.netMode != NetmodeID.MultiplayerClient) { int npcID = NPC.NewNPC((int)npcCenter.X, (int)npcCenter.Y, bossType); Main.npc[npcID].Center = npcCenter; Main.npc[npcID].netUpdate2 = true; if (spawnMessage) { string npcName = !string.IsNullOrEmpty(Main.npc[npcID].GivenName) ? Main.npc[npcID].GivenName : overrideDisplayName; if ((npcName == null || string.IsNullOrEmpty(npcName)) && Main.npc[npcID].modNPC != null) { npcName = Main.npc[npcID].modNPC.DisplayName.GetDefault(); } if (namePlural) { if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(npcName + " have awoken!", 175, 75); } else if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromLiteral(npcName + " have awoken!"), new Color(175, 75, 255)); } } else { if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(Language.GetTextValue("Announcement.HasAwoken", npcName), 175, 75); } else if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { NetworkText.FromLiteral(npcName) }), new Color(175, 75, 255)); } } } } else { // I have no idea how to convert this to the standard system so im gonna post this method too lol FargoNet.SendNetMessage(FargoNet.SummonNPCFromClient, (byte)player.whoAmI, (short)bossType, spawnMessage, npcCenter.X, npcCenter.Y, overrideDisplayName, namePlural); } return(200); }
public static void BroadcastText(object text, Color color) { if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromKey(text.ToString()), color); } else if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(Language.GetTextValue(text.ToString()), color); } }
/* Send message to chat with color */ public static void Talk(string message, Color messageColor) { if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromKey(message), messageColor); } else { Main.NewText(message, messageColor); } }
public override void Action(CommandCaller caller, string input, string[] args) { string key = "Mods.ExampleMod.VolcanoWarning"; Color messageColor = Color.Orange; NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); ExampleWorld exampleWorld = mod.GetModWorld <ExampleWorld>(); exampleWorld.VolcanoCountdown = ExampleWorld.DefaultVolcanoCountdown; exampleWorld.VolcanoCooldown = ExampleWorld.DefaultVolcanoCooldown; }
/// <summary> /// 把t以指定颜色显示于屏幕左下角 /// </summary> public static void PrintColor(string t, byte r, byte g, byte b) { if (Main.netMode != 2) { Main.NewText(t, r, g, b); } else { NetworkText te = NetworkText.FromKey(t); NetMessage.BroadcastChatMessage(te, new Color(r, g, b)); } }
/// <summary> /// 把t转化为字符串显示于屏幕左下角 /// </summary> public static void Print(object t) { if (Main.netMode != 2) { Main.NewText(t); } else { NetworkText te = NetworkText.FromKey(t.ToString()); NetMessage.BroadcastChatMessage(te, Color.White); } }
private void Talk(string key, byte r = 255, byte g = 255, byte b = 255) { if (Main.netMode != 2) { Main.NewText(Language.GetTextValue(key), r, g, b); } else { NetworkText text = NetworkText.FromKey(key); NetMessage.BroadcastChatMessage(text, new Color(r, g, b)); } }
public override void PostUpdate() { if (Main.bloodMoon) { isBloodMoon = true; } if (Main.snowMoon) { isFrostMoon = true; } if (Main.pumpkinMoon) { isPumpkinMoon = true; } if (Main.eclipse) { isEclipse = true; } if (Main.dayTime && isBloodMoon) { isBloodMoon = false; EventKey = "Mods.BossAssist.BMoonEnd"; } else if (Main.dayTime && isFrostMoon) { isFrostMoon = false; EventKey = "Mods.BossAssist.FMoonEnd"; } else if (Main.dayTime && isPumpkinMoon) { isPumpkinMoon = false; EventKey = "Mods.BossAssist.PMoonEnd"; } else if (!Main.dayTime && isEclipse) { isEclipse = false; EventKey = "Mods.BossAssist.EclipseEnd"; } if (EventKey != "") { if (Main.netMode == 0) { Main.NewText(Language.GetTextValue(EventKey), Colors.RarityGreen); // Single Player } else { NetMessage.BroadcastChatMessage(NetworkText.FromKey(EventKey), Colors.RarityGreen); // Multiplayer } EventKey = ""; } }