/** * Returns true if the given player has any of the given item types in thier inventory. * index : Is set to the index of the item found. If it isn't found, it is set to -1. * counts : the minimum stack per item needed for HasItem to return true. * includeAmmo : true if you wish to include the ammo slots. * includeCoins : true if you wish to include the coin slots. */ public static bool HasItem(Player player, int[] types, ref int index, int[] counts = default(int[]), bool includeAmmo = false, bool includeCoins = false) { if (types == null || types.Length == 0) { return(false); //no types to check! } if (counts == null || counts.Length == 0) { counts = BaseUtility.FillArray(new int[types.Length], 1); } int countIndex = -1; if (includeCoins) { for (int m = 50; m < 54; m++) { Item item = player.inventory[m]; if (item != null && BaseUtility.InArray(types, item.type, ref countIndex) && item.stack >= counts[countIndex]) { index = m; return(true); } } } if (includeAmmo) { for (int m = 54; m < 58; m++) { Item item = player.inventory[m]; if (item != null && BaseUtility.InArray(types, item.type, ref countIndex) && item.stack >= counts[countIndex]) { index = m; return(true); } } } for (int m = 0; m < 50; m++) { Item item = player.inventory[m]; if (item != null && BaseUtility.InArray(types, item.type, ref countIndex) && item.stack >= counts[countIndex]) { index = m; return(true); } } return(false); }
public static Color GetTimedColor(Color tColor, Color color, float min, float max, bool clamp) { Color glowColor = BaseUtility.ColorMult(tColor, BaseUtility.MultiLerp(glowTick / (float)glowMax, min, max, min)); if (clamp) { if (color.R > glowColor.R) { glowColor.R = color.R; } if (color.G > glowColor.G) { glowColor.G = color.G; } if (color.B > glowColor.B) { glowColor.B = color.B; } } return(glowColor); }
/* * Returns the total itemstack sum of a specific item in the player's inventory. * * typeIsAmmo : If true, types are considered ammo types. Else, types are considered item types. */ public static int GetItemstackSum(Player player, int[] types, bool typeIsAmmo = false, bool includeAmmo = false, bool includeCoins = false) { int stackCount = 0; if (includeCoins) { for (int m = 50; m < 54; m++) { Item item = player.inventory[m]; if (item != null && (typeIsAmmo ? BaseUtility.InArray(types, item.ammo) : BaseUtility.InArray(types, item.type))) { stackCount += item.stack; } } } if (includeAmmo) { for (int m = 54; m < 58; m++) { Item item = player.inventory[m]; if (item != null && (typeIsAmmo ? BaseUtility.InArray(types, item.ammo) : BaseUtility.InArray(types, item.type))) { stackCount += item.stack; } } } for (int m = 0; m < 50; m++) { Item item = player.inventory[m]; if (item != null && (typeIsAmmo ? BaseUtility.InArray(types, item.ammo) : BaseUtility.InArray(types, item.type))) { stackCount += item.stack; } } return(stackCount); }
public static Color GetGradientColor(Color tColor1, Color tColor2, Color color, bool clamp) { Color glowColor = Color.Lerp(tColor1, tColor2, BaseUtility.MultiLerp(glowTick / (float)glowMax, 0f, 1f, 0f)); if (clamp) { if (color.R > glowColor.R) { glowColor.R = color.R; } if (color.G > glowColor.G) { glowColor.G = color.G; } if (color.B > glowColor.B) { glowColor.B = color.B; } } return(glowColor); }
public static int GoreType(this Mod mod, string name, IDictionary <string, int> gores = null) { return(BaseUtility.CheckForGore(mod, name, gores)); }
public override bool PreAI(NPC npc) { if (!npc.boss || npc.type != NPCID.WallofFlesh || npc.type != NPCID.SkeletronHand || npc.type != NPCID.DungeonGuardian || npc.type != NPCID.WallofFlesh || npc.type != NPCID.WallofFleshEye || npc.type != NPCID.PrimeCannon || npc.type != NPCID.PrimeLaser || npc.type != NPCID.PrimeSaw || npc.type != NPCID.PrimeVice || npc.type != NPCID.EaterofWorldsBody || npc.type != NPCID.EaterofWorldsTail || npc.type != NPCID.EaterofWorldsHead || npc.type != NPCID.TheDestroyerBody || npc.type != NPCID.TheDestroyerTail || npc.type != NPCID.GolemFistLeft || npc.type != NPCID.GolemFistRight || npc.type != NPCID.GolemHead || npc.type != NPCID.GolemHeadFree || npc.type != NPCID.PlanterasHook || npc.type != NPCID.PlanterasTentacle || npc.type != NPCID.Creeper || npc.type != NPCID.PumpkingBlade || npc.type != NPCID.MartianSaucerCannon || npc.type != NPCID.MartianSaucerCore || npc.type != NPCID.MartianSaucerTurret || npc.type != NPCID.MoonLordCore || npc.type != NPCID.MoonLordFreeEye || npc.type != NPCID.MoonLordHand || npc.type != NPCID.MoonLordHead || npc.type != NPCID.MoonLordLeechBlob || npc.type != NPCID.AncientCultistSquidhead || npc.type != NPCID.CultistBossClone || npc.type != NPCID.CultistDragonBody1 || npc.type != NPCID.CultistDragonBody2 || npc.type != NPCID.CultistDragonBody3 || npc.type != NPCID.CultistDragonBody4 || npc.type != NPCID.CultistDragonHead || npc.type != NPCID.CultistDragonTail || npc.type != NPCID.CultistTablet || npc.type != NPCID.MothronEgg || npc.type != NPCID.MothronSpawn || npc.type != NPCID.Mothron || npc.type != NPCID.PirateShipCannon || npc.type != NPCID.LunarTowerSolar || npc.type != NPCID.LunarTowerNebula || npc.type != NPCID.LunarTowerVortex || npc.type != NPCID.LunarTowerStardust || npc.type != NPCID.AncientLight || npc.type != NPCID.AncientDoom || npc.type != NPCID.SandElemental || npc.type != NPCID.DD2EterniaCrystal || npc.type != NPCID.DD2AttackerTest || npc.type != NPCID.DD2Betsy || npc.type != NPCID.DD2DarkMageT1 || npc.type != NPCID.DD2DarkMageT3 || npc.type != NPCID.DD2DrakinT2 || npc.type != NPCID.DD2DrakinT3 || npc.type != NPCID.DD2GoblinBomberT1 || npc.type != NPCID.DD2GoblinBomberT2 || npc.type != NPCID.DD2GoblinBomberT3 || npc.type != NPCID.DD2GoblinT1 || npc.type != NPCID.DD2GoblinT2 || npc.type != NPCID.DD2GoblinT3 || npc.type != NPCID.DD2JavelinstT1 || npc.type != NPCID.DD2JavelinstT2 || npc.type != NPCID.DD2JavelinstT3 || npc.type != NPCID.DD2KoboldFlyerT2 || npc.type != NPCID.DD2KoboldFlyerT3 || npc.type != NPCID.DD2KoboldWalkerT2 || npc.type != NPCID.DD2KoboldWalkerT3 || npc.type != NPCID.DD2LanePortal || npc.type != NPCID.DD2LightningBugT3 || npc.type != NPCID.DD2OgreT2 || npc.type != NPCID.DD2OgreT3 || npc.type != NPCID.DD2SkeletonT1 || npc.type != NPCID.DD2SkeletonT3 || npc.type != NPCID.DD2WitherBeastT2 || npc.type != NPCID.DD2WitherBeastT3 || npc.type != NPCID.DD2WyvernT1 || npc.type != NPCID.DD2WyvernT2 || npc.type != NPCID.DD2WyvernT3 || npc.type != NPCID.ShadowFlameApparition) { if (TimeFrozen) { npc.position = npc.oldPosition; npc.frameCounter--; return(false); } } Player targetPlayer = Main.player[npc.target]; try { if (npc.type == NPCID.Harpy || npc.type == NPCID.WyvernHead || npc.type == NPCID.MartianProbe) { if (npc.timeLeft > 10 && targetPlayer.GetModPlayer <AAPlayer>(mod).ZoneVoid == true) { npc.timeLeft = 10; } } } catch (Exception e) { BaseUtility.LogFancy("MNPC PREAI ERROR: ", e); } return(true); }
public static bool HasAllItems(Player player, int[] types, ref int[] indicies, int[] counts = default(int[]), bool includeAmmo = false, bool includeCoins = false) { if (types == null || types.Length == 0) { return(false); //no types to check! } if (counts == null || counts.Length == 0) { counts = BaseUtility.FillArray(new int[types.Length], 1); } int[] indexArray = new int[types.Length]; bool[] foundItem = new bool[types.Length]; if (includeCoins) { for (int m = 50; m < 54; m++) { for (int m2 = 0; m2 < types.Length; m2++) { if (foundItem[m2]) { continue; } Item item = player.inventory[m]; if (item != null && item.type == types[m2] && item.stack >= counts[m2]) { foundItem[m2] = true; indexArray[m2] = m; } } } } if (includeAmmo) { for (int m = 54; m < 58; m++) { for (int m2 = 0; m2 < types.Length; m2++) { if (foundItem[m2]) { continue; } Item item = player.inventory[m]; if (item != null && item.type == types[m2] && item.stack >= counts[m2]) { foundItem[m2] = true; indexArray[m2] = m; } } } } for (int m = 0; m < 50; m++) { for (int m2 = 0; m2 < types.Length; m2++) { if (foundItem[m2]) { continue; } Item item = player.inventory[m]; if (item != null && item.type == types[m2] && item.stack >= counts[m2]) { foundItem[m2] = true; indexArray[m2] = m; } } } foreach (bool f in foundItem) { if (!f) { return(false); } } return(true); }
/* * Tints the light color according to the buff color given. (prevents 'darkness' occuring if more than one is applied) */ public static Color BuffColorize(Color buffColor, Color lightColor) { Color color2 = BaseUtility.ColorBrightnessClamp(buffColor, lightColor); return(BaseUtility.ColorClamp(BaseUtility.Colorize(buffColor, lightColor), color2)); }