public void OnPlayerDeath(Player player) { var name = player.name; if (_deathCount.TryGetValue(name, out var deaths)) { _deathCount[name] = ++deaths; } else { _deathCount[name] = deaths = 1; } if (deaths % 25 == 0 || deaths == 10) { var message = $"{name} have died {deaths} times!"; switch (Main.netMode) { case 0: Main.NewText(message, 250, 250, 0); break; case 2: ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(message), new Color(250, 250, 0)); break; } } }
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 void ProcessIncomingMessage(string text, byte clientId) { if (text != "") { text = $"*{Main.player[clientId].name} {text}"; ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), RESPONSE_COLOR); } }
public void ProcessIncomingMessage(string text, byte clientId) { if (!(text != "")) { return; } text = string.Format("*{0} {1}", (object)Main.player[(int)clientId].name, (object)text); ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), EmoteCommand.RESPONSE_COLOR, -1); }
public override bool?UseItem(Player player) { if (FargoWorld.OverloadPumpkinMoon) { // cancel it Main.pumpkinMoon = false; FargoWorld.OverloadPumpkinMoon = false; if (Main.netMode == 2) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("The Pumpkin Moon fades away!"), new Color(175, 75, 255)); } else { Main.NewText("The Pumpkin Moon fades away!", 175, 75, 255); } } else { if (Main.netMode == 2) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("The Pumpkin Moon is rising..."), new Color(50, 255, 130)); } else { Main.NewText("The Pumpkin Moon is rising...", 50, 255, 130); } Main.pumpkinMoon = true; Main.snowMoon = false; Main.bloodMoon = false; if (Main.netMode != 1) { NPC.waveKills = 0f; NPC.waveNumber = 15; if (Main.netMode == 2) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("Wave: 15: Everything"), new Color(175, 75, 255)); } else { Main.NewText("Wave: 15: Everything", 175, 75, 255); } } else { NetMessage.SendData(61, -1, -1, null, player.whoAmI, -4f); } FargoWorld.OverloadPumpkinMoon = true; SoundEngine.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); } return(true); }
// 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) { ChatHelper.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) { ChatHelper.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 PrintText(string text, Color color) { if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(text, color); } else if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), color); } }
public static void SendChatMessage(string message, Color color) { if (IsSinglePlayer()) { NewText(message, color); } else { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(message), color); } }
public override ActionResponse Handle() { if (!Main.eclipse) { Main.SkipToTime(0, true); Main.eclipse = true; ChatHelper.BroadcastChatMessage(Language.GetText("LegacyMisc." + 20).ToNetworkText(), new Color(50, (int)byte.MaxValue, 130), -1); NetMessage.SendData(7); return(ActionResponse.Done); } TryLater(TimeSpan.FromSeconds(20)); return(ActionResponse.Retry); }
public override bool Shoot(Player player, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 pos = new Vector2((int)player.position.X + Main.rand.Next(-800, 800), (int)player.position.Y + Main.rand.Next(-1000, -250)); if (!Main.dayTime) { if (!NPC.downedBoss3) { Main.dayTime = false; Main.time = 0; if (Main.netMode == NetmodeID.Server) //sync time { NetMessage.SendData(MessageID.WorldData, -1, -1, null, 0, 0f, 0f, 0f, 0, 0, 0); } } Projectile.NewProjectile(player.GetProjectileSource_Item(source.Item), pos, Vector2.Zero, ModContent.ProjectileType <SpawnProj>(), 0, 0, Main.myPlayer, NPCID.SkeletronHead); if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("Skeletron has awoken!"), new Color(175, 75, 255)); } else { Main.NewText("Skeletron has awoken!", new Color(175, 75, 255)); } } else { pos.X = player.position.X; pos.Y = player.position.Y - 500; Projectile.NewProjectile(player.GetProjectileSource_Item(source.Item), pos, Vector2.Zero, ModContent.ProjectileType <SpawnProj>(), 0, 0, Main.myPlayer, NPCID.DungeonGuardian); if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("Dungeon Guardian has awoken!"), new Color(175, 75, 255)); } else { Main.NewText("Dungeon Guardian has awoken!", new Color(175, 75, 255)); } } SoundEngine.PlaySound(SoundID.Roar, player.position, 0); return(false); }
public override bool UseItem(Player player) { FargoSoulsWorld.SuppressRandomMutant = !FargoSoulsWorld.SuppressRandomMutant; string text = FargoSoulsWorld.SuppressRandomMutant ? "Phantasmal energy wanes..." : "Phantasmal energy pulsates."; if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(text, Color.LimeGreen); } else if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), Color.LimeGreen); NetMessage.SendData(MessageID.WorldData); //sync world } Terraria.Audio.SoundEngine.PlaySound(SoundID.Roar, (int)player.position.X, (int)player.position.Y, 0); return(true); }
public override bool?UseItem(Player player) { string text;; switch (Main.GameMode) { case 0: Main.GameMode = 1; player.difficulty = 0; text = "Expert mode is now enabled!"; break; case 1: Main.GameMode = 2; player.difficulty = 0; text = "Master mode is now enabled!"; break; case 2: Main.GameMode = 3; player.difficulty = 3; text = "Journey mode is now enabled!"; break; default: Main.GameMode = 0; player.difficulty = 0; text = "Normal mode is now enabled!"; break; } if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(text, new Color(175, 75, 255)); } else if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), new Color(175, 75, 255)); NetMessage.SendData(7); //sync world } SoundEngine.PlaySound(15, player.Center, 0); return(true); }
public override bool Shoot(Player player, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 pos = new Vector2((int)player.position.X + Main.rand.Next(-800, 800), (int)player.position.Y + Main.rand.Next(-1000, -250)); Projectile.NewProjectile(player.GetProjectileSource_Item(source.Item), pos, Vector2.Zero, ModContent.ProjectileType <SpawnProj>(), 0, 0, Main.myPlayer, 1, 3); if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("Several bosses have awoken!"), new Color(175, 75, 255)); } else { Main.NewText("Several bosses have awoken!", new Color(175, 75, 255)); } SoundEngine.PlaySound(SoundID.Roar, player.position, 0); return(false); }
public override bool?UseItem(Player player) { int n = NPC.NewNPC((int)player.position.X + Main.rand.Next(-800, 800), (int)player.position.Y + Main.rand.Next(-800, -250), NPCID.BlueSlime); Main.npc[n].SetDefaults(NPCID.Pinky); SoundEngine.PlaySound(SoundID.Roar, player.position, 0); if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("Pinky has awoken!"), new Color(175, 75, 255)); } else { Main.NewText("Pinky has awoken!", new Color(175, 75, 255)); } return(true); }
public static void PutBallInCup_TextAndEffects(Point hitLocation, int plr, int numberOfHits, int projid) { if (numberOfHits != 0) { EmitGolfballExplosion(hitLocation.ToWorldCoordinates(8f, 0f)); string key = "Game.BallBounceResultGolf_Single"; if (numberOfHits != 1) { key = "Game.BallBounceResultGolf_Plural"; } NetworkText networkText = NetworkText.FromKey(key, Main.player[plr].name, NetworkText.FromKey(Lang.GetProjectileName(projid).Key), numberOfHits); if (Main.netMode == 0 || Main.netMode == 1) { Main.NewText(networkText.ToString(), byte.MaxValue, 240, 20); } else if (Main.netMode == 2) { ChatHelper.BroadcastChatMessage(networkText, new Color(255, 240, 20)); } } }
public override bool Shoot(Player player, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int[] pillars = new int[] { NPCID.LunarTowerNebula, NPCID.LunarTowerSolar, NPCID.LunarTowerStardust, NPCID.LunarTowerVortex }; for (int i = 0; i < pillars.Length; i++) { Vector2 pos = new Vector2((int)player.position.X + (400 * i) - 600, (int)player.position.Y - 200); Projectile.NewProjectile(player.GetProjectileSource_Item(source.Item), pos, Vector2.Zero, type, 0, 0, Main.myPlayer, pillars[i]); } if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("The Celestial Pillars have awoken!"), new Color(175, 75, 255)); } else { Main.NewText("The Celestial Pillars have awoken!", new Color(175, 75, 255)); } SoundEngine.PlaySound(SoundID.Roar, player.position, 0); return(false); }
public override bool?UseItem(Player player) { if (FargoWorld.OverloadPirates) { // cancel it Main.invasionSize = 1; FargoWorld.OverloadPirates = false; if (Main.netMode == 2) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("The pirates have calmed down!"), new Color(175, 75, 255)); } else { Main.NewText("The pirates have calmed down!", 175, 75, 255); } } else { if (Main.netMode != 1) { Main.invasionDelay = 0; Main.StartInvasion(3); Main.invasionSize = 15000; Main.invasionSizeStart = 15000; } else { NetMessage.SendData(61, -1, -1, null, player.whoAmI, -3f); } FargoWorld.OverloadPirates = true; SoundEngine.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); } return(true); }
public override bool?UseItem(Player player) { FargoPlayer modPlayer = player.GetFargoPlayer(); modPlayer.BattleCry = !modPlayer.BattleCry; string text = "Spawn rates " + (modPlayer.BattleCry ? "increased!" : "decreased!"); if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(text, new Color(175, 75, 255)); } else if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), new Color(175, 75, 255)); } if (!Main.dedServ) { SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Horn").WithVolume(1f), player.Center); } return(true); }
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 HandlePacket(BinaryReader reader, int whoAmI) { byte messageType = reader.ReadByte(); switch (messageType) { // Regal statue case 1: FargoWorld.CurrentSpawnRateTile[whoAmI] = reader.ReadBoolean(); break; // Abominationn clear events case 2: if (Main.netMode == NetmodeID.Server) { bool eventOccurring = false; if (ClearEvents(ref eventOccurring)) { NetMessage.SendData(MessageID.WorldData); ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("The event has been cancelled!"), new Color(175, 75, 255)); } } break; // Angler reset case 3: if (Main.netMode == NetmodeID.Server) { Main.AnglerQuestSwap(); } break; // Sync npc max life case 4: { int n = reader.ReadInt32(); int lifeMax = reader.ReadInt32(); if (Main.netMode == NetmodeID.MultiplayerClient) { Main.npc[n].lifeMax = lifeMax; } } break; // Kill super dummies case 5: if (Main.netMode == NetmodeID.Server) { for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <NPCs.SuperDummy>()) { NPC npc = Main.npc[i]; npc.life = 0; npc.HitEffect(); Main.npc[i].StrikeNPCNoInteraction(int.MaxValue, 0, 0, false, false, false); if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); } } } } break; default: break; } }
public override void PostUpdate() { if (Main.dayTime && VolcanoCountdown == 0) { if (VolcanoCooldown > 0) { VolcanoCooldown--; } if (VolcanoCooldown <= 0 && Main.rand.NextBool(VolcanoChance) && !GetInstance <ExampleConfigServer>().DisableVolcanoes) { string key = "Mods.ExampleMod.VolcanoWarning"; Color messageColor = Color.Orange; if (Main.netMode == NetmodeID.Server) // Server { ChatHelper.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); } else if (Main.netMode == NetmodeID.SinglePlayer) // Single Player { Main.NewText(Language.GetTextValue(key), messageColor); } VolcanoCountdown = DefaultVolcanoCountdown; VolcanoCooldown = DefaultVolcanoCooldown; } } if (VolcanoCountdown > 0) { VolcanoCountdown--; if (VolcanoCountdown == 0) { VolcanoTremorTime = DefaultVolcanoTremorTime; // Since PostUpdate only happens in single and server, we need to inform the clients to shake if this is a server if (Main.netMode == NetmodeID.Server) { var netMessage = mod.GetPacket(); netMessage.Write((byte)ExampleModMessageType.SetTremorTime); netMessage.Write(VolcanoTremorTime); netMessage.Send(); } for (int playerIndex = 0; playerIndex < 255; playerIndex++) { if (Main.player[playerIndex].active) { Player player = Main.player[playerIndex]; int speed = 12; float spawnX = Main.rand.Next(1000) - 500 + player.Center.X; float spawnY = -1000 + player.Center.Y; var baseSpawn = new Vector2(spawnX, spawnY); Vector2 baseVelocity = player.Center - baseSpawn; baseVelocity.Normalize(); baseVelocity = baseVelocity * speed; var identities = new List <int>(); for (int i = 0; i < VolcanoProjectiles; i++) { Vector2 spawn = baseSpawn; spawn.X = spawn.X + i * 30 - VolcanoProjectiles * 15; Vector2 velocity = baseVelocity; velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-VolcanoAngleSpread / 2 + VolcanoAngleSpread * i / (float)VolcanoProjectiles)); velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; int projectile = Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, Main.rand.Next(ProjectileID.MolotovFire, ProjectileID.MolotovFire3 + 1), 10, 10f, Main.myPlayer, 0f, 0f); Main.projectile[projectile].hostile = true; Main.projectile[projectile].Name = "Volcanic Rubble"; identities.Add(Main.projectile[projectile].identity); } if (Main.netMode == NetmodeID.Server) { var netMessage = mod.GetPacket(); netMessage.Write((byte)ExampleModMessageType.VolcanicRubbleMultiplayerFix); netMessage.Write(identities.Count); for (int i = 0; i < identities.Count; i++) { netMessage.Write(identities[i]); } netMessage.Send(); } } } } } }
public static void SendChatMessage(string message, Color color) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(message), color); }
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 override bool?UseItem(Player player) { Fargowiltas.SwarmActive = true; Fargowiltas.SwarmTotal = 10 * player.inventory[player.selectedItem].stack; Fargowiltas.SwarmKills = 0; if (Fargowiltas.SwarmTotal < 100) { Fargowiltas.SwarmSpawned = 10; } else { //energizer swarms Fargowiltas.SwarmSpawned = maxSpawn; } //DG special case if (npcType == NPCID.SkeletronHead && Main.dayTime) { npcType = NPCID.DungeonGuardian; } //twins special case else if (npcType == NPCID.Retinazer) { Fargowiltas.SwarmTotal *= 2; } //wof mega special case if (npcType == NPCID.WallofFlesh) { FargoGlobalNPC.SpawnWalls(player); counter++; if (counter < 10) { return(true); } } else { //spawn the bosses for (int i = 0; i < Fargowiltas.SwarmSpawned; i++) { int boss = NPC.NewNPC((int)player.position.X + Main.rand.Next(-1000, 1000), (int)player.position.Y + Main.rand.Next(-1000, -400), npcType); Main.npc[boss].GetGlobalNPC <FargoGlobalNPC>().SwarmActive = true; //spawn the other twin as well if (npcType == NPCID.Retinazer) { int twin = NPC.NewNPC((int)player.position.X + Main.rand.Next(-1000, 1000), (int)player.position.Y + Main.rand.Next(-1000, -400), NPCID.Spazmatism); Main.npc[twin].GetGlobalNPC <FargoGlobalNPC>().SwarmActive = true; } else if (npcType == NPCID.TheDestroyer) { //Main.npc[boss].GetGlobalNPC<FargoGlobalNPC>().DestroyerSwarm = true; } } } // Kill whole stack player.inventory[player.selectedItem].stack = 0; if (Main.netMode == NetmodeID.Server) { ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(spawnMessage), new Color(175, 75, 255)); NetMessage.SendData(MessageID.WorldData); } else if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(spawnMessage, 175, 75, 255); } SoundEngine.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); return(true); }