Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ meteor()

static bool Terraria.WorldGen.meteor ( int i,
int j,
bool ignorePlayers = false )
inlinestatic

Definition at line 2829 of file WorldGen.cs.

2830 {
2831 if (i < 50 || i > Main.maxTilesX - 50)
2832 {
2833 return false;
2834 }
2835 if (j < 50 || j > Main.maxTilesY - 50)
2836 {
2837 return false;
2838 }
2839 int num = 35;
2840 Rectangle rectangle = new Rectangle((i - num) * 16, (j - num) * 16, num * 2 * 16, num * 2 * 16);
2841 for (int k = 0; k < 255; k++)
2842 {
2843 if (Main.player[k].active && !ignorePlayers)
2844 {
2845 Rectangle value = new Rectangle((int)(Main.player[k].position.X + (float)(Main.player[k].width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.player[k].position.Y + (float)(Main.player[k].height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
2846 if (rectangle.Intersects(value))
2847 {
2848 return false;
2849 }
2850 }
2851 }
2852 for (int l = 0; l < 200; l++)
2853 {
2854 if (Main.npc[l].active)
2855 {
2856 Rectangle value2 = new Rectangle((int)Main.npc[l].position.X, (int)Main.npc[l].position.Y, Main.npc[l].width, Main.npc[l].height);
2857 if (rectangle.Intersects(value2))
2858 {
2859 return false;
2860 }
2861 }
2862 }
2863 for (int m = i - num; m < i + num; m++)
2864 {
2865 for (int n = j - num; n < j + num; n++)
2866 {
2867 if (Main.tile[m, n].active())
2868 {
2869 if (TileID.Sets.BasicChest[Main.tile[m, n].type] || Main.tileDungeon[Main.tile[m, n].type])
2870 {
2871 return false;
2872 }
2873 switch (Main.tile[m, n].type)
2874 {
2875 case 226:
2876 case 470:
2877 case 475:
2878 case 488:
2879 case 597:
2880 return false;
2881 }
2882 }
2883 }
2884 }
2885 stopDrops = true;
2886 num = genRand.Next(17, 23);
2887 for (int num2 = i - num; num2 < i + num; num2++)
2888 {
2889 for (int num3 = j - num; num3 < j + num; num3++)
2890 {
2891 if (num3 <= j + Main.rand.Next(-2, 3) - 5)
2892 {
2893 continue;
2894 }
2895 double num4 = Math.Abs(i - num2);
2896 double num5 = Math.Abs(j - num3);
2897 if (Math.Sqrt(num4 * num4 + num5 * num5) < (double)num * 0.9 + (double)Main.rand.Next(-4, 5))
2898 {
2899 if (!Main.tileSolid[Main.tile[num2, num3].type])
2900 {
2901 Main.tile[num2, num3].active(active: false);
2902 }
2903 Main.tile[num2, num3].type = 37;
2904 }
2905 }
2906 }
2907 num = genRand.Next(8, 14);
2908 for (int num6 = i - num; num6 < i + num; num6++)
2909 {
2910 for (int num7 = j - num; num7 < j + num; num7++)
2911 {
2912 if (num7 > j + Main.rand.Next(-2, 3) - 4)
2913 {
2914 double num8 = Math.Abs(i - num6);
2915 double num9 = Math.Abs(j - num7);
2916 if (Math.Sqrt(num8 * num8 + num9 * num9) < (double)num * 0.8 + (double)Main.rand.Next(-3, 4))
2917 {
2918 Main.tile[num6, num7].active(active: false);
2919 }
2920 }
2921 }
2922 }
2923 num = genRand.Next(25, 35);
2924 for (int num10 = i - num; num10 < i + num; num10++)
2925 {
2926 for (int num11 = j - num; num11 < j + num; num11++)
2927 {
2928 double num12 = Math.Abs(i - num10);
2929 double num13 = Math.Abs(j - num11);
2930 if (Math.Sqrt(num12 * num12 + num13 * num13) < (double)num * 0.7)
2931 {
2932 if (TileID.Sets.GetsDestroyedForMeteors[Main.tile[num10, num11].type])
2933 {
2935 }
2936 Main.tile[num10, num11].liquid = 0;
2937 }
2938 if (Main.tile[num10, num11].type == 37)
2939 {
2940 if (!SolidTile(num10 - 1, num11) && !SolidTile(num10 + 1, num11) && !SolidTile(num10, num11 - 1) && !SolidTile(num10, num11 + 1))
2941 {
2942 Main.tile[num10, num11].active(active: false);
2943 }
2944 else if ((Main.tile[num10, num11].halfBrick() || Main.tile[num10 - 1, num11].topSlope()) && !SolidTile(num10, num11 + 1))
2945 {
2946 Main.tile[num10, num11].active(active: false);
2947 }
2948 }
2951 }
2952 }
2953 num = genRand.Next(23, 32);
2954 for (int num14 = i - num; num14 < i + num; num14++)
2955 {
2956 for (int num15 = j - num; num15 < j + num; num15++)
2957 {
2958 if (num15 <= j + genRand.Next(-3, 4) - 3 || !Main.tile[num14, num15].active() || Main.rand.Next(10) != 0)
2959 {
2960 continue;
2961 }
2962 double num16 = Math.Abs(i - num14);
2963 double num17 = Math.Abs(j - num15);
2964 if (Math.Sqrt(num16 * num16 + num17 * num17) < (double)num * 0.8)
2965 {
2966 if (TileID.Sets.GetsDestroyedForMeteors[Main.tile[num14, num15].type])
2967 {
2969 }
2970 Main.tile[num14, num15].type = 37;
2972 }
2973 }
2974 }
2975 num = genRand.Next(30, 38);
2976 for (int num18 = i - num; num18 < i + num; num18++)
2977 {
2978 for (int num19 = j - num; num19 < j + num; num19++)
2979 {
2980 if (num19 <= j + genRand.Next(-2, 3) || !Main.tile[num18, num19].active() || Main.rand.Next(20) != 0)
2981 {
2982 continue;
2983 }
2984 double num20 = Math.Abs(i - num18);
2985 double num21 = Math.Abs(j - num19);
2986 if (Math.Sqrt(num20 * num20 + num21 * num21) < (double)num * 0.85)
2987 {
2988 if (TileID.Sets.GetsDestroyedForMeteors[Main.tile[num18, num19].type])
2989 {
2991 }
2992 Main.tile[num18, num19].type = 37;
2994 }
2995 }
2996 }
2997 stopDrops = false;
2998 if (Main.netMode == 0)
2999 {
3000 Main.NewText(Lang.gen[59].Value, 50, byte.MaxValue, 130);
3001 }
3002 else if (Main.netMode == 2)
3003 {
3004 ChatHelper.BroadcastChatMessage(NetworkText.FromKey(Lang.gen[59].Key), new Color(50, 255, 130));
3005 }
3006 if (Main.netMode != 1)
3007 {
3008 NetMessage.SendTileSquare(-1, i, j, 40);
3009 }
3010 return true;
3011 }
static double Sqrt(double d)
static double Abs(double value)
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:46
static bool[] GetsDestroyedForMeteors
Definition TileID.cs:95
static bool[] BasicChest
Definition TileID.cs:223
static NetworkText FromKey(string key, params object[] substitutions)
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static void SquareWallFrame(int i, int j, bool resetFrame=true)
static void SquareTileFrame(int i, int j, bool resetFrame=true)
static bool stopDrops
Definition WorldGen.cs:1004

References System.Math.Abs(), Terraria.ID.TileID.Sets.BasicChest, Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.Localization.NetworkText.FromKey(), Terraria.Lang.gen, Terraria.WorldGen.genRand, Terraria.ID.TileID.Sets.GetsDestroyedForMeteors, Terraria.WorldGen.KillTile(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.netMode, Terraria.Main.NewText(), Terraria.Main.npc, Terraria.Main.player, Terraria.Main.rand, Terraria.NPC.safeRangeX, Terraria.NPC.safeRangeY, Terraria.NetMessage.SendTileSquare(), Terraria.NPC.sHeight, Terraria.Enums.SolidTile, System.Math.Sqrt(), Terraria.WorldGen.SquareTileFrame(), Terraria.WorldGen.SquareWallFrame(), Terraria.WorldGen.stopDrops, Terraria.NPC.sWidth, Terraria.Main.tile, Terraria.Main.tileDungeon, Terraria.Main.tileSolid, and System.value.

Referenced by Terraria.WorldGen.dropMeteor().