using CalamityMod.Items.PermanentBoosters; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Tools { public class DisgustingMeat : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Tools"; public override void SetDefaults() { Item.DefaultToFood(32, 30, 0, 0); Item.value = 0; Item.UseSound = SoundID.NPCDeath13; Item.maxStack = 1; Item.consumable = false; } public override bool AltFunctionUse(Player player) => true; public override bool? UseItem(Player player) { if (player.ItemTimeIsZero) { var calPlayer = player.Calamity(); if (player.altFunctionUse == 2) { TryDropBoosterItem(player, ref calPlayer.rageBoostOne, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.rageBoostTwo, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.rageBoostThree, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.adrenalineBoostOne, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.adrenalineBoostTwo, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.adrenalineBoostThree, ModContent.ItemType()); } else { if (calPlayer.sTangerine || calPlayer.mFruit || calPlayer.tCloudberry || calPlayer.sStrawberry) { TryDropBoosterItem(player, ref calPlayer.sTangerine, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.mFruit, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.tCloudberry, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.sStrawberry, ModContent.ItemType()); } else { for (int i = 0; i < player.ConsumedLifeFruit; i++) { int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.LifeFruit); Main.item[drop].noGrabDelay = 100; } player.ConsumedLifeFruit = 0; for (int j = 0; j < player.ConsumedLifeCrystals; j++) { int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.LifeCrystal); Main.item[drop].noGrabDelay = 100; } player.ConsumedLifeCrystals = 0; } if (calPlayer.cShard || calPlayer.eCore || calPlayer.pHeart) { TryDropBoosterItem(player, ref calPlayer.cShard, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.eCore, ModContent.ItemType()); TryDropBoosterItem(player, ref calPlayer.pHeart, ModContent.ItemType()); } else { for (int k = 0; k < player.ConsumedManaCrystals; k++) { int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.ManaCrystal); Main.item[drop].noGrabDelay = 100; } player.ConsumedManaCrystals = 0; } } return true; } return null; } private static void TryDropBoosterItem(Player player, ref bool condition, int itemType) { if (condition) { condition = false; int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, itemType); Main.item[drop].noGrabDelay = 100; } } } }