Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ ItemCheck_CheckCanUse()

bool Terraria.Player.ItemCheck_CheckCanUse ( Item sItem)
inlineprivate

Definition at line 48702 of file Player.cs.

48703 {
48704 int num = whoAmI;
48705 bool flag = true;
48706 int num2 = (int)((float)Main.mouseX + Main.screenPosition.X) / 16;
48707 int num3 = (int)((float)Main.mouseY + Main.screenPosition.Y) / 16;
48708 if (gravDir == -1f)
48709 {
48710 num3 = (int)(Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY) / 16;
48711 }
48712 if (sItem.type == 3335 && (extraAccessory || !Main.expertMode))
48713 {
48714 flag = false;
48715 }
48716 if (pulley && sItem.fishingPole > 0)
48717 {
48718 flag = false;
48719 }
48720 if (pulley && ItemID.Sets.IsAKite[sItem.type])
48721 {
48722 flag = false;
48723 }
48725 {
48726 flag = false;
48727 }
48728 if (sItem.type == 5451 && ownedProjectileCounts[1020] > 0)
48729 {
48730 flag = false;
48731 }
48732 if ((sItem.type == 3611 || sItem.type == 3625) && wireOperationsCooldown > 0)
48733 {
48734 flag = false;
48735 }
48737 {
48738 flag = false;
48739 }
48741 {
48742 flag = false;
48743 }
48744 if (sItem.shoot > -1 && ProjectileID.Sets.IsADD2Turret[sItem.shoot] && DD2Event.Ongoing && num == Main.myPlayer)
48745 {
48747 if (WouldSpotOverlapWithSentry(worldX, worldY, sItem.shoot == 688 || sItem.shoot == 689 || sItem.shoot == 690))
48748 {
48749 flag = false;
48750 }
48751 }
48752 if (sItem.shoot > -1 && ProjectileID.Sets.IsADD2Turret[sItem.shoot] && num == Main.myPlayer)
48753 {
48755 worldX2 /= 16;
48756 worldY2 /= 16;
48757 worldY2--;
48758 if (sItem.shoot == 688 || sItem.shoot == 689 || sItem.shoot == 690)
48759 {
48760 if (Collision.SolidTiles(worldX2, worldX2, worldY2 - 2, worldY2))
48761 {
48762 flag = false;
48763 }
48764 }
48765 else if (WorldGen.SolidTile(worldX2, worldY2))
48766 {
48767 flag = false;
48768 }
48769 }
48770 if (wet && (sItem.shoot == 85 || sItem.shoot == 15 || sItem.shoot == 34))
48771 {
48772 flag = false;
48773 }
48774 if (sItem.makeNPC > 0 && !NPC.CanReleaseNPCs(whoAmI))
48775 {
48776 flag = false;
48777 }
48778 if (whoAmI == Main.myPlayer && sItem.type == 603 && !Main.runningCollectorsEdition)
48779 {
48780 flag = false;
48781 }
48782 if (sItem.type == 1071 || sItem.type == 1072)
48783 {
48784 bool flag2 = false;
48785 for (int i = 0; i < 58; i++)
48786 {
48787 if (inventory[i].PaintOrCoating)
48788 {
48789 flag2 = true;
48790 break;
48791 }
48792 }
48793 if (!flag2)
48794 {
48795 flag = false;
48796 }
48797 }
48798 if (noItems)
48799 {
48800 flag = false;
48801 }
48802 if (sItem.tileWand > 0)
48803 {
48804 int tileWand = sItem.tileWand;
48805 flag = false;
48806 for (int j = 0; j < 58; j++)
48807 {
48808 if (tileWand == inventory[j].type && inventory[j].stack > 0)
48809 {
48810 flag = true;
48811 break;
48812 }
48813 }
48814 }
48815 if (sItem.shoot == 6 || sItem.shoot == 19 || sItem.shoot == 33 || sItem.shoot == 52 || sItem.shoot == 113 || sItem.shoot == 320 || sItem.shoot == 333 || sItem.shoot == 383 || sItem.shoot == 491 || sItem.shoot == 867 || sItem.shoot == 902 || sItem.shoot == 866)
48816 {
48817 for (int k = 0; k < 1000; k++)
48818 {
48819 if (Main.projectile[k].active && Main.projectile[k].owner == Main.myPlayer && Main.projectile[k].type == sItem.shoot)
48820 {
48821 flag = false;
48822 }
48823 }
48824 }
48825 if (sItem.shoot == 106)
48826 {
48827 int num4 = 0;
48828 for (int l = 0; l < 1000; l++)
48829 {
48830 if (Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == sItem.shoot)
48831 {
48832 num4++;
48833 }
48834 }
48835 if (num4 >= 6)
48836 {
48837 flag = false;
48838 }
48839 }
48840 if (sItem.shoot == 272)
48841 {
48842 int num5 = 0;
48843 for (int m = 0; m < 1000; m++)
48844 {
48845 if (Main.projectile[m].active && Main.projectile[m].owner == Main.myPlayer && Main.projectile[m].type == sItem.shoot)
48846 {
48847 num5++;
48848 }
48849 }
48850 if (num5 >= 10)
48851 {
48852 flag = false;
48853 }
48854 }
48855 if (sItem.shoot == 1000)
48856 {
48857 int num6 = 0;
48858 for (int n = 0; n < 1000; n++)
48859 {
48860 if (Main.projectile[n].active && Main.projectile[n].owner == Main.myPlayer && Main.projectile[n].type == sItem.shoot)
48861 {
48862 num6++;
48863 }
48864 }
48865 if (num6 >= 3)
48866 {
48867 flag = false;
48868 }
48869 }
48870 if (sItem.shoot == 13 || sItem.shoot == 32 || (sItem.shoot >= 230 && sItem.shoot <= 235) || sItem.shoot == 315 || sItem.shoot == 331 || sItem.shoot == 372)
48871 {
48872 for (int num7 = 0; num7 < 1000; num7++)
48873 {
48874 if (Main.projectile[num7].active && Main.projectile[num7].owner == Main.myPlayer && Main.projectile[num7].type == sItem.shoot && Main.projectile[num7].ai[0] != 2f)
48875 {
48876 flag = false;
48877 }
48878 }
48879 }
48880 if (sItem.shoot == 332)
48881 {
48882 int num8 = 0;
48883 for (int num9 = 0; num9 < 1000; num9++)
48884 {
48885 if (Main.projectile[num9].active && Main.projectile[num9].owner == Main.myPlayer && Main.projectile[num9].type == sItem.shoot && Main.projectile[num9].ai[0] != 2f)
48886 {
48887 num8++;
48888 }
48889 }
48890 if (num8 >= 3)
48891 {
48892 flag = false;
48893 }
48894 }
48895 if (sItem.potion && potionDelay > 0)
48896 {
48897 flag = false;
48898 }
48899 if (sItem.mana > 0 && silence)
48900 {
48901 flag = false;
48902 }
48903 if (sItem.mana > 0 && flag)
48904 {
48905 flag = ItemCheck_PayMana(sItem, flag);
48906 }
48907 if (sItem.type == 43 && Main.IsItDay())
48908 {
48909 flag = false;
48910 }
48911 if (sItem.type == 544 && Main.IsItDay())
48912 {
48913 flag = false;
48914 }
48915 if (sItem.type == 556 && Main.IsItDay())
48916 {
48917 flag = false;
48918 }
48919 if (sItem.type == 557 && Main.IsItDay())
48920 {
48921 flag = false;
48922 }
48923 if (sItem.type == 70 && !ZoneCorrupt)
48924 {
48925 flag = false;
48926 }
48927 if (sItem.type == 1133 && !ZoneJungle)
48928 {
48929 flag = false;
48930 }
48931 if (sItem.type == 5120 && !ZoneSnow)
48932 {
48933 flag = false;
48934 }
48935 if (sItem.type == 1844 && (Main.dayTime || Main.pumpkinMoon || Main.snowMoon || DD2Event.Ongoing))
48936 {
48937 flag = false;
48938 }
48939 if (sItem.type == 1958 && (Main.dayTime || Main.pumpkinMoon || Main.snowMoon || DD2Event.Ongoing))
48940 {
48941 flag = false;
48942 }
48943 if (sItem.type == 2767 && (!Main.dayTime || Main.eclipse || !Main.hardMode))
48944 {
48945 flag = false;
48946 }
48947 if (sItem.type == 4271 && (Main.dayTime || Main.bloodMoon))
48948 {
48949 flag = false;
48950 }
48951 if (sItem.type == 3601 && (!NPC.downedGolemBoss || !Main.hardMode || NPC.AnyDanger() || NPC.AnyoneNearCultists()))
48952 {
48953 flag = false;
48954 }
48955 if (!SummonItemCheck(sItem))
48956 {
48957 flag = false;
48958 }
48959 if (sItem.shoot == 17 && flag && num == Main.myPlayer && !ItemCheck_IsValidDirtRodTarget(Main.tile[num2, num3]))
48960 {
48961 flag = false;
48962 }
48963 if (sItem.chlorophyteExtractinatorConsumable && flag && num == Main.myPlayer)
48964 {
48965 Tile tile = Main.tile[num2, num3];
48966 if (!tile.active() || (tile.type != 642 && tile.type != 219))
48967 {
48968 flag = false;
48969 }
48970 }
48971 if (sItem.fishingPole > 0)
48972 {
48973 flag = ItemCheck_CheckFishingBobbers(flag);
48974 }
48976 {
48978 }
48979 if (sItem.shoot == 17 && flag && num == Main.myPlayer)
48980 {
48981 if (ItemCheck_IsValidDirtRodTarget(Main.tile[num2, num3]))
48982 {
48984 if (!Main.tile[num2, num3].active())
48985 {
48986 if (Main.netMode == 1)
48987 {
48988 NetMessage.SendData(17, -1, -1, null, 4, num2, num3);
48989 }
48990 }
48991 else
48992 {
48993 flag = false;
48994 }
48995 }
48996 else
48997 {
48998 flag = false;
48999 }
49000 }
49001 if (flag)
49002 {
49003 flag = HasAmmo(sItem, flag);
49004 }
49005 return flag;
49006 }
static bool[] HasAProjectileThatHasAUsabilityCheck
Definition ItemID.cs:148
static bool[] IsAKite
Definition ItemID.cs:130
bool ItemCheck_CheckUsabilityOfProjectiles(bool canUse)
Definition Player.cs:49008
static bool WouldSpotOverlapWithSentry(int worldX, int worldY, bool lightningAura)
Definition Player.cs:49520
bool downedDD2EventAnyDifficulty
Definition Player.cs:1549
int wireOperationsCooldown
Definition Player.cs:2425
void FindSentryRestingSpot(int checkProj, out int worldX, out int worldY, out int pushYUp)
Definition Player.cs:49548
bool CheckDD2CrystalPaymentLock(Item item)
Definition Player.cs:40442
bool extraAccessory
Definition Player.cs:659
bool SummonItemCheck(Item item)
Definition Player.cs:40228
bool ItemCheck_CheckFishingBobbers(bool canUse)
Definition Player.cs:49021
bool HasAmmo(Item sItem, bool canUse)
Definition Player.cs:49951
int[] ownedProjectileCounts
Definition Player.cs:2545
static bool ItemCheck_IsValidDirtRodTarget(Tile t)
Definition Player.cs:49182
Item[] inventory
Definition Player.cs:1257
bool ItemCheck_PayMana(Item sItem, bool canUse)
Definition Player.cs:49195

