public override void PostUpdate() { if (Main.dedServ || !DisplayWorldTooltips) { return; } Mod displayMod = null; Mod modLoaderMod = ModLoader.GetMod("ModLoader"); //modmodloadermodmodloadermodmodloader int mysteryTile = modLoaderMod.TileType("MysteryTile"); int mysteryTile2 = modLoaderMod.TileType("PendingMysteryTile"); var tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile != null) { if (tile.active() && tile.type != mysteryTile && tile.type != mysteryTile2) { var modTile = TileLoader.GetTile(tile.type); if (modTile != null) { displayMod = modTile.mod; } } else { var modWall = WallLoader.GetWall(tile.wall); if (modWall != null) { displayMod = modWall.mod; } } } var mousePos = Main.MouseWorld; for (int i = 0; i < Main.maxNPCs; i++) { var npc = Main.npc[i]; if (mousePos.Between(npc.TopLeft, npc.BottomRight)) { var modNPC = NPCLoader.GetNPC(npc.type); if (modNPC != null && npc.active && !NPCID.Sets.ProjectileNPC[npc.type]) { displayMod = modNPC.mod; SecondLine = true; break; } } } if (displayMod != null) { MouseText = String.Format("[c/{1}:[{0}][c/{1}:]]", displayMod.DisplayName, Colors.RarityBlue.Hex3()); if (Main.mouseText) { SecondLine = true; } } }
internal static TagCompound SaveTiles() { var hasTile = new bool[TileLoader.TileCount]; var hasWall = new bool[WallLoader.WallCount]; using (var ms = new MemoryStream()) using (var writer = new BinaryWriter(ms)) { WriteTileData(writer, hasTile, hasWall); var tileList = new List <TagCompound>(); for (int type = TileID.Count; type < hasTile.Length; type++) { if (!hasTile[type]) { continue; } var modTile = TileLoader.GetTile(type); tileList.Add(new TagCompound { ["value"] = (short)type, ["mod"] = modTile.mod.Name, ["name"] = modTile.Name, ["framed"] = Main.tileFrameImportant[type], }); } var wallList = new List <TagCompound>(); for (int wall = WallID.Count; wall < hasWall.Length; wall++) { if (!hasWall[wall]) { continue; } var modWall = WallLoader.GetWall(wall); wallList.Add(new TagCompound { ["value"] = (short)wall, ["mod"] = modWall.mod.Name, ["name"] = modWall.Name, }); } if (tileList.Count == 0 && wallList.Count == 0) { return(null); } return(new TagCompound { ["tileMap"] = tileList, ["wallMap"] = wallList, ["data"] = ms.ToArray() }); } }
public override void PostUpdate() { if (Main.dedServ || !DisplayWorldTooltips) { return; } MouseText = String.Empty; SecondLine = false; var modLoaderMod = ModLoader.GetMod("ModLoader"); //modmodloadermodmodloadermodmodloader int mysteryTile = modLoaderMod.TileType("MysteryTile"); int mysteryTile2 = modLoaderMod.TileType("PendingMysteryTile"); var tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile != null) { if (tile.active() && tile.type != mysteryTile && tile.type != mysteryTile2) { var modTile = TileLoader.GetTile(tile.type); if (modTile != null) { MouseText = DisplayTechnicalNames ? (modTile.mod.Name + ":" + modTile.Name) : modTile.mod.DisplayName; } } else { var modWall = WallLoader.GetWall(tile.wall); if (modWall != null) { MouseText = DisplayTechnicalNames ? (modWall.mod.Name + ":" + modWall.Name) : modWall.mod.DisplayName; } } } var mousePos = Main.MouseWorld; for (int i = 0; i < Main.maxNPCs; i++) { var npc = Main.npc[i]; if (mousePos.Between(npc.TopLeft, npc.BottomRight)) { var modNPC = NPCLoader.GetNPC(npc.type); if (modNPC != null && npc.active && !NPCID.Sets.ProjectileNPC[npc.type]) { MouseText = DisplayTechnicalNames ? (modNPC.mod.Name + ":" + modNPC.Name) : modNPC.mod.DisplayName; SecondLine = true; break; } } } if (MouseText != String.Empty && Main.mouseText) { SecondLine = true; } }
public override void PostUpdate() { if (Main.dedServ || !ModContent.GetInstance <Config>().DisplayWorldTooltips) { return; } WMITFModSystem.MouseText = String.Empty; WMITFModSystem.SecondLine = false; var tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile.HasTile && !WMITF.IsUnloadedTile(tile)) { var modTile = TileLoader.GetTile(tile.TileType); if (modTile != null) { WMITFModSystem.MouseText = ModContent.GetInstance <Config>().DisplayTechnicalNames ? (modTile.Mod.Name + ":" + modTile.Name) : modTile.Mod.DisplayName; } } else { var modWall = WallLoader.GetWall(tile.WallType); if (modWall != null) { WMITFModSystem.MouseText = ModContent.GetInstance <Config>().DisplayTechnicalNames ? (modWall.Mod.Name + ":" + modWall.Name) : modWall.Mod.DisplayName; } } var mousePos = Main.MouseWorld; for (int i = 0; i < Main.maxNPCs; i++) { var npc = Main.npc[i]; if (mousePos.Between(npc.TopLeft, npc.BottomRight)) { var modNPC = NPCLoader.GetNPC(npc.type); if (modNPC != null && npc.active && !NPCID.Sets.ProjectileNPC[npc.type]) { WMITFModSystem.MouseText = ModContent.GetInstance <Config>().DisplayTechnicalNames ? (modNPC.Mod.Name + ":" + modNPC.Name) : modNPC.Mod.DisplayName; WMITFModSystem.SecondLine = true; break; } } } if (WMITFModSystem.MouseText != String.Empty && Main.mouseText) { WMITFModSystem.SecondLine = true; } }
internal static bool WriteModMap(BinaryWriter writer) { ISet <ushort> types = new HashSet <ushort>(); for (int i = 0; i < Main.maxTilesX; i++) { for (int j = 0; j < Main.maxTilesY; j++) { ushort type = Main.Map[i, j].Type; if (type >= MapHelper.modPosition) { types.Add(type); } } } if (types.Count == 0) { return(false); } writer.Write((ushort)types.Count); foreach (ushort type in types) { writer.Write(type); if (MapLoader.entryToTile.ContainsKey(type)) { ModTile tile = TileLoader.GetTile(MapLoader.entryToTile[type]); writer.Write(true); writer.Write(tile.Mod.Name); writer.Write(tile.Name); writer.Write((ushort)(type - MapHelper.tileLookup[tile.Type])); } else if (MapLoader.entryToWall.ContainsKey(type)) { ModWall wall = WallLoader.GetWall(MapLoader.entryToWall[type]); writer.Write(false); writer.Write(wall.Mod.Name); writer.Write(wall.Name); writer.Write((ushort)(type - MapHelper.wallLookup[wall.Type])); } else { writer.Write(true); writer.Write(""); writer.Write(""); writer.Write((ushort)0); } } WriteMapData(writer); return(true); }
public static string GetUniqueKey(int type) { if (type < 0 || type >= WallLoader.WallCount) { throw new ArgumentOutOfRangeException("Invalid type: " + type); } if (type < WallID.Count) { return("Terraria " + TileWallIdentityHelpers.WallIdSearch.GetName(type)); } ModWall modWall = WallLoader.GetWall(type); return($"{modWall.mod.Name} {modWall.Name}"); }
internal static bool WriteTiles(BinaryWriter writer) { ISet <ushort> types = new HashSet <ushort>(); ISet <ushort> walls = new HashSet <ushort>(); for (int i = 0; i < Main.maxTilesX; i++) { for (int j = 0; j < Main.maxTilesY; j++) { Tile tile = Main.tile[i, j]; if (tile.active() && tile.type >= TileID.Count) { types.Add(tile.type); } if (tile.wall >= WallID.Count) { walls.Add(tile.wall); } } } if (types.Count > 0 || walls.Count > 0) { writer.Write((ushort)types.Count); foreach (ushort type in types) { writer.Write(type); ModTile modTile = TileLoader.GetTile(type); writer.Write(modTile.mod.Name); writer.Write(modTile.Name); writer.Write(Main.tileFrameImportant[type]); } writer.Write((ushort)walls.Count); foreach (ushort wall in walls) { writer.Write(wall); ModWall modWall = WallLoader.GetWall(wall); writer.Write(modWall.mod.Name); writer.Write(modWall.Name); } WriteTileData(writer); return(true); } return(false); }
public static bool InfectWall(int i, int j) { // Don't infect invalid walls if (WorldGen.InWorld(i, j)) { Tile tile = Framing.GetTileSafely(i, j); // No Lihzahrd infection pre-golem if (tile.wall == WallID.LihzahrdBrickUnsafe && !NPC.downedGolemBoss) { return(false); } // Check if we should bother if (tile.wall != WallID.None) { // Check that the tile isn't already infected if (!(WallLoader.GetWall(tile.wall) is InfectiousWall)) { // Find a matching wall InfectiousWall convertTo = infectiousWalls.FirstOrDefault(t => t.CanInfect(tile.wall)); if (convertTo != null) { // If we found one, convert it tile.wall = convertTo.Type; return(true); } else { // If not, default to Infected Glob (Stone for now) tile.wall = (ushort)Default; return(true); } } } } return(false); }
public override void Kill(int timeLeft) { //Main.PlaySound(SoundID.Item14, projectile.position); switch (Main.rand.Next(4)) { case 1: Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode1"), projectile.position); break; case 2: Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode2"), projectile.position); break; case 3: Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode3"), projectile.position); break; default: Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode4"), projectile.position); break; } { projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 32; projectile.height = 32; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); int num4; for (int i = 0; i < 30; i++) { int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 1.5f); Dust dust = Main.dust[index]; dust.velocity *= 1.4f; } for (int i = 0; i < 20; i++) { int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3.5f); Main.dust[index].noGravity = true; Dust dust = Main.dust[index]; dust.velocity *= 7f; index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1.5f); dust = Main.dust[index]; dust.velocity *= 3f; } for (int i = 0; i < 10; i++) { int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3.5f); Main.dust[index].noGravity = true; Dust dust = Main.dust[index]; dust.velocity *= 14f; index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1.5f); dust = Main.dust[index]; dust.velocity *= 7f; } for (int i = 0; i < 4; i++) { float scaleFactor9 = 1.2f; if (i <= 1) { scaleFactor9 = 2.4f; } Vector2 position48 = new Vector2(projectile.position.X, projectile.position.Y); Vector2 vector = default(Vector2); int index = Gore.NewGore(position48, vector, Main.rand.Next(61, 64), 1f); Gore gore = Main.gore[index]; gore.velocity *= scaleFactor9; Gore gore110 = Main.gore[index]; gore110.velocity.X = gore110.velocity.X + 1f; Gore gore111 = Main.gore[index]; gore111.velocity.Y = gore111.velocity.Y + 1f; Vector2 position49 = new Vector2(projectile.position.X, projectile.position.Y); vector = default(Vector2); index = Gore.NewGore(position49, vector, Main.rand.Next(61, 64), 1f); gore = Main.gore[index]; gore.velocity *= scaleFactor9; Gore gore112 = Main.gore[index]; gore112.velocity.X = gore112.velocity.X - 1f; Gore gore113 = Main.gore[index]; gore113.velocity.Y = gore113.velocity.Y + 1f; Vector2 position50 = new Vector2(projectile.position.X, projectile.position.Y); vector = default(Vector2); index = Gore.NewGore(position50, vector, Main.rand.Next(61, 64), 1f); gore = Main.gore[index]; gore.velocity *= scaleFactor9; Gore gore114 = Main.gore[index]; gore114.velocity.X = gore114.velocity.X + 1f; Gore gore115 = Main.gore[index]; gore115.velocity.Y = gore115.velocity.Y - 1f; Vector2 position51 = new Vector2(projectile.position.X, projectile.position.Y); vector = default(Vector2); index = Gore.NewGore(position51, vector, Main.rand.Next(61, 64), 1f); gore = Main.gore[index]; gore.velocity *= scaleFactor9; Gore gore116 = Main.gore[index]; gore116.velocity.X = gore116.velocity.X - 1f; Gore gore117 = Main.gore[index]; gore117.velocity.Y = gore117.velocity.Y - 1f; } } { int explosionRadius = 8; int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - projectile.position.X / 16f); float diffY = Math.Abs((float)y - projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - projectile.position.X / 16f); float diffY = Math.Abs((float)j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } } }
public override void Kill(int timeLeft) { // Play explosion sound Main.PlaySound(SoundID.Item15, projectile.position); // Smoke Dust spawn for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } // Fire Dust spawn for (int i = 0; i < 80; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } // Large Smoke Gore spawn for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; } // reset size to normal width and height. projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 10; projectile.height = 10; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); // TODO, tmodloader helper method if (ModContent.GetInstance <Configs>().MobGriefing) { int explosionRadius = 8; //if (projectile.type == 29 || projectile.type == 470 || projectile.type == 637) { explosionRadius = 8; } int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - projectile.position.X / 16f); float diffY = Math.Abs((float)y - projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - projectile.position.X / 16f); float diffY = Math.Abs((float)j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; } else { AchievementsHelper.CurrentlyMining = false; } }
private void Explode() { Player player = Main.player[projectile.owner]; //get player // Play explosion sound Main.PlaySound(SoundID.Item14, projectile.position); // Smoke Dust spawn for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X + (projectile.width / 4), projectile.position.Y + (projectile.height / 4)), projectile.width / 2, projectile.height / 2, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } // Fire Dust spawn for (int i = 0; i < 80; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X + (projectile.width / 4), projectile.position.Y + (projectile.height / 4)), projectile.width / 2, projectile.height / 2, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X + (projectile.width / 4), projectile.position.Y + (projectile.height / 4)), projectile.width / 2, projectile.height / 2, 6, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } // Large Smoke Gore spawn for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; } //how many blocks to explode int explosionRadius = projectile.width / 16 / 4; //find min/max x/y tiles in circle around projectile int minTileX = (int)(player.Center.X / 16f - (float)explosionRadius); int maxTileX = (int)(player.Center.X / 16f + (float)explosionRadius); int minTileY = (int)(player.Center.Y / 16f - (float)explosionRadius); int maxTileY = (int)(player.Center.Y / 16f + (float)explosionRadius); //clamp tile range inside world if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; //only get walls inside a circle for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - player.Center.X / 16f); float diffY = Math.Abs((float)y - player.Center.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } //only get tiles inside a circle for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - player.Center.X / 16f); float diffY = Math.Abs((float)j - player.Center.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; //cant kill dungeon walls } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; //cant kill ? walls } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; //cant kill unexplodable walls } if (canKillTile) { //kill tile WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } }
public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, base.projectile.position); for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(base.projectile.position.X, base.projectile.position.Y), base.projectile.width, base.projectile.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } for (int j = 0; j < 80; j++) { int dustIndex2 = Dust.NewDust(new Vector2(base.projectile.position.X, base.projectile.position.Y), base.projectile.width, base.projectile.height, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex2].noGravity = true; Main.dust[dustIndex2].velocity *= 5f; dustIndex2 = Dust.NewDust(new Vector2(base.projectile.position.X, base.projectile.position.Y), base.projectile.width, base.projectile.height, 6, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex2].velocity *= 3f; } for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(base.projectile.position.X + (float)(base.projectile.width / 2) - 24f, base.projectile.position.Y + (float)(base.projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(base.projectile.position.X + (float)(base.projectile.width / 2) - 24f, base.projectile.position.Y + (float)(base.projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; } base.projectile.position.X = base.projectile.position.X + (float)(base.projectile.width / 2); base.projectile.position.Y = base.projectile.position.Y + (float)(base.projectile.height / 2); base.projectile.width = 10; base.projectile.height = 10; base.projectile.position.X = base.projectile.position.X - (float)(base.projectile.width / 2); base.projectile.position.Y = base.projectile.position.Y - (float)(base.projectile.height / 2); int explosionRadius = 5; int minTileX = (int)(base.projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(base.projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(base.projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(base.projectile.position.Y / 16f + (float)explosionRadius); bool flag = minTileX < 0; if (flag) { minTileX = 0; } bool flag2 = maxTileX > Main.maxTilesX; if (flag2) { maxTileX = Main.maxTilesX; } bool flag3 = minTileY < 0; if (flag3) { minTileY = 0; } bool flag4 = maxTileY > Main.maxTilesY; if (flag4) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - base.projectile.position.X / 16f); float diffY = Math.Abs((float)y - base.projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); bool flag5 = distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0; if (flag5) { canKillWalls = true; break; } } } for (int m = minTileX; m <= maxTileX; m++) { for (int n = minTileY; n <= maxTileY; n++) { float diffX3 = Math.Abs((float)m - base.projectile.position.X / 16f); float diffY3 = Math.Abs((float)n - base.projectile.position.Y / 16f); double distanceToTile2 = Math.Sqrt((double)(diffX3 * diffX3 + diffY3 * diffY3)); bool flag7 = distanceToTile2 < (double)explosionRadius; if (flag7) { bool canKillTile = true; bool flag8 = Main.tile[m, n] != null && Main.tile[m, n].active(); if (flag8) { canKillTile = true; bool flag9 = Main.tileDungeon[(int)Main.tile[m, n].type] || Main.tile[m, n].type == 88 || Main.tile[m, n].type == 21 || Main.tile[m, n].type == 26 || Main.tile[m, n].type == 107 || Main.tile[m, n].type == 108 || Main.tile[m, n].type == 111 || Main.tile[m, n].type == 226 || Main.tile[m, n].type == 237 || Main.tile[m, n].type == 221 || Main.tile[m, n].type == 222 || Main.tile[m, n].type == 223 || Main.tile[m, n].type == 211 || Main.tile[m, n].type == 404; if (flag9) { canKillTile = false; } bool flag10 = !Main.hardMode && Main.tile[m, n].type == 58; if (flag10) { canKillTile = false; } bool flag11 = !TileLoader.CanExplode(m, n); if (flag11) { canKillTile = false; } bool flag12 = canKillTile; if (flag12) { WorldGen.KillTile(m, n, false, false, false); bool flag13 = !Main.tile[m, n].active() && Main.netMode != NetmodeID.SinglePlayer; if (flag13) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)m, (float)n, 0f, 0, 0, 0); } } } bool flag14 = canKillTile; if (flag14) { for (int x2 = m - 1; x2 <= m + 1; x2++) { for (int y2 = n - 1; y2 <= n + 1; y2++) { bool flag15 = Main.tile[x2, y2] != null && Main.tile[x2, y2].wall > 0 && canKillWalls && WallLoader.CanExplode(x2, y2, (int)Main.tile[x2, y2].wall); if (flag15) { WorldGen.KillWall(x2, y2, false); bool flag16 = Main.tile[x2, y2].wall == 0 && Main.netMode != NetmodeID.SinglePlayer; if (flag16) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x2, (float)y2, 0f, 0, 0, 0); } } } } } } } } }
public override void AI() { int dustIndex = Dust.NewDust(projectile.position, 0, 0, 107); Main.dust[dustIndex].noGravity = true; int explosionRadius = 3; int minTileX = (int)(projectile.position.X / 16f - explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs(x - projectile.position.X / 16f); float diffY = Math.Abs(y - projectile.position.Y / 16f); double distance = Math.Sqrt(diffX * diffX + diffY * diffY); if (distance < explosionRadius && Main.tile[x, y]?.wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs(i - projectile.position.X / 16f); float diffY = Math.Abs(j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt(diffX * diffX + diffY * diffY); if (distanceToTile < explosionRadius) { bool canKillTile = true; if (Main.tile[i, j]?.active() == true) { canKillTile = true; if (canKillTile) { WorldGen.KillTile(i, j, false, false, true); if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, i, j); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y]?.wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y]?.wall == 0 && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, x, y); } } } } } } } } AchievementsHelper.CurrentlyMining = false; }
public override void Kill(int timeLeft) { // Play explosion sound Main.PlaySound(mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/WarheadSound"), projectile.position); // Smoke Dust spawn for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } // Fire Dust spawn for (int i = 0; i < 80; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } // Large Smoke Gore spawn for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; } // reset size to normal width and height. projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 10; projectile.height = 10; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); // TODO, tmodloader helper method { int explosionRadius = 75; int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius); // fix to not alter blocks outside of the world if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - projectile.position.X / 16f); float diffY = Math.Abs((float)y - projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - projectile.position.X / 16f); float diffY = Math.Abs((float)j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; //dungeon blocks if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) //hardmode allow destruction of Hellstone { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) //verify if tile can fundamentally be blown up or not { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; } }
public static void Explode(Vector2 position, int explosionRadius = 5) { int minTileX = (int)(position.X / 16f - (float)explosionRadius); int maxTileX = (int)(position.X / 16f + (float)explosionRadius); int minTileY = (int)(position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(position.Y / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - position.X / 16f); float diffY = Math.Abs((float)y - position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - position.X / 16f); float diffY = Math.Abs((float)j - position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; }
public void QueryModOrigin() { Point mouseTile = Main.MouseWorld.ToTileCoordinates(); int closestNPCIndex = -1; float closestNPCDistance = float.MaxValue; for (int l = 0; l < 200; l++) { if (Main.npc[l].active) { float distance = Utils.Distance(Main.npc[l].getRect(), Main.MouseWorld); if (distance < closestNPCDistance) { closestNPCDistance = distance; closestNPCIndex = l; } } } int closestItemIndex = -1; float closestItemDistance = float.MaxValue; for (int i = 0; i < 400; i++) { if (Main.item[i].active) { float distance = Utils.Distance(Main.item[i].getRect(), Main.MouseWorld); if (distance < closestItemDistance) { closestItemDistance = distance; closestItemIndex = i; } } } int hoverBuffIndex = -1; int hoverBuffID = -1; for (int k = 0; k < 22; k++) { if (Main.player[Main.myPlayer].buffType[k] > 0) { int buffID = Main.player[Main.myPlayer].buffType[k]; int buffX = 32 + k * 38; int buffY = 76; if (k >= 11) { buffX = 32 + (k - 11) * 38; buffY += 50; } if (Main.mouseX < buffX + Main.buffTexture[buffID].Width && Main.mouseY <buffY + Main.buffTexture[buffID].Height && Main.mouseX> buffX && Main.mouseY > buffY) { hoverBuffIndex = k; hoverBuffID = buffID; } } } //Top to Bottom: // Hover Buff if (hoverBuffIndex > -1 && !Main.playerInventory) { if (hoverBuffID >= BuffID.Count) { ModBuff hoverBuff = BuffLoader.GetBuff(hoverBuffID); Main.NewText("This buff is from: " + hoverBuff.mod.DisplayName); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ModName: {hoverBuff.mod.Name}, InternalName: {hoverBuff.Name}, FullName: {hoverBuff.GetType().FullName}"); } } else { Main.NewText("This is a vanilla buff."); } } // Item in inventory else if (Main.HoverItem.type > 0 && Main.HoverItem != null) { if (Main.HoverItem.modItem != null) { Main.NewText("This item is from: " + Main.HoverItem.modItem.mod.DisplayName); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ModName: {Main.HoverItem.modItem.mod.Name}, InternalName: {Main.HoverItem.modItem.Name}, FullName: {Main.HoverItem.modItem.GetType().FullName}"); } } else { Main.NewText("This is a vanilla item."); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ItemID: {ItemID.Search.GetName(Main.HoverItem.type)}, ItemID#: {Main.HoverItem.type}"); } } } // NPC else if (closestNPCDistance < 30) { NPC closestNPC = Main.npc[closestNPCIndex]; if (closestNPC.modNPC != null) { Main.NewText("This npc is from: " + closestNPC.modNPC.mod.DisplayName); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ModName: {closestNPC.modNPC.mod.Name}, InternalName: {closestNPC.modNPC.Name}, FullName: {closestNPC.modNPC.GetType().FullName}"); } } else { Main.NewText("This is a vanilla npc."); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: NPCID: {NPCID.Search.GetName(closestNPC.type)}, NPCID#: {closestNPC.type}"); } } } // Tile else if (Main.tile[mouseTile.X, mouseTile.Y].type >= TileID.Count) { ModTile modTile = TileLoader.GetTile(Main.tile[mouseTile.X, mouseTile.Y].type); Main.NewText("This tile is from: " + modTile.mod.DisplayName); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ModName: {modTile.mod.Name}, InternalName: {modTile.Name}, FullName: {modTile.GetType().FullName}"); } //Main.NewText("This tile is active: " + Main.tile[mouseTile.X, mouseTile.Y].active()); //Main.NewText("This tile is inactive: " + Main.tile[mouseTile.X, mouseTile.Y].inActive()); //Main.NewText("This tile is nactive: " + Main.tile[mouseTile.X, mouseTile.Y].nactive()); } // Wall else if (Main.tile[mouseTile.X, mouseTile.Y].wall >= WallID.Count) { ModWall modWall = WallLoader.GetWall(Main.tile[mouseTile.X, mouseTile.Y].wall); Main.NewText("This wall is from: " + modWall.mod.DisplayName); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ModName: {modWall.mod.Name}, InternalName: {modWall.Name}, FullName: {modWall.GetType().FullName}"); } } // Item on ground else if (closestItemDistance < 5) { if (Main.item[closestItemIndex].modItem != null) { ModItem modItem = Main.item[closestItemIndex].modItem; Main.NewText("This item is from: " + modItem.mod.DisplayName); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ModName: {modItem.mod.Name}, InternalName: {modItem.Name}, FullName: {modItem.GetType().FullName}"); } } else { Main.NewText("This is a vanilla item."); if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin) { Main.NewText($"Developer Info: ItemID: {ItemID.Search.GetName(Main.item[closestItemIndex].type)}, ItemID#: {Main.item[closestItemIndex].type}"); } } } // How to Use else if (true) { Main.NewText("Hover over an item, npc, tile, or wall to identify which mod it is from."); } }
public override void PreUpdate() { //if (SGAWorld.CutsceneActive) if (SpaceBoss.film.IsActive || CaliburnGuardianHardmode.film.IsActive) { player.AddBuff(ModContent.BuffType <Buffs.InvincibleBuff>(), 2); } if (!Main.gameMenu) { bool spacey = Spacey; enterlimbo += 1; SGAmod.anysubworld = SGAPocketDim.WhereAmI != null; if (Main.netMode != NetmodeID.Server && !Main.dedServ && Main.LocalPlayer == player) { Projectile.NewProjectile(Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) / 2, Vector2.Zero, mod.ProjectileType("DrawOverride"), 0, 0f); if (spacey) { Projectile.NewProjectile(Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) / 2, Vector2.Zero, mod.ProjectileType("AsteriodDraw"), 0, 0f); } } if (SGAPocketDim.WhereAmI != null) { if (SLWorld.currentSubworld is SGAPocketDim sub) { SLWorld.noReturn = false; int limit = sub.LimitPlayers; if (limit % 16 == 0 && limit > 0) { player.AddBuff(BuffID.NoBuilding, 2); } player.GetModPlayer <SGAPlayer>().noModTeleport = true; if (sub.GetType() == typeof(SpaceDim)) { Point loc = new Point((int)(player.Center.X) >> 4, (int)(player.Center.Y) >> 4); if (WorldGen.InWorld(loc.X, loc.Y)) { Tile tilez = Framing.GetTileSafely(loc.X, loc.Y); if (tilez != null) { if (tilez.wall >= 0) { ModWall wallz = WallLoader.GetWall(tilez.wall); if (wallz != null && wallz is IBreathableWallType) { goto movingOn; } } } } player.AddBuff(ModContent.BuffType <SharkvernDrown>(), 3); } } movingOn: if (spacey) { SLWorld.noReturn = true; player.gravity = 0.12f; if (spacevar < 1)//Arriving in Space now { player.velocity = new Vector2(0, -16); player.Center = new Vector2(spaceX * (Main.maxTilesX * 16f), (Main.maxTilesY * 16f) - (16 * 50)); } if (player.velocity.Y > 0 && player.Center.Y > (Main.maxTilesY * 16f) - (16 * 50) && spacevar == 1) { //SGAPocketDim.EnterSubworld(mod.GetType().Name + "_SpaceDim"); SGAPocketDim.Exit(); } targetedAsteriod = null; if (player.HeldItem.pick > 0) { List <Projectile> allAsteriods2 = Main.projectile.Where(testby => testby.active && testby?.modProjectile is IMineableAsteriod).ToList(); List <Projectile> allAsteriods = new List <Projectile>(); if (allAsteriods2.Count > 0) { foreach (Projectile proj in allAsteriods2) { double length3 = Math.Sqrt((Math.Abs(proj.Center.X - player.Center.X) * Math.Abs(proj.Center.X - player.Center.X)) + (Math.Abs(proj.Center.Y - player.Center.Y) * Math.Abs(proj.Center.Y - player.Center.Y))); if (length3 < (Math.Sqrt(Player.tileRangeX * Player.tileRangeY) + player.blockRange) * 48) { allAsteriods.Add(proj); } } Vector2 from = Main.MouseWorld; if (Main.SmartCursorEnabled) { from = player.MountedCenter + Vector2.Normalize(from) * 16f; } //Main.NewText(allAsteriods.Count); allAsteriods = allAsteriods.OrderBy(testby => ((Math.Abs(from.X - testby.Center.X) * Math.Abs(from.X - testby.Center.X)) + (Math.Abs(from.Y - testby.Center.Y) * Math.Abs(from.Y - testby.Center.Y))) + 0).ToList(); restartHere: if (allAsteriods.Count > 0) { MineableAsteriod targetedasteriod = allAsteriods[0].modProjectile as MineableAsteriod; //double length2 = Math.Sqrt(Math.Abs(targetedasteriod.projectile.Center.X - player.Center.X) * Math.Abs(targetedasteriod.projectile.Center.Y - player.Center.Y)); // if (length2 < (Math.Sqrt(Player.tileRangeX * Player.tileRangeY) + player.blockRange) * 16) // { targetedAsteriod = targetedasteriod; targetedasteriod.miningTargeted = targetedasteriod.miningTargeted + 2; //break; // } } } } spacevar = 1; } if (SGAPocketDim.WhereAmI == typeof(LimboDim)) { SLWorld.noReturn = true; } } else //No subworld entered atm { if (spacevar > 0)//dropping out of Space { player.Center = new Vector2(spaceX * (Main.maxTilesX * 16f), 48); player.velocity = new Vector2(0, 16); } if (player.wings > 0 && player.velocity.Y < 0 && player.Center.Y < (16 * 50) && spacevar == 0 && player.controlJump && !IdgNPC.bossAlive) { SpaceDim.postMoonLord = NPC.downedMoonlord; SGAPocketDim.EnterSubworld(mod.GetType().Name + "_SpaceDim"); } spacevar = 0; } spaceX = player.Center.X / (Main.maxTilesX * 16f); if (SGAPocketDim.WhereAmI == typeof(LimboDim)) { player.AddBuff(Idglib.Instance.BuffType("LimboFading"), 1); if (enterlimbo > 0) { enterlimbo = -6; } if (enterlimbo == -5) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/crack"), new Vector2(-1, -1)); player.Center = new Vector2(Main.rand.Next(200, Main.maxTilesX - 400) * 16, 64); } if (enterlimbo > -2) { enterlimbo = -2; if (Framing.GetTileSafely((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f)).wall == mod.WallType("NullWall") && DimDingeonsWorld.ancientLockedFabric) { enterlimbo = -6; } } } if (SGAPocketDim.WhereAmI == typeof(Limborinth)) { if (Framing.GetTileSafely((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f)).wall == mod.WallType("NullWallBossArena")) { if (NullBossArenaSpot == default) { Idglib.Chat("There's no turning back now...", 120, 15, 15); } NullBossArenaSpot = player.Center; } else { if (NullBossArenaSpot != default) { player.velocity = Vector2.Normalize(NullBossArenaSpot - player.Center) * 12f; player.Center = NullBossArenaSpot; } } } else { NullBossArenaSpot = default; } } }
public override void AI() { if (projectile.owner == Main.myPlayer && projectile.timeLeft == 297) { projectile.position = projectile.Center; projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 0; projectile.height = 0; projectile.Center = projectile.position; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); } else if (projectile.owner == Main.myPlayer && projectile.timeLeft > 297) { projectile.tileCollide = false; // change the hitbox size, centered about the original projectile center. This makes the projectile damage enemies during the explosion. projectile.position = projectile.Center; //projectile.position.X = projectile.position.X + (float)(projectile.width / 2); //projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 300; projectile.height = 300; playerCenterX = projectile.position.X; playerCenterY = projectile.position.Y; projectile.Center = projectile.position; //projectile.position.X = projectile.position.X - (float)(projectile.width / 2); //projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); // Play explosion sound Main.PlaySound(SoundID.Item14, projectile.position); Main.PlaySound(SoundID.Item14, projectile.position); Main.PlaySound(SoundID.Item14, projectile.position); // Smoke Dust spawn for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } // Fire Dust spawn for (int i = 0; i < 80; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } // Large Smoke Gore spawn for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; } { int explosionRadius = 15; int minTileX = (int)(playerCenterX / 16f - (float)explosionRadius); int maxTileX = (int)(playerCenterX / 16f + (float)explosionRadius); int minTileY = (int)(playerCenterY / 16f - (float)explosionRadius); int maxTileY = (int)(playerCenterY / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - playerCenterX / 16f); float diffY = Math.Abs((float)y - playerCenterY / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - playerCenterX / 16f); float diffY = Math.Abs((float)j - playerCenterY / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; } } return; }
public override void AI() { Player player = Main.player[projectile.owner]; if (projectile.timeLeft == 10 || projectile.penetrate == 1) { projectile.position += new Vector2(-50, -50); projectile.width = 150; projectile.height = 150; projectile.timeLeft = 9; projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; projectile.friendly = false; projectile.hostile = true; } if (projectile.timeLeft == 9) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); } if (projectile.timeLeft < 10) { projectile.velocity = new Vector2(0, 0); } if (projectile.timeLeft == 3) { projectile.width = 22; projectile.height = 32; projectile.position += new Vector2(60, 60); } // Adapted a tiny bit from ExampleMod's Example Explosive. if (projectile.timeLeft == 1) { int explosionRadius = 6; int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - projectile.position.X / 16f); float diffY = Math.Abs((float)y - projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - projectile.position.X / 16f); float diffY = Math.Abs((float)j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; } for (int i = 0; i < 2; i++) { int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 63, 0f, 0f, 50, default(Color), 1f); Main.dust[dust].noGravity = true; } Lighting.AddLight(projectile.Center, 0.4f, 0.4f, 0.6f); }
public override void Kill(int timeLeft) { Vector2 position = projectile.Center; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Hallelujah"), (int)position.X, (int)position.Y); for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } for (int i = 0; i < 80; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.GoldFlame, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.GoldFlame, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; } projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 15; projectile.height = 15; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); { int explosionRadius = 15; int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - projectile.position.X / 16f); float diffY = Math.Abs((float)y - projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - projectile.position.X / 16f); float diffY = Math.Abs((float)j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; } }
public override void Kill(int timeLeft) { // If we are the original projectile, spawn the 5 child projectiles if (projectile.ai[1] == 0) { for (int i = 0; i < 5; i++) { // Random upward vector. Vector2 vel = new Vector2(Main.rand.NextFloat(-3, 3), Main.rand.NextFloat(-10, -8)); Projectile.NewProjectile(projectile.Center, vel, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 0, 1); } } // Play explosion sound Main.PlaySound(SoundID.Item15, projectile.position); // Smoke Dust spawn for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } // Fire Dust spawn for (int i = 0; i < 80; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } // Large Smoke Gore spawn for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; } // reset size to normal width and height. projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 10; projectile.height = 10; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); // TODO, tmodloader helper method { int explosionRadius = 3; //if (projectile.type == 29 || projectile.type == 470 || projectile.type == 637) { explosionRadius = 7; } int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - projectile.position.X / 16f); float diffY = Math.Abs((float)y - projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - projectile.position.X / 16f); float diffY = Math.Abs((float)j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; } }
/// <summary> Maing logic for using the renovator. </summary> private bool UseRenovator(Item item, byte paintColour) { // Check to consume the appropriate item if (!CheckUseTile(item)) { return(false); // Can't even use the item anyway } Point?target = null; byte mode = 255; mode = RenovatorUseItemMode(item, mode); target = FindTileTarget(mode, paintColour); // nothing if (target == null) { return(false); } // Place twice as fast float newItemTime = (player.HeldItem.useTime / PlayerHooks.TotalUseTimeMultiplier(player, player.HeldItem)); if (mode == 1) { player.itemTime = (int)(newItemTime * (player.wallSpeed) * 0.5f); } else { player.itemTime = (int)(newItemTime * (player.tileSpeed) * 0.5f); } player.itemTime = Math.Max(1, player.itemTime); Main.PlaySound(7, -1, -1, 1, 1f, 0f); int tileX = target.Value.X; int tileY = target.Value.Y; if (item.createTile >= 0) { byte slope = Main.tile[tileX, tileY].slope(); bool half = Main.tile[tileX, tileY].halfBrick(); WorldGen.PlaceTile(tileX, tileY, item.createTile, false, true, player.whoAmI, item.placeStyle); WorldGen.paintTile(tileX, tileY, 0, true); if (Main.netMode == 1) { NetMessage.SendData(17, -1, -1, null, 1, tileX, tileY, (float)item.createTile, item.placeStyle); } WorldGen.SlopeTile(tileX, tileY, slope); if (Main.netMode == 1) { NetMessage.SendData(17, -1, -1, null, 14, tileX, tileY, 0f); } if (half) { WorldGen.PoundTile(tileX, tileY); if (Main.netMode == 1) { NetMessage.SendData(17, -1, -1, null, 7, tileX, tileY, 1f); } } } else { Main.tile[tileX, tileY].wall = 0; WorldGen.PlaceWall(tileX, tileY, item.createWall, false); WorldGen.paintWall(tileX, tileY, 0, true); WallLoader.PlaceInWorld(tileX, tileY, item); if (Main.netMode == 1) { NetMessage.SendData(17, -1, -1, null, 3, tileX, tileY, (float)item.createWall); } } // Consume the item ConsumeTile(item); return(true); }