From e3b898ffbcc63bed15372e1feb259f33f393f321 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Thu, 9 Apr 2020 22:07:45 -0400 Subject: [PATCH] Added "get calamity rarity" Mod.Call --- ModSupport/ModCalls.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 35349c9fad..e38e208146 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -4,6 +4,7 @@ using CalamityMod.Items; using CalamityMod.Projectiles; using CalamityMod.World; using System; +using System.Runtime.InteropServices.WindowsRuntime; using Terraria; namespace CalamityMod @@ -1333,6 +1334,15 @@ namespace CalamityMod #endregion #region Item Rarity + public static int GetCalamityRarity(Item item) + { + CalamityGlobalItem cgi = item.Calamity(); + CalamityRarity calrare = cgi.customRarity; + if (calrare == CalamityRarity.NoEffect) + return item.rare; + return (int)calrare; + } + public static bool SetCalamityRarity(Item item, int rarityNum) { CalamityGlobalItem cgi = item.Calamity(); @@ -1646,6 +1656,18 @@ namespace CalamityMod return new ArgumentNullException("ERROR: Must specify a bool."); return SetBossHealthBarVisible(bossBarEnabled); + case "GetRarity": + case "GetItemRarity": + case "GetCalamityRarity": + case "GetPostMLRarity": + case "GetPostMoonLordRarity": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify an Item."); + if (!(args[1] is Item)) + return new ArgumentException("ERROR: The first argument to \"GetCalamityRarity\" must be an Item."); + Item itemToGet = (Item)args[1]; + return GetCalamityRarity(itemToGet); + case "SetRarity": case "SetItemRarity": case "SetCalamityRarity": @@ -1660,9 +1682,9 @@ namespace CalamityMod if (!(args[1] is Item)) return new ArgumentException("ERROR: The first argument to \"SetCalamityRarity\" must be an Item."); - Item item = (Item)args[1]; + Item itemToSet = (Item)args[1]; int rarity = (int)args[2]; - return SetCalamityRarity(item, rarity); + return SetCalamityRarity(itemToSet, rarity); case "AbominationnClearEvents": bool eventActive = CalamityWorld.rainingAcid;