References Terraria.Tile.active(), Terraria.NPC.AnyDanger(), Terraria.NPC.AnyoneNearCultists(), Terraria.Main.bloodMoon, Terraria.NPC.CanReleaseNPCs(), Terraria.Main.dayTime, Terraria.NPC.downedGolemBoss, Terraria.Main.eclipse, Terraria.Main.expertMode, Terraria.Main.hardMode, Terraria.ID.ItemID.Sets.HasAProjectileThatHasAUsabilityCheck, Terraria.ID.ProjectileID.Sets.IsADD2Turret, Terraria.ID.ItemID.Sets.IsAKite, Terraria.Main.IsItDay(), Terraria.WorldGen.KillTile(), Terraria.Main.mouseY, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.GameContent.Events.DD2Event.Ongoing, Terraria.Main.projectile, Terraria.Main.pumpkinMoon, Terraria.Main.runningCollectorsEdition, Terraria.Main.screenPosition, Terraria.NetMessage.SendData(), Terraria.Main.snowMoon, Terraria.WorldGen.SolidTile(), Terraria.Collision.SolidTiles(), Terraria.Main.tile, Terraria.GameContent.UI.WiresUI.Settings.ToolMode, System.type, and Terraria.Tile.type.

Referenced by Terraria.Player.QuickBuff(), Terraria.Player.QuickGrapple(), Terraria.Player.QuickHeal(), Terraria.Player.QuickMana(), and Terraria.Player.QuickMount().