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

◆ CheckOrb()

static void Terraria.WorldGen.CheckOrb ( int i,
int j,
int type )
inlinestatic

Definition at line 45792 of file WorldGen.cs.

45793 {
45794 if (Main.tile[i, j] == null)
45795 {
45796 return;
45797 }
45798 short frameX = Main.tile[i, j].frameX;
45799 bool flag = false;
45800 if (frameX >= 36)
45801 {
45802 flag = true;
45803 }
45804 if (destroyObject)
45805 {
45806 return;
45807 }
45808 int num = i;
45809 int num2 = j;
45810 num = ((Main.tile[i, j].frameX != 0 && Main.tile[i, j].frameX != 36) ? (i - 1) : i);
45811 num2 = ((Main.tile[i, j].frameY != 0) ? (j - 1) : j);
45812 for (int k = 0; k < 2; k++)
45813 {
45814 for (int l = 0; l < 2; l++)
45815 {
45816 Tile tile = Main.tile[num + k, num2 + l];
45817 if (tile != null && (!tile.nactive() || tile.type != type))
45818 {
45819 destroyObject = true;
45820 break;
45821 }
45822 }
45823 if (destroyObject)
45824 {
45825 break;
45826 }
45827 if (type == 12 || type == 639)
45828 {
45829 Tile tile = Main.tile[num + k, num2 + 2];
45830 if (tile != null && !SolidTileAllowBottomSlope(num + k, num2 + 2))
45831 {
45832 destroyObject = true;
45833 break;
45834 }
45835 }
45836 }
45837 if (!destroyObject)
45838 {
45839 return;
45840 }
45841 for (int m = num; m < num + 2; m++)
45842 {
45843 for (int n = num2; n < num2 + 2; n++)
45844 {
45845 if (Main.tile[m, n] != null && Main.tile[m, n].type == type)
45846 {
45847 KillTile(m, n);
45848 }
45849 }
45850 }
45851 if (Main.netMode != 1 && !noTileActions)
45852 {
45853 switch (type)
45854 {
45855 case 12:
45856 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 29);
45857 break;
45858 case 639:
45859 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 109);
45860 break;
45861 case 31:
45862 if (flag)
45863 {
45864 int num3 = Main.rand.Next(5);
45865 if (!shadowOrbSmashed)
45866 {
45867 num3 = 0;
45868 }
45869 switch (num3)
45870 {
45871 case 0:
45872 {
45873 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 800, 1, noBroadcast: false, -1);
45874 int stack = genRand.Next(100, 101);
45875 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 97, stack);
45876 break;
45877 }
45878 case 1:
45879 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 1256, 1, noBroadcast: false, -1);
45880 break;
45881 case 2:
45882 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 802, 1, noBroadcast: false, -1);
45883 break;
45884 case 3:
45885 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 3062, 1, noBroadcast: false, -1);
45886 break;
45887 case 4:
45888 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 1290, 1, noBroadcast: false, -1);
45889 break;
45890 }
45891 }
45892 else
45893 {
45894 int num4 = Main.rand.Next(5);
45895 if (!shadowOrbSmashed)
45896 {
45897 num4 = 0;
45898 }
45899 switch (num4)
45900 {
45901 case 0:
45902 {
45903 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 96, 1, noBroadcast: false, -1);
45904 int stack2 = genRand.Next(100, 101);
45905 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 97, stack2);
45906 break;
45907 }
45908 case 1:
45909 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 64, 1, noBroadcast: false, -1);
45910 break;
45911 case 2:
45912 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 162, 1, noBroadcast: false, -1);
45913 break;
45914 case 3:
45915 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 115, 1, noBroadcast: false, -1);
45916 break;
45917 case 4:
45918 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 111, 1, noBroadcast: false, -1);
45919 break;
45920 }
45921 }
45922 shadowOrbSmashed = true;
45924 if (shadowOrbCount >= 3)
45925 {
45926 if (!(NPC.AnyNPCs(266) && flag) && (!NPC.AnyNPCs(13) || flag))
45927 {
45928 shadowOrbCount = 0;
45929 float num5 = num * 16;
45930 float num6 = num2 * 16;
45931 float num7 = -1f;
45932 int plr = 0;
45933 for (int num8 = 0; num8 < 255; num8++)
45934 {
45935 float num9 = Math.Abs(Main.player[num8].position.X - num5) + Math.Abs(Main.player[num8].position.Y - num6);
45936 if (num9 < num7 || num7 == -1f)
45937 {
45938 plr = num8;
45939 num7 = num9;
45940 }
45941 }
45942 if (flag)
45943 {
45944 NPC.SpawnOnPlayer(plr, 266);
45945 }
45946 else
45947 {
45948 NPC.SpawnOnPlayer(plr, 13);
45949 }
45950 }
45951 }
45952 else
45953 {
45954 LocalizedText localizedText = Lang.misc[10];
45955 if (shadowOrbCount == 2)
45956 {
45957 localizedText = Lang.misc[11];
45958 }
45959 if (Main.netMode == 0)
45960 {
45961 Main.NewText(localizedText.ToString(), 50, byte.MaxValue, 130);
45962 }
45963 else if (Main.netMode == 2)
45964 {
45966 }
45967 }
45969 break;
45970 }
45971 }
45972 if (flag)
45973 {
45974 SoundEngine.PlaySound(4, i * 16, j * 16);
45975 }
45976 else
45977 {
45978 SoundEngine.PlaySound(13, i * 16, j * 16);
45979 }
45980 destroyObject = false;
45981 }
static double Abs(double value)
static void PlaySound(int type, Vector2 position, int style=1)
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:46
static NetworkText FromKey(string key, params object[] substitutions)
static bool destroyObject
Definition WorldGen.cs:1020
static int shadowOrbCount
Definition WorldGen.cs:976
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static bool noTileActions
Definition WorldGen.cs:966
static bool SolidTileAllowBottomSlope(int i, int j)
static IEntitySource GetItemSource_FromTileBreak(int x, int y)
static bool shadowOrbSmashed
Definition WorldGen.cs:974

References System.Math.Abs(), Terraria.NPC.AnyNPCs(), Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.Localization.NetworkText.FromKey(), Terraria.Lang.misc, Terraria.Tile.nactive(), Terraria.Main.netMode, Terraria.Item.NewItem(), Terraria.Main.NewText(), Terraria.GameContent.Achievements.AchievementsHelper.NotifyProgressionEvent(), Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.rand, Terraria.NPC.SpawnOnPlayer(), Terraria.Main.tile, and System.type.