public override bool CanUseItem(Item item, Player player) { var mymod = (NihilismMod)this.mod; var myworld = ModContent.GetInstance <NihilismWorld>(); if (myworld.Logic == null) { LogLibraries.WarnOnce("Logic not loaded."); return(base.CanUseItem(item, player)); } if (!myworld.Logic.AreItemFiltersEnabled()) { return(base.CanUseItem(item, player)); } bool _; if (!myworld.Logic.DataAccess.IsItemEnabled(item, out _, out _)) { return(false); } else if (item.useAmmo != 0) { Item ammoItem = PlayerItemFinderLibraries.GetCurrentAmmo(player, item); if (ammoItem != null) { if (!myworld.Logic.DataAccess.IsItemEnabled(ammoItem, out _, out _)) { return(false); } } } return(base.CanUseItem(item, player)); }
//////////////// /// @private public override void Action(CommandCaller caller, string input, string[] args) { string _; ObjectivesAPI.AddObjective( objective: new FlatObjective( //title: "Kill The Guide", //description: "He's let in one too many zombies", title: "Kill A Blue Slime", description: "What even is a slime?", isImportant: false, condition: (obj) => NPCLibraries.CurrentPlayerKillsOfBannerNpc(NPCID.BlueSlime) > 0 ), order: -1, alertPlayer: false, result: out _ ); ObjectivesAPI.AddObjective( objective: new PercentObjective( title: "Collect 50 Rings", description: "Wrong game.", isImportant: false, units: 50, condition: (obj) => (float)PlayerItemFinderLibraries.CountTotalOfEach( Main.LocalPlayer, new HashSet <int> { ItemID.GoldRing }, false ) / 50f ), order: -1, alertPlayer: false, result: out _ ); ObjectivesAPI.AddObjective( objective: new FlatObjective( title: "Order Pizza", description: "Can't be done.", isImportant: true ), order: -1, alertPlayer: false, result: out _ ); ObjectivesAPI.AddObjective( objective: new FlatObjective( title: "Collect A Blueberry", description: "Don't ask.", isImportant: true, condition: (obj) => (float)PlayerItemFinderLibraries.CountTotalOfEach( Main.LocalPlayer, new HashSet <int> { ItemID.BlueBerries }, false ) > 0 ), order: -1, alertPlayer: false, result: out _ ); ObjectivesAPI.AddObjective( objective: new FlatObjective( title: "Craft A Molotov", description: "Viva la revolution!", isImportant: false, condition: (obj) => (float)PlayerItemFinderLibraries.CountTotalOfEach( Main.LocalPlayer, new HashSet <int> { ItemID.MolotovCocktail }, false ) > 0 ), order: -1, alertPlayer: false, result: out _ ); ObjectivesAPI.AddObjective( objective: new PercentObjective( title: "Kill 10 Squids", description: "Thanks twerking Squidward. Some random squids must be punished now.", isImportant: true, units: 10, condition: (obj) => (float)NPCLibraries.CurrentPlayerKillsOfBannerNpc(NPCID.Squid) / 10f ), order: -1, alertPlayer: false, result: out _ ); ObjectivesAPI.AddObjective( objective: new PercentObjective( title: "Collect 99 Dirt Blocks", description: "Mission impossible?", isImportant: false, units: 99, condition: (obj) => (float)PlayerItemFinderLibraries.CountTotalOfEach( Main.LocalPlayer, new HashSet <int> { ItemID.DirtBlock }, false ) / 99f ), order: -1, alertPlayer: false, result: out _ ); }
public static bool ApplyRepairIf(Player player, Item item) { if (item?.active != true || item.stack == 0) { return(false); } int scrapItemType = ModContent.ItemType <MagitechScrapItem>(); Item scrapItem = PlayerItemFinderLibraries.FindFirstOfPossessedItemFor( player, new HashSet <int> { scrapItemType }, false ); var myScrapItem = scrapItem?.modItem as MagitechScrapItem; if (myScrapItem == null) { Main.NewText("No repair scrap items in player's possession.", Color.Yellow); return(false); } int ruinedPrefixType = ModContent.PrefixType <RuinedPrefix>(); if (item.prefix != ruinedPrefixType) { return(false); } var config = RuinedItemsConfig.Instance; var myitem = item.GetGlobalItem <RuinedItemsItem>(); bool onlyOnce = config.Get <bool>(nameof(config.MagitechScrapAttemptsRepairOnlyOncePerItem)); if (onlyOnce && myitem.IsScrapUsedUpon) { Main.NewText("Cannot repair this with scrap more than once. Use reforging instead.", Color.Yellow); return(false); } if (PlayerItemLibraries.RemoveInventoryItemQuantity(Main.LocalPlayer, scrapItemType, 1) <= 0) { Main.NewText("Could not use player's scrap items for repairing.", Color.Yellow); return(false); } if (Main.rand.NextFloat() < config.Get <float>(nameof(config.MagitechScrapRepairChance))) { float rollChance = config.Get <float>(nameof(config.GeneralRuinRollChance)); config.SetOverride(nameof(config.GeneralRuinRollChance), 0f); item.Prefix(-1); config.SetOverride(nameof(config.GeneralRuinRollChance), rollChance); CombatText.NewText(Main.LocalPlayer.getRect(), Color.Lime, "Repair success!", true); Main.NewText("Repair success!", Color.Lime); } else { CombatText.NewText(Main.LocalPlayer.getRect(), Color.DimGray, "Repair failed!", true); Main.NewText("Repair failed! Item can now only be repaired via. reforging.", Color.OrangeRed); } myitem.IsScrapUsedUpon = true; Main.PlaySound(SoundID.Item37, Main.LocalPlayer.Center); Main.PlaySound(SoundID.Grab, Main.LocalPlayer.Center); return(true); }